0?1:-1,h.push(K.x,K.y,K.z),u.push(He/A),u.push(1-ne/I),te+=1}}for(let ne=0;ne{alert("Status updated!")},t.appendChild(i),t.appendChild(s),t.appendChild(r),super({container:e,title:"dialog.testTitle",content:t,width:320,height:"auto",position:"center",resizable:!0,draggable:!0,onClose:()=>{console.log("Info dialog closed")},onOpen:()=>{console.log("Info dialog opened")}})}}class tu extends jt{container;activeDialogs=[];constructor(e,t){super(e),this.container=t,this.on("ui:open-dialog",i=>{console.log("[DialogManager] Received open-dialog event:",i),i.id==="info"&&this.showInfoDialog()})}create(e){const t=new ol({container:this.container,...e,onClose:()=>{this.activeDialogs=this.activeDialogs.filter(i=>i!==t),e.onClose&&e.onClose()}});return t.setTheme(Ze.getTheme()),this.activeDialogs.push(t),t}showInfoDialog(){new eu(this.container)}updateTheme(e){this.activeDialogs.forEach(t=>{t.setTheme&&t.setTheme(e)})}destroy(){this.activeDialogs.forEach(e=>e.destroy()),this.activeDialogs=[]}}const Ms={ROTATE:0,DOLLY:1,PAN:2},Ss={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},iu=0,ll=1,su=2,cl=1,hl=2,Ui=3,Si=0,zt=1,Xt=2,bt=0,Ts=1,zn=2,ul=3,dl=4,pl=5,ai=100,nu=101,ru=102,au=103,ou=104,un=200,lu=201,cu=202,hu=203,Hr=204,Vr=205,Gr=206,uu=207,Wr=208,du=209,pu=210,mu=211,fu=212,gu=213,vu=214,jr=0,Xr=1,qr=2,Es=3,Zr=4,Yr=5,Kr=6,$r=7,Jr=0,_u=1,xu=2,qi=0,ml=1,fl=2,gl=3,Qr=4,vl=5,_l=6,xl=7,bl="attached",bu="detached",yl=300,ws=301,Cs=302,Hn=303,ea=304,Vn=306,Ti=1e3,ei=1001,Gn=1002,Ut=1003,Ml=1004,dn=1005,yt=1006,Wn=1007,Ei=1008,oi=1009,Sl=1010,Tl=1011,pn=1012,ta=1013,os=1014,qt=1015,ft=1016,ia=1017,sa=1018,As=1020,El=35902,wl=35899,Cl=1021,Al=1022,Kt=1023,mn=1026,Rs=1027,na=1028,ra=1029,aa=1030,oa=1031,la=1033,jn=33776,Xn=33777,qn=33778,Zn=33779,ca=35840,ha=35841,ua=35842,da=35843,pa=36196,ma=37492,fa=37496,ga=37808,va=37809,_a=37810,xa=37811,ba=37812,ya=37813,Ma=37814,Sa=37815,Ta=37816,Ea=37817,wa=37818,Ca=37819,Aa=37820,Ra=37821,Pa=36492,La=36494,Da=36495,Ia=36283,Ua=36284,Na=36285,Ba=36286,fn=2300,gn=2301,Oa=2302,Rl=2400,Pl=2401,Ll=2402,yu=2500,Mu=0,Dl=1,ka=2,Su=3200,Il=3201,Yn=0,Tu=1,Zi="",At="srgb",Ot="srgb-linear",Kn="linear",it="srgb",Ps=7680,Fa=34055,za=34056,Eu=517,Ha=519,wu=512,Cu=513,Au=514,Ul=515,Ru=516,Pu=517,Lu=518,Du=519,Va=35044,Nl="300 es",wi=2e3,$n=2001;function Bl(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function vn(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function Iu(){const n=vn("canvas");return n.style.display="block",n}const Ol={};function Jn(...n){const e="THREE."+n.shift();console.log(e,...n)}function Me(...n){const e="THREE."+n.shift();console.warn(e,...n)}function Ve(...n){const e="THREE."+n.shift();console.error(e,...n)}function _n(...n){const e=n.join(" ");e in Ol||(Ol[e]=!0,Me(...n))}function Uu(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}class ls{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,a=s.length;r>8&255]+kt[n>>16&255]+kt[n>>24&255]+"-"+kt[e&255]+kt[e>>8&255]+"-"+kt[e>>16&15|64]+kt[e>>24&255]+"-"+kt[t&63|128]+kt[t>>8&255]+"-"+kt[t>>16&255]+kt[t>>24&255]+kt[i&255]+kt[i>>8&255]+kt[i>>16&255]+kt[i>>24&255]).toLowerCase()}function Fe(n,e,t){return Math.max(e,Math.min(t,n))}function Ga(n,e){return(n%e+e)%e}function Nu(n,e,t,i,s){return i+(n-e)*(s-i)/(t-e)}function Bu(n,e,t){return n!==e?(t-n)/(e-n):0}function bn(n,e,t){return(1-t)*n+t*e}function Ou(n,e,t,i){return bn(n,e,1-Math.exp(-t*i))}function ku(n,e=1){return e-Math.abs(Ga(n,e*2)-e)}function Fu(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function zu(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function Hu(n,e){return n+Math.floor(Math.random()*(e-n+1))}function Vu(n,e){return n+Math.random()*(e-n)}function Gu(n){return n*(.5-Math.random())}function Wu(n){n!==void 0&&(kl=n);let e=kl+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function ju(n){return n*xn}function Xu(n){return n*Ls}function qu(n){return(n&n-1)===0&&n!==0}function Zu(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Yu(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Ku(n,e,t,i,s){const r=Math.cos,a=Math.sin,o=r(t/2),l=a(t/2),c=r((e+i)/2),h=a((e+i)/2),u=r((e-i)/2),d=a((e-i)/2),m=r((i-e)/2),g=a((i-e)/2);switch(s){case"XYX":n.set(o*h,l*u,l*d,o*c);break;case"YZY":n.set(l*d,o*h,l*u,o*c);break;case"ZXZ":n.set(l*u,l*d,o*h,o*c);break;case"XZX":n.set(o*h,l*g,l*m,o*c);break;case"YXY":n.set(l*m,o*h,l*g,o*c);break;case"ZYZ":n.set(l*g,l*m,o*h,o*c);break;default:Me("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function ci(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function st(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const Wa={DEG2RAD:xn,RAD2DEG:Ls,generateUUID:li,clamp:Fe,euclideanModulo:Ga,mapLinear:Nu,inverseLerp:Bu,lerp:bn,damp:Ou,pingpong:ku,smoothstep:Fu,smootherstep:zu,randInt:Hu,randFloat:Vu,randFloatSpread:Gu,seededRandom:Wu,degToRad:ju,radToDeg:Xu,isPowerOfTwo:qu,ceilPowerOfTwo:Zu,floorPowerOfTwo:Yu,setQuaternionFromProperEuler:Ku,normalize:st,denormalize:ci};class oe{constructor(e=0,t=0){oe.prototype.isVector2=!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 new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[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=Fe(this.x,e.x,t.x),this.y=Fe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Fe(this.x,e,t),this.y=Fe(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Fe(i,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){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Fe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,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){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class hi{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let l=i[s+0],c=i[s+1],h=i[s+2],u=i[s+3],d=r[a+0],m=r[a+1],g=r[a+2],v=r[a+3];if(o<=0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u;return}if(o>=1){e[t+0]=d,e[t+1]=m,e[t+2]=g,e[t+3]=v;return}if(u!==v||l!==d||c!==m||h!==g){let f=l*d+c*m+h*g+u*v;f<0&&(d=-d,m=-m,g=-g,v=-v,f=-f);let p=1-o;if(f<.9995){const b=Math.acos(f),_=Math.sin(b);p=Math.sin(p*b)/_,o=Math.sin(o*b)/_,l=l*p+d*o,c=c*p+m*o,h=h*p+g*o,u=u*p+v*o}else{l=l*p+d*o,c=c*p+m*o,h=h*p+g*o,u=u*p+v*o;const b=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=b,c*=b,h*=b,u*=b}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],l=i[s+1],c=i[s+2],h=i[s+3],u=r[a],d=r[a+1],m=r[a+2],g=r[a+3];return e[t]=o*g+h*u+l*m-c*d,e[t+1]=l*g+h*d+c*u-o*m,e[t+2]=c*g+h*m+o*d-l*u,e[t+3]=h*g-o*u-l*d-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,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){const i=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),h=o(s/2),u=o(r/2),d=l(i/2),m=l(s/2),g=l(r/2);switch(a){case"XYZ":this._x=d*h*u+c*m*g,this._y=c*m*u-d*h*g,this._z=c*h*g+d*m*u,this._w=c*h*u-d*m*g;break;case"YXZ":this._x=d*h*u+c*m*g,this._y=c*m*u-d*h*g,this._z=c*h*g-d*m*u,this._w=c*h*u+d*m*g;break;case"ZXY":this._x=d*h*u-c*m*g,this._y=c*m*u+d*h*g,this._z=c*h*g+d*m*u,this._w=c*h*u-d*m*g;break;case"ZYX":this._x=d*h*u-c*m*g,this._y=c*m*u+d*h*g,this._z=c*h*g-d*m*u,this._w=c*h*u+d*m*g;break;case"YZX":this._x=d*h*u+c*m*g,this._y=c*m*u+d*h*g,this._z=c*h*g-d*m*u,this._w=c*h*u-d*m*g;break;case"XZY":this._x=d*h*u-c*m*g,this._y=c*m*u-d*h*g,this._z=c*h*g+d*m*u,this._w=c*h*u+d*m*g;break;default:Me("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],u=t[10],d=i+o+u;if(d>0){const m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(h-l)*m,this._y=(r-c)*m,this._z=(a-s)*m}else if(i>o&&i>u){const m=2*Math.sqrt(1+i-o-u);this._w=(h-l)/m,this._x=.25*m,this._y=(s+a)/m,this._z=(r+c)/m}else if(o>u){const m=2*Math.sqrt(1+o-i-u);this._w=(r-c)/m,this._x=(s+a)/m,this._y=.25*m,this._z=(l+h)/m}else{const m=2*Math.sqrt(1+u-i-o);this._w=(a-s)/m,this._x=(r+c)/m,this._y=(l+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Fe(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=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){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=i*h+a*o+s*c-r*l,this._y=s*h+a*l+r*o-i*c,this._z=r*h+a*c+i*l-s*o,this._w=a*h-i*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let i=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class w{constructor(e=0,t=0,i=0){w.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,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 new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Fl.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Fl.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*i),h=2*(o*t-r*s),u=2*(r*i-a*t);return this.x=t+l*c+a*u-o*h,this.y=i+l*h+o*c-r*u,this.z=s+l*u+r*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,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=Fe(this.x,e.x,t.x),this.y=Fe(this.y,e.y,t.y),this.z=Fe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Fe(this.x,e,t),this.y=Fe(this.y,e,t),this.z=Fe(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Fe(i,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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return ja.copy(this).projectOnVector(e),this.sub(ja)}reflect(e){return this.sub(ja.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Fe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}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,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ja=new w,Fl=new hi;class ke{constructor(e,t,i,s,r,a,o,l,c){ke.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c)}set(e,t,i,s,r,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,h[4]=r,h[5]=l,h[6]=i,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const 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){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],h=i[4],u=i[7],d=i[2],m=i[5],g=i[8],v=s[0],f=s[3],p=s[6],b=s[1],_=s[4],E=s[7],R=s[2],T=s[5],A=s[8];return r[0]=a*v+o*b+l*R,r[3]=a*f+o*_+l*T,r[6]=a*p+o*E+l*A,r[1]=c*v+h*b+u*R,r[4]=c*f+h*_+u*T,r[7]=c*p+h*E+u*A,r[2]=d*v+m*b+g*R,r[5]=d*f+m*_+g*T,r[8]=d*p+m*E+g*A,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-i*r*h+i*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,d=o*l-h*r,m=c*r-a*l,g=t*u+i*d+s*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return e[0]=u*v,e[1]=(s*c-h*i)*v,e[2]=(o*i-s*a)*v,e[3]=d*v,e[4]=(h*t-s*l)*v,e[5]=(s*r-o*t)*v,e[6]=m*v,e[7]=(i*l-c*t)*v,e[8]=(a*t-i*r)*v,this}transpose(){let e;const 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){const 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,i,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Xa.makeScale(e,t)),this}rotate(e){return this.premultiply(Xa.makeRotation(-e)),this}translate(e,t){return this.premultiply(Xa.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){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Xa=new ke,zl=new ke().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Hl=new ke().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function $u(){const n={enabled:!0,workingColorSpace:Ot,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===it&&(s.r=Ni(s.r),s.g=Ni(s.g),s.b=Ni(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===it&&(s.r=Ds(s.r),s.g=Ds(s.g),s.b=Ds(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Zi?Kn:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return _n("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return _n("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Ot]:{primaries:e,whitePoint:i,transfer:Kn,toXYZ:zl,fromXYZ:Hl,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:At},outputColorSpaceConfig:{drawingBufferColorSpace:At}},[At]:{primaries:e,whitePoint:i,transfer:it,toXYZ:zl,fromXYZ:Hl,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:At}}}),n}const Xe=$u();function Ni(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Ds(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Is;class Ju{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Is===void 0&&(Is=vn("canvas")),Is.width=e.width,Is.height=e.height;const s=Is.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=Is}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=vn("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0}get width(){return this.source.getSize(Ya).x}get height(){return this.source.getSize(Ya).y}get depth(){return this.source.getSize(Ya).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Me(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Me(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==yl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ti:e.x=e.x-Math.floor(e.x);break;case ei:e.x=e.x<0?0:1;break;case Gn:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ti:e.y=e.y-Math.floor(e.y);break;case ei:e.y=e.y<0?0:1;break;case Gn:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Rt.DEFAULT_IMAGE=null,Rt.DEFAULT_MAPPING=yl,Rt.DEFAULT_ANISOTROPY=1;class $e{constructor(e=0,t=0,i=0,s=1){$e.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=s}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,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,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 new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?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){const t=this.x,i=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*s+a[15]*r,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);const 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,i,s,r;const a=e.elements,o=a[0],l=a[4],c=a[8],h=a[1],u=a[5],d=a[9],m=a[2],g=a[6],v=a[10];if(Math.abs(l-h)<.01&&Math.abs(c-m)<.01&&Math.abs(d-g)<.01){if(Math.abs(l+h)<.1&&Math.abs(c+m)<.1&&Math.abs(d+g)<.1&&Math.abs(o+u+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const p=(o+1)/2,b=(u+1)/2,_=(v+1)/2,E=(l+h)/4,R=(c+m)/4,T=(d+g)/4;return p>b&&p>_?p<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(p),s=E/i,r=R/i):b>_?b<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(b),i=E/s,r=T/s):_<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(_),i=R/r,s=T/r),this.set(i,s,r,t),this}let f=Math.sqrt((g-d)*(g-d)+(c-m)*(c-m)+(h-l)*(h-l));return Math.abs(f)<.001&&(f=1),this.x=(g-d)/f,this.y=(c-m)/f,this.z=(h-l)/f,this.w=Math.acos((o+u+v-1)/2),this}setFromMatrixPosition(e){const 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=Fe(this.x,e.x,t.x),this.y=Fe(this.y,e.y,t.y),this.z=Fe(this.z,e.z,t.z),this.w=Fe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Fe(this.x,e,t),this.y=Fe(this.y,e,t),this.z=Fe(this.z,e,t),this.w=Fe(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Fe(i,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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,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}}class td extends ls{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new $e(0,0,e,t),this.scissorTest=!1,this.viewport=new $e(0,0,e,t);const s={width:e,height:t,depth:i.depth},r=new Rt(s);this.textures=[];const a=i.count;for(let o=0;o1);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,i=e.textures.length;t=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,ui),ui.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(yn),er.subVectors(this.max,yn),Us.subVectors(e.a,yn),Ns.subVectors(e.b,yn),Bs.subVectors(e.c,yn),Yi.subVectors(Ns,Us),Ki.subVectors(Bs,Ns),cs.subVectors(Us,Bs);let t=[0,-Yi.z,Yi.y,0,-Ki.z,Ki.y,0,-cs.z,cs.y,Yi.z,0,-Yi.x,Ki.z,0,-Ki.x,cs.z,0,-cs.x,-Yi.y,Yi.x,0,-Ki.y,Ki.x,0,-cs.y,cs.x,0];return!Ka(t,Us,Ns,Bs,er)||(t=[1,0,0,0,1,0,0,0,1],!Ka(t,Us,Ns,Bs,er))?!1:(tr.crossVectors(Yi,Ki),t=[tr.x,tr.y,tr.z],Ka(t,Us,Ns,Bs,er))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ui).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ui).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Bi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Bi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Bi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Bi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Bi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Bi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Bi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Bi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Bi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Bi=[new w,new w,new w,new w,new w,new w,new w,new w],ui=new w,Qn=new Pt,Us=new w,Ns=new w,Bs=new w,Yi=new w,Ki=new w,cs=new w,yn=new w,er=new w,tr=new w,hs=new w;function Ka(n,e,t,i,s){for(let r=0,a=n.length-3;r<=a;r+=3){hs.fromArray(n,r);const o=s.x*Math.abs(hs.x)+s.y*Math.abs(hs.y)+s.z*Math.abs(hs.z),l=e.dot(hs),c=t.dot(hs),h=i.dot(hs);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const sd=new Pt,Mn=new w,$a=new w;class Ci{constructor(e=new w,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){const i=this.center;t!==void 0?i.copy(t):sd.setFromPoints(e).getCenter(i);let s=0;for(let r=0,a=e.length;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=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;Mn.subVectors(e,this.center);const t=Mn.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(Mn,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):($a.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Mn.copy(e.center).add($a)),this.expandByPoint(Mn.copy(e.center).sub($a))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const Oi=new w,Ja=new w,ir=new w,$i=new w,Qa=new w,sr=new w,eo=new w;class Os{constructor(e=new w,t=new w(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,Oi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Oi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Oi.copy(this.origin).addScaledVector(this.direction,t),Oi.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){Ja.copy(e).add(t).multiplyScalar(.5),ir.copy(t).sub(e).normalize(),$i.copy(this.origin).sub(Ja);const r=e.distanceTo(t)*.5,a=-this.direction.dot(ir),o=$i.dot(this.direction),l=-$i.dot(ir),c=$i.lengthSq(),h=Math.abs(1-a*a);let u,d,m,g;if(h>0)if(u=a*l-o,d=a*o-l,g=r*h,u>=0)if(d>=-g)if(d<=g){const v=1/h;u*=v,d*=v,m=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=r,u=Math.max(0,-(a*d+o)),m=-u*u+d*(d+2*l)+c;else d=-r,u=Math.max(0,-(a*d+o)),m=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-l),r),m=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-r,-l),r),m=d*(d+2*l)+c):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-l),r),m=-u*u+d*(d+2*l)+c);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),m=-u*u+d*(d+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Ja).addScaledVector(ir,d),m}intersectSphere(e,t){Oi.subVectors(e.center,this.origin);const i=Oi.dot(this.direction),s=Oi.dot(Oi)-i*i,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,s=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,s=(e.min.x-d.x)*c),h>=0?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),i>a||r>s||((r>i||isNaN(i))&&(i=r),(a =0?(o=(e.min.z-d.z)*u,l=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),i>l||o>s)||((o>i||i!==i)&&(i=o),(l=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,Oi)!==null}intersectTriangle(e,t,i,s,r){Qa.subVectors(t,e),sr.subVectors(i,e),eo.crossVectors(Qa,sr);let a=this.direction.dot(eo),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;$i.subVectors(this.origin,e);const l=o*this.direction.dot(sr.crossVectors($i,sr));if(l<0)return null;const c=o*this.direction.dot(Qa.cross($i));if(c<0||l+c>a)return null;const h=-o*$i.dot(eo);return h<0?null:this.at(h/a,r)}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)}}class De{constructor(e,t,i,s,r,a,o,l,c,h,u,d,m,g,v,f){De.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c,h,u,d,m,g,v,f)}set(e,t,i,s,r,a,o,l,c,h,u,d,m,g,v,f){const p=this.elements;return p[0]=e,p[4]=t,p[8]=i,p[12]=s,p[1]=r,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=h,p[10]=u,p[14]=d,p[3]=m,p[7]=g,p[11]=v,p[15]=f,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 De().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const 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,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,s=1/ks.setFromMatrixColumn(e,0).length(),r=1/ks.setFromMatrixColumn(e,1).length(),a=1/ks.setFromMatrixColumn(e,2).length();return t[0]=i[0]*s,t[1]=i[1]*s,t[2]=i[2]*s,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,s=e.y,r=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const d=a*h,m=a*u,g=o*h,v=o*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=m+g*c,t[5]=d-v*c,t[9]=-o*l,t[2]=v-d*c,t[6]=g+m*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*h,m=l*u,g=c*h,v=c*u;t[0]=d+v*o,t[4]=g*o-m,t[8]=a*c,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=m*o-g,t[6]=v+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*h,m=l*u,g=c*h,v=c*u;t[0]=d-v*o,t[4]=-a*u,t[8]=g+m*o,t[1]=m+g*o,t[5]=a*h,t[9]=v-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*h,m=a*u,g=o*h,v=o*u;t[0]=l*h,t[4]=g*c-m,t[8]=d*c+v,t[1]=l*u,t[5]=v*c+d,t[9]=m*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,m=a*c,g=o*l,v=o*c;t[0]=l*h,t[4]=v-d*u,t[8]=g*u+m,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=m*u+g,t[10]=d-v*u}else if(e.order==="XZY"){const d=a*l,m=a*c,g=o*l,v=o*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=d*u+v,t[5]=a*h,t[9]=m*u-g,t[2]=g*u-m,t[6]=o*h,t[10]=v*u+d}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(nd,e,rd)}lookAt(e,t,i){const s=this.elements;return $t.subVectors(e,t),$t.lengthSq()===0&&($t.z=1),$t.normalize(),Ji.crossVectors(i,$t),Ji.lengthSq()===0&&(Math.abs(i.z)===1?$t.x+=1e-4:$t.z+=1e-4,$t.normalize(),Ji.crossVectors(i,$t)),Ji.normalize(),nr.crossVectors($t,Ji),s[0]=Ji.x,s[4]=nr.x,s[8]=$t.x,s[1]=Ji.y,s[5]=nr.y,s[9]=$t.y,s[2]=Ji.z,s[6]=nr.z,s[10]=$t.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],h=i[1],u=i[5],d=i[9],m=i[13],g=i[2],v=i[6],f=i[10],p=i[14],b=i[3],_=i[7],E=i[11],R=i[15],T=s[0],A=s[4],I=s[8],S=s[12],M=s[1],L=s[5],N=s[9],z=s[13],H=s[2],j=s[6],q=s[10],te=s[14],G=s[3],K=s[7],ne=s[11],Le=s[15];return r[0]=a*T+o*M+l*H+c*G,r[4]=a*A+o*L+l*j+c*K,r[8]=a*I+o*N+l*q+c*ne,r[12]=a*S+o*z+l*te+c*Le,r[1]=h*T+u*M+d*H+m*G,r[5]=h*A+u*L+d*j+m*K,r[9]=h*I+u*N+d*q+m*ne,r[13]=h*S+u*z+d*te+m*Le,r[2]=g*T+v*M+f*H+p*G,r[6]=g*A+v*L+f*j+p*K,r[10]=g*I+v*N+f*q+p*ne,r[14]=g*S+v*z+f*te+p*Le,r[3]=b*T+_*M+E*H+R*G,r[7]=b*A+_*L+E*j+R*K,r[11]=b*I+_*N+E*q+R*ne,r[15]=b*S+_*z+E*te+R*Le,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],i=e[4],s=e[8],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],u=e[6],d=e[10],m=e[14],g=e[3],v=e[7],f=e[11],p=e[15];return g*(+r*l*u-s*c*u-r*o*d+i*c*d+s*o*m-i*l*m)+v*(+t*l*m-t*c*d+r*a*d-s*a*m+s*c*h-r*l*h)+f*(+t*c*u-t*o*m-r*a*u+i*a*m+r*o*h-i*c*h)+p*(-s*o*h-t*l*u+t*o*d+s*a*u-i*a*d+i*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],m=e[11],g=e[12],v=e[13],f=e[14],p=e[15],b=u*f*c-v*d*c+v*l*m-o*f*m-u*l*p+o*d*p,_=g*d*c-h*f*c-g*l*m+a*f*m+h*l*p-a*d*p,E=h*v*c-g*u*c+g*o*m-a*v*m-h*o*p+a*u*p,R=g*u*l-h*v*l-g*o*d+a*v*d+h*o*f-a*u*f,T=t*b+i*_+s*E+r*R;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/T;return e[0]=b*A,e[1]=(v*d*r-u*f*r-v*s*m+i*f*m+u*s*p-i*d*p)*A,e[2]=(o*f*r-v*l*r+v*s*c-i*f*c-o*s*p+i*l*p)*A,e[3]=(u*l*r-o*d*r-u*s*c+i*d*c+o*s*m-i*l*m)*A,e[4]=_*A,e[5]=(h*f*r-g*d*r+g*s*m-t*f*m-h*s*p+t*d*p)*A,e[6]=(g*l*r-a*f*r-g*s*c+t*f*c+a*s*p-t*l*p)*A,e[7]=(a*d*r-h*l*r+h*s*c-t*d*c-a*s*m+t*l*m)*A,e[8]=E*A,e[9]=(g*u*r-h*v*r-g*i*m+t*v*m+h*i*p-t*u*p)*A,e[10]=(a*v*r-g*o*r+g*i*c-t*v*c-a*i*p+t*o*p)*A,e[11]=(h*o*r-a*u*r-h*i*c+t*u*c+a*i*m-t*o*m)*A,e[12]=R*A,e[13]=(h*v*s-g*u*s+g*i*d-t*v*d-h*i*f+t*u*f)*A,e[14]=(g*o*s-a*v*s-g*i*l+t*v*l+a*i*f-t*o*f)*A,e[15]=(a*u*s-h*o*s+h*i*l-t*u*l-a*i*d+t*o*d)*A,this}scale(e){const t=this.elements,i=e.x,s=e.y,r=e.z;return t[0]*=i,t[4]*=s,t[8]*=r,t[1]*=i,t[5]*=s,t[9]*=r,t[2]*=i,t[6]*=s,t[10]*=r,t[3]*=i,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,s))}makeTranslation(e,t,i){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,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),s=Math.sin(t),r=1-i,a=e.x,o=e.y,l=e.z,c=r*a,h=r*o;return this.set(c*a+i,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+i,h*l-s*a,0,c*l-s*o,h*l+s*a,r*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,s,r,a){return this.set(1,i,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,i){const s=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,h=a+a,u=o+o,d=r*c,m=r*h,g=r*u,v=a*h,f=a*u,p=o*u,b=l*c,_=l*h,E=l*u,R=i.x,T=i.y,A=i.z;return s[0]=(1-(v+p))*R,s[1]=(m+E)*R,s[2]=(g-_)*R,s[3]=0,s[4]=(m-E)*T,s[5]=(1-(d+p))*T,s[6]=(f+b)*T,s[7]=0,s[8]=(g+_)*A,s[9]=(f-b)*A,s[10]=(1-(d+v))*A,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,i){const s=this.elements;let r=ks.set(s[0],s[1],s[2]).length();const a=ks.set(s[4],s[5],s[6]).length(),o=ks.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),e.x=s[12],e.y=s[13],e.z=s[14],di.copy(this);const l=1/r,c=1/a,h=1/o;return di.elements[0]*=l,di.elements[1]*=l,di.elements[2]*=l,di.elements[4]*=c,di.elements[5]*=c,di.elements[6]*=c,di.elements[8]*=h,di.elements[9]*=h,di.elements[10]*=h,t.setFromRotationMatrix(di),i.x=r,i.y=a,i.z=o,this}makePerspective(e,t,i,s,r,a,o=wi,l=!1){const c=this.elements,h=2*r/(t-e),u=2*r/(i-s),d=(t+e)/(t-e),m=(i+s)/(i-s);let g,v;if(l)g=r/(a-r),v=a*r/(a-r);else if(o===wi)g=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===$n)g=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,s,r,a,o=wi,l=!1){const c=this.elements,h=2/(t-e),u=2/(i-s),d=-(t+e)/(t-e),m=-(i+s)/(i-s);let g,v;if(l)g=1/(a-r),v=a/(a-r);else if(o===wi)g=-2/(a-r),v=-(a+r)/(a-r);else if(o===$n)g=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=m,c[2]=0,c[6]=0,c[10]=g,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<16;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const ks=new w,di=new De,nd=new w(0,0,0),rd=new w(1,1,1),Ji=new w,nr=new w,$t=new w,Gl=new De,Wl=new hi;class pi{constructor(e=0,t=0,i=0,s=pi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=s}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,i,s=this._order){return this._x=e,this._y=t,this._z=i,this._order=s,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,i=!0){const s=e.elements,r=s[0],a=s[4],o=s[8],l=s[1],c=s[5],h=s[9],u=s[2],d=s[6],m=s[10];switch(t){case"XYZ":this._y=Math.asin(Fe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Fe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Fe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,m),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Fe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Fe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Fe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,m),this._y=0);break;default:Me("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Gl.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Gl,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Wl.setFromEuler(this),this.setFromQuaternion(Wl,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}pi.DEFAULT_ORDER="XYZ";class to{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1< 1){for(let t=0;t 1){for(let i=0;i 0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c 0){s.children=[];for(let o=0;o 0){s.animations=[];for(let o=0;o 0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),m.length>0&&(i.animations=m),g.length>0&&(i.nodes=g)}return i.object=s,i;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i 0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){mi.subVectors(s,t),Fi.subVectors(i,t),so.subVectors(e,t);const a=mi.dot(mi),o=mi.dot(Fi),l=mi.dot(so),c=Fi.dot(Fi),h=Fi.dot(so),u=a*c-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,m=(c*l-o*h)*d,g=(a*h-o*l)*d;return r.set(1-m-g,g,m)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,zi)===null?!1:zi.x>=0&&zi.y>=0&&zi.x+zi.y<=1}static getInterpolation(e,t,i,s,r,a,o,l){return this.getBarycoord(e,t,i,s,zi)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,zi.x),l.addScaledVector(a,zi.y),l.addScaledVector(o,zi.z),l)}static getInterpolatedAttribute(e,t,i,s,r,a){return oo.setScalar(0),lo.setScalar(0),co.setScalar(0),oo.fromBufferAttribute(e,t),lo.fromBufferAttribute(e,i),co.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(oo,r.x),a.addScaledVector(lo,r.y),a.addScaledVector(co,r.z),a}static isFrontFacing(e,t,i,s){return mi.subVectors(i,t),Fi.subVectors(e,t),mi.cross(Fi).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),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 mi.subVectors(this.c,this.b),Fi.subVectors(this.a,this.b),mi.cross(Fi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return fi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return fi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return fi.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return fi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return fi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let a,o;Hs.subVectors(s,i),Vs.subVectors(r,i),no.subVectors(e,i);const l=Hs.dot(no),c=Vs.dot(no);if(l<=0&&c<=0)return t.copy(i);ro.subVectors(e,s);const h=Hs.dot(ro),u=Vs.dot(ro);if(h>=0&&u<=h)return t.copy(s);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(i).addScaledVector(Hs,a);ao.subVectors(e,r);const m=Hs.dot(ao),g=Vs.dot(ao);if(g>=0&&m<=g)return t.copy(r);const v=m*c-l*g;if(v<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(i).addScaledVector(Vs,o);const f=h*g-m*u;if(f<=0&&u-h>=0&&m-g>=0)return Kl.subVectors(r,s),o=(u-h)/(u-h+(m-g)),t.copy(s).addScaledVector(Kl,o);const p=1/(f+v+d);return a=v*p,o=d*p,t.copy(i).addScaledVector(Hs,a).addScaledVector(Vs,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const $l={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Qi={h:0,s:0,l:0},ar={h:0,s:0,l:0};function ho(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class xe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=At){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Xe.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=Xe.workingColorSpace){return this.r=e,this.g=t,this.b=i,Xe.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=Xe.workingColorSpace){if(e=Ga(e,1),t=Fe(t,0,1),i=Fe(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=ho(a,r,e+1/3),this.g=ho(a,r,e),this.b=ho(a,r,e-1/3)}return Xe.colorSpaceToWorking(this,s),this}setStyle(e,t=At){function i(r){r!==void 0&&parseFloat(r)<1&&Me("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Me("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Me("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=At){const i=$l[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Me("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=Ni(e.r),this.g=Ni(e.g),this.b=Ni(e.b),this}copyLinearToSRGB(e){return this.r=Ds(e.r),this.g=Ds(e.g),this.b=Ds(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=At){return Xe.workingToColorSpace(Ft.copy(this),e),Math.round(Fe(Ft.r*255,0,255))*65536+Math.round(Fe(Ft.g*255,0,255))*256+Math.round(Fe(Ft.b*255,0,255))}getHexString(e=At){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Xe.workingColorSpace){Xe.workingToColorSpace(Ft.copy(this),t);const i=Ft.r,s=Ft.g,r=Ft.b,a=Math.max(i,s,r),o=Math.min(i,s,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case i:l=(s-r)/u+(s 0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Me(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Me(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Ts&&(i.blending=this.blending),this.side!==Si&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Hr&&(i.blendSrc=this.blendSrc),this.blendDst!==Vr&&(i.blendDst=this.blendDst),this.blendEquation!==ai&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Es&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Ha&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ps&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ps&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ps&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}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;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Ht extends ti{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new pi,this.combine=Jr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Hi=ud();function ud(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(i[l]=0,i[l|256]=32768,s[l]=24,s[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,s[l]=-c-1,s[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,s[l]=13,s[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,s[l]=24,s[l|256]=24):(i[l]=31744,i[l|256]=64512,s[l]=13,s[l|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,r[l]=c|h}for(let l=1024;l<2048;++l)r[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function dd(n){Math.abs(n)>65504&&Me("DataUtils.toHalfFloat(): Value out of range."),n=Fe(n,-65504,65504),Hi.floatView[0]=n;const e=Hi.uint32View[0],t=e>>23&511;return Hi.baseTable[t]+((e&8388607)>>Hi.shiftTable[t])}function pd(n){const e=n>>10;return Hi.uint32View[0]=Hi.mantissaTable[Hi.offsetTable[e]+(n&1023)]+Hi.exponentTable[e],Hi.floatView[0]}class or{static toHalfFloat(e){return dd(e)}static fromHalfFloat(e){return pd(e)}}const St=new w,lr=new oe;let md=0;class Vt{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:md++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Va,this.updateRanges=[],this.gpuType=qt,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;s t.count&&Me("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Pt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ve("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new w(-1/0,-1/0,-1/0),new w(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i 0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u0&&(s[l]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const c in s){const h=s[c];this.setAttribute(c,h.clone(t))}const r=e.morphAttributes;for(const c in r){const h=[],u=r[c];for(let d=0,m=u.length;d 0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s (e.far-e.near)**2))&&(ec.copy(r).invert(),us.copy(e.ray).applyMatrix4(ec),!(i.boundingBox!==null&&us.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,us)))}_computeIntersections(e,t,i){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,m=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,v=d.length;g t.far?null:{distance:c,point:mr.clone(),object:n}}function fr(n,e,t,i,s,r,a,o,l,c){n.getVertexPosition(o,hr),n.getVertexPosition(l,ur),n.getVertexPosition(c,dr);const h=gd(n,e,t,i,hr,ur,dr,ic);if(h){const u=new w;fi.getBarycoord(ic,hr,ur,dr,u),s&&(h.uv=fi.getInterpolatedAttribute(s,o,l,c,u,new oe)),r&&(h.uv1=fi.getInterpolatedAttribute(r,o,l,c,u,new oe)),a&&(h.normal=fi.getInterpolatedAttribute(a,o,l,c,u,new w),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new w,materialIndex:0};fi.getNormal(hr,ur,dr,d.normal),h.face=d,h.barycoord=u}return h}class ds extends si{constructor(e=1,t=1,i=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,m=0;g("z","y","x",-1,-1,i,t,e,a,r,0),g("z","y","x",1,-1,i,t,-e,a,r,1),g("x","z","y",1,1,e,i,t,s,a,2),g("x","z","y",1,-1,e,i,-t,s,a,3),g("x","y","z",1,-1,e,t,i,s,r,4),g("x","y","z",-1,-1,e,t,-i,s,r,5),this.setIndex(l),this.setAttribute("position",new gi(c,3)),this.setAttribute("normal",new gi(h,3)),this.setAttribute("uv",new gi(u,2));function g(v,f,p,b,_,E,R,T,A,I,S){const M=E/A,L=R/I,N=E/2,z=R/2,H=T/2,j=A+1,q=I+1;let te=0,G=0;const K=new w;for(let ne=0;ne 0?1:-1,h.push(K.x,K.y,K.z),u.push(He/A),u.push(1-ne/I),te+=1}}for(let ne=0;ne0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class nc extends dt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new De,this.projectionMatrix=new De,this.projectionMatrixInverse=new De,this.coordinateSystem=wi,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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const es=new w,rc=new oe,ac=new oe;class St extends nc{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Ls*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(xn*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ls*2*Math.atan(Math.tan(xn*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){es.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(es.x,es.y).multiplyScalar(-e/es.z),es.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(es.x,es.y).multiplyScalar(-e/es.z)}getViewSize(e,t){return this.getViewBounds(e,rc,ac),t.subVectors(ac,rc)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(xn*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const js=-90,Xs=1;class bd extends dt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new St(js,Xs,e,t);s.layers=this.layers,this.add(s);const r=new St(js,Xs,e,t);r.layers=this.layers,this.add(r);const a=new St(js,Xs,e,t);a.layers=this.layers,this.add(a);const o=new St(js,Xs,e,t);o.layers=this.layers,this.add(o);const l=new St(js,Xs,e,t);l.layers=this.layers,this.add(l);const c=new St(js,Xs,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===wi)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===$n)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,s),e.render(t,r),e.setRenderTarget(i,1,s),e.render(t,a),e.setRenderTarget(i,2,s),e.render(t,o),e.setRenderTarget(i,3,s),e.render(t,l),e.setRenderTarget(i,4,s),e.render(t,c),i.texture.generateMipmaps=v,e.setRenderTarget(i,5,s),e.render(t,h),e.setRenderTarget(u,d,m),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}}class mo extends At{constructor(e=[],t=ws,i,s,r,a,o,l,c,h){super(e,t,i,s,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class yd extends yt{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new mo(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){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;const i={uniforms:{tEquirect:{value:null}},vertexShader:` +}`;class ct extends ti{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=_d,this.fragmentShader=xd,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ws(e.uniforms),this.uniformsGroups=vd(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const s in this.uniforms){const r=this.uniforms[s].value;r&&r.isTexture?t.uniforms[s]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[s]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[s]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[s]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[s]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[s]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[s]={type:"m4",value:r.toArray()}:t.uniforms[s]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class nc extends dt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new De,this.projectionMatrix=new De,this.projectionMatrixInverse=new De,this.coordinateSystem=wi,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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const es=new w,rc=new oe,ac=new oe;class Tt extends nc{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Ls*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(xn*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ls*2*Math.atan(Math.tan(xn*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){es.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(es.x,es.y).multiplyScalar(-e/es.z),es.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(es.x,es.y).multiplyScalar(-e/es.z)}getViewSize(e,t){return this.getViewBounds(e,rc,ac),t.subVectors(ac,rc)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(xn*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const js=-90,Xs=1;class bd extends dt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Tt(js,Xs,e,t);s.layers=this.layers,this.add(s);const r=new Tt(js,Xs,e,t);r.layers=this.layers,this.add(r);const a=new Tt(js,Xs,e,t);a.layers=this.layers,this.add(a);const o=new Tt(js,Xs,e,t);o.layers=this.layers,this.add(o);const l=new Tt(js,Xs,e,t);l.layers=this.layers,this.add(l);const c=new Tt(js,Xs,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===wi)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===$n)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,s),e.render(t,r),e.setRenderTarget(i,1,s),e.render(t,a),e.setRenderTarget(i,2,s),e.render(t,o),e.setRenderTarget(i,3,s),e.render(t,l),e.setRenderTarget(i,4,s),e.render(t,c),i.texture.generateMipmaps=v,e.setRenderTarget(i,5,s),e.render(t,h),e.setRenderTarget(u,d,m),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}}class mo extends Rt{constructor(e=[],t=ws,i,s,r,a,o,l,c,h){super(e,t,i,s,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class yd extends Mt{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new mo(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){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;const i={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; @@ -43,7 +43,7 @@ gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},s=new ds(5,5,5),r=new ct({name:"CubemapFromEquirect",uniforms:Ws(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:zt,blending:xt});r.uniforms.tEquirect.value=t;const a=new rt(s,r),o=t.minFilter;return t.minFilter===Ei&&(t.minFilter=bt),new bd(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,s);e.setRenderTarget(r)}}let Vi=class extends dt{constructor(){super(),this.isGroup=!0,this.type="Group"}};const Md={type:"move"};class fo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Vi,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Vi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new w,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new w),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Vi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new w,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new w),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let s=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const f=t.getJointPose(v,i),p=this._getHandJoint(c,v);f!==null&&(p.matrix.fromArray(f.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=f.radius),p.visible=f!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),m=.02,g=.005;c.inputState.pinching&&d>m+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=m-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(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,this.dispatchEvent(Md)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Vi;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class go extends dt{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 pi,this.environmentIntensity=1,this.environmentRotation=new pi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(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),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Sd{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Va,this.updateRanges=[],this.version=0,this.uuid=li()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let s=0,r=this.stride;s1?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<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){const i=t||Pd.getNormalMatrix(e),s=this.coplanarPoint(Mo).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),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)}}const ps=new Ci,Ld=new oe(.5,.5),_r=new w;class So{constructor(e=new Ai,t=new Ai,i=new Ai,s=new Ai,r=new Ai,a=new Ai){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=wi,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],h=r[4],u=r[5],d=r[6],m=r[7],g=r[8],v=r[9],f=r[10],p=r[11],b=r[12],_=r[13],E=r[14],R=r[15];if(s[0].setComponents(c-a,m-h,p-g,R-b).normalize(),s[1].setComponents(c+a,m+h,p+g,R+b).normalize(),s[2].setComponents(c+o,m+u,p+v,R+_).normalize(),s[3].setComponents(c-o,m-u,p-v,R-_).normalize(),i)s[4].setComponents(l,d,f,E).normalize(),s[5].setComponents(c-l,m-d,p-f,R-E).normalize();else if(s[4].setComponents(c-l,m-d,p-f,R-E).normalize(),t===wi)s[5].setComponents(c+l,m+d,p+f,R+E).normalize();else if(t===$n)s[5].setComponents(l,d,f,E).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),ps.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ps.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ps)}intersectsSprite(e){ps.center.set(0,0,0);const t=Ld.distanceTo(e.center);return ps.radius=.7071067811865476+t,ps.applyMatrix4(e.matrixWorld),this.intersectsSphere(ps)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i) 0?e.max.x:e.min.x,_r.y=s.normal.y>0?e.max.y:e.min.y,_r.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(_r)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class gc extends ti{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xe(16777215),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}}const xr=new w,br=new w,vc=new De,Cn=new Os,yr=new Ci,To=new w,_c=new w;class Eo extends dt{constructor(e=new si,t=new gc){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s i)return;To.applyMatrix4(n.matrixWorld);const l=e.ray.origin.distanceTo(To);if(!(l e.far))return{distance:l,point:_c.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const xc=new w,bc=new w;class Dd extends Eo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s 0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s s.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Co extends At{constructor(e,t,i=os,s,r,a,o=It,l=It,c,h=mn,u=1){if(h!==mn&&h!==Rs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:u};super(d,s,r,a,o,l,h,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new qa(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Tc extends At{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class An extends si{constructor(e=1,t=1,i=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:s};const r=e/2,a=t/2,o=Math.floor(i),l=Math.floor(s),c=o+1,h=l+1,u=e/o,d=t/l,m=[],g=[],v=[],f=[];for(let p=0;p 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}}class Bd extends ti{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yn,this.normalScale=new oe(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}}class Od extends ti{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yn,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new pi,this.combine=Jr,this.reflectivity=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.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}}class Ec extends ti{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Su,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class kd extends ti{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Er(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Fd(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function zd(n){function e(s,r){return n[s]-n[r]}const t=n.length,i=new Array(t);for(let s=0;s!==t;++s)i[s]=s;return i.sort(e),i}function wc(n,e,t){const i=n.length,s=new n.constructor(i);for(let r=0,a=0;a!==i;++r){const o=t[r]*e;for(let l=0;l!==e;++l)s[a++]=n[o+l]}return s}function Cc(n,e,t,i){let s=1,r=n[0];for(;r!==void 0&&r[i]===void 0;)r=n[s++];if(r===void 0)return;let a=r[i];if(a!==void 0)if(Array.isArray(a))do a=r[i],a!==void 0&&(e.push(r.time),t.push(...a)),r=n[s++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[i],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=n[s++];while(r!==void 0);else do a=r[i],a!==void 0&&(e.push(r.time),t.push(a)),r=n[s++];while(r!==void 0)}class Rn{constructor(e,t,i,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,s=t[i],r=t[i-1];i:{e:{let a;t:{s:if(!(e =r)){const o=t[1];e=r)break e}a=i,i=0;break t}break i}for(;i>>1;e t;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=i.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Ve("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,s=this.values,r=i.length;r===0&&(Ve("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){Ve("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){Ve("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(s!==void 0&&Fd(s))for(let o=0,l=s.length;o!==l;++o){const c=s[o];if(isNaN(c)){Ve("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),s=this.getInterpolation()===Oa,r=e.length-1;let a=1;for(let o=1;o 0){e[a]=e[r];for(let o=r*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,s=new i(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}}_i.prototype.ValueTypeName="",_i.prototype.TimeBufferType=Float32Array,_i.prototype.ValueBufferType=Float32Array,_i.prototype.DefaultInterpolation=gn;class Ys extends _i{constructor(e,t,i){super(e,t,i)}}Ys.prototype.ValueTypeName="bool",Ys.prototype.ValueBufferType=Array,Ys.prototype.DefaultInterpolation=fn,Ys.prototype.InterpolantFactoryMethodLinear=void 0,Ys.prototype.InterpolantFactoryMethodSmooth=void 0;class Ac extends _i{constructor(e,t,i,s){super(e,t,i,s)}}Ac.prototype.ValueTypeName="color";class Ks extends _i{constructor(e,t,i,s){super(e,t,i,s)}}Ks.prototype.ValueTypeName="number";class Wd extends Rn{constructor(e,t,i,s){super(e,t,i,s)}interpolate_(e,t,i,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(s-t);let c=e*o;for(let h=c+o;c!==h;c+=4)hi.slerpFlat(r,0,a,c-o,a,c,l);return r}}class $s extends _i{constructor(e,t,i,s){super(e,t,i,s)}InterpolantFactoryMethodLinear(e){return new Wd(this.times,this.values,this.getValueSize(),e)}}$s.prototype.ValueTypeName="quaternion",$s.prototype.InterpolantFactoryMethodSmooth=void 0;class Js extends _i{constructor(e,t,i){super(e,t,i)}}Js.prototype.ValueTypeName="string",Js.prototype.ValueBufferType=Array,Js.prototype.DefaultInterpolation=fn,Js.prototype.InterpolantFactoryMethodLinear=void 0,Js.prototype.InterpolantFactoryMethodSmooth=void 0;class Qs extends _i{constructor(e,t,i,s){super(e,t,i,s)}}Qs.prototype.ValueTypeName="vector";class jd{constructor(e="",t=-1,i=[],s=yu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=s,this.uuid=li(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,s=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(qd(i[a]).scale(s));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],i=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,a=i.length;r!==a;++r)t.push(_i.toJSON(i[r]));return s}static CreateFromMorphTargetSequence(e,t,i,s){const r=t.length,a=[];for(let o=0;o 1){const u=h[1];let d=s[u];d||(s[u]=d=[]),d.push(c)}}const a=[];for(const o in s)a.push(this.CreateFromMorphTargetSequence(o,s[o],t,i));return a}static parseAnimation(e,t){if(Me("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Ve("AnimationClip: No animation in JSONLoader data."),null;const i=function(h,u,d,m,g){if(d.length!==0){const v=[],f=[];Cc(d,v,f,m),v.length!==0&&g.push(new h(u,v,f))}},s=[],r=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h {t&&t(r),this.manager.itemEnd(e)},0),r;if(Wi[e]!==void 0){Wi[e].push({onLoad:t,onProgress:i,onError:s});return}Wi[e]=[],Wi[e].push({onLoad:t,onProgress:i,onError:s});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Me("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=Wi[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),m=d?parseInt(d):0,g=m!==0;let v=0;const f=new ReadableStream({start(p){b();function b(){u.read().then(({done:_,value:E})=>{if(_)p.close();else{v+=E.byteLength;const R=new ProgressEvent("progress",{lengthComputable:g,loaded:v,total:m});for(let T=0,A=h.length;T{p.error(_)})}}});return new Response(f)}else throw new Kd(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),u=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(u);return c.arrayBuffer().then(m=>d.decode(m))}}}).then(c=>{Gi.add(`file:${e}`,c);const h=Wi[e];delete Wi[e];for(let u=0,d=h.length;u {const h=Wi[e];if(h===void 0)throw this.manager.itemError(e),c;delete Wi[e];for(let u=0,d=h.length;u {this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const en=new WeakMap;class Rc extends ts{constructor(e){super(e)}load(e,t,i,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Gi.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);else{let u=en.get(a);u===void 0&&(u=[],en.set(a,u)),u.push({onLoad:t,onError:s})}return a}const o=vn("img");function l(){h(),t&&t(this);const u=en.get(this)||[];for(let d=0;d "u"&&Me("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Me("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Gi.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(c=>{if(Io.has(a)===!0)s&&s(Io.get(a)),r.manager.itemError(e),r.manager.itemEnd(e);else return t&&t(c),r.manager.itemEnd(e),c});return}return setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return Gi.add(`image-bitmap:${e}`,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){s&&s(c),Io.set(l,c),Gi.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Gi.add(`image-bitmap:${e}`,l),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class np extends St{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class rp{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const Uo="\\[\\]\\.:\\/",ap=new RegExp("["+Uo+"]","g"),No="[^"+Uo+"]",op="[^"+Uo.replace("\\.","")+"]",lp=/((?:WC+[\/:])*)/.source.replace("WC",No),cp=/(WCOD+)?/.source.replace("WCOD",op),hp=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",No),up=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",No),dp=new RegExp("^"+lp+cp+hp+up+"$"),pp=["material","materials","bones","map"];class mp{constructor(e,t,i){const s=i||nt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,s=this._bindings[i];s!==void 0&&s.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=i.length;s!==r;++s)i[s].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class nt{constructor(e,t,i){this.path=t,this.parsedPath=i||nt.parseTrackName(t),this.node=nt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new nt.Composite(e,t,i):new nt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(ap,"")}static parseTrackName(e){const t=dp.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=i.nodeName&&i.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){const r=i.nodeName.substring(s+1);pp.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,s),i.objectName=r)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(r){for(let a=0;a m.start-g.start);let d=0;for(let m=1;m m+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=m-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(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,this.dispatchEvent(Md)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Vi;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class go extends dt{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 pi,this.environmentIntensity=1,this.environmentRotation=new pi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(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),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Sd{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Va,this.updateRanges=[],this.version=0,this.uuid=li()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let s=0,r=this.stride;s 1?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<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){const i=t||Pd.getNormalMatrix(e),s=this.coplanarPoint(Mo).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),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)}}const ps=new Ci,Ld=new oe(.5,.5),_r=new w;class So{constructor(e=new Ai,t=new Ai,i=new Ai,s=new Ai,r=new Ai,a=new Ai){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=wi,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],h=r[4],u=r[5],d=r[6],m=r[7],g=r[8],v=r[9],f=r[10],p=r[11],b=r[12],_=r[13],E=r[14],R=r[15];if(s[0].setComponents(c-a,m-h,p-g,R-b).normalize(),s[1].setComponents(c+a,m+h,p+g,R+b).normalize(),s[2].setComponents(c+o,m+u,p+v,R+_).normalize(),s[3].setComponents(c-o,m-u,p-v,R-_).normalize(),i)s[4].setComponents(l,d,f,E).normalize(),s[5].setComponents(c-l,m-d,p-f,R-E).normalize();else if(s[4].setComponents(c-l,m-d,p-f,R-E).normalize(),t===wi)s[5].setComponents(c+l,m+d,p+f,R+E).normalize();else if(t===$n)s[5].setComponents(l,d,f,E).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),ps.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ps.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ps)}intersectsSprite(e){ps.center.set(0,0,0);const t=Ld.distanceTo(e.center);return ps.radius=.7071067811865476+t,ps.applyMatrix4(e.matrixWorld),this.intersectsSphere(ps)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i) 0?e.max.x:e.min.x,_r.y=s.normal.y>0?e.max.y:e.min.y,_r.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(_r)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class gc extends ti{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xe(16777215),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}}const xr=new w,br=new w,vc=new De,Cn=new Os,yr=new Ci,To=new w,_c=new w;class Eo extends dt{constructor(e=new si,t=new gc){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s i)return;To.applyMatrix4(n.matrixWorld);const l=e.ray.origin.distanceTo(To);if(!(l e.far))return{distance:l,point:_c.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const xc=new w,bc=new w;class Dd extends Eo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s 0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=i.length;s s.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Co extends Rt{constructor(e,t,i=os,s,r,a,o=Ut,l=Ut,c,h=mn,u=1){if(h!==mn&&h!==Rs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:u};super(d,s,r,a,o,l,h,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new qa(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Tc extends Rt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class An extends si{constructor(e=1,t=1,i=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:s};const r=e/2,a=t/2,o=Math.floor(i),l=Math.floor(s),c=o+1,h=l+1,u=e/o,d=t/l,m=[],g=[],v=[],f=[];for(let p=0;p 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}}class Bd extends ti{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yn,this.normalScale=new oe(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}}class Od extends ti{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yn,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new pi,this.combine=Jr,this.reflectivity=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.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}}class Ec extends ti{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Su,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class kd extends ti{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Er(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Fd(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function zd(n){function e(s,r){return n[s]-n[r]}const t=n.length,i=new Array(t);for(let s=0;s!==t;++s)i[s]=s;return i.sort(e),i}function wc(n,e,t){const i=n.length,s=new n.constructor(i);for(let r=0,a=0;a!==i;++r){const o=t[r]*e;for(let l=0;l!==e;++l)s[a++]=n[o+l]}return s}function Cc(n,e,t,i){let s=1,r=n[0];for(;r!==void 0&&r[i]===void 0;)r=n[s++];if(r===void 0)return;let a=r[i];if(a!==void 0)if(Array.isArray(a))do a=r[i],a!==void 0&&(e.push(r.time),t.push(...a)),r=n[s++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[i],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=n[s++];while(r!==void 0);else do a=r[i],a!==void 0&&(e.push(r.time),t.push(a)),r=n[s++];while(r!==void 0)}class Rn{constructor(e,t,i,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,s=t[i],r=t[i-1];i:{e:{let a;t:{s:if(!(e =r)){const o=t[1];e=r)break e}a=i,i=0;break t}break i}for(;i>>1;e t;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=i.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Ve("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,s=this.values,r=i.length;r===0&&(Ve("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){Ve("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){Ve("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(s!==void 0&&Fd(s))for(let o=0,l=s.length;o!==l;++o){const c=s[o];if(isNaN(c)){Ve("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),s=this.getInterpolation()===Oa,r=e.length-1;let a=1;for(let o=1;o 0){e[a]=e[r];for(let o=r*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,s=new i(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}}_i.prototype.ValueTypeName="",_i.prototype.TimeBufferType=Float32Array,_i.prototype.ValueBufferType=Float32Array,_i.prototype.DefaultInterpolation=gn;class Ys extends _i{constructor(e,t,i){super(e,t,i)}}Ys.prototype.ValueTypeName="bool",Ys.prototype.ValueBufferType=Array,Ys.prototype.DefaultInterpolation=fn,Ys.prototype.InterpolantFactoryMethodLinear=void 0,Ys.prototype.InterpolantFactoryMethodSmooth=void 0;class Ac extends _i{constructor(e,t,i,s){super(e,t,i,s)}}Ac.prototype.ValueTypeName="color";class Ks extends _i{constructor(e,t,i,s){super(e,t,i,s)}}Ks.prototype.ValueTypeName="number";class Wd extends Rn{constructor(e,t,i,s){super(e,t,i,s)}interpolate_(e,t,i,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(s-t);let c=e*o;for(let h=c+o;c!==h;c+=4)hi.slerpFlat(r,0,a,c-o,a,c,l);return r}}class $s extends _i{constructor(e,t,i,s){super(e,t,i,s)}InterpolantFactoryMethodLinear(e){return new Wd(this.times,this.values,this.getValueSize(),e)}}$s.prototype.ValueTypeName="quaternion",$s.prototype.InterpolantFactoryMethodSmooth=void 0;class Js extends _i{constructor(e,t,i){super(e,t,i)}}Js.prototype.ValueTypeName="string",Js.prototype.ValueBufferType=Array,Js.prototype.DefaultInterpolation=fn,Js.prototype.InterpolantFactoryMethodLinear=void 0,Js.prototype.InterpolantFactoryMethodSmooth=void 0;class Qs extends _i{constructor(e,t,i,s){super(e,t,i,s)}}Qs.prototype.ValueTypeName="vector";class jd{constructor(e="",t=-1,i=[],s=yu){this.name=e,this.tracks=i,this.duration=t,this.blendMode=s,this.uuid=li(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,s=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(qd(i[a]).scale(s));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],i=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,a=i.length;r!==a;++r)t.push(_i.toJSON(i[r]));return s}static CreateFromMorphTargetSequence(e,t,i,s){const r=t.length,a=[];for(let o=0;o 1){const u=h[1];let d=s[u];d||(s[u]=d=[]),d.push(c)}}const a=[];for(const o in s)a.push(this.CreateFromMorphTargetSequence(o,s[o],t,i));return a}static parseAnimation(e,t){if(Me("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Ve("AnimationClip: No animation in JSONLoader data."),null;const i=function(h,u,d,m,g){if(d.length!==0){const v=[],f=[];Cc(d,v,f,m),v.length!==0&&g.push(new h(u,v,f))}},s=[],r=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h {t&&t(r),this.manager.itemEnd(e)},0),r;if(Wi[e]!==void 0){Wi[e].push({onLoad:t,onProgress:i,onError:s});return}Wi[e]=[],Wi[e].push({onLoad:t,onProgress:i,onError:s});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Me("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=Wi[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),m=d?parseInt(d):0,g=m!==0;let v=0;const f=new ReadableStream({start(p){b();function b(){u.read().then(({done:_,value:E})=>{if(_)p.close();else{v+=E.byteLength;const R=new ProgressEvent("progress",{lengthComputable:g,loaded:v,total:m});for(let T=0,A=h.length;T{p.error(_)})}}});return new Response(f)}else throw new Kd(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),u=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(u);return c.arrayBuffer().then(m=>d.decode(m))}}}).then(c=>{Gi.add(`file:${e}`,c);const h=Wi[e];delete Wi[e];for(let u=0,d=h.length;u {const h=Wi[e];if(h===void 0)throw this.manager.itemError(e),c;delete Wi[e];for(let u=0,d=h.length;u {this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const en=new WeakMap;class Rc extends ts{constructor(e){super(e)}load(e,t,i,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Gi.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);else{let u=en.get(a);u===void 0&&(u=[],en.set(a,u)),u.push({onLoad:t,onError:s})}return a}const o=vn("img");function l(){h(),t&&t(this);const u=en.get(this)||[];for(let d=0;d "u"&&Me("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Me("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Gi.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(c=>{if(Io.has(a)===!0)s&&s(Io.get(a)),r.manager.itemError(e),r.manager.itemEnd(e);else return t&&t(c),r.manager.itemEnd(e),c});return}return setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return Gi.add(`image-bitmap:${e}`,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){s&&s(c),Io.set(l,c),Gi.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Gi.add(`image-bitmap:${e}`,l),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class np extends Tt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class rp{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const Uo="\\[\\]\\.:\\/",ap=new RegExp("["+Uo+"]","g"),No="[^"+Uo+"]",op="[^"+Uo.replace("\\.","")+"]",lp=/((?:WC+[\/:])*)/.source.replace("WC",No),cp=/(WCOD+)?/.source.replace("WCOD",op),hp=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",No),up=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",No),dp=new RegExp("^"+lp+cp+hp+up+"$"),pp=["material","materials","bones","map"];class mp{constructor(e,t,i){const s=i||nt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,s=this._bindings[i];s!==void 0&&s.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=i.length;s!==r;++s)i[s].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class nt{constructor(e,t,i){this.path=t,this.parsedPath=i||nt.parseTrackName(t),this.node=nt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new nt.Composite(e,t,i):new nt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(ap,"")}static parseTrackName(e){const t=dp.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=i.nodeName&&i.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){const r=i.nodeName.substring(s+1);pp.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,s),i.objectName=r)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(r){for(let a=0;a m.start-g.start);let d=0;for(let m=1;m #include #include -}`,ze={alphahash_fragment:_p,alphahash_pars_fragment:xp,alphamap_fragment:bp,alphamap_pars_fragment:yp,alphatest_fragment:Mp,alphatest_pars_fragment:Sp,aomap_fragment:Tp,aomap_pars_fragment:Ep,batching_pars_vertex:wp,batching_vertex:Cp,begin_vertex:Ap,beginnormal_vertex:Rp,bsdfs:Pp,iridescence_fragment:Lp,bumpmap_pars_fragment:Dp,clipping_planes_fragment:Ip,clipping_planes_pars_fragment:Up,clipping_planes_pars_vertex:Np,clipping_planes_vertex:Bp,color_fragment:Op,color_pars_fragment:kp,color_pars_vertex:Fp,color_vertex:zp,common:Hp,cube_uv_reflection_fragment:Vp,defaultnormal_vertex:Gp,displacementmap_pars_vertex:Wp,displacementmap_vertex:jp,emissivemap_fragment:Xp,emissivemap_pars_fragment:qp,colorspace_fragment:Zp,colorspace_pars_fragment:Yp,envmap_fragment:Kp,envmap_common_pars_fragment:$p,envmap_pars_fragment:Jp,envmap_pars_vertex:Qp,envmap_physical_pars_fragment:hm,envmap_vertex:em,fog_vertex:tm,fog_pars_vertex:im,fog_fragment:sm,fog_pars_fragment:nm,gradientmap_pars_fragment:rm,lightmap_pars_fragment:am,lights_lambert_fragment:om,lights_lambert_pars_fragment:lm,lights_pars_begin:cm,lights_toon_fragment:um,lights_toon_pars_fragment:dm,lights_phong_fragment:pm,lights_phong_pars_fragment:mm,lights_physical_fragment:fm,lights_physical_pars_fragment:gm,lights_fragment_begin:vm,lights_fragment_maps:_m,lights_fragment_end:xm,logdepthbuf_fragment:bm,logdepthbuf_pars_fragment:ym,logdepthbuf_pars_vertex:Mm,logdepthbuf_vertex:Sm,map_fragment:Tm,map_pars_fragment:Em,map_particle_fragment:wm,map_particle_pars_fragment:Cm,metalnessmap_fragment:Am,metalnessmap_pars_fragment:Rm,morphinstance_vertex:Pm,morphcolor_vertex:Lm,morphnormal_vertex:Dm,morphtarget_pars_vertex:Im,morphtarget_vertex:Um,normal_fragment_begin:Nm,normal_fragment_maps:Bm,normal_pars_fragment:Om,normal_pars_vertex:km,normal_vertex:Fm,normalmap_pars_fragment:zm,clearcoat_normal_fragment_begin:Hm,clearcoat_normal_fragment_maps:Vm,clearcoat_pars_fragment:Gm,iridescence_pars_fragment:Wm,opaque_fragment:jm,packing:Xm,premultiplied_alpha_fragment:qm,project_vertex:Zm,dithering_fragment:Ym,dithering_pars_fragment:Km,roughnessmap_fragment:$m,roughnessmap_pars_fragment:Jm,shadowmap_pars_fragment:Qm,shadowmap_pars_vertex:ef,shadowmap_vertex:tf,shadowmask_pars_fragment:sf,skinbase_vertex:nf,skinning_pars_vertex:rf,skinning_vertex:af,skinnormal_vertex:of,specularmap_fragment:lf,specularmap_pars_fragment:cf,tonemapping_fragment:hf,tonemapping_pars_fragment:uf,transmission_fragment:df,transmission_pars_fragment:pf,uv_pars_fragment:mf,uv_pars_vertex:ff,uv_vertex:gf,worldpos_vertex:vf,background_vert:_f,background_frag:xf,backgroundCube_vert:bf,backgroundCube_frag:yf,cube_vert:Mf,cube_frag:Sf,depth_vert:Tf,depth_frag:Ef,distanceRGBA_vert:wf,distanceRGBA_frag:Cf,equirect_vert:Af,equirect_frag:Rf,linedashed_vert:Pf,linedashed_frag:Lf,meshbasic_vert:Df,meshbasic_frag:If,meshlambert_vert:Uf,meshlambert_frag:Nf,meshmatcap_vert:Bf,meshmatcap_frag:Of,meshnormal_vert:kf,meshnormal_frag:Ff,meshphong_vert:zf,meshphong_frag:Hf,meshphysical_vert:Vf,meshphysical_frag:Gf,meshtoon_vert:Wf,meshtoon_frag:jf,points_vert:Xf,points_frag:qf,shadow_vert:Zf,shadow_frag:Yf,sprite_vert:Kf,sprite_frag:$f},ce={common:{diffuse:{value:new xe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ke}},envmap:{envMap:{value:null},envMapRotation:{value:new ke},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ke},normalScale:{value:new oe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new xe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0},uvTransform:{value:new ke}},sprite:{diffuse:{value:new xe(16777215)},opacity:{value:1},center:{value:new oe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}}},Pi={basic:{uniforms:Gt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.fog]),vertexShader:ze.meshbasic_vert,fragmentShader:ze.meshbasic_frag},lambert:{uniforms:Gt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,ce.lights,{emissive:{value:new xe(0)}}]),vertexShader:ze.meshlambert_vert,fragmentShader:ze.meshlambert_frag},phong:{uniforms:Gt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,ce.lights,{emissive:{value:new xe(0)},specular:{value:new xe(1118481)},shininess:{value:30}}]),vertexShader:ze.meshphong_vert,fragmentShader:ze.meshphong_frag},standard:{uniforms:Gt([ce.common,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.roughnessmap,ce.metalnessmap,ce.fog,ce.lights,{emissive:{value:new xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag},toon:{uniforms:Gt([ce.common,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.gradientmap,ce.fog,ce.lights,{emissive:{value:new xe(0)}}]),vertexShader:ze.meshtoon_vert,fragmentShader:ze.meshtoon_frag},matcap:{uniforms:Gt([ce.common,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,{matcap:{value:null}}]),vertexShader:ze.meshmatcap_vert,fragmentShader:ze.meshmatcap_frag},points:{uniforms:Gt([ce.points,ce.fog]),vertexShader:ze.points_vert,fragmentShader:ze.points_frag},dashed:{uniforms:Gt([ce.common,ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ze.linedashed_vert,fragmentShader:ze.linedashed_frag},depth:{uniforms:Gt([ce.common,ce.displacementmap]),vertexShader:ze.depth_vert,fragmentShader:ze.depth_frag},normal:{uniforms:Gt([ce.common,ce.bumpmap,ce.normalmap,ce.displacementmap,{opacity:{value:1}}]),vertexShader:ze.meshnormal_vert,fragmentShader:ze.meshnormal_frag},sprite:{uniforms:Gt([ce.sprite,ce.fog]),vertexShader:ze.sprite_vert,fragmentShader:ze.sprite_frag},background:{uniforms:{uvTransform:{value:new ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ze.background_vert,fragmentShader:ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ke}},vertexShader:ze.backgroundCube_vert,fragmentShader:ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ze.cube_vert,fragmentShader:ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ze.equirect_vert,fragmentShader:ze.equirect_frag},distanceRGBA:{uniforms:Gt([ce.common,ce.displacementmap,{referencePosition:{value:new w},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ze.distanceRGBA_vert,fragmentShader:ze.distanceRGBA_frag},shadow:{uniforms:Gt([ce.lights,ce.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:ze.shadow_vert,fragmentShader:ze.shadow_frag}};Pi.physical={uniforms:Gt([Pi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ke},clearcoatNormalScale:{value:new oe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ke},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ke},sheen:{value:0},sheenColor:{value:new xe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ke},transmissionSamplerSize:{value:new oe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ke},attenuationDistance:{value:0},attenuationColor:{value:new xe(0)},specularColor:{value:new xe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ke},anisotropyVector:{value:new oe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ke}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag};const wr={r:0,b:0,g:0},fs=new pi,Jf=new De;function Qf(n,e,t,i,s,r,a){const o=new xe(0);let l=r===!0?0:1,c,h,u=null,d=0,m=null;function g(_){let E=_.isScene===!0?_.background:null;return E&&E.isTexture&&(E=(_.backgroundBlurriness>0?t:e).get(E)),E}function v(_){let E=!1;const R=g(_);R===null?p(o,l):R&&R.isColor&&(p(R,1),E=!0);const T=n.xr.getEnvironmentBlendMode();T==="additive"?i.buffers.color.setClear(0,0,0,1,a):T==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,a),(n.autoClear||E)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function f(_,E){const R=g(E);R&&(R.isCubeTexture||R.mapping===Vn)?(h===void 0&&(h=new rt(new ds(1,1,1),new ct({name:"BackgroundCubeMaterial",uniforms:Ws(Pi.backgroundCube.uniforms),vertexShader:Pi.backgroundCube.vertexShader,fragmentShader:Pi.backgroundCube.fragmentShader,side:zt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(T,A,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),fs.copy(E.backgroundRotation),fs.x*=-1,fs.y*=-1,fs.z*=-1,R.isCubeTexture&&R.isRenderTargetTexture===!1&&(fs.y*=-1,fs.z*=-1),h.material.uniforms.envMap.value=R,h.material.uniforms.flipEnvMap.value=R.isCubeTexture&&R.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(Jf.makeRotationFromEuler(fs)),h.material.toneMapped=Xe.getTransfer(R.colorSpace)!==it,(u!==R||d!==R.version||m!==n.toneMapping)&&(h.material.needsUpdate=!0,u=R,d=R.version,m=n.toneMapping),h.layers.enableAll(),_.unshift(h,h.geometry,h.material,0,0,null)):R&&R.isTexture&&(c===void 0&&(c=new rt(new An(2,2),new ct({name:"BackgroundMaterial",uniforms:Ws(Pi.background.uniforms),vertexShader:Pi.background.vertexShader,fragmentShader:Pi.background.fragmentShader,side:Si,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=R,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.toneMapped=Xe.getTransfer(R.colorSpace)!==it,R.matrixAutoUpdate===!0&&R.updateMatrix(),c.material.uniforms.uvTransform.value.copy(R.matrix),(u!==R||d!==R.version||m!==n.toneMapping)&&(c.material.needsUpdate=!0,u=R,d=R.version,m=n.toneMapping),c.layers.enableAll(),_.unshift(c,c.geometry,c.material,0,0,null))}function p(_,E){_.getRGB(wr,sc(n)),i.buffers.color.setClear(wr.r,wr.g,wr.b,E,a)}function b(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(_,E=1){o.set(_),l=E,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(_){l=_,p(o,l)},render:v,addToRenderList:f,dispose:b}}function eg(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=d(null);let r=s,a=!1;function o(M,L,N,z,H){let j=!1;const q=u(z,N,L);r!==q&&(r=q,c(r.object)),j=m(M,z,N,H),j&&g(M,z,N,H),H!==null&&e.update(H,n.ELEMENT_ARRAY_BUFFER),(j||a)&&(a=!1,E(M,L,N,z),H!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function l(){return n.createVertexArray()}function c(M){return n.bindVertexArray(M)}function h(M){return n.deleteVertexArray(M)}function u(M,L,N){const z=N.wireframe===!0;let H=i[M.id];H===void 0&&(H={},i[M.id]=H);let j=H[L.id];j===void 0&&(j={},H[L.id]=j);let q=j[z];return q===void 0&&(q=d(l()),j[z]=q),q}function d(M){const L=[],N=[],z=[];for(let H=0;H =0){const K=H[G];let ne=j[G];if(ne===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(ne=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(ne=M.instanceColor)),K===void 0||K.attribute!==ne||ne&&K.data!==ne.data)return!0;q++}return r.attributesNum!==q||r.index!==z}function g(M,L,N,z){const H={},j=L.attributes;let q=0;const te=N.getAttributes();for(const G in te)if(te[G].location>=0){let K=j[G];K===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(K=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(K=M.instanceColor));const ne={};ne.attribute=K,K&&K.data&&(ne.data=K.data),H[G]=ne,q++}r.attributes=H,r.attributesNum=q,r.index=z}function v(){const M=r.newAttributes;for(let L=0,N=M.length;L =0){let K=H[te];if(K===void 0&&(te==="instanceMatrix"&&M.instanceMatrix&&(K=M.instanceMatrix),te==="instanceColor"&&M.instanceColor&&(K=M.instanceColor)),K!==void 0){const ne=K.normalized,Le=K.itemSize,He=e.get(K);if(He===void 0)continue;const Ye=He.buffer,Je=He.type,Qe=He.bytesPerElement,W=Je===n.INT||Je===n.UNSIGNED_INT||K.gpuType===ta;if(K.isInterleavedBufferAttribute){const Z=K.data,de=Z.stride,Ae=K.offset;if(Z.isInstancedInterleavedBuffer){for(let Te=0;Te 0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(Me("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=n.getParameter(n.MAX_TEXTURE_SIZE),f=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),p=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),_=n.getParameter(n.MAX_VARYING_VECTORS),E=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),R=g>0,T=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:m,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:b,maxVaryings:_,maxFragmentUniforms:E,vertexTextures:R,maxSamples:T}}function sg(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Ai,o=new ke,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const m=u.length!==0||d||i!==0||s;return s=d,i=u.length,m},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,m){const g=u.clippingPlanes,v=u.clipIntersection,f=u.clipShadows,p=n.get(u);if(!s||g===null||g.length===0||r&&!f)r?h(null):c();else{const b=r?0:i,_=b*4;let E=p.clippingState||null;l.value=E,E=h(g,d,_,m);for(let R=0;R!==_;++R)E[R]=t[R];p.clippingState=E,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(u,d,m,g){const v=u!==null?u.length:0;let f=null;if(v!==0){if(f=l.value,g!==!0||f===null){const p=m+v*4,b=d.matrixWorldInverse;o.getNormalMatrix(b),(f===null||f.length 0){const c=new yd(l.height);return c.fromEquirectangularTexture(n,a),e.set(a,c),a.addEventListener("dispose",s),t(c.texture,a.mapping)}else return null}}return a}function s(a){const o=a.target;o.removeEventListener("dispose",s);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function r(){e=new WeakMap}return{get:i,dispose:r}}const is=4,Gc=[.125,.215,.35,.446,.526,.582],gs=20,rg=256,In=new ms,Wc=new xe;let Oo=null,ko=0,Fo=0,zo=!1;const ag=new w;class jc{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,s=100,r={}){const{size:a=256,position:o=ag}=r;Oo=this._renderer.getRenderTarget(),ko=this._renderer.getActiveCubeFace(),Fo=this._renderer.getActiveMipmapLevel(),zo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,s,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Zc(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=qc(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e
2?b:0,b,b),c.setRenderTarget(s),g&&c.render(d,a),c.render(e,a)}c.toneMapping=u,c.autoClear=h,e.background=v}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ws||e.mapping===Cs;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Zc()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=qc());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;tn(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,In)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r g-is?i-g+is:0),p=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=m,l.mipInt.value=g-t,tn(r,f,p,3*v,2*v),s.setRenderTarget(r),s.render(o,In),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-i,tn(e,f,p,3*v,2*v),s.setRenderTarget(e),s.render(o,In)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ve("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[s];u.material=c;const d=c.uniforms,m=this._sizeLods[i]-1,g=isFinite(r)?Math.PI/(2*m):2*Math.PI/(2*gs-1),v=r/g,f=isFinite(r)?1+Math.floor(h*v):gs;f>gs&&Me(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${gs}`);const p=[];let b=0;for(let A=0;A_-is?s-_+is:0),T=4*(this._cubeSize-E);tn(t,R,T,3*E,2*E),l.setRenderTarget(t),l.render(u,In)}}function og(n){const e=[],t=[],i=[];let s=n;const r=n-is+1+Gc.length;for(let a=0;a n-is?l=Gc[a-n+is-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],m=6,g=6,v=3,f=2,p=1,b=new Float32Array(v*g*m),_=new Float32Array(f*g*m),E=new Float32Array(p*g*m);for(let T=0;T 2?0:-1,S=[A,I,0,A+2/3,I,0,A+2/3,I+1,0,A,I,0,A+2/3,I+1,0,A,I+1,0];b.set(S,v*g*T),_.set(d,f*g*T);const M=[T,T,T,T,T,T];E.set(M,p*g*T)}const R=new si;R.setAttribute("position",new Vt(b,v)),R.setAttribute("uv",new Vt(_,f)),R.setAttribute("faceIndex",new Vt(E,p)),i.push(new rt(R,null)),s>is&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function Xc(n,e,t){const i=new yt(n,e,t);return i.texture.mapping=Vn,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function tn(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function lg(n,e,t){return new ct({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:rg,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Cr(),fragmentShader:` +}`,ze={alphahash_fragment:_p,alphahash_pars_fragment:xp,alphamap_fragment:bp,alphamap_pars_fragment:yp,alphatest_fragment:Mp,alphatest_pars_fragment:Sp,aomap_fragment:Tp,aomap_pars_fragment:Ep,batching_pars_vertex:wp,batching_vertex:Cp,begin_vertex:Ap,beginnormal_vertex:Rp,bsdfs:Pp,iridescence_fragment:Lp,bumpmap_pars_fragment:Dp,clipping_planes_fragment:Ip,clipping_planes_pars_fragment:Up,clipping_planes_pars_vertex:Np,clipping_planes_vertex:Bp,color_fragment:Op,color_pars_fragment:kp,color_pars_vertex:Fp,color_vertex:zp,common:Hp,cube_uv_reflection_fragment:Vp,defaultnormal_vertex:Gp,displacementmap_pars_vertex:Wp,displacementmap_vertex:jp,emissivemap_fragment:Xp,emissivemap_pars_fragment:qp,colorspace_fragment:Zp,colorspace_pars_fragment:Yp,envmap_fragment:Kp,envmap_common_pars_fragment:$p,envmap_pars_fragment:Jp,envmap_pars_vertex:Qp,envmap_physical_pars_fragment:hm,envmap_vertex:em,fog_vertex:tm,fog_pars_vertex:im,fog_fragment:sm,fog_pars_fragment:nm,gradientmap_pars_fragment:rm,lightmap_pars_fragment:am,lights_lambert_fragment:om,lights_lambert_pars_fragment:lm,lights_pars_begin:cm,lights_toon_fragment:um,lights_toon_pars_fragment:dm,lights_phong_fragment:pm,lights_phong_pars_fragment:mm,lights_physical_fragment:fm,lights_physical_pars_fragment:gm,lights_fragment_begin:vm,lights_fragment_maps:_m,lights_fragment_end:xm,logdepthbuf_fragment:bm,logdepthbuf_pars_fragment:ym,logdepthbuf_pars_vertex:Mm,logdepthbuf_vertex:Sm,map_fragment:Tm,map_pars_fragment:Em,map_particle_fragment:wm,map_particle_pars_fragment:Cm,metalnessmap_fragment:Am,metalnessmap_pars_fragment:Rm,morphinstance_vertex:Pm,morphcolor_vertex:Lm,morphnormal_vertex:Dm,morphtarget_pars_vertex:Im,morphtarget_vertex:Um,normal_fragment_begin:Nm,normal_fragment_maps:Bm,normal_pars_fragment:Om,normal_pars_vertex:km,normal_vertex:Fm,normalmap_pars_fragment:zm,clearcoat_normal_fragment_begin:Hm,clearcoat_normal_fragment_maps:Vm,clearcoat_pars_fragment:Gm,iridescence_pars_fragment:Wm,opaque_fragment:jm,packing:Xm,premultiplied_alpha_fragment:qm,project_vertex:Zm,dithering_fragment:Ym,dithering_pars_fragment:Km,roughnessmap_fragment:$m,roughnessmap_pars_fragment:Jm,shadowmap_pars_fragment:Qm,shadowmap_pars_vertex:ef,shadowmap_vertex:tf,shadowmask_pars_fragment:sf,skinbase_vertex:nf,skinning_pars_vertex:rf,skinning_vertex:af,skinnormal_vertex:of,specularmap_fragment:lf,specularmap_pars_fragment:cf,tonemapping_fragment:hf,tonemapping_pars_fragment:uf,transmission_fragment:df,transmission_pars_fragment:pf,uv_pars_fragment:mf,uv_pars_vertex:ff,uv_vertex:gf,worldpos_vertex:vf,background_vert:_f,background_frag:xf,backgroundCube_vert:bf,backgroundCube_frag:yf,cube_vert:Mf,cube_frag:Sf,depth_vert:Tf,depth_frag:Ef,distanceRGBA_vert:wf,distanceRGBA_frag:Cf,equirect_vert:Af,equirect_frag:Rf,linedashed_vert:Pf,linedashed_frag:Lf,meshbasic_vert:Df,meshbasic_frag:If,meshlambert_vert:Uf,meshlambert_frag:Nf,meshmatcap_vert:Bf,meshmatcap_frag:Of,meshnormal_vert:kf,meshnormal_frag:Ff,meshphong_vert:zf,meshphong_frag:Hf,meshphysical_vert:Vf,meshphysical_frag:Gf,meshtoon_vert:Wf,meshtoon_frag:jf,points_vert:Xf,points_frag:qf,shadow_vert:Zf,shadow_frag:Yf,sprite_vert:Kf,sprite_frag:$f},ce={common:{diffuse:{value:new xe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ke}},envmap:{envMap:{value:null},envMapRotation:{value:new ke},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ke},normalScale:{value:new oe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new xe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0},uvTransform:{value:new ke}},sprite:{diffuse:{value:new xe(16777215)},opacity:{value:1},center:{value:new oe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ke},alphaMap:{value:null},alphaMapTransform:{value:new ke},alphaTest:{value:0}}},Pi={basic:{uniforms:Gt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.fog]),vertexShader:ze.meshbasic_vert,fragmentShader:ze.meshbasic_frag},lambert:{uniforms:Gt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,ce.lights,{emissive:{value:new xe(0)}}]),vertexShader:ze.meshlambert_vert,fragmentShader:ze.meshlambert_frag},phong:{uniforms:Gt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,ce.lights,{emissive:{value:new xe(0)},specular:{value:new xe(1118481)},shininess:{value:30}}]),vertexShader:ze.meshphong_vert,fragmentShader:ze.meshphong_frag},standard:{uniforms:Gt([ce.common,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.roughnessmap,ce.metalnessmap,ce.fog,ce.lights,{emissive:{value:new xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag},toon:{uniforms:Gt([ce.common,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.gradientmap,ce.fog,ce.lights,{emissive:{value:new xe(0)}}]),vertexShader:ze.meshtoon_vert,fragmentShader:ze.meshtoon_frag},matcap:{uniforms:Gt([ce.common,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,{matcap:{value:null}}]),vertexShader:ze.meshmatcap_vert,fragmentShader:ze.meshmatcap_frag},points:{uniforms:Gt([ce.points,ce.fog]),vertexShader:ze.points_vert,fragmentShader:ze.points_frag},dashed:{uniforms:Gt([ce.common,ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ze.linedashed_vert,fragmentShader:ze.linedashed_frag},depth:{uniforms:Gt([ce.common,ce.displacementmap]),vertexShader:ze.depth_vert,fragmentShader:ze.depth_frag},normal:{uniforms:Gt([ce.common,ce.bumpmap,ce.normalmap,ce.displacementmap,{opacity:{value:1}}]),vertexShader:ze.meshnormal_vert,fragmentShader:ze.meshnormal_frag},sprite:{uniforms:Gt([ce.sprite,ce.fog]),vertexShader:ze.sprite_vert,fragmentShader:ze.sprite_frag},background:{uniforms:{uvTransform:{value:new ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ze.background_vert,fragmentShader:ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ke}},vertexShader:ze.backgroundCube_vert,fragmentShader:ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ze.cube_vert,fragmentShader:ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ze.equirect_vert,fragmentShader:ze.equirect_frag},distanceRGBA:{uniforms:Gt([ce.common,ce.displacementmap,{referencePosition:{value:new w},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ze.distanceRGBA_vert,fragmentShader:ze.distanceRGBA_frag},shadow:{uniforms:Gt([ce.lights,ce.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:ze.shadow_vert,fragmentShader:ze.shadow_frag}};Pi.physical={uniforms:Gt([Pi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ke},clearcoatNormalScale:{value:new oe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ke},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ke},sheen:{value:0},sheenColor:{value:new xe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ke},transmissionSamplerSize:{value:new oe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ke},attenuationDistance:{value:0},attenuationColor:{value:new xe(0)},specularColor:{value:new xe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ke},anisotropyVector:{value:new oe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ke}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag};const wr={r:0,b:0,g:0},fs=new pi,Jf=new De;function Qf(n,e,t,i,s,r,a){const o=new xe(0);let l=r===!0?0:1,c,h,u=null,d=0,m=null;function g(_){let E=_.isScene===!0?_.background:null;return E&&E.isTexture&&(E=(_.backgroundBlurriness>0?t:e).get(E)),E}function v(_){let E=!1;const R=g(_);R===null?p(o,l):R&&R.isColor&&(p(R,1),E=!0);const T=n.xr.getEnvironmentBlendMode();T==="additive"?i.buffers.color.setClear(0,0,0,1,a):T==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,a),(n.autoClear||E)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function f(_,E){const R=g(E);R&&(R.isCubeTexture||R.mapping===Vn)?(h===void 0&&(h=new rt(new ds(1,1,1),new ct({name:"BackgroundCubeMaterial",uniforms:Ws(Pi.backgroundCube.uniforms),vertexShader:Pi.backgroundCube.vertexShader,fragmentShader:Pi.backgroundCube.fragmentShader,side:zt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(T,A,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),fs.copy(E.backgroundRotation),fs.x*=-1,fs.y*=-1,fs.z*=-1,R.isCubeTexture&&R.isRenderTargetTexture===!1&&(fs.y*=-1,fs.z*=-1),h.material.uniforms.envMap.value=R,h.material.uniforms.flipEnvMap.value=R.isCubeTexture&&R.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(Jf.makeRotationFromEuler(fs)),h.material.toneMapped=Xe.getTransfer(R.colorSpace)!==it,(u!==R||d!==R.version||m!==n.toneMapping)&&(h.material.needsUpdate=!0,u=R,d=R.version,m=n.toneMapping),h.layers.enableAll(),_.unshift(h,h.geometry,h.material,0,0,null)):R&&R.isTexture&&(c===void 0&&(c=new rt(new An(2,2),new ct({name:"BackgroundMaterial",uniforms:Ws(Pi.background.uniforms),vertexShader:Pi.background.vertexShader,fragmentShader:Pi.background.fragmentShader,side:Si,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=R,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.toneMapped=Xe.getTransfer(R.colorSpace)!==it,R.matrixAutoUpdate===!0&&R.updateMatrix(),c.material.uniforms.uvTransform.value.copy(R.matrix),(u!==R||d!==R.version||m!==n.toneMapping)&&(c.material.needsUpdate=!0,u=R,d=R.version,m=n.toneMapping),c.layers.enableAll(),_.unshift(c,c.geometry,c.material,0,0,null))}function p(_,E){_.getRGB(wr,sc(n)),i.buffers.color.setClear(wr.r,wr.g,wr.b,E,a)}function b(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(_,E=1){o.set(_),l=E,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(_){l=_,p(o,l)},render:v,addToRenderList:f,dispose:b}}function eg(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=d(null);let r=s,a=!1;function o(M,L,N,z,H){let j=!1;const q=u(z,N,L);r!==q&&(r=q,c(r.object)),j=m(M,z,N,H),j&&g(M,z,N,H),H!==null&&e.update(H,n.ELEMENT_ARRAY_BUFFER),(j||a)&&(a=!1,E(M,L,N,z),H!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function l(){return n.createVertexArray()}function c(M){return n.bindVertexArray(M)}function h(M){return n.deleteVertexArray(M)}function u(M,L,N){const z=N.wireframe===!0;let H=i[M.id];H===void 0&&(H={},i[M.id]=H);let j=H[L.id];j===void 0&&(j={},H[L.id]=j);let q=j[z];return q===void 0&&(q=d(l()),j[z]=q),q}function d(M){const L=[],N=[],z=[];for(let H=0;H =0){const K=H[G];let ne=j[G];if(ne===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(ne=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(ne=M.instanceColor)),K===void 0||K.attribute!==ne||ne&&K.data!==ne.data)return!0;q++}return r.attributesNum!==q||r.index!==z}function g(M,L,N,z){const H={},j=L.attributes;let q=0;const te=N.getAttributes();for(const G in te)if(te[G].location>=0){let K=j[G];K===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(K=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(K=M.instanceColor));const ne={};ne.attribute=K,K&&K.data&&(ne.data=K.data),H[G]=ne,q++}r.attributes=H,r.attributesNum=q,r.index=z}function v(){const M=r.newAttributes;for(let L=0,N=M.length;L =0){let K=H[te];if(K===void 0&&(te==="instanceMatrix"&&M.instanceMatrix&&(K=M.instanceMatrix),te==="instanceColor"&&M.instanceColor&&(K=M.instanceColor)),K!==void 0){const ne=K.normalized,Le=K.itemSize,He=e.get(K);if(He===void 0)continue;const Ye=He.buffer,Je=He.type,Qe=He.bytesPerElement,W=Je===n.INT||Je===n.UNSIGNED_INT||K.gpuType===ta;if(K.isInterleavedBufferAttribute){const Z=K.data,de=Z.stride,Ae=K.offset;if(Z.isInstancedInterleavedBuffer){for(let Te=0;Te 0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(Me("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=n.getParameter(n.MAX_TEXTURE_SIZE),f=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),p=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),_=n.getParameter(n.MAX_VARYING_VECTORS),E=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),R=g>0,T=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:m,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:b,maxVaryings:_,maxFragmentUniforms:E,vertexTextures:R,maxSamples:T}}function sg(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Ai,o=new ke,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const m=u.length!==0||d||i!==0||s;return s=d,i=u.length,m},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,m){const g=u.clippingPlanes,v=u.clipIntersection,f=u.clipShadows,p=n.get(u);if(!s||g===null||g.length===0||r&&!f)r?h(null):c();else{const b=r?0:i,_=b*4;let E=p.clippingState||null;l.value=E,E=h(g,d,_,m);for(let R=0;R!==_;++R)E[R]=t[R];p.clippingState=E,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(u,d,m,g){const v=u!==null?u.length:0;let f=null;if(v!==0){if(f=l.value,g!==!0||f===null){const p=m+v*4,b=d.matrixWorldInverse;o.getNormalMatrix(b),(f===null||f.length 0){const c=new yd(l.height);return c.fromEquirectangularTexture(n,a),e.set(a,c),a.addEventListener("dispose",s),t(c.texture,a.mapping)}else return null}}return a}function s(a){const o=a.target;o.removeEventListener("dispose",s);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function r(){e=new WeakMap}return{get:i,dispose:r}}const is=4,Gc=[.125,.215,.35,.446,.526,.582],gs=20,rg=256,In=new ms,Wc=new xe;let Oo=null,ko=0,Fo=0,zo=!1;const ag=new w;class jc{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,s=100,r={}){const{size:a=256,position:o=ag}=r;Oo=this._renderer.getRenderTarget(),ko=this._renderer.getActiveCubeFace(),Fo=this._renderer.getActiveMipmapLevel(),zo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,s,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Zc(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=qc(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e
2?b:0,b,b),c.setRenderTarget(s),g&&c.render(d,a),c.render(e,a)}c.toneMapping=u,c.autoClear=h,e.background=v}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ws||e.mapping===Cs;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Zc()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=qc());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;tn(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,In)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r g-is?i-g+is:0),p=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=m,l.mipInt.value=g-t,tn(r,f,p,3*v,2*v),s.setRenderTarget(r),s.render(o,In),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-i,tn(e,f,p,3*v,2*v),s.setRenderTarget(e),s.render(o,In)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ve("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[s];u.material=c;const d=c.uniforms,m=this._sizeLods[i]-1,g=isFinite(r)?Math.PI/(2*m):2*Math.PI/(2*gs-1),v=r/g,f=isFinite(r)?1+Math.floor(h*v):gs;f>gs&&Me(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${gs}`);const p=[];let b=0;for(let A=0;A_-is?s-_+is:0),T=4*(this._cubeSize-E);tn(t,R,T,3*E,2*E),l.setRenderTarget(t),l.render(u,In)}}function og(n){const e=[],t=[],i=[];let s=n;const r=n-is+1+Gc.length;for(let a=0;a n-is?l=Gc[a-n+is-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],m=6,g=6,v=3,f=2,p=1,b=new Float32Array(v*g*m),_=new Float32Array(f*g*m),E=new Float32Array(p*g*m);for(let T=0;T 2?0:-1,S=[A,I,0,A+2/3,I,0,A+2/3,I+1,0,A,I,0,A+2/3,I+1,0,A,I+1,0];b.set(S,v*g*T),_.set(d,f*g*T);const M=[T,T,T,T,T,T];E.set(M,p*g*T)}const R=new si;R.setAttribute("position",new Vt(b,v)),R.setAttribute("uv",new Vt(_,f)),R.setAttribute("faceIndex",new Vt(E,p)),i.push(new rt(R,null)),s>is&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function Xc(n,e,t){const i=new Mt(n,e,t);return i.texture.mapping=Vn,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function tn(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function lg(n,e,t){return new ct({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:rg,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Cr(),fragmentShader:` precision highp float; precision highp int; @@ -3697,7 +3697,7 @@ void main() { gl_FragColor = vec4(prefilteredColor, 1.0); } - `,blending:xt,depthTest:!1,depthWrite:!1})}function cg(n,e,t){const i=new Float32Array(gs),s=new w(0,1,0);return new ct({name:"SphericalGaussianBlur",defines:{n:gs,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Cr(),fragmentShader:` + `,blending:bt,depthTest:!1,depthWrite:!1})}function cg(n,e,t){const i=new Float32Array(gs),s=new w(0,1,0);return new ct({name:"SphericalGaussianBlur",defines:{n:gs,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Cr(),fragmentShader:` precision mediump float; precision mediump int; @@ -3757,7 +3757,7 @@ void main() { } } - `,blending:xt,depthTest:!1,depthWrite:!1})}function qc(){return new ct({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Cr(),fragmentShader:` + `,blending:bt,depthTest:!1,depthWrite:!1})}function qc(){return new ct({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Cr(),fragmentShader:` precision mediump float; precision mediump int; @@ -3776,7 +3776,7 @@ void main() { gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } - `,blending:xt,depthTest:!1,depthWrite:!1})}function Zc(){return new ct({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Cr(),fragmentShader:` + `,blending:bt,depthTest:!1,depthWrite:!1})}function Zc(){return new ct({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Cr(),fragmentShader:` precision mediump float; precision mediump int; @@ -3792,7 +3792,7 @@ void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } - `,blending:xt,depthTest:!1,depthWrite:!1})}function Cr(){return` + `,blending:bt,depthTest:!1,depthWrite:!1})}function Cr(){return` precision mediump float; precision mediump int; @@ -3847,7 +3847,7 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}function hg(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===Hn||l===ea,h=l===ws||l===Cs;if(c||h){let u=e.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new jc(n)),u=c?t.fromEquirectangular(o,u):t.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),u.texture;if(u!==void 0)return u.texture;{const m=o.image;return c&&m&&m.height>0||h&&m&&s(m)?(t===null&&(t=new jc(n)),u=c?t.fromEquirectangular(o):t.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),o.addEventListener("dispose",r),u.texture):null}}}return o}function s(o){let l=0;const c=6;for(let h=0;h e.maxTextureSize&&(T=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const A=new Float32Array(R*T*4*u),I=new Vl(A,R,T,u);I.type=qt,I.needsUpdate=!0;const S=E*4;for(let M=0;M0)return n;const s=e*t;let r=eh[s];if(r===void 0&&(r=new Float32Array(s),eh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function Tt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0||h&&m&&s(m)?(t===null&&(t=new jc(n)),u=c?t.fromEquirectangular(o):t.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),o.addEventListener("dispose",r),u.texture):null}}}return o}function s(o){let l=0;const c=6;for(let h=0;h e.maxTextureSize&&(T=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const A=new Float32Array(R*T*4*u),I=new Vl(A,R,T,u);I.type=qt,I.needsUpdate=!0;const S=E*4;for(let M=0;M0)return n;const s=e*t;let r=eh[s];if(r===void 0&&(r=new Float32Array(s),eh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function Et(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t":" "} ${o}: ${t[a]}`)}return i.join(` `)}const oh=new ke;function h0(n){Xe._getMatrix(oh,Xe.workingColorSpace,n);const e=`mat3( ${oh.elements.map(t=>t.toFixed(4))} )`;switch(Xe.getTransfer(n)){case Kn:return[e,"LinearTransferOETF"];case it:return[e,"sRGBTransferOETF"];default:return Me("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function lh(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),s=(n.getShaderInfoLog(e)||"").trim();if(i&&s==="")return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const a=parseInt(r[1]);return t.toUpperCase()+` @@ -3898,7 +3898,7 @@ Material Type: `+L.type+` Program Info Log: `+j+` `+ne+` -`+Le)}else j!==""?Me("WebGLProgram: Program Info Log:",j):(q===""||te==="")&&(K=!1);K&&(L.diagnostics={runnable:G,programLog:j,vertexShader:{log:q,prefix:f},fragmentShader:{log:te,prefix:p}})}s.deleteShader(R),s.deleteShader(T),I=new Rr(s,v),S=g0(s,v)}let I;this.getUniforms=function(){return I===void 0&&A(this),I};let S;this.getAttributes=function(){return S===void 0&&A(this),S};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=s.getProgramParameter(v,o0)),M},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=l0++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=R,this.fragmentShader=T,this}let A0=0;class R0{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,s=this._getShaderStage(t),r=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new P0(e),t.set(e,i)),i}}class P0{constructor(e){this.id=A0++,this.code=e,this.usedTimes=0}}function L0(n,e,t,i,s,r,a){const o=new to,l=new R0,c=new Set,h=[],u=s.logarithmicDepthBuffer,d=s.vertexTextures;let m=s.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(S){return c.add(S),S===0?"uv":`uv${S}`}function f(S,M,L,N,z){const H=N.fog,j=z.geometry,q=S.isMeshStandardMaterial?N.environment:null,te=(S.isMeshStandardMaterial?t:e).get(S.envMap||q),G=te&&te.mapping===Vn?te.image.height:null,K=g[S.type];S.precision!==null&&(m=s.getMaxPrecision(S.precision),m!==S.precision&&Me("WebGLProgram.getParameters:",S.precision,"not supported, using",m,"instead."));const ne=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,Le=ne!==void 0?ne.length:0;let He=0;j.morphAttributes.position!==void 0&&(He=1),j.morphAttributes.normal!==void 0&&(He=2),j.morphAttributes.color!==void 0&&(He=3);let Ye,Je,Qe,W;if(K){const ot=Pi[K];Ye=ot.vertexShader,Je=ot.fragmentShader}else Ye=S.vertexShader,Je=S.fragmentShader,l.update(S),Qe=l.getVertexShaderID(S),W=l.getFragmentShaderID(S);const Z=n.getRenderTarget(),de=n.state.buffers.depth.getReversed(),Ae=z.isInstancedMesh===!0,Te=z.isBatchedMesh===!0,we=!!S.map,et=!!S.matcap,qe=!!te,We=!!S.aoMap,D=!!S.lightMap,_t=!!S.bumpMap,je=!!S.normalMap,tt=!!S.displacementMap,fe=!!S.emissiveMap,lt=!!S.metalnessMap,Se=!!S.roughnessMap,Ie=S.anisotropy>0,C=S.clearcoat>0,x=S.dispersion>0,O=S.iridescence>0,X=S.sheen>0,Y=S.transmission>0,V=Ie&&!!S.anisotropyMap,be=C&&!!S.clearcoatMap,re=C&&!!S.clearcoatNormalMap,Ee=C&&!!S.clearcoatRoughnessMap,pe=O&&!!S.iridescenceMap,J=O&&!!S.iridescenceThicknessMap,se=X&&!!S.sheenColorMap,Oe=X&&!!S.sheenRoughnessMap,Ce=!!S.specularMap,ue=!!S.specularColorMap,Re=!!S.specularIntensityMap,P=Y&&!!S.transmissionMap,ae=Y&&!!S.thicknessMap,ie=!!S.gradientMap,he=!!S.alphaMap,Q=S.alphaTest>0,$=!!S.alphaHash,_e=!!S.extensions;let Pe=qi;S.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(Pe=n.toneMapping);const Lt={shaderID:K,shaderType:S.type,shaderName:S.name,vertexShader:Ye,fragmentShader:Je,defines:S.defines,customVertexShaderID:Qe,customFragmentShaderID:W,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:m,batching:Te,batchingColor:Te&&z._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&z.instanceColor!==null,instancingMorph:Ae&&z.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:Z===null?n.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:Bt,alphaToCoverage:!!S.alphaToCoverage,map:we,matcap:et,envMap:qe,envMapMode:qe&&te.mapping,envMapCubeUVHeight:G,aoMap:We,lightMap:D,bumpMap:_t,normalMap:je,displacementMap:d&&tt,emissiveMap:fe,normalMapObjectSpace:je&&S.normalMapType===Tu,normalMapTangentSpace:je&&S.normalMapType===Yn,metalnessMap:lt,roughnessMap:Se,anisotropy:Ie,anisotropyMap:V,clearcoat:C,clearcoatMap:be,clearcoatNormalMap:re,clearcoatRoughnessMap:Ee,dispersion:x,iridescence:O,iridescenceMap:pe,iridescenceThicknessMap:J,sheen:X,sheenColorMap:se,sheenRoughnessMap:Oe,specularMap:Ce,specularColorMap:ue,specularIntensityMap:Re,transmission:Y,transmissionMap:P,thicknessMap:ae,gradientMap:ie,opaque:S.transparent===!1&&S.blending===Ts&&S.alphaToCoverage===!1,alphaMap:he,alphaTest:Q,alphaHash:$,combine:S.combine,mapUv:we&&v(S.map.channel),aoMapUv:We&&v(S.aoMap.channel),lightMapUv:D&&v(S.lightMap.channel),bumpMapUv:_t&&v(S.bumpMap.channel),normalMapUv:je&&v(S.normalMap.channel),displacementMapUv:tt&&v(S.displacementMap.channel),emissiveMapUv:fe&&v(S.emissiveMap.channel),metalnessMapUv:lt&&v(S.metalnessMap.channel),roughnessMapUv:Se&&v(S.roughnessMap.channel),anisotropyMapUv:V&&v(S.anisotropyMap.channel),clearcoatMapUv:be&&v(S.clearcoatMap.channel),clearcoatNormalMapUv:re&&v(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ee&&v(S.clearcoatRoughnessMap.channel),iridescenceMapUv:pe&&v(S.iridescenceMap.channel),iridescenceThicknessMapUv:J&&v(S.iridescenceThicknessMap.channel),sheenColorMapUv:se&&v(S.sheenColorMap.channel),sheenRoughnessMapUv:Oe&&v(S.sheenRoughnessMap.channel),specularMapUv:Ce&&v(S.specularMap.channel),specularColorMapUv:ue&&v(S.specularColorMap.channel),specularIntensityMapUv:Re&&v(S.specularIntensityMap.channel),transmissionMapUv:P&&v(S.transmissionMap.channel),thicknessMapUv:ae&&v(S.thicknessMap.channel),alphaMapUv:he&&v(S.alphaMap.channel),vertexTangents:!!j.attributes.tangent&&(je||Ie),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!j.attributes.color&&j.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!j.attributes.uv&&(we||he),fog:!!H,useFog:S.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:S.flatShading===!0&&S.wireframe===!1,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:de,skinning:z.isSkinnedMesh===!0,morphTargets:j.morphAttributes.position!==void 0,morphNormals:j.morphAttributes.normal!==void 0,morphColors:j.morphAttributes.color!==void 0,morphTargetsCount:Le,morphTextureStride:He,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:n.shadowMap.enabled&&L.length>0,shadowMapType:n.shadowMap.type,toneMapping:Pe,decodeVideoTexture:we&&S.map.isVideoTexture===!0&&Xe.getTransfer(S.map.colorSpace)===it,decodeVideoTextureEmissive:fe&&S.emissiveMap.isVideoTexture===!0&&Xe.getTransfer(S.emissiveMap.colorSpace)===it,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Xt,flipSided:S.side===zt,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionClipCullDistance:_e&&S.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(_e&&S.extensions.multiDraw===!0||Te)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()};return Lt.vertexUv1s=c.has(1),Lt.vertexUv2s=c.has(2),Lt.vertexUv3s=c.has(3),c.clear(),Lt}function p(S){const M=[];if(S.shaderID?M.push(S.shaderID):(M.push(S.customVertexShaderID),M.push(S.customFragmentShaderID)),S.defines!==void 0)for(const L in S.defines)M.push(L),M.push(S.defines[L]);return S.isRawShaderMaterial===!1&&(b(M,S),_(M,S),M.push(n.outputColorSpace)),M.push(S.customProgramCacheKey),M.join()}function b(S,M){S.push(M.precision),S.push(M.outputColorSpace),S.push(M.envMapMode),S.push(M.envMapCubeUVHeight),S.push(M.mapUv),S.push(M.alphaMapUv),S.push(M.lightMapUv),S.push(M.aoMapUv),S.push(M.bumpMapUv),S.push(M.normalMapUv),S.push(M.displacementMapUv),S.push(M.emissiveMapUv),S.push(M.metalnessMapUv),S.push(M.roughnessMapUv),S.push(M.anisotropyMapUv),S.push(M.clearcoatMapUv),S.push(M.clearcoatNormalMapUv),S.push(M.clearcoatRoughnessMapUv),S.push(M.iridescenceMapUv),S.push(M.iridescenceThicknessMapUv),S.push(M.sheenColorMapUv),S.push(M.sheenRoughnessMapUv),S.push(M.specularMapUv),S.push(M.specularColorMapUv),S.push(M.specularIntensityMapUv),S.push(M.transmissionMapUv),S.push(M.thicknessMapUv),S.push(M.combine),S.push(M.fogExp2),S.push(M.sizeAttenuation),S.push(M.morphTargetsCount),S.push(M.morphAttributeCount),S.push(M.numDirLights),S.push(M.numPointLights),S.push(M.numSpotLights),S.push(M.numSpotLightMaps),S.push(M.numHemiLights),S.push(M.numRectAreaLights),S.push(M.numDirLightShadows),S.push(M.numPointLightShadows),S.push(M.numSpotLightShadows),S.push(M.numSpotLightShadowsWithMaps),S.push(M.numLightProbes),S.push(M.shadowMapType),S.push(M.toneMapping),S.push(M.numClippingPlanes),S.push(M.numClipIntersection),S.push(M.depthPacking)}function _(S,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),M.gradientMap&&o.enable(22),S.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.reversedDepthBuffer&&o.enable(4),M.skinning&&o.enable(5),M.morphTargets&&o.enable(6),M.morphNormals&&o.enable(7),M.morphColors&&o.enable(8),M.premultipliedAlpha&&o.enable(9),M.shadowMapEnabled&&o.enable(10),M.doubleSided&&o.enable(11),M.flipSided&&o.enable(12),M.useDepthPacking&&o.enable(13),M.dithering&&o.enable(14),M.transmission&&o.enable(15),M.sheen&&o.enable(16),M.opaque&&o.enable(17),M.pointsUvs&&o.enable(18),M.decodeVideoTexture&&o.enable(19),M.decodeVideoTextureEmissive&&o.enable(20),M.alphaToCoverage&&o.enable(21),S.push(o.mask)}function E(S){const M=g[S.type];let L;if(M){const N=Pi[M];L=vi.clone(N.uniforms)}else L=S.uniforms;return L}function R(S,M){let L;for(let N=0,z=h.length;N 0?i.push(p):m.transparent===!0?s.push(p):t.push(p)}function l(u,d,m,g,v,f){const p=a(u,d,m,g,v,f);m.transmission>0?i.unshift(p):m.transparent===!0?s.unshift(p):t.unshift(p)}function c(u,d){t.length>1&&t.sort(u||I0),i.length>1&&i.sort(d||ph),s.length>1&&s.sort(d||ph)}function h(){for(let u=e,d=n.length;u =r.length?(a=new mh,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function N0(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new w,color:new xe};break;case"SpotLight":t={position:new w,direction:new w,color:new xe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new w,color:new xe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new w,skyColor:new xe,groundColor:new xe};break;case"RectAreaLight":t={color:new xe,position:new w,halfWidth:new w,halfHeight:new w};break}return n[e.id]=t,t}}}function B0(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let O0=0;function k0(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function F0(n){const e=new N0,t=B0(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new w);const s=new w,r=new De,a=new De;function o(c){let h=0,u=0,d=0;for(let S=0;S<9;S++)i.probe[S].set(0,0,0);let m=0,g=0,v=0,f=0,p=0,b=0,_=0,E=0,R=0,T=0,A=0;c.sort(k0);for(let S=0,M=c.length;S 0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ce.LTC_FLOAT_1,i.rectAreaLTC2=ce.LTC_FLOAT_2):(i.rectAreaLTC1=ce.LTC_HALF_1,i.rectAreaLTC2=ce.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=u,i.ambient[2]=d;const I=i.hash;(I.directionalLength!==m||I.pointLength!==g||I.spotLength!==v||I.rectAreaLength!==f||I.hemiLength!==p||I.numDirectionalShadows!==b||I.numPointShadows!==_||I.numSpotShadows!==E||I.numSpotMaps!==R||I.numLightProbes!==A)&&(i.directional.length=m,i.spot.length=v,i.rectArea.length=f,i.point.length=g,i.hemi.length=p,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=_,i.pointShadowMap.length=_,i.spotShadow.length=E,i.spotShadowMap.length=E,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=_,i.spotLightMatrix.length=E+R-T,i.spotLightMap.length=R,i.numSpotLightShadowsWithMaps=T,i.numLightProbes=A,I.directionalLength=m,I.pointLength=g,I.spotLength=v,I.rectAreaLength=f,I.hemiLength=p,I.numDirectionalShadows=b,I.numPointShadows=_,I.numSpotShadows=E,I.numSpotMaps=R,I.numLightProbes=A,i.version=O0++)}function l(c,h){let u=0,d=0,m=0,g=0,v=0;const f=h.matrixWorldInverse;for(let p=0,b=c.length;p=a.length?(o=new fh(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const H0=`void main() { +`+Le)}else j!==""?Me("WebGLProgram: Program Info Log:",j):(q===""||te==="")&&(K=!1);K&&(L.diagnostics={runnable:G,programLog:j,vertexShader:{log:q,prefix:f},fragmentShader:{log:te,prefix:p}})}s.deleteShader(R),s.deleteShader(T),I=new Rr(s,v),S=g0(s,v)}let I;this.getUniforms=function(){return I===void 0&&A(this),I};let S;this.getAttributes=function(){return S===void 0&&A(this),S};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=s.getProgramParameter(v,o0)),M},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=l0++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=R,this.fragmentShader=T,this}let A0=0;class R0{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,s=this._getShaderStage(t),r=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new P0(e),t.set(e,i)),i}}class P0{constructor(e){this.id=A0++,this.code=e,this.usedTimes=0}}function L0(n,e,t,i,s,r,a){const o=new to,l=new R0,c=new Set,h=[],u=s.logarithmicDepthBuffer,d=s.vertexTextures;let m=s.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(S){return c.add(S),S===0?"uv":`uv${S}`}function f(S,M,L,N,z){const H=N.fog,j=z.geometry,q=S.isMeshStandardMaterial?N.environment:null,te=(S.isMeshStandardMaterial?t:e).get(S.envMap||q),G=te&&te.mapping===Vn?te.image.height:null,K=g[S.type];S.precision!==null&&(m=s.getMaxPrecision(S.precision),m!==S.precision&&Me("WebGLProgram.getParameters:",S.precision,"not supported, using",m,"instead."));const ne=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,Le=ne!==void 0?ne.length:0;let He=0;j.morphAttributes.position!==void 0&&(He=1),j.morphAttributes.normal!==void 0&&(He=2),j.morphAttributes.color!==void 0&&(He=3);let Ye,Je,Qe,W;if(K){const ot=Pi[K];Ye=ot.vertexShader,Je=ot.fragmentShader}else Ye=S.vertexShader,Je=S.fragmentShader,l.update(S),Qe=l.getVertexShaderID(S),W=l.getFragmentShaderID(S);const Z=n.getRenderTarget(),de=n.state.buffers.depth.getReversed(),Ae=z.isInstancedMesh===!0,Te=z.isBatchedMesh===!0,we=!!S.map,et=!!S.matcap,qe=!!te,We=!!S.aoMap,D=!!S.lightMap,xt=!!S.bumpMap,je=!!S.normalMap,tt=!!S.displacementMap,fe=!!S.emissiveMap,lt=!!S.metalnessMap,Se=!!S.roughnessMap,Ie=S.anisotropy>0,C=S.clearcoat>0,x=S.dispersion>0,O=S.iridescence>0,X=S.sheen>0,Y=S.transmission>0,V=Ie&&!!S.anisotropyMap,be=C&&!!S.clearcoatMap,re=C&&!!S.clearcoatNormalMap,Ee=C&&!!S.clearcoatRoughnessMap,pe=O&&!!S.iridescenceMap,J=O&&!!S.iridescenceThicknessMap,se=X&&!!S.sheenColorMap,Oe=X&&!!S.sheenRoughnessMap,Ce=!!S.specularMap,ue=!!S.specularColorMap,Re=!!S.specularIntensityMap,P=Y&&!!S.transmissionMap,ae=Y&&!!S.thicknessMap,ie=!!S.gradientMap,he=!!S.alphaMap,Q=S.alphaTest>0,$=!!S.alphaHash,_e=!!S.extensions;let Pe=qi;S.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(Pe=n.toneMapping);const Dt={shaderID:K,shaderType:S.type,shaderName:S.name,vertexShader:Ye,fragmentShader:Je,defines:S.defines,customVertexShaderID:Qe,customFragmentShaderID:W,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:m,batching:Te,batchingColor:Te&&z._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&z.instanceColor!==null,instancingMorph:Ae&&z.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:Z===null?n.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:Ot,alphaToCoverage:!!S.alphaToCoverage,map:we,matcap:et,envMap:qe,envMapMode:qe&&te.mapping,envMapCubeUVHeight:G,aoMap:We,lightMap:D,bumpMap:xt,normalMap:je,displacementMap:d&&tt,emissiveMap:fe,normalMapObjectSpace:je&&S.normalMapType===Tu,normalMapTangentSpace:je&&S.normalMapType===Yn,metalnessMap:lt,roughnessMap:Se,anisotropy:Ie,anisotropyMap:V,clearcoat:C,clearcoatMap:be,clearcoatNormalMap:re,clearcoatRoughnessMap:Ee,dispersion:x,iridescence:O,iridescenceMap:pe,iridescenceThicknessMap:J,sheen:X,sheenColorMap:se,sheenRoughnessMap:Oe,specularMap:Ce,specularColorMap:ue,specularIntensityMap:Re,transmission:Y,transmissionMap:P,thicknessMap:ae,gradientMap:ie,opaque:S.transparent===!1&&S.blending===Ts&&S.alphaToCoverage===!1,alphaMap:he,alphaTest:Q,alphaHash:$,combine:S.combine,mapUv:we&&v(S.map.channel),aoMapUv:We&&v(S.aoMap.channel),lightMapUv:D&&v(S.lightMap.channel),bumpMapUv:xt&&v(S.bumpMap.channel),normalMapUv:je&&v(S.normalMap.channel),displacementMapUv:tt&&v(S.displacementMap.channel),emissiveMapUv:fe&&v(S.emissiveMap.channel),metalnessMapUv:lt&&v(S.metalnessMap.channel),roughnessMapUv:Se&&v(S.roughnessMap.channel),anisotropyMapUv:V&&v(S.anisotropyMap.channel),clearcoatMapUv:be&&v(S.clearcoatMap.channel),clearcoatNormalMapUv:re&&v(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ee&&v(S.clearcoatRoughnessMap.channel),iridescenceMapUv:pe&&v(S.iridescenceMap.channel),iridescenceThicknessMapUv:J&&v(S.iridescenceThicknessMap.channel),sheenColorMapUv:se&&v(S.sheenColorMap.channel),sheenRoughnessMapUv:Oe&&v(S.sheenRoughnessMap.channel),specularMapUv:Ce&&v(S.specularMap.channel),specularColorMapUv:ue&&v(S.specularColorMap.channel),specularIntensityMapUv:Re&&v(S.specularIntensityMap.channel),transmissionMapUv:P&&v(S.transmissionMap.channel),thicknessMapUv:ae&&v(S.thicknessMap.channel),alphaMapUv:he&&v(S.alphaMap.channel),vertexTangents:!!j.attributes.tangent&&(je||Ie),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!j.attributes.color&&j.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!j.attributes.uv&&(we||he),fog:!!H,useFog:S.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:S.flatShading===!0&&S.wireframe===!1,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:de,skinning:z.isSkinnedMesh===!0,morphTargets:j.morphAttributes.position!==void 0,morphNormals:j.morphAttributes.normal!==void 0,morphColors:j.morphAttributes.color!==void 0,morphTargetsCount:Le,morphTextureStride:He,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:n.shadowMap.enabled&&L.length>0,shadowMapType:n.shadowMap.type,toneMapping:Pe,decodeVideoTexture:we&&S.map.isVideoTexture===!0&&Xe.getTransfer(S.map.colorSpace)===it,decodeVideoTextureEmissive:fe&&S.emissiveMap.isVideoTexture===!0&&Xe.getTransfer(S.emissiveMap.colorSpace)===it,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Xt,flipSided:S.side===zt,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionClipCullDistance:_e&&S.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(_e&&S.extensions.multiDraw===!0||Te)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()};return Dt.vertexUv1s=c.has(1),Dt.vertexUv2s=c.has(2),Dt.vertexUv3s=c.has(3),c.clear(),Dt}function p(S){const M=[];if(S.shaderID?M.push(S.shaderID):(M.push(S.customVertexShaderID),M.push(S.customFragmentShaderID)),S.defines!==void 0)for(const L in S.defines)M.push(L),M.push(S.defines[L]);return S.isRawShaderMaterial===!1&&(b(M,S),_(M,S),M.push(n.outputColorSpace)),M.push(S.customProgramCacheKey),M.join()}function b(S,M){S.push(M.precision),S.push(M.outputColorSpace),S.push(M.envMapMode),S.push(M.envMapCubeUVHeight),S.push(M.mapUv),S.push(M.alphaMapUv),S.push(M.lightMapUv),S.push(M.aoMapUv),S.push(M.bumpMapUv),S.push(M.normalMapUv),S.push(M.displacementMapUv),S.push(M.emissiveMapUv),S.push(M.metalnessMapUv),S.push(M.roughnessMapUv),S.push(M.anisotropyMapUv),S.push(M.clearcoatMapUv),S.push(M.clearcoatNormalMapUv),S.push(M.clearcoatRoughnessMapUv),S.push(M.iridescenceMapUv),S.push(M.iridescenceThicknessMapUv),S.push(M.sheenColorMapUv),S.push(M.sheenRoughnessMapUv),S.push(M.specularMapUv),S.push(M.specularColorMapUv),S.push(M.specularIntensityMapUv),S.push(M.transmissionMapUv),S.push(M.thicknessMapUv),S.push(M.combine),S.push(M.fogExp2),S.push(M.sizeAttenuation),S.push(M.morphTargetsCount),S.push(M.morphAttributeCount),S.push(M.numDirLights),S.push(M.numPointLights),S.push(M.numSpotLights),S.push(M.numSpotLightMaps),S.push(M.numHemiLights),S.push(M.numRectAreaLights),S.push(M.numDirLightShadows),S.push(M.numPointLightShadows),S.push(M.numSpotLightShadows),S.push(M.numSpotLightShadowsWithMaps),S.push(M.numLightProbes),S.push(M.shadowMapType),S.push(M.toneMapping),S.push(M.numClippingPlanes),S.push(M.numClipIntersection),S.push(M.depthPacking)}function _(S,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),M.gradientMap&&o.enable(22),S.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.reversedDepthBuffer&&o.enable(4),M.skinning&&o.enable(5),M.morphTargets&&o.enable(6),M.morphNormals&&o.enable(7),M.morphColors&&o.enable(8),M.premultipliedAlpha&&o.enable(9),M.shadowMapEnabled&&o.enable(10),M.doubleSided&&o.enable(11),M.flipSided&&o.enable(12),M.useDepthPacking&&o.enable(13),M.dithering&&o.enable(14),M.transmission&&o.enable(15),M.sheen&&o.enable(16),M.opaque&&o.enable(17),M.pointsUvs&&o.enable(18),M.decodeVideoTexture&&o.enable(19),M.decodeVideoTextureEmissive&&o.enable(20),M.alphaToCoverage&&o.enable(21),S.push(o.mask)}function E(S){const M=g[S.type];let L;if(M){const N=Pi[M];L=vi.clone(N.uniforms)}else L=S.uniforms;return L}function R(S,M){let L;for(let N=0,z=h.length;N 0?i.push(p):m.transparent===!0?s.push(p):t.push(p)}function l(u,d,m,g,v,f){const p=a(u,d,m,g,v,f);m.transmission>0?i.unshift(p):m.transparent===!0?s.unshift(p):t.unshift(p)}function c(u,d){t.length>1&&t.sort(u||I0),i.length>1&&i.sort(d||ph),s.length>1&&s.sort(d||ph)}function h(){for(let u=e,d=n.length;u =r.length?(a=new mh,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function N0(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new w,color:new xe};break;case"SpotLight":t={position:new w,direction:new w,color:new xe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new w,color:new xe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new w,skyColor:new xe,groundColor:new xe};break;case"RectAreaLight":t={color:new xe,position:new w,halfWidth:new w,halfHeight:new w};break}return n[e.id]=t,t}}}function B0(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let O0=0;function k0(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function F0(n){const e=new N0,t=B0(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new w);const s=new w,r=new De,a=new De;function o(c){let h=0,u=0,d=0;for(let S=0;S<9;S++)i.probe[S].set(0,0,0);let m=0,g=0,v=0,f=0,p=0,b=0,_=0,E=0,R=0,T=0,A=0;c.sort(k0);for(let S=0,M=c.length;S 0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ce.LTC_FLOAT_1,i.rectAreaLTC2=ce.LTC_FLOAT_2):(i.rectAreaLTC1=ce.LTC_HALF_1,i.rectAreaLTC2=ce.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=u,i.ambient[2]=d;const I=i.hash;(I.directionalLength!==m||I.pointLength!==g||I.spotLength!==v||I.rectAreaLength!==f||I.hemiLength!==p||I.numDirectionalShadows!==b||I.numPointShadows!==_||I.numSpotShadows!==E||I.numSpotMaps!==R||I.numLightProbes!==A)&&(i.directional.length=m,i.spot.length=v,i.rectArea.length=f,i.point.length=g,i.hemi.length=p,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=_,i.pointShadowMap.length=_,i.spotShadow.length=E,i.spotShadowMap.length=E,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=_,i.spotLightMatrix.length=E+R-T,i.spotLightMap.length=R,i.numSpotLightShadowsWithMaps=T,i.numLightProbes=A,I.directionalLength=m,I.pointLength=g,I.spotLength=v,I.rectAreaLength=f,I.hemiLength=p,I.numDirectionalShadows=b,I.numPointShadows=_,I.numSpotShadows=E,I.numSpotMaps=R,I.numLightProbes=A,i.version=O0++)}function l(c,h){let u=0,d=0,m=0,g=0,v=0;const f=h.matrixWorldInverse;for(let p=0,b=c.length;p=a.length?(o=new fh(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const H0=`void main() { gl_Position = vec4( position, 1.0 ); }`,V0=`uniform sampler2D shadow_pass; uniform vec2 resolution; @@ -3926,7 +3926,7 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function G0(n,e,t){let i=new So;const s=new oe,r=new oe,a=new $e,o=new Ec({depthPacking:Il}),l=new kd,c={},h=t.maxTextureSize,u={[Si]:zt,[zt]:Si,[Xt]:Xt},d=new ct({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new oe},radius:{value:4}},vertexShader:H0,fragmentShader:V0}),m=d.clone();m.defines.HORIZONTAL_PASS=1;const g=new si;g.setAttribute("position",new Vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new rt(g,d),f=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=cl;let p=this.type;this.render=function(T,A,I){if(f.enabled===!1||f.autoUpdate===!1&&f.needsUpdate===!1||T.length===0)return;const S=n.getRenderTarget(),M=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),N=n.state;N.setBlending(xt),N.buffers.depth.getReversed()===!0?N.buffers.color.setClear(0,0,0,0):N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);const z=p!==Ui&&this.type===Ui,H=p===Ui&&this.type!==Ui;for(let j=0,q=T.length;j h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/K.x),s.x=r.x*K.x,G.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/K.y),s.y=r.y*K.y,G.mapSize.y=r.y)),G.map===null||z===!0||H===!0){const Le=this.type!==Ui?{minFilter:It,magFilter:It}:{};G.map!==null&&G.map.dispose(),G.map=new yt(s.x,s.y,Le),G.map.texture.name=te.name+".shadowMap",G.camera.updateProjectionMatrix()}n.setRenderTarget(G.map),n.clear();const ne=G.getViewportCount();for(let Le=0;Le0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){const N=M.uuid,z=A.uuid;let H=c[N];H===void 0&&(H={},c[N]=H);let j=H[z];j===void 0&&(j=M.clone(),H[z]=j,A.addEventListener("dispose",R)),M=j}if(M.visible=A.visible,M.wireframe=A.wireframe,S===Ui?M.side=A.shadowSide!==null?A.shadowSide:A.side:M.side=A.shadowSide!==null?A.shadowSide:u[A.side],M.alphaMap=A.alphaMap,M.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,M.map=A.map,M.clipShadows=A.clipShadows,M.clippingPlanes=A.clippingPlanes,M.clipIntersection=A.clipIntersection,M.displacementMap=A.displacementMap,M.displacementScale=A.displacementScale,M.displacementBias=A.displacementBias,M.wireframeLinewidth=A.wireframeLinewidth,M.linewidth=A.linewidth,I.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const N=n.properties.get(M);N.light=I}return M}function E(T,A,I,S,M){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===Ui)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,T.matrixWorld);const N=e.update(T),z=T.material;if(Array.isArray(z)){const H=N.groups;for(let j=0,q=H.length;j =1):G.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),q=te>=2);let K=null,ne={};const Le=n.getParameter(n.SCISSOR_BOX),He=n.getParameter(n.VIEWPORT),Ye=new $e().fromArray(Le),Je=new $e().fromArray(He);function Qe(P,ae,ie,he){const Q=new Uint8Array(4),$=n.createTexture();n.bindTexture(P,$),n.texParameteri(P,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(P,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let _e=0;_e"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new oe,h=new WeakMap;let u;const d=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(C,x){return m?new OffscreenCanvas(C,x):vn("canvas")}function v(C,x,O){let X=1;const Y=Ie(C);if((Y.width>O||Y.height>O)&&(X=O/Math.max(Y.width,Y.height)),X<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const V=Math.floor(X*Y.width),be=Math.floor(X*Y.height);u===void 0&&(u=g(V,be));const re=x?g(V,be):u;return re.width=V,re.height=be,re.getContext("2d").drawImage(C,0,0,V,be),Me("WebGLRenderer: Texture has been resized from ("+Y.width+"x"+Y.height+") to ("+V+"x"+be+")."),re}else return"data"in C&&Me("WebGLRenderer: Image in DataTexture is too big ("+Y.width+"x"+Y.height+")."),C;return C}function f(C){return C.generateMipmaps}function p(C){n.generateMipmap(C)}function b(C){return C.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:C.isWebGL3DRenderTarget?n.TEXTURE_3D:C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function _(C,x,O,X,Y=!1){if(C!==null){if(n[C]!==void 0)return n[C];Me("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let V=x;if(x===n.RED&&(O===n.FLOAT&&(V=n.R32F),O===n.HALF_FLOAT&&(V=n.R16F),O===n.UNSIGNED_BYTE&&(V=n.R8)),x===n.RED_INTEGER&&(O===n.UNSIGNED_BYTE&&(V=n.R8UI),O===n.UNSIGNED_SHORT&&(V=n.R16UI),O===n.UNSIGNED_INT&&(V=n.R32UI),O===n.BYTE&&(V=n.R8I),O===n.SHORT&&(V=n.R16I),O===n.INT&&(V=n.R32I)),x===n.RG&&(O===n.FLOAT&&(V=n.RG32F),O===n.HALF_FLOAT&&(V=n.RG16F),O===n.UNSIGNED_BYTE&&(V=n.RG8)),x===n.RG_INTEGER&&(O===n.UNSIGNED_BYTE&&(V=n.RG8UI),O===n.UNSIGNED_SHORT&&(V=n.RG16UI),O===n.UNSIGNED_INT&&(V=n.RG32UI),O===n.BYTE&&(V=n.RG8I),O===n.SHORT&&(V=n.RG16I),O===n.INT&&(V=n.RG32I)),x===n.RGB_INTEGER&&(O===n.UNSIGNED_BYTE&&(V=n.RGB8UI),O===n.UNSIGNED_SHORT&&(V=n.RGB16UI),O===n.UNSIGNED_INT&&(V=n.RGB32UI),O===n.BYTE&&(V=n.RGB8I),O===n.SHORT&&(V=n.RGB16I),O===n.INT&&(V=n.RGB32I)),x===n.RGBA_INTEGER&&(O===n.UNSIGNED_BYTE&&(V=n.RGBA8UI),O===n.UNSIGNED_SHORT&&(V=n.RGBA16UI),O===n.UNSIGNED_INT&&(V=n.RGBA32UI),O===n.BYTE&&(V=n.RGBA8I),O===n.SHORT&&(V=n.RGBA16I),O===n.INT&&(V=n.RGBA32I)),x===n.RGB&&(O===n.UNSIGNED_INT_5_9_9_9_REV&&(V=n.RGB9_E5),O===n.UNSIGNED_INT_10F_11F_11F_REV&&(V=n.R11F_G11F_B10F)),x===n.RGBA){const be=Y?Kn:Xe.getTransfer(X);O===n.FLOAT&&(V=n.RGBA32F),O===n.HALF_FLOAT&&(V=n.RGBA16F),O===n.UNSIGNED_BYTE&&(V=be===it?n.SRGB8_ALPHA8:n.RGBA8),O===n.UNSIGNED_SHORT_4_4_4_4&&(V=n.RGBA4),O===n.UNSIGNED_SHORT_5_5_5_1&&(V=n.RGB5_A1)}return(V===n.R16F||V===n.R32F||V===n.RG16F||V===n.RG32F||V===n.RGBA16F||V===n.RGBA32F)&&e.get("EXT_color_buffer_float"),V}function E(C,x){let O;return C?x===null||x===os||x===As?O=n.DEPTH24_STENCIL8:x===qt?O=n.DEPTH32F_STENCIL8:x===pn&&(O=n.DEPTH24_STENCIL8,Me("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===os||x===As?O=n.DEPTH_COMPONENT24:x===qt?O=n.DEPTH_COMPONENT32F:x===pn&&(O=n.DEPTH_COMPONENT16),O}function R(C,x){return f(C)===!0||C.isFramebufferTexture&&C.minFilter!==It&&C.minFilter!==bt?Math.log2(Math.max(x.width,x.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?x.mipmaps.length:1}function T(C){const x=C.target;x.removeEventListener("dispose",T),I(x),x.isVideoTexture&&h.delete(x)}function A(C){const x=C.target;x.removeEventListener("dispose",A),M(x)}function I(C){const x=i.get(C);if(x.__webglInit===void 0)return;const O=C.source,X=d.get(O);if(X){const Y=X[x.__cacheKey];Y.usedTimes--,Y.usedTimes===0&&S(C),Object.keys(X).length===0&&d.delete(O)}i.remove(C)}function S(C){const x=i.get(C);n.deleteTexture(x.__webglTexture);const O=C.source,X=d.get(O);delete X[x.__cacheKey],a.memory.textures--}function M(C){const x=i.get(C);if(C.depthTexture&&(C.depthTexture.dispose(),i.remove(C.depthTexture)),C.isWebGLCubeRenderTarget)for(let X=0;X<6;X++){if(Array.isArray(x.__webglFramebuffer[X]))for(let Y=0;Y =s.maxTextures&&Me("WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+s.maxTextures),L+=1,C}function H(C){const x=[];return x.push(C.wrapS),x.push(C.wrapT),x.push(C.wrapR||0),x.push(C.magFilter),x.push(C.minFilter),x.push(C.anisotropy),x.push(C.internalFormat),x.push(C.format),x.push(C.type),x.push(C.generateMipmaps),x.push(C.premultiplyAlpha),x.push(C.flipY),x.push(C.unpackAlignment),x.push(C.colorSpace),x.join()}function j(C,x){const O=i.get(C);if(C.isVideoTexture&<(C),C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&O.__version!==C.version){const X=C.image;if(X===null)Me("WebGLRenderer: Texture marked for update but no image data found.");else if(X.complete===!1)Me("WebGLRenderer: Texture marked for update but image is incomplete");else{W(O,C,x);return}}else C.isExternalTexture&&(O.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,O.__webglTexture,n.TEXTURE0+x)}function q(C,x){const O=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&O.__version!==C.version){W(O,C,x);return}else C.isExternalTexture&&(O.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,O.__webglTexture,n.TEXTURE0+x)}function te(C,x){const O=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&O.__version!==C.version){W(O,C,x);return}t.bindTexture(n.TEXTURE_3D,O.__webglTexture,n.TEXTURE0+x)}function G(C,x){const O=i.get(C);if(C.version>0&&O.__version!==C.version){Z(O,C,x);return}t.bindTexture(n.TEXTURE_CUBE_MAP,O.__webglTexture,n.TEXTURE0+x)}const K={[Ti]:n.REPEAT,[ei]:n.CLAMP_TO_EDGE,[Gn]:n.MIRRORED_REPEAT},ne={[It]:n.NEAREST,[Ml]:n.NEAREST_MIPMAP_NEAREST,[dn]:n.NEAREST_MIPMAP_LINEAR,[bt]:n.LINEAR,[Wn]:n.LINEAR_MIPMAP_NEAREST,[Ei]:n.LINEAR_MIPMAP_LINEAR},Le={[wu]:n.NEVER,[Du]:n.ALWAYS,[Cu]:n.LESS,[Ul]:n.LEQUAL,[Au]:n.EQUAL,[Lu]:n.GEQUAL,[Ru]:n.GREATER,[Pu]:n.NOTEQUAL};function He(C,x){if(x.type===qt&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===bt||x.magFilter===Wn||x.magFilter===dn||x.magFilter===Ei||x.minFilter===bt||x.minFilter===Wn||x.minFilter===dn||x.minFilter===Ei)&&Me("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(C,n.TEXTURE_WRAP_S,K[x.wrapS]),n.texParameteri(C,n.TEXTURE_WRAP_T,K[x.wrapT]),(C===n.TEXTURE_3D||C===n.TEXTURE_2D_ARRAY)&&n.texParameteri(C,n.TEXTURE_WRAP_R,K[x.wrapR]),n.texParameteri(C,n.TEXTURE_MAG_FILTER,ne[x.magFilter]),n.texParameteri(C,n.TEXTURE_MIN_FILTER,ne[x.minFilter]),x.compareFunction&&(n.texParameteri(C,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(C,n.TEXTURE_COMPARE_FUNC,Le[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===It||x.minFilter!==dn&&x.minFilter!==Ei||x.type===qt&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const O=e.get("EXT_texture_filter_anisotropic");n.texParameterf(C,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function Ye(C,x){let O=!1;C.__webglInit===void 0&&(C.__webglInit=!0,x.addEventListener("dispose",T));const X=x.source;let Y=d.get(X);Y===void 0&&(Y={},d.set(X,Y));const V=H(x);if(V!==C.__cacheKey){Y[V]===void 0&&(Y[V]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,O=!0),Y[V].usedTimes++;const be=Y[C.__cacheKey];be!==void 0&&(Y[C.__cacheKey].usedTimes--,be.usedTimes===0&&S(x)),C.__cacheKey=V,C.__webglTexture=Y[V].texture}return O}function Je(C,x,O){return Math.floor(Math.floor(C/O)/x)}function Qe(C,x,O,X){const Y=C.updateRanges;if(Y.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,x.width,x.height,O,X,x.data);else{Y.sort((pe,J)=>pe.start-J.start);let V=0;for(let pe=1;pe 0){P&&ae&&t.texStorage2D(n.TEXTURE_2D,he,Ce,Re[0].width,Re[0].height);for(let Q=0,$=Re.length;Q<$;Q++)ue=Re[Q],P?ie&&t.texSubImage2D(n.TEXTURE_2D,Q,0,0,ue.width,ue.height,se,Oe,ue.data):t.texImage2D(n.TEXTURE_2D,Q,Ce,ue.width,ue.height,0,se,Oe,ue.data);x.generateMipmaps=!1}else P?(ae&&t.texStorage2D(n.TEXTURE_2D,he,Ce,J.width,J.height),ie&&Qe(x,J,se,Oe)):t.texImage2D(n.TEXTURE_2D,0,Ce,J.width,J.height,0,se,Oe,J.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){P&&ae&&t.texStorage3D(n.TEXTURE_2D_ARRAY,he,Ce,Re[0].width,Re[0].height,J.depth);for(let Q=0,$=Re.length;Q<$;Q++)if(ue=Re[Q],x.format!==Kt)if(se!==null)if(P){if(ie)if(x.layerUpdates.size>0){const _e=Hc(ue.width,ue.height,x.format,x.type);for(const Pe of x.layerUpdates){const Lt=ue.data.subarray(Pe*_e/ue.data.BYTES_PER_ELEMENT,(Pe+1)*_e/ue.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Q,0,0,Pe,ue.width,ue.height,1,se,Lt)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Q,0,0,0,ue.width,ue.height,J.depth,se,ue.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Q,Ce,ue.width,ue.height,J.depth,0,ue.data,0,0);else Me("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else P?ie&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Q,0,0,0,ue.width,ue.height,J.depth,se,Oe,ue.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Q,Ce,ue.width,ue.height,J.depth,0,se,Oe,ue.data)}else{P&&ae&&t.texStorage2D(n.TEXTURE_2D,he,Ce,Re[0].width,Re[0].height);for(let Q=0,$=Re.length;Q<$;Q++)ue=Re[Q],x.format!==Kt?se!==null?P?ie&&t.compressedTexSubImage2D(n.TEXTURE_2D,Q,0,0,ue.width,ue.height,se,ue.data):t.compressedTexImage2D(n.TEXTURE_2D,Q,Ce,ue.width,ue.height,0,ue.data):Me("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):P?ie&&t.texSubImage2D(n.TEXTURE_2D,Q,0,0,ue.width,ue.height,se,Oe,ue.data):t.texImage2D(n.TEXTURE_2D,Q,Ce,ue.width,ue.height,0,se,Oe,ue.data)}else if(x.isDataArrayTexture)if(P){if(ae&&t.texStorage3D(n.TEXTURE_2D_ARRAY,he,Ce,J.width,J.height,J.depth),ie)if(x.layerUpdates.size>0){const Q=Hc(J.width,J.height,x.format,x.type);for(const $ of x.layerUpdates){const _e=J.data.subarray($*Q/J.data.BYTES_PER_ELEMENT,($+1)*Q/J.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,$,J.width,J.height,1,se,Oe,_e)}x.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,se,Oe,J.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ce,J.width,J.height,J.depth,0,se,Oe,J.data);else if(x.isData3DTexture)P?(ae&&t.texStorage3D(n.TEXTURE_3D,he,Ce,J.width,J.height,J.depth),ie&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,se,Oe,J.data)):t.texImage3D(n.TEXTURE_3D,0,Ce,J.width,J.height,J.depth,0,se,Oe,J.data);else if(x.isFramebufferTexture){if(ae)if(P)t.texStorage2D(n.TEXTURE_2D,he,Ce,J.width,J.height);else{let Q=J.width,$=J.height;for(let _e=0;_e >=1,$>>=1}}else if(Re.length>0){if(P&&ae){const Q=Ie(Re[0]);t.texStorage2D(n.TEXTURE_2D,he,Ce,Q.width,Q.height)}for(let Q=0,$=Re.length;Q<$;Q++)ue=Re[Q],P?ie&&t.texSubImage2D(n.TEXTURE_2D,Q,0,0,se,Oe,ue):t.texImage2D(n.TEXTURE_2D,Q,Ce,se,Oe,ue);x.generateMipmaps=!1}else if(P){if(ae){const Q=Ie(J);t.texStorage2D(n.TEXTURE_2D,he,Ce,Q.width,Q.height)}ie&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,se,Oe,J)}else t.texImage2D(n.TEXTURE_2D,0,Ce,se,Oe,J);f(x)&&p(X),be.__version=V.version,x.onUpdate&&x.onUpdate(x)}C.__version=x.version}function Z(C,x,O){if(x.image.length!==6)return;const X=Ye(C,x),Y=x.source;t.bindTexture(n.TEXTURE_CUBE_MAP,C.__webglTexture,n.TEXTURE0+O);const V=i.get(Y);if(Y.version!==V.__version||X===!0){t.activeTexture(n.TEXTURE0+O);const be=Xe.getPrimaries(Xe.workingColorSpace),re=x.colorSpace===Zi?null:Xe.getPrimaries(x.colorSpace),Ee=x.colorSpace===Zi||be===re?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,x.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,x.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ee);const pe=x.isCompressedTexture||x.image[0].isCompressedTexture,J=x.image[0]&&x.image[0].isDataTexture,se=[];for(let $=0;$<6;$++)!pe&&!J?se[$]=v(x.image[$],!0,s.maxCubemapSize):se[$]=J?x.image[$].image:x.image[$],se[$]=Se(x,se[$]);const Oe=se[0],Ce=r.convert(x.format,x.colorSpace),ue=r.convert(x.type),Re=_(x.internalFormat,Ce,ue,x.colorSpace),P=x.isVideoTexture!==!0,ae=V.__version===void 0||X===!0,ie=Y.dataReady;let he=R(x,Oe);He(n.TEXTURE_CUBE_MAP,x);let Q;if(pe){P&&ae&&t.texStorage2D(n.TEXTURE_CUBE_MAP,he,Re,Oe.width,Oe.height);for(let $=0;$<6;$++){Q=se[$].mipmaps;for(let _e=0;_e 0&&he++;const $=Ie(se[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,he,Re,$.width,$.height)}for(let $=0;$<6;$++)if(J){P?ie&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,se[$].width,se[$].height,Ce,ue,se[$].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,Re,se[$].width,se[$].height,0,Ce,ue,se[$].data);for(let _e=0;_e >V),Oe=Math.max(1,x.height>>V);Y===n.TEXTURE_3D||Y===n.TEXTURE_2D_ARRAY?t.texImage3D(Y,V,Ee,se,Oe,x.depth,0,be,re,null):t.texImage2D(Y,V,Ee,se,Oe,0,be,re,null)}t.bindFramebuffer(n.FRAMEBUFFER,C),fe(x)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,X,Y,J.__webglTexture,0,tt(x)):(Y===n.TEXTURE_2D||Y>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Y<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,X,Y,J.__webglTexture,V),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ae(C,x,O){if(n.bindRenderbuffer(n.RENDERBUFFER,C),x.depthBuffer){const X=x.depthTexture,Y=X&&X.isDepthTexture?X.type:null,V=E(x.stencilBuffer,Y),be=x.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,re=tt(x);fe(x)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,re,V,x.width,x.height):O?n.renderbufferStorageMultisample(n.RENDERBUFFER,re,V,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,V,x.width,x.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,be,n.RENDERBUFFER,C)}else{const X=x.textures;for(let Y=0;Y {delete x.__boundDepthTexture,delete x.__depthDisposeCallback,X.removeEventListener("dispose",Y)};X.addEventListener("dispose",Y),x.__depthDisposeCallback=Y}x.__boundDepthTexture=X}if(C.depthTexture&&!x.__autoAllocateDepthBuffer){if(O)throw new Error("target.depthTexture not supported in Cube render targets");const X=C.texture.mipmaps;X&&X.length>0?Te(x.__webglFramebuffer[0],C):Te(x.__webglFramebuffer,C)}else if(O){x.__webglDepthbuffer=[];for(let X=0;X<6;X++)if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[X]),x.__webglDepthbuffer[X]===void 0)x.__webglDepthbuffer[X]=n.createRenderbuffer(),Ae(x.__webglDepthbuffer[X],C,!1);else{const Y=C.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,V=x.__webglDepthbuffer[X];n.bindRenderbuffer(n.RENDERBUFFER,V),n.framebufferRenderbuffer(n.FRAMEBUFFER,Y,n.RENDERBUFFER,V)}}else{const X=C.texture.mipmaps;if(X&&X.length>0?t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=n.createRenderbuffer(),Ae(x.__webglDepthbuffer,C,!1);else{const Y=C.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,V=x.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,V),n.framebufferRenderbuffer(n.FRAMEBUFFER,Y,n.RENDERBUFFER,V)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function et(C,x,O){const X=i.get(C);x!==void 0&&de(X.__webglFramebuffer,C,C.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),O!==void 0&&we(C)}function qe(C){const x=C.texture,O=i.get(C),X=i.get(x);C.addEventListener("dispose",A);const Y=C.textures,V=C.isWebGLCubeRenderTarget===!0,be=Y.length>1;if(be||(X.__webglTexture===void 0&&(X.__webglTexture=n.createTexture()),X.__version=x.version,a.memory.textures++),V){O.__webglFramebuffer=[];for(let re=0;re<6;re++)if(x.mipmaps&&x.mipmaps.length>0){O.__webglFramebuffer[re]=[];for(let Ee=0;Ee 0){O.__webglFramebuffer=[];for(let re=0;re 0&&fe(C)===!1){O.__webglMultisampledFramebuffer=n.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let re=0;re 0)for(let Ee=0;Ee 0)for(let Ee=0;Ee 0){if(fe(C)===!1){const x=C.textures,O=C.width,X=C.height;let Y=n.COLOR_BUFFER_BIT;const V=C.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,be=i.get(C),re=x.length>1;if(re)for(let pe=0;pe 0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,be.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,be.__webglFramebuffer);for(let pe=0;pe 0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function lt(C){const x=a.render.frame;h.get(C)!==x&&(h.set(C,x),C.update())}function Se(C,x){const O=C.colorSpace,X=C.format,Y=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||O!==Bt&&O!==Zi&&(Xe.getTransfer(O)===it?(X!==Kt||Y!==oi)&&Me("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ve("WebGLTextures: Unsupported texture color space:",O)),x}function Ie(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=z,this.resetTextureUnits=N,this.setTexture2D=j,this.setTexture2DArray=q,this.setTexture3D=te,this.setTextureCube=G,this.rebindTextures=et,this.setupRenderTarget=qe,this.updateRenderTargetMipmap=We,this.updateMultisampleRenderTarget=je,this.setupDepthRenderbuffer=we,this.setupFrameBufferTexture=de,this.useMultisampledRTT=fe}function q0(n,e){function t(i,s=Zi){let r;const a=Xe.getTransfer(s);if(i===oi)return n.UNSIGNED_BYTE;if(i===ia)return n.UNSIGNED_SHORT_4_4_4_4;if(i===sa)return n.UNSIGNED_SHORT_5_5_5_1;if(i===El)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===wl)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Sl)return n.BYTE;if(i===Tl)return n.SHORT;if(i===pn)return n.UNSIGNED_SHORT;if(i===ta)return n.INT;if(i===os)return n.UNSIGNED_INT;if(i===qt)return n.FLOAT;if(i===ft)return n.HALF_FLOAT;if(i===Cl)return n.ALPHA;if(i===Al)return n.RGB;if(i===Kt)return n.RGBA;if(i===mn)return n.DEPTH_COMPONENT;if(i===Rs)return n.DEPTH_STENCIL;if(i===na)return n.RED;if(i===ra)return n.RED_INTEGER;if(i===aa)return n.RG;if(i===oa)return n.RG_INTEGER;if(i===la)return n.RGBA_INTEGER;if(i===jn||i===Xn||i===qn||i===Zn)if(a===it)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===jn)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Xn)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===qn)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Zn)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===jn)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Xn)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===qn)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Zn)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===ca||i===ha||i===ua||i===da)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===ca)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===ha)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ua)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===da)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===pa||i===ma||i===fa)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===pa||i===ma)return a===it?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===fa)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===ga||i===va||i===_a||i===xa||i===ba||i===ya||i===Ma||i===Sa||i===Ta||i===Ea||i===wa||i===Ca||i===Aa||i===Ra)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===ga)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===va)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===_a)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===xa)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===ba)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===ya)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ma)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Sa)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ta)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Ea)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===wa)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Ca)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Aa)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ra)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Pa||i===La||i===Da)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===Pa)return a===it?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===La)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Da)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Ia||i===Ua||i===Na||i===Ba)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===Ia)return r.COMPRESSED_RED_RGTC1_EXT;if(i===Ua)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Na)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Ba)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===As?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const Z0=` +}`;function G0(n,e,t){let i=new So;const s=new oe,r=new oe,a=new $e,o=new Ec({depthPacking:Il}),l=new kd,c={},h=t.maxTextureSize,u={[Si]:zt,[zt]:Si,[Xt]:Xt},d=new ct({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new oe},radius:{value:4}},vertexShader:H0,fragmentShader:V0}),m=d.clone();m.defines.HORIZONTAL_PASS=1;const g=new si;g.setAttribute("position",new Vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new rt(g,d),f=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=cl;let p=this.type;this.render=function(T,A,I){if(f.enabled===!1||f.autoUpdate===!1&&f.needsUpdate===!1||T.length===0)return;const S=n.getRenderTarget(),M=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),N=n.state;N.setBlending(bt),N.buffers.depth.getReversed()===!0?N.buffers.color.setClear(0,0,0,0):N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);const z=p!==Ui&&this.type===Ui,H=p===Ui&&this.type!==Ui;for(let j=0,q=T.length;j h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/K.x),s.x=r.x*K.x,G.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/K.y),s.y=r.y*K.y,G.mapSize.y=r.y)),G.map===null||z===!0||H===!0){const Le=this.type!==Ui?{minFilter:Ut,magFilter:Ut}:{};G.map!==null&&G.map.dispose(),G.map=new Mt(s.x,s.y,Le),G.map.texture.name=te.name+".shadowMap",G.camera.updateProjectionMatrix()}n.setRenderTarget(G.map),n.clear();const ne=G.getViewportCount();for(let Le=0;Le0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){const N=M.uuid,z=A.uuid;let H=c[N];H===void 0&&(H={},c[N]=H);let j=H[z];j===void 0&&(j=M.clone(),H[z]=j,A.addEventListener("dispose",R)),M=j}if(M.visible=A.visible,M.wireframe=A.wireframe,S===Ui?M.side=A.shadowSide!==null?A.shadowSide:A.side:M.side=A.shadowSide!==null?A.shadowSide:u[A.side],M.alphaMap=A.alphaMap,M.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,M.map=A.map,M.clipShadows=A.clipShadows,M.clippingPlanes=A.clippingPlanes,M.clipIntersection=A.clipIntersection,M.displacementMap=A.displacementMap,M.displacementScale=A.displacementScale,M.displacementBias=A.displacementBias,M.wireframeLinewidth=A.wireframeLinewidth,M.linewidth=A.linewidth,I.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const N=n.properties.get(M);N.light=I}return M}function E(T,A,I,S,M){if(T.visible===!1)return;if(T.layers.test(A.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===Ui)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,T.matrixWorld);const N=e.update(T),z=T.material;if(Array.isArray(z)){const H=N.groups;for(let j=0,q=H.length;j =1):G.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),q=te>=2);let K=null,ne={};const Le=n.getParameter(n.SCISSOR_BOX),He=n.getParameter(n.VIEWPORT),Ye=new $e().fromArray(Le),Je=new $e().fromArray(He);function Qe(P,ae,ie,he){const Q=new Uint8Array(4),$=n.createTexture();n.bindTexture(P,$),n.texParameteri(P,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(P,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let _e=0;_e"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new oe,h=new WeakMap;let u;const d=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(C,x){return m?new OffscreenCanvas(C,x):vn("canvas")}function v(C,x,O){let X=1;const Y=Ie(C);if((Y.width>O||Y.height>O)&&(X=O/Math.max(Y.width,Y.height)),X<1)if(typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&C instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&C instanceof ImageBitmap||typeof VideoFrame<"u"&&C instanceof VideoFrame){const V=Math.floor(X*Y.width),be=Math.floor(X*Y.height);u===void 0&&(u=g(V,be));const re=x?g(V,be):u;return re.width=V,re.height=be,re.getContext("2d").drawImage(C,0,0,V,be),Me("WebGLRenderer: Texture has been resized from ("+Y.width+"x"+Y.height+") to ("+V+"x"+be+")."),re}else return"data"in C&&Me("WebGLRenderer: Image in DataTexture is too big ("+Y.width+"x"+Y.height+")."),C;return C}function f(C){return C.generateMipmaps}function p(C){n.generateMipmap(C)}function b(C){return C.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:C.isWebGL3DRenderTarget?n.TEXTURE_3D:C.isWebGLArrayRenderTarget||C.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function _(C,x,O,X,Y=!1){if(C!==null){if(n[C]!==void 0)return n[C];Me("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+C+"'")}let V=x;if(x===n.RED&&(O===n.FLOAT&&(V=n.R32F),O===n.HALF_FLOAT&&(V=n.R16F),O===n.UNSIGNED_BYTE&&(V=n.R8)),x===n.RED_INTEGER&&(O===n.UNSIGNED_BYTE&&(V=n.R8UI),O===n.UNSIGNED_SHORT&&(V=n.R16UI),O===n.UNSIGNED_INT&&(V=n.R32UI),O===n.BYTE&&(V=n.R8I),O===n.SHORT&&(V=n.R16I),O===n.INT&&(V=n.R32I)),x===n.RG&&(O===n.FLOAT&&(V=n.RG32F),O===n.HALF_FLOAT&&(V=n.RG16F),O===n.UNSIGNED_BYTE&&(V=n.RG8)),x===n.RG_INTEGER&&(O===n.UNSIGNED_BYTE&&(V=n.RG8UI),O===n.UNSIGNED_SHORT&&(V=n.RG16UI),O===n.UNSIGNED_INT&&(V=n.RG32UI),O===n.BYTE&&(V=n.RG8I),O===n.SHORT&&(V=n.RG16I),O===n.INT&&(V=n.RG32I)),x===n.RGB_INTEGER&&(O===n.UNSIGNED_BYTE&&(V=n.RGB8UI),O===n.UNSIGNED_SHORT&&(V=n.RGB16UI),O===n.UNSIGNED_INT&&(V=n.RGB32UI),O===n.BYTE&&(V=n.RGB8I),O===n.SHORT&&(V=n.RGB16I),O===n.INT&&(V=n.RGB32I)),x===n.RGBA_INTEGER&&(O===n.UNSIGNED_BYTE&&(V=n.RGBA8UI),O===n.UNSIGNED_SHORT&&(V=n.RGBA16UI),O===n.UNSIGNED_INT&&(V=n.RGBA32UI),O===n.BYTE&&(V=n.RGBA8I),O===n.SHORT&&(V=n.RGBA16I),O===n.INT&&(V=n.RGBA32I)),x===n.RGB&&(O===n.UNSIGNED_INT_5_9_9_9_REV&&(V=n.RGB9_E5),O===n.UNSIGNED_INT_10F_11F_11F_REV&&(V=n.R11F_G11F_B10F)),x===n.RGBA){const be=Y?Kn:Xe.getTransfer(X);O===n.FLOAT&&(V=n.RGBA32F),O===n.HALF_FLOAT&&(V=n.RGBA16F),O===n.UNSIGNED_BYTE&&(V=be===it?n.SRGB8_ALPHA8:n.RGBA8),O===n.UNSIGNED_SHORT_4_4_4_4&&(V=n.RGBA4),O===n.UNSIGNED_SHORT_5_5_5_1&&(V=n.RGB5_A1)}return(V===n.R16F||V===n.R32F||V===n.RG16F||V===n.RG32F||V===n.RGBA16F||V===n.RGBA32F)&&e.get("EXT_color_buffer_float"),V}function E(C,x){let O;return C?x===null||x===os||x===As?O=n.DEPTH24_STENCIL8:x===qt?O=n.DEPTH32F_STENCIL8:x===pn&&(O=n.DEPTH24_STENCIL8,Me("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===os||x===As?O=n.DEPTH_COMPONENT24:x===qt?O=n.DEPTH_COMPONENT32F:x===pn&&(O=n.DEPTH_COMPONENT16),O}function R(C,x){return f(C)===!0||C.isFramebufferTexture&&C.minFilter!==Ut&&C.minFilter!==yt?Math.log2(Math.max(x.width,x.height))+1:C.mipmaps!==void 0&&C.mipmaps.length>0?C.mipmaps.length:C.isCompressedTexture&&Array.isArray(C.image)?x.mipmaps.length:1}function T(C){const x=C.target;x.removeEventListener("dispose",T),I(x),x.isVideoTexture&&h.delete(x)}function A(C){const x=C.target;x.removeEventListener("dispose",A),M(x)}function I(C){const x=i.get(C);if(x.__webglInit===void 0)return;const O=C.source,X=d.get(O);if(X){const Y=X[x.__cacheKey];Y.usedTimes--,Y.usedTimes===0&&S(C),Object.keys(X).length===0&&d.delete(O)}i.remove(C)}function S(C){const x=i.get(C);n.deleteTexture(x.__webglTexture);const O=C.source,X=d.get(O);delete X[x.__cacheKey],a.memory.textures--}function M(C){const x=i.get(C);if(C.depthTexture&&(C.depthTexture.dispose(),i.remove(C.depthTexture)),C.isWebGLCubeRenderTarget)for(let X=0;X<6;X++){if(Array.isArray(x.__webglFramebuffer[X]))for(let Y=0;Y =s.maxTextures&&Me("WebGLTextures: Trying to use "+C+" texture units while this GPU supports only "+s.maxTextures),L+=1,C}function H(C){const x=[];return x.push(C.wrapS),x.push(C.wrapT),x.push(C.wrapR||0),x.push(C.magFilter),x.push(C.minFilter),x.push(C.anisotropy),x.push(C.internalFormat),x.push(C.format),x.push(C.type),x.push(C.generateMipmaps),x.push(C.premultiplyAlpha),x.push(C.flipY),x.push(C.unpackAlignment),x.push(C.colorSpace),x.join()}function j(C,x){const O=i.get(C);if(C.isVideoTexture&<(C),C.isRenderTargetTexture===!1&&C.isExternalTexture!==!0&&C.version>0&&O.__version!==C.version){const X=C.image;if(X===null)Me("WebGLRenderer: Texture marked for update but no image data found.");else if(X.complete===!1)Me("WebGLRenderer: Texture marked for update but image is incomplete");else{W(O,C,x);return}}else C.isExternalTexture&&(O.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,O.__webglTexture,n.TEXTURE0+x)}function q(C,x){const O=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&O.__version!==C.version){W(O,C,x);return}else C.isExternalTexture&&(O.__webglTexture=C.sourceTexture?C.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,O.__webglTexture,n.TEXTURE0+x)}function te(C,x){const O=i.get(C);if(C.isRenderTargetTexture===!1&&C.version>0&&O.__version!==C.version){W(O,C,x);return}t.bindTexture(n.TEXTURE_3D,O.__webglTexture,n.TEXTURE0+x)}function G(C,x){const O=i.get(C);if(C.version>0&&O.__version!==C.version){Z(O,C,x);return}t.bindTexture(n.TEXTURE_CUBE_MAP,O.__webglTexture,n.TEXTURE0+x)}const K={[Ti]:n.REPEAT,[ei]:n.CLAMP_TO_EDGE,[Gn]:n.MIRRORED_REPEAT},ne={[Ut]:n.NEAREST,[Ml]:n.NEAREST_MIPMAP_NEAREST,[dn]:n.NEAREST_MIPMAP_LINEAR,[yt]:n.LINEAR,[Wn]:n.LINEAR_MIPMAP_NEAREST,[Ei]:n.LINEAR_MIPMAP_LINEAR},Le={[wu]:n.NEVER,[Du]:n.ALWAYS,[Cu]:n.LESS,[Ul]:n.LEQUAL,[Au]:n.EQUAL,[Lu]:n.GEQUAL,[Ru]:n.GREATER,[Pu]:n.NOTEQUAL};function He(C,x){if(x.type===qt&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===yt||x.magFilter===Wn||x.magFilter===dn||x.magFilter===Ei||x.minFilter===yt||x.minFilter===Wn||x.minFilter===dn||x.minFilter===Ei)&&Me("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(C,n.TEXTURE_WRAP_S,K[x.wrapS]),n.texParameteri(C,n.TEXTURE_WRAP_T,K[x.wrapT]),(C===n.TEXTURE_3D||C===n.TEXTURE_2D_ARRAY)&&n.texParameteri(C,n.TEXTURE_WRAP_R,K[x.wrapR]),n.texParameteri(C,n.TEXTURE_MAG_FILTER,ne[x.magFilter]),n.texParameteri(C,n.TEXTURE_MIN_FILTER,ne[x.minFilter]),x.compareFunction&&(n.texParameteri(C,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(C,n.TEXTURE_COMPARE_FUNC,Le[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Ut||x.minFilter!==dn&&x.minFilter!==Ei||x.type===qt&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const O=e.get("EXT_texture_filter_anisotropic");n.texParameterf(C,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function Ye(C,x){let O=!1;C.__webglInit===void 0&&(C.__webglInit=!0,x.addEventListener("dispose",T));const X=x.source;let Y=d.get(X);Y===void 0&&(Y={},d.set(X,Y));const V=H(x);if(V!==C.__cacheKey){Y[V]===void 0&&(Y[V]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,O=!0),Y[V].usedTimes++;const be=Y[C.__cacheKey];be!==void 0&&(Y[C.__cacheKey].usedTimes--,be.usedTimes===0&&S(x)),C.__cacheKey=V,C.__webglTexture=Y[V].texture}return O}function Je(C,x,O){return Math.floor(Math.floor(C/O)/x)}function Qe(C,x,O,X){const Y=C.updateRanges;if(Y.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,x.width,x.height,O,X,x.data);else{Y.sort((pe,J)=>pe.start-J.start);let V=0;for(let pe=1;pe 0){P&&ae&&t.texStorage2D(n.TEXTURE_2D,he,Ce,Re[0].width,Re[0].height);for(let Q=0,$=Re.length;Q<$;Q++)ue=Re[Q],P?ie&&t.texSubImage2D(n.TEXTURE_2D,Q,0,0,ue.width,ue.height,se,Oe,ue.data):t.texImage2D(n.TEXTURE_2D,Q,Ce,ue.width,ue.height,0,se,Oe,ue.data);x.generateMipmaps=!1}else P?(ae&&t.texStorage2D(n.TEXTURE_2D,he,Ce,J.width,J.height),ie&&Qe(x,J,se,Oe)):t.texImage2D(n.TEXTURE_2D,0,Ce,J.width,J.height,0,se,Oe,J.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){P&&ae&&t.texStorage3D(n.TEXTURE_2D_ARRAY,he,Ce,Re[0].width,Re[0].height,J.depth);for(let Q=0,$=Re.length;Q<$;Q++)if(ue=Re[Q],x.format!==Kt)if(se!==null)if(P){if(ie)if(x.layerUpdates.size>0){const _e=Hc(ue.width,ue.height,x.format,x.type);for(const Pe of x.layerUpdates){const Dt=ue.data.subarray(Pe*_e/ue.data.BYTES_PER_ELEMENT,(Pe+1)*_e/ue.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Q,0,0,Pe,ue.width,ue.height,1,se,Dt)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Q,0,0,0,ue.width,ue.height,J.depth,se,ue.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Q,Ce,ue.width,ue.height,J.depth,0,ue.data,0,0);else Me("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else P?ie&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Q,0,0,0,ue.width,ue.height,J.depth,se,Oe,ue.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Q,Ce,ue.width,ue.height,J.depth,0,se,Oe,ue.data)}else{P&&ae&&t.texStorage2D(n.TEXTURE_2D,he,Ce,Re[0].width,Re[0].height);for(let Q=0,$=Re.length;Q<$;Q++)ue=Re[Q],x.format!==Kt?se!==null?P?ie&&t.compressedTexSubImage2D(n.TEXTURE_2D,Q,0,0,ue.width,ue.height,se,ue.data):t.compressedTexImage2D(n.TEXTURE_2D,Q,Ce,ue.width,ue.height,0,ue.data):Me("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):P?ie&&t.texSubImage2D(n.TEXTURE_2D,Q,0,0,ue.width,ue.height,se,Oe,ue.data):t.texImage2D(n.TEXTURE_2D,Q,Ce,ue.width,ue.height,0,se,Oe,ue.data)}else if(x.isDataArrayTexture)if(P){if(ae&&t.texStorage3D(n.TEXTURE_2D_ARRAY,he,Ce,J.width,J.height,J.depth),ie)if(x.layerUpdates.size>0){const Q=Hc(J.width,J.height,x.format,x.type);for(const $ of x.layerUpdates){const _e=J.data.subarray($*Q/J.data.BYTES_PER_ELEMENT,($+1)*Q/J.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,$,J.width,J.height,1,se,Oe,_e)}x.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,se,Oe,J.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ce,J.width,J.height,J.depth,0,se,Oe,J.data);else if(x.isData3DTexture)P?(ae&&t.texStorage3D(n.TEXTURE_3D,he,Ce,J.width,J.height,J.depth),ie&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,se,Oe,J.data)):t.texImage3D(n.TEXTURE_3D,0,Ce,J.width,J.height,J.depth,0,se,Oe,J.data);else if(x.isFramebufferTexture){if(ae)if(P)t.texStorage2D(n.TEXTURE_2D,he,Ce,J.width,J.height);else{let Q=J.width,$=J.height;for(let _e=0;_e >=1,$>>=1}}else if(Re.length>0){if(P&&ae){const Q=Ie(Re[0]);t.texStorage2D(n.TEXTURE_2D,he,Ce,Q.width,Q.height)}for(let Q=0,$=Re.length;Q<$;Q++)ue=Re[Q],P?ie&&t.texSubImage2D(n.TEXTURE_2D,Q,0,0,se,Oe,ue):t.texImage2D(n.TEXTURE_2D,Q,Ce,se,Oe,ue);x.generateMipmaps=!1}else if(P){if(ae){const Q=Ie(J);t.texStorage2D(n.TEXTURE_2D,he,Ce,Q.width,Q.height)}ie&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,se,Oe,J)}else t.texImage2D(n.TEXTURE_2D,0,Ce,se,Oe,J);f(x)&&p(X),be.__version=V.version,x.onUpdate&&x.onUpdate(x)}C.__version=x.version}function Z(C,x,O){if(x.image.length!==6)return;const X=Ye(C,x),Y=x.source;t.bindTexture(n.TEXTURE_CUBE_MAP,C.__webglTexture,n.TEXTURE0+O);const V=i.get(Y);if(Y.version!==V.__version||X===!0){t.activeTexture(n.TEXTURE0+O);const be=Xe.getPrimaries(Xe.workingColorSpace),re=x.colorSpace===Zi?null:Xe.getPrimaries(x.colorSpace),Ee=x.colorSpace===Zi||be===re?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,x.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,x.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ee);const pe=x.isCompressedTexture||x.image[0].isCompressedTexture,J=x.image[0]&&x.image[0].isDataTexture,se=[];for(let $=0;$<6;$++)!pe&&!J?se[$]=v(x.image[$],!0,s.maxCubemapSize):se[$]=J?x.image[$].image:x.image[$],se[$]=Se(x,se[$]);const Oe=se[0],Ce=r.convert(x.format,x.colorSpace),ue=r.convert(x.type),Re=_(x.internalFormat,Ce,ue,x.colorSpace),P=x.isVideoTexture!==!0,ae=V.__version===void 0||X===!0,ie=Y.dataReady;let he=R(x,Oe);He(n.TEXTURE_CUBE_MAP,x);let Q;if(pe){P&&ae&&t.texStorage2D(n.TEXTURE_CUBE_MAP,he,Re,Oe.width,Oe.height);for(let $=0;$<6;$++){Q=se[$].mipmaps;for(let _e=0;_e 0&&he++;const $=Ie(se[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,he,Re,$.width,$.height)}for(let $=0;$<6;$++)if(J){P?ie&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,se[$].width,se[$].height,Ce,ue,se[$].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,Re,se[$].width,se[$].height,0,Ce,ue,se[$].data);for(let _e=0;_e >V),Oe=Math.max(1,x.height>>V);Y===n.TEXTURE_3D||Y===n.TEXTURE_2D_ARRAY?t.texImage3D(Y,V,Ee,se,Oe,x.depth,0,be,re,null):t.texImage2D(Y,V,Ee,se,Oe,0,be,re,null)}t.bindFramebuffer(n.FRAMEBUFFER,C),fe(x)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,X,Y,J.__webglTexture,0,tt(x)):(Y===n.TEXTURE_2D||Y>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Y<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,X,Y,J.__webglTexture,V),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ae(C,x,O){if(n.bindRenderbuffer(n.RENDERBUFFER,C),x.depthBuffer){const X=x.depthTexture,Y=X&&X.isDepthTexture?X.type:null,V=E(x.stencilBuffer,Y),be=x.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,re=tt(x);fe(x)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,re,V,x.width,x.height):O?n.renderbufferStorageMultisample(n.RENDERBUFFER,re,V,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,V,x.width,x.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,be,n.RENDERBUFFER,C)}else{const X=x.textures;for(let Y=0;Y {delete x.__boundDepthTexture,delete x.__depthDisposeCallback,X.removeEventListener("dispose",Y)};X.addEventListener("dispose",Y),x.__depthDisposeCallback=Y}x.__boundDepthTexture=X}if(C.depthTexture&&!x.__autoAllocateDepthBuffer){if(O)throw new Error("target.depthTexture not supported in Cube render targets");const X=C.texture.mipmaps;X&&X.length>0?Te(x.__webglFramebuffer[0],C):Te(x.__webglFramebuffer,C)}else if(O){x.__webglDepthbuffer=[];for(let X=0;X<6;X++)if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[X]),x.__webglDepthbuffer[X]===void 0)x.__webglDepthbuffer[X]=n.createRenderbuffer(),Ae(x.__webglDepthbuffer[X],C,!1);else{const Y=C.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,V=x.__webglDepthbuffer[X];n.bindRenderbuffer(n.RENDERBUFFER,V),n.framebufferRenderbuffer(n.FRAMEBUFFER,Y,n.RENDERBUFFER,V)}}else{const X=C.texture.mipmaps;if(X&&X.length>0?t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=n.createRenderbuffer(),Ae(x.__webglDepthbuffer,C,!1);else{const Y=C.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,V=x.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,V),n.framebufferRenderbuffer(n.FRAMEBUFFER,Y,n.RENDERBUFFER,V)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function et(C,x,O){const X=i.get(C);x!==void 0&&de(X.__webglFramebuffer,C,C.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),O!==void 0&&we(C)}function qe(C){const x=C.texture,O=i.get(C),X=i.get(x);C.addEventListener("dispose",A);const Y=C.textures,V=C.isWebGLCubeRenderTarget===!0,be=Y.length>1;if(be||(X.__webglTexture===void 0&&(X.__webglTexture=n.createTexture()),X.__version=x.version,a.memory.textures++),V){O.__webglFramebuffer=[];for(let re=0;re<6;re++)if(x.mipmaps&&x.mipmaps.length>0){O.__webglFramebuffer[re]=[];for(let Ee=0;Ee 0){O.__webglFramebuffer=[];for(let re=0;re 0&&fe(C)===!1){O.__webglMultisampledFramebuffer=n.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let re=0;re 0)for(let Ee=0;Ee 0)for(let Ee=0;Ee 0){if(fe(C)===!1){const x=C.textures,O=C.width,X=C.height;let Y=n.COLOR_BUFFER_BIT;const V=C.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,be=i.get(C),re=x.length>1;if(re)for(let pe=0;pe 0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,be.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,be.__webglFramebuffer);for(let pe=0;pe 0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function lt(C){const x=a.render.frame;h.get(C)!==x&&(h.set(C,x),C.update())}function Se(C,x){const O=C.colorSpace,X=C.format,Y=C.type;return C.isCompressedTexture===!0||C.isVideoTexture===!0||O!==Ot&&O!==Zi&&(Xe.getTransfer(O)===it?(X!==Kt||Y!==oi)&&Me("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ve("WebGLTextures: Unsupported texture color space:",O)),x}function Ie(C){return typeof HTMLImageElement<"u"&&C instanceof HTMLImageElement?(c.width=C.naturalWidth||C.width,c.height=C.naturalHeight||C.height):typeof VideoFrame<"u"&&C instanceof VideoFrame?(c.width=C.displayWidth,c.height=C.displayHeight):(c.width=C.width,c.height=C.height),c}this.allocateTextureUnit=z,this.resetTextureUnits=N,this.setTexture2D=j,this.setTexture2DArray=q,this.setTexture3D=te,this.setTextureCube=G,this.rebindTextures=et,this.setupRenderTarget=qe,this.updateRenderTargetMipmap=We,this.updateMultisampleRenderTarget=je,this.setupDepthRenderbuffer=we,this.setupFrameBufferTexture=de,this.useMultisampledRTT=fe}function q0(n,e){function t(i,s=Zi){let r;const a=Xe.getTransfer(s);if(i===oi)return n.UNSIGNED_BYTE;if(i===ia)return n.UNSIGNED_SHORT_4_4_4_4;if(i===sa)return n.UNSIGNED_SHORT_5_5_5_1;if(i===El)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===wl)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Sl)return n.BYTE;if(i===Tl)return n.SHORT;if(i===pn)return n.UNSIGNED_SHORT;if(i===ta)return n.INT;if(i===os)return n.UNSIGNED_INT;if(i===qt)return n.FLOAT;if(i===ft)return n.HALF_FLOAT;if(i===Cl)return n.ALPHA;if(i===Al)return n.RGB;if(i===Kt)return n.RGBA;if(i===mn)return n.DEPTH_COMPONENT;if(i===Rs)return n.DEPTH_STENCIL;if(i===na)return n.RED;if(i===ra)return n.RED_INTEGER;if(i===aa)return n.RG;if(i===oa)return n.RG_INTEGER;if(i===la)return n.RGBA_INTEGER;if(i===jn||i===Xn||i===qn||i===Zn)if(a===it)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===jn)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Xn)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===qn)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Zn)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===jn)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Xn)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===qn)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Zn)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===ca||i===ha||i===ua||i===da)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===ca)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===ha)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ua)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===da)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===pa||i===ma||i===fa)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===pa||i===ma)return a===it?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===fa)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===ga||i===va||i===_a||i===xa||i===ba||i===ya||i===Ma||i===Sa||i===Ta||i===Ea||i===wa||i===Ca||i===Aa||i===Ra)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===ga)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===va)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===_a)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===xa)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===ba)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===ya)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ma)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Sa)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ta)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Ea)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===wa)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Ca)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Aa)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ra)return a===it?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Pa||i===La||i===Da)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===Pa)return a===it?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===La)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Da)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Ia||i===Ua||i===Na||i===Ba)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===Ia)return r.COMPRESSED_RED_RGTC1_EXT;if(i===Ua)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Na)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Ba)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===As?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const Z0=` void main() { gl_Position = vec4( position, 1.0 ); @@ -3950,11 +3950,11 @@ void main() { } -}`;class K0{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Tc(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new ct({vertexShader:Z0,fragmentShader:Y0,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new rt(new An(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class $0 extends ls{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,m=null,g=null;const v=typeof XRWebGLBinding<"u",f=new K0,p={},b=t.getContextAttributes();let _=null,E=null;const R=[],T=[],A=new oe;let I=null;const S=new St;S.viewport=new $e;const M=new St;M.viewport=new $e;const L=[S,M],N=new np;let z=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let Z=R[W];return Z===void 0&&(Z=new fo,R[W]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(W){let Z=R[W];return Z===void 0&&(Z=new fo,R[W]=Z),Z.getGripSpace()},this.getHand=function(W){let Z=R[W];return Z===void 0&&(Z=new fo,R[W]=Z),Z.getHandSpace()};function j(W){const Z=T.indexOf(W.inputSource);if(Z===-1)return;const de=R[Z];de!==void 0&&(de.update(W.inputSource,W.frame,c||a),de.dispatchEvent({type:W.type,data:W.inputSource}))}function q(){s.removeEventListener("select",j),s.removeEventListener("selectstart",j),s.removeEventListener("selectend",j),s.removeEventListener("squeeze",j),s.removeEventListener("squeezestart",j),s.removeEventListener("squeezeend",j),s.removeEventListener("end",q),s.removeEventListener("inputsourceschange",te);for(let W=0;W =0&&(T[Ae]=null,R[Ae].disconnect(de))}for(let Z=0;Z =T.length){T.push(de),Ae=we;break}else if(T[we]===null){T[we]=de,Ae=we;break}if(Ae===-1)break}const Te=R[Ae];Te&&Te.connect(de)}}const G=new w,K=new w;function ne(W,Z,de){G.setFromMatrixPosition(Z.matrixWorld),K.setFromMatrixPosition(de.matrixWorld);const Ae=G.distanceTo(K),Te=Z.projectionMatrix.elements,we=de.projectionMatrix.elements,et=Te[14]/(Te[10]-1),qe=Te[14]/(Te[10]+1),We=(Te[9]+1)/Te[5],D=(Te[9]-1)/Te[5],_t=(Te[8]-1)/Te[0],je=(we[8]+1)/we[0],tt=et*_t,fe=et*je,lt=Ae/(-_t+je),Se=lt*-_t;if(Z.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(Se),W.translateZ(lt),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert(),Te[10]===-1)W.projectionMatrix.copy(Z.projectionMatrix),W.projectionMatrixInverse.copy(Z.projectionMatrixInverse);else{const Ie=et+lt,C=qe+lt,x=tt-Se,O=fe+(Ae-Se),X=We*qe/C*Ie,Y=D*qe/C*Ie;W.projectionMatrix.makePerspective(x,O,X,Y,Ie,C),W.projectionMatrixInverse.copy(W.projectionMatrix).invert()}}function Le(W,Z){Z===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices(Z.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(s===null)return;let Z=W.near,de=W.far;f.texture!==null&&(f.depthNear>0&&(Z=f.depthNear),f.depthFar>0&&(de=f.depthFar)),N.near=M.near=S.near=Z,N.far=M.far=S.far=de,(z!==N.near||H!==N.far)&&(s.updateRenderState({depthNear:N.near,depthFar:N.far}),z=N.near,H=N.far),N.layers.mask=W.layers.mask|6,S.layers.mask=N.layers.mask&3,M.layers.mask=N.layers.mask&5;const Ae=W.parent,Te=N.cameras;Le(N,Ae);for(let we=0;we 0&&(f.alphaTest.value=p.alphaTest);const b=e.get(p),_=b.envMap,E=b.envMapRotation;_&&(f.envMap.value=_,vs.copy(E),vs.x*=-1,vs.y*=-1,vs.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(vs.y*=-1,vs.z*=-1),f.envMapRotation.value.setFromMatrix4(J0.makeRotationFromEuler(vs)),f.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=p.reflectivity,f.ior.value=p.ior,f.refractionRatio.value=p.refractionRatio),p.lightMap&&(f.lightMap.value=p.lightMap,f.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,f.lightMapTransform)),p.aoMap&&(f.aoMap.value=p.aoMap,f.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,f.aoMapTransform))}function a(f,p){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,p.map&&(f.map.value=p.map,t(p.map,f.mapTransform))}function o(f,p){f.dashSize.value=p.dashSize,f.totalSize.value=p.dashSize+p.gapSize,f.scale.value=p.scale}function l(f,p,b,_){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,f.size.value=p.size*b,f.scale.value=_*.5,p.map&&(f.map.value=p.map,t(p.map,f.uvTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest)}function c(f,p){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,f.rotation.value=p.rotation,p.map&&(f.map.value=p.map,t(p.map,f.mapTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest)}function h(f,p){f.specular.value.copy(p.specular),f.shininess.value=Math.max(p.shininess,1e-4)}function u(f,p){p.gradientMap&&(f.gradientMap.value=p.gradientMap)}function d(f,p){f.metalness.value=p.metalness,p.metalnessMap&&(f.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,f.metalnessMapTransform)),f.roughness.value=p.roughness,p.roughnessMap&&(f.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,f.roughnessMapTransform)),p.envMap&&(f.envMapIntensity.value=p.envMapIntensity)}function m(f,p,b){f.ior.value=p.ior,p.sheen>0&&(f.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),f.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(f.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,f.sheenColorMapTransform)),p.sheenRoughnessMap&&(f.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,f.sheenRoughnessMapTransform))),p.clearcoat>0&&(f.clearcoat.value=p.clearcoat,f.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(f.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,f.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(f.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===zt&&f.clearcoatNormalScale.value.negate())),p.dispersion>0&&(f.dispersion.value=p.dispersion),p.iridescence>0&&(f.iridescence.value=p.iridescence,f.iridescenceIOR.value=p.iridescenceIOR,f.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(f.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,f.iridescenceMapTransform)),p.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),p.transmission>0&&(f.transmission.value=p.transmission,f.transmissionSamplerMap.value=b.texture,f.transmissionSamplerSize.value.set(b.width,b.height),p.transmissionMap&&(f.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,f.transmissionMapTransform)),f.thickness.value=p.thickness,p.thicknessMap&&(f.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=p.attenuationDistance,f.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(f.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(f.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=p.specularIntensity,f.specularColor.value.copy(p.specularColor),p.specularColorMap&&(f.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,f.specularColorMapTransform)),p.specularIntensityMap&&(f.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,f.specularIntensityMapTransform))}function g(f,p){p.matcap&&(f.matcap.value=p.matcap)}function v(f,p){const b=e.get(p).light;f.referencePosition.value.setFromMatrixPosition(b.matrixWorld),f.nearDistance.value=b.shadow.camera.near,f.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function e1(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(b,_){const E=_.program;i.uniformBlockBinding(b,E)}function c(b,_){let E=s[b.id];E===void 0&&(g(b),E=h(b),s[b.id]=E,b.addEventListener("dispose",f));const R=_.program;i.updateUBOMapping(b,R);const T=e.render.frame;r[b.id]!==T&&(d(b),r[b.id]=T)}function h(b){const _=u();b.__bindingPointIndex=_;const E=n.createBuffer(),R=b.__size,T=b.usage;return n.bindBuffer(n.UNIFORM_BUFFER,E),n.bufferData(n.UNIFORM_BUFFER,R,T),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,_,E),E}function u(){for(let b=0;b 0&&(E+=R-T),b.__size=E,b.__cache={},this}function v(b){const _={boundary:0,storage:0};return typeof b=="number"||typeof b=="boolean"?(_.boundary=4,_.storage=4):b.isVector2?(_.boundary=8,_.storage=8):b.isVector3||b.isColor?(_.boundary=16,_.storage=12):b.isVector4?(_.boundary=16,_.storage=16):b.isMatrix3?(_.boundary=48,_.storage=48):b.isMatrix4?(_.boundary=64,_.storage=64):b.isTexture?Me("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Me("WebGLRenderer: Unsupported uniform value type.",b),_}function f(b){const _=b.target;_.removeEventListener("dispose",f);const E=a.indexOf(_.__bindingPointIndex);a.splice(E,1),n.deleteBuffer(s[_.id]),delete s[_.id],delete r[_.id]}function p(){for(const b in s)n.deleteBuffer(s[b]);a=[],s={},r={}}return{bind:l,update:c,dispose:p}}const t1=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let ji=null;function i1(){return ji===null&&(ji=new qs(t1,32,32,aa,ft),ji.minFilter=bt,ji.magFilter=bt,ji.wrapS=ei,ji.wrapT=ei,ji.generateMipmaps=!1,ji.needsUpdate=!0),ji}class Lr{constructor(e={}){const{canvas:t=Iu(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let m;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=i.getContextAttributes().alpha}else m=a;const g=new Set([la,oa,ra]),v=new Set([oi,os,pn,As,ia,sa]),f=new Uint32Array(4),p=new Int32Array(4);let b=null,_=null;const E=[],R=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=qi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const T=this;let A=!1;this._outputColorSpace=Ct;let I=0,S=0,M=null,L=-1,N=null;const z=new $e,H=new $e;let j=null;const q=new xe(0);let te=0,G=t.width,K=t.height,ne=1,Le=null,He=null;const Ye=new $e(0,0,G,K),Je=new $e(0,0,G,K);let Qe=!1;const W=new So;let Z=!1,de=!1;const Ae=new De,Te=new w,we=new $e,et={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let qe=!1;function We(){return M===null?ne:1}let D=i;function _t(y,B){return t.getContext(y,B)}try{const y={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r181"),t.addEventListener("webglcontextlost",Q,!1),t.addEventListener("webglcontextrestored",$,!1),t.addEventListener("webglcontextcreationerror",_e,!1),D===null){const B="webgl2";if(D=_t(B,y),D===null)throw _t(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(y){throw y("WebGLRenderer: "+y.message),y}let je,tt,fe,lt,Se,Ie,C,x,O,X,Y,V,be,re,Ee,pe,J,se,Oe,Ce,ue,Re,P,ae;function ie(){je=new ug(D),je.init(),Re=new q0(D,je),tt=new ig(D,je,e,Re),fe=new j0(D,je),tt.reversedDepthBuffer&&d&&fe.buffers.depth.setReversed(!0),lt=new mg(D),Se=new D0,Ie=new X0(D,je,fe,Se,tt,Re,lt),C=new ng(T),x=new hg(T),O=new vp(D),P=new eg(D,O),X=new dg(D,O,lt,P),Y=new gg(D,X,O,lt),Oe=new fg(D,tt,Ie),pe=new sg(Se),V=new L0(T,C,x,je,tt,P,pe),be=new Q0(T,Se),re=new U0,Ee=new z0(je),se=new Qf(T,C,x,fe,Y,m,l),J=new G0(T,Y,tt),ae=new e1(D,lt,tt,fe),Ce=new tg(D,je,lt),ue=new pg(D,je,lt),lt.programs=V.programs,T.capabilities=tt,T.extensions=je,T.properties=Se,T.renderLists=re,T.shadowMap=J,T.state=fe,T.info=lt}ie();const he=new $0(T,D);this.xr=he,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const y=je.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=je.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(y){y!==void 0&&(ne=y,this.setSize(G,K,!1))},this.getSize=function(y){return y.set(G,K)},this.setSize=function(y,B,k=!0){if(he.isPresenting){Me("WebGLRenderer: Can't change size while VR device is presenting.");return}G=y,K=B,t.width=Math.floor(y*ne),t.height=Math.floor(B*ne),k===!0&&(t.style.width=y+"px",t.style.height=B+"px"),this.setViewport(0,0,y,B)},this.getDrawingBufferSize=function(y){return y.set(G*ne,K*ne).floor()},this.setDrawingBufferSize=function(y,B,k){G=y,K=B,ne=k,t.width=Math.floor(y*k),t.height=Math.floor(B*k),this.setViewport(0,0,y,B)},this.getCurrentViewport=function(y){return y.copy(z)},this.getViewport=function(y){return y.copy(Ye)},this.setViewport=function(y,B,k,F){y.isVector4?Ye.set(y.x,y.y,y.z,y.w):Ye.set(y,B,k,F),fe.viewport(z.copy(Ye).multiplyScalar(ne).round())},this.getScissor=function(y){return y.copy(Je)},this.setScissor=function(y,B,k,F){y.isVector4?Je.set(y.x,y.y,y.z,y.w):Je.set(y,B,k,F),fe.scissor(H.copy(Je).multiplyScalar(ne).round())},this.getScissorTest=function(){return Qe},this.setScissorTest=function(y){fe.setScissorTest(Qe=y)},this.setOpaqueSort=function(y){Le=y},this.setTransparentSort=function(y){He=y},this.getClearColor=function(y){return y.copy(se.getClearColor())},this.setClearColor=function(){se.setClearColor(...arguments)},this.getClearAlpha=function(){return se.getClearAlpha()},this.setClearAlpha=function(){se.setClearAlpha(...arguments)},this.clear=function(y=!0,B=!0,k=!0){let F=0;if(y){let U=!1;if(M!==null){const ee=M.texture.format;U=g.has(ee)}if(U){const ee=M.texture.type,me=v.has(ee),ge=se.getClearColor(),ve=se.getClearAlpha(),Ue=ge.r,Be=ge.g,Ne=ge.b;me?(f[0]=Ue,f[1]=Be,f[2]=Ne,f[3]=ve,D.clearBufferuiv(D.COLOR,0,f)):(p[0]=Ue,p[1]=Be,p[2]=Ne,p[3]=ve,D.clearBufferiv(D.COLOR,0,p))}else F|=D.COLOR_BUFFER_BIT}B&&(F|=D.DEPTH_BUFFER_BIT),k&&(F|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),D.clear(F)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Q,!1),t.removeEventListener("webglcontextrestored",$,!1),t.removeEventListener("webglcontextcreationerror",_e,!1),se.dispose(),re.dispose(),Ee.dispose(),Se.dispose(),C.dispose(),x.dispose(),Y.dispose(),P.dispose(),ae.dispose(),V.dispose(),he.dispose(),he.removeEventListener("sessionstart",zh),he.removeEventListener("sessionend",Hh),xs.stop()};function Q(y){y.preventDefault(),Jn("WebGLRenderer: Context Lost."),A=!0}function $(){Jn("WebGLRenderer: Context Restored."),A=!1;const y=lt.autoReset,B=J.enabled,k=J.autoUpdate,F=J.needsUpdate,U=J.type;ie(),lt.autoReset=y,J.enabled=B,J.autoUpdate=k,J.needsUpdate=F,J.type=U}function _e(y){Ve("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Pe(y){const B=y.target;B.removeEventListener("dispose",Pe),Lt(B)}function Lt(y){ot(y),Se.remove(y)}function ot(y){const B=Se.get(y).programs;B!==void 0&&(B.forEach(function(k){V.releaseProgram(k)}),y.isShaderMaterial&&V.releaseShaderCache(y))}this.renderBufferDirect=function(y,B,k,F,U,ee){B===null&&(B=et);const me=U.isMesh&&U.matrixWorld.determinant()<0,ge=B_(y,B,k,F,U);fe.setMaterial(F,me);let ve=k.index,Ue=1;if(F.wireframe===!0){if(ve=X.getWireframeAttribute(k),ve===void 0)return;Ue=2}const Be=k.drawRange,Ne=k.attributes.position;let Ke=Be.start*Ue,ht=(Be.start+Be.count)*Ue;ee!==null&&(Ke=Math.max(Ke,ee.start*Ue),ht=Math.min(ht,(ee.start+ee.count)*Ue)),ve!==null?(Ke=Math.max(Ke,0),ht=Math.min(ht,ve.count)):Ne!=null&&(Ke=Math.max(Ke,0),ht=Math.min(ht,Ne.count));const vt=ht-Ke;if(vt<0||vt===1/0)return;P.setup(U,F,ge,k,ve);let pt,ut=Ce;if(ve!==null&&(pt=O.get(ve),ut=ue,ut.setIndex(pt)),U.isMesh)F.wireframe===!0?(fe.setLineWidth(F.wireframeLinewidth*We()),ut.setMode(D.LINES)):ut.setMode(D.TRIANGLES);else if(U.isLine){let ye=F.linewidth;ye===void 0&&(ye=1),fe.setLineWidth(ye*We()),U.isLineSegments?ut.setMode(D.LINES):U.isLineLoop?ut.setMode(D.LINE_LOOP):ut.setMode(D.LINE_STRIP)}else U.isPoints?ut.setMode(D.POINTS):U.isSprite&&ut.setMode(D.TRIANGLES);if(U.isBatchedMesh)if(U._multiDrawInstances!==null)_n("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),ut.renderMultiDrawInstances(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount,U._multiDrawInstances);else if(je.get("WEBGL_multi_draw"))ut.renderMultiDraw(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount);else{const ye=U._multiDrawStarts,Ut=U._multiDrawCounts,Xi=U._multiDrawCount,yi=ve?O.get(ve).bytesPerElement:1,cn=Se.get(F).currentProgram.getUniforms();for(let Qt=0;Qt {function ee(){if(F.forEach(function(me){Se.get(me).currentProgram.isReady()&&F.delete(me)}),F.size===0){U(y);return}setTimeout(ee,10)}je.get("KHR_parallel_shader_compile")!==null?ee():setTimeout(ee,10)})};let bi=null;function N_(y){bi&&bi(y)}function zh(){xs.stop()}function Hh(){xs.start()}const xs=new Vc;xs.setAnimationLoop(N_),typeof self<"u"&&xs.setContext(self),this.setAnimationLoop=function(y){bi=y,he.setAnimationLoop(y),y===null?xs.stop():xs.start()},he.addEventListener("sessionstart",zh),he.addEventListener("sessionend",Hh),this.render=function(y,B){if(B!==void 0&&B.isCamera!==!0){Ve("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),he.enabled===!0&&he.isPresenting===!0&&(he.cameraAutoUpdate===!0&&he.updateCamera(B),B=he.getCamera()),y.isScene===!0&&y.onBeforeRender(T,y,B,M),_=Ee.get(y,R.length),_.init(B),R.push(_),Ae.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),W.setFromProjectionMatrix(Ae,wi,B.reversedDepth),de=this.localClippingEnabled,Z=pe.init(this.clippingPlanes,de),b=re.get(y,E.length),b.init(),E.push(b),he.enabled===!0&&he.isPresenting===!0){const ee=T.xr.getDepthSensingMesh();ee!==null&&nl(ee,B,-1/0,T.sortObjects)}nl(y,B,0,T.sortObjects),b.finish(),T.sortObjects===!0&&b.sort(Le,He),qe=he.enabled===!1||he.isPresenting===!1||he.hasDepthSensing()===!1,qe&&se.addToRenderList(b,y),this.info.render.frame++,Z===!0&&pe.beginShadows();const k=_.state.shadowsArray;J.render(k,y,B),Z===!0&&pe.endShadows(),this.info.autoReset===!0&&this.info.reset();const F=b.opaque,U=b.transmissive;if(_.setupLights(),B.isArrayCamera){const ee=B.cameras;if(U.length>0)for(let me=0,ge=ee.length;me 0&&Gh(F,U,y,B),qe&&se.render(y),Vh(b,y,B);M!==null&&S===0&&(Ie.updateMultisampleRenderTarget(M),Ie.updateRenderTargetMipmap(M)),y.isScene===!0&&y.onAfterRender(T,y,B),P.resetDefaultState(),L=-1,N=null,R.pop(),R.length>0?(_=R[R.length-1],Z===!0&&pe.setGlobalState(T.clippingPlanes,_.state.camera)):_=null,E.pop(),E.length>0?b=E[E.length-1]:b=null};function nl(y,B,k,F){if(y.visible===!1)return;if(y.layers.test(B.layers)){if(y.isGroup)k=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(B);else if(y.isLight)_.pushLight(y),y.castShadow&&_.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||W.intersectsSprite(y)){F&&we.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Ae);const ee=Y.update(y),me=y.material;me.visible&&b.push(y,ee,me,k,we.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||W.intersectsObject(y))){const ee=Y.update(y),me=y.material;if(F&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),we.copy(y.boundingSphere.center)):(ee.boundingSphere===null&&ee.computeBoundingSphere(),we.copy(ee.boundingSphere.center)),we.applyMatrix4(y.matrixWorld).applyMatrix4(Ae)),Array.isArray(me)){const ge=ee.groups;for(let ve=0,Ue=ge.length;ve 0&&kr(U,B,k),ee.length>0&&kr(ee,B,k),me.length>0&&kr(me,B,k),fe.buffers.depth.setTest(!0),fe.buffers.depth.setMask(!0),fe.buffers.color.setMask(!0),fe.setPolygonOffset(!1)}function Gh(y,B,k,F){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;_.state.transmissionRenderTarget[F.id]===void 0&&(_.state.transmissionRenderTarget[F.id]=new yt(1,1,{generateMipmaps:!0,type:je.has("EXT_color_buffer_half_float")||je.has("EXT_color_buffer_float")?ft:oi,minFilter:Ei,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xe.workingColorSpace}));const U=_.state.transmissionRenderTarget[F.id],ee=F.viewport||z;U.setSize(ee.z*T.transmissionResolutionScale,ee.w*T.transmissionResolutionScale);const me=T.getRenderTarget(),ge=T.getActiveCubeFace(),ve=T.getActiveMipmapLevel();T.setRenderTarget(U),T.getClearColor(q),te=T.getClearAlpha(),te<1&&T.setClearColor(16777215,.5),T.clear(),qe&&se.render(k);const Ue=T.toneMapping;T.toneMapping=qi;const Be=F.viewport;if(F.viewport!==void 0&&(F.viewport=void 0),_.setupLightsView(F),Z===!0&&pe.setGlobalState(T.clippingPlanes,F),kr(y,k,F),Ie.updateMultisampleRenderTarget(U),Ie.updateRenderTargetMipmap(U),je.has("WEBGL_multisampled_render_to_texture")===!1){let Ne=!1;for(let Ke=0,ht=B.length;Ke 0),Ne=!!k.morphAttributes.position,Ke=!!k.morphAttributes.normal,ht=!!k.morphAttributes.color;let vt=qi;F.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(vt=T.toneMapping);const pt=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,ut=pt!==void 0?pt.length:0,ye=Se.get(F),Ut=_.state.lights;if(Z===!0&&(de===!0||y!==N)){const Nt=y===N&&F.id===L;pe.setState(F,y,Nt)}let Xi=!1;F.version===ye.__version?(ye.needsLights&&ye.lightsStateVersion!==Ut.state.version||ye.outputColorSpace!==ge||U.isBatchedMesh&&ye.batching===!1||!U.isBatchedMesh&&ye.batching===!0||U.isBatchedMesh&&ye.batchingColor===!0&&U.colorTexture===null||U.isBatchedMesh&&ye.batchingColor===!1&&U.colorTexture!==null||U.isInstancedMesh&&ye.instancing===!1||!U.isInstancedMesh&&ye.instancing===!0||U.isSkinnedMesh&&ye.skinning===!1||!U.isSkinnedMesh&&ye.skinning===!0||U.isInstancedMesh&&ye.instancingColor===!0&&U.instanceColor===null||U.isInstancedMesh&&ye.instancingColor===!1&&U.instanceColor!==null||U.isInstancedMesh&&ye.instancingMorph===!0&&U.morphTexture===null||U.isInstancedMesh&&ye.instancingMorph===!1&&U.morphTexture!==null||ye.envMap!==ve||F.fog===!0&&ye.fog!==ee||ye.numClippingPlanes!==void 0&&(ye.numClippingPlanes!==pe.numPlanes||ye.numIntersection!==pe.numIntersection)||ye.vertexAlphas!==Ue||ye.vertexTangents!==Be||ye.morphTargets!==Ne||ye.morphNormals!==Ke||ye.morphColors!==ht||ye.toneMapping!==vt||ye.morphTargetsCount!==ut)&&(Xi=!0):(Xi=!0,ye.__version=F.version);let yi=ye.currentProgram;Xi===!0&&(yi=Fr(F,B,U));let cn=!1,Qt=!1,Fn=!1;const mt=yi.getUniforms(),Yt=ye.uniforms;if(fe.useProgram(yi.program)&&(cn=!0,Qt=!0,Fn=!0),F.id!==L&&(L=F.id,Qt=!0),cn||N!==y){fe.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),mt.setValue(D,"projectionMatrix",y.projectionMatrix),mt.setValue(D,"viewMatrix",y.matrixWorldInverse);const Nt=mt.map.cameraPosition;Nt!==void 0&&Nt.setValue(D,Te.setFromMatrixPosition(y.matrixWorld)),tt.logarithmicDepthBuffer&&mt.setValue(D,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(F.isMeshPhongMaterial||F.isMeshToonMaterial||F.isMeshLambertMaterial||F.isMeshBasicMaterial||F.isMeshStandardMaterial||F.isShaderMaterial)&&mt.setValue(D,"isOrthographic",y.isOrthographicCamera===!0),N!==y&&(N=y,Qt=!0,Fn=!0)}if(U.isSkinnedMesh){mt.setOptional(D,U,"bindMatrix"),mt.setOptional(D,U,"bindMatrixInverse");const Nt=U.skeleton;Nt&&(Nt.boneTexture===null&&Nt.computeBoneTexture(),mt.setValue(D,"boneTexture",Nt.boneTexture,Ie))}U.isBatchedMesh&&(mt.setOptional(D,U,"batchingTexture"),mt.setValue(D,"batchingTexture",U._matricesTexture,Ie),mt.setOptional(D,U,"batchingIdTexture"),mt.setValue(D,"batchingIdTexture",U._indirectTexture,Ie),mt.setOptional(D,U,"batchingColorTexture"),U._colorsTexture!==null&&mt.setValue(D,"batchingColorTexture",U._colorsTexture,Ie));const ri=k.morphAttributes;if((ri.position!==void 0||ri.normal!==void 0||ri.color!==void 0)&&Oe.update(U,k,yi),(Qt||ye.receiveShadow!==U.receiveShadow)&&(ye.receiveShadow=U.receiveShadow,mt.setValue(D,"receiveShadow",U.receiveShadow)),F.isMeshGouraudMaterial&&F.envMap!==null&&(Yt.envMap.value=ve,Yt.flipEnvMap.value=ve.isCubeTexture&&ve.isRenderTargetTexture===!1?-1:1),F.isMeshStandardMaterial&&F.envMap===null&&B.environment!==null&&(Yt.envMapIntensity.value=B.environmentIntensity),Yt.dfgLUT!==void 0&&(Yt.dfgLUT.value=i1()),Qt&&(mt.setValue(D,"toneMappingExposure",T.toneMappingExposure),ye.needsLights&&O_(Yt,Fn),ee&&F.fog===!0&&be.refreshFogUniforms(Yt,ee),be.refreshMaterialUniforms(Yt,F,ne,K,_.state.transmissionRenderTarget[y.id]),Rr.upload(D,jh(ye),Yt,Ie)),F.isShaderMaterial&&F.uniformsNeedUpdate===!0&&(Rr.upload(D,jh(ye),Yt,Ie),F.uniformsNeedUpdate=!1),F.isSpriteMaterial&&mt.setValue(D,"center",U.center),mt.setValue(D,"modelViewMatrix",U.modelViewMatrix),mt.setValue(D,"normalMatrix",U.normalMatrix),mt.setValue(D,"modelMatrix",U.matrixWorld),F.isShaderMaterial||F.isRawShaderMaterial){const Nt=F.uniformsGroups;for(let Mi=0,rl=Nt.length;Mi 0&&Ie.useMultisampledRTT(y)===!1?U=Se.get(y).__webglMultisampledFramebuffer:Array.isArray(Ue)?U=Ue[k]:U=Ue,z.copy(y.viewport),H.copy(y.scissor),j=y.scissorTest}else z.copy(Ye).multiplyScalar(ne).floor(),H.copy(Je).multiplyScalar(ne).floor(),j=Qe;if(k!==0&&(U=F_),fe.bindFramebuffer(D.FRAMEBUFFER,U)&&F&&fe.drawBuffers(y,U),fe.viewport(z),fe.scissor(H),fe.setScissorTest(j),ee){const ge=Se.get(y.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+B,ge.__webglTexture,k)}else if(me){const ge=B;for(let ve=0;ve =0&&B<=y.width-F&&k>=0&&k<=y.height-U&&(y.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+ge),D.readPixels(B,k,F,U,Re.convert(Be),Re.convert(Ne),ee))}finally{const Ue=M!==null?Se.get(M).__webglFramebuffer:null;fe.bindFramebuffer(D.FRAMEBUFFER,Ue)}}},this.readRenderTargetPixelsAsync=async function(y,B,k,F,U,ee,me,ge=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ve=Se.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&me!==void 0&&(ve=ve[me]),ve)if(B>=0&&B<=y.width-F&&k>=0&&k<=y.height-U){fe.bindFramebuffer(D.FRAMEBUFFER,ve);const Ue=y.textures[ge],Be=Ue.format,Ne=Ue.type;if(!tt.textureFormatReadable(Be))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(Ne))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ke=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,Ke),D.bufferData(D.PIXEL_PACK_BUFFER,ee.byteLength,D.STREAM_READ),y.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+ge),D.readPixels(B,k,F,U,Re.convert(Be),Re.convert(Ne),0);const ht=M!==null?Se.get(M).__webglFramebuffer:null;fe.bindFramebuffer(D.FRAMEBUFFER,ht);const vt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await Uu(D,vt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,Ke),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,ee),D.deleteBuffer(Ke),D.deleteSync(vt),ee}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,B=null,k=0){const F=Math.pow(2,-k),U=Math.floor(y.image.width*F),ee=Math.floor(y.image.height*F),me=B!==null?B.x:0,ge=B!==null?B.y:0;Ie.setTexture2D(y,0),D.copyTexSubImage2D(D.TEXTURE_2D,k,0,0,me,ge,U,ee),fe.unbindTexture()};const z_=D.createFramebuffer(),H_=D.createFramebuffer();this.copyTextureToTexture=function(y,B,k=null,F=null,U=0,ee=null){ee===null&&(U!==0?(_n("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ee=U,U=0):ee=0);let me,ge,ve,Ue,Be,Ne,Ke,ht,vt;const pt=y.isCompressedTexture?y.mipmaps[ee]:y.image;if(k!==null)me=k.max.x-k.min.x,ge=k.max.y-k.min.y,ve=k.isBox3?k.max.z-k.min.z:1,Ue=k.min.x,Be=k.min.y,Ne=k.isBox3?k.min.z:0;else{const ri=Math.pow(2,-U);me=Math.floor(pt.width*ri),ge=Math.floor(pt.height*ri),y.isDataArrayTexture?ve=pt.depth:y.isData3DTexture?ve=Math.floor(pt.depth*ri):ve=1,Ue=0,Be=0,Ne=0}F!==null?(Ke=F.x,ht=F.y,vt=F.z):(Ke=0,ht=0,vt=0);const ut=Re.convert(B.format),ye=Re.convert(B.type);let Ut;B.isData3DTexture?(Ie.setTexture3D(B,0),Ut=D.TEXTURE_3D):B.isDataArrayTexture||B.isCompressedArrayTexture?(Ie.setTexture2DArray(B,0),Ut=D.TEXTURE_2D_ARRAY):(Ie.setTexture2D(B,0),Ut=D.TEXTURE_2D),D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,B.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,B.unpackAlignment);const Xi=D.getParameter(D.UNPACK_ROW_LENGTH),yi=D.getParameter(D.UNPACK_IMAGE_HEIGHT),cn=D.getParameter(D.UNPACK_SKIP_PIXELS),Qt=D.getParameter(D.UNPACK_SKIP_ROWS),Fn=D.getParameter(D.UNPACK_SKIP_IMAGES);D.pixelStorei(D.UNPACK_ROW_LENGTH,pt.width),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,pt.height),D.pixelStorei(D.UNPACK_SKIP_PIXELS,Ue),D.pixelStorei(D.UNPACK_SKIP_ROWS,Be),D.pixelStorei(D.UNPACK_SKIP_IMAGES,Ne);const mt=y.isDataArrayTexture||y.isData3DTexture,Yt=B.isDataArrayTexture||B.isData3DTexture;if(y.isDepthTexture){const ri=Se.get(y),Nt=Se.get(B),Mi=Se.get(ri.__renderTarget),rl=Se.get(Nt.__renderTarget);fe.bindFramebuffer(D.READ_FRAMEBUFFER,Mi.__webglFramebuffer),fe.bindFramebuffer(D.DRAW_FRAMEBUFFER,rl.__webglFramebuffer);for(let bs=0;bs (E=A.indexOf(` +}`;class K0{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Tc(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new ct({vertexShader:Z0,fragmentShader:Y0,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new rt(new An(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class $0 extends ls{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,m=null,g=null;const v=typeof XRWebGLBinding<"u",f=new K0,p={},b=t.getContextAttributes();let _=null,E=null;const R=[],T=[],A=new oe;let I=null;const S=new Tt;S.viewport=new $e;const M=new Tt;M.viewport=new $e;const L=[S,M],N=new np;let z=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let Z=R[W];return Z===void 0&&(Z=new fo,R[W]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(W){let Z=R[W];return Z===void 0&&(Z=new fo,R[W]=Z),Z.getGripSpace()},this.getHand=function(W){let Z=R[W];return Z===void 0&&(Z=new fo,R[W]=Z),Z.getHandSpace()};function j(W){const Z=T.indexOf(W.inputSource);if(Z===-1)return;const de=R[Z];de!==void 0&&(de.update(W.inputSource,W.frame,c||a),de.dispatchEvent({type:W.type,data:W.inputSource}))}function q(){s.removeEventListener("select",j),s.removeEventListener("selectstart",j),s.removeEventListener("selectend",j),s.removeEventListener("squeeze",j),s.removeEventListener("squeezestart",j),s.removeEventListener("squeezeend",j),s.removeEventListener("end",q),s.removeEventListener("inputsourceschange",te);for(let W=0;W =0&&(T[Ae]=null,R[Ae].disconnect(de))}for(let Z=0;Z =T.length){T.push(de),Ae=we;break}else if(T[we]===null){T[we]=de,Ae=we;break}if(Ae===-1)break}const Te=R[Ae];Te&&Te.connect(de)}}const G=new w,K=new w;function ne(W,Z,de){G.setFromMatrixPosition(Z.matrixWorld),K.setFromMatrixPosition(de.matrixWorld);const Ae=G.distanceTo(K),Te=Z.projectionMatrix.elements,we=de.projectionMatrix.elements,et=Te[14]/(Te[10]-1),qe=Te[14]/(Te[10]+1),We=(Te[9]+1)/Te[5],D=(Te[9]-1)/Te[5],xt=(Te[8]-1)/Te[0],je=(we[8]+1)/we[0],tt=et*xt,fe=et*je,lt=Ae/(-xt+je),Se=lt*-xt;if(Z.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(Se),W.translateZ(lt),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert(),Te[10]===-1)W.projectionMatrix.copy(Z.projectionMatrix),W.projectionMatrixInverse.copy(Z.projectionMatrixInverse);else{const Ie=et+lt,C=qe+lt,x=tt-Se,O=fe+(Ae-Se),X=We*qe/C*Ie,Y=D*qe/C*Ie;W.projectionMatrix.makePerspective(x,O,X,Y,Ie,C),W.projectionMatrixInverse.copy(W.projectionMatrix).invert()}}function Le(W,Z){Z===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices(Z.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(s===null)return;let Z=W.near,de=W.far;f.texture!==null&&(f.depthNear>0&&(Z=f.depthNear),f.depthFar>0&&(de=f.depthFar)),N.near=M.near=S.near=Z,N.far=M.far=S.far=de,(z!==N.near||H!==N.far)&&(s.updateRenderState({depthNear:N.near,depthFar:N.far}),z=N.near,H=N.far),N.layers.mask=W.layers.mask|6,S.layers.mask=N.layers.mask&3,M.layers.mask=N.layers.mask&5;const Ae=W.parent,Te=N.cameras;Le(N,Ae);for(let we=0;we 0&&(f.alphaTest.value=p.alphaTest);const b=e.get(p),_=b.envMap,E=b.envMapRotation;_&&(f.envMap.value=_,vs.copy(E),vs.x*=-1,vs.y*=-1,vs.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(vs.y*=-1,vs.z*=-1),f.envMapRotation.value.setFromMatrix4(J0.makeRotationFromEuler(vs)),f.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=p.reflectivity,f.ior.value=p.ior,f.refractionRatio.value=p.refractionRatio),p.lightMap&&(f.lightMap.value=p.lightMap,f.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,f.lightMapTransform)),p.aoMap&&(f.aoMap.value=p.aoMap,f.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,f.aoMapTransform))}function a(f,p){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,p.map&&(f.map.value=p.map,t(p.map,f.mapTransform))}function o(f,p){f.dashSize.value=p.dashSize,f.totalSize.value=p.dashSize+p.gapSize,f.scale.value=p.scale}function l(f,p,b,_){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,f.size.value=p.size*b,f.scale.value=_*.5,p.map&&(f.map.value=p.map,t(p.map,f.uvTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest)}function c(f,p){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,f.rotation.value=p.rotation,p.map&&(f.map.value=p.map,t(p.map,f.mapTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest)}function h(f,p){f.specular.value.copy(p.specular),f.shininess.value=Math.max(p.shininess,1e-4)}function u(f,p){p.gradientMap&&(f.gradientMap.value=p.gradientMap)}function d(f,p){f.metalness.value=p.metalness,p.metalnessMap&&(f.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,f.metalnessMapTransform)),f.roughness.value=p.roughness,p.roughnessMap&&(f.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,f.roughnessMapTransform)),p.envMap&&(f.envMapIntensity.value=p.envMapIntensity)}function m(f,p,b){f.ior.value=p.ior,p.sheen>0&&(f.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),f.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(f.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,f.sheenColorMapTransform)),p.sheenRoughnessMap&&(f.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,f.sheenRoughnessMapTransform))),p.clearcoat>0&&(f.clearcoat.value=p.clearcoat,f.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(f.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,f.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(f.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===zt&&f.clearcoatNormalScale.value.negate())),p.dispersion>0&&(f.dispersion.value=p.dispersion),p.iridescence>0&&(f.iridescence.value=p.iridescence,f.iridescenceIOR.value=p.iridescenceIOR,f.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(f.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,f.iridescenceMapTransform)),p.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),p.transmission>0&&(f.transmission.value=p.transmission,f.transmissionSamplerMap.value=b.texture,f.transmissionSamplerSize.value.set(b.width,b.height),p.transmissionMap&&(f.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,f.transmissionMapTransform)),f.thickness.value=p.thickness,p.thicknessMap&&(f.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=p.attenuationDistance,f.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(f.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(f.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=p.specularIntensity,f.specularColor.value.copy(p.specularColor),p.specularColorMap&&(f.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,f.specularColorMapTransform)),p.specularIntensityMap&&(f.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,f.specularIntensityMapTransform))}function g(f,p){p.matcap&&(f.matcap.value=p.matcap)}function v(f,p){const b=e.get(p).light;f.referencePosition.value.setFromMatrixPosition(b.matrixWorld),f.nearDistance.value=b.shadow.camera.near,f.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function e1(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(b,_){const E=_.program;i.uniformBlockBinding(b,E)}function c(b,_){let E=s[b.id];E===void 0&&(g(b),E=h(b),s[b.id]=E,b.addEventListener("dispose",f));const R=_.program;i.updateUBOMapping(b,R);const T=e.render.frame;r[b.id]!==T&&(d(b),r[b.id]=T)}function h(b){const _=u();b.__bindingPointIndex=_;const E=n.createBuffer(),R=b.__size,T=b.usage;return n.bindBuffer(n.UNIFORM_BUFFER,E),n.bufferData(n.UNIFORM_BUFFER,R,T),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,_,E),E}function u(){for(let b=0;b 0&&(E+=R-T),b.__size=E,b.__cache={},this}function v(b){const _={boundary:0,storage:0};return typeof b=="number"||typeof b=="boolean"?(_.boundary=4,_.storage=4):b.isVector2?(_.boundary=8,_.storage=8):b.isVector3||b.isColor?(_.boundary=16,_.storage=12):b.isVector4?(_.boundary=16,_.storage=16):b.isMatrix3?(_.boundary=48,_.storage=48):b.isMatrix4?(_.boundary=64,_.storage=64):b.isTexture?Me("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Me("WebGLRenderer: Unsupported uniform value type.",b),_}function f(b){const _=b.target;_.removeEventListener("dispose",f);const E=a.indexOf(_.__bindingPointIndex);a.splice(E,1),n.deleteBuffer(s[_.id]),delete s[_.id],delete r[_.id]}function p(){for(const b in s)n.deleteBuffer(s[b]);a=[],s={},r={}}return{bind:l,update:c,dispose:p}}const t1=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let ji=null;function i1(){return ji===null&&(ji=new qs(t1,32,32,aa,ft),ji.minFilter=yt,ji.magFilter=yt,ji.wrapS=ei,ji.wrapT=ei,ji.generateMipmaps=!1,ji.needsUpdate=!0),ji}class Lr{constructor(e={}){const{canvas:t=Iu(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let m;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=i.getContextAttributes().alpha}else m=a;const g=new Set([la,oa,ra]),v=new Set([oi,os,pn,As,ia,sa]),f=new Uint32Array(4),p=new Int32Array(4);let b=null,_=null;const E=[],R=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=qi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const T=this;let A=!1;this._outputColorSpace=At;let I=0,S=0,M=null,L=-1,N=null;const z=new $e,H=new $e;let j=null;const q=new xe(0);let te=0,G=t.width,K=t.height,ne=1,Le=null,He=null;const Ye=new $e(0,0,G,K),Je=new $e(0,0,G,K);let Qe=!1;const W=new So;let Z=!1,de=!1;const Ae=new De,Te=new w,we=new $e,et={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let qe=!1;function We(){return M===null?ne:1}let D=i;function xt(y,B){return t.getContext(y,B)}try{const y={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r181"),t.addEventListener("webglcontextlost",Q,!1),t.addEventListener("webglcontextrestored",$,!1),t.addEventListener("webglcontextcreationerror",_e,!1),D===null){const B="webgl2";if(D=xt(B,y),D===null)throw xt(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(y){throw y("WebGLRenderer: "+y.message),y}let je,tt,fe,lt,Se,Ie,C,x,O,X,Y,V,be,re,Ee,pe,J,se,Oe,Ce,ue,Re,P,ae;function ie(){je=new ug(D),je.init(),Re=new q0(D,je),tt=new ig(D,je,e,Re),fe=new j0(D,je),tt.reversedDepthBuffer&&d&&fe.buffers.depth.setReversed(!0),lt=new mg(D),Se=new D0,Ie=new X0(D,je,fe,Se,tt,Re,lt),C=new ng(T),x=new hg(T),O=new vp(D),P=new eg(D,O),X=new dg(D,O,lt,P),Y=new gg(D,X,O,lt),Oe=new fg(D,tt,Ie),pe=new sg(Se),V=new L0(T,C,x,je,tt,P,pe),be=new Q0(T,Se),re=new U0,Ee=new z0(je),se=new Qf(T,C,x,fe,Y,m,l),J=new G0(T,Y,tt),ae=new e1(D,lt,tt,fe),Ce=new tg(D,je,lt),ue=new pg(D,je,lt),lt.programs=V.programs,T.capabilities=tt,T.extensions=je,T.properties=Se,T.renderLists=re,T.shadowMap=J,T.state=fe,T.info=lt}ie();const he=new $0(T,D);this.xr=he,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const y=je.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=je.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(y){y!==void 0&&(ne=y,this.setSize(G,K,!1))},this.getSize=function(y){return y.set(G,K)},this.setSize=function(y,B,k=!0){if(he.isPresenting){Me("WebGLRenderer: Can't change size while VR device is presenting.");return}G=y,K=B,t.width=Math.floor(y*ne),t.height=Math.floor(B*ne),k===!0&&(t.style.width=y+"px",t.style.height=B+"px"),this.setViewport(0,0,y,B)},this.getDrawingBufferSize=function(y){return y.set(G*ne,K*ne).floor()},this.setDrawingBufferSize=function(y,B,k){G=y,K=B,ne=k,t.width=Math.floor(y*k),t.height=Math.floor(B*k),this.setViewport(0,0,y,B)},this.getCurrentViewport=function(y){return y.copy(z)},this.getViewport=function(y){return y.copy(Ye)},this.setViewport=function(y,B,k,F){y.isVector4?Ye.set(y.x,y.y,y.z,y.w):Ye.set(y,B,k,F),fe.viewport(z.copy(Ye).multiplyScalar(ne).round())},this.getScissor=function(y){return y.copy(Je)},this.setScissor=function(y,B,k,F){y.isVector4?Je.set(y.x,y.y,y.z,y.w):Je.set(y,B,k,F),fe.scissor(H.copy(Je).multiplyScalar(ne).round())},this.getScissorTest=function(){return Qe},this.setScissorTest=function(y){fe.setScissorTest(Qe=y)},this.setOpaqueSort=function(y){Le=y},this.setTransparentSort=function(y){He=y},this.getClearColor=function(y){return y.copy(se.getClearColor())},this.setClearColor=function(){se.setClearColor(...arguments)},this.getClearAlpha=function(){return se.getClearAlpha()},this.setClearAlpha=function(){se.setClearAlpha(...arguments)},this.clear=function(y=!0,B=!0,k=!0){let F=0;if(y){let U=!1;if(M!==null){const ee=M.texture.format;U=g.has(ee)}if(U){const ee=M.texture.type,me=v.has(ee),ge=se.getClearColor(),ve=se.getClearAlpha(),Ue=ge.r,Be=ge.g,Ne=ge.b;me?(f[0]=Ue,f[1]=Be,f[2]=Ne,f[3]=ve,D.clearBufferuiv(D.COLOR,0,f)):(p[0]=Ue,p[1]=Be,p[2]=Ne,p[3]=ve,D.clearBufferiv(D.COLOR,0,p))}else F|=D.COLOR_BUFFER_BIT}B&&(F|=D.DEPTH_BUFFER_BIT),k&&(F|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),D.clear(F)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Q,!1),t.removeEventListener("webglcontextrestored",$,!1),t.removeEventListener("webglcontextcreationerror",_e,!1),se.dispose(),re.dispose(),Ee.dispose(),Se.dispose(),C.dispose(),x.dispose(),Y.dispose(),P.dispose(),ae.dispose(),V.dispose(),he.dispose(),he.removeEventListener("sessionstart",zh),he.removeEventListener("sessionend",Hh),xs.stop()};function Q(y){y.preventDefault(),Jn("WebGLRenderer: Context Lost."),A=!0}function $(){Jn("WebGLRenderer: Context Restored."),A=!1;const y=lt.autoReset,B=J.enabled,k=J.autoUpdate,F=J.needsUpdate,U=J.type;ie(),lt.autoReset=y,J.enabled=B,J.autoUpdate=k,J.needsUpdate=F,J.type=U}function _e(y){Ve("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Pe(y){const B=y.target;B.removeEventListener("dispose",Pe),Dt(B)}function Dt(y){ot(y),Se.remove(y)}function ot(y){const B=Se.get(y).programs;B!==void 0&&(B.forEach(function(k){V.releaseProgram(k)}),y.isShaderMaterial&&V.releaseShaderCache(y))}this.renderBufferDirect=function(y,B,k,F,U,ee){B===null&&(B=et);const me=U.isMesh&&U.matrixWorld.determinant()<0,ge=B_(y,B,k,F,U);fe.setMaterial(F,me);let ve=k.index,Ue=1;if(F.wireframe===!0){if(ve=X.getWireframeAttribute(k),ve===void 0)return;Ue=2}const Be=k.drawRange,Ne=k.attributes.position;let Ke=Be.start*Ue,ht=(Be.start+Be.count)*Ue;ee!==null&&(Ke=Math.max(Ke,ee.start*Ue),ht=Math.min(ht,(ee.start+ee.count)*Ue)),ve!==null?(Ke=Math.max(Ke,0),ht=Math.min(ht,ve.count)):Ne!=null&&(Ke=Math.max(Ke,0),ht=Math.min(ht,Ne.count));const _t=ht-Ke;if(_t<0||_t===1/0)return;P.setup(U,F,ge,k,ve);let pt,ut=Ce;if(ve!==null&&(pt=O.get(ve),ut=ue,ut.setIndex(pt)),U.isMesh)F.wireframe===!0?(fe.setLineWidth(F.wireframeLinewidth*We()),ut.setMode(D.LINES)):ut.setMode(D.TRIANGLES);else if(U.isLine){let ye=F.linewidth;ye===void 0&&(ye=1),fe.setLineWidth(ye*We()),U.isLineSegments?ut.setMode(D.LINES):U.isLineLoop?ut.setMode(D.LINE_LOOP):ut.setMode(D.LINE_STRIP)}else U.isPoints?ut.setMode(D.POINTS):U.isSprite&&ut.setMode(D.TRIANGLES);if(U.isBatchedMesh)if(U._multiDrawInstances!==null)_n("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),ut.renderMultiDrawInstances(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount,U._multiDrawInstances);else if(je.get("WEBGL_multi_draw"))ut.renderMultiDraw(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount);else{const ye=U._multiDrawStarts,Nt=U._multiDrawCounts,Xi=U._multiDrawCount,yi=ve?O.get(ve).bytesPerElement:1,cn=Se.get(F).currentProgram.getUniforms();for(let Qt=0;Qt {function ee(){if(F.forEach(function(me){Se.get(me).currentProgram.isReady()&&F.delete(me)}),F.size===0){U(y);return}setTimeout(ee,10)}je.get("KHR_parallel_shader_compile")!==null?ee():setTimeout(ee,10)})};let bi=null;function N_(y){bi&&bi(y)}function zh(){xs.stop()}function Hh(){xs.start()}const xs=new Vc;xs.setAnimationLoop(N_),typeof self<"u"&&xs.setContext(self),this.setAnimationLoop=function(y){bi=y,he.setAnimationLoop(y),y===null?xs.stop():xs.start()},he.addEventListener("sessionstart",zh),he.addEventListener("sessionend",Hh),this.render=function(y,B){if(B!==void 0&&B.isCamera!==!0){Ve("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),he.enabled===!0&&he.isPresenting===!0&&(he.cameraAutoUpdate===!0&&he.updateCamera(B),B=he.getCamera()),y.isScene===!0&&y.onBeforeRender(T,y,B,M),_=Ee.get(y,R.length),_.init(B),R.push(_),Ae.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),W.setFromProjectionMatrix(Ae,wi,B.reversedDepth),de=this.localClippingEnabled,Z=pe.init(this.clippingPlanes,de),b=re.get(y,E.length),b.init(),E.push(b),he.enabled===!0&&he.isPresenting===!0){const ee=T.xr.getDepthSensingMesh();ee!==null&&nl(ee,B,-1/0,T.sortObjects)}nl(y,B,0,T.sortObjects),b.finish(),T.sortObjects===!0&&b.sort(Le,He),qe=he.enabled===!1||he.isPresenting===!1||he.hasDepthSensing()===!1,qe&&se.addToRenderList(b,y),this.info.render.frame++,Z===!0&&pe.beginShadows();const k=_.state.shadowsArray;J.render(k,y,B),Z===!0&&pe.endShadows(),this.info.autoReset===!0&&this.info.reset();const F=b.opaque,U=b.transmissive;if(_.setupLights(),B.isArrayCamera){const ee=B.cameras;if(U.length>0)for(let me=0,ge=ee.length;me 0&&Gh(F,U,y,B),qe&&se.render(y),Vh(b,y,B);M!==null&&S===0&&(Ie.updateMultisampleRenderTarget(M),Ie.updateRenderTargetMipmap(M)),y.isScene===!0&&y.onAfterRender(T,y,B),P.resetDefaultState(),L=-1,N=null,R.pop(),R.length>0?(_=R[R.length-1],Z===!0&&pe.setGlobalState(T.clippingPlanes,_.state.camera)):_=null,E.pop(),E.length>0?b=E[E.length-1]:b=null};function nl(y,B,k,F){if(y.visible===!1)return;if(y.layers.test(B.layers)){if(y.isGroup)k=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(B);else if(y.isLight)_.pushLight(y),y.castShadow&&_.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||W.intersectsSprite(y)){F&&we.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Ae);const ee=Y.update(y),me=y.material;me.visible&&b.push(y,ee,me,k,we.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||W.intersectsObject(y))){const ee=Y.update(y),me=y.material;if(F&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),we.copy(y.boundingSphere.center)):(ee.boundingSphere===null&&ee.computeBoundingSphere(),we.copy(ee.boundingSphere.center)),we.applyMatrix4(y.matrixWorld).applyMatrix4(Ae)),Array.isArray(me)){const ge=ee.groups;for(let ve=0,Ue=ge.length;ve 0&&kr(U,B,k),ee.length>0&&kr(ee,B,k),me.length>0&&kr(me,B,k),fe.buffers.depth.setTest(!0),fe.buffers.depth.setMask(!0),fe.buffers.color.setMask(!0),fe.setPolygonOffset(!1)}function Gh(y,B,k,F){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;_.state.transmissionRenderTarget[F.id]===void 0&&(_.state.transmissionRenderTarget[F.id]=new Mt(1,1,{generateMipmaps:!0,type:je.has("EXT_color_buffer_half_float")||je.has("EXT_color_buffer_float")?ft:oi,minFilter:Ei,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xe.workingColorSpace}));const U=_.state.transmissionRenderTarget[F.id],ee=F.viewport||z;U.setSize(ee.z*T.transmissionResolutionScale,ee.w*T.transmissionResolutionScale);const me=T.getRenderTarget(),ge=T.getActiveCubeFace(),ve=T.getActiveMipmapLevel();T.setRenderTarget(U),T.getClearColor(q),te=T.getClearAlpha(),te<1&&T.setClearColor(16777215,.5),T.clear(),qe&&se.render(k);const Ue=T.toneMapping;T.toneMapping=qi;const Be=F.viewport;if(F.viewport!==void 0&&(F.viewport=void 0),_.setupLightsView(F),Z===!0&&pe.setGlobalState(T.clippingPlanes,F),kr(y,k,F),Ie.updateMultisampleRenderTarget(U),Ie.updateRenderTargetMipmap(U),je.has("WEBGL_multisampled_render_to_texture")===!1){let Ne=!1;for(let Ke=0,ht=B.length;Ke 0),Ne=!!k.morphAttributes.position,Ke=!!k.morphAttributes.normal,ht=!!k.morphAttributes.color;let _t=qi;F.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(_t=T.toneMapping);const pt=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,ut=pt!==void 0?pt.length:0,ye=Se.get(F),Nt=_.state.lights;if(Z===!0&&(de===!0||y!==N)){const Bt=y===N&&F.id===L;pe.setState(F,y,Bt)}let Xi=!1;F.version===ye.__version?(ye.needsLights&&ye.lightsStateVersion!==Nt.state.version||ye.outputColorSpace!==ge||U.isBatchedMesh&&ye.batching===!1||!U.isBatchedMesh&&ye.batching===!0||U.isBatchedMesh&&ye.batchingColor===!0&&U.colorTexture===null||U.isBatchedMesh&&ye.batchingColor===!1&&U.colorTexture!==null||U.isInstancedMesh&&ye.instancing===!1||!U.isInstancedMesh&&ye.instancing===!0||U.isSkinnedMesh&&ye.skinning===!1||!U.isSkinnedMesh&&ye.skinning===!0||U.isInstancedMesh&&ye.instancingColor===!0&&U.instanceColor===null||U.isInstancedMesh&&ye.instancingColor===!1&&U.instanceColor!==null||U.isInstancedMesh&&ye.instancingMorph===!0&&U.morphTexture===null||U.isInstancedMesh&&ye.instancingMorph===!1&&U.morphTexture!==null||ye.envMap!==ve||F.fog===!0&&ye.fog!==ee||ye.numClippingPlanes!==void 0&&(ye.numClippingPlanes!==pe.numPlanes||ye.numIntersection!==pe.numIntersection)||ye.vertexAlphas!==Ue||ye.vertexTangents!==Be||ye.morphTargets!==Ne||ye.morphNormals!==Ke||ye.morphColors!==ht||ye.toneMapping!==_t||ye.morphTargetsCount!==ut)&&(Xi=!0):(Xi=!0,ye.__version=F.version);let yi=ye.currentProgram;Xi===!0&&(yi=Fr(F,B,U));let cn=!1,Qt=!1,Fn=!1;const mt=yi.getUniforms(),Yt=ye.uniforms;if(fe.useProgram(yi.program)&&(cn=!0,Qt=!0,Fn=!0),F.id!==L&&(L=F.id,Qt=!0),cn||N!==y){fe.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),mt.setValue(D,"projectionMatrix",y.projectionMatrix),mt.setValue(D,"viewMatrix",y.matrixWorldInverse);const Bt=mt.map.cameraPosition;Bt!==void 0&&Bt.setValue(D,Te.setFromMatrixPosition(y.matrixWorld)),tt.logarithmicDepthBuffer&&mt.setValue(D,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(F.isMeshPhongMaterial||F.isMeshToonMaterial||F.isMeshLambertMaterial||F.isMeshBasicMaterial||F.isMeshStandardMaterial||F.isShaderMaterial)&&mt.setValue(D,"isOrthographic",y.isOrthographicCamera===!0),N!==y&&(N=y,Qt=!0,Fn=!0)}if(U.isSkinnedMesh){mt.setOptional(D,U,"bindMatrix"),mt.setOptional(D,U,"bindMatrixInverse");const Bt=U.skeleton;Bt&&(Bt.boneTexture===null&&Bt.computeBoneTexture(),mt.setValue(D,"boneTexture",Bt.boneTexture,Ie))}U.isBatchedMesh&&(mt.setOptional(D,U,"batchingTexture"),mt.setValue(D,"batchingTexture",U._matricesTexture,Ie),mt.setOptional(D,U,"batchingIdTexture"),mt.setValue(D,"batchingIdTexture",U._indirectTexture,Ie),mt.setOptional(D,U,"batchingColorTexture"),U._colorsTexture!==null&&mt.setValue(D,"batchingColorTexture",U._colorsTexture,Ie));const ri=k.morphAttributes;if((ri.position!==void 0||ri.normal!==void 0||ri.color!==void 0)&&Oe.update(U,k,yi),(Qt||ye.receiveShadow!==U.receiveShadow)&&(ye.receiveShadow=U.receiveShadow,mt.setValue(D,"receiveShadow",U.receiveShadow)),F.isMeshGouraudMaterial&&F.envMap!==null&&(Yt.envMap.value=ve,Yt.flipEnvMap.value=ve.isCubeTexture&&ve.isRenderTargetTexture===!1?-1:1),F.isMeshStandardMaterial&&F.envMap===null&&B.environment!==null&&(Yt.envMapIntensity.value=B.environmentIntensity),Yt.dfgLUT!==void 0&&(Yt.dfgLUT.value=i1()),Qt&&(mt.setValue(D,"toneMappingExposure",T.toneMappingExposure),ye.needsLights&&O_(Yt,Fn),ee&&F.fog===!0&&be.refreshFogUniforms(Yt,ee),be.refreshMaterialUniforms(Yt,F,ne,K,_.state.transmissionRenderTarget[y.id]),Rr.upload(D,jh(ye),Yt,Ie)),F.isShaderMaterial&&F.uniformsNeedUpdate===!0&&(Rr.upload(D,jh(ye),Yt,Ie),F.uniformsNeedUpdate=!1),F.isSpriteMaterial&&mt.setValue(D,"center",U.center),mt.setValue(D,"modelViewMatrix",U.modelViewMatrix),mt.setValue(D,"normalMatrix",U.normalMatrix),mt.setValue(D,"modelMatrix",U.matrixWorld),F.isShaderMaterial||F.isRawShaderMaterial){const Bt=F.uniformsGroups;for(let Mi=0,rl=Bt.length;Mi 0&&Ie.useMultisampledRTT(y)===!1?U=Se.get(y).__webglMultisampledFramebuffer:Array.isArray(Ue)?U=Ue[k]:U=Ue,z.copy(y.viewport),H.copy(y.scissor),j=y.scissorTest}else z.copy(Ye).multiplyScalar(ne).floor(),H.copy(Je).multiplyScalar(ne).floor(),j=Qe;if(k!==0&&(U=F_),fe.bindFramebuffer(D.FRAMEBUFFER,U)&&F&&fe.drawBuffers(y,U),fe.viewport(z),fe.scissor(H),fe.setScissorTest(j),ee){const ge=Se.get(y.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+B,ge.__webglTexture,k)}else if(me){const ge=B;for(let ve=0;ve =0&&B<=y.width-F&&k>=0&&k<=y.height-U&&(y.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+ge),D.readPixels(B,k,F,U,Re.convert(Be),Re.convert(Ne),ee))}finally{const Ue=M!==null?Se.get(M).__webglFramebuffer:null;fe.bindFramebuffer(D.FRAMEBUFFER,Ue)}}},this.readRenderTargetPixelsAsync=async function(y,B,k,F,U,ee,me,ge=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ve=Se.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&me!==void 0&&(ve=ve[me]),ve)if(B>=0&&B<=y.width-F&&k>=0&&k<=y.height-U){fe.bindFramebuffer(D.FRAMEBUFFER,ve);const Ue=y.textures[ge],Be=Ue.format,Ne=Ue.type;if(!tt.textureFormatReadable(Be))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(Ne))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ke=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,Ke),D.bufferData(D.PIXEL_PACK_BUFFER,ee.byteLength,D.STREAM_READ),y.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+ge),D.readPixels(B,k,F,U,Re.convert(Be),Re.convert(Ne),0);const ht=M!==null?Se.get(M).__webglFramebuffer:null;fe.bindFramebuffer(D.FRAMEBUFFER,ht);const _t=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await Uu(D,_t,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,Ke),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,ee),D.deleteBuffer(Ke),D.deleteSync(_t),ee}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,B=null,k=0){const F=Math.pow(2,-k),U=Math.floor(y.image.width*F),ee=Math.floor(y.image.height*F),me=B!==null?B.x:0,ge=B!==null?B.y:0;Ie.setTexture2D(y,0),D.copyTexSubImage2D(D.TEXTURE_2D,k,0,0,me,ge,U,ee),fe.unbindTexture()};const z_=D.createFramebuffer(),H_=D.createFramebuffer();this.copyTextureToTexture=function(y,B,k=null,F=null,U=0,ee=null){ee===null&&(U!==0?(_n("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ee=U,U=0):ee=0);let me,ge,ve,Ue,Be,Ne,Ke,ht,_t;const pt=y.isCompressedTexture?y.mipmaps[ee]:y.image;if(k!==null)me=k.max.x-k.min.x,ge=k.max.y-k.min.y,ve=k.isBox3?k.max.z-k.min.z:1,Ue=k.min.x,Be=k.min.y,Ne=k.isBox3?k.min.z:0;else{const ri=Math.pow(2,-U);me=Math.floor(pt.width*ri),ge=Math.floor(pt.height*ri),y.isDataArrayTexture?ve=pt.depth:y.isData3DTexture?ve=Math.floor(pt.depth*ri):ve=1,Ue=0,Be=0,Ne=0}F!==null?(Ke=F.x,ht=F.y,_t=F.z):(Ke=0,ht=0,_t=0);const ut=Re.convert(B.format),ye=Re.convert(B.type);let Nt;B.isData3DTexture?(Ie.setTexture3D(B,0),Nt=D.TEXTURE_3D):B.isDataArrayTexture||B.isCompressedArrayTexture?(Ie.setTexture2DArray(B,0),Nt=D.TEXTURE_2D_ARRAY):(Ie.setTexture2D(B,0),Nt=D.TEXTURE_2D),D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,B.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,B.unpackAlignment);const Xi=D.getParameter(D.UNPACK_ROW_LENGTH),yi=D.getParameter(D.UNPACK_IMAGE_HEIGHT),cn=D.getParameter(D.UNPACK_SKIP_PIXELS),Qt=D.getParameter(D.UNPACK_SKIP_ROWS),Fn=D.getParameter(D.UNPACK_SKIP_IMAGES);D.pixelStorei(D.UNPACK_ROW_LENGTH,pt.width),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,pt.height),D.pixelStorei(D.UNPACK_SKIP_PIXELS,Ue),D.pixelStorei(D.UNPACK_SKIP_ROWS,Be),D.pixelStorei(D.UNPACK_SKIP_IMAGES,Ne);const mt=y.isDataArrayTexture||y.isData3DTexture,Yt=B.isDataArrayTexture||B.isData3DTexture;if(y.isDepthTexture){const ri=Se.get(y),Bt=Se.get(B),Mi=Se.get(ri.__renderTarget),rl=Se.get(Bt.__renderTarget);fe.bindFramebuffer(D.READ_FRAMEBUFFER,Mi.__webglFramebuffer),fe.bindFramebuffer(D.DRAW_FRAMEBUFFER,rl.__webglFramebuffer);for(let bs=0;bs (E=A.indexOf(` `))&&R =f.byteLength||!(A=i(f)))&&t(1,"no header found"),(I=A.match(p))||t(3,"bad initial token"),T.valid|=1,T.programtype=I[1],T.string+=A+` `;A=i(f),A!==!1;){if(T.string+=A+` `,A.charAt(0)==="#"){T.comments+=A+` -`;continue}if((I=A.match(b))&&(T.gamma=parseFloat(I[1])),(I=A.match(_))&&(T.exposure=parseFloat(I[1])),(I=A.match(E))&&(T.valid|=2,T.format=I[1]),(I=A.match(R))&&(T.valid|=4,T.height=parseInt(I[1],10),T.width=parseInt(I[2],10)),T.valid&2&&T.valid&4)break}return T.valid&2||t(3,"missing format specifier"),T.valid&4||t(3,"missing image size specifier"),T},r=function(f,p,b){const _=p;if(_<8||_>32767||f[0]!==2||f[1]!==2||f[2]&128)return new Uint8Array(f);_!==(f[2]<<8|f[3])&&t(3,"wrong scanline width");const E=new Uint8Array(4*p*b);E.length||t(4,"unable to allocate buffer space");let R=0,T=0;const A=4*_,I=new Uint8Array(4),S=new Uint8Array(A);let M=b;for(;M>0&&T
f.byteLength&&t(1),I[0]=f[T++],I[1]=f[T++],I[2]=f[T++],I[3]=f[T++],(I[0]!=2||I[1]!=2||(I[2]<<8|I[3])!=_)&&t(3,"bad rgbe scanline format");let L=0,N;for(;L128;if(H&&(N-=128),(N===0||L+N>A)&&t(3,"bad scanline data"),H){const j=f[T++];for(let q=0;q 32767||f[0]!==2||f[1]!==2||f[2]&128)return new Uint8Array(f);_!==(f[2]<<8|f[3])&&t(3,"wrong scanline width");const E=new Uint8Array(4*p*b);E.length||t(4,"unable to allocate buffer space");let R=0,T=0;const A=4*_,I=new Uint8Array(4),S=new Uint8Array(A);let M=b;for(;M>0&&T f.byteLength&&t(1),I[0]=f[T++],I[1]=f[T++],I[2]=f[T++],I[3]=f[T++],(I[0]!=2||I[1]!=2||(I[2]<<8|I[3])!=_)&&t(3,"bad rgbe scanline format");let L=0,N;for(;L128;if(H&&(N-=128),(N===0||L+N>A)&&t(3,"bad scanline data"),H){const j=f[T++];for(let q=0;q v?(f=1,p=0):(f=0,p=1);const b=g-f+h,_=v-p+h,E=g-1+2*h,R=v-1+2*h,T=l&255,A=c&255,I=this.perm[T+this.perm[A]]%12,S=this.perm[T+f+this.perm[A+p]]%12,M=this.perm[T+1+this.perm[A+1]]%12;let L=.5-g*g-v*v;L<0?i=0:(L*=L,i=L*L*this._dot(this.grad3[I],g,v));let N=.5-b*b-_*_;N<0?s=0:(N*=N,s=N*N*this._dot(this.grad3[S],b,_));let z=.5-E*E-R*R;return z<0?r=0:(z*=z,r=z*z*this._dot(this.grad3[M],E,R)),70*(i+s+r)}noise3d(e,t,i){let s,r,a,o;const l=(e+t+i)*.3333333333333333,c=Math.floor(e+l),h=Math.floor(t+l),u=Math.floor(i+l),d=1/6,m=(c+h+u)*d,g=c-m,v=h-m,f=u-m,p=e-g,b=t-v,_=i-f;let E,R,T,A,I,S;p>=b?b>=_?(E=1,R=0,T=0,A=1,I=1,S=0):p>=_?(E=1,R=0,T=0,A=1,I=0,S=1):(E=0,R=0,T=1,A=1,I=0,S=1):b<_?(E=0,R=0,T=1,A=0,I=1,S=1):p<_?(E=0,R=1,T=0,A=0,I=1,S=1):(E=0,R=1,T=0,A=1,I=1,S=0);const M=p-E+d,L=b-R+d,N=_-T+d,z=p-A+2*d,H=b-I+2*d,j=_-S+2*d,q=p-1+3*d,te=b-1+3*d,G=_-1+3*d,K=c&255,ne=h&255,Le=u&255,He=this.perm[K+this.perm[ne+this.perm[Le]]]%12,Ye=this.perm[K+E+this.perm[ne+R+this.perm[Le+T]]]%12,Je=this.perm[K+A+this.perm[ne+I+this.perm[Le+S]]]%12,Qe=this.perm[K+1+this.perm[ne+1+this.perm[Le+1]]]%12;let W=.6-p*p-b*b-_*_;W<0?s=0:(W*=W,s=W*W*this._dot3(this.grad3[He],p,b,_));let Z=.6-M*M-L*L-N*N;Z<0?r=0:(Z*=Z,r=Z*Z*this._dot3(this.grad3[Ye],M,L,N));let de=.6-z*z-H*H-j*j;de<0?a=0:(de*=de,a=de*de*this._dot3(this.grad3[Je],z,H,j));let Ae=.6-q*q-te*te-G*G;return Ae<0?o=0:(Ae*=Ae,o=Ae*Ae*this._dot3(this.grad3[Qe],q,te,G)),32*(s+r+a+o)}noise4d(e,t,i,s){const r=this.grad4,a=this.simplex,o=this.perm,l=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20;let h,u,d,m,g;const v=(e+t+i+s)*l,f=Math.floor(e+v),p=Math.floor(t+v),b=Math.floor(i+v),_=Math.floor(s+v),E=(f+p+b+_)*c,R=f-E,T=p-E,A=b-E,I=_-E,S=e-R,M=t-T,L=i-A,N=s-I,z=S>M?32:0,H=S>L?16:0,j=M>L?8:0,q=S>N?4:0,te=M>N?2:0,G=L>N?1:0,K=z+H+j+q+te+G,ne=a[K][0]>=3?1:0,Le=a[K][1]>=3?1:0,He=a[K][2]>=3?1:0,Ye=a[K][3]>=3?1:0,Je=a[K][0]>=2?1:0,Qe=a[K][1]>=2?1:0,W=a[K][2]>=2?1:0,Z=a[K][3]>=2?1:0,de=a[K][0]>=1?1:0,Ae=a[K][1]>=1?1:0,Te=a[K][2]>=1?1:0,we=a[K][3]>=1?1:0,et=S-ne+c,qe=M-Le+c,We=L-He+c,D=N-Ye+c,_t=S-Je+2*c,je=M-Qe+2*c,tt=L-W+2*c,fe=N-Z+2*c,lt=S-de+3*c,Se=M-Ae+3*c,Ie=L-Te+3*c,C=N-we+3*c,x=S-1+4*c,O=M-1+4*c,X=L-1+4*c,Y=N-1+4*c,V=f&255,be=p&255,re=b&255,Ee=_&255,pe=o[V+o[be+o[re+o[Ee]]]]%32,J=o[V+ne+o[be+Le+o[re+He+o[Ee+Ye]]]]%32,se=o[V+Je+o[be+Qe+o[re+W+o[Ee+Z]]]]%32,Oe=o[V+de+o[be+Ae+o[re+Te+o[Ee+we]]]]%32,Ce=o[V+1+o[be+1+o[re+1+o[Ee+1]]]]%32;let ue=.6-S*S-M*M-L*L-N*N;ue<0?h=0:(ue*=ue,h=ue*ue*this._dot4(r[pe],S,M,L,N));let Re=.6-et*et-qe*qe-We*We-D*D;Re<0?u=0:(Re*=Re,u=Re*Re*this._dot4(r[J],et,qe,We,D));let P=.6-_t*_t-je*je-tt*tt-fe*fe;P<0?d=0:(P*=P,d=P*P*this._dot4(r[se],_t,je,tt,fe));let ae=.6-lt*lt-Se*Se-Ie*Ie-C*C;ae<0?m=0:(ae*=ae,m=ae*ae*this._dot4(r[Oe],lt,Se,Ie,C));let ie=.6-x*x-O*O-X*X-Y*Y;return ie<0?g=0:(ie*=ie,g=ie*ie*this._dot4(r[Ce],x,O,X,Y)),27*(h+u+d+m+g)}_dot(e,t,i){return e[0]*t+e[1]*i}_dot3(e,t,i,s){return e[0]*t+e[1]*i+e[2]*s}_dot4(e,t,i,s,r){return e[0]*t+e[1]*i+e[2]*s+e[3]*r}}class xi extends ns{constructor(e,t,i=512,s=512,r,a,o){super(),this.width=i,this.height=s,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=[],this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=u1(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new yt(this.width,this.height,{type:ft}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new ct({defines:Object.assign({},Dr.defines),uniforms:vi.clone(Dr.uniforms),vertexShader:Dr.vertexShader,fragmentShader:Dr.fragmentShader,blending:xt,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new Bd,this.normalMaterial.blending=xt,this.pdMaterial=new ct({defines:Object.assign({},Ur.defines),uniforms:vi.clone(Ur.uniforms),vertexShader:Ur.vertexShader,fragmentShader:Ur.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new ct({defines:Object.assign({},Ir.defines),uniforms:vi.clone(Ir.uniforms),vertexShader:Ir.vertexShader,fragmentShader:Ir.fragmentShader,blending:xt}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new ct({uniforms:vi.clone(ss.uniforms),vertexShader:ss.vertexShader,fragmentShader:ss.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Wr,blendDst:un,blendEquation:ai,blendSrcAlpha:Gr,blendDstAlpha:un,blendEquationAlpha:ai}),this.blendMaterial=new ct({uniforms:vi.clone(Wo.uniforms),vertexShader:Wo.vertexShader,fragmentShader:Wo.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:pl,blendSrc:Wr,blendDst:un,blendEquation:ai,blendSrcAlpha:Gr,blendDstAlpha:un,blendEquationAlpha:ai}),this._fsQuad=new Nn(null),this._originalClearColor=new xe,this.setGBuffer(r?r.depthTexture:void 0,r?r.normalTexture:void 0),a!==void 0&&this.updateGtaoMaterial(a),o!==void 0&&this.updatePdMaterial(o)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){e!==void 0?(this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1):(this.depthTexture=new Co,this.depthTexture.format=Rs,this.depthTexture.type=As,this.normalRenderTarget=new yt(this.width,this.height,{minFilter:It,magFilter:It,type:ft,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const i=this.normalTexture?1:0,s=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=i,this.gtaoMaterial.defines.DEPTH_SWIZZLING=s,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=i,this.pdMaterial.defines.DEPTH_SWIZZLING=s,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&(e.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=e.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=vh(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(e,t,i){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(e,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(e,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case xi.OUTPUT.Off:break;case xi.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=i.texture,this.copyMaterial.blending=xt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case xi.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=xt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case xi.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=xt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case xi.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case xi.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=xt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case xi.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=i.texture,this.copyMaterial.blending=xt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(e,this.blendMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}_renderPass(e,t,i,s,r){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,s!=null&&(e.setClearColor(s),e.setClearAlpha(r||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_renderOverride(e,t,i,s,r){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,s=t.clearColor||s,r=t.clearAlpha||r,s!=null&&(e.setClearColor(s),e.setClearAlpha(r||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_overrideVisibility(){const e=this.scene,t=this._visibilityCache;e.traverse(function(i){(i.isPoints||i.isLine||i.isLine2)&&i.visible&&(i.visible=!1,t.push(i))})}_restoreVisibility(){const e=this._visibilityCache;for(let t=0;t v?(f=1,p=0):(f=0,p=1);const b=g-f+h,_=v-p+h,E=g-1+2*h,R=v-1+2*h,T=l&255,A=c&255,I=this.perm[T+this.perm[A]]%12,S=this.perm[T+f+this.perm[A+p]]%12,M=this.perm[T+1+this.perm[A+1]]%12;let L=.5-g*g-v*v;L<0?i=0:(L*=L,i=L*L*this._dot(this.grad3[I],g,v));let N=.5-b*b-_*_;N<0?s=0:(N*=N,s=N*N*this._dot(this.grad3[S],b,_));let z=.5-E*E-R*R;return z<0?r=0:(z*=z,r=z*z*this._dot(this.grad3[M],E,R)),70*(i+s+r)}noise3d(e,t,i){let s,r,a,o;const l=(e+t+i)*.3333333333333333,c=Math.floor(e+l),h=Math.floor(t+l),u=Math.floor(i+l),d=1/6,m=(c+h+u)*d,g=c-m,v=h-m,f=u-m,p=e-g,b=t-v,_=i-f;let E,R,T,A,I,S;p>=b?b>=_?(E=1,R=0,T=0,A=1,I=1,S=0):p>=_?(E=1,R=0,T=0,A=1,I=0,S=1):(E=0,R=0,T=1,A=1,I=0,S=1):b<_?(E=0,R=0,T=1,A=0,I=1,S=1):p<_?(E=0,R=1,T=0,A=0,I=1,S=1):(E=0,R=1,T=0,A=1,I=1,S=0);const M=p-E+d,L=b-R+d,N=_-T+d,z=p-A+2*d,H=b-I+2*d,j=_-S+2*d,q=p-1+3*d,te=b-1+3*d,G=_-1+3*d,K=c&255,ne=h&255,Le=u&255,He=this.perm[K+this.perm[ne+this.perm[Le]]]%12,Ye=this.perm[K+E+this.perm[ne+R+this.perm[Le+T]]]%12,Je=this.perm[K+A+this.perm[ne+I+this.perm[Le+S]]]%12,Qe=this.perm[K+1+this.perm[ne+1+this.perm[Le+1]]]%12;let W=.6-p*p-b*b-_*_;W<0?s=0:(W*=W,s=W*W*this._dot3(this.grad3[He],p,b,_));let Z=.6-M*M-L*L-N*N;Z<0?r=0:(Z*=Z,r=Z*Z*this._dot3(this.grad3[Ye],M,L,N));let de=.6-z*z-H*H-j*j;de<0?a=0:(de*=de,a=de*de*this._dot3(this.grad3[Je],z,H,j));let Ae=.6-q*q-te*te-G*G;return Ae<0?o=0:(Ae*=Ae,o=Ae*Ae*this._dot3(this.grad3[Qe],q,te,G)),32*(s+r+a+o)}noise4d(e,t,i,s){const r=this.grad4,a=this.simplex,o=this.perm,l=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20;let h,u,d,m,g;const v=(e+t+i+s)*l,f=Math.floor(e+v),p=Math.floor(t+v),b=Math.floor(i+v),_=Math.floor(s+v),E=(f+p+b+_)*c,R=f-E,T=p-E,A=b-E,I=_-E,S=e-R,M=t-T,L=i-A,N=s-I,z=S>M?32:0,H=S>L?16:0,j=M>L?8:0,q=S>N?4:0,te=M>N?2:0,G=L>N?1:0,K=z+H+j+q+te+G,ne=a[K][0]>=3?1:0,Le=a[K][1]>=3?1:0,He=a[K][2]>=3?1:0,Ye=a[K][3]>=3?1:0,Je=a[K][0]>=2?1:0,Qe=a[K][1]>=2?1:0,W=a[K][2]>=2?1:0,Z=a[K][3]>=2?1:0,de=a[K][0]>=1?1:0,Ae=a[K][1]>=1?1:0,Te=a[K][2]>=1?1:0,we=a[K][3]>=1?1:0,et=S-ne+c,qe=M-Le+c,We=L-He+c,D=N-Ye+c,xt=S-Je+2*c,je=M-Qe+2*c,tt=L-W+2*c,fe=N-Z+2*c,lt=S-de+3*c,Se=M-Ae+3*c,Ie=L-Te+3*c,C=N-we+3*c,x=S-1+4*c,O=M-1+4*c,X=L-1+4*c,Y=N-1+4*c,V=f&255,be=p&255,re=b&255,Ee=_&255,pe=o[V+o[be+o[re+o[Ee]]]]%32,J=o[V+ne+o[be+Le+o[re+He+o[Ee+Ye]]]]%32,se=o[V+Je+o[be+Qe+o[re+W+o[Ee+Z]]]]%32,Oe=o[V+de+o[be+Ae+o[re+Te+o[Ee+we]]]]%32,Ce=o[V+1+o[be+1+o[re+1+o[Ee+1]]]]%32;let ue=.6-S*S-M*M-L*L-N*N;ue<0?h=0:(ue*=ue,h=ue*ue*this._dot4(r[pe],S,M,L,N));let Re=.6-et*et-qe*qe-We*We-D*D;Re<0?u=0:(Re*=Re,u=Re*Re*this._dot4(r[J],et,qe,We,D));let P=.6-xt*xt-je*je-tt*tt-fe*fe;P<0?d=0:(P*=P,d=P*P*this._dot4(r[se],xt,je,tt,fe));let ae=.6-lt*lt-Se*Se-Ie*Ie-C*C;ae<0?m=0:(ae*=ae,m=ae*ae*this._dot4(r[Oe],lt,Se,Ie,C));let ie=.6-x*x-O*O-X*X-Y*Y;return ie<0?g=0:(ie*=ie,g=ie*ie*this._dot4(r[Ce],x,O,X,Y)),27*(h+u+d+m+g)}_dot(e,t,i){return e[0]*t+e[1]*i}_dot3(e,t,i,s){return e[0]*t+e[1]*i+e[2]*s}_dot4(e,t,i,s,r){return e[0]*t+e[1]*i+e[2]*s+e[3]*r}}class xi extends ns{constructor(e,t,i=512,s=512,r,a,o){super(),this.width=i,this.height=s,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=[],this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=u1(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new Mt(this.width,this.height,{type:ft}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new ct({defines:Object.assign({},Dr.defines),uniforms:vi.clone(Dr.uniforms),vertexShader:Dr.vertexShader,fragmentShader:Dr.fragmentShader,blending:bt,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new Bd,this.normalMaterial.blending=bt,this.pdMaterial=new ct({defines:Object.assign({},Ur.defines),uniforms:vi.clone(Ur.uniforms),vertexShader:Ur.vertexShader,fragmentShader:Ur.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new ct({defines:Object.assign({},Ir.defines),uniforms:vi.clone(Ir.uniforms),vertexShader:Ir.vertexShader,fragmentShader:Ir.fragmentShader,blending:bt}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new ct({uniforms:vi.clone(ss.uniforms),vertexShader:ss.vertexShader,fragmentShader:ss.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Wr,blendDst:un,blendEquation:ai,blendSrcAlpha:Gr,blendDstAlpha:un,blendEquationAlpha:ai}),this.blendMaterial=new ct({uniforms:vi.clone(Wo.uniforms),vertexShader:Wo.vertexShader,fragmentShader:Wo.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:pl,blendSrc:Wr,blendDst:un,blendEquation:ai,blendSrcAlpha:Gr,blendDstAlpha:un,blendEquationAlpha:ai}),this._fsQuad=new Nn(null),this._originalClearColor=new xe,this.setGBuffer(r?r.depthTexture:void 0,r?r.normalTexture:void 0),a!==void 0&&this.updateGtaoMaterial(a),o!==void 0&&this.updatePdMaterial(o)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){e!==void 0?(this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1):(this.depthTexture=new Co,this.depthTexture.format=Rs,this.depthTexture.type=As,this.normalRenderTarget=new Mt(this.width,this.height,{minFilter:Ut,magFilter:Ut,type:ft,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const i=this.normalTexture?1:0,s=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=i,this.gtaoMaterial.defines.DEPTH_SWIZZLING=s,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=i,this.pdMaterial.defines.DEPTH_SWIZZLING=s,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&(e.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=e.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=vh(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(e,t,i){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(e,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(e,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case xi.OUTPUT.Off:break;case xi.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=i.texture,this.copyMaterial.blending=bt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case xi.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=bt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case xi.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=bt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case xi.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case xi.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=bt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case xi.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=i.texture,this.copyMaterial.blending=bt,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(e,this.blendMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}_renderPass(e,t,i,s,r){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,s!=null&&(e.setClearColor(s),e.setClearAlpha(r||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_renderOverride(e,t,i,s,r){e.getClearColor(this._originalClearColor);const a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,s=t.clearColor||s,r=t.clearAlpha||r,s!=null&&(e.setClearColor(s),e.setClearAlpha(r||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_overrideVisibility(){const e=this.scene,t=this._visibilityCache;e.traverse(function(i){(i.isPoints||i.isLine||i.isLine2)&&i.visible&&(i.visible=!1,t.push(i))})}_restoreVisibility(){const e=this._visibilityCache;for(let t=0;t l+1e3&&(h.update(1e3*c/(m-l),100),l=m,c=0,d)){var g=performance.memory;d.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return m},update:function(){o=this.end()},domElement:a,setMode:s}};return t.Panel=function(i,s,r){var a=1/0,o=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,u=48*c,d=3*c,m=2*c,g=3*c,v=15*c,f=74*c,p=30*c,b=document.createElement("canvas");b.width=h,b.height=u,b.style.cssText="width:80px;height:48px";var _=b.getContext("2d");return _.font="bold "+9*c+"px Helvetica,Arial,sans-serif",_.textBaseline="top",_.fillStyle=r,_.fillRect(0,0,h,u),_.fillStyle=s,_.fillText(i,d,m),_.fillRect(g,v,f,p),_.fillStyle=r,_.globalAlpha=.9,_.fillRect(g,v,f,p),{dom:b,update:function(E,R){a=Math.min(a,E),o=Math.max(o,E),_.fillStyle=r,_.globalAlpha=1,_.fillRect(0,0,h,v),_.fillStyle=s,_.fillText(l(E)+" "+i+" ("+l(a)+"-"+l(o)+")",d,m),_.drawImage(b,g+c,v,f-c,p,g,v,f-c,p),_.fillRect(g+f-c,v,c,p),_.fillStyle=r,_.globalAlpha=.9,_.fillRect(g+f-c,v,c,l((1-E/R)*p))}}},t})})(jo)),jo.exports}var y1=b1();const M1=_1(y1);class S1{scene;constructor(e){this.scene=new go,this.setupEnvironment(e.backgroundColor),this.setupLights()}setupEnvironment(e=15790320){this.scene.background=new xe(e)}setupLights(){}setBackground(e){this.scene.background=new xe(e)}getBoundingBox(){const e=new Rt;return this.scene.traverse(t=>{if(t instanceof rt||t instanceof Vi){const i=new Rt().setFromObject(t);e.union(i)}}),e.isEmpty()&&e.setFromCenterAndSize(new w(0,0,0),new w(10,10,10)),e}}const xh={type:"change"},Xo={type:"start"},bh={type:"end"},Br=new Os,yh=new Ai,T1=Math.cos(70*Wa.DEG2RAD),wt=new w,Zt=2*Math.PI,at={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},qo=1e-6;class Mh extends fp{constructor(e,t=null){super(e,t),this.state=at.NONE,this.target=new w,this.cursor=new w,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Ms.ROTATE,MIDDLE:Ms.DOLLY,RIGHT:Ms.PAN},this.touches={ONE:Ss.ROTATE,TWO:Ss.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new w,this._lastQuaternion=new hi,this._lastTargetPosition=new w,this._quat=new hi().setFromUnitVectors(e.up,new w(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new zc,this._sphericalDelta=new zc,this._scale=1,this._panOffset=new w,this._rotateStart=new oe,this._rotateEnd=new oe,this._rotateDelta=new oe,this._panStart=new oe,this._panEnd=new oe,this._panDelta=new oe,this._dollyStart=new oe,this._dollyEnd=new oe,this._dollyDelta=new oe,this._dollyDirection=new w,this._mouse=new oe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=w1.bind(this),this._onPointerDown=E1.bind(this),this._onPointerUp=C1.bind(this),this._onContextMenu=U1.bind(this),this._onMouseWheel=P1.bind(this),this._onKeyDown=L1.bind(this),this._onTouchStart=D1.bind(this),this._onTouchMove=I1.bind(this),this._onMouseDown=A1.bind(this),this._onMouseMove=R1.bind(this),this._interceptControlDown=N1.bind(this),this._interceptControlUp=B1.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(xh),this.update(),this.state=at.NONE}update(e=null){const t=this.object.position;wt.copy(t).sub(this.target),wt.applyQuaternion(this._quat),this._spherical.setFromVector3(wt),this.autoRotate&&this.state===at.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=Zt:i>Math.PI&&(i-=Zt),s<-Math.PI?s+=Zt:s>Math.PI&&(s-=Zt),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(wt.setFromSpherical(this._spherical),wt.applyQuaternion(this._quatInverse),t.copy(this.target).add(wt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=wt.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new w(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new w(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=wt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Br.origin.copy(this.object.position),Br.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Br.direction)) qo||8*(1-this._lastQuaternion.dot(this.object.quaternion))>qo||this._lastTargetPosition.distanceToSquared(this.target)>qo?(this.dispatchEvent(xh),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Zt/60*this.autoRotateSpeed*e:Zt/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){wt.setFromMatrixColumn(t,0),wt.multiplyScalar(-e),this._panOffset.add(wt)}_panUp(e,t){this.screenSpacePanning===!0?wt.setFromMatrixColumn(t,1):(wt.setFromMatrixColumn(t,0),wt.crossVectors(this.object.up,wt)),wt.multiplyScalar(e),this._panOffset.add(wt)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;wt.copy(s).sub(this.target);let r=wt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Zt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Zt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Zt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Zt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t (n.Top="top",n.Bottom="bottom",n.Left="left",n.Right="right",n.Front="front",n.Back="back",n.Iso="iso",n))(rn||{}),an=(n=>(n.Perspective="perspective",n.Orthographic="orthographic",n))(an||{}),Or=(n=>(n.Orbit="orbit",n.FirstPerson="walk",n.PanOnly="pan_only",n))(Or||{});class O1{camera;controls;engineState;constructor(e,t,i,s){this.engineState=s,this.camera=new St(45,t/i,.1,1e4),this.camera.position.set(20,20,20),this.controls=new Mh(this.camera,e,this.engineState),this.controls.enableDamping=!0,this.controls.dampingFactor=.05}updateAspect(e,t){this.camera.aspect=e/t,this.camera.updateProjectionMatrix()}tick(){this.controls.update()}setView(e){const t=this.camera.position.length();switch(e){case rn.Top:case"top":this.camera.position.set(0,t,0);break;case rn.Front:case"front":this.camera.position.set(0,0,t);break;case rn.Iso:case"iso":this.camera.position.set(t/Math.sqrt(3),t/Math.sqrt(3),t/Math.sqrt(3));break}this.camera.lookAt(0,0,0),this.controls.update()}}function Sh(n,e){if(e===Mu)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===ka||e===Dl){let t=n.getIndex();if(t===null){const a=[],o=n.getAttribute("position");if(o!==void 0){for(let l=0;l =2.0 are supported."));return}const c=new gv(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h =0&&o[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(i,s)}parseAsync(e,t){const i=this;return new Promise(function(s,r){i.parse(e,t,s,r)})}}function k1(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const Ge={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class F1{constructor(e){this.parser=e,this.name=Ge.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,s=t.length;i =0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class Q1{constructor(e){this.parser=e,this.name=Ge.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=s.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return i.loadTextureImage(e,a.source,l)}}class ev{constructor(e){this.parser=e,this.name=Ge.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=s.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return i.loadTextureImage(e,a.source,l)}}class tv{constructor(e){this.name=Ge.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const s=i.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(o){const l=s.byteOffset||0,c=s.byteLength||0,h=s.count,u=s.byteStride,d=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,u,d,s.mode,s.filter).then(function(m){return m.buffer}):a.ready.then(function(){const m=new ArrayBuffer(h*u);return a.decodeGltfBuffer(new Uint8Array(m),h,u,d,s.mode,s.filter),m})})}else return null}}class iv{constructor(e){this.name=Ge.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const s=t.meshes[i.mesh];for(const l of s.primitives)if(l.mode!==ni.TRIANGLES&&l.mode!==ni.TRIANGLE_STRIP&&l.mode!==ni.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=i.extensions[this.name].attributes,a=[],o={};for(const l in r)a.push(this.parser.getDependency("accessor",r[l]).then(c=>(o[l]=c,o[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const c=l.pop(),h=c.isGroup?c.children:[c],u=l[0].count,d=[];for(const m of h){const g=new De,v=new w,f=new hi,p=new w(1,1,1),b=new Ad(m.geometry,m.material,u);for(let _=0;_0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":n.search(/\.ktx2($|\?)/i)>0||n.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const fv=new De;class gv{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new k1,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,s=-1,r=!1,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);s=i&&l?parseInt(l[1],10):-1,r=o.indexOf("Firefox")>-1,a=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&s<17||r&&a<98?this.textureLoader=new Lc(this.options.manager):this.textureLoader=new sp(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ro(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(a){const o={scene:a[0][s.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:s.asset,parser:i,userData:{}};return _s(r,o,s),Li(o,s),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let s=0,r=t.length;s{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,h]of a.children.entries())r(h,o.children[c])};return r(i,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i =2&&f.setY(S,T[A*l+1]),l>=3&&f.setZ(S,T[A*l+2]),l>=4&&f.setW(S,T[A*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}f.normalized=g}return f})}loadTexture(e){const t=this.json,i=this.options,s=t.textures[e].source,r=t.images[s];let a=this.textureLoader;if(r.uri){const o=i.manager.getHandler(r.uri);o!==null&&(a=o)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,i){const s=this,r=this.json,a=r.textures[e],o=r.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const u=(r.samplers||{})[a.sampler]||{};return h.magFilter=Ah[u.magFilter]||bt,h.minFilter=Ah[u.minFilter]||Ei,h.wrapS=Rh[u.wrapS]||Ti,h.wrapT=Rh[u.wrapT]||Ti,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==It&&h.minFilter!==bt,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const a=s.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=i.getDependency("bufferView",a.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:a.mimeType});return l=o.createObjectURL(d),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(u){return new Promise(function(d,m){let g=d;t.isImageBitmapLoader===!0&&(g=function(v){const f=new At(v);f.needsUpdate=!0,d(f)}),t.load(Dn.resolveURL(u,r.path),g,void 0,m)})}).then(function(u){return c===!0&&o.revokeObjectURL(l),Li(u,a),u.userData.mimeType=a.mimeType||mv(a.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=h,h}assignTexture(e,t,i,s){const r=this;return this.getDependency("texture",i.index).then(function(a){if(!a)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(a=a.clone(),a.channel=i.texCoord),r.extensions[Ge.KHR_TEXTURE_TRANSFORM]){const o=i.extensions!==void 0?i.extensions[Ge.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=r.associations.get(a);a=r.extensions[Ge.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.associations.set(a,l)}}return s!==void 0&&(a.colorSpace=s),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new yc,ti.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(o,l)),i=l}else if(e.isLine){const o="LineBasicMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new gc,ti.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(o,l)),i=l}if(s||r||a){let o="ClonedMaterial:"+i.uuid+":";s&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=i.clone(),r&&(l.vertexColors=!0),a&&(l.flatShading=!0),s&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return Ao}loadMaterial(e){const t=this,i=this.json,s=this.extensions,r=i.materials[e];let a;const o={},l=r.extensions||{},c=[];if(l[Ge.KHR_MATERIALS_UNLIT]){const u=s[Ge.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{const u=r.pbrMetallicRoughness||{};if(o.color=new xe(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],Bt),o.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",u.baseColorTexture,Ct)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=Xt);const h=r.alphaMode||Ko.OPAQUE;if(h===Ko.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===Ko.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&a!==Ht&&(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new oe(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;o.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&a!==Ht&&(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&a!==Ht){const u=r.emissiveFactor;o.emissive=new xe().setRGB(u[0],u[1],u[2],Bt)}return r.emissiveTexture!==void 0&&a!==Ht&&c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Ct)),Promise.all(c).then(function(){const u=new a(o);return r.name&&(u.name=r.name),Li(u,r),t.associations.set(u,{materials:e}),r.extensions&&_s(s,u,r),u})}createUniqueName(e){const t=nt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,s=this.primitiveCache;function r(o){return i[Ge.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return Ph(l,o,t)})}const a=[];for(let o=0,l=e.length;o 0&&dv(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),Li(p,r),f.extensions&&_s(s,p,f),t.assignFinalMaterial(p),u.push(p)}for(let m=0,g=u.length;m 1?h=new Vi:c.length===1?h=c[0]:h=new dt,h!==c[0])for(let u=0,d=c.length;u 1){const u=s.associations.get(h);s.associations.set(h,{...u})}return s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],s=this,r=new Vi;i.name&&(r.name=s.createUniqueName(i.name)),Li(r,i),i.extensions&&_s(t,r,i);const a=i.nodes||[],o=[];for(let l=0,c=a.length;l {const u=new Map;for(const[d,m]of s.associations)(d instanceof ti||d instanceof At)&&u.set(d,m);return h.traverse(d=>{const m=s.associations.get(d);m!=null&&u.set(d,m)}),u};return s.associations=c(r),r})}_createAnimationTracks(e,t,i,s,r){const a=[],o=e.name?e.name:e.uuid,l=[];rs[r.path]===rs.weights?e.traverse(function(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}):l.push(o);let c;switch(rs[r.path]){case rs.weights:c=Ks;break;case rs.rotation:c=$s;break;case rs.translation:case rs.scale:c=Qs;break;default:switch(i.itemSize){case 1:c=Ks;break;case 2:case 3:default:c=Qs;break}break}const h=s.interpolation!==void 0?cv[s.interpolation]:gn,u=this._getArrayFromAccessor(i);for(let d=0,m=l.length;d {this.loader.load(e,s=>{const r=s.scene;r.traverse(a=>{a instanceof rt&&(a.receiveShadow=!0,a.castShadow=!0)}),this.scene.add(r),this.models.push({children:this.extractMeshes(r)}),t(r)},void 0,s=>{console.error("An error happened loading the model:",s),i(s)})})}extractMeshes(e){const t=[];return e.traverse(i=>{i instanceof rt&&t.push(i)}),t}clearModels(){this.models=[]}}class xv{scene;highlightMaterial;originalMaterials=new Map;originalRenderOrders=new Map;selectedObjects=[];constructor(e,t,i,s){this.scene=e,this.highlightMaterial=new Ht({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.8,side:Xt})}setEventModule(e){}setSelectedWithMaterial(e){this.clearSelected(),e.forEach(t=>{t.isMesh&&(this.originalMaterials.has(t.uuid)||this.originalMaterials.set(t.uuid,t.material),this.originalRenderOrders.has(t.uuid)||this.originalRenderOrders.set(t.uuid,t.renderOrder),t.material=this.highlightMaterial,t.renderOrder=999,this.selectedObjects.push(t))})}clearSelected(){this.selectedObjects.forEach(e=>{const t=this.originalMaterials.get(e.uuid);t&&(e.material=t);const i=this.originalRenderOrders.get(e.uuid);i!==void 0&&(e.renderOrder=i)}),this.selectedObjects=[],this.originalMaterials.clear(),this.originalRenderOrders.clear()}highlight(e){this.setSelectedWithMaterial(e)}clearHighlight(){this.clearSelected()}setVisibility(e,t){this.scene.traverse(i=>{(e.includes(i.uuid)||e.includes(i.name))&&(i.visible=t)})}}class as extends ns{constructor(e,t,i,s){super(),this.renderScene=t,this.renderCamera=i,this.selectedObjects=s!==void 0?s:[],this.visibleEdgeColor=new xe(1,1,1),this.hiddenEdgeColor=new xe(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.patternTexture=null,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,this._visibilityCache=new Map,this._selectionCache=new Set,this.resolution=e!==void 0?new oe(e.x,e.y):new oe(256,256);const r=Math.round(this.resolution.x/this.downSampleRatio),a=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new yt(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new Ec,this.depthMaterial.side=Xt,this.depthMaterial.depthPacking=Il,this.depthMaterial.blending=xt,this.prepareMaskMaterial=this._getPrepareMaskMaterial(),this.prepareMaskMaterial.side=Xt,this.prepareMaskMaterial.fragmentShader=h(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetDepthBuffer=new yt(this.resolution.x,this.resolution.y,{type:ft}),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new yt(r,a,{type:ft}),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new yt(r,a,{type:ft}),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new yt(Math.round(r/2),Math.round(a/2),{type:ft}),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this._getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new yt(r,a,{type:ft}),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new yt(Math.round(r/2),Math.round(a/2),{type:ft}),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;const o=4,l=4;this.separableBlurMaterial1=this._getSeparableBlurMaterial(o),this.separableBlurMaterial1.uniforms.texSize.value.set(r,a),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this._getSeparableBlurMaterial(l),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(r/2),Math.round(a/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=l,this.overlayMaterial=this._getOverlayMaterial();const c=ss;this.copyUniforms=vi.clone(c.uniforms),this.materialCopy=new ct({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:xt,depthTest:!1,depthWrite:!1}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new xe,this.oldClearAlpha=1,this._fsQuad=new Nn(null),this.tempPulseColor1=new xe,this.tempPulseColor2=new xe,this.textureMatrix=new De;function h(u,d){const m=d.isPerspectiveCamera?"perspective":"orthographic";return u.replace(/DEPTH_TO_VIEW_Z/g,m+"DepthToViewZ")}}dispose(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),this.depthMaterial.dispose(),this.prepareMaskMaterial.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this._fsQuad.dispose()}setSize(e,t){this.renderTargetMaskBuffer.setSize(e,t),this.renderTargetDepthBuffer.setSize(e,t);let i=Math.round(e/this.downSampleRatio),s=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(i,s),this.renderTargetBlurBuffer1.setSize(i,s),this.renderTargetEdgeBuffer1.setSize(i,s),this.separableBlurMaterial1.uniforms.texSize.value.set(i,s),i=Math.round(i/2),s=Math.round(s/2),this.renderTargetBlurBuffer2.setSize(i,s),this.renderTargetEdgeBuffer2.setSize(i,s),this.separableBlurMaterial2.uniforms.texSize.value.set(i,s)}render(e,t,i,s,r){if(this.selectedObjects.length>0){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const a=e.autoClear;e.autoClear=!1,r&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this._updateSelectionCache(),this._changeVisibilityOfSelectedObjects(!1);const o=this.renderScene.background,l=this.renderScene.overrideMaterial;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this._changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this._updateTextureMatrix(),this._changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this._changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this._selectionCache.clear(),this.renderScene.background=o,this.renderScene.overrideMaterial=l,this._fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this._fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const c=.625+Math.cos(performance.now()*.01/this.pulsePeriod)*.75/2;this.tempPulseColor1.multiplyScalar(c),this.tempPulseColor2.multiplyScalar(c)}this._fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=as.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this._fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=as.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=as.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this._fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=as.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(i),this._fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=a}this.renderToScreen&&(this._fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=i.texture,e.setRenderTarget(null),this._fsQuad.render(e))}_updateSelectionCache(){const e=this._selectionCache;function t(i){i.isMesh&&e.add(i)}e.clear();for(let i=0;i + }`};function _1(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var jo={exports:{}},x1=jo.exports,_h;function b1(){return _h||(_h=1,(function(n,e){(function(t,i){n.exports=i()})(x1,function(){var t=function(){function i(m){return a.appendChild(m.dom),m}function s(m){for(var g=0;g l+1e3&&(h.update(1e3*c/(m-l),100),l=m,c=0,d)){var g=performance.memory;d.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return m},update:function(){o=this.end()},domElement:a,setMode:s}};return t.Panel=function(i,s,r){var a=1/0,o=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,u=48*c,d=3*c,m=2*c,g=3*c,v=15*c,f=74*c,p=30*c,b=document.createElement("canvas");b.width=h,b.height=u,b.style.cssText="width:80px;height:48px";var _=b.getContext("2d");return _.font="bold "+9*c+"px Helvetica,Arial,sans-serif",_.textBaseline="top",_.fillStyle=r,_.fillRect(0,0,h,u),_.fillStyle=s,_.fillText(i,d,m),_.fillRect(g,v,f,p),_.fillStyle=r,_.globalAlpha=.9,_.fillRect(g,v,f,p),{dom:b,update:function(E,R){a=Math.min(a,E),o=Math.max(o,E),_.fillStyle=r,_.globalAlpha=1,_.fillRect(0,0,h,v),_.fillStyle=s,_.fillText(l(E)+" "+i+" ("+l(a)+"-"+l(o)+")",d,m),_.drawImage(b,g+c,v,f-c,p,g,v,f-c,p),_.fillRect(g+f-c,v,c,p),_.fillStyle=r,_.globalAlpha=.9,_.fillRect(g+f-c,v,c,l((1-E/R)*p))}}},t})})(jo)),jo.exports}var y1=b1();const M1=_1(y1);class S1{scene;constructor(e){this.scene=new go,this.setupEnvironment(e.backgroundColor),this.setupLights()}setupEnvironment(e=15790320){this.scene.background=new xe(e)}setupLights(){}setBackground(e){this.scene.background=new xe(e)}getBoundingBox(){const e=new Pt;return this.scene.traverse(t=>{if(t instanceof rt||t instanceof Vi){const i=new Pt().setFromObject(t);e.union(i)}}),e.isEmpty()&&e.setFromCenterAndSize(new w(0,0,0),new w(10,10,10)),e}}const xh={type:"change"},Xo={type:"start"},bh={type:"end"},Br=new Os,yh=new Ai,T1=Math.cos(70*Wa.DEG2RAD),Ct=new w,Zt=2*Math.PI,at={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},qo=1e-6;class Mh extends fp{constructor(e,t=null){super(e,t),this.state=at.NONE,this.target=new w,this.cursor=new w,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Ms.ROTATE,MIDDLE:Ms.DOLLY,RIGHT:Ms.PAN},this.touches={ONE:Ss.ROTATE,TWO:Ss.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new w,this._lastQuaternion=new hi,this._lastTargetPosition=new w,this._quat=new hi().setFromUnitVectors(e.up,new w(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new zc,this._sphericalDelta=new zc,this._scale=1,this._panOffset=new w,this._rotateStart=new oe,this._rotateEnd=new oe,this._rotateDelta=new oe,this._panStart=new oe,this._panEnd=new oe,this._panDelta=new oe,this._dollyStart=new oe,this._dollyEnd=new oe,this._dollyDelta=new oe,this._dollyDirection=new w,this._mouse=new oe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=w1.bind(this),this._onPointerDown=E1.bind(this),this._onPointerUp=C1.bind(this),this._onContextMenu=U1.bind(this),this._onMouseWheel=P1.bind(this),this._onKeyDown=L1.bind(this),this._onTouchStart=D1.bind(this),this._onTouchMove=I1.bind(this),this._onMouseDown=A1.bind(this),this._onMouseMove=R1.bind(this),this._interceptControlDown=N1.bind(this),this._interceptControlUp=B1.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(xh),this.update(),this.state=at.NONE}update(e=null){const t=this.object.position;Ct.copy(t).sub(this.target),Ct.applyQuaternion(this._quat),this._spherical.setFromVector3(Ct),this.autoRotate&&this.state===at.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=Zt:i>Math.PI&&(i-=Zt),s<-Math.PI?s+=Zt:s>Math.PI&&(s-=Zt),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ct.setFromSpherical(this._spherical),Ct.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ct),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ct.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new w(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new w(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ct.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Br.origin.copy(this.object.position),Br.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Br.direction)) qo||8*(1-this._lastQuaternion.dot(this.object.quaternion))>qo||this._lastTargetPosition.distanceToSquared(this.target)>qo?(this.dispatchEvent(xh),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Zt/60*this.autoRotateSpeed*e:Zt/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ct.setFromMatrixColumn(t,0),Ct.multiplyScalar(-e),this._panOffset.add(Ct)}_panUp(e,t){this.screenSpacePanning===!0?Ct.setFromMatrixColumn(t,1):(Ct.setFromMatrixColumn(t,0),Ct.crossVectors(this.object.up,Ct)),Ct.multiplyScalar(e),this._panOffset.add(Ct)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ct.copy(s).sub(this.target);let r=Ct.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Zt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Zt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Zt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Zt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Zt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t (n.Top="top",n.Bottom="bottom",n.Left="left",n.Right="right",n.Front="front",n.Back="back",n.Iso="iso",n))(rn||{}),an=(n=>(n.Perspective="perspective",n.Orthographic="orthographic",n))(an||{}),Or=(n=>(n.Orbit="orbit",n.FirstPerson="walk",n.PanOnly="pan_only",n))(Or||{});class O1{camera;controls;engineState;constructor(e,t,i,s){this.engineState=s,this.camera=new Tt(45,t/i,.1,1e4),this.camera.position.set(20,20,20),this.controls=new Mh(this.camera,e,this.engineState),this.controls.enableDamping=!0,this.controls.dampingFactor=.05}updateAspect(e,t){this.camera.aspect=e/t,this.camera.updateProjectionMatrix()}tick(){this.controls.update()}setView(e){const t=this.camera.position.length();switch(e){case rn.Top:case"top":this.camera.position.set(0,t,0);break;case rn.Front:case"front":this.camera.position.set(0,0,t);break;case rn.Iso:case"iso":this.camera.position.set(t/Math.sqrt(3),t/Math.sqrt(3),t/Math.sqrt(3));break}this.camera.lookAt(0,0,0),this.controls.update()}}function Sh(n,e){if(e===Mu)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===ka||e===Dl){let t=n.getIndex();if(t===null){const a=[],o=n.getAttribute("position");if(o!==void 0){for(let l=0;l =2.0 are supported."));return}const c=new gv(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h =0&&o[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(i,s)}parseAsync(e,t){const i=this;return new Promise(function(s,r){i.parse(e,t,s,r)})}}function k1(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const Ge={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class F1{constructor(e){this.parser=e,this.name=Ge.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,s=t.length;i =0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class Q1{constructor(e){this.parser=e,this.name=Ge.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=s.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return i.loadTextureImage(e,a.source,l)}}class ev{constructor(e){this.parser=e,this.name=Ge.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=s.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return i.loadTextureImage(e,a.source,l)}}class tv{constructor(e){this.name=Ge.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const s=i.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(o){const l=s.byteOffset||0,c=s.byteLength||0,h=s.count,u=s.byteStride,d=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,u,d,s.mode,s.filter).then(function(m){return m.buffer}):a.ready.then(function(){const m=new ArrayBuffer(h*u);return a.decodeGltfBuffer(new Uint8Array(m),h,u,d,s.mode,s.filter),m})})}else return null}}class iv{constructor(e){this.name=Ge.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const s=t.meshes[i.mesh];for(const l of s.primitives)if(l.mode!==ni.TRIANGLES&&l.mode!==ni.TRIANGLE_STRIP&&l.mode!==ni.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=i.extensions[this.name].attributes,a=[],o={};for(const l in r)a.push(this.parser.getDependency("accessor",r[l]).then(c=>(o[l]=c,o[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const c=l.pop(),h=c.isGroup?c.children:[c],u=l[0].count,d=[];for(const m of h){const g=new De,v=new w,f=new hi,p=new w(1,1,1),b=new Ad(m.geometry,m.material,u);for(let _=0;_0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":n.search(/\.ktx2($|\?)/i)>0||n.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const fv=new De;class gv{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new k1,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,s=-1,r=!1,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);s=i&&l?parseInt(l[1],10):-1,r=o.indexOf("Firefox")>-1,a=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&s<17||r&&a<98?this.textureLoader=new Lc(this.options.manager):this.textureLoader=new sp(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ro(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(a){const o={scene:a[0][s.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:s.asset,parser:i,userData:{}};return _s(r,o,s),Li(o,s),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let s=0,r=t.length;s{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,h]of a.children.entries())r(h,o.children[c])};return r(i,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i =2&&f.setY(S,T[A*l+1]),l>=3&&f.setZ(S,T[A*l+2]),l>=4&&f.setW(S,T[A*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}f.normalized=g}return f})}loadTexture(e){const t=this.json,i=this.options,s=t.textures[e].source,r=t.images[s];let a=this.textureLoader;if(r.uri){const o=i.manager.getHandler(r.uri);o!==null&&(a=o)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,i){const s=this,r=this.json,a=r.textures[e],o=r.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const u=(r.samplers||{})[a.sampler]||{};return h.magFilter=Ah[u.magFilter]||yt,h.minFilter=Ah[u.minFilter]||Ei,h.wrapS=Rh[u.wrapS]||Ti,h.wrapT=Rh[u.wrapT]||Ti,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==Ut&&h.minFilter!==yt,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const a=s.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=i.getDependency("bufferView",a.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:a.mimeType});return l=o.createObjectURL(d),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(u){return new Promise(function(d,m){let g=d;t.isImageBitmapLoader===!0&&(g=function(v){const f=new Rt(v);f.needsUpdate=!0,d(f)}),t.load(Dn.resolveURL(u,r.path),g,void 0,m)})}).then(function(u){return c===!0&&o.revokeObjectURL(l),Li(u,a),u.userData.mimeType=a.mimeType||mv(a.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=h,h}assignTexture(e,t,i,s){const r=this;return this.getDependency("texture",i.index).then(function(a){if(!a)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(a=a.clone(),a.channel=i.texCoord),r.extensions[Ge.KHR_TEXTURE_TRANSFORM]){const o=i.extensions!==void 0?i.extensions[Ge.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=r.associations.get(a);a=r.extensions[Ge.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.associations.set(a,l)}}return s!==void 0&&(a.colorSpace=s),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new yc,ti.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(o,l)),i=l}else if(e.isLine){const o="LineBasicMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new gc,ti.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(o,l)),i=l}if(s||r||a){let o="ClonedMaterial:"+i.uuid+":";s&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=i.clone(),r&&(l.vertexColors=!0),a&&(l.flatShading=!0),s&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return Ao}loadMaterial(e){const t=this,i=this.json,s=this.extensions,r=i.materials[e];let a;const o={},l=r.extensions||{},c=[];if(l[Ge.KHR_MATERIALS_UNLIT]){const u=s[Ge.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{const u=r.pbrMetallicRoughness||{};if(o.color=new xe(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],Ot),o.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",u.baseColorTexture,At)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=Xt);const h=r.alphaMode||Ko.OPAQUE;if(h===Ko.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===Ko.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&a!==Ht&&(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new oe(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;o.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&a!==Ht&&(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&a!==Ht){const u=r.emissiveFactor;o.emissive=new xe().setRGB(u[0],u[1],u[2],Ot)}return r.emissiveTexture!==void 0&&a!==Ht&&c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,At)),Promise.all(c).then(function(){const u=new a(o);return r.name&&(u.name=r.name),Li(u,r),t.associations.set(u,{materials:e}),r.extensions&&_s(s,u,r),u})}createUniqueName(e){const t=nt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,s=this.primitiveCache;function r(o){return i[Ge.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return Ph(l,o,t)})}const a=[];for(let o=0,l=e.length;o 0&&dv(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),Li(p,r),f.extensions&&_s(s,p,f),t.assignFinalMaterial(p),u.push(p)}for(let m=0,g=u.length;m 1?h=new Vi:c.length===1?h=c[0]:h=new dt,h!==c[0])for(let u=0,d=c.length;u 1){const u=s.associations.get(h);s.associations.set(h,{...u})}return s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],s=this,r=new Vi;i.name&&(r.name=s.createUniqueName(i.name)),Li(r,i),i.extensions&&_s(t,r,i);const a=i.nodes||[],o=[];for(let l=0,c=a.length;l {const u=new Map;for(const[d,m]of s.associations)(d instanceof ti||d instanceof Rt)&&u.set(d,m);return h.traverse(d=>{const m=s.associations.get(d);m!=null&&u.set(d,m)}),u};return s.associations=c(r),r})}_createAnimationTracks(e,t,i,s,r){const a=[],o=e.name?e.name:e.uuid,l=[];rs[r.path]===rs.weights?e.traverse(function(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}):l.push(o);let c;switch(rs[r.path]){case rs.weights:c=Ks;break;case rs.rotation:c=$s;break;case rs.translation:case rs.scale:c=Qs;break;default:switch(i.itemSize){case 1:c=Ks;break;case 2:case 3:default:c=Qs;break}break}const h=s.interpolation!==void 0?cv[s.interpolation]:gn,u=this._getArrayFromAccessor(i);for(let d=0,m=l.length;d {this.loader.load(e,s=>{const r=s.scene;r.traverse(a=>{a instanceof rt&&(a.receiveShadow=!0,a.castShadow=!0)}),this.scene.add(r),this.models.push({children:this.extractMeshes(r)}),t(r)},void 0,s=>{console.error("An error happened loading the model:",s),i(s)})})}extractMeshes(e){const t=[];return e.traverse(i=>{i instanceof rt&&t.push(i)}),t}clearModels(){this.models=[]}}class xv{scene;highlightMaterial;originalMaterials=new Map;originalRenderOrders=new Map;selectedObjects=[];constructor(e,t,i,s){this.scene=e,this.highlightMaterial=new Ht({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.8,side:Xt})}setEventModule(e){}setSelectedWithMaterial(e){this.clearSelected(),e.forEach(t=>{t.isMesh&&(this.originalMaterials.has(t.uuid)||this.originalMaterials.set(t.uuid,t.material),this.originalRenderOrders.has(t.uuid)||this.originalRenderOrders.set(t.uuid,t.renderOrder),t.material=this.highlightMaterial,t.renderOrder=999,this.selectedObjects.push(t))})}clearSelected(){this.selectedObjects.forEach(e=>{const t=this.originalMaterials.get(e.uuid);t&&(e.material=t);const i=this.originalRenderOrders.get(e.uuid);i!==void 0&&(e.renderOrder=i)}),this.selectedObjects=[],this.originalMaterials.clear(),this.originalRenderOrders.clear()}highlight(e){this.setSelectedWithMaterial(e)}clearHighlight(){this.clearSelected()}setVisibility(e,t){this.scene.traverse(i=>{(e.includes(i.uuid)||e.includes(i.name))&&(i.visible=t)})}}class as extends ns{constructor(e,t,i,s){super(),this.renderScene=t,this.renderCamera=i,this.selectedObjects=s!==void 0?s:[],this.visibleEdgeColor=new xe(1,1,1),this.hiddenEdgeColor=new xe(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.patternTexture=null,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,this._visibilityCache=new Map,this._selectionCache=new Set,this.resolution=e!==void 0?new oe(e.x,e.y):new oe(256,256);const r=Math.round(this.resolution.x/this.downSampleRatio),a=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new Mt(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new Ec,this.depthMaterial.side=Xt,this.depthMaterial.depthPacking=Il,this.depthMaterial.blending=bt,this.prepareMaskMaterial=this._getPrepareMaskMaterial(),this.prepareMaskMaterial.side=Xt,this.prepareMaskMaterial.fragmentShader=h(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetDepthBuffer=new Mt(this.resolution.x,this.resolution.y,{type:ft}),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new Mt(r,a,{type:ft}),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new Mt(r,a,{type:ft}),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new Mt(Math.round(r/2),Math.round(a/2),{type:ft}),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this._getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new Mt(r,a,{type:ft}),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new Mt(Math.round(r/2),Math.round(a/2),{type:ft}),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;const o=4,l=4;this.separableBlurMaterial1=this._getSeparableBlurMaterial(o),this.separableBlurMaterial1.uniforms.texSize.value.set(r,a),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this._getSeparableBlurMaterial(l),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(r/2),Math.round(a/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=l,this.overlayMaterial=this._getOverlayMaterial();const c=ss;this.copyUniforms=vi.clone(c.uniforms),this.materialCopy=new ct({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:bt,depthTest:!1,depthWrite:!1}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new xe,this.oldClearAlpha=1,this._fsQuad=new Nn(null),this.tempPulseColor1=new xe,this.tempPulseColor2=new xe,this.textureMatrix=new De;function h(u,d){const m=d.isPerspectiveCamera?"perspective":"orthographic";return u.replace(/DEPTH_TO_VIEW_Z/g,m+"DepthToViewZ")}}dispose(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),this.depthMaterial.dispose(),this.prepareMaskMaterial.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this._fsQuad.dispose()}setSize(e,t){this.renderTargetMaskBuffer.setSize(e,t),this.renderTargetDepthBuffer.setSize(e,t);let i=Math.round(e/this.downSampleRatio),s=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(i,s),this.renderTargetBlurBuffer1.setSize(i,s),this.renderTargetEdgeBuffer1.setSize(i,s),this.separableBlurMaterial1.uniforms.texSize.value.set(i,s),i=Math.round(i/2),s=Math.round(s/2),this.renderTargetBlurBuffer2.setSize(i,s),this.renderTargetEdgeBuffer2.setSize(i,s),this.separableBlurMaterial2.uniforms.texSize.value.set(i,s)}render(e,t,i,s,r){if(this.selectedObjects.length>0){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const a=e.autoClear;e.autoClear=!1,r&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this._updateSelectionCache(),this._changeVisibilityOfSelectedObjects(!1);const o=this.renderScene.background,l=this.renderScene.overrideMaterial;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this._changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this._updateTextureMatrix(),this._changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this._changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this._selectionCache.clear(),this.renderScene.background=o,this.renderScene.overrideMaterial=l,this._fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this._fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const c=.625+Math.cos(performance.now()*.01/this.pulsePeriod)*.75/2;this.tempPulseColor1.multiplyScalar(c),this.tempPulseColor2.multiplyScalar(c)}this._fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=as.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this._fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=as.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=as.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this._fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=as.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(i),this._fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=a}this.renderToScreen&&(this._fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=i.texture,e.setRenderTarget(null),this._fsQuad.render(e))}_updateSelectionCache(){const e=this._selectionCache;function t(i){i.isMesh&&e.add(i)}e.clear();for(let i=0;i #include #include @@ -4890,10 +4890,10 @@ void main() { if(usePatternTexture) finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r); gl_FragColor = finalColor; - }`,blending:zn,depthTest:!1,depthWrite:!1,transparent:!0})}}as.BlurDirectionX=new oe(1,0),as.BlurDirectionY=new oe(0,1);class bv{outlinePass;hoveredObjects=[];selectedObjects=[];constructor(e,t,i,s){this.outlinePass=new as(new oe(i,s),e,t),this.outlinePass.edgeStrength=3,this.outlinePass.edgeGlow=.5,this.outlinePass.edgeThickness=1,this.outlinePass.pulsePeriod=0,this.outlinePass.visibleEdgeColor.set("#ff9800"),this.outlinePass.hiddenEdgeColor.set("#ff9800")}getPass(){return this.outlinePass}setHoveredObjects(e){this.hoveredObjects=e,this.updateOutline(),e.length>0&&(this.outlinePass.edgeStrength=3,this.outlinePass.edgeGlow=.5,this.outlinePass.visibleEdgeColor.set("#ff9800"),this.outlinePass.hiddenEdgeColor.set("#ff9800"))}setSelectedObjects(e){this.selectedObjects=e,this.updateOutline(),e.length>0&&(this.outlinePass.edgeStrength=5,this.outlinePass.edgeGlow=1,this.outlinePass.visibleEdgeColor.set("#00aaff"),this.outlinePass.hiddenEdgeColor.set("#00aaff"))}clearHovered(){this.hoveredObjects=[],this.updateOutline()}clearSelected(){this.selectedObjects=[],this.updateOutline()}clearAll(){this.hoveredObjects=[],this.selectedObjects=[],this.updateOutline()}updateOutline(){this.selectedObjects.length>0?(this.outlinePass.selectedObjects=this.selectedObjects,this.outlinePass.edgeStrength=5,this.outlinePass.edgeGlow=1,this.outlinePass.visibleEdgeColor.set("#00aaff"),this.outlinePass.hiddenEdgeColor.set("#00aaff")):this.hoveredObjects.length>0?(this.outlinePass.selectedObjects=this.hoveredObjects,this.outlinePass.edgeStrength=3,this.outlinePass.edgeGlow=.5,this.outlinePass.visibleEdgeColor.set("#ff9800"),this.outlinePass.hiddenEdgeColor.set("#ff9800")):this.outlinePass.selectedObjects=[]}resize(e,t){this.outlinePass.setSize(e,t)}setHoverStyle(e){e.color&&(this.outlinePass.visibleEdgeColor.set(e.color),this.outlinePass.hiddenEdgeColor.set(e.color)),e.strength!==void 0&&(this.outlinePass.edgeStrength=e.strength),e.glow!==void 0&&(this.outlinePass.edgeGlow=e.glow),e.thickness!==void 0&&(this.outlinePass.edgeThickness=e.thickness)}setSelectedStyle(e){}}class yv{scene;camera;canvas;controls;outlineManager;isSelecting=!1;startPoint=new oe;endPoint=new oe;ctrlPressed=!1;controlsEnabled=!0;selectionBox=null;selectedObjects=[];constructor(e,t,i,s,r){this.scene=e,this.camera=t,this.canvas=i,this.controls=s,this.outlineManager=r,this.setupEventListeners(),this.createSelectionBoxElement()}createSelectionBoxElement(){this.selectionBox=document.createElement("div"),this.selectionBox.style.position="absolute",this.selectionBox.style.border="2px dashed #00aaff",this.selectionBox.style.backgroundColor="rgba(0, 170, 255, 0.1)",this.selectionBox.style.pointerEvents="none",this.selectionBox.style.display="none",this.selectionBox.style.zIndex="1000",this.canvas.parentElement&&this.canvas.parentElement.appendChild(this.selectionBox)}setupEventListeners(){window.addEventListener("keydown",this.onKeyDown.bind(this)),window.addEventListener("keyup",this.onKeyUp.bind(this)),this.canvas.addEventListener("mousedown",this.onMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.onMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.onMouseUp.bind(this))}onKeyDown(e){(e.key==="Control"||e.key==="Meta")&&(this.ctrlPressed=!0)}onKeyUp(e){(e.key==="Control"||e.key==="Meta")&&(this.ctrlPressed=!1,this.isSelecting&&this.endSelection())}onMouseDown(e){if(e.button!==0||!this.ctrlPressed)return;const t=this.canvas.getBoundingClientRect();this.startPoint.set(e.clientX-t.left,e.clientY-t.top),this.endPoint.copy(this.startPoint),this.isSelecting=!0,this.controls&&this.controls.enabled!==void 0&&(this.controlsEnabled=this.controls.enabled,this.controls.enabled=!1),this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation()}onMouseMove(e){if(!this.isSelecting)return;const t=this.canvas.getBoundingClientRect();this.endPoint.set(e.clientX-t.left,e.clientY-t.top),this.updateSelectionBoxUI(),this.updateSelectedObjects(),e.preventDefault(),e.stopPropagation()}onMouseUp(e){this.isSelecting&&(this.endSelection(),e.preventDefault(),e.stopPropagation())}endSelection(){this.isSelecting&&(this.isSelecting=!1,this.controls&&this.controls.enabled!==void 0&&(this.controls.enabled=this.controlsEnabled),this.selectionBox&&(this.selectionBox.style.display="none"),this.updateSelectedObjects())}updateSelectionBoxUI(){if(!this.selectionBox)return;const e=Math.min(this.startPoint.x,this.endPoint.x),t=Math.min(this.startPoint.y,this.endPoint.y),i=Math.abs(this.endPoint.x-this.startPoint.x),s=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${e}px`,this.selectionBox.style.top=`${t}px`,this.selectionBox.style.width=`${i}px`,this.selectionBox.style.height=`${s}px`}updateSelectedObjects(){const e=this.endPoint.x>this.startPoint.x,t=this.endPoint.y>this.startPoint.y,i=e&&t,s=this.canvas.getBoundingClientRect(),r=s.width,a=s.height,o=new oe(Math.min(this.startPoint.x,this.endPoint.x)/r,Math.min(this.startPoint.y,this.endPoint.y)/a),l=new oe(Math.max(this.startPoint.x,this.endPoint.x)/r,Math.max(this.startPoint.y,this.endPoint.y)/a),c=[];this.scene.traverse(h=>{if(!h.isMesh||!h.visible)return;const u=h;if(!u.geometry)return;u.geometry.boundingBox||u.geometry.computeBoundingBox();const d=u.geometry.boundingBox;if(!d)return;const m=this.getBoundingBoxCorners(d,u).map(f=>this.worldToScreen(f)),g=this.getScreenBoundingBox(m);let v=!1;i?v=this.isFullyContained(g,o,l):v=this.isPartiallyContained(g,o,l),v&&c.push(h)}),this.selectedObjects=c,this.outlineManager.setSelectedObjects(this.selectedObjects)}getBoundingBoxCorners(e,t){const i=[],s=e.min,r=e.max;return i.push(new w(s.x,s.y,s.z)),i.push(new w(r.x,s.y,s.z)),i.push(new w(s.x,r.y,s.z)),i.push(new w(r.x,r.y,s.z)),i.push(new w(s.x,s.y,r.z)),i.push(new w(r.x,s.y,r.z)),i.push(new w(s.x,r.y,r.z)),i.push(new w(r.x,r.y,r.z)),i.forEach(a=>{a.applyMatrix4(t.matrixWorld)}),i}worldToScreen(e){const t=e.clone();t.project(this.camera);const i=(t.x+1)/2,s=(1-t.y)/2;return new oe(i,s)}getScreenBoundingBox(e){const t=new oe(1/0,1/0),i=new oe(-1/0,-1/0);return e.forEach(s=>{t.x=Math.min(t.x,s.x),t.y=Math.min(t.y,s.y),i.x=Math.max(i.x,s.x),i.y=Math.max(i.y,s.y)}),{min:t,max:i}}isFullyContained(e,t,i){return e.min.x>=t.x&&e.min.y>=t.y&&e.max.x<=i.x&&e.max.y<=i.y}isPartiallyContained(e,t,i){return!(e.max.x i.x||e.max.y i.y)}clearSelection(){this.selectedObjects=[],this.outlineManager.clearSelected()}getSelectedObjects(){return this.selectedObjects}dispose(){window.removeEventListener("keydown",this.onKeyDown.bind(this)),window.removeEventListener("keyup",this.onKeyUp.bind(this)),this.canvas.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.canvas.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.canvas.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.selectionBox&&this.selectionBox.parentElement&&this.selectionBox.parentElement.removeChild(this.selectionBox),this.clearSelection()}}class Mv{scene;clippingPlane;stencilGroup=null;isEnabledFlag=!1;capMesh=null;planeInitialized=!1;tempCenter=new w;sceneBounds=new Rt;capColor=new xe(16711680);constructor(e){this.scene=e,this.clippingPlane=new Ai(new w(0,-1,0),0)}enable(){this.isEnabledFlag=!0,this.refresh()}disable(){this.isEnabledFlag=!1,this.cleanup()}refresh(){this.isEnabledFlag&&(this.cleanupStencilGroup(),this.ensurePlaneInitialized(),this.updateSceneMaterials(!0),this.createStencilGroup())}setPlane(e,t){this.planeInitialized=!0,this.clippingPlane.normal.copy(e).normalize(),this.clippingPlane.constant=t,this.isEnabledFlag&&this.updateCapPlane()}isEnabled(){return this.isEnabledFlag}setCapColor(e){if(this.capColor.set(e),this.capMesh){const t=this.capMesh.material;t.color.copy(this.capColor),t.needsUpdate=!0}}updateSceneMaterials(e){this.scene.traverse(t=>{if(t instanceof rt){if(t.userData.isStencilCap)return;(Array.isArray(t.material)?t.material:[t.material]).forEach(i=>{i&&(e?((!i.clippingPlanes||i.clippingPlanes.indexOf(this.clippingPlane)===-1)&&(i.clippingPlanes=[this.clippingPlane]),i.clipShadows=!0):i.clippingPlanes=[],i.needsUpdate=!0)})}})}createStencilGroup(){this.stencilGroup=new Vi,this.stencilGroup.name="ClippingStencilGroup",this.scene.add(this.stencilGroup);let e=0;this.scene.traverse(t=>{if(t instanceof rt&&t.visible&&!t.userData.isStencilCap){if(!t.geometry)return;this.createStencilMeshesForObject(t),e++}}),console.log(`ClippingManager: Generated stencil geometry for ${e} meshes.`),this.addCapPlane(),this.updateCapPlane()}createStencilMeshesForObject(e){const t=e.geometry;e.updateMatrixWorld(!0);const i=e.matrixWorld,s=new Ht({depthWrite:!1,depthTest:!1,colorWrite:!1,stencilWrite:!0,stencilFunc:Ha,clippingPlanes:[this.clippingPlane]}),r=s.clone();r.side=zt,r.stencilFail=Fa,r.stencilZFail=Fa,r.stencilZPass=Fa;const a=new rt(t,r);a.applyMatrix4(i),a.matrixAutoUpdate=!1,a.userData.isStencilCap=!0,a.renderOrder=1,this.stencilGroup.add(a);const o=s.clone();o.side=Si,o.stencilFail=za,o.stencilZFail=za,o.stencilZPass=za;const l=new rt(t,o);l.applyMatrix4(i),l.matrixAutoUpdate=!1,l.userData.isStencilCap=!0,l.renderOrder=1,this.stencilGroup.add(l)}addCapPlane(){const e=new Ht({color:this.capColor,side:Xt,stencilWrite:!0,transparent:!0,opacity:0,stencilFunc:Eu,stencilRef:0,clippingPlanes:[],depthTest:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),t=new An(1e5,1e5),i=new rt(t,e);i.userData.isCapPlane=!0,i.userData.isStencilCap=!0,i.renderOrder=2,this.capMesh=i,this.stencilGroup.add(i)}updateCapPlane(){if(!this.stencilGroup||!this.capMesh)return;const e=this.capMesh,t=this.clippingPlane.normal,i=-this.clippingPlane.constant;e.quaternion.setFromUnitVectors(new w(0,0,1),t),e.position.copy(t).multiplyScalar(i)}cleanupStencilGroup(){this.stencilGroup&&(this.scene.remove(this.stencilGroup),this.stencilGroup.traverse(e=>{e.material&&(Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose()),e.geometry&&e.userData.isCapPlane&&e.geometry.dispose()}),this.stencilGroup=null,this.capMesh=null)}cleanup(){this.updateSceneMaterials(!1),this.cleanupStencilGroup()}ensurePlaneInitialized(){if(this.planeInitialized||(this.sceneBounds.makeEmpty(),this.sceneBounds.setFromObject(this.scene),this.sceneBounds.isEmpty()))return;this.sceneBounds.getCenter(this.tempCenter);const e=this.clippingPlane.normal;this.clippingPlane.constant=-e.dot(this.tempCenter),this.planeInitialized=!0,this.updateCapPlane()}}class Sv{_lastClickWorldPosition=null;_lastClickScreenPosition=null;constructor(){}setLastClickWorldPosition(e){this._lastClickWorldPosition=e.clone()}getLastClickWorldPosition(){return this._lastClickWorldPosition}setLastClickScreenPosition(e){this._lastClickScreenPosition=e.clone()}getLastClickScreenPosition(){return this._lastClickScreenPosition}clearClickState(){this._lastClickWorldPosition=null,this._lastClickScreenPosition=null}}function Tv(n){let e=new Object;return e.updataSceneOctreeBox=function(){n.octreeBoxModels=[];let t=e.getBoundingBox();e.ocBox=e.splitBoxIntoAuto(t);let i=0;n.models.forEach(a=>{a.children.forEach(o=>{o.info.forEach(l=>{r(l,e.ocBox)})}),i=i+1}),s(e.ocBox);function s(a){for(let o=a.children.length-1;o>=0;o--){let l=a.children[o];l.isLeaf==!1&&s(l),l.children.length==0&&(l.isLeaf=!0),l.isLeaf&&(l.elements==null||l.elements.length==0)&&a.children.splice(o,1)}}function r(a,o){var l={min:a.box.min,max:a.box.max};if(e.boxContainBox(o,l)==!0)if(o.elements==null&&(o.elements=[]),o.isLeaf==!1){let c=!1;for(let h=0;h =t.min.x&&i.min.y>=t.min.y&&i.min.z>=t.min.z&&i.max.x<=t.max.x&&i.max.y<=t.max.y&&i.max.z<=t.max.z},e.splitBoxIntoAuto=function(t,i=10){let s=[],r=[],a=[],o=(t.max.x-t.min.x)*.5,l=(t.max.y-t.min.y)*.5,c=(t.max.z-t.min.z)*.5;if(o>i){let h=t,u={min:h.min,max:new w(h.min.x+o,h.max.y,h.max.z)},d={min:new w(h.min.x+o,h.min.y,h.min.z),max:h.max};s.push(u),s.push(d)}if(l>i)for(let h of s){let u={min:h.min,max:new w(h.max.x,h.min.y+l,h.max.z)},d={min:new w(h.min.x,h.min.y+l,h.min.z),max:h.max};r.push(u),r.push(d)}else r=s;if(c>i)for(let h of r){let u={min:h.min,max:new w(h.max.x,h.max.y,h.min.z+c)},d={min:new w(h.min.x,h.min.y,h.min.z+c),max:h.max};a.push(u),a.push(d)}else a=r;if(t.children=a,t.children.length>0){t.isLeaf=!1;for(let h=0;h {r.children.forEach(a=>{a.geometry.computeBoundingBox();let o=a.geometry.boundingBox.min,l=a.geometry.boundingBox.max;o.x s.x&&(s.x=l.x),l.y>s.y&&(s.y=l.y),l.z>s.z&&(s.z=l.z)})}),{min:i,max:s}},e}var ln=Object.freeze({Linear:Object.freeze({None:function(n){return n},In:function(n){return n},Out:function(n){return n},InOut:function(n){return n}}),Quadratic:Object.freeze({In:function(n){return n*n},Out:function(n){return n*(2-n)},InOut:function(n){return(n*=2)<1?.5*n*n:-.5*(--n*(n-2)-1)}}),Cubic:Object.freeze({In:function(n){return n*n*n},Out:function(n){return--n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n:.5*((n-=2)*n*n+2)}}),Quartic:Object.freeze({In:function(n){return n*n*n*n},Out:function(n){return 1- --n*n*n*n},InOut:function(n){return(n*=2)<1?.5*n*n*n*n:-.5*((n-=2)*n*n*n-2)}}),Quintic:Object.freeze({In:function(n){return n*n*n*n*n},Out:function(n){return--n*n*n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n*n*n:.5*((n-=2)*n*n*n*n+2)}}),Sinusoidal:Object.freeze({In:function(n){return 1-Math.sin((1-n)*Math.PI/2)},Out:function(n){return Math.sin(n*Math.PI/2)},InOut:function(n){return .5*(1-Math.sin(Math.PI*(.5-n)))}}),Exponential:Object.freeze({In:function(n){return n===0?0:Math.pow(1024,n-1)},Out:function(n){return n===1?1:1-Math.pow(2,-10*n)},InOut:function(n){return n===0?0:n===1?1:(n*=2)<1?.5*Math.pow(1024,n-1):.5*(-Math.pow(2,-10*(n-1))+2)}}),Circular:Object.freeze({In:function(n){return 1-Math.sqrt(1-n*n)},Out:function(n){return Math.sqrt(1- --n*n)},InOut:function(n){return(n*=2)<1?-.5*(Math.sqrt(1-n*n)-1):.5*(Math.sqrt(1-(n-=2)*n)+1)}}),Elastic:Object.freeze({In:function(n){return n===0?0:n===1?1:-Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI)},Out:function(n){return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n-.1)*5*Math.PI)+1},InOut:function(n){return n===0?0:n===1?1:(n*=2,n<1?-.5*Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI):.5*Math.pow(2,-10*(n-1))*Math.sin((n-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(n){var e=1.70158;return n===1?1:n*n*((e+1)*n-e)},Out:function(n){var e=1.70158;return n===0?0:--n*n*((e+1)*n+e)+1},InOut:function(n){var e=2.5949095;return(n*=2)<1?.5*(n*n*((e+1)*n-e)):.5*((n-=2)*n*((e+1)*n+e)+2)}}),Bounce:Object.freeze({In:function(n){return 1-ln.Bounce.Out(1-n)},Out:function(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375},InOut:function(n){return n<.5?ln.Bounce.In(n*2)*.5:ln.Bounce.Out(n*2-1)*.5+.5}}),generatePow:function(n){return n===void 0&&(n=4),n=n 1e4?1e4:n,{In:function(e){return Math.pow(e,n)},Out:function(e){return 1-Math.pow(1-e,n)},InOut:function(e){return e<.5?Math.pow(e*2,n)/2:(1-Math.pow(2-e*2,n))/2+.5}}}}),On=function(){return performance.now()},Ev=(function(){function n(){this._tweens={},this._tweensAddedDuringUpdate={}}return n.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},n.prototype.removeAll=function(){this._tweens={}},n.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},n.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},n.prototype.update=function(e,t){e===void 0&&(e=On()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s 1?r(n[t],n[t-1],t-i):r(n[s],n[s+1>t?t:s+1],i-s)},Utils:{Linear:function(n,e,t){return(e-n)*t+n}}},Lh=(function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n})(),el=new Ev,wv=(function(){function n(e,t){t===void 0&&(t=el),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=ln.Linear.None,this._interpolationFunction=Qo.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Lh.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return n.prototype.getId=function(){return this._id},n.prototype.isPlaying=function(){return this._isPlaying},n.prototype.isPaused=function(){return this._isPaused},n.prototype.getDuration=function(){return this._duration},n.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},n.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},n.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},n.prototype.start=function(e,t){if(e===void 0&&(e=On()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var r in this._valuesEnd)s[r]=this._valuesEnd[r];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},n.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},n.prototype._setupProperties=function(e,t,i,s,r){for(var a in i){var o=e[a],l=Array.isArray(o),c=l?"array":typeof o,h=!l&&Array.isArray(i[a]);if(!(c==="undefined"||c==="function")){if(h){var u=i[a];if(u.length===0)continue;for(var d=[o],m=0,g=u.length;m "u"||r)&&(t[a]=o),l||(t[a]*=1),h?s[a]=i[a].slice().reverse():s[a]=t[a]||0}}},n.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},n.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},n.prototype.pause=function(e){return e===void 0&&(e=On()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},n.prototype.resume=function(e){return e===void 0&&(e=On()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},n.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e a)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e c)return 1;var f=Math.trunc(o/l),p=o-f*l,b=Math.min(p/i._duration,1);return b===0&&o===i._duration?1:b},u=h(),d=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,d),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||o>=this._duration)if(this._repeat>0){var m=Math.min(Math.trunc((o-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=m);for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*m,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,v=this._chainedTweens.length;g {f&&(E||(f(R),E=!0))}),f&&setTimeout(()=>{E||(f(!0),E=!0)},v+10)},i.CameraGoHome=function(){var g=n.octreeBox.getBoundingBox(),v=g.min.clone().add(g.max.clone()).multiplyScalar(.5);let f=new w(1,1,1);var p=v.clone().add(f.multiplyScalar(1*g.max.distanceTo(g.min)));l(e.camera.position,p,n.controls.target.clone(),v)};function l(g,v,f,p,b,_,E=1e3,R){var T;b&&_?(T=new tl.Tween({x1:g.x,y1:g.y,z1:g.z,x2:f.x,y2:f.y,z2:f.z,_x:b._x,_y:b._y,_z:b._z,_w:b._w}),T.to({x1:v.x,y1:v.y,z1:v.z,x2:p.x,y2:p.y,z2:p.z,_x:_._x,_y:_._y,_z:_._z,_w:_._w},E)):(T=new tl.Tween({x1:g.x,y1:g.y,z1:g.z,x2:f.x,y2:f.y,z2:f.z}),T.to({x1:v.x,y1:v.y,z1:v.z,x2:p.x,y2:p.y,z2:p.z},E)),T.onUpdate(function(I){b&&_?(e.camera.quaternion._x=I._x,e.camera.quaternion._y=I._y,e.camera.quaternion._z=I._z,e.camera.quaternion._w=I._w):n.controls.auto=!0,e.camera.position.x=I.x1,e.camera.position.y=I.y1,e.camera.position.z=I.z1,n.controls.target.x=I.x2,n.controls.target.y=I.y2,n.controls.target.z=I.z2,n.controls.update(),i.RenderScene()}),T.onComplete(function(I){n.controls.auto=!1,i.RenderScene(),R&&R(!0),cancelAnimationFrame(s),s=null}),T.easing(tl.Easing.Cubic.InOut);function A(I){s=requestAnimationFrame(A),T.update()}T.start(),A()}function c(){r=document.createElement("div"),r.className="ViewCube",t.appendChild(r),a=document.createElement("div"),a.className="ViewAttr",t.appendChild(a)}function h(){i.sceneOrtho=Cv();var f=window.innerWidth,p=window.innerHeight,g=f>p?f/p:p/f,v=150;i.camera=new ms(v*g/-2,v*g/2,2*v/2,1.4*v/-2,.01,1e4);var f=r.clientWidth,p=r.clientHeight,b=new Lr({alpha:!0});b.setSize(f,p),b.setClearAlpha(0),i.sceneOrtho.renderer=b;let _=new Bc(16777215,.8);i.sceneOrtho.add(_),Av(r,b)}function u(){let g=[{label:"右",icon:"cube/cn_right.png"},{label:"左",icon:"cube/cn_left.png"},{label:"顶",icon:"cube/cn_top.png"},{label:"底",icon:"cube/cn_bottom.png"},{label:"前",icon:"cube/cn_front.png"},{label:"后",icon:"cube/cn_back.png"}];var v=[];for(const p of g)v.push(new Ht({color:16777215,map:new Lc().load(p.icon)}));new Od({color:255});var f=new rt(new ds(110,110,110),v);i.sceneOrtho.add(f),d(122),r.addEventListener("mousedown",p=>{var b={};b.x=p.offsetX/r.clientWidth*2-1,b.y=-(p.offsetY/r.clientHeight)*2+1;var _=new kc;_.setFromCamera(b,i.camera);const E=_.intersectObjects(o,!1);E.length>0&&i.ToggleDirectionView(E[0].object.name)}),r.addEventListener("mousemove",p=>{var b={};b.x=p.offsetX/r.clientWidth*2-1,b.y=-(p.offsetY/r.clientHeight)*2+1;var _=new kc;_.setFromCamera(b,i.camera);const E=_.intersectObjects(o,!1);for(var R of o)R.material.opacity=.01;E.length>0&&(E[0].object.material.opacity=.2)})}function d(g){for(var v=g*.5-20,f=[{name:"right",a:30,b:75,c:75,point:new w(v,0,0)},{name:"back",a:75,b:75,c:30,point:new w(0,0,-v)},{name:"left",a:30,b:75,c:75,point:new w(-v,0,0)},{name:"front",a:75,b:75,c:30,point:new w(0,0,v)},{name:"top",a:75,b:30,c:75,point:new w(0,v,0)},{name:"button",a:75,b:30,c:75,point:new w(0,-v,0)}],p=[{name:"top_right_back",a:30,b:30,c:30,point:new w(-v,v,v)},{name:"button_front_right",a:30,b:30,c:30,point:new w(-v,-v,v)},{name:"top_front_right",a:30,b:30,c:30,point:new w(v,v,v)},{name:"button_right_back",a:30,b:30,c:30,point:new w(v,-v,v)},{name:"top_back_left",a:30,b:30,c:30,point:new w(-v,v,-v)},{name:"button_back_left",a:30,b:30,c:30,point:new w(-v,-v,-v)},{name:"top_left_front",a:30,b:30,c:30,point:new w(v,v,-v)},{name:"button_left_front",a:30,b:30,c:30,point:new w(v,-v,-v)}],b=[{name:"top_front",a:30,b:30,c:75,point:new w(v,v,0)},{name:"top_right",a:75,b:30,c:30,point:new w(0,v,v)},{name:"top_back",a:30,b:30,c:75,point:new w(-v,v,0)},{name:"top_left",a:75,b:30,c:30,point:new w(0,v,-v)},{name:"button_front",a:30,b:30,c:75,point:new w(v,-v,0)},{name:"button_right",a:75,b:30,c:30,point:new w(0,-v,v)},{name:"button_back",a:30,b:30,c:75,point:new w(-v,-v,0)},{name:"button_left",a:75,b:30,c:30,point:new w(0,-v,-v)},{name:"front_right",a:30,b:75,c:30,point:new w(v,0,v)},{name:"right_back",a:30,b:75,c:30,point:new w(-v,0,v)},{name:"back_left",a:30,b:75,c:30,point:new w(-v,0,-v)},{name:"left_front",a:30,b:75,c:30,point:new w(v,0,-v)}],_=0;_ {t instanceof rt&&n.includes(t.name)&&e.push(t)}),this.manager.highlight(e)}addSelection(n){this.select(n)}removeSelection(n){this.manager.clearHighlight()}clearSelection(){this.manager.clearHighlight()}getHiddenComponents(){const n=[];return this.scene.traverse(e=>{e.visible||n.push(e.name)}),n}setVisibility(n,e){this.manager.setVisibility(n,e)}isolate(n){this.scene.traverse(e=>e.visible=!1),this.setVisibility(n,!0)}clearIsolation(){this.scene.traverse(n=>n.visible=!0)}setColor(n,e){console.warn("[V1] setColor not implemented")}restoreColor(n){console.warn("[V1] restoreColor not implemented")}setOpacity(n,e){console.warn("[V1] setOpacity not implemented")}restoreOpacity(n){console.warn("[V1] restoreOpacity not implemented")}clearAllOverrides(){}getBoundingBox(n){let e;if(this.scene.traverse(t=>{t.name===n&&(e=t)}),e){const t=new Rt().setFromObject(e);return{min:t.min,max:t.max}}return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}}},Iv=class{constructor(n,e){this.sceneManager=n,this.renderer=e}setBackgroundColor(n){this.sceneManager.setBackground(n)}setSkybox(n){const e=new Pc().load(n);this.sceneManager.scene.background=e}enableShadows(n){}enableAntialiasing(n){}enableAmbientOcclusion(n){}addSectionPlane(n,e){return""}removeSectionPlane(n){}clearSectionPlanes(){}enableSectioning(n){}captureScreen(n,e){return this.renderer.domElement.toDataURL()}getViewerConfig(){return{shadows:!1,ambientOcclusion:!1,sectioning:!1}}getRenderStatistics(){const n=this.renderer.info||{},e=n.render||{},t=n.memory||{};return{calls:e.calls||0,triangles:e.triangles||0,points:e.points||0,lines:e.lines||0,memory:{geometries:t.geometries||0,textures:t.textures||0}}}},Uv=class{async getProperties(n){return[{name:"Identity Data",properties:[{name:"Element ID",value:n},{name:"Version",value:"V1 Engine"}]}]}async getPropertyValue(n,e){return"Unknown"}async getModelTree(n){return[{id:"root",name:"Model Root (V1)",type:"Model",hasChildren:!1}]}async search(n){return[]}},Nv=class{activeTool=null;tools=new Map;activate(n,e){console.log(`[V1] Activating tool: ${n}`,e),this.activeTool=n}deactivate(){this.activeTool&&(console.log(`[V1] Deactivating tool: ${this.activeTool}`),this.activeTool=null)}getActiveTool(){return this.activeTool}registerTool(n,e){this.tools.set(n,e)}},Bv=class{listeners=new Map;on(n,e){this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(e)}off(n,e){if(!this.listeners.has(n))return;const t=this.listeners.get(n),i=t.indexOf(e);i!==-1&&t.splice(i,1)}trigger(n,e){this.listeners.has(n)&&this.listeners.get(n).forEach(t=>{try{t(e)}catch(i){console.error(`Error in event listener for ${n}:`,i)}})}},Ov=class{container;renderer;composer=null;stats=null;engineState;sceneManager;cameraManager;loaderManager;interactionManager;outlineManager;selectionBoxManager=null;clippingManager;octreeBox;loader;cameraTool;components;data;viewer;tools;events;viewCube;scene;camera;models;controls;measure;animationId=null;constructor(n){const e=document.getElementById(n.containerId);if(!e)throw new Error(`Container ${n.containerId} not found`);this.container=e,this.models=[],this.engineState=new Sv,this.sceneManager=new S1(n);const{width:t,height:i}=this.getContainerSize();this.cameraManager=new O1(this.container,t,i,this.engineState);try{this.renderer=new Lr({antialias:n.antialias??!0}),console.log("Engine: Using WebGPURenderer")}catch(s){console.warn("WebGPURenderer failed",s),this.renderer=new Lr({antialias:n.antialias??!0})}this.renderer.setSize(t,i),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=hl,this.renderer.toneMapping=Qr,this.renderer.toneMappingExposure=1,this.renderer.localClippingEnabled=!0,this.container.appendChild(this.renderer.domElement),this.loaderManager=new _v(this.sceneManager.scene),this.outlineManager=new bv(this.sceneManager.scene,this.cameraManager.camera,t,i),this.interactionManager=new xv(this.sceneManager.scene,this.cameraManager.camera,this.renderer.domElement,this.engineState),this.selectionBoxManager=new yv(this.sceneManager.scene,this.cameraManager.camera,this.renderer.domElement,this.cameraManager.controls,this.outlineManager),this.clippingManager=new Mv(this.sceneManager.scene),setTimeout(()=>{this.clippingManager.enable()},1e3),this.events=new Bv,this.interactionManager.setEventModule(this.events),this.loader=new Pv(this.loaderManager,this.sceneManager.scene,this.clippingManager),this.cameraTool=new Lv(this.cameraManager),this.components=new Dv(this.interactionManager,this.sceneManager.scene),this.viewer=new Iv(this.sceneManager,this.renderer),this.data=new Uv,this.tools=new Nv,this.scene=this.sceneManager.scene,this.scene.camera=this.cameraManager.camera,this.camera=this.cameraManager.camera,this.controls=this.cameraManager.controls,this.octreeBox=Tv(this),this.viewCube=Rv(this,this.scene,this.container),this.viewCube.init(),this.setupVisuals(),this.setupPostProcessing(),n.showStats!==!1&&this.initStats(),this.setupResizeObserver(),this.animate()}initStats(){this.stats=new M1,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom)}toggleStats(n){n&&!this.stats?this.initStats():!n&&this.stats&&(this.container.removeChild(this.stats.dom),this.stats=null)}getVersion(){return"1.2.0 (WebGPU Experimental)"}setupVisuals(){const n=this.sceneManager.scene;n.children.filter(s=>s instanceof Pn).forEach(s=>n.remove(s));const e=new Nc(16777215,4.5);e.position.set(10,20,10),e.castShadow=!0,e.shadow.mapSize.width=4096,e.shadow.mapSize.height=4096,e.shadow.camera.near=.1,e.shadow.camera.far=500,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2,n.add(e);const i=new Bc(4210752,.4);n.add(i),new n1().load("https://raw.githubusercontent.com/mrdoob/three.js/master/examples/textures/equirectangular/royal_esplanade_1k.hdr",s=>{s.mapping=Hn,n.environment=s,n.environmentIntensity=1})}setupPostProcessing(){if(!this.renderer)return;const{width:n,height:e}=this.getContainerSize(),t=window.devicePixelRatio,i=this.sceneManager.scene,s=this.cameraManager.camera;this.composer=new c1(this.renderer),this.composer.setPixelRatio(t),this.composer.setSize(n,e);const r=new h1(i,s);this.composer.addPass(r);const a=new xi(i,s,n,e);a.output=xi.OUTPUT.Default,a.blendIntensity=1,a.updateGtaoMaterial&&a.updateGtaoMaterial({radius:3,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!1}),this.composer.addPass(a);const o=this.outlineManager.getPass();this.composer.addPass(o);const l=new nn(new oe(n,e),.05,.1,.5);this.composer.addPass(l);const c=new g1;this.composer.addPass(c);const h=new Go(v1);h.material.uniforms.resolution.value.x=1/(n*t),h.material.uniforms.resolution.value.y=1/(e*t),this.composer.addPass(h)}resize(){const{width:n,height:e}=this.getContainerSize(),t=window.devicePixelRatio;if(this.cameraManager.updateAspect(n,e),this.renderer.setSize(n,e),this.renderer.setPixelRatio(t),this.outlineManager&&this.outlineManager.resize(n,e),this.composer){this.composer.setPixelRatio(t),this.composer.setSize(n,e);const i=this.composer.passes.find(s=>s instanceof Go&&s.material.uniforms.resolution);i&&(i.material.uniforms.resolution.value.x=1/(n*t),i.material.uniforms.resolution.value.y=1/(e*t))}}getContainerSize(){return{width:this.container.clientWidth,height:this.container.clientHeight}}setupResizeObserver(){new ResizeObserver(()=>{this.resize()}).observe(this.container)}animate=()=>{this.animationId=requestAnimationFrame(this.animate),this.viewCube.RenderScene(),this.stats&&this.stats.begin(),this.cameraManager.tick(),this.composer?this.composer.render():this.renderer.renderAsync?this.renderer.renderAsync(this.sceneManager.scene,this.cameraManager.camera):this.renderer.render(this.sceneManager.scene,this.cameraManager.camera),this.stats&&this.stats.end()};dispose(){this.animationId&&cancelAnimationFrame(this.animationId),this.selectionBoxManager&&this.selectionBoxManager.dispose(),this.renderer.dispose(),this.container.innerHTML=""}};class Ih{constructor(e,t,i){this.object=e,this.id=t,this.uuid=i,this.object.name=t}get name(){return this.object.name}set name(e){this.object.name=e}get visible(){return this.object.visible}set visible(e){this.object.visible=e}getBoundingBox(){const e=new Rt().setFromObject(this.object);return{min:e.min,max:e.max}}setMatrix(e){this.object.matrix.fromArray(e),this.object.matrix.decompose(this.object.position,this.object.quaternion,this.object.scale)}}class kv{scene;gltfLoader;models=new Map;constructor(e){this.scene=e,this.gltfLoader=new Th}async loadModel(e,t){return new Promise((i,s)=>{this.gltfLoader.load(e,r=>{const a=r.scene,o=t?.id||Wa.generateUUID();t?.position&&a.position.fromArray(t.position),t?.scale&&a.scale.fromArray(t.scale),t?.rotation&&a.rotation.setFromVector3(new w(...t.rotation)),this.scene.add(a);const l=new Ih(a,o,a.uuid);this.models.set(o,l),i(l)},r=>{t?.onProgress&&t.onProgress(r.loaded/r.total*100)},r=>s(r))})}unloadModel(e){const t=this.models.get(e);t&&t instanceof Ih&&(this.scene.remove(t.object),this.models.delete(e))}getAllModels(){return Array.from(this.models.values())}getModel(e){return this.models.get(e)}}class Fv{camera;controls;container;constructor(e,t,i){this.container=e,this.camera=new St(75,t/i,.1,1e3),this.camera.position.set(10,10,10),this.camera.lookAt(0,0,0),this.controls=new Mh(this.camera,this.container),this.controls.enableDamping=!0}getCamera(){return this.camera}update(){this.controls.update()}updateAspect(e,t){if(this.camera instanceof St)this.camera.aspect=e/t,this.camera.updateProjectionMatrix();else if(this.camera instanceof ms){const i=e/t,s=20;this.camera.left=-s*i/2,this.camera.right=s*i/2,this.camera.top=s/2,this.camera.bottom=-s/2,this.camera.updateProjectionMatrix()}}setView(e,t){switch(e){case rn.Top:this.camera.position.set(0,20,0);break;case rn.Front:this.camera.position.set(0,0,20);break;default:console.warn("View not fully implemented:",e)}this.camera.lookAt(0,0,0),this.controls.update()}fitToView(e,t){}goHome(e){this.camera.position.set(10,10,10),this.camera.lookAt(0,0,0),this.controls.update()}setProjection(e){e===an.Perspective&&!(this.camera instanceof St)||e===an.Orthographic&&this.camera instanceof ms}setNavigationMode(e){e===Or.Orbit?(this.controls.enabled=!0,this.controls.enableRotate=!0):e===Or.PanOnly&&(this.controls.enableRotate=!1)}getState(){const e=this.controls.target;return{position:this.camera.position.toArray(),target:e.toArray(),up:this.camera.up.toArray(),projection:this.camera instanceof St?an.Perspective:an.Orthographic}}restoreState(e,t){this.camera.position.fromArray(e.position),this.camera.up.fromArray(e.up),this.controls.target.fromArray(e.target),this.controls.update()}}class zv{scene;selectedIds=new Set;materialCache=new Map;constructor(e){this.scene=e}findObject(e){let t;return this.scene.traverse(i=>{i.name===e&&(t=i)}),t}getSelection(){return Array.from(this.selectedIds)}select(e){this.clearSelection(),this.addSelection(e)}addSelection(e){e.forEach(t=>{this.selectedIds.add(t),this.findObject(t)})}removeSelection(e){e.forEach(t=>this.selectedIds.delete(t))}clearSelection(){this.selectedIds.clear()}getHiddenComponents(){const e=[];return this.scene.traverse(t=>{t.visible||e.push(t.name)}),e}setVisibility(e,t){e.forEach(i=>{const s=this.findObject(i);s&&(s.visible=t)})}isolate(e){this.scene.traverse(t=>t.visible=!1),this.setVisibility(e,!0)}clearIsolation(){this.scene.traverse(e=>e.visible=!0)}setColor(e,t){e.forEach(i=>{const s=this.findObject(i);if(s&&s instanceof rt){this.materialCache.has(i)||this.materialCache.set(i,s.material);const r=new Ht({color:t});s.material=r}})}restoreColor(e){e.forEach(t=>{const i=this.findObject(t);i&&this.materialCache.has(t)&&(i.material=this.materialCache.get(t),this.materialCache.delete(t))})}setOpacity(e,t){}restoreOpacity(e){}clearAllOverrides(){this.materialCache.forEach((e,t)=>{const i=this.findObject(t);i&&i instanceof rt&&(i.material=e)}),this.materialCache.clear()}getBoundingBox(e){const t=this.findObject(e);if(t){const i=new Rt().setFromObject(t);return{min:i.min,max:i.max}}return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}}}class Hv{async getProperties(e){return[{name:"Identity Data",properties:[{name:"Element ID",value:e},{name:"Name",value:"Sample Element"}]}]}async getPropertyValue(e,t){return"Unknown"}async getModelTree(e){return[{id:"root",name:"Model Root",type:"Model",hasChildren:!0,children:[{id:"l1",name:"Level 1",type:"Level",hasChildren:!1}]}]}async search(e){return console.log("Searching for:",e),[]}}class Vv{scene;renderer;_shadowsEnabled=!1;_aoEnabled=!1;_sectioningEnabled=!1;constructor(e,t){this.scene=e,this.renderer=t}setBackgroundColor(e){this.scene.background=new xe(e)}setSkybox(e){const t=new Pc().load(e);this.scene.background=t}enableShadows(e){this._shadowsEnabled=e,this.renderer.shadowMap.enabled=e,this.scene.traverse(t=>{t instanceof rt&&(t.castShadow=e,t.receiveShadow=e)})}enableAntialiasing(e){console.warn("Changing antialiasing at runtime requires recreating the WebGL context, which is complex. Ignored.")}enableAmbientOcclusion(e){this._aoEnabled=e,console.log("AO enabled:",e,"(Requires PostProcessing pass - not implemented in this basic kernel)")}addSectionPlane(e,t){const i=new Ai(new w(...e),t);return this.renderer.clippingPlanes.push(i),"plane-"+(this.renderer.clippingPlanes.length-1)}removeSectionPlane(e){this.renderer.clippingPlanes.pop()}clearSectionPlanes(){this.renderer.clippingPlanes=[]}enableSectioning(e){this._sectioningEnabled=e,this.renderer.localClippingEnabled=e}captureScreen(e,t){return this.renderer.domElement.toDataURL()}getViewerConfig(){return{shadows:this._shadowsEnabled,ambientOcclusion:this._aoEnabled,sectioning:this._sectioningEnabled}}getRenderStatistics(){const e=this.renderer.info;return{calls:e.render.calls,triangles:e.render.triangles,points:e.render.points,lines:e.render.lines,memory:{geometries:e.memory.geometries,textures:e.memory.textures}}}}class Gv{activeTool=null;tools=new Map;activate(e,t){console.log(`Activating tool: ${e}`,t),this.activeTool=e}deactivate(){this.activeTool&&(console.log(`Deactivating tool: ${this.activeTool}`),this.activeTool=null)}getActiveTool(){return this.activeTool}registerTool(e,t){this.tools.set(e,t)}}class Wv{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)}off(e,t){if(!this.listeners.has(e))return;const i=this.listeners.get(e),s=i.indexOf(t);s!==-1&&i.splice(s,1)}trigger(e,t){this.listeners.has(e)&&this.listeners.get(e).forEach(i=>{try{i(t)}catch(s){console.error(`Error in event listener for ${e}:`,s)}})}}class Uh{loader;cameraTool;components;data;viewer;tools;events;viewCube;container;scene;renderer;_cameraModule;animationId=null;constructor(e){const t=document.getElementById(e.containerId);if(!t)throw new Error(`Container ${e.containerId} not found`);this.container=t,this.scene=new go,this.renderer=new Lr({antialias:e.antialias??!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.container.appendChild(this.renderer.domElement),this.events=new Wv,this._cameraModule=new Fv(this.container,this.container.clientWidth,this.container.clientHeight),this.cameraTool=this._cameraModule,this.loader=new kv(this.scene),this.components=new zv(this.scene),this.data=new Hv,this.viewer=new Vv(this.scene,this.renderer),this.tools=new Gv,this.viewCube={show:()=>console.warn("[V2] ViewCube not implemented"),hide:()=>{},setDirection:()=>{},goHome:()=>{},isVisible:()=>!1,updateOptions:()=>{}},this.resize(),this.setupResizeObserver(),this.animate()}getVersion(){return"2.0.0"}resize(){const e=this.container.clientWidth,t=this.container.clientHeight;this.renderer.setSize(e,t),this._cameraModule.updateAspect(e,t)}dispose(){this.animationId&&cancelAnimationFrame(this.animationId),this.renderer.dispose(),this.container.innerHTML=""}setupResizeObserver(){new ResizeObserver(()=>{this.resize()}).observe(this.container)}animate=()=>{this.animationId=requestAnimationFrame(this.animate),this._cameraModule.update(),this.renderer.render(this.scene,this._cameraModule.getCamera())}}function jv(n){const e=n.version||"v1";switch(e){case"v2":return new Uh(n);case"v1":return new Ov(n);default:return console.warn(`Version '${e}' not found. Falling back to v2.`),new Uh(n)}}class Xv{engine=null;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e){this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={backgroundColor:e.backgroundColor??1710618,version:e.version??"v1",showStats:e.showStats??!1,showViewCube:e.showViewCube??!0}}init(){if(this._isInitialized){console.warn("[Engine] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine] Cannot initialize destroyed engine.");return}try{const e={containerId:this.containerId,backgroundColor:this.options.backgroundColor,version:this.options.version,showStats:this.options.showStats,showViewCube:this.options.showViewCube};if(this.engine=jv(e),!this.engine)throw new Error("Failed to create engine instance");this._isInitialized=!0,this.unsubscribeTheme=Ze.subscribe(t=>{this.setTheme(t)}),this.setTheme(Ze.getTheme())}catch(e){throw console.error("[Engine] Failed to initialize engine:",e),this._isInitialized=!1,e}}setTheme(e){if(!this._isInitialized||!this.engine)return;let t;e.name==="dark"?t=1710618:e.name==="light"?t=16119285:t=this.options.backgroundColor??1710618,this.engine&&typeof this.engine.setBackgroundColor=="function"?this.engine.setBackgroundColor(t):this.engine&&this.engine.scene&&this.engine.scene.background&&this.engine.scene.background.setHex(t)}setLocales(){}isInitialized(){return this._isInitialized}loadModel(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine] Engine not initialized. Please call init() first.");return}if(!e){console.error("[Engine] Model URL is required.");return}this.engine.loader.loadModel(e,t)}getEngine(){return this.engine}destroy(){this._isDestroyed||(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1)}}class qv{element;content=null;isVisible=!1;onCloseCallback;options;mouseDownTime=0;CLICK_THRESHOLD=200;constructor(e){this.options=e,this.element=document.createElement("div"),this.element.className=`bim-right-key ${e?.className||""}`,e?.zIndex&&(this.element.style.zIndex=e.zIndex.toString()),document.body.appendChild(this.element)}init(){document.addEventListener("mousedown",this.handleGlobalClick),this.element.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation()}),this.options?.container&&(this.options.container.addEventListener("mousedown",this.handleContainerMouseDown),this.options.container.addEventListener("mouseup",this.handleContainerMouseUp),this.options.container.addEventListener("contextmenu",this.handleContainerContextMenu))}setTheme(e){}setLocales(){}destroy(){document.removeEventListener("mousedown",this.handleGlobalClick),this.options?.container&&(this.options.container.removeEventListener("mousedown",this.handleContainerMouseDown),this.options.container.removeEventListener("mouseup",this.handleContainerMouseUp),this.options.container.removeEventListener("contextmenu",this.handleContainerContextMenu)),this.unmountContent(),this.element.remove()}handleContainerMouseDown=e=>{e.button===2&&(this.mouseDownTime=Date.now())};handleContainerMouseUp=e=>{e.button!==2||Date.now()-this.mouseDownTime>this.CLICK_THRESHOLD||this.options?.onContext&&this.options.onContext(e)};handleContainerContextMenu=e=>{e.preventDefault()};setOnClose(e){this.onCloseCallback=e}mount(e){this.unmountContent(),this.content=e,this.element.appendChild(e.getElement())}unmountContent(){this.content&&(this.content.destroy(),this.element.innerHTML="",this.content=null)}show(e,t){this.element.classList.add("visible"),this.isVisible=!0,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`;const i=this.element.getBoundingClientRect(),s=window.innerWidth,r=window.innerHeight;let a=e,o=t;e+i.width>s&&(a=e-i.width),t+i.height>r&&(o=t-i.height),this.element.style.left=`${a}px`,this.element.style.top=`${o}px`}hide(){this.element.classList.remove("visible"),this.isVisible=!1,this.unmountContent(),this.onCloseCallback&&this.onCloseCallback()}handleGlobalClick=e=>{this.isVisible&&(this.element.contains(e.target)||this.hide())}}class il{element;options;unsubscribeLocale=null;unsubscribeTheme=null;activeSubMenu=null;constructor(e){this.options=e,this.element=document.createElement("ul"),this.element.className="bim-menu"}init(){this.render(),this.unsubscribeLocale=Dt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=Ze.subscribe(e=>{this.setTheme(e)})}setTheme(e){const t=this.element.style;t.setProperty("--bim-ui_bg_color",e.panelBackground),t.setProperty("--bim-ui_text_primary",e.textPrimary),t.setProperty("--bim-ui_border_color",e.border),t.setProperty("--bim-ui_bg_hover",e.componentHover)}setLocales(){this.element.innerHTML="",this.render()}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.closeSubMenu(),this.element.remove()}getElement(){return this.element}render(){const{items:e,groupOrder:t}=this.options,i=new Map,s="default";e.forEach(a=>{const o=a.group||s;i.has(o)||i.set(o,[]),i.get(o).push(a)});let r=[];if(t){r=t.filter(a=>i.has(a));for(const a of i.keys())r.includes(a)||r.push(a)}else r=Array.from(i.keys());r.forEach((a,o)=>{if(o>0){const c=document.createElement("li");c.className="bim-menu-divider",this.element.appendChild(c)}const l=i.get(a);l.sort((c,h)=>(c.order||0)-(h.order||0)),l.forEach(c=>{c.visible!==!1&&this.element.appendChild(this.createItemElement(c))})})}createItemElement(e){const t=document.createElement("li"),i=!e.disabled;t.className=`bim-menu-item ${i?"":"disabled"}`;const s=document.createElement("div");s.className="bim-menu-item-icon",e.icon&&(s.innerHTML=e.icon),t.appendChild(s);const r=document.createElement("div");r.className="bim-menu-item-label",r.textContent=le(e.label),t.appendChild(r);const a=e.children,o=a&&a.length>0;if(o){const l=document.createElement("div");l.className="bim-menu-item-arrow",l.innerHTML='',t.appendChild(l),t.addEventListener("mouseenter",()=>this.openSubMenu(e,t))}else t.addEventListener("mouseenter",()=>this.closeSubMenu());return i&&t.addEventListener("click",l=>{l.stopPropagation(),console.log(`[BimMenu] Clicked item: ${e.id}`),o||(e.onClick?(console.log(`[BimMenu] Executing onClick for ${e.id}`),e.onClick()):console.warn(`[BimMenu] No onClick handler for ${e.id}`))}),t}openSubMenu(e,t){const i=e.children;if(!i||i.length===0)return;this.closeSubMenu();const s=document.createElement("div");s.style.position="fixed",s.style.zIndex="10001";const r=t.getBoundingClientRect();s.style.top=`${r.top}px`,s.style.left=`${r.right}px`,s.addEventListener("mousedown",l=>l.stopPropagation());const a=new il({items:i});a.init(),s.appendChild(a.element),document.body.appendChild(s),this.activeSubMenu={menu:a,container:s};const o=s.getBoundingClientRect();o.right>window.innerWidth&&(s.style.left=`${r.left-o.width}px`)}closeSubMenu(){this.activeSubMenu&&(this.activeSubMenu.menu.destroy(),this.activeSubMenu.container.remove(),this.activeSubMenu=null)}}class Nh extends jt{container;rightKeyPanel;contextHandlers=[];constructor(e,t){super(e),this.container=t,this.rightKeyPanel=new qv({zIndex:9e3,container:this.container,onContext:this.handleContextMenu}),this.rightKeyPanel.init()}destroy(){this.rightKeyPanel.destroy()}registerHandler(e){this.contextHandlers.push(e)}showMenu(e,t,i,s){if(!i||i.length===0)return;const r=new il({items:i,groupOrder:s});r.init(),this.rightKeyPanel.mount(r),this.rightKeyPanel.show(e,t)}hide(){this.rightKeyPanel.hide()}handleContextMenu=e=>{let t=null;for(const i of this.contextHandlers){const s=i(e);s&&s.length>0&&(t||(t=[]),t=t.concat(s))}t&&t.length>0?this.showMenu(e.clientX,e.clientY,t):this.hide()}}const Zv=n=>({id:"infoMenu",label:"menu.info",group:"info",icon:'',onClick:()=>{console.log("dianjile"),n.dialog?.showInfoDialog(),n.engine?.rightKey?.hide()}}),Yv=n=>({id:"fourMenu",label:"menu.info",icon:'',onClick:()=>{console.log("dianjile"),n.dialog?.showInfoDialog(),n.engine?.rightKey?.hide()}}),Kv=n=>({id:"infoMenu",label:"menu.info",icon:'',onClick:()=>{console.log("dianjile"),n.dialog?.showInfoDialog(),n.engine?.rightKey?.hide()}}),$v=n=>({id:"homeMenu",label:"menu.home",group:"home",children:[Kv(n),Yv(n)],icon:'',onClick:()=>{n.dialog?.showInfoDialog(),n.engine?.rightKey?.hide()}});class Jv extends jt{container;engineInstance=null;rightKey=null;constructor(e,t){super(e),this.container=t}initialize(e){this.engineInstance&&this.engineInstance.isInitialized()&&(console.warn("[EngineManager] 3D Engine already initialized. Destroying old instance..."),this.engineInstance.destroy(),this.engineInstance=null);try{return this.engineInstance=new Xv({container:this.container,...e}),this.engineInstance.init(),this.rightKey=new Nh(this.engine,this.container),this.rightKey.registerHandler(t=>[Zv(this.engine),$v(this.engine)]),this.engineInstance.isInitialized()}catch(t){return console.error("[EngineManager] Failed to initialize 3D engine:",t),this.engineInstance=null,!1}}isInitialized(){return this.engineInstance!==null&&this.engineInstance.isInitialized()}loadModel(e,t){if(!this.engineInstance||!this.engineInstance.isInitialized()){console.error("[EngineManager] 3D Engine not initialized. Please call initialize() first.");return}this.engineInstance.loadModel(e,t)}getEngine(){return this.engineInstance?this.engineInstance.getEngine():(console.warn("[EngineManager] 3D Engine not initialized."),null)}destroy(){this.engineInstance&&(this.engineInstance.destroy(),this.engineInstance=null),this.rightKey&&(this.rightKey.destroy(),this.rightKey=null)}}var gt=(n=>(n[n.Unchecked=0]="Unchecked",n[n.Checked=1]="Checked",n[n.Indeterminate=2]="Indeterminate",n))(gt||{});class Qv{config;element;children=[];parent=null;checkState=gt.Unchecked;contentEl;switcherEl;checkboxEl=null;titleEl;actionsEl;childrenContainer;onExpandChange;onCheckChange;onNodeClick;renderActions;constructor(e,t,i){this.config=e,this.onExpandChange=i.onExpand,this.onCheckChange=i.onCheck,this.onNodeClick=i.onClick,this.renderActions=t.renderActions,this.checkState=e.checked?gt.Checked:gt.Unchecked,this.element=this.createDom(t)}createDom(e){const t=document.createElement("div");t.className="bim-tree-node",this.config.disabled&&t.classList.add("is-disabled"),this.contentEl=document.createElement("div"),this.contentEl.className="bim-tree-node-content",this.switcherEl=document.createElement("span"),this.switcherEl.className="bim-tree-switcher",this.switcherEl.innerHTML='';const i=this.config.children&&this.config.children.length>0;if(i?this.config.expanded&&this.switcherEl.classList.add("is-expanded"):this.switcherEl.classList.add("is-hidden"),this.switcherEl.addEventListener("click",r=>{r.stopPropagation(),this.toggleExpand()}),this.contentEl.appendChild(this.switcherEl),e.checkable!==!1&&(this.checkboxEl=document.createElement("span"),this.checkboxEl.className="bim-tree-checkbox",this.updateCheckboxUI(),this.checkboxEl.addEventListener("click",r=>{r.stopPropagation(),!this.config.disabled&&this.toggleCheck()}),this.contentEl.appendChild(this.checkboxEl)),this.config.icon){const r=document.createElement("span");r.className="bim-tree-icon",r.innerHTML=this.config.icon.includes("`,this.contentEl.appendChild(r)}this.titleEl=document.createElement("span"),this.titleEl.className="bim-tree-title",this.updateLabel(),this.contentEl.appendChild(this.titleEl),this.actionsEl=document.createElement("div"),this.actionsEl.className="bim-tree-node-actions",this.actionsEl.addEventListener("click",r=>{r.stopPropagation()}),this.contentEl.appendChild(this.actionsEl),this.contentEl.addEventListener("click",r=>{if(r.stopPropagation(),this.config.disabled)return;(this.config.clickAction||"select")==="expand"?this.toggleExpand():this.onNodeClick(this)}),t.appendChild(this.contentEl),this.childrenContainer=document.createElement("div"),this.childrenContainer.className="bim-tree-children";const s=e.indent||24;return this.childrenContainer.style.paddingLeft=`${s}px`,this.config.expanded&&i&&this.childrenContainer.classList.add("is-visible"),t.appendChild(this.childrenContainer),t}setSelected(e){if(e){if(this.contentEl.classList.add("is-selected"),this.renderActions){const t=this.renderActions(this.config);this.actionsEl.innerHTML="",typeof t=="string"?this.actionsEl.innerHTML=t:t instanceof HTMLElement&&this.actionsEl.appendChild(t)}}else this.contentEl.classList.remove("is-selected"),this.actionsEl.innerHTML=""}updateLabel(){this.titleEl&&(this.titleEl.textContent=this.config.label)}toggleExpand(e){if(!this.config.children||this.config.children.length===0)return;const t=e!==void 0?e:!this.config.expanded;this.config.expanded=t,t?(this.switcherEl.classList.add("is-expanded"),this.childrenContainer.classList.add("is-visible")):(this.switcherEl.classList.remove("is-expanded"),this.childrenContainer.classList.remove("is-visible")),e===void 0&&this.onExpandChange(this)}toggleCheck(){const e=this.checkState!==gt.Checked;this.setChecked(e?gt.Checked:gt.Unchecked,!0)}setChecked(e,t=!1){this.checkState!==e&&(this.checkState=e,this.config.checked=e===gt.Checked,this.updateCheckboxUI(),t&&this.onCheckChange(this))}updateCheckboxUI(){this.checkboxEl&&(this.checkboxEl.classList.remove("is-checked","is-indeterminate"),this.checkState===gt.Checked?this.checkboxEl.classList.add("is-checked"):this.checkState===gt.Indeterminate&&this.checkboxEl.classList.add("is-indeterminate"))}appendChild(e){e.parent=this,this.children.push(e),this.childrenContainer.appendChild(e.element),this.children.length===1&&this.switcherEl.classList.remove("is-hidden")}destroy(){this.children.forEach(e=>e.destroy()),this.children=[],this.element.remove(),this.parent=null}}class e_{element;contentElement;searchInput=null;searchResults=null;options;nodeMap=new Map;rootNodes=[];selectedNode=null;unsubscribeLocale=null;unsubscribeTheme=null;clickOutsideHandler=null;onNodeCheck;onNodeSelect;onNodeExpand;constructor(e){this.options={checkable:!0,checkStrictly:!0,indent:24,defaultExpandAll:!0,enableSearch:!1,searchPlaceholder:"tree.searchPlaceholder",...e},this.element=document.createElement("div"),this.element.className="bim-tree",this.options.enableSearch&&this.createSearchDOM(),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tree-content",this.element.appendChild(this.contentElement),e.onNodeCheck&&(this.onNodeCheck=e.onNodeCheck),e.onNodeSelect&&(this.onNodeSelect=e.onNodeSelect),e.onNodeExpand&&(this.onNodeExpand=e.onNodeExpand)}createSearchDOM(){const e=document.createElement("div");e.className="bim-tree-search";const t=document.createElement("div");t.className="bim-tree-search-wrapper";const i=document.createElement("span");i.className="bim-tree-search-icon",i.innerHTML='',t.appendChild(i),this.searchInput=document.createElement("input"),this.searchInput.className="bim-tree-search-input",this.searchInput.type="text",this.searchInput.placeholder=le(this.options.searchPlaceholder||"搜索..."),this.searchInput.addEventListener("input",s=>{const r=s.target.value;this.handleSearch(r)}),t.appendChild(this.searchInput),e.appendChild(t),this.searchResults=document.createElement("div"),this.searchResults.className="bim-tree-search-results",e.appendChild(this.searchResults),this.element.appendChild(e),this.clickOutsideHandler=s=>{this.searchResults&&!this.searchResults.contains(s.target)&&!this.searchInput?.contains(s.target)&&this.searchResults.classList.remove("is-visible")},document.addEventListener("click",this.clickOutsideHandler)}init(){this.render(),this.unsubscribeLocale=Dt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=Ze.subscribe(e=>this.setTheme(e)),this.setTheme(Ze.getTheme())}handleSearch(e){if(!this.searchResults)return;if(!e.trim()){this.searchResults.classList.remove("is-visible"),this.searchResults.innerHTML="";return}const t=[],i=e.toLowerCase();this.nodeMap.forEach(s=>{const r=s.config.label;r.toLowerCase().includes(i)&&t.push({node:s,label:r,path:this.getNodePath(s)})}),this.renderSearchResults(t)}getNodePath(e){const t=[];let i=e.parent;for(;i;)t.unshift(i.config.label),i=i.parent;return t.join(" > ")}renderSearchResults(e){if(this.searchResults){if(this.searchResults.innerHTML="",e.length===0){const t=document.createElement("div");t.className="bim-tree-search-item",t.style.cursor="default",t.style.color="#999",t.textContent="No results",this.searchResults.appendChild(t)}else e.forEach(t=>{const i=document.createElement("div");i.className="bim-tree-search-item";const s=document.createElement("span");s.className="bim-tree-search-item-title",s.textContent=t.label;const r=document.createElement("span");r.className="bim-tree-search-item-path",r.textContent=t.path,i.appendChild(s),t.path&&i.appendChild(r),i.addEventListener("click",()=>{this.revealNode(t.node)}),this.searchResults.appendChild(i)});this.searchResults.classList.add("is-visible")}}revealNode(e){this.searchResults&&(this.searchResults.classList.remove("is-visible"),this.searchInput&&(this.searchInput.value=""));let t=e.parent;for(;t;)t.toggleExpand(!0),t=t.parent;this.handleNodeSelect(e),setTimeout(()=>{e.element.scrollIntoView({behavior:"smooth",block:"center"})},100)}setTheme(e){const t=this.element.style;t.setProperty("--bim-ui_bg_color",e.panelBackground),t.setProperty("--bim-ui_text_primary",e.textPrimary),t.setProperty("--bim-ui_text_secondary",e.textSecondary||"#999"),t.setProperty("--bim-ui_border_color",e.border),t.setProperty("--bim-ui_bg_hover",e.componentHover),t.setProperty("--bim-primary_color",e.primary)}setLocales(){this.nodeMap.forEach(e=>e.updateLabel()),this.searchInput&&(this.searchInput.placeholder=le(this.options.searchPlaceholder||"tree.searchPlaceholder"))}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null),this.rootNodes.forEach(e=>e.destroy()),this.rootNodes=[],this.nodeMap.clear(),this.element.remove(),this.selectedNode=null}render(){this.contentElement.innerHTML="",this.nodeMap.clear(),this.rootNodes=[],this.options.data.forEach(e=>{this.createNodeRecursively(e,null)})}createNodeRecursively(e,t){e.expanded===void 0&&(e.expanded=this.options.defaultExpandAll);const i=new Qv(e,this.options,{onExpand:s=>{this.onNodeExpand&&this.onNodeExpand(s)},onCheck:s=>this.handleNodeCheck(s),onClick:s=>this.handleNodeSelect(s)});this.nodeMap.set(e.id,i),t?t.appendChild(i):(this.rootNodes.push(i),this.contentElement.appendChild(i.element)),e.children&&e.children.length>0&&e.children.forEach(s=>{this.createNodeRecursively(s,i)})}handleNodeSelect(e){this.selectedNode&&this.selectedNode!==e&&this.selectedNode.setSelected(!1),e.setSelected(!0),this.selectedNode=e,this.onNodeSelect&&this.onNodeSelect(e)}handleNodeCheck(e){const t=e.checkState===gt.Checked;if(this.onNodeCheck&&this.onNodeCheck(e),this.options.checkStrictly===!1)return;const i=(r,a)=>{r.children.forEach(o=>{o.config.disabled||(o.setChecked(a,!1),i(o,a))})};t?i(e,gt.Checked):i(e,gt.Unchecked);let s=e.parent;for(;s;){if(s.config.disabled){s=s.parent;continue}const r=s.children,a=r.every(l=>l.checkState===gt.Checked),o=r.every(l=>l.checkState===gt.Unchecked);a?s.setChecked(gt.Checked,!1):o?s.setChecked(gt.Unchecked,!1):s.setChecked(gt.Indeterminate,!1),s=s.parent}}getNode(e){return this.nodeMap.get(e)}checkNode(e,t){const i=this.nodeMap.get(e);i&&i.setChecked(t?gt.Checked:gt.Unchecked,!0)}expandAll(e){this.nodeMap.forEach(t=>t.toggleExpand(e))}getCheckedNodes(e=!1){const t=[];return this.nodeMap.forEach(i=>{(i.checkState===gt.Checked||e&&i.checkState===gt.Indeterminate)&&t.push(i.config)}),t}}class Bh{element;navElement;contentElement;options;activeId;tabMap=new Map;panelMap=new Map;unsubscribeLocale=null;unsubscribeTheme=null;navClickHandler=null;constructor(e){this.options=e,this.activeId=e.activeId||(e.tabs[0]?.id??null),e.tabs.forEach(t=>this.tabMap.set(t.id,t)),this.element=document.createElement("div"),this.element.className="bim-tab",this.navElement=document.createElement("div"),this.navElement.className="bim-tab__nav",this.navElement.setAttribute("role","tablist"),this.element.appendChild(this.navElement),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tab__content",this.element.appendChild(this.contentElement),this.options.container.appendChild(this.element)}init(){this.renderNav(),this.renderPanels(),this.setLocales(),this.setTheme(Ze.getTheme()),this.unsubscribeLocale=Dt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=Ze.subscribe(e=>this.setTheme(e))}renderNav(){this.navElement.innerHTML="",this.navClickHandler=e=>{const t=e.target.closest(".bim-tab__item");if(!t)return;const i=t.dataset.id;!i||this.tabMap.get(i)?.disabled||this.activateTab(i)},this.navElement.addEventListener("click",this.navClickHandler),this.options.tabs.forEach(e=>{const t=document.createElement("button");if(t.type="button",t.className="bim-tab__item",t.dataset.id=e.id,t.setAttribute("role","tab"),t.id=`tab-${e.id}`,t.setAttribute("aria-selected",`${e.id===this.activeId}`),e.disabled&&(t.disabled=!0,t.setAttribute("aria-disabled","true"),t.classList.add("is-disabled")),e.icon){const s=document.createElement("span");s.className="bim-tab__icon",s.innerHTML=e.icon,t.appendChild(s)}const i=document.createElement("span");i.className="bim-tab__title",i.textContent=this.resolveTitle(e.title),t.appendChild(i),e.id===this.activeId&&t.classList.add("is-active"),this.navElement.appendChild(t)})}renderPanels(){this.contentElement.innerHTML="",this.panelMap.clear(),this.options.tabs.forEach(e=>{const t=document.createElement("div");t.className="bim-tab__panel",t.dataset.id=e.id,t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",`tab-${e.id}`),e.content instanceof HTMLElement?t.appendChild(e.content):typeof e.content=="string"&&(t.innerHTML=e.content),e.id===this.activeId?t.classList.add("is-active"):t.style.display="none",this.panelMap.set(e.id,t),this.contentElement.appendChild(t)})}activateTab(e){if(this.activeId===e)return;const t=this.tabMap.get(e);if(!t||t.disabled)return;this.activeId=e,this.navElement.querySelectorAll(".bim-tab__item").forEach(s=>{const r=s.dataset.id===e;s.classList.toggle("is-active",r),s.setAttribute("aria-selected",`${r}`)}),this.panelMap.forEach((s,r)=>{const a=r===e;s.classList.toggle("is-active",a),s.style.display=a?"block":"none"}),this.options.onChange&&this.options.onChange(e,t)}setTheme(e){const t=this.element.style;t.setProperty("--bim-tab-bg",e.panelBackground),t.setProperty("--bim-tab-nav-bg",e.panelBackground),t.setProperty("--bim-tab-text",e.textPrimary),t.setProperty("--bim-tab-text-secondary",e.textSecondary),t.setProperty("--bim-tab-text-active",e.primary),t.setProperty("--bim-tab-border",e.border),t.setProperty("--bim-tab-hover-bg",e.componentHover),t.setProperty("--bim-tab-active-bg",e.componentActive),t.setProperty("--bim-tab-icon",e.icon)}setLocales(){this.navElement.querySelectorAll(".bim-tab__item").forEach(t=>{const i=t.dataset.id;if(!i)return;const s=this.tabMap.get(i);if(!s)return;const r=t.querySelector(".bim-tab__title");r&&(r.textContent=this.resolveTitle(s.title))})}destroy(){this.navClickHandler&&(this.navElement.removeEventListener("click",this.navClickHandler),this.navClickHandler=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.panelMap.clear(),this.tabMap.clear(),this.element.remove()}resolveTitle(e){try{return le(e)||e}catch{return e}}}const Oh={测量:'',地图:'',框选放大:'',漫游:'',目录树:'',剖切:'',剖切盒:'',全屏:'',设置:'',拾曲面剖切:'',轴向剖切:'',主视角:'',文档:'',标高:'',距离:'',最小距离:'',激光边距:'',角度:'',坡度:'',体积:'',空间体积:'',close:'',check:'',warning:'',error:'',success:'',plus:'',minus:'',arrowUp:'',arrowDown:'',arrowLeft:'',arrowRight:'',search:'',refresh:'',delete:'',edit:'',save:'',expand:'',collapse:'',default:''};function Ft(n){const e=Oh[n];return e||(console.warn(`[IconManager] Icon "${n}" not found, using default icon`),Oh.default)}const t_=[{id:"root",label:"全部构件",expanded:!0,clickAction:"expand",children:[{id:"level-1",label:"一层",expanded:!1,icon:'',clickAction:"expand",children:[{id:"l1-wall",label:"墙体(128)"},{id:"l1-column",label:"柱(46)"},{id:"l1-beam",label:"梁(82)"},{id:"l1-slab",label:"楼板(12)"},{id:"l1-door",label:"门(24)"},{id:"l1-window",label:"窗(36)"}]},{id:"level-2",label:"二层",expanded:!1,clickAction:"expand",children:[{id:"l2-wall",label:"墙体(141)"},{id:"l2-column",label:"柱(52)"},{id:"l2-beam",label:"梁(90)"},{id:"l2-slab",label:"楼板(12)"},{id:"l2-door",label:"门(18)"},{id:"l2-window",label:"窗(40)"}]},{id:"level-3",label:"三层",expanded:!1,clickAction:"expand",children:[{id:"l3-wall",label:"墙体(136)"},{id:"l3-column",label:"柱(48)"},{id:"l3-beam",label:"梁(88)"},{id:"l3-slab",label:"楼板(12)"},{id:"l3-door",label:"门(16)"},{id:"l3-window",label:"窗(38)"}]},{id:"level-roof",label:"屋面层",expanded:!1,clickAction:"expand",children:[{id:"rf-slab",label:"屋面板(6)"},{id:"rf-beam",label:"屋面梁(24)"},{id:"rf-parapet",label:"女儿墙(18)"}]}]}];class i_ extends jt{toolbar=null;toolbarContainer=null;container;dialog=null;constructor(e,t){super(e),this.container=t,this.init()}init(){this.toolbarContainer=document.createElement("div"),this.toolbarContainer.id="bim-construct-tree",this.container.appendChild(this.toolbarContainer),this.toolbar=new zr({container:this.toolbarContainer,showLabel:!1,direction:"column",position:"top-left",align:"vertical",expand:"up"}),this.toolbar.init(),this.toolbar.setEngine(this.engine),this.toolbar.addGroup("construct-tree"),this.toolbar.addButton({id:"construct-tree-btn",groupId:"construct-tree",type:"button",label:"construct-tree",icon:Ft("目录树"),onClick:()=>{this.openConstructTreeDialog()}}),this.toolbar.render()}openConstructTreeDialog(){this.setVisible(!1);const e=new e_({data:t_,checkable:!0,indent:0,enableSearch:!0,checkStrictly:!0,defaultExpandAll:!0,renderActions:o=>'',onNodeCheck:o=>{console.log("onNodeCheck",o)},onNodeSelect:o=>{console.log("onNodeSelect",o)},onNodeExpand:o=>{console.log("onNodeExpand",o),this.dialog?.fitWidth()}});e.init();const t=document.createElement("div");t.className="construct-tab__panel-content";const i=document.createElement("div");i.className="construct-tab__panel-content";const s=document.createElement("div");s.className="construct-tab__panel-content",s.appendChild(e.element);const r=document.createElement("div");r.className="construct-tab__container",r.style.height="100%",r.style.overflow="hidden";const a=new Bh({container:r,tabs:[{id:"component",title:"tab.component",content:s},{id:"system",title:"tab.system",content:t},{id:"space",title:"tab.space",content:i}],activeId:"component",onChange:()=>{this.dialog?.fitWidth()}});a.init(),this.dialog=this.engine.dialog.create({title:"constructTree.title",minWidth:320,height:420,content:r,position:{x:20,y:20},resizable:!1,onClose:()=>{a.destroy(),e.destroy(),this.setVisible(!0)}}),this.dialog?.fitWidth()}refresh(){this.toolbar?.render()}destroy(){this.toolbar?.destroy(),this.toolbar=null}addGroup(e,t){this.toolbar?.addGroup(e,t),this.toolbar?.render()}addButton(e){this.toolbar?.addButton(e),this.toolbar?.render()}setButtonVisibility(e,t){this.toolbar?.updateButtonVisibility(e,t)}setShowLabel(e){this.toolbar?.setShowLabel(e)}setVisible(e){this.toolbarContainer&&(this.toolbarContainer.style.visibility=e?"visible":"hidden")}setBackgroundColor(e){this.toolbar?.setBackgroundColor(e)}setColors(e){this.toolbar?.setColors(e)}}class s_{element;headerEl;contentEl;contentBoxEl;arrowEl;titleEl;config;parent;constructor(e,t){this.config=e,this.parent=t,this.element=this.createDom()}createDom(){const e=document.createElement("div");if(e.className=`bim-collapse-item ${this.config.className||""}`,this.config.disabled&&e.classList.add("is-disabled"),e.dataset.id=this.config.id,this.headerEl=document.createElement("div"),this.headerEl.className="bim-collapse-header",this.arrowEl=document.createElement("span"),this.arrowEl.className="bim-collapse-arrow",this.arrowEl.innerHTML='',this.headerEl.appendChild(this.arrowEl),this.config.icon){const t=document.createElement("span");t.className="bim-collapse-icon",t.innerHTML=this.config.icon,this.headerEl.appendChild(t)}if(this.titleEl=document.createElement("span"),this.titleEl.className="bim-collapse-title",this.titleEl.textContent=le(this.config.title),this.headerEl.appendChild(this.titleEl),this.config.extra){const t=document.createElement("div");t.className="bim-collapse-extra",typeof this.config.extra=="string"?t.innerHTML=this.config.extra:t.appendChild(this.config.extra),this.headerEl.appendChild(t)}return this.headerEl.addEventListener("click",()=>{this.config.disabled||this.parent.toggleItem(this.config.id)}),e.appendChild(this.headerEl),this.contentEl=document.createElement("div"),this.contentEl.className="bim-collapse-content is-hidden",this.contentBoxEl=document.createElement("div"),this.contentBoxEl.className="bim-collapse-content-box",typeof this.config.content=="string"?this.contentBoxEl.innerHTML=this.config.content:this.contentBoxEl.appendChild(this.config.content),this.contentEl.appendChild(this.contentBoxEl),e.appendChild(this.contentEl),e}updateLocale(){this.titleEl&&(this.titleEl.textContent=le(this.config.title))}setActive(e){e?(this.element.classList.add("is-active"),this.contentEl.classList.remove("is-hidden")):(this.element.classList.remove("is-active"),this.contentEl.classList.add("is-hidden"))}}class kh{element;options;items=new Map;activeIds=new Set;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e){this.options={bordered:!0,accordion:!1,...e},this.element=document.createElement("div"),this.element.className=`bim-collapse ${this.options.className||""}`,this.options.bordered||(this.element.style.border="none"),this.options.ghost&&this.element.classList.add("is-ghost");const t=typeof this.options.container=="string"?document.getElementById(this.options.container):this.options.container;t&&t.appendChild(this.element),this.options.activeIds&&this.options.activeIds.forEach(i=>this.activeIds.add(i)),this.init()}init(){this.options.items.forEach(e=>{const t=new s_(e,this);this.items.set(e.id,t),this.element.appendChild(t.element),this.activeIds.has(e.id)&&t.setActive(!0)}),this.unsubscribeLocale=Dt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=Ze.subscribe(e=>{this.setTheme(e)}),this.setTheme(Ze.getTheme())}toggleItem(e){const t=this.activeIds.has(e);this.options.accordion?(this.activeIds.clear(),t||this.activeIds.add(e)):t?this.activeIds.delete(e):this.activeIds.add(e),this.refreshState(),this.options.onChange&&this.options.onChange(Array.from(this.activeIds))}refreshState(){this.items.forEach((e,t)=>{e.setActive(this.activeIds.has(t))})}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-color",e.panelBackground),t.setProperty("--bim-border-color",e.border),t.setProperty("--bim-text-color",e.textPrimary),t.setProperty("--bim-header-bg-color",e.componentHover),t.setProperty("--bim-header-hover-bg-color",e.componentHover),t.setProperty("--bim-content-bg-color",e.panelBackground),t.setProperty("--bim-disabled-color",e.textSecondary)}setLocales(){this.items.forEach(e=>e.updateLocale())}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove(),this.items.clear()}}class sl{element;options;unsubscribeTheme=null;constructor(e){this.options={bordered:!1,...e},this.element=this.createDom();const t=typeof this.options.container=="string"?document.getElementById(this.options.container):this.options.container;t&&t.appendChild(this.element),this.init()}init(){this.applyCustomStyles(),this.renderItems(),this.unsubscribeTheme=Ze.subscribe(e=>{this.setTheme(e)}),this.setTheme(Ze.getTheme())}createDom(){const e=document.createElement("div");return e.className=`bim-description ${this.options.className||""}`,this.options.bordered&&e.classList.add("is-bordered"),e}applyCustomStyles(){const e=this.element.style;this.options.fontSize&&e.setProperty("--bim-desc-font-size",this.options.fontSize),this.options.labelColor&&e.setProperty("--bim-desc-label-color",this.options.labelColor),this.options.valueColor&&e.setProperty("--bim-desc-value-color",this.options.valueColor),this.options.labelPadding&&e.setProperty("--bim-desc-label-padding",this.options.labelPadding),this.options.valuePadding&&e.setProperty("--bim-desc-value-padding",this.options.valuePadding)}renderItems(){this.element.innerHTML="",this.options.items.forEach(e=>{const t=document.createElement("div");t.className=`bim-description-item ${e.className||""}`;const i=document.createElement("div");i.className="bim-description-label",e.labelColor&&(i.style.color=e.labelColor),this.options.labelWidth&&(i.style.width=this.options.labelWidth),i.textContent=this.options.bordered?e.label:e.label+":";const s=document.createElement("div");s.className="bim-description-value",e.valueColor&&(s.style.color=e.valueColor),typeof e.value=="string"?s.innerHTML=e.value:s.appendChild(e.value),t.appendChild(i),t.appendChild(s),this.element.appendChild(t)})}setItems(e){this.options.items=e,this.renderItems()}setTheme(e){const t=this.element.style;t.setProperty("--bim-text-color",e.textPrimary),t.setProperty("--bim-label-color",e.textSecondary),t.setProperty("--bim-value-color",e.textPrimary),t.setProperty("--bim-border-color",e.border)}setLocales(){}destroy(){this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}}class n_ extends jt{dialogId="property-panel-dialog";dialog=null;constructor(e){super(e)}init(){document.addEventListener("bim-demo:open-property-panel",()=>{this.show()})}show(){if(!this.engine.dialog){console.warn("Dialog manager is not initialized");return}if(this.isOpen())return;const e=360,t=document.body.clientWidth-e-40;console.log("x",t),this.dialog=this.engine.dialog.create({id:this.dialogId,title:"panel.property.title",content:"",width:`${e}px`,height:"500px",position:{x:t,y:20},showMask:!1,resizable:!0,onClose:()=>{this.hide()}});const i=document.createElement("div");i.style.height="100%",i.style.display="flex",i.style.flexDirection="column",this.dialog.setContent(i),new Bh({container:i,tabs:[{id:"props",title:"panel.property.tab.props",content:this.createPropsTabContent()},{id:"material",title:"panel.property.tab.material",content:this.createMaterialTabContent()}]}).init()}createPropsTabContent(){const e=document.createElement("div");return e.style.height="100%",e.style.overflowY="auto",new kh({container:e,accordion:!0,activeIds:["base","location"],items:[{id:"base",title:"panel.property.base",content:this.createBaseInfoContent()},{id:"advanced",title:"panel.property.advanced",content:this.createAdvancedInfoContent(),disabled:!1}]}),e}createMaterialTabContent(){const e=document.createElement("div");return e.style.height="100%",e.style.overflowY="auto",new kh({container:e,accordion:!0,activeIds:["material"],items:[{id:"material",title:"panel.property.material",content:this.createMaterialContent()}]}),e}createBaseInfoContent(){const e=document.createElement("div");return new sl({container:e,labelWidth:"80px",bordered:!0,items:[{label:"Guid",value:'1f8d-4a2e-9c'},{label:"Name",value:"Basic Wall: Generic - 200mm"},{label:"Type",value:"Basic Wall"},{label:"Level",value:"Trane - Centrifugal Water Chiller - CVHF 2 Stage direct drive TAG(BP-RHS-1100RT) 0202104531 1"}]}),e}createAdvancedInfoContent(){const e=document.createElement("div");return new sl({container:e,labelWidth:"100px",bordered:!0,items:[{label:"Area",value:"32.5 m²"},{label:"Volume",value:"6.5 m³"},{label:"Length",value:"5000 mm"},{label:"Phase",value:"New Construction"}]}),e}createMaterialContent(){const e=document.createElement("div"),t=document.createElement("div");t.style.display="flex",t.style.alignItems="center",t.style.marginBottom="4px",t.innerHTML=` + }`,blending:zn,depthTest:!1,depthWrite:!1,transparent:!0})}}as.BlurDirectionX=new oe(1,0),as.BlurDirectionY=new oe(0,1);class bv{outlinePass;hoveredObjects=[];selectedObjects=[];constructor(e,t,i,s){this.outlinePass=new as(new oe(i,s),e,t),this.outlinePass.edgeStrength=3,this.outlinePass.edgeGlow=.5,this.outlinePass.edgeThickness=1,this.outlinePass.pulsePeriod=0,this.outlinePass.visibleEdgeColor.set("#ff9800"),this.outlinePass.hiddenEdgeColor.set("#ff9800")}getPass(){return this.outlinePass}setHoveredObjects(e){this.hoveredObjects=e,this.updateOutline(),e.length>0&&(this.outlinePass.edgeStrength=3,this.outlinePass.edgeGlow=.5,this.outlinePass.visibleEdgeColor.set("#ff9800"),this.outlinePass.hiddenEdgeColor.set("#ff9800"))}setSelectedObjects(e){this.selectedObjects=e,this.updateOutline(),e.length>0&&(this.outlinePass.edgeStrength=5,this.outlinePass.edgeGlow=1,this.outlinePass.visibleEdgeColor.set("#00aaff"),this.outlinePass.hiddenEdgeColor.set("#00aaff"))}clearHovered(){this.hoveredObjects=[],this.updateOutline()}clearSelected(){this.selectedObjects=[],this.updateOutline()}clearAll(){this.hoveredObjects=[],this.selectedObjects=[],this.updateOutline()}updateOutline(){this.selectedObjects.length>0?(this.outlinePass.selectedObjects=this.selectedObjects,this.outlinePass.edgeStrength=5,this.outlinePass.edgeGlow=1,this.outlinePass.visibleEdgeColor.set("#00aaff"),this.outlinePass.hiddenEdgeColor.set("#00aaff")):this.hoveredObjects.length>0?(this.outlinePass.selectedObjects=this.hoveredObjects,this.outlinePass.edgeStrength=3,this.outlinePass.edgeGlow=.5,this.outlinePass.visibleEdgeColor.set("#ff9800"),this.outlinePass.hiddenEdgeColor.set("#ff9800")):this.outlinePass.selectedObjects=[]}resize(e,t){this.outlinePass.setSize(e,t)}setHoverStyle(e){e.color&&(this.outlinePass.visibleEdgeColor.set(e.color),this.outlinePass.hiddenEdgeColor.set(e.color)),e.strength!==void 0&&(this.outlinePass.edgeStrength=e.strength),e.glow!==void 0&&(this.outlinePass.edgeGlow=e.glow),e.thickness!==void 0&&(this.outlinePass.edgeThickness=e.thickness)}setSelectedStyle(e){}}class yv{scene;camera;canvas;controls;outlineManager;isSelecting=!1;startPoint=new oe;endPoint=new oe;ctrlPressed=!1;controlsEnabled=!0;selectionBox=null;selectedObjects=[];constructor(e,t,i,s,r){this.scene=e,this.camera=t,this.canvas=i,this.controls=s,this.outlineManager=r,this.setupEventListeners(),this.createSelectionBoxElement()}createSelectionBoxElement(){this.selectionBox=document.createElement("div"),this.selectionBox.style.position="absolute",this.selectionBox.style.border="2px dashed #00aaff",this.selectionBox.style.backgroundColor="rgba(0, 170, 255, 0.1)",this.selectionBox.style.pointerEvents="none",this.selectionBox.style.display="none",this.selectionBox.style.zIndex="1000",this.canvas.parentElement&&this.canvas.parentElement.appendChild(this.selectionBox)}setupEventListeners(){window.addEventListener("keydown",this.onKeyDown.bind(this)),window.addEventListener("keyup",this.onKeyUp.bind(this)),this.canvas.addEventListener("mousedown",this.onMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.onMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.onMouseUp.bind(this))}onKeyDown(e){(e.key==="Control"||e.key==="Meta")&&(this.ctrlPressed=!0)}onKeyUp(e){(e.key==="Control"||e.key==="Meta")&&(this.ctrlPressed=!1,this.isSelecting&&this.endSelection())}onMouseDown(e){if(e.button!==0||!this.ctrlPressed)return;const t=this.canvas.getBoundingClientRect();this.startPoint.set(e.clientX-t.left,e.clientY-t.top),this.endPoint.copy(this.startPoint),this.isSelecting=!0,this.controls&&this.controls.enabled!==void 0&&(this.controlsEnabled=this.controls.enabled,this.controls.enabled=!1),this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation()}onMouseMove(e){if(!this.isSelecting)return;const t=this.canvas.getBoundingClientRect();this.endPoint.set(e.clientX-t.left,e.clientY-t.top),this.updateSelectionBoxUI(),this.updateSelectedObjects(),e.preventDefault(),e.stopPropagation()}onMouseUp(e){this.isSelecting&&(this.endSelection(),e.preventDefault(),e.stopPropagation())}endSelection(){this.isSelecting&&(this.isSelecting=!1,this.controls&&this.controls.enabled!==void 0&&(this.controls.enabled=this.controlsEnabled),this.selectionBox&&(this.selectionBox.style.display="none"),this.updateSelectedObjects())}updateSelectionBoxUI(){if(!this.selectionBox)return;const e=Math.min(this.startPoint.x,this.endPoint.x),t=Math.min(this.startPoint.y,this.endPoint.y),i=Math.abs(this.endPoint.x-this.startPoint.x),s=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${e}px`,this.selectionBox.style.top=`${t}px`,this.selectionBox.style.width=`${i}px`,this.selectionBox.style.height=`${s}px`}updateSelectedObjects(){const e=this.endPoint.x>this.startPoint.x,t=this.endPoint.y>this.startPoint.y,i=e&&t,s=this.canvas.getBoundingClientRect(),r=s.width,a=s.height,o=new oe(Math.min(this.startPoint.x,this.endPoint.x)/r,Math.min(this.startPoint.y,this.endPoint.y)/a),l=new oe(Math.max(this.startPoint.x,this.endPoint.x)/r,Math.max(this.startPoint.y,this.endPoint.y)/a),c=[];this.scene.traverse(h=>{if(!h.isMesh||!h.visible)return;const u=h;if(!u.geometry)return;u.geometry.boundingBox||u.geometry.computeBoundingBox();const d=u.geometry.boundingBox;if(!d)return;const m=this.getBoundingBoxCorners(d,u).map(f=>this.worldToScreen(f)),g=this.getScreenBoundingBox(m);let v=!1;i?v=this.isFullyContained(g,o,l):v=this.isPartiallyContained(g,o,l),v&&c.push(h)}),this.selectedObjects=c,this.outlineManager.setSelectedObjects(this.selectedObjects)}getBoundingBoxCorners(e,t){const i=[],s=e.min,r=e.max;return i.push(new w(s.x,s.y,s.z)),i.push(new w(r.x,s.y,s.z)),i.push(new w(s.x,r.y,s.z)),i.push(new w(r.x,r.y,s.z)),i.push(new w(s.x,s.y,r.z)),i.push(new w(r.x,s.y,r.z)),i.push(new w(s.x,r.y,r.z)),i.push(new w(r.x,r.y,r.z)),i.forEach(a=>{a.applyMatrix4(t.matrixWorld)}),i}worldToScreen(e){const t=e.clone();t.project(this.camera);const i=(t.x+1)/2,s=(1-t.y)/2;return new oe(i,s)}getScreenBoundingBox(e){const t=new oe(1/0,1/0),i=new oe(-1/0,-1/0);return e.forEach(s=>{t.x=Math.min(t.x,s.x),t.y=Math.min(t.y,s.y),i.x=Math.max(i.x,s.x),i.y=Math.max(i.y,s.y)}),{min:t,max:i}}isFullyContained(e,t,i){return e.min.x>=t.x&&e.min.y>=t.y&&e.max.x<=i.x&&e.max.y<=i.y}isPartiallyContained(e,t,i){return!(e.max.x i.x||e.max.y i.y)}clearSelection(){this.selectedObjects=[],this.outlineManager.clearSelected()}getSelectedObjects(){return this.selectedObjects}dispose(){window.removeEventListener("keydown",this.onKeyDown.bind(this)),window.removeEventListener("keyup",this.onKeyUp.bind(this)),this.canvas.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.canvas.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.canvas.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.selectionBox&&this.selectionBox.parentElement&&this.selectionBox.parentElement.removeChild(this.selectionBox),this.clearSelection()}}class Mv{scene;clippingPlane;stencilGroup=null;isEnabledFlag=!1;capMesh=null;planeInitialized=!1;tempCenter=new w;sceneBounds=new Pt;capColor=new xe(16711680);constructor(e){this.scene=e,this.clippingPlane=new Ai(new w(0,-1,0),0)}enable(){this.isEnabledFlag=!0,this.refresh()}disable(){this.isEnabledFlag=!1,this.cleanup()}refresh(){this.isEnabledFlag&&(this.cleanupStencilGroup(),this.ensurePlaneInitialized(),this.updateSceneMaterials(!0),this.createStencilGroup())}setPlane(e,t){this.planeInitialized=!0,this.clippingPlane.normal.copy(e).normalize(),this.clippingPlane.constant=t,this.isEnabledFlag&&this.updateCapPlane()}isEnabled(){return this.isEnabledFlag}setCapColor(e){if(this.capColor.set(e),this.capMesh){const t=this.capMesh.material;t.color.copy(this.capColor),t.needsUpdate=!0}}updateSceneMaterials(e){this.scene.traverse(t=>{if(t instanceof rt){if(t.userData.isStencilCap)return;(Array.isArray(t.material)?t.material:[t.material]).forEach(i=>{i&&(e?((!i.clippingPlanes||i.clippingPlanes.indexOf(this.clippingPlane)===-1)&&(i.clippingPlanes=[this.clippingPlane]),i.clipShadows=!0):i.clippingPlanes=[],i.needsUpdate=!0)})}})}createStencilGroup(){this.stencilGroup=new Vi,this.stencilGroup.name="ClippingStencilGroup",this.scene.add(this.stencilGroup);let e=0;this.scene.traverse(t=>{if(t instanceof rt&&t.visible&&!t.userData.isStencilCap){if(!t.geometry)return;this.createStencilMeshesForObject(t),e++}}),console.log(`ClippingManager: Generated stencil geometry for ${e} meshes.`),this.addCapPlane(),this.updateCapPlane()}createStencilMeshesForObject(e){const t=e.geometry;e.updateMatrixWorld(!0);const i=e.matrixWorld,s=new Ht({depthWrite:!1,depthTest:!1,colorWrite:!1,stencilWrite:!0,stencilFunc:Ha,clippingPlanes:[this.clippingPlane]}),r=s.clone();r.side=zt,r.stencilFail=Fa,r.stencilZFail=Fa,r.stencilZPass=Fa;const a=new rt(t,r);a.applyMatrix4(i),a.matrixAutoUpdate=!1,a.userData.isStencilCap=!0,a.renderOrder=1,this.stencilGroup.add(a);const o=s.clone();o.side=Si,o.stencilFail=za,o.stencilZFail=za,o.stencilZPass=za;const l=new rt(t,o);l.applyMatrix4(i),l.matrixAutoUpdate=!1,l.userData.isStencilCap=!0,l.renderOrder=1,this.stencilGroup.add(l)}addCapPlane(){const e=new Ht({color:this.capColor,side:Xt,stencilWrite:!0,transparent:!0,opacity:0,stencilFunc:Eu,stencilRef:0,clippingPlanes:[],depthTest:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),t=new An(1e5,1e5),i=new rt(t,e);i.userData.isCapPlane=!0,i.userData.isStencilCap=!0,i.renderOrder=2,this.capMesh=i,this.stencilGroup.add(i)}updateCapPlane(){if(!this.stencilGroup||!this.capMesh)return;const e=this.capMesh,t=this.clippingPlane.normal,i=-this.clippingPlane.constant;e.quaternion.setFromUnitVectors(new w(0,0,1),t),e.position.copy(t).multiplyScalar(i)}cleanupStencilGroup(){this.stencilGroup&&(this.scene.remove(this.stencilGroup),this.stencilGroup.traverse(e=>{e.material&&(Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose()),e.geometry&&e.userData.isCapPlane&&e.geometry.dispose()}),this.stencilGroup=null,this.capMesh=null)}cleanup(){this.updateSceneMaterials(!1),this.cleanupStencilGroup()}ensurePlaneInitialized(){if(this.planeInitialized||(this.sceneBounds.makeEmpty(),this.sceneBounds.setFromObject(this.scene),this.sceneBounds.isEmpty()))return;this.sceneBounds.getCenter(this.tempCenter);const e=this.clippingPlane.normal;this.clippingPlane.constant=-e.dot(this.tempCenter),this.planeInitialized=!0,this.updateCapPlane()}}class Sv{_lastClickWorldPosition=null;_lastClickScreenPosition=null;constructor(){}setLastClickWorldPosition(e){this._lastClickWorldPosition=e.clone()}getLastClickWorldPosition(){return this._lastClickWorldPosition}setLastClickScreenPosition(e){this._lastClickScreenPosition=e.clone()}getLastClickScreenPosition(){return this._lastClickScreenPosition}clearClickState(){this._lastClickWorldPosition=null,this._lastClickScreenPosition=null}}function Tv(n){let e=new Object;return e.updataSceneOctreeBox=function(){n.octreeBoxModels=[];let t=e.getBoundingBox();e.ocBox=e.splitBoxIntoAuto(t);let i=0;n.models.forEach(a=>{a.children.forEach(o=>{o.info.forEach(l=>{r(l,e.ocBox)})}),i=i+1}),s(e.ocBox);function s(a){for(let o=a.children.length-1;o>=0;o--){let l=a.children[o];l.isLeaf==!1&&s(l),l.children.length==0&&(l.isLeaf=!0),l.isLeaf&&(l.elements==null||l.elements.length==0)&&a.children.splice(o,1)}}function r(a,o){var l={min:a.box.min,max:a.box.max};if(e.boxContainBox(o,l)==!0)if(o.elements==null&&(o.elements=[]),o.isLeaf==!1){let c=!1;for(let h=0;h =t.min.x&&i.min.y>=t.min.y&&i.min.z>=t.min.z&&i.max.x<=t.max.x&&i.max.y<=t.max.y&&i.max.z<=t.max.z},e.splitBoxIntoAuto=function(t,i=10){let s=[],r=[],a=[],o=(t.max.x-t.min.x)*.5,l=(t.max.y-t.min.y)*.5,c=(t.max.z-t.min.z)*.5;if(o>i){let h=t,u={min:h.min,max:new w(h.min.x+o,h.max.y,h.max.z)},d={min:new w(h.min.x+o,h.min.y,h.min.z),max:h.max};s.push(u),s.push(d)}if(l>i)for(let h of s){let u={min:h.min,max:new w(h.max.x,h.min.y+l,h.max.z)},d={min:new w(h.min.x,h.min.y+l,h.min.z),max:h.max};r.push(u),r.push(d)}else r=s;if(c>i)for(let h of r){let u={min:h.min,max:new w(h.max.x,h.max.y,h.min.z+c)},d={min:new w(h.min.x,h.min.y,h.min.z+c),max:h.max};a.push(u),a.push(d)}else a=r;if(t.children=a,t.children.length>0){t.isLeaf=!1;for(let h=0;h {r.children.forEach(a=>{a.geometry.computeBoundingBox();let o=a.geometry.boundingBox.min,l=a.geometry.boundingBox.max;o.x s.x&&(s.x=l.x),l.y>s.y&&(s.y=l.y),l.z>s.z&&(s.z=l.z)})}),{min:i,max:s}},e}var ln=Object.freeze({Linear:Object.freeze({None:function(n){return n},In:function(n){return n},Out:function(n){return n},InOut:function(n){return n}}),Quadratic:Object.freeze({In:function(n){return n*n},Out:function(n){return n*(2-n)},InOut:function(n){return(n*=2)<1?.5*n*n:-.5*(--n*(n-2)-1)}}),Cubic:Object.freeze({In:function(n){return n*n*n},Out:function(n){return--n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n:.5*((n-=2)*n*n+2)}}),Quartic:Object.freeze({In:function(n){return n*n*n*n},Out:function(n){return 1- --n*n*n*n},InOut:function(n){return(n*=2)<1?.5*n*n*n*n:-.5*((n-=2)*n*n*n-2)}}),Quintic:Object.freeze({In:function(n){return n*n*n*n*n},Out:function(n){return--n*n*n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n*n*n:.5*((n-=2)*n*n*n*n+2)}}),Sinusoidal:Object.freeze({In:function(n){return 1-Math.sin((1-n)*Math.PI/2)},Out:function(n){return Math.sin(n*Math.PI/2)},InOut:function(n){return .5*(1-Math.sin(Math.PI*(.5-n)))}}),Exponential:Object.freeze({In:function(n){return n===0?0:Math.pow(1024,n-1)},Out:function(n){return n===1?1:1-Math.pow(2,-10*n)},InOut:function(n){return n===0?0:n===1?1:(n*=2)<1?.5*Math.pow(1024,n-1):.5*(-Math.pow(2,-10*(n-1))+2)}}),Circular:Object.freeze({In:function(n){return 1-Math.sqrt(1-n*n)},Out:function(n){return Math.sqrt(1- --n*n)},InOut:function(n){return(n*=2)<1?-.5*(Math.sqrt(1-n*n)-1):.5*(Math.sqrt(1-(n-=2)*n)+1)}}),Elastic:Object.freeze({In:function(n){return n===0?0:n===1?1:-Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI)},Out:function(n){return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n-.1)*5*Math.PI)+1},InOut:function(n){return n===0?0:n===1?1:(n*=2,n<1?-.5*Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI):.5*Math.pow(2,-10*(n-1))*Math.sin((n-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(n){var e=1.70158;return n===1?1:n*n*((e+1)*n-e)},Out:function(n){var e=1.70158;return n===0?0:--n*n*((e+1)*n+e)+1},InOut:function(n){var e=2.5949095;return(n*=2)<1?.5*(n*n*((e+1)*n-e)):.5*((n-=2)*n*((e+1)*n+e)+2)}}),Bounce:Object.freeze({In:function(n){return 1-ln.Bounce.Out(1-n)},Out:function(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375},InOut:function(n){return n<.5?ln.Bounce.In(n*2)*.5:ln.Bounce.Out(n*2-1)*.5+.5}}),generatePow:function(n){return n===void 0&&(n=4),n=n 1e4?1e4:n,{In:function(e){return Math.pow(e,n)},Out:function(e){return 1-Math.pow(1-e,n)},InOut:function(e){return e<.5?Math.pow(e*2,n)/2:(1-Math.pow(2-e*2,n))/2+.5}}}}),On=function(){return performance.now()},Ev=(function(){function n(){this._tweens={},this._tweensAddedDuringUpdate={}}return n.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},n.prototype.removeAll=function(){this._tweens={}},n.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},n.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},n.prototype.update=function(e,t){e===void 0&&(e=On()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s 1?r(n[t],n[t-1],t-i):r(n[s],n[s+1>t?t:s+1],i-s)},Utils:{Linear:function(n,e,t){return(e-n)*t+n}}},Lh=(function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n})(),el=new Ev,wv=(function(){function n(e,t){t===void 0&&(t=el),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=ln.Linear.None,this._interpolationFunction=Qo.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Lh.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return n.prototype.getId=function(){return this._id},n.prototype.isPlaying=function(){return this._isPlaying},n.prototype.isPaused=function(){return this._isPaused},n.prototype.getDuration=function(){return this._duration},n.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},n.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},n.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},n.prototype.start=function(e,t){if(e===void 0&&(e=On()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var r in this._valuesEnd)s[r]=this._valuesEnd[r];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},n.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},n.prototype._setupProperties=function(e,t,i,s,r){for(var a in i){var o=e[a],l=Array.isArray(o),c=l?"array":typeof o,h=!l&&Array.isArray(i[a]);if(!(c==="undefined"||c==="function")){if(h){var u=i[a];if(u.length===0)continue;for(var d=[o],m=0,g=u.length;m "u"||r)&&(t[a]=o),l||(t[a]*=1),h?s[a]=i[a].slice().reverse():s[a]=t[a]||0}}},n.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},n.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},n.prototype.pause=function(e){return e===void 0&&(e=On()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},n.prototype.resume=function(e){return e===void 0&&(e=On()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},n.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e a)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e c)return 1;var f=Math.trunc(o/l),p=o-f*l,b=Math.min(p/i._duration,1);return b===0&&o===i._duration?1:b},u=h(),d=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,d),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||o>=this._duration)if(this._repeat>0){var m=Math.min(Math.trunc((o-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=m);for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*m,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,v=this._chainedTweens.length;g {f&&(E||(f(R),E=!0))}),f&&setTimeout(()=>{E||(f(!0),E=!0)},v+10)},i.CameraGoHome=function(){var g=n.octreeBox.getBoundingBox(),v=g.min.clone().add(g.max.clone()).multiplyScalar(.5);let f=new w(1,1,1);var p=v.clone().add(f.multiplyScalar(1*g.max.distanceTo(g.min)));l(e.camera.position,p,n.controls.target.clone(),v)};function l(g,v,f,p,b,_,E=1e3,R){var T;b&&_?(T=new tl.Tween({x1:g.x,y1:g.y,z1:g.z,x2:f.x,y2:f.y,z2:f.z,_x:b._x,_y:b._y,_z:b._z,_w:b._w}),T.to({x1:v.x,y1:v.y,z1:v.z,x2:p.x,y2:p.y,z2:p.z,_x:_._x,_y:_._y,_z:_._z,_w:_._w},E)):(T=new tl.Tween({x1:g.x,y1:g.y,z1:g.z,x2:f.x,y2:f.y,z2:f.z}),T.to({x1:v.x,y1:v.y,z1:v.z,x2:p.x,y2:p.y,z2:p.z},E)),T.onUpdate(function(I){b&&_?(e.camera.quaternion._x=I._x,e.camera.quaternion._y=I._y,e.camera.quaternion._z=I._z,e.camera.quaternion._w=I._w):n.controls.auto=!0,e.camera.position.x=I.x1,e.camera.position.y=I.y1,e.camera.position.z=I.z1,n.controls.target.x=I.x2,n.controls.target.y=I.y2,n.controls.target.z=I.z2,n.controls.update(),i.RenderScene()}),T.onComplete(function(I){n.controls.auto=!1,i.RenderScene(),R&&R(!0),cancelAnimationFrame(s),s=null}),T.easing(tl.Easing.Cubic.InOut);function A(I){s=requestAnimationFrame(A),T.update()}T.start(),A()}function c(){r=document.createElement("div"),r.className="ViewCube",t.appendChild(r),a=document.createElement("div"),a.className="ViewAttr",t.appendChild(a)}function h(){i.sceneOrtho=Cv();var f=window.innerWidth,p=window.innerHeight,g=f>p?f/p:p/f,v=150;i.camera=new ms(v*g/-2,v*g/2,2*v/2,1.4*v/-2,.01,1e4);var f=r.clientWidth,p=r.clientHeight,b=new Lr({alpha:!0});b.setSize(f,p),b.setClearAlpha(0),i.sceneOrtho.renderer=b;let _=new Bc(16777215,.8);i.sceneOrtho.add(_),Av(r,b)}function u(){let g=[{label:"右",icon:"cube/cn_right.png"},{label:"左",icon:"cube/cn_left.png"},{label:"顶",icon:"cube/cn_top.png"},{label:"底",icon:"cube/cn_bottom.png"},{label:"前",icon:"cube/cn_front.png"},{label:"后",icon:"cube/cn_back.png"}];var v=[];for(const p of g)v.push(new Ht({color:16777215,map:new Lc().load(p.icon)}));new Od({color:255});var f=new rt(new ds(110,110,110),v);i.sceneOrtho.add(f),d(122),r.addEventListener("mousedown",p=>{var b={};b.x=p.offsetX/r.clientWidth*2-1,b.y=-(p.offsetY/r.clientHeight)*2+1;var _=new kc;_.setFromCamera(b,i.camera);const E=_.intersectObjects(o,!1);E.length>0&&i.ToggleDirectionView(E[0].object.name)}),r.addEventListener("mousemove",p=>{var b={};b.x=p.offsetX/r.clientWidth*2-1,b.y=-(p.offsetY/r.clientHeight)*2+1;var _=new kc;_.setFromCamera(b,i.camera);const E=_.intersectObjects(o,!1);for(var R of o)R.material.opacity=.01;E.length>0&&(E[0].object.material.opacity=.2)})}function d(g){for(var v=g*.5-20,f=[{name:"right",a:30,b:75,c:75,point:new w(v,0,0)},{name:"back",a:75,b:75,c:30,point:new w(0,0,-v)},{name:"left",a:30,b:75,c:75,point:new w(-v,0,0)},{name:"front",a:75,b:75,c:30,point:new w(0,0,v)},{name:"top",a:75,b:30,c:75,point:new w(0,v,0)},{name:"button",a:75,b:30,c:75,point:new w(0,-v,0)}],p=[{name:"top_right_back",a:30,b:30,c:30,point:new w(-v,v,v)},{name:"button_front_right",a:30,b:30,c:30,point:new w(-v,-v,v)},{name:"top_front_right",a:30,b:30,c:30,point:new w(v,v,v)},{name:"button_right_back",a:30,b:30,c:30,point:new w(v,-v,v)},{name:"top_back_left",a:30,b:30,c:30,point:new w(-v,v,-v)},{name:"button_back_left",a:30,b:30,c:30,point:new w(-v,-v,-v)},{name:"top_left_front",a:30,b:30,c:30,point:new w(v,v,-v)},{name:"button_left_front",a:30,b:30,c:30,point:new w(v,-v,-v)}],b=[{name:"top_front",a:30,b:30,c:75,point:new w(v,v,0)},{name:"top_right",a:75,b:30,c:30,point:new w(0,v,v)},{name:"top_back",a:30,b:30,c:75,point:new w(-v,v,0)},{name:"top_left",a:75,b:30,c:30,point:new w(0,v,-v)},{name:"button_front",a:30,b:30,c:75,point:new w(v,-v,0)},{name:"button_right",a:75,b:30,c:30,point:new w(0,-v,v)},{name:"button_back",a:30,b:30,c:75,point:new w(-v,-v,0)},{name:"button_left",a:75,b:30,c:30,point:new w(0,-v,-v)},{name:"front_right",a:30,b:75,c:30,point:new w(v,0,v)},{name:"right_back",a:30,b:75,c:30,point:new w(-v,0,v)},{name:"back_left",a:30,b:75,c:30,point:new w(-v,0,-v)},{name:"left_front",a:30,b:75,c:30,point:new w(v,0,-v)}],_=0;_ {t instanceof rt&&n.includes(t.name)&&e.push(t)}),this.manager.highlight(e)}addSelection(n){this.select(n)}removeSelection(n){this.manager.clearHighlight()}clearSelection(){this.manager.clearHighlight()}getHiddenComponents(){const n=[];return this.scene.traverse(e=>{e.visible||n.push(e.name)}),n}setVisibility(n,e){this.manager.setVisibility(n,e)}isolate(n){this.scene.traverse(e=>e.visible=!1),this.setVisibility(n,!0)}clearIsolation(){this.scene.traverse(n=>n.visible=!0)}setColor(n,e){console.warn("[V1] setColor not implemented")}restoreColor(n){console.warn("[V1] restoreColor not implemented")}setOpacity(n,e){console.warn("[V1] setOpacity not implemented")}restoreOpacity(n){console.warn("[V1] restoreOpacity not implemented")}clearAllOverrides(){}getBoundingBox(n){let e;if(this.scene.traverse(t=>{t.name===n&&(e=t)}),e){const t=new Pt().setFromObject(e);return{min:t.min,max:t.max}}return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}}},Iv=class{constructor(n,e){this.sceneManager=n,this.renderer=e}setBackgroundColor(n){this.sceneManager.setBackground(n)}setSkybox(n){const e=new Pc().load(n);this.sceneManager.scene.background=e}enableShadows(n){}enableAntialiasing(n){}enableAmbientOcclusion(n){}addSectionPlane(n,e){return""}removeSectionPlane(n){}clearSectionPlanes(){}enableSectioning(n){}captureScreen(n,e){return this.renderer.domElement.toDataURL()}getViewerConfig(){return{shadows:!1,ambientOcclusion:!1,sectioning:!1}}getRenderStatistics(){const n=this.renderer.info||{},e=n.render||{},t=n.memory||{};return{calls:e.calls||0,triangles:e.triangles||0,points:e.points||0,lines:e.lines||0,memory:{geometries:t.geometries||0,textures:t.textures||0}}}},Uv=class{async getProperties(n){return[{name:"Identity Data",properties:[{name:"Element ID",value:n},{name:"Version",value:"V1 Engine"}]}]}async getPropertyValue(n,e){return"Unknown"}async getModelTree(n){return[{id:"root",name:"Model Root (V1)",type:"Model",hasChildren:!1}]}async search(n){return[]}},Nv=class{activeTool=null;tools=new Map;activate(n,e){console.log(`[V1] Activating tool: ${n}`,e),this.activeTool=n}deactivate(){this.activeTool&&(console.log(`[V1] Deactivating tool: ${this.activeTool}`),this.activeTool=null)}getActiveTool(){return this.activeTool}registerTool(n,e){this.tools.set(n,e)}},Bv=class{listeners=new Map;on(n,e){this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(e)}off(n,e){if(!this.listeners.has(n))return;const t=this.listeners.get(n),i=t.indexOf(e);i!==-1&&t.splice(i,1)}trigger(n,e){this.listeners.has(n)&&this.listeners.get(n).forEach(t=>{try{t(e)}catch(i){console.error(`Error in event listener for ${n}:`,i)}})}},Ov=class{container;renderer;composer=null;stats=null;engineState;sceneManager;cameraManager;loaderManager;interactionManager;outlineManager;selectionBoxManager=null;clippingManager;octreeBox;loader;cameraTool;components;data;viewer;tools;events;viewCube;scene;camera;models;controls;measure;animationId=null;constructor(n){const e=document.getElementById(n.containerId);if(!e)throw new Error(`Container ${n.containerId} not found`);this.container=e,this.models=[],this.engineState=new Sv,this.sceneManager=new S1(n);const{width:t,height:i}=this.getContainerSize();this.cameraManager=new O1(this.container,t,i,this.engineState);try{this.renderer=new Lr({antialias:n.antialias??!0}),console.log("Engine: Using WebGPURenderer")}catch(s){console.warn("WebGPURenderer failed",s),this.renderer=new Lr({antialias:n.antialias??!0})}this.renderer.setSize(t,i),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=hl,this.renderer.toneMapping=Qr,this.renderer.toneMappingExposure=1,this.renderer.localClippingEnabled=!0,this.container.appendChild(this.renderer.domElement),this.loaderManager=new _v(this.sceneManager.scene),this.outlineManager=new bv(this.sceneManager.scene,this.cameraManager.camera,t,i),this.interactionManager=new xv(this.sceneManager.scene,this.cameraManager.camera,this.renderer.domElement,this.engineState),this.selectionBoxManager=new yv(this.sceneManager.scene,this.cameraManager.camera,this.renderer.domElement,this.cameraManager.controls,this.outlineManager),this.clippingManager=new Mv(this.sceneManager.scene),setTimeout(()=>{this.clippingManager.enable()},1e3),this.events=new Bv,this.interactionManager.setEventModule(this.events),this.loader=new Pv(this.loaderManager,this.sceneManager.scene,this.clippingManager),this.cameraTool=new Lv(this.cameraManager),this.components=new Dv(this.interactionManager,this.sceneManager.scene),this.viewer=new Iv(this.sceneManager,this.renderer),this.data=new Uv,this.tools=new Nv,this.scene=this.sceneManager.scene,this.scene.camera=this.cameraManager.camera,this.camera=this.cameraManager.camera,this.controls=this.cameraManager.controls,this.octreeBox=Tv(this),this.viewCube=Rv(this,this.scene,this.container),this.viewCube.init(),this.setupVisuals(),this.setupPostProcessing(),n.showStats!==!1&&this.initStats(),this.setupResizeObserver(),this.animate()}initStats(){this.stats=new M1,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom)}toggleStats(n){n&&!this.stats?this.initStats():!n&&this.stats&&(this.container.removeChild(this.stats.dom),this.stats=null)}getVersion(){return"1.2.0 (WebGPU Experimental)"}setupVisuals(){const n=this.sceneManager.scene;n.children.filter(s=>s instanceof Pn).forEach(s=>n.remove(s));const e=new Nc(16777215,4.5);e.position.set(10,20,10),e.castShadow=!0,e.shadow.mapSize.width=4096,e.shadow.mapSize.height=4096,e.shadow.camera.near=.1,e.shadow.camera.far=500,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2,n.add(e);const i=new Bc(4210752,.4);n.add(i),new n1().load("https://raw.githubusercontent.com/mrdoob/three.js/master/examples/textures/equirectangular/royal_esplanade_1k.hdr",s=>{s.mapping=Hn,n.environment=s,n.environmentIntensity=1})}setupPostProcessing(){if(!this.renderer)return;const{width:n,height:e}=this.getContainerSize(),t=window.devicePixelRatio,i=this.sceneManager.scene,s=this.cameraManager.camera;this.composer=new c1(this.renderer),this.composer.setPixelRatio(t),this.composer.setSize(n,e);const r=new h1(i,s);this.composer.addPass(r);const a=new xi(i,s,n,e);a.output=xi.OUTPUT.Default,a.blendIntensity=1,a.updateGtaoMaterial&&a.updateGtaoMaterial({radius:3,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!1}),this.composer.addPass(a);const o=this.outlineManager.getPass();this.composer.addPass(o);const l=new nn(new oe(n,e),.05,.1,.5);this.composer.addPass(l);const c=new g1;this.composer.addPass(c);const h=new Go(v1);h.material.uniforms.resolution.value.x=1/(n*t),h.material.uniforms.resolution.value.y=1/(e*t),this.composer.addPass(h)}resize(){const{width:n,height:e}=this.getContainerSize(),t=window.devicePixelRatio;if(this.cameraManager.updateAspect(n,e),this.renderer.setSize(n,e),this.renderer.setPixelRatio(t),this.outlineManager&&this.outlineManager.resize(n,e),this.composer){this.composer.setPixelRatio(t),this.composer.setSize(n,e);const i=this.composer.passes.find(s=>s instanceof Go&&s.material.uniforms.resolution);i&&(i.material.uniforms.resolution.value.x=1/(n*t),i.material.uniforms.resolution.value.y=1/(e*t))}}getContainerSize(){return{width:this.container.clientWidth,height:this.container.clientHeight}}setupResizeObserver(){new ResizeObserver(()=>{this.resize()}).observe(this.container)}animate=()=>{this.animationId=requestAnimationFrame(this.animate),this.viewCube.RenderScene(),this.stats&&this.stats.begin(),this.cameraManager.tick(),this.composer?this.composer.render():this.renderer.renderAsync?this.renderer.renderAsync(this.sceneManager.scene,this.cameraManager.camera):this.renderer.render(this.sceneManager.scene,this.cameraManager.camera),this.stats&&this.stats.end()};dispose(){this.animationId&&cancelAnimationFrame(this.animationId),this.selectionBoxManager&&this.selectionBoxManager.dispose(),this.renderer.dispose(),this.container.innerHTML=""}};class Ih{constructor(e,t,i){this.object=e,this.id=t,this.uuid=i,this.object.name=t}get name(){return this.object.name}set name(e){this.object.name=e}get visible(){return this.object.visible}set visible(e){this.object.visible=e}getBoundingBox(){const e=new Pt().setFromObject(this.object);return{min:e.min,max:e.max}}setMatrix(e){this.object.matrix.fromArray(e),this.object.matrix.decompose(this.object.position,this.object.quaternion,this.object.scale)}}class kv{scene;gltfLoader;models=new Map;constructor(e){this.scene=e,this.gltfLoader=new Th}async loadModel(e,t){return new Promise((i,s)=>{this.gltfLoader.load(e,r=>{const a=r.scene,o=t?.id||Wa.generateUUID();t?.position&&a.position.fromArray(t.position),t?.scale&&a.scale.fromArray(t.scale),t?.rotation&&a.rotation.setFromVector3(new w(...t.rotation)),this.scene.add(a);const l=new Ih(a,o,a.uuid);this.models.set(o,l),i(l)},r=>{t?.onProgress&&t.onProgress(r.loaded/r.total*100)},r=>s(r))})}unloadModel(e){const t=this.models.get(e);t&&t instanceof Ih&&(this.scene.remove(t.object),this.models.delete(e))}getAllModels(){return Array.from(this.models.values())}getModel(e){return this.models.get(e)}}class Fv{camera;controls;container;constructor(e,t,i){this.container=e,this.camera=new Tt(75,t/i,.1,1e3),this.camera.position.set(10,10,10),this.camera.lookAt(0,0,0),this.controls=new Mh(this.camera,this.container),this.controls.enableDamping=!0}getCamera(){return this.camera}update(){this.controls.update()}updateAspect(e,t){if(this.camera instanceof Tt)this.camera.aspect=e/t,this.camera.updateProjectionMatrix();else if(this.camera instanceof ms){const i=e/t,s=20;this.camera.left=-s*i/2,this.camera.right=s*i/2,this.camera.top=s/2,this.camera.bottom=-s/2,this.camera.updateProjectionMatrix()}}setView(e,t){switch(e){case rn.Top:this.camera.position.set(0,20,0);break;case rn.Front:this.camera.position.set(0,0,20);break;default:console.warn("View not fully implemented:",e)}this.camera.lookAt(0,0,0),this.controls.update()}fitToView(e,t){}goHome(e){this.camera.position.set(10,10,10),this.camera.lookAt(0,0,0),this.controls.update()}setProjection(e){e===an.Perspective&&!(this.camera instanceof Tt)||e===an.Orthographic&&this.camera instanceof ms}setNavigationMode(e){e===Or.Orbit?(this.controls.enabled=!0,this.controls.enableRotate=!0):e===Or.PanOnly&&(this.controls.enableRotate=!1)}getState(){const e=this.controls.target;return{position:this.camera.position.toArray(),target:e.toArray(),up:this.camera.up.toArray(),projection:this.camera instanceof Tt?an.Perspective:an.Orthographic}}restoreState(e,t){this.camera.position.fromArray(e.position),this.camera.up.fromArray(e.up),this.controls.target.fromArray(e.target),this.controls.update()}}class zv{scene;selectedIds=new Set;materialCache=new Map;constructor(e){this.scene=e}findObject(e){let t;return this.scene.traverse(i=>{i.name===e&&(t=i)}),t}getSelection(){return Array.from(this.selectedIds)}select(e){this.clearSelection(),this.addSelection(e)}addSelection(e){e.forEach(t=>{this.selectedIds.add(t),this.findObject(t)})}removeSelection(e){e.forEach(t=>this.selectedIds.delete(t))}clearSelection(){this.selectedIds.clear()}getHiddenComponents(){const e=[];return this.scene.traverse(t=>{t.visible||e.push(t.name)}),e}setVisibility(e,t){e.forEach(i=>{const s=this.findObject(i);s&&(s.visible=t)})}isolate(e){this.scene.traverse(t=>t.visible=!1),this.setVisibility(e,!0)}clearIsolation(){this.scene.traverse(e=>e.visible=!0)}setColor(e,t){e.forEach(i=>{const s=this.findObject(i);if(s&&s instanceof rt){this.materialCache.has(i)||this.materialCache.set(i,s.material);const r=new Ht({color:t});s.material=r}})}restoreColor(e){e.forEach(t=>{const i=this.findObject(t);i&&this.materialCache.has(t)&&(i.material=this.materialCache.get(t),this.materialCache.delete(t))})}setOpacity(e,t){}restoreOpacity(e){}clearAllOverrides(){this.materialCache.forEach((e,t)=>{const i=this.findObject(t);i&&i instanceof rt&&(i.material=e)}),this.materialCache.clear()}getBoundingBox(e){const t=this.findObject(e);if(t){const i=new Pt().setFromObject(t);return{min:i.min,max:i.max}}return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}}}class Hv{async getProperties(e){return[{name:"Identity Data",properties:[{name:"Element ID",value:e},{name:"Name",value:"Sample Element"}]}]}async getPropertyValue(e,t){return"Unknown"}async getModelTree(e){return[{id:"root",name:"Model Root",type:"Model",hasChildren:!0,children:[{id:"l1",name:"Level 1",type:"Level",hasChildren:!1}]}]}async search(e){return console.log("Searching for:",e),[]}}class Vv{scene;renderer;_shadowsEnabled=!1;_aoEnabled=!1;_sectioningEnabled=!1;constructor(e,t){this.scene=e,this.renderer=t}setBackgroundColor(e){this.scene.background=new xe(e)}setSkybox(e){const t=new Pc().load(e);this.scene.background=t}enableShadows(e){this._shadowsEnabled=e,this.renderer.shadowMap.enabled=e,this.scene.traverse(t=>{t instanceof rt&&(t.castShadow=e,t.receiveShadow=e)})}enableAntialiasing(e){console.warn("Changing antialiasing at runtime requires recreating the WebGL context, which is complex. Ignored.")}enableAmbientOcclusion(e){this._aoEnabled=e,console.log("AO enabled:",e,"(Requires PostProcessing pass - not implemented in this basic kernel)")}addSectionPlane(e,t){const i=new Ai(new w(...e),t);return this.renderer.clippingPlanes.push(i),"plane-"+(this.renderer.clippingPlanes.length-1)}removeSectionPlane(e){this.renderer.clippingPlanes.pop()}clearSectionPlanes(){this.renderer.clippingPlanes=[]}enableSectioning(e){this._sectioningEnabled=e,this.renderer.localClippingEnabled=e}captureScreen(e,t){return this.renderer.domElement.toDataURL()}getViewerConfig(){return{shadows:this._shadowsEnabled,ambientOcclusion:this._aoEnabled,sectioning:this._sectioningEnabled}}getRenderStatistics(){const e=this.renderer.info;return{calls:e.render.calls,triangles:e.render.triangles,points:e.render.points,lines:e.render.lines,memory:{geometries:e.memory.geometries,textures:e.memory.textures}}}}class Gv{activeTool=null;tools=new Map;activate(e,t){console.log(`Activating tool: ${e}`,t),this.activeTool=e}deactivate(){this.activeTool&&(console.log(`Deactivating tool: ${this.activeTool}`),this.activeTool=null)}getActiveTool(){return this.activeTool}registerTool(e,t){this.tools.set(e,t)}}class Wv{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)}off(e,t){if(!this.listeners.has(e))return;const i=this.listeners.get(e),s=i.indexOf(t);s!==-1&&i.splice(s,1)}trigger(e,t){this.listeners.has(e)&&this.listeners.get(e).forEach(i=>{try{i(t)}catch(s){console.error(`Error in event listener for ${e}:`,s)}})}}class Uh{loader;cameraTool;components;data;viewer;tools;events;viewCube;container;scene;renderer;_cameraModule;animationId=null;constructor(e){const t=document.getElementById(e.containerId);if(!t)throw new Error(`Container ${e.containerId} not found`);this.container=t,this.scene=new go,this.renderer=new Lr({antialias:e.antialias??!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.container.appendChild(this.renderer.domElement),this.events=new Wv,this._cameraModule=new Fv(this.container,this.container.clientWidth,this.container.clientHeight),this.cameraTool=this._cameraModule,this.loader=new kv(this.scene),this.components=new zv(this.scene),this.data=new Hv,this.viewer=new Vv(this.scene,this.renderer),this.tools=new Gv,this.viewCube={show:()=>console.warn("[V2] ViewCube not implemented"),hide:()=>{},setDirection:()=>{},goHome:()=>{},isVisible:()=>!1,updateOptions:()=>{}},this.resize(),this.setupResizeObserver(),this.animate()}getVersion(){return"2.0.0"}resize(){const e=this.container.clientWidth,t=this.container.clientHeight;this.renderer.setSize(e,t),this._cameraModule.updateAspect(e,t)}dispose(){this.animationId&&cancelAnimationFrame(this.animationId),this.renderer.dispose(),this.container.innerHTML=""}setupResizeObserver(){new ResizeObserver(()=>{this.resize()}).observe(this.container)}animate=()=>{this.animationId=requestAnimationFrame(this.animate),this._cameraModule.update(),this.renderer.render(this.scene,this._cameraModule.getCamera())}}function jv(n){const e=n.version||"v1";switch(e){case"v2":return new Uh(n);case"v1":return new Ov(n);default:return console.warn(`Version '${e}' not found. Falling back to v2.`),new Uh(n)}}class Xv{engine=null;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e){this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={backgroundColor:e.backgroundColor??1710618,version:e.version??"v1",showStats:e.showStats??!1,showViewCube:e.showViewCube??!0}}init(){if(this._isInitialized){console.warn("[Engine] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine] Cannot initialize destroyed engine.");return}try{const e={containerId:this.containerId,backgroundColor:this.options.backgroundColor,version:this.options.version,showStats:this.options.showStats,showViewCube:this.options.showViewCube};if(this.engine=jv(e),!this.engine)throw new Error("Failed to create engine instance");this._isInitialized=!0,this.unsubscribeTheme=Ze.subscribe(t=>{this.setTheme(t)}),this.setTheme(Ze.getTheme())}catch(e){throw console.error("[Engine] Failed to initialize engine:",e),this._isInitialized=!1,e}}setTheme(e){if(!this._isInitialized||!this.engine)return;let t;e.name==="dark"?t=1710618:e.name==="light"?t=16119285:t=this.options.backgroundColor??1710618,this.engine&&typeof this.engine.setBackgroundColor=="function"?this.engine.setBackgroundColor(t):this.engine&&this.engine.scene&&this.engine.scene.background&&this.engine.scene.background.setHex(t)}setLocales(){}isInitialized(){return this._isInitialized}loadModel(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine] Engine not initialized. Please call init() first.");return}if(!e){console.error("[Engine] Model URL is required.");return}this.engine.loader.loadModel(e,t)}getEngine(){return this.engine}destroy(){this._isDestroyed||(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1)}}class qv{element;content=null;isVisible=!1;onCloseCallback;options;mouseDownTime=0;CLICK_THRESHOLD=200;constructor(e){this.options=e,this.element=document.createElement("div"),this.element.className=`bim-right-key ${e?.className||""}`,e?.zIndex&&(this.element.style.zIndex=e.zIndex.toString()),document.body.appendChild(this.element)}init(){document.addEventListener("mousedown",this.handleGlobalClick),this.element.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation()}),this.options?.container&&(this.options.container.addEventListener("mousedown",this.handleContainerMouseDown),this.options.container.addEventListener("mouseup",this.handleContainerMouseUp),this.options.container.addEventListener("contextmenu",this.handleContainerContextMenu))}setTheme(e){}setLocales(){}destroy(){document.removeEventListener("mousedown",this.handleGlobalClick),this.options?.container&&(this.options.container.removeEventListener("mousedown",this.handleContainerMouseDown),this.options.container.removeEventListener("mouseup",this.handleContainerMouseUp),this.options.container.removeEventListener("contextmenu",this.handleContainerContextMenu)),this.unmountContent(),this.element.remove()}handleContainerMouseDown=e=>{e.button===2&&(this.mouseDownTime=Date.now())};handleContainerMouseUp=e=>{e.button!==2||Date.now()-this.mouseDownTime>this.CLICK_THRESHOLD||this.options?.onContext&&this.options.onContext(e)};handleContainerContextMenu=e=>{e.preventDefault()};setOnClose(e){this.onCloseCallback=e}mount(e){this.unmountContent(),this.content=e,this.element.appendChild(e.getElement())}unmountContent(){this.content&&(this.content.destroy(),this.element.innerHTML="",this.content=null)}show(e,t){this.element.classList.add("visible"),this.isVisible=!0,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`;const i=this.element.getBoundingClientRect(),s=window.innerWidth,r=window.innerHeight;let a=e,o=t;e+i.width>s&&(a=e-i.width),t+i.height>r&&(o=t-i.height),this.element.style.left=`${a}px`,this.element.style.top=`${o}px`}hide(){this.element.classList.remove("visible"),this.isVisible=!1,this.unmountContent(),this.onCloseCallback&&this.onCloseCallback()}handleGlobalClick=e=>{this.isVisible&&(this.element.contains(e.target)||this.hide())}}class il{element;options;unsubscribeLocale=null;unsubscribeTheme=null;activeSubMenu=null;constructor(e){this.options=e,this.element=document.createElement("ul"),this.element.className="bim-menu"}init(){this.render(),this.unsubscribeLocale=It.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=Ze.subscribe(e=>{this.setTheme(e)})}setTheme(e){const t=this.element.style;t.setProperty("--bim-ui_bg_color",e.panelBackground),t.setProperty("--bim-ui_text_primary",e.textPrimary),t.setProperty("--bim-ui_border_color",e.border),t.setProperty("--bim-ui_bg_hover",e.componentHover)}setLocales(){this.element.innerHTML="",this.render()}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.closeSubMenu(),this.element.remove()}getElement(){return this.element}render(){const{items:e,groupOrder:t}=this.options,i=new Map,s="default";e.forEach(a=>{const o=a.group||s;i.has(o)||i.set(o,[]),i.get(o).push(a)});let r=[];if(t){r=t.filter(a=>i.has(a));for(const a of i.keys())r.includes(a)||r.push(a)}else r=Array.from(i.keys());r.forEach((a,o)=>{if(o>0){const c=document.createElement("li");c.className="bim-menu-divider",this.element.appendChild(c)}const l=i.get(a);l.sort((c,h)=>(c.order||0)-(h.order||0)),l.forEach(c=>{c.visible!==!1&&this.element.appendChild(this.createItemElement(c))})})}createItemElement(e){const t=document.createElement("li"),i=!e.disabled;t.className=`bim-menu-item ${i?"":"disabled"}`;const s=document.createElement("div");s.className="bim-menu-item-icon",e.icon&&(s.innerHTML=e.icon),t.appendChild(s);const r=document.createElement("div");r.className="bim-menu-item-label",r.textContent=le(e.label),t.appendChild(r);const a=e.children,o=a&&a.length>0;if(o){const l=document.createElement("div");l.className="bim-menu-item-arrow",l.innerHTML='',t.appendChild(l),t.addEventListener("mouseenter",()=>this.openSubMenu(e,t))}else t.addEventListener("mouseenter",()=>this.closeSubMenu());return i&&t.addEventListener("click",l=>{l.stopPropagation(),console.log(`[BimMenu] Clicked item: ${e.id}`),o||(e.onClick?(console.log(`[BimMenu] Executing onClick for ${e.id}`),e.onClick()):console.warn(`[BimMenu] No onClick handler for ${e.id}`))}),t}openSubMenu(e,t){const i=e.children;if(!i||i.length===0)return;this.closeSubMenu();const s=document.createElement("div");s.style.position="fixed",s.style.zIndex="10001";const r=t.getBoundingClientRect();s.style.top=`${r.top}px`,s.style.left=`${r.right}px`,s.addEventListener("mousedown",l=>l.stopPropagation());const a=new il({items:i});a.init(),s.appendChild(a.element),document.body.appendChild(s),this.activeSubMenu={menu:a,container:s};const o=s.getBoundingClientRect();o.right>window.innerWidth&&(s.style.left=`${r.left-o.width}px`)}closeSubMenu(){this.activeSubMenu&&(this.activeSubMenu.menu.destroy(),this.activeSubMenu.container.remove(),this.activeSubMenu=null)}}class Nh extends jt{container;rightKeyPanel;contextHandlers=[];constructor(e,t){super(e),this.container=t,this.rightKeyPanel=new qv({zIndex:9e3,container:this.container,onContext:this.handleContextMenu}),this.rightKeyPanel.init()}destroy(){this.rightKeyPanel.destroy()}registerHandler(e){this.contextHandlers.push(e)}showMenu(e,t,i,s){if(!i||i.length===0)return;const r=new il({items:i,groupOrder:s});r.init(),this.rightKeyPanel.mount(r),this.rightKeyPanel.show(e,t)}hide(){this.rightKeyPanel.hide()}handleContextMenu=e=>{let t=null;for(const i of this.contextHandlers){const s=i(e);s&&s.length>0&&(t||(t=[]),t=t.concat(s))}t&&t.length>0?this.showMenu(e.clientX,e.clientY,t):this.hide()}}const Zv=n=>({id:"infoMenu",label:"menu.info",group:"info",icon:'',onClick:()=>{console.log("dianjile"),n.dialog?.showInfoDialog(),n.engine?.rightKey?.hide()}}),Yv=n=>({id:"fourMenu",label:"menu.info",icon:'',onClick:()=>{console.log("dianjile"),n.dialog?.showInfoDialog(),n.engine?.rightKey?.hide()}}),Kv=n=>({id:"infoMenu",label:"menu.info",icon:'',onClick:()=>{console.log("dianjile"),n.dialog?.showInfoDialog(),n.engine?.rightKey?.hide()}}),$v=n=>({id:"homeMenu",label:"menu.home",group:"home",children:[Kv(n),Yv(n)],icon:'',onClick:()=>{n.dialog?.showInfoDialog(),n.engine?.rightKey?.hide()}});class Jv extends jt{container;engineInstance=null;rightKey=null;constructor(e,t){super(e),this.container=t}initialize(e){this.engineInstance&&this.engineInstance.isInitialized()&&(console.warn("[EngineManager] 3D Engine already initialized. Destroying old instance..."),this.engineInstance.destroy(),this.engineInstance=null);try{return this.engineInstance=new Xv({container:this.container,...e}),this.engineInstance.init(),this.rightKey=new Nh(this.engine,this.container),this.rightKey.registerHandler(t=>[Zv(this.engine),$v(this.engine)]),this.engineInstance.isInitialized()}catch(t){return console.error("[EngineManager] Failed to initialize 3D engine:",t),this.engineInstance=null,!1}}isInitialized(){return this.engineInstance!==null&&this.engineInstance.isInitialized()}loadModel(e,t){if(!this.engineInstance||!this.engineInstance.isInitialized()){console.error("[EngineManager] 3D Engine not initialized. Please call initialize() first.");return}this.engineInstance.loadModel(e,t)}getEngine(){return this.engineInstance?this.engineInstance.getEngine():(console.warn("[EngineManager] 3D Engine not initialized."),null)}destroy(){this.engineInstance&&(this.engineInstance.destroy(),this.engineInstance=null),this.rightKey&&(this.rightKey.destroy(),this.rightKey=null)}}var gt=(n=>(n[n.Unchecked=0]="Unchecked",n[n.Checked=1]="Checked",n[n.Indeterminate=2]="Indeterminate",n))(gt||{});class Qv{config;element;children=[];parent=null;checkState=gt.Unchecked;contentEl;switcherEl;checkboxEl=null;titleEl;actionsEl;childrenContainer;onExpandChange;onCheckChange;onNodeClick;renderActions;constructor(e,t,i){this.config=e,this.onExpandChange=i.onExpand,this.onCheckChange=i.onCheck,this.onNodeClick=i.onClick,this.renderActions=t.renderActions,this.checkState=e.checked?gt.Checked:gt.Unchecked,this.element=this.createDom(t)}createDom(e){const t=document.createElement("div");t.className="bim-tree-node",this.config.disabled&&t.classList.add("is-disabled"),this.contentEl=document.createElement("div"),this.contentEl.className="bim-tree-node-content",this.switcherEl=document.createElement("span"),this.switcherEl.className="bim-tree-switcher",this.switcherEl.innerHTML='';const i=this.config.children&&this.config.children.length>0;if(i?this.config.expanded&&this.switcherEl.classList.add("is-expanded"):this.switcherEl.classList.add("is-hidden"),this.switcherEl.addEventListener("click",r=>{r.stopPropagation(),this.toggleExpand()}),this.contentEl.appendChild(this.switcherEl),e.checkable!==!1&&(this.checkboxEl=document.createElement("span"),this.checkboxEl.className="bim-tree-checkbox",this.updateCheckboxUI(),this.checkboxEl.addEventListener("click",r=>{r.stopPropagation(),!this.config.disabled&&this.toggleCheck()}),this.contentEl.appendChild(this.checkboxEl)),this.config.icon){const r=document.createElement("span");r.className="bim-tree-icon",r.innerHTML=this.config.icon.includes("`,this.contentEl.appendChild(r)}this.titleEl=document.createElement("span"),this.titleEl.className="bim-tree-title",this.updateLabel(),this.contentEl.appendChild(this.titleEl),this.actionsEl=document.createElement("div"),this.actionsEl.className="bim-tree-node-actions",this.actionsEl.addEventListener("click",r=>{r.stopPropagation()}),this.contentEl.appendChild(this.actionsEl),this.contentEl.addEventListener("click",r=>{if(r.stopPropagation(),this.config.disabled)return;(this.config.clickAction||"select")==="expand"?this.toggleExpand():this.onNodeClick(this)}),t.appendChild(this.contentEl),this.childrenContainer=document.createElement("div"),this.childrenContainer.className="bim-tree-children";const s=e.indent||24;return this.childrenContainer.style.paddingLeft=`${s}px`,this.config.expanded&&i&&this.childrenContainer.classList.add("is-visible"),t.appendChild(this.childrenContainer),t}setSelected(e){if(e){if(this.contentEl.classList.add("is-selected"),this.renderActions){const t=this.renderActions(this.config);this.actionsEl.innerHTML="",typeof t=="string"?this.actionsEl.innerHTML=t:t instanceof HTMLElement&&this.actionsEl.appendChild(t)}}else this.contentEl.classList.remove("is-selected"),this.actionsEl.innerHTML=""}updateLabel(){this.titleEl&&(this.titleEl.textContent=this.config.label)}toggleExpand(e){if(!this.config.children||this.config.children.length===0)return;const t=e!==void 0?e:!this.config.expanded;this.config.expanded=t,t?(this.switcherEl.classList.add("is-expanded"),this.childrenContainer.classList.add("is-visible")):(this.switcherEl.classList.remove("is-expanded"),this.childrenContainer.classList.remove("is-visible")),e===void 0&&this.onExpandChange(this)}toggleCheck(){const e=this.checkState!==gt.Checked;this.setChecked(e?gt.Checked:gt.Unchecked,!0)}setChecked(e,t=!1){this.checkState!==e&&(this.checkState=e,this.config.checked=e===gt.Checked,this.updateCheckboxUI(),t&&this.onCheckChange(this))}updateCheckboxUI(){this.checkboxEl&&(this.checkboxEl.classList.remove("is-checked","is-indeterminate"),this.checkState===gt.Checked?this.checkboxEl.classList.add("is-checked"):this.checkState===gt.Indeterminate&&this.checkboxEl.classList.add("is-indeterminate"))}appendChild(e){e.parent=this,this.children.push(e),this.childrenContainer.appendChild(e.element),this.children.length===1&&this.switcherEl.classList.remove("is-hidden")}destroy(){this.children.forEach(e=>e.destroy()),this.children=[],this.element.remove(),this.parent=null}}class e_{element;contentElement;searchInput=null;searchResults=null;options;nodeMap=new Map;rootNodes=[];selectedNode=null;unsubscribeLocale=null;unsubscribeTheme=null;clickOutsideHandler=null;onNodeCheck;onNodeSelect;onNodeExpand;constructor(e){this.options={checkable:!0,checkStrictly:!0,indent:24,defaultExpandAll:!0,enableSearch:!1,searchPlaceholder:"tree.searchPlaceholder",...e},this.element=document.createElement("div"),this.element.className="bim-tree",this.options.enableSearch&&this.createSearchDOM(),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tree-content",this.element.appendChild(this.contentElement),e.onNodeCheck&&(this.onNodeCheck=e.onNodeCheck),e.onNodeSelect&&(this.onNodeSelect=e.onNodeSelect),e.onNodeExpand&&(this.onNodeExpand=e.onNodeExpand)}createSearchDOM(){const e=document.createElement("div");e.className="bim-tree-search";const t=document.createElement("div");t.className="bim-tree-search-wrapper";const i=document.createElement("span");i.className="bim-tree-search-icon",i.innerHTML='',t.appendChild(i),this.searchInput=document.createElement("input"),this.searchInput.className="bim-tree-search-input",this.searchInput.type="text",this.searchInput.placeholder=le(this.options.searchPlaceholder||"搜索..."),this.searchInput.addEventListener("input",s=>{const r=s.target.value;this.handleSearch(r)}),t.appendChild(this.searchInput),e.appendChild(t),this.searchResults=document.createElement("div"),this.searchResults.className="bim-tree-search-results",e.appendChild(this.searchResults),this.element.appendChild(e),this.clickOutsideHandler=s=>{this.searchResults&&!this.searchResults.contains(s.target)&&!this.searchInput?.contains(s.target)&&this.searchResults.classList.remove("is-visible")},document.addEventListener("click",this.clickOutsideHandler)}init(){this.render(),this.unsubscribeLocale=It.subscribe(()=>this.setLocales()),this.unsubscribeTheme=Ze.subscribe(e=>this.setTheme(e)),this.setTheme(Ze.getTheme())}handleSearch(e){if(!this.searchResults)return;if(!e.trim()){this.searchResults.classList.remove("is-visible"),this.searchResults.innerHTML="";return}const t=[],i=e.toLowerCase();this.nodeMap.forEach(s=>{const r=s.config.label;r.toLowerCase().includes(i)&&t.push({node:s,label:r,path:this.getNodePath(s)})}),this.renderSearchResults(t)}getNodePath(e){const t=[];let i=e.parent;for(;i;)t.unshift(i.config.label),i=i.parent;return t.join(" > ")}renderSearchResults(e){if(this.searchResults){if(this.searchResults.innerHTML="",e.length===0){const t=document.createElement("div");t.className="bim-tree-search-item",t.style.cursor="default",t.style.color="#999",t.textContent="No results",this.searchResults.appendChild(t)}else e.forEach(t=>{const i=document.createElement("div");i.className="bim-tree-search-item";const s=document.createElement("span");s.className="bim-tree-search-item-title",s.textContent=t.label;const r=document.createElement("span");r.className="bim-tree-search-item-path",r.textContent=t.path,i.appendChild(s),t.path&&i.appendChild(r),i.addEventListener("click",()=>{this.revealNode(t.node)}),this.searchResults.appendChild(i)});this.searchResults.classList.add("is-visible")}}revealNode(e){this.searchResults&&(this.searchResults.classList.remove("is-visible"),this.searchInput&&(this.searchInput.value=""));let t=e.parent;for(;t;)t.toggleExpand(!0),t=t.parent;this.handleNodeSelect(e),setTimeout(()=>{e.element.scrollIntoView({behavior:"smooth",block:"center"})},100)}setTheme(e){const t=this.element.style;t.setProperty("--bim-ui_bg_color",e.panelBackground),t.setProperty("--bim-ui_text_primary",e.textPrimary),t.setProperty("--bim-ui_text_secondary",e.textSecondary||"#999"),t.setProperty("--bim-ui_border_color",e.border),t.setProperty("--bim-ui_bg_hover",e.componentHover),t.setProperty("--bim-primary_color",e.primary)}setLocales(){this.nodeMap.forEach(e=>e.updateLabel()),this.searchInput&&(this.searchInput.placeholder=le(this.options.searchPlaceholder||"tree.searchPlaceholder"))}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null),this.rootNodes.forEach(e=>e.destroy()),this.rootNodes=[],this.nodeMap.clear(),this.element.remove(),this.selectedNode=null}render(){this.contentElement.innerHTML="",this.nodeMap.clear(),this.rootNodes=[],this.options.data.forEach(e=>{this.createNodeRecursively(e,null)})}createNodeRecursively(e,t){e.expanded===void 0&&(e.expanded=this.options.defaultExpandAll);const i=new Qv(e,this.options,{onExpand:s=>{this.onNodeExpand&&this.onNodeExpand(s)},onCheck:s=>this.handleNodeCheck(s),onClick:s=>this.handleNodeSelect(s)});this.nodeMap.set(e.id,i),t?t.appendChild(i):(this.rootNodes.push(i),this.contentElement.appendChild(i.element)),e.children&&e.children.length>0&&e.children.forEach(s=>{this.createNodeRecursively(s,i)})}handleNodeSelect(e){this.selectedNode&&this.selectedNode!==e&&this.selectedNode.setSelected(!1),e.setSelected(!0),this.selectedNode=e,this.onNodeSelect&&this.onNodeSelect(e)}handleNodeCheck(e){const t=e.checkState===gt.Checked;if(this.onNodeCheck&&this.onNodeCheck(e),this.options.checkStrictly===!1)return;const i=(r,a)=>{r.children.forEach(o=>{o.config.disabled||(o.setChecked(a,!1),i(o,a))})};t?i(e,gt.Checked):i(e,gt.Unchecked);let s=e.parent;for(;s;){if(s.config.disabled){s=s.parent;continue}const r=s.children,a=r.every(l=>l.checkState===gt.Checked),o=r.every(l=>l.checkState===gt.Unchecked);a?s.setChecked(gt.Checked,!1):o?s.setChecked(gt.Unchecked,!1):s.setChecked(gt.Indeterminate,!1),s=s.parent}}getNode(e){return this.nodeMap.get(e)}checkNode(e,t){const i=this.nodeMap.get(e);i&&i.setChecked(t?gt.Checked:gt.Unchecked,!0)}expandAll(e){this.nodeMap.forEach(t=>t.toggleExpand(e))}getCheckedNodes(e=!1){const t=[];return this.nodeMap.forEach(i=>{(i.checkState===gt.Checked||e&&i.checkState===gt.Indeterminate)&&t.push(i.config)}),t}}class Bh{element;navElement;contentElement;options;activeId;tabMap=new Map;panelMap=new Map;unsubscribeLocale=null;unsubscribeTheme=null;navClickHandler=null;constructor(e){this.options=e,this.activeId=e.activeId||(e.tabs[0]?.id??null),e.tabs.forEach(t=>this.tabMap.set(t.id,t)),this.element=document.createElement("div"),this.element.className="bim-tab",this.navElement=document.createElement("div"),this.navElement.className="bim-tab__nav",this.navElement.setAttribute("role","tablist"),this.element.appendChild(this.navElement),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tab__content",this.element.appendChild(this.contentElement),this.options.container.appendChild(this.element)}init(){this.renderNav(),this.renderPanels(),this.setLocales(),this.setTheme(Ze.getTheme()),this.unsubscribeLocale=It.subscribe(()=>this.setLocales()),this.unsubscribeTheme=Ze.subscribe(e=>this.setTheme(e))}renderNav(){this.navElement.innerHTML="",this.navClickHandler=e=>{const t=e.target.closest(".bim-tab__item");if(!t)return;const i=t.dataset.id;!i||this.tabMap.get(i)?.disabled||this.activateTab(i)},this.navElement.addEventListener("click",this.navClickHandler),this.options.tabs.forEach(e=>{const t=document.createElement("button");if(t.type="button",t.className="bim-tab__item",t.dataset.id=e.id,t.setAttribute("role","tab"),t.id=`tab-${e.id}`,t.setAttribute("aria-selected",`${e.id===this.activeId}`),e.disabled&&(t.disabled=!0,t.setAttribute("aria-disabled","true"),t.classList.add("is-disabled")),e.icon){const s=document.createElement("span");s.className="bim-tab__icon",s.innerHTML=e.icon,t.appendChild(s)}const i=document.createElement("span");i.className="bim-tab__title",i.textContent=this.resolveTitle(e.title),t.appendChild(i),e.id===this.activeId&&t.classList.add("is-active"),this.navElement.appendChild(t)})}renderPanels(){this.contentElement.innerHTML="",this.panelMap.clear(),this.options.tabs.forEach(e=>{const t=document.createElement("div");t.className="bim-tab__panel",t.dataset.id=e.id,t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",`tab-${e.id}`),e.content instanceof HTMLElement?t.appendChild(e.content):typeof e.content=="string"&&(t.innerHTML=e.content),e.id===this.activeId?t.classList.add("is-active"):t.style.display="none",this.panelMap.set(e.id,t),this.contentElement.appendChild(t)})}activateTab(e){if(this.activeId===e)return;const t=this.tabMap.get(e);if(!t||t.disabled)return;this.activeId=e,this.navElement.querySelectorAll(".bim-tab__item").forEach(s=>{const r=s.dataset.id===e;s.classList.toggle("is-active",r),s.setAttribute("aria-selected",`${r}`)}),this.panelMap.forEach((s,r)=>{const a=r===e;s.classList.toggle("is-active",a),s.style.display=a?"block":"none"}),this.options.onChange&&this.options.onChange(e,t)}setTheme(e){const t=this.element.style;t.setProperty("--bim-tab-bg",e.panelBackground),t.setProperty("--bim-tab-nav-bg",e.panelBackground),t.setProperty("--bim-tab-text",e.textPrimary),t.setProperty("--bim-tab-text-secondary",e.textSecondary),t.setProperty("--bim-tab-text-active",e.primary),t.setProperty("--bim-tab-border",e.border),t.setProperty("--bim-tab-hover-bg",e.componentHover),t.setProperty("--bim-tab-active-bg",e.componentActive),t.setProperty("--bim-tab-icon",e.icon)}setLocales(){this.navElement.querySelectorAll(".bim-tab__item").forEach(t=>{const i=t.dataset.id;if(!i)return;const s=this.tabMap.get(i);if(!s)return;const r=t.querySelector(".bim-tab__title");r&&(r.textContent=this.resolveTitle(s.title))})}destroy(){this.navClickHandler&&(this.navElement.removeEventListener("click",this.navClickHandler),this.navClickHandler=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.panelMap.clear(),this.tabMap.clear(),this.element.remove()}resolveTitle(e){try{return le(e)||e}catch{return e}}}const Oh={测量:'',地图:'',框选放大:'',漫游:'',目录树:'',剖切:'',剖切盒:'',全屏:'',设置:'',拾曲面剖切:'',轴向剖切:'',主视角:'',文档:'',第一人称漫游:'',反向:'',路径漫游:'',适应到模型:'',隐藏:'',重置:'',标高:'',距离:'',最小距离:'',激光边距:'',角度:'',坡度:'',体积:'',空间体积:'',close:'',check:'',warning:'',error:'',success:'',plus:'',minus:'',arrowUp:'',arrowDown:'',arrowLeft:'',arrowRight:'',search:'',refresh:'',delete:'',edit:'',save:'',expand:'',collapse:'',default:''};function vt(n){const e=Oh[n];return e||(console.warn(`[IconManager] Icon "${n}" not found, using default icon`),Oh.default)}const t_=[{id:"root",label:"全部构件",expanded:!0,clickAction:"expand",children:[{id:"level-1",label:"一层",expanded:!1,icon:'',clickAction:"expand",children:[{id:"l1-wall",label:"墙体(128)"},{id:"l1-column",label:"柱(46)"},{id:"l1-beam",label:"梁(82)"},{id:"l1-slab",label:"楼板(12)"},{id:"l1-door",label:"门(24)"},{id:"l1-window",label:"窗(36)"}]},{id:"level-2",label:"二层",expanded:!1,clickAction:"expand",children:[{id:"l2-wall",label:"墙体(141)"},{id:"l2-column",label:"柱(52)"},{id:"l2-beam",label:"梁(90)"},{id:"l2-slab",label:"楼板(12)"},{id:"l2-door",label:"门(18)"},{id:"l2-window",label:"窗(40)"}]},{id:"level-3",label:"三层",expanded:!1,clickAction:"expand",children:[{id:"l3-wall",label:"墙体(136)"},{id:"l3-column",label:"柱(48)"},{id:"l3-beam",label:"梁(88)"},{id:"l3-slab",label:"楼板(12)"},{id:"l3-door",label:"门(16)"},{id:"l3-window",label:"窗(38)"}]},{id:"level-roof",label:"屋面层",expanded:!1,clickAction:"expand",children:[{id:"rf-slab",label:"屋面板(6)"},{id:"rf-beam",label:"屋面梁(24)"},{id:"rf-parapet",label:"女儿墙(18)"}]}]}];class i_ extends jt{toolbar=null;toolbarContainer=null;container;dialog=null;constructor(e,t){super(e),this.container=t,this.init()}init(){this.toolbarContainer=document.createElement("div"),this.toolbarContainer.id="bim-construct-tree",this.container.appendChild(this.toolbarContainer),this.toolbar=new zr({container:this.toolbarContainer,showLabel:!1,direction:"column",position:"top-left",align:"vertical",expand:"up"}),this.toolbar.init(),this.toolbar.setEngine(this.engine),this.toolbar.addGroup("construct-tree"),this.toolbar.addButton({id:"construct-tree-btn",groupId:"construct-tree",type:"button",label:"construct-tree",icon:vt("目录树"),onClick:()=>{this.openConstructTreeDialog()}}),this.toolbar.render()}openConstructTreeDialog(){this.setVisible(!1);const e=new e_({data:t_,checkable:!0,indent:0,enableSearch:!0,checkStrictly:!0,defaultExpandAll:!0,renderActions:o=>'',onNodeCheck:o=>{console.log("onNodeCheck",o)},onNodeSelect:o=>{console.log("onNodeSelect",o)},onNodeExpand:o=>{console.log("onNodeExpand",o),this.dialog?.fitWidth()}});e.init();const t=document.createElement("div");t.className="construct-tab__panel-content";const i=document.createElement("div");i.className="construct-tab__panel-content";const s=document.createElement("div");s.className="construct-tab__panel-content",s.appendChild(e.element);const r=document.createElement("div");r.className="construct-tab__container",r.style.height="100%",r.style.overflow="hidden";const a=new Bh({container:r,tabs:[{id:"component",title:"tab.component",content:s},{id:"system",title:"tab.system",content:t},{id:"space",title:"tab.space",content:i}],activeId:"component",onChange:()=>{this.dialog?.fitWidth()}});a.init(),this.dialog=this.engine.dialog.create({title:"constructTree.title",minWidth:320,height:420,content:r,position:{x:20,y:20},resizable:!1,onClose:()=>{a.destroy(),e.destroy(),this.setVisible(!0)}}),this.dialog?.fitWidth()}refresh(){this.toolbar?.render()}destroy(){this.toolbar?.destroy(),this.toolbar=null}addGroup(e,t){this.toolbar?.addGroup(e,t),this.toolbar?.render()}addButton(e){this.toolbar?.addButton(e),this.toolbar?.render()}setButtonVisibility(e,t){this.toolbar?.updateButtonVisibility(e,t)}setShowLabel(e){this.toolbar?.setShowLabel(e)}setVisible(e){this.toolbarContainer&&(this.toolbarContainer.style.visibility=e?"visible":"hidden")}setBackgroundColor(e){this.toolbar?.setBackgroundColor(e)}setColors(e){this.toolbar?.setColors(e)}}class s_{element;headerEl;contentEl;contentBoxEl;arrowEl;titleEl;config;parent;constructor(e,t){this.config=e,this.parent=t,this.element=this.createDom()}createDom(){const e=document.createElement("div");if(e.className=`bim-collapse-item ${this.config.className||""}`,this.config.disabled&&e.classList.add("is-disabled"),e.dataset.id=this.config.id,this.headerEl=document.createElement("div"),this.headerEl.className="bim-collapse-header",this.arrowEl=document.createElement("span"),this.arrowEl.className="bim-collapse-arrow",this.arrowEl.innerHTML='',this.headerEl.appendChild(this.arrowEl),this.config.icon){const t=document.createElement("span");t.className="bim-collapse-icon",t.innerHTML=this.config.icon,this.headerEl.appendChild(t)}if(this.titleEl=document.createElement("span"),this.titleEl.className="bim-collapse-title",this.titleEl.textContent=le(this.config.title),this.headerEl.appendChild(this.titleEl),this.config.extra){const t=document.createElement("div");t.className="bim-collapse-extra",typeof this.config.extra=="string"?t.innerHTML=this.config.extra:t.appendChild(this.config.extra),this.headerEl.appendChild(t)}return this.headerEl.addEventListener("click",()=>{this.config.disabled||this.parent.toggleItem(this.config.id)}),e.appendChild(this.headerEl),this.contentEl=document.createElement("div"),this.contentEl.className="bim-collapse-content is-hidden",this.contentBoxEl=document.createElement("div"),this.contentBoxEl.className="bim-collapse-content-box",typeof this.config.content=="string"?this.contentBoxEl.innerHTML=this.config.content:this.contentBoxEl.appendChild(this.config.content),this.contentEl.appendChild(this.contentBoxEl),e.appendChild(this.contentEl),e}updateLocale(){this.titleEl&&(this.titleEl.textContent=le(this.config.title))}setActive(e){e?(this.element.classList.add("is-active"),this.contentEl.classList.remove("is-hidden")):(this.element.classList.remove("is-active"),this.contentEl.classList.add("is-hidden"))}}class kh{element;options;items=new Map;activeIds=new Set;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e){this.options={bordered:!0,accordion:!1,...e},this.element=document.createElement("div"),this.element.className=`bim-collapse ${this.options.className||""}`,this.options.bordered||(this.element.style.border="none"),this.options.ghost&&this.element.classList.add("is-ghost");const t=typeof this.options.container=="string"?document.getElementById(this.options.container):this.options.container;t&&t.appendChild(this.element),this.options.activeIds&&this.options.activeIds.forEach(i=>this.activeIds.add(i)),this.init()}init(){this.options.items.forEach(e=>{const t=new s_(e,this);this.items.set(e.id,t),this.element.appendChild(t.element),this.activeIds.has(e.id)&&t.setActive(!0)}),this.unsubscribeLocale=It.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=Ze.subscribe(e=>{this.setTheme(e)}),this.setTheme(Ze.getTheme())}toggleItem(e){const t=this.activeIds.has(e);this.options.accordion?(this.activeIds.clear(),t||this.activeIds.add(e)):t?this.activeIds.delete(e):this.activeIds.add(e),this.refreshState(),this.options.onChange&&this.options.onChange(Array.from(this.activeIds))}refreshState(){this.items.forEach((e,t)=>{e.setActive(this.activeIds.has(t))})}setTheme(e){const t=this.element.style;t.setProperty("--bim-bg-color",e.panelBackground),t.setProperty("--bim-border-color",e.border),t.setProperty("--bim-text-color",e.textPrimary),t.setProperty("--bim-header-bg-color",e.componentHover),t.setProperty("--bim-header-hover-bg-color",e.componentHover),t.setProperty("--bim-content-bg-color",e.panelBackground),t.setProperty("--bim-disabled-color",e.textSecondary)}setLocales(){this.items.forEach(e=>e.updateLocale())}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove(),this.items.clear()}}class sl{element;options;unsubscribeTheme=null;constructor(e){this.options={bordered:!1,...e},this.element=this.createDom();const t=typeof this.options.container=="string"?document.getElementById(this.options.container):this.options.container;t&&t.appendChild(this.element),this.init()}init(){this.applyCustomStyles(),this.renderItems(),this.unsubscribeTheme=Ze.subscribe(e=>{this.setTheme(e)}),this.setTheme(Ze.getTheme())}createDom(){const e=document.createElement("div");return e.className=`bim-description ${this.options.className||""}`,this.options.bordered&&e.classList.add("is-bordered"),e}applyCustomStyles(){const e=this.element.style;this.options.fontSize&&e.setProperty("--bim-desc-font-size",this.options.fontSize),this.options.labelColor&&e.setProperty("--bim-desc-label-color",this.options.labelColor),this.options.valueColor&&e.setProperty("--bim-desc-value-color",this.options.valueColor),this.options.labelPadding&&e.setProperty("--bim-desc-label-padding",this.options.labelPadding),this.options.valuePadding&&e.setProperty("--bim-desc-value-padding",this.options.valuePadding)}renderItems(){this.element.innerHTML="",this.options.items.forEach(e=>{const t=document.createElement("div");t.className=`bim-description-item ${e.className||""}`;const i=document.createElement("div");i.className="bim-description-label",e.labelColor&&(i.style.color=e.labelColor),this.options.labelWidth&&(i.style.width=this.options.labelWidth),i.textContent=this.options.bordered?e.label:e.label+":";const s=document.createElement("div");s.className="bim-description-value",e.valueColor&&(s.style.color=e.valueColor),typeof e.value=="string"?s.innerHTML=e.value:s.appendChild(e.value),t.appendChild(i),t.appendChild(s),this.element.appendChild(t)})}setItems(e){this.options.items=e,this.renderItems()}setTheme(e){const t=this.element.style;t.setProperty("--bim-text-color",e.textPrimary),t.setProperty("--bim-label-color",e.textSecondary),t.setProperty("--bim-value-color",e.textPrimary),t.setProperty("--bim-border-color",e.border)}setLocales(){}destroy(){this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}}class n_ extends jt{dialogId="property-panel-dialog";dialog=null;constructor(e){super(e)}init(){document.addEventListener("bim-demo:open-property-panel",()=>{this.show()})}show(){if(!this.engine.dialog){console.warn("Dialog manager is not initialized");return}if(this.isOpen())return;const e=360,t=document.body.clientWidth-e-40;console.log("x",t),this.dialog=this.engine.dialog.create({id:this.dialogId,title:"panel.property.title",content:"",width:`${e}px`,height:"500px",position:{x:t,y:20},showMask:!1,resizable:!0,onClose:()=>{this.hide()}});const i=document.createElement("div");i.style.height="100%",i.style.display="flex",i.style.flexDirection="column",this.dialog.setContent(i),new Bh({container:i,tabs:[{id:"props",title:"panel.property.tab.props",content:this.createPropsTabContent()},{id:"material",title:"panel.property.tab.material",content:this.createMaterialTabContent()}]}).init()}createPropsTabContent(){const e=document.createElement("div");return e.style.height="100%",e.style.overflowY="auto",new kh({container:e,accordion:!0,activeIds:["base","location"],items:[{id:"base",title:"panel.property.base",content:this.createBaseInfoContent()},{id:"advanced",title:"panel.property.advanced",content:this.createAdvancedInfoContent(),disabled:!1}]}),e}createMaterialTabContent(){const e=document.createElement("div");return e.style.height="100%",e.style.overflowY="auto",new kh({container:e,accordion:!0,activeIds:["material"],items:[{id:"material",title:"panel.property.material",content:this.createMaterialContent()}]}),e}createBaseInfoContent(){const e=document.createElement("div");return new sl({container:e,labelWidth:"80px",bordered:!0,items:[{label:"Guid",value:'1f8d-4a2e-9c'},{label:"Name",value:"Basic Wall: Generic - 200mm"},{label:"Type",value:"Basic Wall"},{label:"Level",value:"Trane - Centrifugal Water Chiller - CVHF 2 Stage direct drive TAG(BP-RHS-1100RT) 0202104531 1"}]}),e}createAdvancedInfoContent(){const e=document.createElement("div");return new sl({container:e,labelWidth:"100px",bordered:!0,items:[{label:"Area",value:"32.5 m²"},{label:"Volume",value:"6.5 m³"},{label:"Length",value:"5000 mm"},{label:"Phase",value:"New Construction"}]}),e}createMaterialContent(){const e=document.createElement("div"),t=document.createElement("div");t.style.display="flex",t.style.alignItems="center",t.style.marginBottom="4px",t.innerHTML=` Concrete - Cast-in-Place Gray - `;const i=document.createElement("div");return new sl({container:i,items:[{label:"Preview",value:t},{label:"Class",value:"Concrete"},{label:"Density",value:"2400 kg/m³"},{label:"Thermal",value:"0.6 W/(m·K)"}]}),e.appendChild(i),e}isOpen(){return this.dialog!==null}hide(){this.dialog&&(this.dialog.destroy(),this.dialog=null)}destroy(){this.hide()}}const r_={distance:'',minDistance:'',angle:'',elevation:'',volume:'',laserDistance:'',slope:'',spaceVolume:''};class kn{element;options;activeMode;isExpanded;result=null;config;draftConfig=null;view="main";static CONFIG_CACHE_KEY="bim-engine:measure:config";static DEFAULT_CONFIG={unit:"mm",precision:2};toolButtons=new Map;toggleBtn;toggleTextEl;mainValueValueEl;mainValueLabelEl;mainNumberEl;mainUnitEl;xyzBoxEl;xyzXEl;xyzYEl;xyzZEl;clearBtn;settingsBtn;mainViewEl;settingsViewEl;unitSelectEl;precisionSelectEl;saveSettingsBtn;cancelSettingsBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.activeMode=e.defaultMode??"distance",this.isExpanded=e.defaultExpanded??!1,this.config=this.loadConfigFromCache()??{...kn.DEFAULT_CONFIG},this.element=this.createDom()}init(){this.unsubscribeLocale=Dt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=Ze.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(Ze.getTheme()),this.applyExpandedState(),this.applyActiveModeState(),this.applyViewState(),this.renderResult()}setTheme(e){const t=this.element.style;t.setProperty("--bim-measure-border",e.border??"rgba(255, 255, 255, 0.12)"),t.setProperty("--bim-measure-divider",e.border??"rgba(255, 255, 255, 0.10)"),t.setProperty("--bim-measure-icon-color",e.icon??"#ddd"),t.setProperty("--bim-measure-label-color",e.textSecondary??"rgba(255, 255, 255, 0.70)"),t.setProperty("--bim-measure-value-color",e.textPrimary??"rgba(255, 255, 255, 0.90)"),t.setProperty("--bim-measure-danger",e.primary??"#46d369"),t.setProperty("--bim-measure-primary",e.primary??"#0078d4"),t.setProperty("--bim-measure-primary-hover",e.primaryHover??"#0063b1"),t.setProperty("--bim-measure-btn-bg",e.componentBackground??"rgba(255, 255, 255, 0.06)"),t.setProperty("--bim-measure-btn-hover-bg",e.componentHover??"rgba(255, 255, 255, 0.10)"),t.setProperty("--bim-measure-btn-active-bg",e.componentActive??"rgba(255, 255, 255, 0.14)")}setLocales(){for(const[t,i]of this.toolButtons.entries())i.title=le(this.getModeI18nKey(t)),i.setAttribute("aria-label",i.title);this.toggleBtn.title=this.isExpanded?le("measure.actions.collapse"):le("measure.actions.expand"),this.toggleBtn.setAttribute("aria-label",this.toggleBtn.title),this.toggleTextEl&&(this.toggleTextEl.textContent=this.toggleBtn.title),this.clearBtn.textContent=le("measure.actions.clearAll"),this.settingsBtn.title=le("measure.actions.settings"),this.settingsBtn.setAttribute("aria-label",this.settingsBtn.title),this.mainValueLabelEl.textContent=le(this.getModeValueLabelI18nKey(this.activeMode)),this.element.querySelectorAll("[data-i18n-key]").forEach(t=>{const i=t.dataset.i18nKey;i&&(t.textContent=le(i))}),this.saveSettingsBtn.textContent=le("measure.settings.save"),this.cancelSettingsBtn.textContent=le("measure.settings.cancel")}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}getActiveMode(){return this.activeMode}switchMode(e){this.setActiveMode(e)}setActiveMode(e){this.activeMode!==e&&(this.activeMode=e,this.applyActiveModeState(),this.mainValueLabelEl.textContent=le(this.getModeValueLabelI18nKey(this.activeMode)),this.options.onModeChange&&this.options.onModeChange(e),this.renderResult(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded))}setResult(e){this.result=e,this.renderResult()}clearAll(){this.result=null,this.renderResult(),this.options.onClearAll&&this.options.onClearAll()}openSettings(){this.enterSettingsView(),this.options.onSettings&&this.options.onSettings()}getConfig(){return{...this.config}}setConfig(e,t=!1){const i={unit:e.unit??this.config.unit,precision:e.precision??this.config.precision};this.config=i,t&&this.saveConfigToCache(i),this.renderResult(),this.view==="settings"&&this.syncSettingsFormFromConfig(i)}setExpanded(e){this.isExpanded!==e&&(this.isExpanded=e,this.applyExpandedState(),this.setLocales(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded))}getExpanded(){return this.isExpanded}createDom(){const e=document.createElement("div");e.className="bim-measure-panel",this.mainViewEl=document.createElement("div"),this.mainViewEl.className="bim-measure-main";const t=document.createElement("div");t.className="bim-measure-tools";const i=document.createElement("div");i.className="bim-measure-tool-grid";const s=["distance","minDistance","angle","elevation","volume","laserDistance","slope","spaceVolume"],r=` + `;const i=document.createElement("div");return new sl({container:i,items:[{label:"Preview",value:t},{label:"Class",value:"Concrete"},{label:"Density",value:"2400 kg/m³"},{label:"Thermal",value:"0.6 W/(m·K)"}]}),e.appendChild(i),e}isOpen(){return this.dialog!==null}hide(){this.dialog&&(this.dialog.destroy(),this.dialog=null)}destroy(){this.hide()}}const r_={distance:'',minDistance:'',angle:'',elevation:'',volume:'',laserDistance:'',slope:'',spaceVolume:''};class kn{element;options;activeMode;isExpanded;result=null;config;draftConfig=null;view="main";static CONFIG_CACHE_KEY="bim-engine:measure:config";static DEFAULT_CONFIG={unit:"mm",precision:2};toolButtons=new Map;toggleBtn;toggleTextEl;mainValueValueEl;mainValueLabelEl;mainNumberEl;mainUnitEl;xyzBoxEl;xyzXEl;xyzYEl;xyzZEl;clearBtn;settingsBtn;mainViewEl;settingsViewEl;unitSelectEl;precisionSelectEl;saveSettingsBtn;cancelSettingsBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.activeMode=e.defaultMode??"distance",this.isExpanded=e.defaultExpanded??!1,this.config=this.loadConfigFromCache()??{...kn.DEFAULT_CONFIG},this.element=this.createDom()}init(){this.unsubscribeLocale=It.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=Ze.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(Ze.getTheme()),this.applyExpandedState(),this.applyActiveModeState(),this.applyViewState(),this.renderResult()}setTheme(e){const t=this.element.style;t.setProperty("--bim-measure-border",e.border??"rgba(255, 255, 255, 0.12)"),t.setProperty("--bim-measure-divider",e.border??"rgba(255, 255, 255, 0.10)"),t.setProperty("--bim-measure-icon-color",e.icon??"#ddd"),t.setProperty("--bim-measure-label-color",e.textSecondary??"rgba(255, 255, 255, 0.70)"),t.setProperty("--bim-measure-value-color",e.textPrimary??"rgba(255, 255, 255, 0.90)"),t.setProperty("--bim-measure-danger",e.primary??"#46d369"),t.setProperty("--bim-measure-primary",e.primary??"#0078d4"),t.setProperty("--bim-measure-primary-hover",e.primaryHover??"#0063b1"),t.setProperty("--bim-measure-btn-bg",e.componentBackground??"rgba(255, 255, 255, 0.06)"),t.setProperty("--bim-measure-btn-hover-bg",e.componentHover??"rgba(255, 255, 255, 0.10)"),t.setProperty("--bim-measure-btn-active-bg",e.componentActive??"rgba(255, 255, 255, 0.14)")}setLocales(){for(const[t,i]of this.toolButtons.entries())i.title=le(this.getModeI18nKey(t)),i.setAttribute("aria-label",i.title);this.toggleBtn.title=this.isExpanded?le("measure.actions.collapse"):le("measure.actions.expand"),this.toggleBtn.setAttribute("aria-label",this.toggleBtn.title),this.toggleTextEl&&(this.toggleTextEl.textContent=this.toggleBtn.title),this.clearBtn.textContent=le("measure.actions.clearAll"),this.settingsBtn.title=le("measure.actions.settings"),this.settingsBtn.setAttribute("aria-label",this.settingsBtn.title),this.mainValueLabelEl.textContent=le(this.getModeValueLabelI18nKey(this.activeMode)),this.element.querySelectorAll("[data-i18n-key]").forEach(t=>{const i=t.dataset.i18nKey;i&&(t.textContent=le(i))}),this.saveSettingsBtn.textContent=le("measure.settings.save"),this.cancelSettingsBtn.textContent=le("measure.settings.cancel")}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}getActiveMode(){return this.activeMode}switchMode(e){this.setActiveMode(e)}setActiveMode(e){this.activeMode!==e&&(this.activeMode=e,this.applyActiveModeState(),this.mainValueLabelEl.textContent=le(this.getModeValueLabelI18nKey(this.activeMode)),this.options.onModeChange&&this.options.onModeChange(e),this.renderResult(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded))}setResult(e){this.result=e,this.renderResult()}clearAll(){this.result=null,this.renderResult(),this.options.onClearAll&&this.options.onClearAll()}openSettings(){this.enterSettingsView(),this.options.onSettings&&this.options.onSettings()}getConfig(){return{...this.config}}setConfig(e,t=!1){const i={unit:e.unit??this.config.unit,precision:e.precision??this.config.precision};this.config=i,t&&this.saveConfigToCache(i),this.renderResult(),this.view==="settings"&&this.syncSettingsFormFromConfig(i)}setExpanded(e){this.isExpanded!==e&&(this.isExpanded=e,this.applyExpandedState(),this.setLocales(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded))}getExpanded(){return this.isExpanded}createDom(){const e=document.createElement("div");e.className="bim-measure-panel",this.mainViewEl=document.createElement("div"),this.mainViewEl.className="bim-measure-main";const t=document.createElement("div");t.className="bim-measure-tools";const i=document.createElement("div");i.className="bim-measure-tool-grid";const s=["distance","minDistance","angle","elevation","volume","laserDistance","slope","spaceVolume"],r=` @@ -4905,5 +4905,5 @@ void main() { - `,this.settingsBtn.addEventListener("click",()=>{this.openSettings()}),g.appendChild(this.clearBtn),g.appendChild(this.settingsBtn),this.mainViewEl.appendChild(g),this.settingsViewEl=this.createSettingsDom(),e.appendChild(this.mainViewEl),e.appendChild(this.settingsViewEl),e}createSettingsDom(){const e=document.createElement("div");e.className="bim-measure-settings";const t=document.createElement("div");t.className="bim-measure-settings-title",t.dataset.i18nKey="measure.settings.title",e.appendChild(t);const i=document.createElement("div");i.className="bim-measure-settings-row";const s=document.createElement("div");s.className="label",s.dataset.i18nKey="measure.settings.unit",this.unitSelectEl=document.createElement("select"),this.unitSelectEl.className="bim-measure-settings-select",this.unitSelectEl.appendChild(this.makeOption("m")),this.unitSelectEl.appendChild(this.makeOption("cm")),this.unitSelectEl.appendChild(this.makeOption("mm")),this.unitSelectEl.appendChild(this.makeOption("km")),i.appendChild(s),i.appendChild(this.unitSelectEl),e.appendChild(i);const r=document.createElement("div");r.className="bim-measure-settings-hint",r.dataset.i18nKey="measure.settings.hint",e.appendChild(r);const a=document.createElement("div");a.className="bim-measure-settings-row";const o=document.createElement("div");o.className="label",o.dataset.i18nKey="measure.settings.precision",this.precisionSelectEl=document.createElement("select"),this.precisionSelectEl.className="bim-measure-settings-select",this.precisionSelectEl.appendChild(this.makePrecisionOption(0)),this.precisionSelectEl.appendChild(this.makePrecisionOption(1)),this.precisionSelectEl.appendChild(this.makePrecisionOption(2)),this.precisionSelectEl.appendChild(this.makePrecisionOption(3)),a.appendChild(o),a.appendChild(this.precisionSelectEl),e.appendChild(a);const l=document.createElement("div");return l.className="bim-measure-settings-actions",this.saveSettingsBtn=document.createElement("button"),this.saveSettingsBtn.type="button",this.saveSettingsBtn.className="bim-measure-settings-save",this.saveSettingsBtn.addEventListener("click",()=>{this.saveSettings()}),this.cancelSettingsBtn=document.createElement("button"),this.cancelSettingsBtn.type="button",this.cancelSettingsBtn.className="bim-measure-settings-cancel",this.cancelSettingsBtn.addEventListener("click",()=>{this.cancelSettings()}),l.appendChild(this.saveSettingsBtn),l.appendChild(this.cancelSettingsBtn),e.appendChild(l),this.syncSettingsFormFromConfig(this.config),e}makeOption(e){const t=document.createElement("option");return t.value=e,t.textContent=e,t}makePrecisionOption(e){const t=document.createElement("option");return t.value=String(e),t.textContent=e===0?"0":`0.${"0".repeat(e)}`,t}enterSettingsView(){this.draftConfig={...this.config},this.view="settings",this.syncSettingsFormFromConfig(this.config),this.applyViewState()}saveSettings(){const e=this.unitSelectEl.value||this.config.unit,t=Number(this.precisionSelectEl.value),i={unit:e,precision:this.isValidPrecision(t)?t:this.config.precision};this.config=i,this.saveConfigToCache(i),this.draftConfig=null,this.view="main",this.applyViewState(),this.renderResult(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded)}cancelSettings(){this.draftConfig&&(this.config={...this.draftConfig}),this.draftConfig=null,this.view="main",this.applyViewState(),this.renderResult(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded)}syncSettingsFormFromConfig(e){this.unitSelectEl.value=e.unit,this.precisionSelectEl.value=String(e.precision)}applyViewState(){this.view==="settings"?(this.mainViewEl.style.display="none",this.settingsViewEl.style.display="block"):(this.mainViewEl.style.display="block",this.settingsViewEl.style.display="none")}loadConfigFromCache(){try{const e=localStorage.getItem(kn.CONFIG_CACHE_KEY);if(!e)return null;const t=JSON.parse(e);if(!t||typeof t!="object")return null;const i=t.unit,s=t.precision;return!this.isValidUnit(i)||!this.isValidPrecision(s)?null:{unit:i,precision:s}}catch{return null}}saveConfigToCache(e){try{localStorage.setItem(kn.CONFIG_CACHE_KEY,JSON.stringify(e))}catch{}}isValidUnit(e){return e==="m"||e==="cm"||e==="mm"||e==="km"}isValidPrecision(e){return e===0||e===1||e===2||e===3}applyExpandedState(){let e=0;for(const t of this.toolButtons.values())e>=4?t.style.display=this.isExpanded?"":"none":t.style.display="",e++;this.isExpanded?this.toggleBtn.classList.add("is-expanded"):this.toggleBtn.classList.remove("is-expanded")}applyActiveModeState(){for(const[e,t]of this.toolButtons.entries())e===this.activeMode?t.classList.add("is-active"):t.classList.remove("is-active")}renderResult(){if(this.activeMode==="laserDistance")this.mainValueLabelEl.style.display="none",this.mainNumberEl.textContent=le(this.getModeI18nKey("laserDistance")),this.mainUnitEl.textContent="",this.mainNumberEl.classList.add("is-laser-text");else{this.mainValueLabelEl.style.display="",this.mainValueLabelEl.textContent=le(this.getModeValueLabelI18nKey(this.activeMode));const e=this.formatMainValueParts(this.activeMode,this.result);this.mainNumberEl.textContent=e.numberText,this.mainUnitEl.textContent=e.unitText,this.mainNumberEl.classList.remove("is-laser-text")}if(this.activeMode==="distance"){this.xyzBoxEl.style.display="";const e=this.result?.xyz;if(!e){this.xyzXEl.textContent="--",this.xyzYEl.textContent="--",this.xyzZEl.textContent="--";return}this.xyzXEl.textContent=this.formatNumberWithPrecision(e.x,this.config.precision),this.xyzYEl.textContent=this.formatNumberWithPrecision(e.y,this.config.precision),this.xyzZEl.textContent=this.formatNumberWithPrecision(e.z,this.config.precision);return}this.xyzBoxEl.style.display="none"}getModeI18nKey(e){return`measure.modes.${e}`}getModeValueLabelI18nKey(e){return`measure.labels.value.${e}`}formatNumberWithPrecision(e,t){return e.toFixed(t)}convertMmToUnit(e,t){switch(t){case"mm":return e;case"cm":return e/10;case"m":return e/1e3;case"km":return e/1e6;default:return e}}getUnitI18nKey(e){return`measure.units.${e}`}convertMm3ToUnit3(e,t){switch(t){case"mm":return e;case"cm":return e/1e3;case"m":return e/1e9;case"km":return e/1e18;default:return e}}formatMainValueParts(e,t){if(e==="laserDistance")return{numberText:le(this.getModeI18nKey("laserDistance")),unitText:""};if(!t)return this.getEmptyValuePartsByMode(e);switch(e){case"distance":return this.formatLengthParts(t.distanceMm);case"minDistance":return this.formatLengthParts(t.minDistanceMm);case"angle":return this.formatFixedUnitParts(t.angleDeg,le("measure.units.deg"));case"elevation":return this.formatFixedUnitParts(t.elevationMm===void 0?void 0:t.elevationMm/1e3,le("measure.units.m"));case"volume":return this.formatVolumeParts(t.volumeM3);case"slope":return this.formatFixedUnitParts(t.slopePercent,le("measure.units.percent"));case"spaceVolume":return this.formatVolumeParts(t.spaceVolumeM3);default:return{numberText:"--",unitText:""}}}getEmptyValuePartsByMode(e){switch(e){case"distance":case"minDistance":return{numberText:"--",unitText:le(this.getUnitI18nKey(this.config.unit))};case"angle":return{numberText:"--",unitText:le("measure.units.deg")};case"elevation":return{numberText:"--",unitText:le("measure.units.m")};case"volume":case"spaceVolume":return{numberText:"--",unitText:`${this.config.unit}³`};case"slope":return{numberText:"--",unitText:le("measure.units.percent")};default:return{numberText:"--",unitText:""}}}formatFixedUnitParts(e,t){return e==null||Number.isNaN(e)?{numberText:"--",unitText:t}:{numberText:this.formatNumberWithPrecision(e,this.config.precision),unitText:t}}formatLengthParts(e){const t=le(this.getUnitI18nKey(this.config.unit));if(e==null||Number.isNaN(e))return{numberText:"--",unitText:t};const i=this.convertMmToUnit(e,this.config.unit);return{numberText:this.formatNumberWithPrecision(i,this.config.precision),unitText:t}}formatVolumeParts(e){const t=`${this.config.unit}³`;if(e==null||Number.isNaN(e))return{numberText:"--",unitText:t};const i=this.convertMm3ToUnit3(e,this.config.unit);return{numberText:this.formatNumberWithPrecision(i,this.config.precision),unitText:t}}}class a_ extends jt{dialogId="measure-dialog";dialog=null;panel=null;config=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}const e=250,t=300,i=20,s=this.engine.container,r=s.clientWidth,a=s.clientHeight,o=r-e-i,l=(a-t)/2;this.destroy(),this.panel=new kn({defaultMode:"distance",defaultExpanded:!1,onModeChange:h=>{console.log("[MeasureDialogManager] 当前测量方式已切换:",h)},onClearAll:()=>{console.log("[MeasureDialogManager] 删除全部(仅 UI 清空,本次不清理引擎侧内容)")},onSettings:()=>{console.log("[MeasureDialogManager] 打开设置(仅预留接口)")},onExpandedChange:()=>{this.dialog?.fitHeight(!1)}}),this.panel.init(),this.config=this.panel.getConfig();const c=document.createElement("div");c.style.padding="12px",c.appendChild(this.panel.element),this.dialog=this.engine.dialog.create({id:this.dialogId,title:"measure.dialogTitle",content:c,width:e,height:"auto",position:{x:o,y:l},onClose:()=>{this.engine.toolbar?.setBtnActive("measure",!1)}}),this.dialog.init(),this.dialog.fitHeight(!1)}getActiveMode(){return this.panel?this.panel.getActiveMode():null}switchMode(e){this.panel&&this.panel.switchMode(e)}setMeasureResult(e){this.panel&&this.panel.setResult(e)}getConfig(){return this.panel&&(this.config=this.panel.getConfig()),this.config?{...this.config}:null}setConfig(e,t=!0){if(this.panel){this.panel.setConfig(e,t),this.config=this.panel.getConfig(),this.dialog?.fitHeight(!1);return}const i=this.config,s={unit:e.unit??i?.unit??"mm",precision:e.precision??i?.precision??2};this.config=s}clearAll(){this.panel&&this.panel.clearAll()}openSettings(){this.panel&&this.panel.openSettings()}destroy(){this.dialog&&(this.dialog.destroy(),this.dialog=null),this.panel&&(this.panel.destroy(),this.panel=null)}}class o_{element;options;hideBtn;reverseBtn;resetBtn;hideLabelEl;reverseLabelEl;resetLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.element=this.createDom()}init(){this.unsubscribeLocale=Dt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=Ze.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(Ze.getTheme())}setTheme(e){const t=this.element.style;t.setProperty("--bim-section-btn-bg",e.componentBackground??"rgba(255, 255, 255, 0.06)"),t.setProperty("--bim-section-btn-hover",e.componentHover??"rgba(255, 255, 255, 0.10)"),t.setProperty("--bim-section-btn-active",e.componentActive??"rgba(255, 255, 255, 0.14)"),t.setProperty("--bim-primary-color",e.primary??"#1890ff"),t.setProperty("--bim-icon-color",e.icon??"#ccc"),t.setProperty("--bim-text-color",e.textSecondary??"rgba(255, 255, 255, 0.90)"),t.setProperty("--bim-text-active-color",e.textPrimary??"#fff")}setLocales(){this.hideLabelEl.textContent=le("sectionPlane.actions.hide"),this.reverseLabelEl.textContent=le("sectionPlane.actions.reverse"),this.resetLabelEl.textContent=le("sectionPlane.actions.reset"),this.hideBtn.title=le("sectionPlane.actions.hide"),this.reverseBtn.title=le("sectionPlane.actions.reverse"),this.resetBtn.title=le("sectionPlane.actions.reset")}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}createDom(){const e=document.createElement("div");return e.className="section-plane-panel",this.hideBtn=this.createButton("hide",'',()=>{this.options.onHide&&this.options.onHide()}),this.reverseBtn=this.createButton("reverse",'',()=>{this.options.onReverse&&this.options.onReverse()}),this.resetBtn=this.createButton("reset",'',()=>{this.options.onReset&&this.options.onReset()}),e.appendChild(this.hideBtn),e.appendChild(this.reverseBtn),e.appendChild(this.resetBtn),e}createButton(e,t,i){const s=document.createElement("button");s.type="button",s.className="section-plane-btn";const r=document.createElement("div");r.className="section-plane-btn-icon",r.innerHTML=t,s.appendChild(r);const a=document.createElement("div");return a.className="section-plane-btn-label",s.appendChild(a),e==="hide"?this.hideLabelEl=a:e==="reverse"?this.reverseLabelEl=a:this.resetLabelEl=a,s.addEventListener("click",i),s}}class l_ extends jt{dialogId="section-plane-dialog";dialog=null;panel=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}this.destroy(),this.panel=new o_({onHide:()=>{console.log("[SectionPlaneDialogManager] 隐藏")},onReverse:()=>{console.log("[SectionPlaneDialogManager] 反向")},onReset:()=>{console.log("[SectionPlaneDialogManager] 重置")}}),this.panel.init();const e=240,t=120,i=20,s=50,r=this.engine.container,a=r.clientWidth,o=r.clientHeight,l=a-e-i,c=o-t-s;this.dialog=this.engine.dialog.create({id:this.dialogId,title:"sectionPlane.dialogTitle",width:e,height:t,position:{x:l,y:c},draggable:!0,resizable:!1,content:this.panel.element,onClose:()=>{this.engine.toolbar?.setBtnActive("section-plane",!1),this.hide()}})}hide(){this.destroy()}destroy(){this.dialog&&(this.dialog.destroy(),this.dialog=null),this.panel&&(this.panel.destroy(),this.panel=null)}}class c_{element;options;isHidden=!1;activeAxis="x";hideBtn;reverseBtn;hideLabelEl;reverseLabelEl;axisXBtn;axisYBtn;axisZBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.activeAxis=e.defaultAxis??"x",this.element=this.createDom()}init(){this.unsubscribeLocale=Dt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=Ze.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(Ze.getTheme()),this.updateHideButtonState(),this.updateAxisButtonsState()}setTheme(e){const t=this.element.style;t.setProperty("--bim-section-axis-btn-bg",e.componentBackground??"rgba(255, 255, 255, 0.06)"),t.setProperty("--bim-section-axis-btn-hover",e.componentHover??"rgba(255, 255, 255, 0.10)"),t.setProperty("--bim-section-axis-btn-active",e.componentActive??"rgba(255, 255, 255, 0.14)"),t.setProperty("--bim-primary-color",e.primary??"#1890ff"),t.setProperty("--bim-icon-color",e.icon??"#ccc"),t.setProperty("--bim-text-color",e.textSecondary??"rgba(255, 255, 255, 0.90)"),t.setProperty("--bim-text-active-color",e.textPrimary??"#fff")}setLocales(){this.hideLabelEl.textContent=le("sectionAxis.actions.hide"),this.reverseLabelEl.textContent=le("sectionAxis.actions.reverse"),this.hideBtn.title=le("sectionAxis.actions.hide"),this.reverseBtn.title=le("sectionAxis.actions.reverse"),this.axisXBtn.title=le("sectionAxis.actions.axisX"),this.axisYBtn.title=le("sectionAxis.actions.axisY"),this.axisZBtn.title=le("sectionAxis.actions.axisZ")}setHiddenState(e){this.isHidden=e,this.updateHideButtonState()}getHiddenState(){return this.isHidden}setActiveAxis(e){this.activeAxis=e,this.updateAxisButtonsState()}getActiveAxis(){return this.activeAxis}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}createDom(){const e=document.createElement("div");e.className="section-axis-panel";const t=document.createElement("div");t.className="section-axis-row-1",this.hideBtn=this.createButton("hide",'',()=>this.handleHideToggle()),this.reverseBtn=this.createButton("reverse",'',()=>this.handleReverse()),t.appendChild(this.hideBtn),t.appendChild(this.reverseBtn);const i=document.createElement("div");return i.className="section-axis-row-2",this.axisXBtn=this.createAxisButton("axisX","X",()=>this.handleAxisChange("x")),this.axisYBtn=this.createAxisButton("axisY","Y",()=>this.handleAxisChange("y")),this.axisZBtn=this.createAxisButton("axisZ","Z",()=>this.handleAxisChange("z")),i.appendChild(this.axisXBtn),i.appendChild(this.axisYBtn),i.appendChild(this.axisZBtn),e.appendChild(t),e.appendChild(i),e}createButton(e,t,i){const s=document.createElement("button");s.type="button",s.className="section-axis-btn";const r=document.createElement("div");r.className="section-axis-btn-icon",r.innerHTML=t,s.appendChild(r);const a=document.createElement("div");return a.className="section-axis-btn-label",s.appendChild(a),e==="hide"?this.hideLabelEl=a:e==="reverse"&&(this.reverseLabelEl=a),s.addEventListener("click",i),s}createAxisButton(e,t,i){const s=document.createElement("button");s.type="button",s.className="section-axis-btn section-axis-btn-text";const r=document.createElement("div");return r.className="section-axis-btn-label",r.textContent=t,s.appendChild(r),s.addEventListener("click",i),s}handleHideToggle(){this.isHidden=!this.isHidden,this.updateHideButtonState(),this.options.onHideToggle&&this.options.onHideToggle(this.isHidden)}handleReverse(){this.options.onReverse&&this.options.onReverse()}handleAxisChange(e){this.activeAxis!==e&&(this.activeAxis=e,this.updateAxisButtonsState(),this.options.onAxisChange&&this.options.onAxisChange(e))}updateHideButtonState(){this.isHidden?this.hideBtn.classList.add("active"):this.hideBtn.classList.remove("active")}updateAxisButtonsState(){this.axisXBtn.classList.toggle("active",this.activeAxis==="x"),this.axisYBtn.classList.toggle("active",this.activeAxis==="y"),this.axisZBtn.classList.toggle("active",this.activeAxis==="z")}}class h_ extends jt{dialogId="section-axis-dialog";dialog=null;panel=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}this.destroy(),this.panel=new c_({defaultAxis:"x",defaultHidden:!1,onHideToggle:c=>{console.log("[SectionAxisDialogManager] 隐藏切换:",c)},onReverse:()=>{console.log("[SectionAxisDialogManager] 反向剖切")},onAxisChange:c=>{console.log("[SectionAxisDialogManager] 切换轴向:",c)}}),this.panel.init();const e=240,t=20,i=50,s=this.engine.container,r=s.clientWidth,a=s.clientHeight,o=r-e-t,l=a-i-200;this.dialog=this.engine.dialog.create({id:this.dialogId,title:"sectionAxis.dialogTitle",width:e,height:"auto",position:{x:o,y:l},draggable:!0,resizable:!1,content:this.panel.element,onClose:()=>{this.engine.toolbar?.setBtnActive("section-axis",!1),this.hide()}}),this.dialog.init(),this.dialog.fitHeight(!1)}hide(){this.destroy()}getHiddenState(){return this.panel?.getHiddenState()??!1}setHiddenState(e){this.panel?.setHiddenState(e)}getActiveAxis(){return this.panel?.getActiveAxis()??"x"}setActiveAxis(e){this.panel?.setActiveAxis(e)}destroy(){this.dialog&&(this.dialog.destroy(),this.dialog=null),this.panel&&(this.panel.destroy(),this.panel=null)}}const Fh={x:{min:0,max:100},y:{min:0,max:100},z:{min:0,max:100}};class u_{element;options;isHidden=!1;isReversed=!1;range;hideBtn;reverseBtn;fitBtn;resetBtn;hideLabelEl;reverseLabelEl;fitLabelEl;resetLabelEl;xLabelEl;yLabelEl;zLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;xSlider;ySlider;zSlider;xMinHandle;xMaxHandle;yMinHandle;yMaxHandle;zMinHandle;zMaxHandle;dragState={isDragging:!1,axis:null,handleType:null,pointerId:null};constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.isReversed=e.defaultReversed??!1,this.range=JSON.parse(JSON.stringify(e.defaultRange??Fh))}init(){this.element=this.createPanel(),this.unsubscribeLocale=Dt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=Ze.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(Ze.getTheme()),this.updateButtonStates(),this.updateAllSlidersUI(),this.setupDragListeners()}setHiddenState(e){this.isHidden=e,this.updateButtonStates()}getHiddenState(){return this.isHidden}setReversedState(e){this.isReversed=e,this.updateButtonStates()}getReversedState(){return this.isReversed}setRange(e){e.x&&(this.range.x={...this.range.x,...e.x}),e.y&&(this.range.y={...this.range.y,...e.y}),e.z&&(this.range.z={...this.range.z,...e.z}),this.updateAllSlidersUI()}getRange(){return JSON.parse(JSON.stringify(this.range))}reset(){this.isHidden=this.options.defaultHidden??!1,this.isReversed=this.options.defaultReversed??!1,this.range=JSON.parse(JSON.stringify(this.options.defaultRange??Fh)),this.updateButtonStates(),this.updateAllSlidersUI(),this.options.onReset?.(),this.options.onRangeChange?.(this.range)}createPanel(){const e=document.createElement("div");e.className="section-box-panel";const t=document.createElement("div");t.className="section-box-row-buttons",this.hideBtn=this.createButton("hide",le("sectionBox.actions.hide"),()=>{this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle?.(this.isHidden)},"hide"),this.reverseBtn=this.createButton("reverse",le("sectionBox.actions.reverse"),()=>{this.isReversed=!this.isReversed,this.updateButtonStates(),this.options.onReverseToggle?.(this.isReversed)},"reverse"),this.fitBtn=this.createButton("fit",le("sectionBox.actions.fitToModel"),()=>{this.options.onFitToModel?.()},"fit"),this.resetBtn=this.createButton("reset",le("sectionBox.actions.reset"),()=>this.reset(),"reset"),[this.hideBtn,this.reverseBtn,this.fitBtn,this.resetBtn].forEach(s=>t.appendChild(s));const i=document.createElement("div");return i.className="section-box-sliders",i.addEventListener("pointerdown",s=>s.stopPropagation()),this.xSlider=this.createSlider("x",le("sectionBox.axes.x")),this.ySlider=this.createSlider("y",le("sectionBox.axes.y")),this.zSlider=this.createSlider("z",le("sectionBox.axes.z")),[this.xSlider,this.ySlider,this.zSlider].forEach(s=>i.appendChild(s)),e.appendChild(t),e.appendChild(i),e}createButton(e,t,i,s){const r=document.createElement("button");r.className="section-box-btn",r.title=t;const a=document.createElement("div");a.className="section-box-btn-icon",a.innerHTML=this.getIconSVG(e);const o=document.createElement("div");return o.className="section-box-btn-label",o.textContent=t,s==="hide"?this.hideLabelEl=o:s==="reverse"?this.reverseLabelEl=o:s==="fit"?this.fitLabelEl=o:s==="reset"&&(this.resetLabelEl=o),r.appendChild(a),r.appendChild(o),r.addEventListener("click",i),r}createSlider(e,t){const i=document.createElement("div");i.className="section-box-slider";const s=document.createElement("div");s.className="section-box-slider-label",s.textContent=t,e==="x"?this.xLabelEl=s:e==="y"?this.yLabelEl=s:this.zLabelEl=s;const r=document.createElement("div");r.className="section-box-slider-track";const a=document.createElement("div");a.className="section-box-slider-range";const o=document.createElement("div");o.className="section-box-slider-handle",o.setAttribute("data-axis",e),o.setAttribute("data-handle","min");const l=document.createElement("div");return l.className="section-box-slider-handle",l.setAttribute("data-axis",e),l.setAttribute("data-handle","max"),r.append(a,o,l),i.append(s,r),e==="x"?(this.xMinHandle=o,this.xMaxHandle=l):e==="y"?(this.yMinHandle=o,this.yMaxHandle=l):(this.zMinHandle=o,this.zMaxHandle=l),i}setupDragListeners(){[this.xMinHandle,this.xMaxHandle,this.yMinHandle,this.yMaxHandle,this.zMinHandle,this.zMaxHandle].forEach(t=>{t.addEventListener("pointerdown",s=>{s.preventDefault(),s.stopPropagation(),t.setPointerCapture(s.pointerId),this.dragState={isDragging:!0,axis:t.getAttribute("data-axis"),handleType:t.getAttribute("data-handle"),pointerId:s.pointerId},t.classList.add("dragging"),t.closest(".section-box-slider").style.zIndex="100"}),t.addEventListener("pointermove",s=>{this.dragState.isDragging&&this.dragState.pointerId===s.pointerId&&this.onDragging(s)});const i=s=>{this.dragState.isDragging&&this.dragState.pointerId===s.pointerId&&(t.releasePointerCapture(s.pointerId),t.closest(".section-box-slider").style.zIndex="",t.classList.remove("dragging"),this.dragState.isDragging=!1,this.dragState.pointerId=null)};t.addEventListener("pointerup",i),t.addEventListener("pointercancel",i)})}onDragging(e){const{axis:t,handleType:i}=this.dragState;if(!t||!i)return;const a=(t==="x"?this.xSlider:t==="y"?this.ySlider:this.zSlider).querySelector(".section-box-slider-track").getBoundingClientRect();let o=(e.clientX-a.left)/a.width*100;o=Math.max(0,Math.min(100,o));const l=this.range[t];i==="min"?l.min=Math.min(o,l.max):l.max=Math.max(o,l.min),this.updateSliderUI(t),this.options.onRangeChange?.(this.range)}updateSliderUI(e){const t=this.range[e],i=e==="x"?this.xMinHandle:e==="y"?this.yMinHandle:this.zMinHandle,s=e==="x"?this.xMaxHandle:e==="y"?this.yMaxHandle:this.zMaxHandle,a=(e==="x"?this.xSlider:e==="y"?this.ySlider:this.zSlider).querySelector(".section-box-slider-range");i.style.left=`${t.min}%`,s.style.left=`${t.max}%`,a.style.left=`${t.min}%`,a.style.width=`${t.max-t.min}%`,i.setAttribute("data-value",Math.round(t.min).toString()),s.setAttribute("data-value",Math.round(t.max).toString())}updateAllSlidersUI(){["x","y","z"].forEach(e=>this.updateSliderUI(e))}updateButtonStates(){this.hideBtn&&this.hideBtn.classList.toggle("active",this.isHidden),this.reverseBtn&&this.reverseBtn.classList.toggle("active",this.isReversed)}getIconSVG(e){return{hide:'',reverse:'',fit:'',reset:''}[e]||""}setLocales(){this.hideLabelEl&&(this.hideLabelEl.textContent=le("sectionBox.actions.hide"),this.reverseLabelEl.textContent=le("sectionBox.actions.reverse"),this.fitLabelEl.textContent=le("sectionBox.actions.fitToModel"),this.resetLabelEl.textContent=le("sectionBox.actions.reset"),this.xLabelEl.textContent=le("sectionBox.axes.x"),this.yLabelEl.textContent=le("sectionBox.axes.y"),this.zLabelEl.textContent=le("sectionBox.axes.z"),this.hideBtn.title=le("sectionBox.actions.hide"),this.reverseBtn.title=le("sectionBox.actions.reverse"),this.fitBtn.title=le("sectionBox.actions.fitToModel"),this.resetBtn.title=le("sectionBox.actions.reset"))}setTheme(e){if(!this.element)return;const t=this.element.style;t.setProperty("--bim-section-box-btn-bg",e.componentBackground??"rgba(255, 255, 255, 0.06)"),t.setProperty("--bim-section-box-btn-hover",e.componentHover??"rgba(255, 255, 255, 0.10)"),t.setProperty("--bim-section-box-btn-active",e.componentActive??"rgba(255, 255, 255, 0.14)"),t.setProperty("--bim-primary-color",e.primary??"#1890ff"),t.setProperty("--bim-icon-color",e.icon??"#ccc"),t.setProperty("--bim-text-color",e.textSecondary??"rgba(255, 255, 255, 0.90)"),t.setProperty("--bim-text-active-color",e.textPrimary??"#fff")}destroy(){this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element&&this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class d_ extends jt{dialogId="section-box-dialog";dialog=null;panel=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}this.destroy(),this.panel=new u_({defaultHidden:!1,defaultReversed:!1,onHideToggle:c=>{console.log("[SectionBoxDialogManager] 隐藏切换:",c)},onReverseToggle:c=>{console.log("[SectionBoxDialogManager] 反向切换:",c)},onFitToModel:()=>{console.log("[SectionBoxDialogManager] 适应到模型")},onReset:()=>{console.log("[SectionBoxDialogManager] 重置")},onRangeChange:c=>{console.log("[SectionBoxDialogManager] 范围变化:",c)}}),this.panel.init();const e=280,t=20,i=50,s=this.engine.container,r=s.clientWidth,a=s.clientHeight,o=r-e-t,l=a-i-300;this.dialog=this.engine.dialog.create({id:this.dialogId,title:"sectionBox.dialogTitle",width:e,height:"auto",position:{x:o,y:l},draggable:!0,resizable:!1,content:this.panel.element,onClose:()=>{this.engine.toolbar?.setBtnActive("section-box",!1),this.hide()}}),this.dialog.init(),this.dialog.fitHeight(!1)}hide(){this.destroy()}getHiddenState(){return this.panel?.getHiddenState()??!1}setHiddenState(e){this.panel?.setHiddenState(e)}getReversedState(){return this.panel?.getReversedState()??!1}setReversedState(e){this.panel?.setReversedState(e)}getRange(){return this.panel?.getRange()??null}setRange(e){this.panel?.setRange(e)}destroy(){this.dialog&&(this.dialog.destroy(),this.dialog=null),this.panel&&(this.panel.destroy(),this.panel=null)}}class p_{element;options;state={mode:"none",isPlanViewActive:!1,speed:1,gravity:!1,collision:!1,characterModel:"construction-worker",walkMode:"walk"};planViewBtn;pathModeBtn;walkModeBtn;settingsContainer;speedControl;speedDecreaseBtn;speedIncreaseBtn;speedDisplay;gravityCheckbox;gravityLabel;collisionCheckbox;collisionLabel;characterModelSelect;characterModelLabel;walkModeSelect;walkModeLabel;exitBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.state.speed=e.defaultSpeed??1,this.state.gravity=e.defaultGravity??!1,this.state.collision=e.defaultCollision??!1,this.state.characterModel=e.defaultCharacterModel??"construction-worker",this.state.walkMode=e.defaultWalkMode??"walk"}init(){this.element=this.createPanel(),this.updateSettingsView(),this.unsubscribeLocale=Dt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=Ze.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(Ze.getTheme())}setPlanViewActive(e){this.state.isPlanViewActive=e,this.updateButtonStates()}setPathModeActive(e){if(!e&&this.state.mode!=="path")return;const t=e?"path":"none";this.setMode(t)}getState(){return{...this.state}}createPanel(){const e=document.createElement("div");e.className="walk-control-panel";const t=this.createLeftButtons(),i=document.createElement("div");i.className="walk-divider",this.settingsContainer=this.createSettingsContainer();const s=document.createElement("div");s.className="walk-divider";const r=this.createExitButton();return e.appendChild(t),e.appendChild(i),e.appendChild(this.settingsContainer),e.appendChild(s),e.appendChild(r),e}createLeftButtons(){const e=document.createElement("div");return e.className="walk-control-left",this.planViewBtn=this.createIconButton("plan-view",()=>{this.state.isPlanViewActive=!this.state.isPlanViewActive,this.updateButtonStates(),this.options.onPlanViewToggle?.(this.state.isPlanViewActive)}),this.pathModeBtn=this.createIconButton("path",()=>{const t=this.state.mode==="path"?"none":"path";this.setMode(t),this.options.onPathModeToggle?.(t==="path")}),this.walkModeBtn=this.createIconButton("walk",()=>{const t=this.state.mode==="walk"?"none":"walk";this.setMode(t),this.options.onWalkModeToggle?.(t==="walk")}),e.appendChild(this.planViewBtn),e.appendChild(this.pathModeBtn),e.appendChild(this.walkModeBtn),e}createSettingsContainer(){const e=document.createElement("div");e.className="walk-control-settings",this.speedControl=this.createSpeedControl();const t=document.createElement("label");t.className="walk-checkbox-wrapper walk-checkbox-gravity",this.gravityCheckbox=document.createElement("input"),this.gravityCheckbox.type="checkbox",this.gravityCheckbox.className="walk-checkbox",this.gravityCheckbox.checked=this.state.gravity,this.gravityCheckbox.addEventListener("change",()=>{this.state.gravity=this.gravityCheckbox.checked,this.options.onGravityToggle?.(this.state.gravity)}),this.gravityLabel=document.createElement("span"),this.gravityLabel.className="walk-checkbox-label",t.appendChild(this.gravityCheckbox),t.appendChild(this.gravityLabel);const i=document.createElement("label");i.className="walk-checkbox-wrapper walk-checkbox-collision",this.collisionCheckbox=document.createElement("input"),this.collisionCheckbox.type="checkbox",this.collisionCheckbox.className="walk-checkbox",this.collisionCheckbox.checked=this.state.collision,this.collisionCheckbox.addEventListener("change",()=>{this.state.collision=this.collisionCheckbox.checked,this.options.onCollisionToggle?.(this.state.collision)}),this.collisionLabel=document.createElement("span"),this.collisionLabel.className="walk-checkbox-label",i.appendChild(this.collisionCheckbox),i.appendChild(this.collisionLabel);const s=document.createElement("div");s.className="walk-select-wrapper walk-select-wrapper-character-model",this.characterModelLabel=document.createElement("label"),this.characterModelLabel.className="walk-select-label",this.characterModelSelect=document.createElement("select"),this.characterModelSelect.className="walk-select walk-select-character-model",this.characterModelSelect.addEventListener("change",()=>{this.state.characterModel=this.characterModelSelect.value,this.options.onCharacterModelChange?.(this.state.characterModel)}),s.appendChild(this.characterModelLabel),s.appendChild(this.characterModelSelect);const r=document.createElement("div");return r.className="walk-select-wrapper walk-select-wrapper-walk-mode",this.walkModeLabel=document.createElement("label"),this.walkModeLabel.className="walk-select-label",this.walkModeSelect=document.createElement("select"),this.walkModeSelect.className="walk-select walk-select-walk-mode",this.walkModeSelect.addEventListener("change",()=>{this.state.walkMode=this.walkModeSelect.value,this.options.onWalkModeChange?.(this.state.walkMode)}),r.appendChild(this.walkModeLabel),r.appendChild(this.walkModeSelect),e.appendChild(this.speedControl),e.appendChild(s),e.appendChild(r),e.appendChild(t),e.appendChild(i),e}createSpeedControl(){const e=document.createElement("div");e.className="walk-speed-control";const t=document.createElement("label");t.className="walk-speed-label",t.textContent=le("walkControl.speed");const i=document.createElement("div");return i.className="walk-speed-group",this.speedDecreaseBtn=document.createElement("button"),this.speedDecreaseBtn.className="walk-speed-btn",this.speedDecreaseBtn.textContent="-",this.speedDecreaseBtn.addEventListener("click",()=>{this.state.speed>1&&(this.state.speed--,this.updateSpeedDisplay(),this.options.onSpeedChange?.(this.state.speed))}),this.speedDisplay=document.createElement("div"),this.speedDisplay.className="walk-speed-display",this.speedDisplay.textContent=`${this.state.speed}X`,this.speedIncreaseBtn=document.createElement("button"),this.speedIncreaseBtn.className="walk-speed-btn",this.speedIncreaseBtn.textContent="+",this.speedIncreaseBtn.addEventListener("click",()=>{this.state.speed<10&&(this.state.speed++,this.updateSpeedDisplay(),this.options.onSpeedChange?.(this.state.speed))}),i.appendChild(this.speedDecreaseBtn),i.appendChild(this.speedDisplay),i.appendChild(this.speedIncreaseBtn),e.appendChild(t),e.appendChild(i),e}createIconButton(e,t){const i=document.createElement("button");return i.className=`walk-icon-btn walk-icon-btn-${e}`,i.innerHTML=this.getIconSVG(e),i.addEventListener("click",t),i}createExitButton(){const e=document.createElement("button");return e.className="walk-exit-btn",e.addEventListener("click",()=>{this.options.onExit?.()}),this.exitBtn=e,e}setMode(e){const t=this.state.mode;t==="walk"&&e!=="walk"&&this.options.onWalkModeToggle?.(!1),t==="path"&&e!=="path"&&this.options.onPathModeToggle?.(!1),this.state.mode=e,e==="path"?(this.state.gravity=!1,this.state.collision=!1,this.gravityCheckbox.checked=!1,this.gravityCheckbox.disabled=!0,this.collisionCheckbox.checked=!1,this.collisionCheckbox.disabled=!0):(this.gravityCheckbox.disabled=!1,this.collisionCheckbox.disabled=!1),this.updateButtonStates(),this.updateSettingsView(),this.updateSpeedButtonStates()}updateButtonStates(){this.planViewBtn.classList.toggle("active",this.state.isPlanViewActive),this.pathModeBtn.classList.toggle("active",this.state.mode==="path"),this.walkModeBtn.classList.toggle("active",this.state.mode==="walk")}updateSettingsView(){const e=this.speedControl,t=this.gravityCheckbox.parentElement,i=this.collisionCheckbox.parentElement,s=this.characterModelSelect.parentElement,r=this.walkModeSelect.parentElement;this.state.mode==="walk"?(e.style.display="none",t.style.display="flex",i.style.display="flex",s.style.display="flex",r.style.display="flex"):(e.style.display="flex",t.style.display="flex",i.style.display="flex",s.style.display="none",r.style.display="none")}updateSpeedDisplay(){this.speedDisplay.textContent=`${this.state.speed}X`,this.updateSpeedButtonStates()}updateSpeedButtonStates(){this.speedDecreaseBtn.disabled=this.state.speed<=1,this.speedIncreaseBtn.disabled=this.state.speed>=10}getIconSVG(e){return{"plan-view":Ft("地图"),path:Ft("地图"),walk:Ft("漫游")}[e]||""}setLocales(){const e=this.speedControl.querySelector(".walk-speed-label");e&&(e.textContent=le("walkControl.speed")),this.gravityLabel.textContent=le("walkControl.gravity"),this.collisionLabel.textContent=le("walkControl.collision"),this.characterModelLabel.textContent=le("walkControl.characterModel.label"),this.characterModelSelect.innerHTML="";const t=document.createElement("option");t.value="construction-worker",t.textContent=le("walkControl.characterModel.constructionWorker"),t.selected=this.state.characterModel==="construction-worker",this.characterModelSelect.appendChild(t);const i=document.createElement("option");i.value="office-male",i.textContent=le("walkControl.characterModel.officeMale"),i.selected=this.state.characterModel==="office-male",this.characterModelSelect.appendChild(i),this.walkModeLabel.textContent=le("walkControl.walkMode.label"),this.walkModeSelect.innerHTML="";const s=document.createElement("option");s.value="walk",s.textContent=le("walkControl.walkMode.walk"),s.selected=this.state.walkMode==="walk",this.walkModeSelect.appendChild(s);const r=document.createElement("option");r.value="run",r.textContent=le("walkControl.walkMode.run"),r.selected=this.state.walkMode==="run",this.walkModeSelect.appendChild(r),this.exitBtn.textContent=le("walkControl.exit")}setTheme(e){if(!this.element)return;const t=this.element.style;t.setProperty("--bim-walk-control-bg",e.panelBackground??"rgba(0, 0, 0, 0.8)"),t.setProperty("--bim-walk-btn-hover",e.componentHover??"rgba(255, 255, 255, 0.15)"),t.setProperty("--bim-walk-btn-active",e.componentActive??"rgba(255, 255, 255, 0.3)"),t.setProperty("--bim-primary-color",e.primary??"#1890ff"),t.setProperty("--bim-primary-hover",e.primaryHover??"#40a9ff"),t.setProperty("--bim-icon-color",e.icon??"#ccc"),t.setProperty("--bim-text-color",e.textPrimary??"#fff"),t.setProperty("--bim-divider-color",e.border??"rgba(255, 255, 255, 0.2)"),t.setProperty("--bim-speed-group-bg",e.componentHover??"rgba(255, 255, 255, 0.1)"),t.setProperty("--bim-speed-btn-bg",e.componentHover??"rgba(255, 255, 255, 0.1)"),t.setProperty("--bim-speed-btn-hover",e.componentActive??"rgba(255, 255, 255, 0.2)"),t.setProperty("--bim-select-bg",e.componentHover??"rgba(255, 255, 255, 0.1)"),t.setProperty("--bim-select-border",e.border??"rgba(255, 255, 255, 0.2)"),t.setProperty("--bim-select-option-bg",e.panelBackground??"#333")}destroy(){this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element&&this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class m_{element;unsubscribeLocale=null;unsubscribeTheme=null;constructor(){}init(){this.element=this.createPanel(),this.unsubscribeLocale=Dt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=Ze.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(Ze.getTheme())}createPanel(){const e=document.createElement("div");return e.className="walk-path-panel",e.style.padding="20px",e.style.color="var(--bim-text-color, #fff)",e.textContent="路径漫游内容待实现",e}setLocales(){}setTheme(e){}destroy(){this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element&&this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class f_ extends jt{dialogId="walk-path-dialog";dialog=null;panel=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}this.destroy(),this.panel=new m_,this.panel.init();const e=300,t=400,i=20,s=this.engine.container,r=s.clientHeight,o=s.clientWidth-e-i,l=(r-t)/2;this.dialog=this.engine.dialog.create({id:this.dialogId,title:"walkControl.path.dialogTitle",width:e,height:t,position:{x:o,y:l},draggable:!0,resizable:!1,content:this.panel.element,onClose:()=>{this.engine.walkControl&&this.engine.walkControl.panel&&this.engine.walkControl.panel.setPathModeActive(!1),this.hide()}}),this.dialog.init()}hide(){this.destroy()}destroy(){const e=this.dialog;this.dialog=null,e&&e.destroy(),this.panel&&(this.panel.destroy(),this.panel=null)}}class g_ extends jt{panel=null;pathManager=null;constructor(e){super(e)}init(){this.pathManager=new f_(this.engine),this.pathManager.init()}show(){if(!this.engine.toolbar){console.warn("Toolbar not initialized");return}this.engine.toolbar.hide(),this.panel=new p_({onPlanViewToggle:e=>{console.log("[WalkControl] 地图:",e),e?this.engine.map?.show():this.engine.map?.hide(),this.emit("walk:plan-view-toggle",{isActive:e})},onPathModeToggle:e=>{console.log("[WalkControl] 路径漫游:",e),e?this.pathManager?.show():this.pathManager?.hide(),this.emit("walk:path-mode-toggle",{isActive:e})},onWalkModeToggle:e=>{console.log("[WalkControl] 漫游模式:",e),e&&this.pathManager?.hide(),this.emit("walk:walk-mode-toggle",{isActive:e})},onSpeedChange:e=>{console.log("[WalkControl] 速度变化:",e),this.emit("walk:speed-change",{speed:e})},onGravityToggle:e=>{console.log("[WalkControl] 重力:",e),this.emit("walk:gravity-toggle",{enabled:e})},onCollisionToggle:e=>{console.log("[WalkControl] 碰撞:",e),this.emit("walk:collision-toggle",{enabled:e})},onCharacterModelChange:e=>{console.log("[WalkControl] 角色模型:",e)},onWalkModeChange:e=>{console.log("[WalkControl] 行走模式:",e)},onExit:()=>{this.hide()}}),this.panel.init(),this.engine.map?.isOpen()&&this.panel.setPlanViewActive(!0),this.engine.on("map:opened",()=>{this.panel?.setPlanViewActive(!0)}),this.engine.on("map:closed",()=>{this.panel?.setPlanViewActive(!1)}),this.engine.container?(this.panel.element.style.position="absolute",this.panel.element.style.bottom="20px",this.panel.element.style.left="50%",this.panel.element.style.transform="translateX(-50%)",this.panel.element.style.zIndex="1000",this.engine.container.appendChild(this.panel.element)):console.warn("[WalkControlManager] Container not found")}hide(){this.pathManager?.hide(),this.panel&&(this.panel.destroy(),this.panel=null),this.engine.toolbar&&this.engine.toolbar.show()}destroy(){this.hide(),this.pathManager?.destroy(),this.pathManager=null}}class v_{element;unsubscribeLocale=null;unsubscribeTheme=null;constructor(){}init(){this.element=this.createPanel(),this.unsubscribeLocale=Dt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=Ze.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(Ze.getTheme())}createPanel(){const e=document.createElement("div");return e.className="map-panel",e.style.padding="20px",e.style.color="#fff",e.textContent="地图内容待实现",e}setLocales(){}setTheme(e){}destroy(){this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element&&this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class __ extends jt{dialogId="map-dialog";dialog=null;panel=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}if(this.isOpen())return;this.panel=new v_,this.panel.init();const e=300,t=400,i=20,s=20,a=this.engine.container.clientHeight,o=i,l=a-t-s;this.dialog=this.engine.dialog.create({id:this.dialogId,title:"map.dialogTitle",width:e,height:t,position:{x:o,y:l},draggable:!0,resizable:!1,content:this.panel.element,onClose:()=>{this.hide()}}),this.dialog.init(),this.emit("map:opened",{})}hide(){this.destroy(),this.emit("map:closed",{})}isOpen(){return this.dialog!==null}destroy(){const e=this.dialog;this.dialog=null,e&&e.destroy(),this.panel&&(this.panel.destroy(),this.panel=null)}}class x_{events=new Map;on(e,t){return this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t),()=>this.off(e,t)}off(e,t){const i=this.events.get(e);if(!i)return;const s=i.indexOf(t);s!==-1&&i.splice(s,1)}emit(e,t){const i=this.events.get(e);i&&i.forEach(s=>{try{s(t)}catch(r){console.error(`[EventEmitter] Error in listener for event "${e}":`,r)}})}clear(){this.events.clear()}}class b_ extends x_{container;wrapper=null;toolbar=null;constructTreeBtn=null;buttonGroup=null;dialog=null;engine=null;rightKey=null;propertyPanel=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;map=null;constructor(e,t){super();const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,t?.locale&&Dt.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):Ze.setTheme(t.theme)),this.init()}emit(e,t){super.emit(e,t)}on(e,t){return super.on(e,t)}setLocale(e){Dt.setLocale(e)}getLocale(){return Dt.getLocale()}setTheme(e){Ze.setTheme(e)}setCustomTheme(e){Ze.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper),this.engine=new Jv(this,this.wrapper),this.dialog=new tu(this,this.wrapper),this.toolbar=new Jh(this,this.wrapper),this.buttonGroup=new Qh(this,this.wrapper),this.rightKey=new Nh(this,this.wrapper),this.constructTreeBtn=new i_(this,this.wrapper),this.propertyPanel=new n_(this),this.measure=new a_(this),this.sectionPlane=new l_(this),this.sectionAxis=new h_(this),this.sectionBox=new d_(this),this.walkControl=new g_(this),this.walkControl.init(),this.map=new __(this),this.map.init(),this.updateTheme(Ze.getTheme()),Ze.subscribe(e=>{this.updateTheme(e)})}updateTheme(e){this.wrapper&&(this.wrapper.style.backgroundColor=e.background,this.wrapper.style.color=e.textPrimary)}destroy(){this.toolbar?.destroy(),this.buttonGroup?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.propertyPanel?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.container.innerHTML="",this.clear()}}const y_=Object.freeze(Object.defineProperty({__proto__:null,createHomeButton:n=>({id:"home",groupId:"group-1",type:"button",label:"toolbar.home",icon:Ft("主视角"),keepActive:!0,onClick:e=>{console.log("首页按钮被点击:",e.id),n.emit("ui:open-dialog",{id:"home-info"})}})},Symbol.toStringTag,{value:"Module"})),M_=Object.freeze(Object.defineProperty({__proto__:null,createZoomBoxButton:n=>({id:"zoom-box",groupId:"group-1",keepActive:!0,type:"button",label:"toolbar.zoomBox",icon:Ft("框选放大"),onClick:()=>{}})},Symbol.toStringTag,{value:"Module"})),S_=Object.freeze(Object.defineProperty({__proto__:null,createWalkMenuButton:n=>({id:"walk",groupId:"group-1",type:"button",label:"toolbar.walk",align:"vertical",icon:Ft("漫游"),onClick:()=>{console.log("漫游按钮被点击"),n.walkControl?.show()}})},Symbol.toStringTag,{value:"Module"})),T_=Object.freeze(Object.defineProperty({__proto__:null,createMapButton:n=>(n.on("map:opened",()=>{n.toolbar?.setBtnActive("map",!0)}),n.on("map:closed",()=>{n.toolbar?.setBtnActive("map",!1)}),{id:"map",groupId:"group-1",type:"button",label:"toolbar.map",align:"vertical",keepActive:!0,icon:Ft("地图"),onClick:()=>{n.map?.isOpen()?n.map?.hide():n.map?.show()}})},Symbol.toStringTag,{value:"Module"})),E_=Object.freeze(Object.defineProperty({__proto__:null,createPropertyButton:n=>({id:"property",groupId:"group-1",type:"button",label:"toolbar.property",align:"vertical",icon:Ft("文档"),onClick:()=>{console.log("构件详情按钮被点击"),n.propertyPanel?.show()}})},Symbol.toStringTag,{value:"Module"})),w_=Object.freeze(Object.defineProperty({__proto__:null,createSettingButton:n=>({id:"setting",groupId:"group-2",type:"button",label:"toolbar.setting",icon:Ft("设置"),keepActive:!1,onClick:e=>{console.log("设置按钮被点击:",e.id)}})},Symbol.toStringTag,{value:"Module"})),C_='',A_=Object.freeze(Object.defineProperty({__proto__:null,createInfoButton:n=>({id:"toolbar-info",groupId:"group-2",type:"button",label:"toolbar.info",icon:C_,onClick:()=>{document.dispatchEvent(new CustomEvent("bim-demo:open-property-panel"))}})},Symbol.toStringTag,{value:"Module"})),R_=Object.freeze(Object.defineProperty({__proto__:null,createFullscreenButton:n=>({id:"fullscreen",groupId:"group-2",type:"button",label:"toolbar.fullscreen",align:"vertical",icon:Ft("全屏"),onClick:async()=>{console.log("全屏按钮被点击"),window.self!==window.top&&console.warn('检测到在 Iframe 中运行,请确保父级 iframe 标签拥有 allow="fullscreen" 属性');try{const t=document,s=!!(t.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement);console.log("当前是否全屏:",s);const a=document.querySelector(".bim-engine-container")||document.body,o=a;if(s){console.log("准备退出全屏...");const l=t.exitFullscreen||t.webkitExitFullscreen||t.mozCancelFullScreen||t.msExitFullscreen;l&&(await l.call(t),console.log("退出全屏请求已发送"))}else{console.log("准备进入全屏..."),(a.style.backgroundColor===""||a.style.backgroundColor==="transparent")&&(a.style.backgroundColor="#ffffff");const l=o.requestFullscreen||o.webkitRequestFullscreen||o.mozRequestFullScreen||o.msRequestFullscreen;l?(await l.call(o,{navigationUI:"hide"}),console.log("全屏请求已发送")):(console.warn("当前浏览器不支持全屏 API"),alert("当前浏览器不支持全屏功能"))}}catch(t){console.error("全屏操作失败:",t),t&&t.message&&t.message.includes("denied")&&console.error('全屏请求被拒绝。如果是 Iframe,请检查 allow="fullscreen"。如果是自动触发,请确保由用户点击触发。')}}})},Symbol.toStringTag,{value:"Module"})),P_=Object.freeze(Object.defineProperty({__proto__:null,createMeasureButton:n=>({id:"measure",groupId:"group-1",type:"button",label:"toolbar.measure",icon:Ft("测量"),keepActive:!0,onClick:e=>{e.isActive?n.measure?.show():n.measure?.destroy()}})},Symbol.toStringTag,{value:"Module"})),L_=Object.freeze(Object.defineProperty({__proto__:null,createSectionMenuButton:n=>({id:"section",groupId:"group-1",type:"menu",label:"toolbar.section",align:"vertical",icon:Ft("剖切"),keepActive:!0,onClick:e=>{console.log("剖切按钮被点击:",e.id)}})},Symbol.toStringTag,{value:"Module"})),D_=Object.freeze(Object.defineProperty({__proto__:null,createSectionPlaneButton:n=>({id:"section-plane",groupId:"group-1",parentId:"section",type:"button",keepActive:!0,exclusive:!0,align:"vertical",label:"toolbar.sectionPlane",icon:Ft("拾曲面剖切"),onClick:e=>{console.log("拾取面剖切被点击:",e.id,"激活状态:",e.isActive),e.isActive?n.sectionPlane?.show():n.sectionPlane?.hide()}})},Symbol.toStringTag,{value:"Module"})),I_=Object.freeze(Object.defineProperty({__proto__:null,createSectionAxisButton:n=>({id:"section-axis",groupId:"group-1",parentId:"section",type:"button",keepActive:!0,exclusive:!0,align:"vertical",label:"toolbar.sectionAxis",icon:Ft("轴向剖切"),onClick:e=>{e.isActive?n.sectionAxis?.show():n.sectionAxis?.destroy()}})},Symbol.toStringTag,{value:"Module"})),U_=Object.freeze(Object.defineProperty({__proto__:null,createSectionBoxButton:n=>({id:"section-box",groupId:"group-1",parentId:"section",type:"button",keepActive:!0,exclusive:!0,align:"vertical",label:"toolbar.sectionBox",icon:Ft("剖切盒"),onClick:e=>{console.log("剖切盒被点击:",e.id,"激活状态:",e.isActive),e.isActive?n.sectionBox?.show():n.sectionBox?.hide()}})},Symbol.toStringTag,{value:"Module"}));ys.BimEngine=b_,Object.defineProperty(ys,Symbol.toStringTag,{value:"Module"})})); + `,this.settingsBtn.addEventListener("click",()=>{this.openSettings()}),g.appendChild(this.clearBtn),g.appendChild(this.settingsBtn),this.mainViewEl.appendChild(g),this.settingsViewEl=this.createSettingsDom(),e.appendChild(this.mainViewEl),e.appendChild(this.settingsViewEl),e}createSettingsDom(){const e=document.createElement("div");e.className="bim-measure-settings";const t=document.createElement("div");t.className="bim-measure-settings-title",t.dataset.i18nKey="measure.settings.title",e.appendChild(t);const i=document.createElement("div");i.className="bim-measure-settings-row";const s=document.createElement("div");s.className="label",s.dataset.i18nKey="measure.settings.unit",this.unitSelectEl=document.createElement("select"),this.unitSelectEl.className="bim-measure-settings-select",this.unitSelectEl.appendChild(this.makeOption("m")),this.unitSelectEl.appendChild(this.makeOption("cm")),this.unitSelectEl.appendChild(this.makeOption("mm")),this.unitSelectEl.appendChild(this.makeOption("km")),i.appendChild(s),i.appendChild(this.unitSelectEl),e.appendChild(i);const r=document.createElement("div");r.className="bim-measure-settings-hint",r.dataset.i18nKey="measure.settings.hint",e.appendChild(r);const a=document.createElement("div");a.className="bim-measure-settings-row";const o=document.createElement("div");o.className="label",o.dataset.i18nKey="measure.settings.precision",this.precisionSelectEl=document.createElement("select"),this.precisionSelectEl.className="bim-measure-settings-select",this.precisionSelectEl.appendChild(this.makePrecisionOption(0)),this.precisionSelectEl.appendChild(this.makePrecisionOption(1)),this.precisionSelectEl.appendChild(this.makePrecisionOption(2)),this.precisionSelectEl.appendChild(this.makePrecisionOption(3)),a.appendChild(o),a.appendChild(this.precisionSelectEl),e.appendChild(a);const l=document.createElement("div");return l.className="bim-measure-settings-actions",this.saveSettingsBtn=document.createElement("button"),this.saveSettingsBtn.type="button",this.saveSettingsBtn.className="bim-measure-settings-save",this.saveSettingsBtn.addEventListener("click",()=>{this.saveSettings()}),this.cancelSettingsBtn=document.createElement("button"),this.cancelSettingsBtn.type="button",this.cancelSettingsBtn.className="bim-measure-settings-cancel",this.cancelSettingsBtn.addEventListener("click",()=>{this.cancelSettings()}),l.appendChild(this.saveSettingsBtn),l.appendChild(this.cancelSettingsBtn),e.appendChild(l),this.syncSettingsFormFromConfig(this.config),e}makeOption(e){const t=document.createElement("option");return t.value=e,t.textContent=e,t}makePrecisionOption(e){const t=document.createElement("option");return t.value=String(e),t.textContent=e===0?"0":`0.${"0".repeat(e)}`,t}enterSettingsView(){this.draftConfig={...this.config},this.view="settings",this.syncSettingsFormFromConfig(this.config),this.applyViewState()}saveSettings(){const e=this.unitSelectEl.value||this.config.unit,t=Number(this.precisionSelectEl.value),i={unit:e,precision:this.isValidPrecision(t)?t:this.config.precision};this.config=i,this.saveConfigToCache(i),this.draftConfig=null,this.view="main",this.applyViewState(),this.renderResult(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded)}cancelSettings(){this.draftConfig&&(this.config={...this.draftConfig}),this.draftConfig=null,this.view="main",this.applyViewState(),this.renderResult(),this.options.onExpandedChange&&this.options.onExpandedChange(this.isExpanded)}syncSettingsFormFromConfig(e){this.unitSelectEl.value=e.unit,this.precisionSelectEl.value=String(e.precision)}applyViewState(){this.view==="settings"?(this.mainViewEl.style.display="none",this.settingsViewEl.style.display="block"):(this.mainViewEl.style.display="block",this.settingsViewEl.style.display="none")}loadConfigFromCache(){try{const e=localStorage.getItem(kn.CONFIG_CACHE_KEY);if(!e)return null;const t=JSON.parse(e);if(!t||typeof t!="object")return null;const i=t.unit,s=t.precision;return!this.isValidUnit(i)||!this.isValidPrecision(s)?null:{unit:i,precision:s}}catch{return null}}saveConfigToCache(e){try{localStorage.setItem(kn.CONFIG_CACHE_KEY,JSON.stringify(e))}catch{}}isValidUnit(e){return e==="m"||e==="cm"||e==="mm"||e==="km"}isValidPrecision(e){return e===0||e===1||e===2||e===3}applyExpandedState(){let e=0;for(const t of this.toolButtons.values())e>=4?t.style.display=this.isExpanded?"":"none":t.style.display="",e++;this.isExpanded?this.toggleBtn.classList.add("is-expanded"):this.toggleBtn.classList.remove("is-expanded")}applyActiveModeState(){for(const[e,t]of this.toolButtons.entries())e===this.activeMode?t.classList.add("is-active"):t.classList.remove("is-active")}renderResult(){if(this.activeMode==="laserDistance")this.mainValueLabelEl.style.display="none",this.mainNumberEl.textContent=le(this.getModeI18nKey("laserDistance")),this.mainUnitEl.textContent="",this.mainNumberEl.classList.add("is-laser-text");else{this.mainValueLabelEl.style.display="",this.mainValueLabelEl.textContent=le(this.getModeValueLabelI18nKey(this.activeMode));const e=this.formatMainValueParts(this.activeMode,this.result);this.mainNumberEl.textContent=e.numberText,this.mainUnitEl.textContent=e.unitText,this.mainNumberEl.classList.remove("is-laser-text")}if(this.activeMode==="distance"){this.xyzBoxEl.style.display="";const e=this.result?.xyz;if(!e){this.xyzXEl.textContent="--",this.xyzYEl.textContent="--",this.xyzZEl.textContent="--";return}this.xyzXEl.textContent=this.formatNumberWithPrecision(e.x,this.config.precision),this.xyzYEl.textContent=this.formatNumberWithPrecision(e.y,this.config.precision),this.xyzZEl.textContent=this.formatNumberWithPrecision(e.z,this.config.precision);return}this.xyzBoxEl.style.display="none"}getModeI18nKey(e){return`measure.modes.${e}`}getModeValueLabelI18nKey(e){return`measure.labels.value.${e}`}formatNumberWithPrecision(e,t){return e.toFixed(t)}convertMmToUnit(e,t){switch(t){case"mm":return e;case"cm":return e/10;case"m":return e/1e3;case"km":return e/1e6;default:return e}}getUnitI18nKey(e){return`measure.units.${e}`}convertMm3ToUnit3(e,t){switch(t){case"mm":return e;case"cm":return e/1e3;case"m":return e/1e9;case"km":return e/1e18;default:return e}}formatMainValueParts(e,t){if(e==="laserDistance")return{numberText:le(this.getModeI18nKey("laserDistance")),unitText:""};if(!t)return this.getEmptyValuePartsByMode(e);switch(e){case"distance":return this.formatLengthParts(t.distanceMm);case"minDistance":return this.formatLengthParts(t.minDistanceMm);case"angle":return this.formatFixedUnitParts(t.angleDeg,le("measure.units.deg"));case"elevation":return this.formatFixedUnitParts(t.elevationMm===void 0?void 0:t.elevationMm/1e3,le("measure.units.m"));case"volume":return this.formatVolumeParts(t.volumeM3);case"slope":return this.formatFixedUnitParts(t.slopePercent,le("measure.units.percent"));case"spaceVolume":return this.formatVolumeParts(t.spaceVolumeM3);default:return{numberText:"--",unitText:""}}}getEmptyValuePartsByMode(e){switch(e){case"distance":case"minDistance":return{numberText:"--",unitText:le(this.getUnitI18nKey(this.config.unit))};case"angle":return{numberText:"--",unitText:le("measure.units.deg")};case"elevation":return{numberText:"--",unitText:le("measure.units.m")};case"volume":case"spaceVolume":return{numberText:"--",unitText:`${this.config.unit}³`};case"slope":return{numberText:"--",unitText:le("measure.units.percent")};default:return{numberText:"--",unitText:""}}}formatFixedUnitParts(e,t){return e==null||Number.isNaN(e)?{numberText:"--",unitText:t}:{numberText:this.formatNumberWithPrecision(e,this.config.precision),unitText:t}}formatLengthParts(e){const t=le(this.getUnitI18nKey(this.config.unit));if(e==null||Number.isNaN(e))return{numberText:"--",unitText:t};const i=this.convertMmToUnit(e,this.config.unit);return{numberText:this.formatNumberWithPrecision(i,this.config.precision),unitText:t}}formatVolumeParts(e){const t=`${this.config.unit}³`;if(e==null||Number.isNaN(e))return{numberText:"--",unitText:t};const i=this.convertMm3ToUnit3(e,this.config.unit);return{numberText:this.formatNumberWithPrecision(i,this.config.precision),unitText:t}}}class a_ extends jt{dialogId="measure-dialog";dialog=null;panel=null;config=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}const e=250,t=300,i=20,s=this.engine.container,r=s.clientWidth,a=s.clientHeight,o=r-e-i,l=(a-t)/2;this.destroy(),this.panel=new kn({defaultMode:"distance",defaultExpanded:!1,onModeChange:h=>{console.log("[MeasureDialogManager] 当前测量方式已切换:",h)},onClearAll:()=>{console.log("[MeasureDialogManager] 删除全部(仅 UI 清空,本次不清理引擎侧内容)")},onSettings:()=>{console.log("[MeasureDialogManager] 打开设置(仅预留接口)")},onExpandedChange:()=>{this.dialog?.fitHeight(!1)}}),this.panel.init(),this.config=this.panel.getConfig();const c=document.createElement("div");c.style.padding="12px",c.appendChild(this.panel.element),this.dialog=this.engine.dialog.create({id:this.dialogId,title:"measure.dialogTitle",content:c,width:e,height:"auto",position:{x:o,y:l},onClose:()=>{this.engine.toolbar?.setBtnActive("measure",!1)}}),this.dialog.init(),this.dialog.fitHeight(!1)}getActiveMode(){return this.panel?this.panel.getActiveMode():null}switchMode(e){this.panel&&this.panel.switchMode(e)}setMeasureResult(e){this.panel&&this.panel.setResult(e)}getConfig(){return this.panel&&(this.config=this.panel.getConfig()),this.config?{...this.config}:null}setConfig(e,t=!0){if(this.panel){this.panel.setConfig(e,t),this.config=this.panel.getConfig(),this.dialog?.fitHeight(!1);return}const i=this.config,s={unit:e.unit??i?.unit??"mm",precision:e.precision??i?.precision??2};this.config=s}clearAll(){this.panel&&this.panel.clearAll()}openSettings(){this.panel&&this.panel.openSettings()}destroy(){this.dialog&&(this.dialog.destroy(),this.dialog=null),this.panel&&(this.panel.destroy(),this.panel=null)}}class o_{element;options;hideBtn;reverseBtn;resetBtn;hideLabelEl;reverseLabelEl;resetLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.element=this.createDom()}init(){this.unsubscribeLocale=It.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=Ze.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(Ze.getTheme())}setTheme(e){const t=this.element.style;t.setProperty("--bim-section-btn-bg",e.componentBackground??"rgba(255, 255, 255, 0.06)"),t.setProperty("--bim-section-btn-hover",e.componentHover??"rgba(255, 255, 255, 0.10)"),t.setProperty("--bim-section-btn-active",e.componentActive??"rgba(255, 255, 255, 0.14)"),t.setProperty("--bim-primary-color",e.primary??"#1890ff"),t.setProperty("--bim-icon-color",e.icon??"#ccc"),t.setProperty("--bim-text-color",e.textSecondary??"rgba(255, 255, 255, 0.90)"),t.setProperty("--bim-text-active-color",e.textPrimary??"#fff")}setLocales(){this.hideLabelEl.textContent=le("sectionPlane.actions.hide"),this.reverseLabelEl.textContent=le("sectionPlane.actions.reverse"),this.resetLabelEl.textContent=le("sectionPlane.actions.reset"),this.hideBtn.title=le("sectionPlane.actions.hide"),this.reverseBtn.title=le("sectionPlane.actions.reverse"),this.resetBtn.title=le("sectionPlane.actions.reset")}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}createDom(){const e=document.createElement("div");return e.className="section-plane-panel",this.hideBtn=this.createButton("hide",vt("隐藏"),()=>{this.options.onHide&&this.options.onHide()}),this.reverseBtn=this.createButton("reverse",vt("反向"),()=>{this.options.onReverse&&this.options.onReverse()}),this.resetBtn=this.createButton("reset",vt("重置"),()=>{this.options.onReset&&this.options.onReset()}),e.appendChild(this.hideBtn),e.appendChild(this.reverseBtn),e.appendChild(this.resetBtn),e}createButton(e,t,i){const s=document.createElement("button");s.type="button",s.className="section-plane-btn";const r=document.createElement("div");r.className="section-plane-btn-icon",r.innerHTML=t,s.appendChild(r);const a=document.createElement("div");return a.className="section-plane-btn-label",s.appendChild(a),e==="hide"?this.hideLabelEl=a:e==="reverse"?this.reverseLabelEl=a:this.resetLabelEl=a,s.addEventListener("click",i),s}}class l_ extends jt{dialogId="section-plane-dialog";dialog=null;panel=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}this.destroy(),this.panel=new o_({onHide:()=>{console.log("[SectionPlaneDialogManager] 隐藏")},onReverse:()=>{console.log("[SectionPlaneDialogManager] 反向")},onReset:()=>{console.log("[SectionPlaneDialogManager] 重置")}}),this.panel.init();const e=240,t=120,i=20,s=50,r=this.engine.container,a=r.clientWidth,o=r.clientHeight,l=a-e-i,c=o-t-s;this.dialog=this.engine.dialog.create({id:this.dialogId,title:"sectionPlane.dialogTitle",width:e,height:t,position:{x:l,y:c},draggable:!0,resizable:!1,content:this.panel.element,onClose:()=>{this.engine.toolbar?.setBtnActive("section-plane",!1),this.hide()}})}hide(){this.destroy()}destroy(){this.dialog&&(this.dialog.destroy(),this.dialog=null),this.panel&&(this.panel.destroy(),this.panel=null)}}class c_{element;options;isHidden=!1;activeAxis="x";hideBtn;reverseBtn;hideLabelEl;reverseLabelEl;axisXBtn;axisYBtn;axisZBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.activeAxis=e.defaultAxis??"x",this.element=this.createDom()}init(){this.unsubscribeLocale=It.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=Ze.subscribe(e=>{this.setTheme(e)}),this.setLocales(),this.setTheme(Ze.getTheme()),this.updateHideButtonState(),this.updateAxisButtonsState()}setTheme(e){const t=this.element.style;t.setProperty("--bim-section-axis-btn-bg",e.componentBackground??"rgba(255, 255, 255, 0.06)"),t.setProperty("--bim-section-axis-btn-hover",e.componentHover??"rgba(255, 255, 255, 0.10)"),t.setProperty("--bim-section-axis-btn-active",e.componentActive??"rgba(255, 255, 255, 0.14)"),t.setProperty("--bim-primary-color",e.primary??"#1890ff"),t.setProperty("--bim-icon-color",e.icon??"#ccc"),t.setProperty("--bim-text-color",e.textSecondary??"rgba(255, 255, 255, 0.90)"),t.setProperty("--bim-text-active-color",e.textPrimary??"#fff")}setLocales(){this.hideLabelEl.textContent=le("sectionAxis.actions.hide"),this.reverseLabelEl.textContent=le("sectionAxis.actions.reverse"),this.hideBtn.title=le("sectionAxis.actions.hide"),this.reverseBtn.title=le("sectionAxis.actions.reverse"),this.axisXBtn.title=le("sectionAxis.actions.axisX"),this.axisYBtn.title=le("sectionAxis.actions.axisY"),this.axisZBtn.title=le("sectionAxis.actions.axisZ")}setHiddenState(e){this.isHidden=e,this.updateHideButtonState()}getHiddenState(){return this.isHidden}setActiveAxis(e){this.activeAxis=e,this.updateAxisButtonsState()}getActiveAxis(){return this.activeAxis}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.element.remove()}createDom(){const e=document.createElement("div");e.className="section-axis-panel";const t=document.createElement("div");t.className="section-axis-row-1",this.hideBtn=this.createButton("hide",vt("隐藏"),()=>this.handleHideToggle()),this.reverseBtn=this.createButton("reverse",vt("反向"),()=>this.handleReverse()),t.appendChild(this.hideBtn),t.appendChild(this.reverseBtn);const i=document.createElement("div");return i.className="section-axis-row-2",this.axisXBtn=this.createAxisButton("axisX","X",()=>this.handleAxisChange("x")),this.axisYBtn=this.createAxisButton("axisY","Y",()=>this.handleAxisChange("y")),this.axisZBtn=this.createAxisButton("axisZ","Z",()=>this.handleAxisChange("z")),i.appendChild(this.axisXBtn),i.appendChild(this.axisYBtn),i.appendChild(this.axisZBtn),e.appendChild(t),e.appendChild(i),e}createButton(e,t,i){const s=document.createElement("button");s.type="button",s.className="section-axis-btn";const r=document.createElement("div");r.className="section-axis-btn-icon",r.innerHTML=t,s.appendChild(r);const a=document.createElement("div");return a.className="section-axis-btn-label",s.appendChild(a),e==="hide"?this.hideLabelEl=a:e==="reverse"&&(this.reverseLabelEl=a),s.addEventListener("click",i),s}createAxisButton(e,t,i){const s=document.createElement("button");s.type="button",s.className="section-axis-btn section-axis-btn-text";const r=document.createElement("div");return r.className="section-axis-btn-label",r.textContent=t,s.appendChild(r),s.addEventListener("click",i),s}handleHideToggle(){this.isHidden=!this.isHidden,this.updateHideButtonState(),this.options.onHideToggle&&this.options.onHideToggle(this.isHidden)}handleReverse(){this.options.onReverse&&this.options.onReverse()}handleAxisChange(e){this.activeAxis!==e&&(this.activeAxis=e,this.updateAxisButtonsState(),this.options.onAxisChange&&this.options.onAxisChange(e))}updateHideButtonState(){this.isHidden?this.hideBtn.classList.add("active"):this.hideBtn.classList.remove("active")}updateAxisButtonsState(){this.axisXBtn.classList.toggle("active",this.activeAxis==="x"),this.axisYBtn.classList.toggle("active",this.activeAxis==="y"),this.axisZBtn.classList.toggle("active",this.activeAxis==="z")}}class h_ extends jt{dialogId="section-axis-dialog";dialog=null;panel=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}this.destroy(),this.panel=new c_({defaultAxis:"x",defaultHidden:!1,onHideToggle:c=>{console.log("[SectionAxisDialogManager] 隐藏切换:",c)},onReverse:()=>{console.log("[SectionAxisDialogManager] 反向剖切")},onAxisChange:c=>{console.log("[SectionAxisDialogManager] 切换轴向:",c)}}),this.panel.init();const e=240,t=20,i=50,s=this.engine.container,r=s.clientWidth,a=s.clientHeight,o=r-e-t,l=a-i-200;this.dialog=this.engine.dialog.create({id:this.dialogId,title:"sectionAxis.dialogTitle",width:e,height:"auto",position:{x:o,y:l},draggable:!0,resizable:!1,content:this.panel.element,onClose:()=>{this.engine.toolbar?.setBtnActive("section-axis",!1),this.hide()}}),this.dialog.init(),this.dialog.fitHeight(!1)}hide(){this.destroy()}getHiddenState(){return this.panel?.getHiddenState()??!1}setHiddenState(e){this.panel?.setHiddenState(e)}getActiveAxis(){return this.panel?.getActiveAxis()??"x"}setActiveAxis(e){this.panel?.setActiveAxis(e)}destroy(){this.dialog&&(this.dialog.destroy(),this.dialog=null),this.panel&&(this.panel.destroy(),this.panel=null)}}const Fh={x:{min:0,max:100},y:{min:0,max:100},z:{min:0,max:100}};class u_{element;options;isHidden=!1;isReversed=!1;range;hideBtn;reverseBtn;fitBtn;resetBtn;hideLabelEl;reverseLabelEl;fitLabelEl;resetLabelEl;xLabelEl;yLabelEl;zLabelEl;unsubscribeLocale=null;unsubscribeTheme=null;xSlider;ySlider;zSlider;xMinHandle;xMaxHandle;yMinHandle;yMaxHandle;zMinHandle;zMaxHandle;dragState={isDragging:!1,axis:null,handleType:null,pointerId:null};constructor(e={}){this.options=e,this.isHidden=e.defaultHidden??!1,this.isReversed=e.defaultReversed??!1,this.range=JSON.parse(JSON.stringify(e.defaultRange??Fh))}init(){this.element=this.createPanel(),this.unsubscribeLocale=It.subscribe(()=>this.setLocales()),this.unsubscribeTheme=Ze.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(Ze.getTheme()),this.updateButtonStates(),this.updateAllSlidersUI(),this.setupDragListeners()}setHiddenState(e){this.isHidden=e,this.updateButtonStates()}getHiddenState(){return this.isHidden}setReversedState(e){this.isReversed=e,this.updateButtonStates()}getReversedState(){return this.isReversed}setRange(e){e.x&&(this.range.x={...this.range.x,...e.x}),e.y&&(this.range.y={...this.range.y,...e.y}),e.z&&(this.range.z={...this.range.z,...e.z}),this.updateAllSlidersUI()}getRange(){return JSON.parse(JSON.stringify(this.range))}reset(){this.isHidden=this.options.defaultHidden??!1,this.isReversed=this.options.defaultReversed??!1,this.range=JSON.parse(JSON.stringify(this.options.defaultRange??Fh)),this.updateButtonStates(),this.updateAllSlidersUI(),this.options.onReset?.(),this.options.onRangeChange?.(this.range)}createPanel(){const e=document.createElement("div");e.className="section-box-panel";const t=document.createElement("div");t.className="section-box-row-buttons",this.hideBtn=this.createButton("hide",le("sectionBox.actions.hide"),()=>{this.isHidden=!this.isHidden,this.updateButtonStates(),this.options.onHideToggle?.(this.isHidden)},"hide"),this.reverseBtn=this.createButton("reverse",le("sectionBox.actions.reverse"),()=>{this.isReversed=!this.isReversed,this.updateButtonStates(),this.options.onReverseToggle?.(this.isReversed)},"reverse"),this.fitBtn=this.createButton("fit",le("sectionBox.actions.fitToModel"),()=>{this.options.onFitToModel?.()},"fit"),this.resetBtn=this.createButton("reset",le("sectionBox.actions.reset"),()=>this.reset(),"reset"),[this.hideBtn,this.reverseBtn,this.fitBtn,this.resetBtn].forEach(s=>t.appendChild(s));const i=document.createElement("div");return i.className="section-box-sliders",i.addEventListener("pointerdown",s=>s.stopPropagation()),this.xSlider=this.createSlider("x",le("sectionBox.axes.x")),this.ySlider=this.createSlider("y",le("sectionBox.axes.y")),this.zSlider=this.createSlider("z",le("sectionBox.axes.z")),[this.xSlider,this.ySlider,this.zSlider].forEach(s=>i.appendChild(s)),e.appendChild(t),e.appendChild(i),e}createButton(e,t,i,s){const r=document.createElement("button");r.className="section-box-btn",r.title=t;const a={hide:"隐藏",reverse:"反向",fit:"适应到模型",reset:"重置"},o=document.createElement("div");o.className="section-box-btn-icon",o.innerHTML=vt(a[e]||e);const l=document.createElement("div");return l.className="section-box-btn-label",l.textContent=t,s==="hide"?this.hideLabelEl=l:s==="reverse"?this.reverseLabelEl=l:s==="fit"?this.fitLabelEl=l:s==="reset"&&(this.resetLabelEl=l),r.appendChild(o),r.appendChild(l),r.addEventListener("click",i),r}createSlider(e,t){const i=document.createElement("div");i.className="section-box-slider";const s=document.createElement("div");s.className="section-box-slider-label",s.textContent=t,e==="x"?this.xLabelEl=s:e==="y"?this.yLabelEl=s:this.zLabelEl=s;const r=document.createElement("div");r.className="section-box-slider-track";const a=document.createElement("div");a.className="section-box-slider-range";const o=document.createElement("div");o.className="section-box-slider-handle",o.setAttribute("data-axis",e),o.setAttribute("data-handle","min");const l=document.createElement("div");return l.className="section-box-slider-handle",l.setAttribute("data-axis",e),l.setAttribute("data-handle","max"),r.append(a,o,l),i.append(s,r),e==="x"?(this.xMinHandle=o,this.xMaxHandle=l):e==="y"?(this.yMinHandle=o,this.yMaxHandle=l):(this.zMinHandle=o,this.zMaxHandle=l),i}setupDragListeners(){[this.xMinHandle,this.xMaxHandle,this.yMinHandle,this.yMaxHandle,this.zMinHandle,this.zMaxHandle].forEach(t=>{t.addEventListener("pointerdown",s=>{s.preventDefault(),s.stopPropagation(),t.setPointerCapture(s.pointerId),this.dragState={isDragging:!0,axis:t.getAttribute("data-axis"),handleType:t.getAttribute("data-handle"),pointerId:s.pointerId},t.classList.add("dragging"),t.closest(".section-box-slider").style.zIndex="100"}),t.addEventListener("pointermove",s=>{this.dragState.isDragging&&this.dragState.pointerId===s.pointerId&&this.onDragging(s)});const i=s=>{this.dragState.isDragging&&this.dragState.pointerId===s.pointerId&&(t.releasePointerCapture(s.pointerId),t.closest(".section-box-slider").style.zIndex="",t.classList.remove("dragging"),this.dragState.isDragging=!1,this.dragState.pointerId=null)};t.addEventListener("pointerup",i),t.addEventListener("pointercancel",i)})}onDragging(e){const{axis:t,handleType:i}=this.dragState;if(!t||!i)return;const a=(t==="x"?this.xSlider:t==="y"?this.ySlider:this.zSlider).querySelector(".section-box-slider-track").getBoundingClientRect();let o=(e.clientX-a.left)/a.width*100;o=Math.max(0,Math.min(100,o));const l=this.range[t];i==="min"?l.min=Math.min(o,l.max):l.max=Math.max(o,l.min),this.updateSliderUI(t),this.options.onRangeChange?.(this.range)}updateSliderUI(e){const t=this.range[e],i=e==="x"?this.xMinHandle:e==="y"?this.yMinHandle:this.zMinHandle,s=e==="x"?this.xMaxHandle:e==="y"?this.yMaxHandle:this.zMaxHandle,a=(e==="x"?this.xSlider:e==="y"?this.ySlider:this.zSlider).querySelector(".section-box-slider-range");i.style.left=`${t.min}%`,s.style.left=`${t.max}%`,a.style.left=`${t.min}%`,a.style.width=`${t.max-t.min}%`,i.setAttribute("data-value",Math.round(t.min).toString()),s.setAttribute("data-value",Math.round(t.max).toString())}updateAllSlidersUI(){["x","y","z"].forEach(e=>this.updateSliderUI(e))}updateButtonStates(){this.hideBtn&&this.hideBtn.classList.toggle("active",this.isHidden),this.reverseBtn&&this.reverseBtn.classList.toggle("active",this.isReversed)}setLocales(){this.hideLabelEl&&(this.hideLabelEl.textContent=le("sectionBox.actions.hide"),this.reverseLabelEl.textContent=le("sectionBox.actions.reverse"),this.fitLabelEl.textContent=le("sectionBox.actions.fitToModel"),this.resetLabelEl.textContent=le("sectionBox.actions.reset"),this.xLabelEl.textContent=le("sectionBox.axes.x"),this.yLabelEl.textContent=le("sectionBox.axes.y"),this.zLabelEl.textContent=le("sectionBox.axes.z"),this.hideBtn.title=le("sectionBox.actions.hide"),this.reverseBtn.title=le("sectionBox.actions.reverse"),this.fitBtn.title=le("sectionBox.actions.fitToModel"),this.resetBtn.title=le("sectionBox.actions.reset"))}setTheme(e){if(!this.element)return;const t=this.element.style;t.setProperty("--bim-section-box-btn-bg",e.componentBackground??"rgba(255, 255, 255, 0.06)"),t.setProperty("--bim-section-box-btn-hover",e.componentHover??"rgba(255, 255, 255, 0.10)"),t.setProperty("--bim-section-box-btn-active",e.componentActive??"rgba(255, 255, 255, 0.14)"),t.setProperty("--bim-primary-color",e.primary??"#1890ff"),t.setProperty("--bim-icon-color",e.icon??"#ccc"),t.setProperty("--bim-text-color",e.textSecondary??"rgba(255, 255, 255, 0.90)"),t.setProperty("--bim-text-active-color",e.textPrimary??"#fff")}destroy(){this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element&&this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class d_ extends jt{dialogId="section-box-dialog";dialog=null;panel=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}this.destroy(),this.panel=new u_({defaultHidden:!1,defaultReversed:!1,onHideToggle:c=>{console.log("[SectionBoxDialogManager] 隐藏切换:",c)},onReverseToggle:c=>{console.log("[SectionBoxDialogManager] 反向切换:",c)},onFitToModel:()=>{console.log("[SectionBoxDialogManager] 适应到模型")},onReset:()=>{console.log("[SectionBoxDialogManager] 重置")},onRangeChange:c=>{console.log("[SectionBoxDialogManager] 范围变化:",c)}}),this.panel.init();const e=280,t=20,i=50,s=this.engine.container,r=s.clientWidth,a=s.clientHeight,o=r-e-t,l=a-i-300;this.dialog=this.engine.dialog.create({id:this.dialogId,title:"sectionBox.dialogTitle",width:e,height:"auto",position:{x:o,y:l},draggable:!0,resizable:!1,content:this.panel.element,onClose:()=>{this.engine.toolbar?.setBtnActive("section-box",!1),this.hide()}}),this.dialog.init(),this.dialog.fitHeight(!1)}hide(){this.destroy()}getHiddenState(){return this.panel?.getHiddenState()??!1}setHiddenState(e){this.panel?.setHiddenState(e)}getReversedState(){return this.panel?.getReversedState()??!1}setReversedState(e){this.panel?.setReversedState(e)}getRange(){return this.panel?.getRange()??null}setRange(e){this.panel?.setRange(e)}destroy(){this.dialog&&(this.dialog.destroy(),this.dialog=null),this.panel&&(this.panel.destroy(),this.panel=null)}}class p_{element;options;state={mode:"none",isPlanViewActive:!1,speed:1,gravity:!1,collision:!1,characterModel:"construction-worker",walkMode:"walk"};planViewBtn;pathModeBtn;walkModeBtn;settingsContainer;speedControl;speedDecreaseBtn;speedIncreaseBtn;speedDisplay;gravityCheckbox;gravityLabel;collisionCheckbox;collisionLabel;characterModelSelect;characterModelLabel;walkModeSelect;walkModeLabel;exitBtn;unsubscribeLocale=null;unsubscribeTheme=null;constructor(e={}){this.options=e,this.state.speed=e.defaultSpeed??1,this.state.gravity=e.defaultGravity??!1,this.state.collision=e.defaultCollision??!1,this.state.characterModel=e.defaultCharacterModel??"construction-worker",this.state.walkMode=e.defaultWalkMode??"walk"}init(){this.element=this.createPanel(),this.updateSettingsView(),this.unsubscribeLocale=It.subscribe(()=>this.setLocales()),this.unsubscribeTheme=Ze.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(Ze.getTheme())}setPlanViewActive(e){this.state.isPlanViewActive=e,this.updateButtonStates()}setPathModeActive(e){if(!e&&this.state.mode!=="path")return;const t=e?"path":"none";this.setMode(t)}getState(){return{...this.state}}createPanel(){const e=document.createElement("div");e.className="walk-control-panel";const t=this.createLeftButtons(),i=document.createElement("div");i.className="walk-divider",this.settingsContainer=this.createSettingsContainer();const s=document.createElement("div");s.className="walk-divider";const r=this.createExitButton();return e.appendChild(t),e.appendChild(i),e.appendChild(this.settingsContainer),e.appendChild(s),e.appendChild(r),e}createLeftButtons(){const e=document.createElement("div");return e.className="walk-control-left",this.planViewBtn=this.createIconButton("plan-view",()=>{this.state.isPlanViewActive=!this.state.isPlanViewActive,this.updateButtonStates(),this.options.onPlanViewToggle?.(this.state.isPlanViewActive)}),this.pathModeBtn=this.createIconButton("path",()=>{const t=this.state.mode==="path"?"none":"path";this.setMode(t),this.options.onPathModeToggle?.(t==="path")}),this.walkModeBtn=this.createIconButton("walk",()=>{const t=this.state.mode==="walk"?"none":"walk";this.setMode(t),this.options.onWalkModeToggle?.(t==="walk")}),e.appendChild(this.planViewBtn),e.appendChild(this.pathModeBtn),e.appendChild(this.walkModeBtn),e}createSettingsContainer(){const e=document.createElement("div");e.className="walk-control-settings",this.speedControl=this.createSpeedControl();const t=document.createElement("label");t.className="walk-checkbox-wrapper walk-checkbox-gravity",this.gravityCheckbox=document.createElement("input"),this.gravityCheckbox.type="checkbox",this.gravityCheckbox.className="walk-checkbox",this.gravityCheckbox.checked=this.state.gravity,this.gravityCheckbox.addEventListener("change",()=>{this.state.gravity=this.gravityCheckbox.checked,this.options.onGravityToggle?.(this.state.gravity)}),this.gravityLabel=document.createElement("span"),this.gravityLabel.className="walk-checkbox-label",t.appendChild(this.gravityCheckbox),t.appendChild(this.gravityLabel);const i=document.createElement("label");i.className="walk-checkbox-wrapper walk-checkbox-collision",this.collisionCheckbox=document.createElement("input"),this.collisionCheckbox.type="checkbox",this.collisionCheckbox.className="walk-checkbox",this.collisionCheckbox.checked=this.state.collision,this.collisionCheckbox.addEventListener("change",()=>{this.state.collision=this.collisionCheckbox.checked,this.options.onCollisionToggle?.(this.state.collision)}),this.collisionLabel=document.createElement("span"),this.collisionLabel.className="walk-checkbox-label",i.appendChild(this.collisionCheckbox),i.appendChild(this.collisionLabel);const s=document.createElement("div");s.className="walk-select-wrapper walk-select-wrapper-character-model",this.characterModelLabel=document.createElement("label"),this.characterModelLabel.className="walk-select-label",this.characterModelSelect=document.createElement("select"),this.characterModelSelect.className="walk-select walk-select-character-model",this.characterModelSelect.addEventListener("change",()=>{this.state.characterModel=this.characterModelSelect.value,this.options.onCharacterModelChange?.(this.state.characterModel)}),s.appendChild(this.characterModelLabel),s.appendChild(this.characterModelSelect);const r=document.createElement("div");return r.className="walk-select-wrapper walk-select-wrapper-walk-mode",this.walkModeLabel=document.createElement("label"),this.walkModeLabel.className="walk-select-label",this.walkModeSelect=document.createElement("select"),this.walkModeSelect.className="walk-select walk-select-walk-mode",this.walkModeSelect.addEventListener("change",()=>{this.state.walkMode=this.walkModeSelect.value,this.options.onWalkModeChange?.(this.state.walkMode)}),r.appendChild(this.walkModeLabel),r.appendChild(this.walkModeSelect),e.appendChild(this.speedControl),e.appendChild(s),e.appendChild(r),e.appendChild(t),e.appendChild(i),e}createSpeedControl(){const e=document.createElement("div");e.className="walk-speed-control";const t=document.createElement("label");t.className="walk-speed-label",t.textContent=le("walkControl.speed");const i=document.createElement("div");return i.className="walk-speed-group",this.speedDecreaseBtn=document.createElement("button"),this.speedDecreaseBtn.className="walk-speed-btn",this.speedDecreaseBtn.textContent="-",this.speedDecreaseBtn.addEventListener("click",()=>{this.state.speed>1&&(this.state.speed--,this.updateSpeedDisplay(),this.options.onSpeedChange?.(this.state.speed))}),this.speedDisplay=document.createElement("div"),this.speedDisplay.className="walk-speed-display",this.speedDisplay.textContent=`${this.state.speed}X`,this.speedIncreaseBtn=document.createElement("button"),this.speedIncreaseBtn.className="walk-speed-btn",this.speedIncreaseBtn.textContent="+",this.speedIncreaseBtn.addEventListener("click",()=>{this.state.speed<10&&(this.state.speed++,this.updateSpeedDisplay(),this.options.onSpeedChange?.(this.state.speed))}),i.appendChild(this.speedDecreaseBtn),i.appendChild(this.speedDisplay),i.appendChild(this.speedIncreaseBtn),e.appendChild(t),e.appendChild(i),e}createIconButton(e,t){const i=document.createElement("button");return i.className=`walk-icon-btn walk-icon-btn-${e}`,i.innerHTML=this.getIconSVG(e),i.addEventListener("click",t),i}createExitButton(){const e=document.createElement("button");return e.className="walk-exit-btn",e.addEventListener("click",()=>{this.options.onExit?.()}),this.exitBtn=e,e}setMode(e){const t=this.state.mode;t==="walk"&&e!=="walk"&&this.options.onWalkModeToggle?.(!1),t==="path"&&e!=="path"&&this.options.onPathModeToggle?.(!1),this.state.mode=e,e==="path"?(this.state.gravity=!1,this.state.collision=!1,this.gravityCheckbox.checked=!1,this.gravityCheckbox.disabled=!0,this.collisionCheckbox.checked=!1,this.collisionCheckbox.disabled=!0):(this.gravityCheckbox.disabled=!1,this.collisionCheckbox.disabled=!1),this.updateButtonStates(),this.updateSettingsView(),this.updateSpeedButtonStates()}updateButtonStates(){this.planViewBtn.classList.toggle("active",this.state.isPlanViewActive),this.pathModeBtn.classList.toggle("active",this.state.mode==="path"),this.walkModeBtn.classList.toggle("active",this.state.mode==="walk")}updateSettingsView(){const e=this.speedControl,t=this.gravityCheckbox.parentElement,i=this.collisionCheckbox.parentElement,s=this.characterModelSelect.parentElement,r=this.walkModeSelect.parentElement;this.state.mode==="walk"?(e.style.display="none",t.style.display="flex",i.style.display="flex",s.style.display="flex",r.style.display="flex"):(e.style.display="flex",t.style.display="flex",i.style.display="flex",s.style.display="none",r.style.display="none")}updateSpeedDisplay(){this.speedDisplay.textContent=`${this.state.speed}X`,this.updateSpeedButtonStates()}updateSpeedButtonStates(){this.speedDecreaseBtn.disabled=this.state.speed<=1,this.speedIncreaseBtn.disabled=this.state.speed>=10}getIconSVG(e){return{"plan-view":vt("地图"),path:vt("路径漫游"),walk:vt("第一人称漫游")}[e]||""}setLocales(){const e=this.speedControl.querySelector(".walk-speed-label");e&&(e.textContent=le("walkControl.speed")),this.gravityLabel.textContent=le("walkControl.gravity"),this.collisionLabel.textContent=le("walkControl.collision"),this.characterModelLabel.textContent=le("walkControl.characterModel.label"),this.characterModelSelect.innerHTML="";const t=document.createElement("option");t.value="construction-worker",t.textContent=le("walkControl.characterModel.constructionWorker"),t.selected=this.state.characterModel==="construction-worker",this.characterModelSelect.appendChild(t);const i=document.createElement("option");i.value="office-male",i.textContent=le("walkControl.characterModel.officeMale"),i.selected=this.state.characterModel==="office-male",this.characterModelSelect.appendChild(i),this.walkModeLabel.textContent=le("walkControl.walkMode.label"),this.walkModeSelect.innerHTML="";const s=document.createElement("option");s.value="walk",s.textContent=le("walkControl.walkMode.walk"),s.selected=this.state.walkMode==="walk",this.walkModeSelect.appendChild(s);const r=document.createElement("option");r.value="run",r.textContent=le("walkControl.walkMode.run"),r.selected=this.state.walkMode==="run",this.walkModeSelect.appendChild(r),this.exitBtn.textContent=le("walkControl.exit")}setTheme(e){if(!this.element)return;const t=this.element.style;t.setProperty("--bim-walk-control-bg",e.panelBackground??"rgba(0, 0, 0, 0.8)"),t.setProperty("--bim-walk-btn-hover",e.componentHover??"rgba(255, 255, 255, 0.15)"),t.setProperty("--bim-walk-btn-active",e.componentActive??"rgba(255, 255, 255, 0.3)"),t.setProperty("--bim-primary-color",e.primary??"#1890ff"),t.setProperty("--bim-primary-hover",e.primaryHover??"#40a9ff"),t.setProperty("--bim-icon-color",e.icon??"#ccc"),t.setProperty("--bim-text-color",e.textPrimary??"#fff"),t.setProperty("--bim-divider-color",e.border??"rgba(255, 255, 255, 0.2)"),t.setProperty("--bim-speed-group-bg",e.componentHover??"rgba(255, 255, 255, 0.1)"),t.setProperty("--bim-speed-btn-bg",e.componentHover??"rgba(255, 255, 255, 0.1)"),t.setProperty("--bim-speed-btn-hover",e.componentActive??"rgba(255, 255, 255, 0.2)"),t.setProperty("--bim-select-bg",e.componentHover??"rgba(255, 255, 255, 0.1)"),t.setProperty("--bim-select-border",e.border??"rgba(255, 255, 255, 0.2)"),t.setProperty("--bim-select-option-bg",e.panelBackground??"#333")}destroy(){this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element&&this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class m_{element;unsubscribeLocale=null;unsubscribeTheme=null;constructor(){}init(){this.element=this.createPanel(),this.unsubscribeLocale=It.subscribe(()=>this.setLocales()),this.unsubscribeTheme=Ze.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(Ze.getTheme())}createPanel(){const e=document.createElement("div");return e.className="walk-path-panel",e.style.padding="20px",e.style.color="var(--bim-text-color, #fff)",e.textContent="路径漫游内容待实现",e}setLocales(){}setTheme(e){}destroy(){this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element&&this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class f_ extends jt{dialogId="walk-path-dialog";dialog=null;panel=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}this.destroy(),this.panel=new m_,this.panel.init();const e=300,t=400,i=20,s=this.engine.container,r=s.clientHeight,o=s.clientWidth-e-i,l=(r-t)/2;this.dialog=this.engine.dialog.create({id:this.dialogId,title:"walkControl.path.dialogTitle",width:e,height:t,position:{x:o,y:l},draggable:!0,resizable:!1,content:this.panel.element,onClose:()=>{this.engine.walkControl&&this.engine.walkControl.panel&&this.engine.walkControl.panel.setPathModeActive(!1),this.hide()}}),this.dialog.init()}hide(){this.destroy()}destroy(){const e=this.dialog;this.dialog=null,e&&e.destroy(),this.panel&&(this.panel.destroy(),this.panel=null)}}class g_ extends jt{panel=null;pathManager=null;constructor(e){super(e)}init(){this.pathManager=new f_(this.engine),this.pathManager.init()}show(){if(!this.engine.toolbar){console.warn("Toolbar not initialized");return}this.engine.toolbar.hide(),this.panel=new p_({onPlanViewToggle:e=>{console.log("[WalkControl] 地图:",e),e?this.engine.map?.show():this.engine.map?.hide(),this.emit("walk:plan-view-toggle",{isActive:e})},onPathModeToggle:e=>{console.log("[WalkControl] 路径漫游:",e),e?this.pathManager?.show():this.pathManager?.hide(),this.emit("walk:path-mode-toggle",{isActive:e})},onWalkModeToggle:e=>{console.log("[WalkControl] 漫游模式:",e),e&&this.pathManager?.hide(),this.emit("walk:walk-mode-toggle",{isActive:e})},onSpeedChange:e=>{console.log("[WalkControl] 速度变化:",e),this.emit("walk:speed-change",{speed:e})},onGravityToggle:e=>{console.log("[WalkControl] 重力:",e),this.emit("walk:gravity-toggle",{enabled:e})},onCollisionToggle:e=>{console.log("[WalkControl] 碰撞:",e),this.emit("walk:collision-toggle",{enabled:e})},onCharacterModelChange:e=>{console.log("[WalkControl] 角色模型:",e)},onWalkModeChange:e=>{console.log("[WalkControl] 行走模式:",e)},onExit:()=>{this.hide()}}),this.panel.init(),this.engine.map?.isOpen()&&this.panel.setPlanViewActive(!0),this.engine.on("map:opened",()=>{this.panel?.setPlanViewActive(!0)}),this.engine.on("map:closed",()=>{this.panel?.setPlanViewActive(!1)}),this.engine.container?(this.panel.element.style.position="absolute",this.panel.element.style.bottom="20px",this.panel.element.style.left="50%",this.panel.element.style.transform="translateX(-50%)",this.panel.element.style.zIndex="1000",this.engine.container.appendChild(this.panel.element)):console.warn("[WalkControlManager] Container not found")}hide(){this.pathManager?.hide(),this.panel&&(this.panel.destroy(),this.panel=null),this.engine.toolbar&&this.engine.toolbar.show()}destroy(){this.hide(),this.pathManager?.destroy(),this.pathManager=null}}class v_{element;unsubscribeLocale=null;unsubscribeTheme=null;constructor(){}init(){this.element=this.createPanel(),this.unsubscribeLocale=It.subscribe(()=>this.setLocales()),this.unsubscribeTheme=Ze.subscribe(e=>this.setTheme(e)),this.setLocales(),this.setTheme(Ze.getTheme())}createPanel(){const e=document.createElement("div");return e.className="map-panel",e.style.padding="20px",e.style.color="#fff",e.textContent="地图内容待实现",e}setLocales(){}setTheme(e){}destroy(){this.unsubscribeLocale?.(),this.unsubscribeTheme?.(),this.element&&this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}class __ extends jt{dialogId="map-dialog";dialog=null;panel=null;constructor(e){super(e)}init(){}show(){if(!this.engine.dialog||!this.engine.container){console.warn("Dialog manager or container is not initialized");return}if(this.isOpen())return;this.panel=new v_,this.panel.init();const e=300,t=400,i=20,s=20,a=this.engine.container.clientHeight,o=i,l=a-t-s;this.dialog=this.engine.dialog.create({id:this.dialogId,title:"map.dialogTitle",width:e,height:t,position:{x:o,y:l},draggable:!0,resizable:!1,content:this.panel.element,onClose:()=>{this.hide()}}),this.dialog.init(),this.emit("map:opened",{})}hide(){this.destroy(),this.emit("map:closed",{})}isOpen(){return this.dialog!==null}destroy(){const e=this.dialog;this.dialog=null,e&&e.destroy(),this.panel&&(this.panel.destroy(),this.panel=null)}}class x_{events=new Map;on(e,t){return this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t),()=>this.off(e,t)}off(e,t){const i=this.events.get(e);if(!i)return;const s=i.indexOf(t);s!==-1&&i.splice(s,1)}emit(e,t){const i=this.events.get(e);i&&i.forEach(s=>{try{s(t)}catch(r){console.error(`[EventEmitter] Error in listener for event "${e}":`,r)}})}clear(){this.events.clear()}}class b_ extends x_{container;wrapper=null;toolbar=null;constructTreeBtn=null;buttonGroup=null;dialog=null;engine=null;rightKey=null;propertyPanel=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;map=null;constructor(e,t){super();const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,t?.locale&&It.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):Ze.setTheme(t.theme)),this.init()}emit(e,t){super.emit(e,t)}on(e,t){return super.on(e,t)}setLocale(e){It.setLocale(e)}getLocale(){return It.getLocale()}setTheme(e){Ze.setTheme(e)}setCustomTheme(e){Ze.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper),this.engine=new Jv(this,this.wrapper),this.dialog=new tu(this,this.wrapper),this.toolbar=new Jh(this,this.wrapper),this.buttonGroup=new Qh(this,this.wrapper),this.rightKey=new Nh(this,this.wrapper),this.constructTreeBtn=new i_(this,this.wrapper),this.propertyPanel=new n_(this),this.measure=new a_(this),this.sectionPlane=new l_(this),this.sectionAxis=new h_(this),this.sectionBox=new d_(this),this.walkControl=new g_(this),this.walkControl.init(),this.map=new __(this),this.map.init(),this.updateTheme(Ze.getTheme()),Ze.subscribe(e=>{this.updateTheme(e)})}updateTheme(e){this.wrapper&&(this.wrapper.style.backgroundColor=e.background,this.wrapper.style.color=e.textPrimary)}destroy(){this.toolbar?.destroy(),this.buttonGroup?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.propertyPanel?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.container.innerHTML="",this.clear()}}const y_=Object.freeze(Object.defineProperty({__proto__:null,createHomeButton:n=>({id:"home",groupId:"group-1",type:"button",label:"toolbar.home",icon:vt("主视角"),keepActive:!0,onClick:e=>{console.log("首页按钮被点击:",e.id),n.emit("ui:open-dialog",{id:"home-info"})}})},Symbol.toStringTag,{value:"Module"})),M_=Object.freeze(Object.defineProperty({__proto__:null,createZoomBoxButton:n=>({id:"zoom-box",groupId:"group-1",keepActive:!0,type:"button",label:"toolbar.zoomBox",icon:vt("框选放大"),onClick:()=>{}})},Symbol.toStringTag,{value:"Module"})),S_=Object.freeze(Object.defineProperty({__proto__:null,createWalkMenuButton:n=>({id:"walk",groupId:"group-1",type:"button",label:"toolbar.walk",align:"vertical",icon:vt("漫游"),onClick:()=>{console.log("漫游按钮被点击"),n.walkControl?.show()}})},Symbol.toStringTag,{value:"Module"})),T_=Object.freeze(Object.defineProperty({__proto__:null,createMapButton:n=>(n.on("map:opened",()=>{n.toolbar?.setBtnActive("map",!0)}),n.on("map:closed",()=>{n.toolbar?.setBtnActive("map",!1)}),{id:"map",groupId:"group-1",type:"button",label:"toolbar.map",align:"vertical",keepActive:!0,icon:vt("地图"),onClick:()=>{n.map?.isOpen()?n.map?.hide():n.map?.show()}})},Symbol.toStringTag,{value:"Module"})),E_=Object.freeze(Object.defineProperty({__proto__:null,createPropertyButton:n=>({id:"property",groupId:"group-1",type:"button",label:"toolbar.property",align:"vertical",icon:vt("文档"),onClick:()=>{console.log("构件详情按钮被点击"),n.propertyPanel?.show()}})},Symbol.toStringTag,{value:"Module"})),w_=Object.freeze(Object.defineProperty({__proto__:null,createSettingButton:n=>({id:"setting",groupId:"group-2",type:"button",label:"toolbar.setting",icon:vt("设置"),keepActive:!1,onClick:e=>{console.log("设置按钮被点击:",e.id)}})},Symbol.toStringTag,{value:"Module"})),C_='',A_=Object.freeze(Object.defineProperty({__proto__:null,createInfoButton:n=>({id:"toolbar-info",groupId:"group-2",type:"button",label:"toolbar.info",icon:C_,onClick:()=>{document.dispatchEvent(new CustomEvent("bim-demo:open-property-panel"))}})},Symbol.toStringTag,{value:"Module"})),R_=Object.freeze(Object.defineProperty({__proto__:null,createFullscreenButton:n=>({id:"fullscreen",groupId:"group-2",type:"button",label:"toolbar.fullscreen",align:"vertical",icon:vt("全屏"),onClick:async()=>{console.log("全屏按钮被点击"),window.self!==window.top&&console.warn('检测到在 Iframe 中运行,请确保父级 iframe 标签拥有 allow="fullscreen" 属性');try{const t=document,s=!!(t.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement);console.log("当前是否全屏:",s);const a=document.querySelector(".bim-engine-container")||document.body,o=a;if(s){console.log("准备退出全屏...");const l=t.exitFullscreen||t.webkitExitFullscreen||t.mozCancelFullScreen||t.msExitFullscreen;l&&(await l.call(t),console.log("退出全屏请求已发送"))}else{console.log("准备进入全屏..."),(a.style.backgroundColor===""||a.style.backgroundColor==="transparent")&&(a.style.backgroundColor="#ffffff");const l=o.requestFullscreen||o.webkitRequestFullscreen||o.mozRequestFullScreen||o.msRequestFullscreen;l?(await l.call(o,{navigationUI:"hide"}),console.log("全屏请求已发送")):(console.warn("当前浏览器不支持全屏 API"),alert("当前浏览器不支持全屏功能"))}}catch(t){console.error("全屏操作失败:",t),t&&t.message&&t.message.includes("denied")&&console.error('全屏请求被拒绝。如果是 Iframe,请检查 allow="fullscreen"。如果是自动触发,请确保由用户点击触发。')}}})},Symbol.toStringTag,{value:"Module"})),P_=Object.freeze(Object.defineProperty({__proto__:null,createMeasureButton:n=>({id:"measure",groupId:"group-1",type:"button",label:"toolbar.measure",icon:vt("测量"),keepActive:!0,onClick:e=>{e.isActive?n.measure?.show():n.measure?.destroy()}})},Symbol.toStringTag,{value:"Module"})),L_=Object.freeze(Object.defineProperty({__proto__:null,createSectionMenuButton:n=>({id:"section",groupId:"group-1",type:"menu",label:"toolbar.section",align:"vertical",icon:vt("剖切"),keepActive:!0,onClick:e=>{console.log("剖切按钮被点击:",e.id)}})},Symbol.toStringTag,{value:"Module"})),D_=Object.freeze(Object.defineProperty({__proto__:null,createSectionPlaneButton:n=>({id:"section-plane",groupId:"group-1",parentId:"section",type:"button",keepActive:!0,exclusive:!0,align:"vertical",label:"toolbar.sectionPlane",icon:vt("拾曲面剖切"),onClick:e=>{console.log("拾取面剖切被点击:",e.id,"激活状态:",e.isActive),e.isActive?n.sectionPlane?.show():n.sectionPlane?.hide()}})},Symbol.toStringTag,{value:"Module"})),I_=Object.freeze(Object.defineProperty({__proto__:null,createSectionAxisButton:n=>({id:"section-axis",groupId:"group-1",parentId:"section",type:"button",keepActive:!0,exclusive:!0,align:"vertical",label:"toolbar.sectionAxis",icon:vt("轴向剖切"),onClick:e=>{e.isActive?n.sectionAxis?.show():n.sectionAxis?.destroy()}})},Symbol.toStringTag,{value:"Module"})),U_=Object.freeze(Object.defineProperty({__proto__:null,createSectionBoxButton:n=>({id:"section-box",groupId:"group-1",parentId:"section",type:"button",keepActive:!0,exclusive:!0,align:"vertical",label:"toolbar.sectionBox",icon:vt("剖切盒"),onClick:e=>{console.log("剖切盒被点击:",e.id,"激活状态:",e.isActive),e.isActive?n.sectionBox?.show():n.sectionBox?.hide()}})},Symbol.toStringTag,{value:"Module"}));ys.BimEngine=b_,Object.defineProperty(ys,Symbol.toStringTag,{value:"Module"})})); //# sourceMappingURL=bim-engine-sdk.umd.js.map diff --git a/dist/bim-engine-sdk.umd.js.map b/dist/bim-engine-sdk.umd.js.map index 5923e2f..472b739 100644 --- a/dist/bim-engine-sdk.umd.js.map +++ b/dist/bim-engine-sdk.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"bim-engine-sdk.umd.js","sources":["../src/locales/zh-CN.ts","../src/locales/en-US.ts","../src/services/locale.ts","../src/themes/presets.ts","../src/services/theme.ts","../src/components/button-group/index.ts","../src/components/button-group/toolbar/index.ts","../src/core/component.ts","../src/managers/toolbar-manager.ts","../src/managers/button-group-manager.ts","../src/components/dialog/index.ts","../src/components/dialog/bimInfoDialog/index.ts","../src/managers/dialog-manager.ts","../src/bim-engine-sdk.es.js","../src/components/engine/index.ts","../src/components/right-key/index.ts","../src/components/menu/index.ts","../src/managers/right-key-manager.ts","../src/components/menu/buttons/info.ts","../src/components/menu/buttons/four.ts","../src/components/menu/buttons/second.ts","../src/components/menu/buttons/home.ts","../src/managers/engine-manager.ts","../src/components/tree/types.ts","../src/components/tree/tree-node.ts","../src/components/tree/index.ts","../src/components/tab/index.ts","../src/utils/icon-manager.ts","../src/managers/construct-tree-manager-btn.ts","../src/components/collapse/index.ts","../src/components/description/index.ts","../src/managers/property-panel-manager.ts","../src/components/measure-panel/index.ts","../src/managers/measure-dialog-manager.ts","../src/components/section-plane-panel/index.ts","../src/managers/section-plane-dialog-manager.ts","../src/components/section-axis-panel/index.ts","../src/managers/section-axis-dialog-manager.ts","../src/components/section-box-panel/index.ts","../src/managers/section-box-dialog-manager.ts","../src/components/walk-control-panel/index.ts","../src/components/walk-path-panel/index.ts","../src/managers/walk-path-dialog-manager.ts","../src/managers/walk-control-manager.ts","../src/components/map-panel/index.ts","../src/managers/map-dialog-manager.ts","../src/core/event-emitter.ts","../src/bim-engine.ts","../src/components/button-group/toolbar/buttons/home/index.ts","../src/components/button-group/toolbar/buttons/zoom-box/index.ts","../src/components/button-group/toolbar/buttons/walk/walk-menu/index.ts","../src/components/button-group/toolbar/buttons/map/index.ts","../src/components/button-group/toolbar/buttons/property/index.ts","../src/components/button-group/toolbar/buttons/setting/index.ts","../src/components/button-group/toolbar/buttons/info/icon.ts","../src/components/button-group/toolbar/buttons/info/index.ts","../src/components/button-group/toolbar/buttons/fullscreen/index.ts","../src/components/button-group/toolbar/buttons/measure/index.ts","../src/components/button-group/toolbar/buttons/section/section-menu/index.ts","../src/components/button-group/toolbar/buttons/section/section-plane/index.ts","../src/components/button-group/toolbar/buttons/section/section-axis/index.ts","../src/components/button-group/toolbar/buttons/section/section-box/index.ts"],"sourcesContent":["import {TranslationDictionary} from './types';\n\nexport const zhCN: TranslationDictionary = {\n common: {\n title: 'BimEngine',\n description: '这是一个使用 BIM-ENGINE。',\n openTestDialog: '打开测试弹窗',\n openInfoDialog: '打开信息弹窗 (封装版)',\n },\n toolbar: {\n home: '首页',\n measure: '测量',\n zoomBox: '选框放大',\n info: '信息',\n location: '定位',\n setting: '设置',\n walk: '漫游',\n map: '地图',\n property: '构件详情',\n fullscreen: '全屏',\n walkMenu: '漫游菜单',\n walkPerson: '第一人称',\n walkBird: '第三人称',\n tree: '模型树',\n section: '剖切',\n sectionPlane: '拾取面剖切',\n sectionAxis: '轴向剖切',\n sectionBox: '剖切盒'\n },\n dialog: {\n testTitle: '测试弹窗',\n testContent: ' 这是一个 可拖拽 且 可缩放 的弹窗。',\n },\n menu: {\n info: '信息',\n home: '首页'\n },\n tree: {\n searchPlaceholder: '请输入要搜索的内容',\n },\n constructTree: {\n title: '目录树',\n },\n tab: {\n component: '构件',\n system: '系统',\n space: '空间',\n },\n panel: {\n property: {\n title: '构件详情',\n base: '基本属性',\n material: '材质信息',\n advanced: '高级设置',\n tab: {\n props: '属性',\n material: '材质'\n }\n }\n },\n measure: {\n btnName: '测量',\n dialogTitle: '测量',\n modes: {\n distance: '距离',\n minDistance: '最小距离',\n angle: '角度',\n elevation: '标高',\n volume: '体积',\n laserDistance: '激光测距',\n slope: '坡度',\n spaceVolume: '空间体积',\n },\n actions: {\n expand: '展开',\n collapse: '收起',\n clearAll: '删除全部',\n settings: '设置',\n },\n labels: {\n currentMode: '当前测量方式:',\n x: 'X:',\n y: 'Y:',\n z: 'Z:',\n value: {\n distance: '距离:',\n minDistance: '最小距离:',\n angle: '角度:',\n elevation: '标高:',\n volume: '体积:',\n laserDistance: '激光测距:',\n slope: '坡度:',\n spaceVolume: '空间体积:',\n }\n },\n units: {\n mm: 'mm',\n cm: 'cm',\n m: 'm',\n km: 'km',\n deg: '°',\n m3: 'm³',\n percent: '%',\n },\n settings: {\n title: '设置',\n unit: '单位:',\n precision: '精度:',\n hint: '距离、最小距离和标高默认使用该单位;角度和体积有各自默认单位。',\n save: '保存设置',\n cancel: '取消',\n }\n },\n sectionPlane: {\n dialogTitle: '拾取面剖切',\n actions: {\n hide: '隐藏',\n reverse: '反向',\n reset: '重置'\n }\n },\n sectionAxis: {\n dialogTitle: '轴向剖切',\n actions: {\n hide: '隐藏',\n reverse: '反向',\n axisX: 'X',\n axisY: 'Y',\n axisZ: 'Z'\n }\n },\n sectionBox: {\n dialogTitle: '剖切盒',\n actions: {\n hide: '隐藏',\n reverse: '反向',\n fitToModel: '适应',\n reset: '重置'\n },\n axes: {\n x: 'X',\n y: 'Y',\n z: 'Z'\n }\n },\n walkControl: {\n speed: '移动速度:',\n gravity: '重力',\n collision: '碰撞',\n characterModel: {\n label: '建筑工人',\n constructionWorker: '建筑工人',\n officeMale: '办公室男性'\n },\n walkMode: {\n label: '行走模式',\n walk: '行走模式',\n run: '奔跑模式'\n },\n exit: '退出',\n path: {\n dialogTitle: '路径漫游'\n }\n },\n map: {\n dialogTitle: '地图'\n }\n};\n","import {TranslationDictionary} from './types';\n\nexport const enUS: TranslationDictionary = {\n common: {\n title: 'BimEngine',\n description: 'This is a BIM-ENGINE demo.',\n openTestDialog: 'Open Test Dialog',\n openInfoDialog: 'Open Info Dialog (Wrapped)',\n },\n toolbar: {\n home: 'Home',\n measure: 'Measure',\n zoomBox: 'Zoom Box',\n info: 'Info',\n location: 'Location',\n setting: 'Settings',\n walk: 'Walk',\n map: 'Map',\n property: 'Property',\n fullscreen: 'Fullscreen',\n walkPerson: 'Person',\n walkBird: 'Bird Eye',\n walkMenu: 'Menu',\n tree: 'Tree',\n section: 'Section',\n sectionPlane: 'Plane Section',\n sectionAxis: 'Axis Section',\n sectionBox: 'Section Box'\n },\n dialog: {\n testTitle: 'Test Dialog',\n testContent: '
你可以尝试拖动标题栏,或者拖动右下角改变大小。This is a draggable and resizable dialog.',\n },\n menu: {\n info: 'Info',\n home: 'Home',\n },\n tree: {\n searchPlaceholder: 'Please enter content to search',\n },\n constructTree: {\n title: 'Construct Tree',\n },\n tab: {\n component: 'Component',\n system: 'System',\n space: 'Space',\n },\n panel: {\n property: {\n title: 'Component Details',\n base: 'Basic Info',\n material: 'Material',\n advanced: 'Advanced',\n tab: {\n props: 'Properties',\n material: 'Material'\n }\n }\n },\n measure: {\n btnName: 'Measure',\n dialogTitle: 'Measure',\n modes: {\n distance: 'Distance',\n minDistance: 'Min Distance',\n angle: 'Angle',\n elevation: 'Elevation',\n volume: 'Volume',\n laserDistance: 'Laser Distance',\n slope: 'Slope',\n spaceVolume: 'Space Volume',\n },\n actions: {\n expand: 'Expand',\n collapse: 'Collapse',\n clearAll: 'Clear All',\n settings: 'Settings',\n },\n labels: {\n currentMode: 'Mode:',\n x: 'X:',\n y: 'Y:',\n z: 'Z:',\n value: {\n distance: 'Distance:',\n minDistance: 'Min Distance:',\n angle: 'Angle:',\n elevation: 'Elevation:',\n volume: 'Volume:',\n laserDistance: 'Laser Distance:',\n slope: 'Slope:',\n spaceVolume: 'Space Volume:',\n }\n },\n units: {\n mm: 'mm',\n cm: 'cm',\n m: 'm',\n km: 'km',\n deg: '°',\n m3: 'm³',\n percent: '%',\n },\n settings: {\n title: 'Settings',\n unit: 'Unit:',\n precision: 'Precision:',\n hint: 'Distance, min distance and elevation use this unit by default; angle and volume use their own units.',\n save: 'Save',\n cancel: 'Cancel',\n }\n },\n sectionPlane: {\n dialogTitle: 'Plane Section',\n actions: {\n hide: 'Hide',\n reverse: 'Reverse',\n reset: 'Reset'\n }\n },\n sectionAxis: {\n dialogTitle: 'Axis Section',\n actions: {\n hide: 'Hide',\n reverse: 'Reverse',\n axisX: 'X',\n axisY: 'Y',\n axisZ: 'Z'\n }\n },\n sectionBox: {\n dialogTitle: 'Section Box',\n actions: {\n hide: 'Hide',\n reverse: 'Reverse',\n fitToModel: 'Fit',\n reset: 'Reset'\n },\n axes: {\n x: 'X',\n y: 'Y',\n z: 'Z'\n }\n },\n walkControl: {\n speed: 'Speed:',\n gravity: 'Gravity',\n collision: 'Collision',\n characterModel: {\n label: 'Construction Worker',\n constructionWorker: 'Construction Worker',\n officeMale: 'Office Male'\n },\n walkMode: {\n label: 'Walk Mode',\n walk: 'Walk',\n run: 'Run'\n },\n exit: 'Exit',\n path: {\n dialogTitle: 'Path Walk'\n }\n },\n map: {\n dialogTitle: 'Map'\n }\n};\n","import { LocaleType, TranslationDictionary } from '../locales/types';\nimport { zhCN } from '../locales/zh-CN';\nimport { enUS } from '../locales/en-US';\n\ntype LocaleChangeListener = (locale: LocaleType) => void;\n\n/**\n * 语言管理器类\n */\nexport class LocaleManager {\n private currentLocale: LocaleType = 'zh-CN';\n private messages: Record
Try dragging the title bar or resizing from the bottom-right corner.= {\n 'zh-CN': zhCN,\n 'en-US': enUS,\n };\n private listeners: LocaleChangeListener[] = [];\n\n constructor() {\n // 默认初始化\n }\n\n /**\n * 获取当前语言\n */\n public getLocale(): LocaleType {\n return this.currentLocale;\n }\n\n /**\n * 切换语言\n */\n public setLocale(locale: LocaleType) {\n if (this.currentLocale === locale) return;\n this.currentLocale = locale;\n this.notifyListeners();\n }\n\n /**\n * 翻译核心方法\n */\n public t(key: string): string {\n if (!key) return '';\n \n const keys = key.split('.');\n let value: any = this.messages[this.currentLocale];\n \n for (const k of keys) {\n if (value && typeof value === 'object' && k in value) {\n value = value[k];\n } else {\n return key;\n }\n }\n return value as string;\n }\n\n /**\n * 订阅变更\n */\n public subscribe(listener: LocaleChangeListener): () => void {\n this.listeners.push(listener);\n return () => {\n this.listeners = this.listeners.filter(l => l !== listener);\n };\n }\n\n private notifyListeners() {\n this.listeners.forEach(listener => listener(this.currentLocale));\n }\n}\n\n// --- 导出单例 ---\nexport const localeManager = new LocaleManager();\n\n// --- 导出便捷方法 ---\n/**\n * 全局翻译函数\n * @param key 键路径 (如 'toolbar.home')\n */\nexport const t = (key: string): string => localeManager.t(key);\n","import { ThemeConfig } from './types';\n\n/**\n * 深色主题 (默认)\n */\nexport const darkTheme: ThemeConfig = {\n name: 'dark',\n primary: '#0078d4',\n primaryHover: '#0063b1',\n\n // 修改:背景色统一为浅灰,不再跟随深色模式变黑\n background: '#f5f5f5',\n panelBackground: 'rgba(30, 30, 30, 0.9)',\n\n textPrimary: '#ffffff',\n textSecondary: '#cccccc',\n\n border: '#444444',\n\n icon: '#cccccc',\n iconActive: '#ffffff',\n\n componentBackground: 'transparent',\n componentHover: '#4e4d4dff',\n componentActive: 'rgba(255, 255, 255, 0.1)'\n};\n\n/**\n * 浅色主题\n */\nexport const lightTheme: ThemeConfig = {\n name: 'light',\n primary: '#0078d4',\n primaryHover: '#106ebe',\n\n // 统一为浅灰\n background: '#f5f5f5',\n panelBackground: '#ffffff',\n\n textPrimary: '#333333',\n textSecondary: '#666666',\n\n border: '#e0e0e0',\n\n icon: '#555555',\n iconActive: '#0078d4',\n\n componentBackground: 'transparent',\n componentHover: '#f0f0f0',\n componentActive: '#e0e0e0'\n};","import { ThemeConfig } from '../themes/types';\nimport { darkTheme, lightTheme } from '../themes/presets';\n\ntype ThemeChangeListener = (theme: ThemeConfig) => void;\n\n/**\n * 主题管理器 (单例)\n */\nexport class ThemeManager {\n private currentTheme: ThemeConfig = darkTheme;\n private listeners: ThemeChangeListener[] = [];\n\n constructor() {\n // 默认初始化\n }\n\n /**\n * 获取当前主题配置\n */\n public getTheme(): ThemeConfig {\n return this.currentTheme;\n }\n\n /**\n * 切换预设主题\n * @param themeName 'dark' | 'light'\n */\n public setTheme(themeName: 'dark' | 'light') {\n if (themeName === 'light') {\n this.applyTheme(lightTheme);\n } else {\n this.applyTheme(darkTheme);\n }\n }\n\n /**\n * 应用自定义主题配置\n * @param theme 配置对象\n */\n public setCustomTheme(theme: ThemeConfig) {\n this.applyTheme(theme);\n }\n\n /**\n * 内部应用主题逻辑\n */\n private applyTheme(theme: ThemeConfig) {\n this.currentTheme = theme;\n this.notifyListeners();\n }\n\n /**\n * 订阅主题变更\n */\n public subscribe(listener: ThemeChangeListener): () => void {\n this.listeners.push(listener);\n // 立即回调一次当前状态\n listener(this.currentTheme);\n return () => {\n this.listeners = this.listeners.filter(l => l !== listener);\n };\n }\n\n private notifyListeners() {\n this.listeners.forEach(listener => listener(this.currentTheme));\n }\n}\n\n// 导出单例\nexport const themeManager = new ThemeManager();","import './index.css';\nimport type {\n OptButton,\n ButtonGroup,\n ButtonGroupOptions,\n ButtonConfig,\n ButtonGroupColors\n} from './index.type';\nimport { t, localeManager } from '../../services/locale';\nimport { themeManager } from '../../services/theme';\nimport type { ThemeConfig } from '../../themes/types';\nimport { IBimComponent } from '../../types/component';\nimport type { BimEngine } from '../../bim-engine';\nimport { EngineEvents } from '../../types/events';\n\n/**\n * 通用按钮组组件 (BimButtonGroup)\n */\nexport class BimButtonGroup implements IBimComponent {\n private container: HTMLElement;\n private options: ButtonGroupOptions;\n private groups: ButtonGroup[] = [];\n private activeBtnIds: Set = new Set();\n private btnRefs: Map = new Map();\n private dropdownElement: HTMLElement | null = null;\n private hoverTimeout: number | null = null;\n private customColors: Set = new Set(); // 记录用户自定义的颜色属性\n private unsubscribeLocale: (() => void) | null = null;\n private unsubscribeTheme: (() => void) | null = null;\n\n protected engine: BimEngine | null = null;\n\n private readonly DEFAULT_ICON = '';\n\n constructor(options: ButtonGroupOptions) {\n const el = typeof options.container === 'string'\n ? document.getElementById(options.container)\n : options.container;\n\n if (!el) throw new Error('Container not found');\n\n this.container = el;\n // 合并默认配置\n this.options = {\n showLabel: true,\n visibility: {},\n direction: 'row', // 默认横向\n position: 'static', // 默认静态定位\n align: 'vertical', // 默认图标在上\n expand: 'down', // 默认向下展开\n ...options\n };\n\n // 记录初始传入的自定义颜色\n const colorKeys: (keyof ButtonGroupColors)[] = [\n 'backgroundColor', 'btnBackgroundColor', 'btnHoverColor',\n 'btnActiveColor', 'iconColor', 'iconActiveColor',\n 'textColor', 'textActiveColor'\n ];\n colorKeys.forEach(key => {\n if (options[key]) {\n this.customColors.add(key);\n }\n });\n\n this.initContainer();\n this.applyStyles();\n }\n\n public setEngine(engine: BimEngine) {\n this.engine = engine;\n }\n\n protected emit (event: K, payload: EngineEvents[K]) {\n if (this.engine) {\n this.engine.emit(event, payload);\n } else {\n console.warn('[BimButtonGroup] Engine not set, cannot emit event:', event);\n }\n }\n\n private initContainer(): void {\n this.container.innerHTML = '';\n this.container.classList.add('bim-btn-group-root');\n\n if (this.options.direction === 'column') {\n this.container.classList.add('dir-column');\n } else {\n this.container.classList.add('dir-row');\n }\n\n if (this.options.className) {\n this.container.classList.add(this.options.className);\n }\n\n this.updatePosition();\n\n // 添加事件拦截,防止点击穿透到 3D 引擎\n this.setupEventInterception(this.container);\n }\n\n /**\n * 设置事件拦截,防止事件冒泡到下层元素(如 3D 引擎)\n */\n private setupEventInterception(el: HTMLElement): void {\n const stopPropagation = (e: Event) => {\n e.stopPropagation();\n };\n\n const events = [\n 'click', 'dblclick', 'contextmenu', 'wheel',\n 'mousedown', 'mouseup', 'mousemove',\n 'touchstart', 'touchend', 'touchmove',\n 'pointerdown', 'pointerup', 'pointermove', 'pointerenter', 'pointerleave', 'pointerover', 'pointerout'\n ];\n\n events.forEach(eventType => {\n el.addEventListener(eventType, stopPropagation, { passive: false });\n });\n }\n\n private updatePosition() {\n const pos = this.options.position;\n const style = this.container.style;\n\n style.top = ''; style.bottom = ''; style.left = ''; style.right = ''; style.transform = '';\n\n if (pos === 'static') {\n this.container.classList.add('static');\n return;\n }\n\n this.container.classList.remove('static');\n this.container.style.position = 'absolute';\n\n if (typeof pos === 'object' && 'x' in pos) {\n style.left = `${pos.x}px`;\n style.top = `${pos.y}px`;\n } else {\n const margin = '20px';\n switch (pos) {\n case 'top-left':\n style.top = margin; style.left = margin;\n break;\n case 'top-center':\n style.top = margin; style.left = '50%'; style.transform = 'translateX(-50%)';\n break;\n case 'top-right':\n style.top = margin; style.right = margin;\n break;\n case 'bottom-left':\n style.bottom = margin; style.left = margin;\n break;\n case 'bottom-center':\n style.bottom = margin; style.left = '50%'; style.transform = 'translateX(-50%)';\n break;\n case 'bottom-right':\n style.bottom = margin; style.right = margin;\n break;\n case 'left-center':\n style.left = margin; style.top = '50%'; style.transform = 'translateY(-50%)';\n break;\n case 'right-center':\n style.right = margin; style.top = '50%'; style.transform = 'translateY(-50%)';\n break;\n case 'center':\n style.top = '50%'; style.left = '50%'; style.transform = 'translate(-50%, -50%)';\n break;\n }\n }\n }\n\n /**\n * 应用样式到容器\n */\n private applyStyles(): void {\n const style = this.container.style;\n if (this.options.backgroundColor) style.setProperty('--bim-btn-group-section-bg', this.options.backgroundColor);\n if (this.options.btnBackgroundColor) style.setProperty('--bim-btn-bg', this.options.btnBackgroundColor);\n if (this.options.btnHoverColor) style.setProperty('--bim-btn-hover-bg', this.options.btnHoverColor);\n if (this.options.btnActiveColor) style.setProperty('--bim-btn-active-bg', this.options.btnActiveColor);\n if (this.options.iconColor) style.setProperty('--bim-icon-color', this.options.iconColor);\n if (this.options.iconActiveColor) style.setProperty('--bim-icon-active-color', this.options.iconActiveColor);\n if (this.options.textColor) style.setProperty('--bim-btn-text-color', this.options.textColor);\n if (this.options.textActiveColor) style.setProperty('--bim-btn-text-active-color', this.options.textActiveColor);\n\n // 同步更新所有已存在的dropdown元素的CSS变量(dropdown被添加到body,无法继承容器的CSS变量)\n const dropdowns = document.querySelectorAll('.opt-btn-dropdown');\n dropdowns.forEach(dropdown => {\n const dropdownStyle = (dropdown as HTMLElement).style;\n if (this.options.iconColor) dropdownStyle.setProperty('--bim-icon-color', this.options.iconColor);\n if (this.options.iconActiveColor) dropdownStyle.setProperty('--bim-icon-active-color', this.options.iconActiveColor);\n if (this.options.textColor) dropdownStyle.setProperty('--bim-btn-text-color', this.options.textColor);\n if (this.options.textActiveColor) dropdownStyle.setProperty('--bim-btn-text-active-color', this.options.textActiveColor);\n if (this.options.btnBackgroundColor) dropdownStyle.setProperty('--bim-btn-bg', this.options.btnBackgroundColor);\n if (this.options.btnHoverColor) dropdownStyle.setProperty('--bim-btn-hover-bg', this.options.btnHoverColor);\n if (this.options.btnActiveColor) dropdownStyle.setProperty('--bim-btn-active-bg', this.options.btnActiveColor);\n });\n }\n\n /**\n * 设置主题的primary颜色(用于边框等)\n */\n private setPrimaryColor(color: string): void {\n this.container.style.setProperty('--bim-primary-color', color);\n\n // 同步更新所有dropdown(dropdown被添加到body,无法继承容器的CSS变量)\n const dropdowns = document.querySelectorAll('.opt-btn-dropdown');\n dropdowns.forEach(dropdown => {\n (dropdown as HTMLElement).style.setProperty('--bim-primary-color', color);\n });\n }\n\n /**\n * 设置主题颜色\n * 只会应用到没有被用户自定义的颜色属性上\n */\n public setTheme(theme: ThemeConfig): void {\n const themeColors: ButtonGroupColors = {\n backgroundColor: theme.panelBackground,\n btnBackgroundColor: theme.componentBackground,\n btnHoverColor: theme.componentHover,\n btnActiveColor: theme.componentActive,\n iconColor: theme.icon,\n iconActiveColor: theme.iconActive,\n textColor: theme.textSecondary,\n textActiveColor: theme.textPrimary\n };\n\n // 只应用没有被自定义的颜色\n Object.entries(themeColors).forEach(([key, value]) => {\n const colorKey = key as keyof ButtonGroupColors;\n if (!this.customColors.has(colorKey)) {\n this.options[colorKey] = value;\n }\n });\n\n this.applyStyles();\n this.setPrimaryColor(theme.primary);\n }\n\n /**\n * 直接设置颜色(强制覆盖)\n * 设置的颜色会被标记为自定义,后续的 setTheme 不会覆盖它们\n */\n public setColors(colors: ButtonGroupColors): void {\n // 更新 options\n this.options = { ...this.options, ...colors };\n\n // 标记这些颜色为自定义\n Object.keys(colors).forEach(key => {\n this.customColors.add(key as keyof ButtonGroupColors);\n });\n\n this.applyStyles();\n }\n\n public async init(): Promise {\n this.render();\n\n // 自动订阅语言变更\n this.unsubscribeLocale = localeManager.subscribe(() => {\n this.setLocales();\n });\n\n // 自动订阅主题变更\n this.unsubscribeTheme = themeManager.subscribe((theme) => {\n this.setTheme(theme);\n });\n }\n\n public setLocales(): void {\n this.render();\n }\n\n public addGroup(groupId: string, beforeGroupId?: string): void {\n if (this.groups.some(g => g.id === groupId)) return;\n const newGroup: ButtonGroup = { id: groupId, buttons: [] };\n if (beforeGroupId) {\n const index = this.groups.findIndex(g => g.id === beforeGroupId);\n index !== -1 ? this.groups.splice(index, 0, newGroup) : this.groups.push(newGroup);\n } else {\n this.groups.push(newGroup);\n }\n }\n\n public addButton(config: ButtonConfig): void {\n const { groupId, parentId } = config;\n const group = this.groups.find(g => g.id === groupId);\n if (!group) return;\n\n const button: OptButton = { ...config, children: config.children || [] };\n if (parentId) {\n const parentBtn = this.findButton(group.buttons, parentId);\n if (parentBtn) {\n if (!parentBtn.children) parentBtn.children = [];\n parentBtn.children.push(button);\n }\n } else {\n group.buttons.push(button);\n }\n }\n\n private findButton(buttons: OptButton[], id: string): OptButton | undefined {\n for (const btn of buttons) {\n if (btn.id === id) return btn;\n if (btn.children) {\n const found = this.findButton(btn.children, id);\n if (found) return found;\n }\n }\n return undefined;\n }\n\n public render(): void {\n this.container.innerHTML = '';\n this.btnRefs.clear();\n\n this.groups.forEach((group, index) => {\n const groupElement = this.renderGroup(group, index, this.groups.length);\n this.container.appendChild(groupElement);\n });\n }\n\n private renderGroup(group: ButtonGroup, index: number, total: number): HTMLElement {\n const groupEl = document.createElement('div');\n groupEl.className = 'bim-btn-group-section';\n\n if (index < total - 1) {\n groupEl.classList.add('has-divider');\n }\n\n group.buttons.forEach(button => {\n if (this.isVisible(button.id)) {\n const btnWrapper = this.renderButton(button);\n groupEl.appendChild(btnWrapper);\n }\n });\n return groupEl;\n }\n\n private renderButton(button: OptButton): HTMLElement {\n const wrapper = document.createElement('div');\n wrapper.className = 'opt-btn-wrapper';\n\n const btnEl = document.createElement('div');\n btnEl.className = 'opt-btn';\n\n // 初始化时根据 button 自身的属性同步 active 状态\n if (button.isActive) {\n this.activeBtnIds.add(button.id);\n }\n\n // 按钮优先使用自己的 align,否则使用全局配置,默认为 vertical\n const align = button.align || this.options.align || 'vertical';\n if (align === 'horizontal') {\n btnEl.classList.add('align-horizontal');\n } else {\n btnEl.classList.add('align-vertical');\n }\n\n if (this.activeBtnIds.has(button.id)) btnEl.classList.add('active');\n if (button.disabled) btnEl.classList.add('disabled');\n\n // 判断是否显示 label\n const hasLabel = this.options.showLabel && button.label;\n if (!hasLabel) {\n btnEl.classList.add('no-label');\n // 当不显示 label 时,添加 title 属性作为 tooltip\n if (button.label) {\n btnEl.title = t(button.label);\n }\n }\n\n // 应用按钮的自定义样式\n const iconSize = button.iconSize || 32;\n const minWidth = button.minWidth || 50;\n btnEl.style.minWidth = `${minWidth}px`;\n\n const icon = document.createElement('div');\n icon.className = 'opt-btn-icon';\n icon.style.width = `${iconSize}px`;\n icon.style.height = `${iconSize}px`;\n icon.innerHTML = this.getIcon(button.icon);\n btnEl.appendChild(icon);\n\n // 创建文字和箭头的容器,确保它们始终在一起(无论主轴是横是竖)\n const textWrapper = document.createElement('div');\n textWrapper.className = 'opt-btn-text-wrapper';\n\n if (this.options.showLabel && button.label) {\n const label = document.createElement('span');\n label.className = 'opt-btn-label';\n label.textContent = t(button.label);\n textWrapper.appendChild(label);\n }\n\n if (button.children && button.children.length > 0) {\n const arrow = document.createElement('span');\n arrow.className = 'opt-btn-arrow';\n arrow.textContent = '▼';\n textWrapper.appendChild(arrow);\n }\n\n // 只有当有内容时才添加 wrapper\n if (textWrapper.hasChildNodes()) {\n btnEl.appendChild(textWrapper);\n }\n\n btnEl.addEventListener('click', () => this.handleClick(button));\n btnEl.addEventListener('mouseenter', () => this.handleMouseEnter(button, btnEl));\n btnEl.addEventListener('mouseleave', () => this.handleMouseLeave());\n\n this.btnRefs.set(button.id, btnEl);\n wrapper.appendChild(btnEl);\n return wrapper;\n }\n\n /**\n * 设置按钮的激活状态\n * @param id 按钮 ID\n * @param active 可选,如果不传则切换(toggle)当前状态\n */\n public setBtnActive(id: string, active?: boolean): void {\n const button = this.findButtonById(id);\n if (!button) return;\n\n // 确定最终状态\n const newState = active !== undefined ? active : !this.activeBtnIds.has(id);\n\n if (newState) {\n this.activeBtnIds.add(id);\n } else {\n this.activeBtnIds.delete(id);\n }\n\n // 同步对象状态并更新 DOM\n button.isActive = newState;\n this.updateButtonState(id);\n }\n\n private handleClick(button: OptButton): void {\n if (button.disabled) return;\n if (!button.children || button.children.length === 0) {\n if (button.keepActive) {\n // 1) 先切换自身激活状态(onClick 里通常会根据 isActive 决定“打开/关闭”逻辑)\n const wasActive = this.activeBtnIds.has(button.id);\n const newState = !wasActive;\n this.setBtnActive(button.id, newState);\n\n // 2) 互斥逻辑:仅在“本次切换为激活”时触发\n // - 一级按钮:同 groupId 下其它一级按钮互斥\n // - 二级按钮:同 groupId + 同 parentId 下其它二级按钮互斥\n // - 被关闭的按钮需要触发 onClick(用于执行关闭逻辑)\n if (newState && button.exclusive && button.groupId) {\n this.deactivateExclusiveSiblings(button);\n }\n }\n this.closeDropdown();\n if (button.onClick) button.onClick(button);\n }\n }\n\n /**\n * 互斥关闭同范围内的其它已激活按钮,并触发它们的 onClick\n * @param button 当前被激活的按钮\n */\n private deactivateExclusiveSiblings(button: OptButton): void {\n const group = this.groups.find(g => g.id === button.groupId);\n if (!group) return;\n\n // 二级按钮:同 groupId + 同 parentId\n if (button.parentId) {\n const parent = this.findButton(group.buttons, button.parentId);\n const siblings = parent?.children || [];\n for (const sib of siblings) {\n if (!sib) continue;\n if (sib.id === button.id) continue;\n if (sib.parentId !== button.parentId) continue;\n if (sib.groupId !== button.groupId) continue;\n\n if (this.activeBtnIds.has(sib.id)) {\n this.setBtnActive(sib.id, false);\n // 触发被关闭按钮的 onClick(此时 sib.isActive 已经同步为 false)\n if (sib.onClick) sib.onClick(sib);\n }\n }\n return;\n }\n\n // 一级按钮:同 groupId 下其它一级按钮(不包含二级)\n for (const sib of group.buttons) {\n if (sib.id === button.id) continue;\n if (sib.groupId !== button.groupId) continue;\n if (sib.parentId) continue; // 只处理一级按钮\n\n if (this.activeBtnIds.has(sib.id)) {\n this.setBtnActive(sib.id, false);\n if (sib.onClick) sib.onClick(sib);\n }\n }\n }\n\n private handleMouseEnter(button: OptButton, btnEl: HTMLElement): void {\n if (this.hoverTimeout) clearTimeout(this.hoverTimeout);\n if (button.children && button.children.length > 0) {\n this.showDropdown(button, btnEl);\n } else {\n this.closeDropdown();\n }\n }\n\n private handleMouseLeave(): void {\n this.hoverTimeout = window.setTimeout(() => this.closeDropdown(), 200);\n }\n\n private showDropdown(button: OptButton, btnEl: HTMLElement): void {\n this.closeDropdown();\n if (!button.children) return;\n\n const dropdown = document.createElement('div');\n dropdown.className = 'opt-btn-dropdown';\n if (this.options.backgroundColor) dropdown.style.setProperty('--bim-toolbar-bg', this.options.backgroundColor);\n\n // 将主题CSS变量复制到dropdown元素上(因为dropdown被添加到body,无法继承容器的CSS变量)\n const dropdownStyle = dropdown.style;\n if (this.options.iconColor) dropdownStyle.setProperty('--bim-icon-color', this.options.iconColor);\n if (this.options.iconActiveColor) dropdownStyle.setProperty('--bim-icon-active-color', this.options.iconActiveColor);\n if (this.options.textColor) dropdownStyle.setProperty('--bim-btn-text-color', this.options.textColor);\n if (this.options.textActiveColor) dropdownStyle.setProperty('--bim-btn-text-active-color', this.options.textActiveColor);\n if (this.options.btnBackgroundColor) dropdownStyle.setProperty('--bim-btn-bg', this.options.btnBackgroundColor);\n if (this.options.btnHoverColor) dropdownStyle.setProperty('--bim-btn-hover-bg', this.options.btnHoverColor);\n if (this.options.btnActiveColor) dropdownStyle.setProperty('--bim-btn-active-bg', this.options.btnActiveColor);\n\n // 获取按钮的位置信息\n const btnRect = btnEl.getBoundingClientRect();\n const expand = this.options.expand || 'down';\n\n // 根据主按钮组的方向设置下拉菜单的布局方向\n if (this.options.direction === 'row') {\n dropdown.style.flexDirection = 'column'; // 横向按钮组,菜单纵向排列\n } else {\n dropdown.style.flexDirection = 'row'; // 纵向按钮组,菜单横向排列\n }\n\n // 先添加到 DOM 以便计算尺寸\n document.body.appendChild(dropdown);\n\n // 添加事件拦截\n this.setupEventInterception(dropdown);\n\n // 添加菜单项\n button.children.forEach(subBtn => {\n if (this.isVisible(subBtn.id)) {\n const item = this.renderDropdownItem(subBtn);\n dropdown.appendChild(item);\n }\n });\n\n // 获取下拉菜单的实际尺寸\n const dropdownRect = dropdown.getBoundingClientRect();\n\n if (expand === 'up') {\n // 向上展开,与按钮水平居中对齐\n dropdown.style.bottom = (window.innerHeight - btnRect.top + 8) + 'px';\n dropdown.style.left = (btnRect.left + (btnRect.width - dropdownRect.width) / 2) + 'px';\n } else if (expand === 'down') {\n // 向下展开,与按钮水平居中对齐\n dropdown.style.top = (btnRect.bottom + 8) + 'px';\n dropdown.style.left = (btnRect.left + (btnRect.width - dropdownRect.width) / 2) + 'px';\n } else if (expand === 'right') {\n // 向右展开,与按钮垂直居中对齐\n dropdown.style.top = (btnRect.top + (btnRect.height - dropdownRect.height) / 2) + 'px';\n dropdown.style.left = (btnRect.right + 8) + 'px';\n } else if (expand === 'left') {\n // 向左展开,与按钮垂直居中对齐\n dropdown.style.top = (btnRect.top + (btnRect.height - dropdownRect.height) / 2) + 'px';\n dropdown.style.right = (window.innerWidth - btnRect.left + 8) + 'px';\n }\n\n dropdown.addEventListener('mouseenter', () => { if (this.hoverTimeout) clearTimeout(this.hoverTimeout); });\n dropdown.addEventListener('mouseleave', () => this.handleMouseLeave());\n this.dropdownElement = dropdown;\n }\n\n private renderDropdownItem(button: OptButton): HTMLElement {\n const item = document.createElement('div');\n item.className = 'opt-btn-dropdown-item';\n\n // 应用按钮的 align 设置,默认为 horizontal(图标在左)\n const align = button.align || 'horizontal';\n if (align === 'horizontal') {\n item.classList.add('align-horizontal');\n } else {\n item.classList.add('align-vertical');\n }\n\n // 二级菜单项的 active 状态渲染(修复 keepActive 在二级按钮“看起来不生效”的问题)\n // 说明:\n // - keepActive 的状态会记录在 activeBtnIds / button.isActive 上\n // - 下拉菜单每次打开都会重新渲染,因此必须在这里同步一次 active 样式\n if (this.activeBtnIds.has(button.id) || button.isActive) {\n item.classList.add('active');\n }\n\n // 应用按钮的自定义样式\n const iconSize = button.iconSize || 32; // 二级菜单默认图标更小\n const minWidth = button.minWidth; // 不设置默认值,让下拉菜单项保持紧凑\n if (minWidth) {\n item.style.minWidth = `${minWidth}px`;\n }\n\n const icon = document.createElement('div');\n icon.className = 'opt-btn-icon';\n icon.style.width = `${iconSize}px`;\n icon.style.height = `${iconSize}px`;\n icon.innerHTML = this.getIcon(button.icon);\n item.appendChild(icon);\n\n // 只有在 showLabel 为 true 时才显示 label\n if (this.options.showLabel && button.label) {\n const label = document.createElement('span');\n label.className = 'opt-btn-dropdown-label';\n label.textContent = t(button.label);\n item.appendChild(label);\n } else if (button.label) {\n // 当不显示 label 时,添加 title 属性作为 tooltip\n item.title = t(button.label);\n }\n\n item.addEventListener('click', (e) => { e.stopPropagation(); this.handleClick(button); });\n return item;\n }\n\n private closeDropdown(): void {\n if (this.dropdownElement) {\n this.dropdownElement.remove();\n this.dropdownElement = null;\n }\n this.btnRefs.forEach(btnEl => {\n const arrow = btnEl.querySelector('.opt-btn-arrow');\n if (arrow) arrow.classList.remove('rotated');\n });\n }\n\n private updateButtonState(buttonId: string): void {\n const btnEl = this.btnRefs.get(buttonId);\n if (btnEl) {\n if (this.activeBtnIds.has(buttonId)) {\n btnEl.classList.add('active');\n } else {\n btnEl.classList.remove('active');\n }\n }\n }\n\n private getIcon(icon?: string): string { return icon || this.DEFAULT_ICON; }\n\n public updateButtonVisibility(id: string, visible: boolean): void {\n if (!this.options.visibility) this.options.visibility = {};\n this.options.visibility[id] = visible;\n this.render();\n }\n\n public setShowLabel(show: boolean): void {\n this.options.showLabel = show;\n this.updateLabelsVisibility();\n }\n\n private updateLabelsVisibility(): void {\n this.btnRefs.forEach((btnEl, buttonId) => {\n // 查找按钮配置\n const button = this.findButtonById(buttonId);\n if (!button) return;\n\n const hasLabel = this.options.showLabel && button.label;\n\n // 更新 no-label 类和 title 属性\n if (hasLabel) {\n btnEl.classList.remove('no-label');\n // 显示标签时,移除 title(避免重复显示)\n btnEl.removeAttribute('title');\n } else {\n btnEl.classList.add('no-label');\n // 隐藏标签时,添加 title 作为 tooltip\n if (button.label) {\n btnEl.title = t(button.label);\n }\n }\n });\n }\n\n private findButtonById(id: string): OptButton | undefined {\n for (const group of this.groups) {\n const found = this.findButton(group.buttons, id);\n if (found) return found;\n }\n return undefined;\n }\n\n public setBackgroundColor(color: string): void { this.setColors({ backgroundColor: color }); }\n private isVisible(id: string): boolean { return this.options.visibility?.[id] !== false; }\n\n public destroy(): void {\n if (this.unsubscribeLocale) {\n this.unsubscribeLocale();\n this.unsubscribeLocale = null;\n }\n if (this.unsubscribeTheme) {\n this.unsubscribeTheme();\n this.unsubscribeTheme = null;\n }\n this.closeDropdown();\n this.container.innerHTML = '';\n this.btnRefs.clear();\n }\n}\n","import { BimButtonGroup } from '../index';\n\n/**\n * 底部工具栏 (Toolbar)\n * BimButtonGroup 的子类,专门用于加载工具栏默认按钮。\n */\nexport class Toolbar extends BimButtonGroup {\n /**\n * 重写初始化,加载默认按钮\n */\n public async init(): Promise