gl-draw 0.9.0-beta.113 → 0.9.0-beta.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/worker/geo.js +125 -125
  2. package/package.json +1 -1
@@ -1,12 +1,12 @@
1
- var gA=Object.defineProperty,_A=Object.defineProperties;var xA=Object.getOwnPropertyDescriptors;var Vl=Object.getOwnPropertySymbols;var w0=Object.prototype.hasOwnProperty,E0=Object.prototype.propertyIsEnumerable;var us=Math.pow,b0=(ot,At,xt)=>At in ot?gA(ot,At,{enumerable:!0,configurable:!0,writable:!0,value:xt}):ot[At]=xt,Wl=(ot,At)=>{for(var xt in At||(At={}))w0.call(At,xt)&&b0(ot,xt,At[xt]);if(Vl)for(var xt of Vl(At))E0.call(At,xt)&&b0(ot,xt,At[xt]);return ot},A0=(ot,At)=>_A(ot,xA(At));var T0=(ot,At)=>{var xt={};for(var Jt in ot)w0.call(ot,Jt)&&At.indexOf(Jt)<0&&(xt[Jt]=ot[Jt]);if(ot!=null&&Vl)for(var Jt of Vl(ot))At.indexOf(Jt)<0&&E0.call(ot,Jt)&&(xt[Jt]=ot[Jt]);return xt};var fs=(ot,At,xt)=>new Promise((Jt,dr)=>{var va=Mn=>{try{ds(xt.next(Mn))}catch(pr){dr(pr)}},Xl=Mn=>{try{ds(xt.throw(Mn))}catch(pr){dr(pr)}},ds=Mn=>Mn.done?Jt(Mn.value):Promise.resolve(Mn.value).then(va,Xl);ds((xt=xt.apply(ot,At)).next())});(function(){"use strict";/**
1
+ var _A=Object.defineProperty,xA=Object.defineProperties;var yA=Object.getOwnPropertyDescriptors;var Vl=Object.getOwnPropertySymbols;var E0=Object.prototype.hasOwnProperty,A0=Object.prototype.propertyIsEnumerable;var us=Math.pow,w0=(ot,At,xt)=>At in ot?_A(ot,At,{enumerable:!0,configurable:!0,writable:!0,value:xt}):ot[At]=xt,Wl=(ot,At)=>{for(var xt in At||(At={}))E0.call(At,xt)&&w0(ot,xt,At[xt]);if(Vl)for(var xt of Vl(At))A0.call(At,xt)&&w0(ot,xt,At[xt]);return ot},T0=(ot,At)=>xA(ot,yA(At));var R0=(ot,At)=>{var xt={};for(var Jt in ot)E0.call(ot,Jt)&&At.indexOf(Jt)<0&&(xt[Jt]=ot[Jt]);if(ot!=null&&Vl)for(var Jt of Vl(ot))At.indexOf(Jt)<0&&A0.call(ot,Jt)&&(xt[Jt]=ot[Jt]);return xt};var fs=(ot,At,xt)=>new Promise((Jt,dr)=>{var va=Mn=>{try{ds(xt.next(Mn))}catch(pr){dr(pr)}},Xl=Mn=>{try{ds(xt.throw(Mn))}catch(pr){dr(pr)}},ds=Mn=>Mn.done?Jt(Mn.value):Promise.resolve(Mn.value).then(va,Xl);ds((xt=xt.apply(ot,At)).next())});(function(){"use strict";/**
2
2
  * @license
3
3
  * Copyright 2010-2023 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
- */const ot="154",At={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},xt={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Jt=0,dr=1,va=2,Xl=3,ds=0,Mn=1,pr=2,Dn=3,Xn=0,kt=1,Nn=2,C0=2,qn=0,Ui=1,ql=2,$l=3,Yl=4,Ju=5,Di=100,Ku=101,ju=102,Zl=103,Jl=104,Qu=200,ef=201,tf=202,nf=203,Kl=204,jl=205,rf=206,sf=207,af=208,of=209,lf=210,cf=0,hf=1,uf=2,Ma=3,ff=4,df=5,pf=6,mf=7,ps=0,gf=1,_f=2,Fn=0,xf=1,yf=2,vf=3,Mf=4,Sf=5,Sa=300,pi=301,mi=302,ms=303,gs=304,mr=306,_s=1e3,Dt=1001,xs=1002,yt=1003,ba=1004,P0=1004,ys=1005,L0=1005,vt=1006,Ql=1007,I0=1007,gi=1008,U0=1008,$n=1009,bf=1010,wf=1011,wa=1012,ec=1013,Yn=1014,On=1015,gr=1016,tc=1017,nc=1018,_i=1020,Ef=1021,an=1023,Af=1024,Tf=1025,xi=1026,Ni=1027,Rf=1028,ic=1029,Cf=1030,rc=1031,sc=1033,Ea=33776,Aa=33777,Ta=33778,Ra=33779,ac=35840,oc=35841,lc=35842,cc=35843,Pf=36196,hc=37492,uc=37496,fc=37808,dc=37809,pc=37810,mc=37811,gc=37812,_c=37813,xc=37814,yc=37815,vc=37816,Mc=37817,Sc=37818,bc=37819,wc=37820,Ec=37821,Ca=36492,Lf=36283,Ac=36284,Tc=36285,Rc=36286,If=2200,Uf=2201,Df=2202,vs=2300,Ms=2301,Pa=2302,Fi=2400,Oi=2401,Ss=2402,La=2500,Cc=2501,D0=0,N0=1,F0=2,Pc=3e3,yi=3001,Nf=3200,Ff=3201,vi=0,Of=1,Mi="",Ge="srgb",Sn="srgb-linear",Lc="display-p3",O0=0,Ia=7680,B0=7681,z0=7682,k0=7683,G0=34055,H0=34056,V0=5386,W0=512,X0=513,q0=514,$0=515,Y0=516,Z0=517,J0=518,Bf=519,zf=512,kf=513,Gf=514,Hf=515,Vf=516,Wf=517,Xf=518,qf=519,bs=35044,K0=35048,j0=35040,Q0=35045,e_=35049,t_=35041,n_=35046,i_=35050,r_=35042,s_="100",Ic="300 es",Ua=1035,Bn=2e3,ws=2001;class Zn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const Nt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let $f=1234567;const Bi=Math.PI/180,_r=180/Math.PI;function on(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Nt[r&255]+Nt[r>>8&255]+Nt[r>>16&255]+Nt[r>>24&255]+"-"+Nt[e&255]+Nt[e>>8&255]+"-"+Nt[e>>16&15|64]+Nt[e>>24&255]+"-"+Nt[t&63|128]+Nt[t>>8&255]+"-"+Nt[t>>16&255]+Nt[t>>24&255]+Nt[n&255]+Nt[n>>8&255]+Nt[n>>16&255]+Nt[n>>24&255]).toLowerCase()}function ft(r,e,t){return Math.max(e,Math.min(t,r))}function Uc(r,e){return(r%e+e)%e}function a_(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function o_(r,e,t){return r!==e?(t-r)/(e-r):0}function Es(r,e,t){return(1-t)*r+t*e}function l_(r,e,t,n){return Es(r,e,1-Math.exp(-t*n))}function c_(r,e=1){return e-Math.abs(Uc(r,e*2)-e)}function h_(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function u_(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function f_(r,e){return r+Math.floor(Math.random()*(e-r+1))}function d_(r,e){return r+Math.random()*(e-r)}function p_(r){return r*(.5-Math.random())}function m_(r){r!==void 0&&($f=r);let e=$f+=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 g_(r){return r*Bi}function __(r){return r*_r}function Dc(r){return(r&r-1)===0&&r!==0}function Yf(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Da(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function x_(r,e,t,n,i){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+n)/2),h=a((e+n)/2),u=s((e-n)/2),f=a((e-n)/2),d=s((n-e)/2),p=a((n-e)/2);switch(i){case"XYX":r.set(o*h,l*u,l*f,o*c);break;case"YZY":r.set(l*f,o*h,l*u,o*c);break;case"ZXZ":r.set(l*u,l*f,o*h,o*c);break;case"XZX":r.set(o*h,l*p,l*d,o*c);break;case"YXY":r.set(l*d,o*h,l*p,o*c);break;case"ZYZ":r.set(l*p,l*d,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function ln(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function We(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const y_={DEG2RAD:Bi,RAD2DEG:_r,generateUUID:on,clamp:ft,euclideanModulo:Uc,mapLinear:a_,inverseLerp:o_,lerp:Es,damp:l_,pingpong:c_,smoothstep:h_,smootherstep:u_,randInt:f_,randFloat:d_,randFloatSpread:p_,seededRandom:m_,degToRad:g_,radToDeg:__,isPowerOfTwo:Dc,ceilPowerOfTwo:Yf,floorPowerOfTwo:Da,setQuaternionFromProperEuler:x_,normalize:We,denormalize:ln};class q{constructor(e=0,t=0){q.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,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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 n=this.dot(e)/t;return Math.acos(ft(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*i+e.x,this.y=s*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xe{constructor(e,t,n,i,s,a,o,l,c){Xe.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,l,c)}set(e,t,n,i,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=n,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,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],f=n[2],d=n[5],p=n[8],_=i[0],g=i[3],m=i[6],y=i[1],x=i[4],v=i[7],M=i[2],w=i[5],A=i[8];return s[0]=a*_+o*y+l*M,s[3]=a*g+o*x+l*w,s[6]=a*m+o*v+l*A,s[1]=c*_+h*y+u*M,s[4]=c*g+h*x+u*w,s[7]=c*m+h*v+u*A,s[2]=f*_+d*y+p*M,s[5]=f*g+d*x+p*w,s[8]=f*m+d*v+p*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],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*s*h+n*o*l+i*s*c-i*a*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,f=o*l-h*s,d=c*s-a*l,p=t*u+n*f+i*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/p;return e[0]=u*_,e[1]=(i*c-h*n)*_,e[2]=(o*n-i*a)*_,e[3]=f*_,e[4]=(h*t-i*l)*_,e[5]=(i*s-o*t)*_,e[6]=d*_,e[7]=(n*l-c*t)*_,e[8]=(a*t-n*s)*_,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,n,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Nc.makeScale(e,t)),this}rotate(e){return this.premultiply(Nc.makeRotation(-e)),this}translate(e,t){return this.premultiply(Nc.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),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Nc=new Xe;function Zf(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}const v_={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function xr(r,e){return new v_[r](e)}function As(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const Jf={};function Ts(r){r in Jf||(Jf[r]=!0,console.warn(r))}function yr(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Fc(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}const M_=new Xe().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),S_=new Xe().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function b_(r){return r.convertSRGBToLinear().applyMatrix3(S_)}function w_(r){return r.applyMatrix3(M_).convertLinearToSRGB()}const E_={[Sn]:r=>r,[Ge]:r=>r.convertSRGBToLinear(),[Lc]:b_},A_={[Sn]:r=>r,[Ge]:r=>r.convertLinearToSRGB(),[Lc]:w_},gn={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(r){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!r},get workingColorSpace(){return Sn},set workingColorSpace(r){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(r,e,t){if(this.enabled===!1||e===t||!e||!t)return r;const n=E_[e],i=A_[t];if(n===void 0||i===void 0)throw new Error(`Unsupported color space conversion, "${e}" to "${t}".`);return i(n(r))},fromWorkingColorSpace:function(r,e){return this.convert(r,this.workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this.workingColorSpace)}};let vr;class Oc{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement=="undefined")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{vr===void 0&&(vr=As("canvas")),vr.width=e.width,vr.height=e.height;const n=vr.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=vr}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){const t=As("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=yr(s[a]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(yr(t[n]/255)*255):t[n]=yr(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let T_=0;class zi{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:T_++}),this.uuid=on(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(Bc(i[a].image)):s.push(Bc(i[a]))}else s=Bc(i);n.url=s}return t||(e.images[this.uuid]=n),n}}function Bc(r){return typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&r instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&r instanceof ImageBitmap?Oc.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let R_=0;class Mt extends Zn{constructor(e=Mt.DEFAULT_IMAGE,t=Mt.DEFAULT_MAPPING,n=Dt,i=Dt,s=vt,a=gi,o=an,l=$n,c=Mt.DEFAULT_ANISOTROPY,h=Mi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:R_++}),this.uuid=on(),this.name="",this.source=new zi(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new q(0,0),this.repeat=new q(1,1),this.center=new q(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Xe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof h=="string"?this.colorSpace=h:(Ts("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===yi?Ge:Mi),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}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)}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.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Sa)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case _s:e.x=e.x-Math.floor(e.x);break;case Dt:e.x=e.x<0?0:1;break;case xs: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 _s:e.y=e.y-Math.floor(e.y);break;case Dt:e.y=e.y<0?0:1;break;case xs: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)}get encoding(){return Ts("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Ge?yi:Pc}set encoding(e){Ts("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===yi?Ge:Mi}}Mt.DEFAULT_IMAGE=null,Mt.DEFAULT_MAPPING=Sa,Mt.DEFAULT_ANISOTROPY=1;class rt{constructor(e=0,t=0,n=0,i=1){rt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw 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,n=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*s,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,n,i,s;const l=e.elements,c=l[0],h=l[4],u=l[8],f=l[1],d=l[5],p=l[9],_=l[2],g=l[6],m=l[10];if(Math.abs(h-f)<.01&&Math.abs(u-_)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+f)<.1&&Math.abs(u+_)<.1&&Math.abs(p+g)<.1&&Math.abs(c+d+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const x=(c+1)/2,v=(d+1)/2,M=(m+1)/2,w=(h+f)/4,A=(u+_)/4,C=(p+g)/4;return x>v&&x>M?x<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(x),i=w/n,s=A/n):v>M?v<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(v),n=w/i,s=C/i):M<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(M),n=A/s,i=C/s),this.set(n,i,s,t),this}let y=Math.sqrt((g-p)*(g-p)+(u-_)*(u-_)+(f-h)*(f-h));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(u-_)/y,this.z=(f-h)/y,this.w=Math.acos((c+d+m-1)/2),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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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 bn extends Zn{constructor(e=1,t=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new rt(0,0,e,t),this.scissorTest=!1,this.viewport=new rt(0,0,e,t);const i={width:e,height:t,depth:1};n.encoding!==void 0&&(Ts("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===yi?Ge:Mi),this.texture=new Mt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:vt,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,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.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new zi(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Na extends Mt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=yt,this.minFilter=yt,this.wrapR=Dt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class C_ extends bn{constructor(e=1,t=1,n=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Na(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class zc extends Mt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=yt,this.minFilter=yt,this.wrapR=Dt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class P_ extends bn{constructor(e=1,t=1,n=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new zc(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class L_ extends bn{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let a=0;a<n;a++)this.texture[a]=s.clone(),this.texture[a].isRenderTargetTexture=!0}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,s=this.texture.length;i<s;i++)this.texture[i].image.width=e,this.texture[i].image.height=t,this.texture[i].image.depth=n;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),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.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.texture.length=0;for(let t=0,n=e.texture.length;t<n;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}}class Kt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,a,o){let l=n[i+0],c=n[i+1],h=n[i+2],u=n[i+3];const f=s[a+0],d=s[a+1],p=s[a+2],_=s[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]=f,e[t+1]=d,e[t+2]=p,e[t+3]=_;return}if(u!==_||l!==f||c!==d||h!==p){let g=1-o;const m=l*f+c*d+h*p+u*_,y=m>=0?1:-1,x=1-m*m;if(x>Number.EPSILON){const M=Math.sqrt(x),w=Math.atan2(M,m*y);g=Math.sin(g*w)/M,o=Math.sin(o*w)/M}const v=o*y;if(l=l*g+f*v,c=c*g+d*v,h=h*g+p*v,u=u*g+_*v,g===1-o){const M=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=M,c*=M,h*=M,u*=M}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[a],f=s[a+1],d=s[a+2],p=s[a+3];return e[t]=o*p+h*u+l*d-c*f,e[t+1]=l*p+h*f+c*u-o*d,e[t+2]=c*p+h*d+o*f-l*u,e[t+3]=h*p-o*u-l*f-c*d,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,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(i/2),u=o(s/2),f=l(n/2),d=l(i/2),p=l(s/2);switch(a){case"XYZ":this._x=f*h*u+c*d*p,this._y=c*d*u-f*h*p,this._z=c*h*p+f*d*u,this._w=c*h*u-f*d*p;break;case"YXZ":this._x=f*h*u+c*d*p,this._y=c*d*u-f*h*p,this._z=c*h*p-f*d*u,this._w=c*h*u+f*d*p;break;case"ZXY":this._x=f*h*u-c*d*p,this._y=c*d*u+f*h*p,this._z=c*h*p+f*d*u,this._w=c*h*u-f*d*p;break;case"ZYX":this._x=f*h*u-c*d*p,this._y=c*d*u+f*h*p,this._z=c*h*p-f*d*u,this._w=c*h*u+f*d*p;break;case"YZX":this._x=f*h*u+c*d*p,this._y=c*d*u+f*h*p,this._z=c*h*p-f*d*u,this._w=c*h*u-f*d*p;break;case"XZY":this._x=f*h*u-c*d*p,this._y=c*d*u-f*h*p,this._z=c*h*p+f*d*u,this._w=c*h*u+f*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],u=t[10],f=n+o+u;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(h-l)*d,this._y=(s-c)*d,this._z=(a-i)*d}else if(n>o&&n>u){const d=2*Math.sqrt(1+n-o-u);this._w=(h-l)/d,this._x=.25*d,this._y=(i+a)/d,this._z=(s+c)/d}else if(o>u){const d=2*Math.sqrt(1+o-n-u);this._w=(s-c)/d,this._x=(i+a)/d,this._y=.25*d,this._z=(l+h)/d}else{const d=2*Math.sqrt(1+u-n-o);this._w=(a-i)/d,this._x=(s+c)/d,this._y=(l+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ft(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 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 n=e._x,i=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+i*c-s*l,this._y=i*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-i*o,this._w=a*h-n*o-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const d=1-t;return this._w=d*a+t*this._w,this._x=d*n+t*this._x,this._y=d*i+t*this._y,this._z=d*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-t)*h)/c,f=Math.sin(t*h)/c;return this._w=a*u+this._w*f,this._x=n*u+this._x*f,this._y=i*u+this._y*f,this._z=s*u+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}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}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 R{constructor(e=0,t=0,n=0){R.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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(Kf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Kf.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=l*t+a*i-o*n,h=l*n+o*t-s*i,u=l*i+s*n-a*t,f=-s*t-a*n-o*i;return this.x=c*l+f*-s+h*-o-u*-a,this.y=h*l+f*-a+u*-s-c*-o,this.z=u*l+f*-o+c*-a-h*-s,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,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-s*o,this.y=s*a-n*l,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return kc.copy(this).projectOnVector(e),this.sub(kc)}reflect(e){return this.sub(kc.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 n=this.dot(e)/t;return Math.acos(ft(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-us(e,2));return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const kc=new R,Kf=new Kt;class _n{constructor(e=new R(1/0,1/0,1/0),t=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Kn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Kn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Kn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){if(e.updateWorldMatrix(!1,!1),e.boundingBox!==void 0)e.boundingBox===null&&e.computeBoundingBox(),Mr.copy(e.boundingBox),Mr.applyMatrix4(e.matrixWorld),this.union(Mr);else{const i=e.geometry;if(i!==void 0)if(t&&i.attributes!==void 0&&i.attributes.position!==void 0){const s=i.attributes.position;for(let a=0,o=s.count;a<o;a++)Kn.fromBufferAttribute(s,a).applyMatrix4(e.matrixWorld),this.expandByPoint(Kn)}else i.boundingBox===null&&i.computeBoundingBox(),Mr.copy(i.boundingBox),Mr.applyMatrix4(e.matrixWorld),this.union(Mr)}const n=e.children;for(let i=0,s=n.length;i<s;i++)this.expandByObject(n[i],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Kn),Kn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Rs),Fa.subVectors(this.max,Rs),Sr.subVectors(e.a,Rs),br.subVectors(e.b,Rs),wr.subVectors(e.c,Rs),Si.subVectors(br,Sr),bi.subVectors(wr,br),ki.subVectors(Sr,wr);let t=[0,-Si.z,Si.y,0,-bi.z,bi.y,0,-ki.z,ki.y,Si.z,0,-Si.x,bi.z,0,-bi.x,ki.z,0,-ki.x,-Si.y,Si.x,0,-bi.y,bi.x,0,-ki.y,ki.x,0];return!Gc(t,Sr,br,wr,Fa)||(t=[1,0,0,0,1,0,0,0,1],!Gc(t,Sr,br,wr,Fa))?!1:(Oa.crossVectors(Si,bi),t=[Oa.x,Oa.y,Oa.z],Gc(t,Sr,br,wr,Fa))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Kn).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:(Jn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Jn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Jn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Jn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Jn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Jn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Jn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Jn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Jn),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)}}const Jn=[new R,new R,new R,new R,new R,new R,new R,new R],Kn=new R,Mr=new _n,Sr=new R,br=new R,wr=new R,Si=new R,bi=new R,ki=new R,Rs=new R,Fa=new R,Oa=new R,Gi=new R;function Gc(r,e,t,n,i){for(let s=0,a=r.length-3;s<=a;s+=3){Gi.fromArray(r,s);const o=i.x*Math.abs(Gi.x)+i.y*Math.abs(Gi.y)+i.z*Math.abs(Gi.z),l=e.dot(Gi),c=t.dot(Gi),h=n.dot(Gi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const I_=new _n,Cs=new R,Hc=new R;class wn{constructor(e=new R,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):I_.setFromPoints(e).getCenter(n);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(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;Cs.subVectors(e,this.center);const t=Cs.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Cs,i/n),this.radius+=i}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):(Hc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Cs.copy(e.center).add(Hc)),this.expandByPoint(Cs.copy(e.center).sub(Hc))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const jn=new R,Vc=new R,Ba=new R,wi=new R,Wc=new R,za=new R,Xc=new R;class Er{constructor(e=new R,t=new R(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,jn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=jn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(jn.copy(this.origin).addScaledVector(this.direction,t),jn.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Vc.copy(e).add(t).multiplyScalar(.5),Ba.copy(t).sub(e).normalize(),wi.copy(this.origin).sub(Vc);const s=e.distanceTo(t)*.5,a=-this.direction.dot(Ba),o=wi.dot(this.direction),l=-wi.dot(Ba),c=wi.lengthSq(),h=Math.abs(1-a*a);let u,f,d,p;if(h>0)if(u=a*l-o,f=a*o-l,p=s*h,u>=0)if(f>=-p)if(f<=p){const _=1/h;u*=_,f*=_,d=u*(u+a*f+2*o)+f*(a*u+f+2*l)+c}else f=s,u=Math.max(0,-(a*f+o)),d=-u*u+f*(f+2*l)+c;else f=-s,u=Math.max(0,-(a*f+o)),d=-u*u+f*(f+2*l)+c;else f<=-p?(u=Math.max(0,-(-a*s+o)),f=u>0?-s:Math.min(Math.max(-s,-l),s),d=-u*u+f*(f+2*l)+c):f<=p?(u=0,f=Math.min(Math.max(-s,-l),s),d=f*(f+2*l)+c):(u=Math.max(0,-(a*s+o)),f=u>0?s:Math.min(Math.max(-s,-l),s),d=-u*u+f*(f+2*l)+c);else f=a>0?-s:s,u=Math.max(0,-(a*f+o)),d=-u*u+f*(f+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Vc).addScaledVector(Ba,f),d}intersectSphere(e,t){jn.subVectors(e.center,this.origin);const n=jn.dot(this.direction),i=jn.dot(jn)-n*n,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return 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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,f=this.origin;return c>=0?(n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c):(n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c),h>=0?(s=(e.min.y-f.y)*h,a=(e.max.y-f.y)*h):(s=(e.max.y-f.y)*h,a=(e.min.y-f.y)*h),n>a||s>i||((s>n||isNaN(n))&&(n=s),(a<i||isNaN(i))&&(i=a),u>=0?(o=(e.min.z-f.z)*u,l=(e.max.z-f.z)*u):(o=(e.max.z-f.z)*u,l=(e.min.z-f.z)*u),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,jn)!==null}intersectTriangle(e,t,n,i,s){Wc.subVectors(t,e),za.subVectors(n,e),Xc.crossVectors(Wc,za);let a=this.direction.dot(Xc),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;wi.subVectors(this.origin,e);const l=o*this.direction.dot(za.crossVectors(wi,za));if(l<0)return null;const c=o*this.direction.dot(Wc.cross(wi));if(c<0||l+c>a)return null;const h=-o*wi.dot(Xc);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Be{constructor(e,t,n,i,s,a,o,l,c,h,u,f,d,p,_,g){Be.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,n,i,s,a,o,l,c,h,u,f,d,p,_,g)}set(e,t,n,i,s,a,o,l,c,h,u,f,d,p,_,g){const m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=s,m[5]=a,m[9]=o,m[13]=l,m[2]=c,m[6]=h,m[10]=u,m[14]=f,m[3]=d,m[7]=p,m[11]=_,m[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Be().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Ar.setFromMatrixColumn(e,0).length(),s=1/Ar.setFromMatrixColumn(e,1).length(),a=1/Ar.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const f=a*h,d=a*u,p=o*h,_=o*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=d+p*c,t[5]=f-_*c,t[9]=-o*l,t[2]=_-f*c,t[6]=p+d*c,t[10]=a*l}else if(e.order==="YXZ"){const f=l*h,d=l*u,p=c*h,_=c*u;t[0]=f+_*o,t[4]=p*o-d,t[8]=a*c,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=d*o-p,t[6]=_+f*o,t[10]=a*l}else if(e.order==="ZXY"){const f=l*h,d=l*u,p=c*h,_=c*u;t[0]=f-_*o,t[4]=-a*u,t[8]=p+d*o,t[1]=d+p*o,t[5]=a*h,t[9]=_-f*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const f=a*h,d=a*u,p=o*h,_=o*u;t[0]=l*h,t[4]=p*c-d,t[8]=f*c+_,t[1]=l*u,t[5]=_*c+f,t[9]=d*c-p,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const f=a*l,d=a*c,p=o*l,_=o*c;t[0]=l*h,t[4]=_-f*u,t[8]=p*u+d,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=d*u+p,t[10]=f-_*u}else if(e.order==="XZY"){const f=a*l,d=a*c,p=o*l,_=o*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=f*u+_,t[5]=a*h,t[9]=d*u-p,t[2]=p*u-d,t[6]=o*h,t[10]=_*u+f}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(U_,e,D_)}lookAt(e,t,n){const i=this.elements;return cn.subVectors(e,t),cn.lengthSq()===0&&(cn.z=1),cn.normalize(),Ei.crossVectors(n,cn),Ei.lengthSq()===0&&(Math.abs(n.z)===1?cn.x+=1e-4:cn.z+=1e-4,cn.normalize(),Ei.crossVectors(n,cn)),Ei.normalize(),ka.crossVectors(cn,Ei),i[0]=Ei.x,i[4]=ka.x,i[8]=cn.x,i[1]=Ei.y,i[5]=ka.y,i[9]=cn.y,i[2]=Ei.z,i[6]=ka.z,i[10]=cn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],f=n[9],d=n[13],p=n[2],_=n[6],g=n[10],m=n[14],y=n[3],x=n[7],v=n[11],M=n[15],w=i[0],A=i[4],C=i[8],S=i[12],b=i[1],L=i[5],k=i[9],U=i[13],N=i[2],I=i[6],B=i[10],O=i[14],H=i[3],X=i[7],ee=i[11],z=i[15];return s[0]=a*w+o*b+l*N+c*H,s[4]=a*A+o*L+l*I+c*X,s[8]=a*C+o*k+l*B+c*ee,s[12]=a*S+o*U+l*O+c*z,s[1]=h*w+u*b+f*N+d*H,s[5]=h*A+u*L+f*I+d*X,s[9]=h*C+u*k+f*B+d*ee,s[13]=h*S+u*U+f*O+d*z,s[2]=p*w+_*b+g*N+m*H,s[6]=p*A+_*L+g*I+m*X,s[10]=p*C+_*k+g*B+m*ee,s[14]=p*S+_*U+g*O+m*z,s[3]=y*w+x*b+v*N+M*H,s[7]=y*A+x*L+v*I+M*X,s[11]=y*C+x*k+v*B+M*ee,s[15]=y*S+x*U+v*O+M*z,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],n=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],u=e[6],f=e[10],d=e[14],p=e[3],_=e[7],g=e[11],m=e[15];return p*(+s*l*u-i*c*u-s*o*f+n*c*f+i*o*d-n*l*d)+_*(+t*l*d-t*c*f+s*a*f-i*a*d+i*c*h-s*l*h)+g*(+t*c*u-t*o*d-s*a*u+n*a*d+s*o*h-n*c*h)+m*(-i*o*h-t*l*u+t*o*f+i*a*u-n*a*f+n*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,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],f=e[10],d=e[11],p=e[12],_=e[13],g=e[14],m=e[15],y=u*g*c-_*f*c+_*l*d-o*g*d-u*l*m+o*f*m,x=p*f*c-h*g*c-p*l*d+a*g*d+h*l*m-a*f*m,v=h*_*c-p*u*c+p*o*d-a*_*d-h*o*m+a*u*m,M=p*u*l-h*_*l-p*o*f+a*_*f+h*o*g-a*u*g,w=t*y+n*x+i*v+s*M;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/w;return e[0]=y*A,e[1]=(_*f*s-u*g*s-_*i*d+n*g*d+u*i*m-n*f*m)*A,e[2]=(o*g*s-_*l*s+_*i*c-n*g*c-o*i*m+n*l*m)*A,e[3]=(u*l*s-o*f*s-u*i*c+n*f*c+o*i*d-n*l*d)*A,e[4]=x*A,e[5]=(h*g*s-p*f*s+p*i*d-t*g*d-h*i*m+t*f*m)*A,e[6]=(p*l*s-a*g*s-p*i*c+t*g*c+a*i*m-t*l*m)*A,e[7]=(a*f*s-h*l*s+h*i*c-t*f*c-a*i*d+t*l*d)*A,e[8]=v*A,e[9]=(p*u*s-h*_*s-p*n*d+t*_*d+h*n*m-t*u*m)*A,e[10]=(a*_*s-p*o*s+p*n*c-t*_*c-a*n*m+t*o*m)*A,e[11]=(h*o*s-a*u*s-h*n*c+t*u*c+a*n*d-t*o*d)*A,e[12]=M*A,e[13]=(h*_*i-p*u*i+p*n*f-t*_*f-h*n*g+t*u*g)*A,e[14]=(p*o*i-a*_*i-p*n*l+t*_*l+a*n*g-t*o*g)*A,e[15]=(a*u*i-h*o*i+h*n*l-t*u*l-a*n*f+t*o*f)*A,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,h*o+n,h*l-i*a,0,c*l-i*o,h*l+i*a,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,a){return this.set(1,n,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,u=o+o,f=s*c,d=s*h,p=s*u,_=a*h,g=a*u,m=o*u,y=l*c,x=l*h,v=l*u,M=n.x,w=n.y,A=n.z;return i[0]=(1-(_+m))*M,i[1]=(d+v)*M,i[2]=(p-x)*M,i[3]=0,i[4]=(d-v)*w,i[5]=(1-(f+m))*w,i[6]=(g+y)*w,i[7]=0,i[8]=(p+x)*A,i[9]=(g-y)*A,i[10]=(1-(f+_))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=Ar.set(i[0],i[1],i[2]).length();const a=Ar.set(i[4],i[5],i[6]).length(),o=Ar.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],En.copy(this);const c=1/s,h=1/a,u=1/o;return En.elements[0]*=c,En.elements[1]*=c,En.elements[2]*=c,En.elements[4]*=h,En.elements[5]*=h,En.elements[6]*=h,En.elements[8]*=u,En.elements[9]*=u,En.elements[10]*=u,t.setFromRotationMatrix(En),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=Bn){const l=this.elements,c=2*s/(t-e),h=2*s/(n-i),u=(t+e)/(t-e),f=(n+i)/(n-i);let d,p;if(o===Bn)d=-(a+s)/(a-s),p=-2*a*s/(a-s);else if(o===ws)d=-a/(a-s),p=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=d,l[14]=p,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=Bn){const l=this.elements,c=1/(t-e),h=1/(n-i),u=1/(a-s),f=(t+e)*c,d=(n+i)*h;let p,_;if(o===Bn)p=(a+s)*u,_=-2*u;else if(o===ws)p=s*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-d,l[2]=0,l[6]=0,l[10]=_,l[14]=-p,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ar=new R,En=new Be,U_=new R(0,0,0),D_=new R(1,1,1),Ei=new R,ka=new R,cn=new R,jf=new Be,Qf=new Kt;class Ps{constructor(e=0,t=0,n=0,i=Ps.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],h=i[9],u=i[2],f=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(ft(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(f,c),this._z=0);break;case"YXZ":this._x=Math.asin(-ft(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(ft(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-ft(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(ft(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-ft(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return jf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(jf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Qf.setFromEuler(this),this.setFromQuaternion(Qf,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}}Ps.DEFAULT_ORDER="XYZ";class Ga{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let N_=0;const ed=new R,Tr=new Kt,Qn=new Be,Ha=new R,Ls=new R,F_=new R,O_=new Kt,td=new R(1,0,0),nd=new R(0,1,0),id=new R(0,0,1),B_={type:"added"},rd={type:"removed"};class tt extends Zn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:N_++}),this.uuid=on(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=tt.DEFAULT_UP.clone();const e=new R,t=new Ps,n=new Kt,i=new R(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Be},normalMatrix:{value:new Xe}}),this.matrix=new Be,this.matrixWorld=new Be,this.matrixAutoUpdate=tt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=tt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new Ga,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Tr.setFromAxisAngle(e,t),this.quaternion.multiply(Tr),this}rotateOnWorldAxis(e,t){return Tr.setFromAxisAngle(e,t),this.quaternion.premultiply(Tr),this}rotateX(e){return this.rotateOnAxis(td,e)}rotateY(e){return this.rotateOnAxis(nd,e)}rotateZ(e){return this.rotateOnAxis(id,e)}translateOnAxis(e,t){return ed.copy(e).applyQuaternion(this.quaternion),this.position.add(ed.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(td,e)}translateY(e){return this.translateOnAxis(nd,e)}translateZ(e){return this.translateOnAxis(id,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Qn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ha.copy(e):Ha.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Ls.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Qn.lookAt(Ls,Ha,this.up):Qn.lookAt(Ha,Ls,this.up),this.quaternion.setFromRotationMatrix(Qn),i&&(Qn.extractRotation(i.matrixWorld),Tr.setFromRotationMatrix(Qn),this.quaternion.premultiply(Tr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(B_)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(rd)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(rd)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Qn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Qn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Qn),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t){let n=[];this[e]===t&&n.push(this);for(let i=0,s=this.children.length;i<s;i++){const a=this.children[i].getObjectsByProperty(e,t);a.length>0&&(n=n.concat(a))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,e,F_),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,O_,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++){const s=t[n];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++){const o=i[s];o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(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<h;c++){const u=l[c];s(e.shapes,u)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),u=a(e.shapes),f=a(e.skeletons),d=a(e.animations),p=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),p.length>0&&(n.nodes=p)}return n.object=i,n;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.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}tt.DEFAULT_UP=new R(0,1,0),tt.DEFAULT_MATRIX_AUTO_UPDATE=!0,tt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const An=new R,ei=new R,qc=new R,ti=new R,Rr=new R,Cr=new R,sd=new R,$c=new R,Yc=new R,Zc=new R;let Va=!1;class jt{constructor(e=new R,t=new R,n=new R){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),An.subVectors(e,t),i.cross(An);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){An.subVectors(i,t),ei.subVectors(n,t),qc.subVectors(e,t);const a=An.dot(An),o=An.dot(ei),l=An.dot(qc),c=ei.dot(ei),h=ei.dot(qc),u=a*c-o*o;if(u===0)return s.set(-2,-1,-1);const f=1/u,d=(c*l-o*h)*f,p=(a*h-o*l)*f;return s.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,ti),ti.x>=0&&ti.y>=0&&ti.x+ti.y<=1}static getUV(e,t,n,i,s,a,o,l){return Va===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Va=!0),this.getInterpolation(e,t,n,i,s,a,o,l)}static getInterpolation(e,t,n,i,s,a,o,l){return this.getBarycoord(e,t,n,i,ti),l.setScalar(0),l.addScaledVector(s,ti.x),l.addScaledVector(a,ti.y),l.addScaledVector(o,ti.z),l}static isFrontFacing(e,t,n,i){return An.subVectors(n,t),ei.subVectors(e,t),An.cross(ei).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return An.subVectors(this.c,this.b),ei.subVectors(this.a,this.b),An.cross(ei).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return jt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return jt.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return Va===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Va=!0),jt.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}getInterpolation(e,t,n,i,s){return jt.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return jt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return jt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let a,o;Rr.subVectors(i,n),Cr.subVectors(s,n),$c.subVectors(e,n);const l=Rr.dot($c),c=Cr.dot($c);if(l<=0&&c<=0)return t.copy(n);Yc.subVectors(e,i);const h=Rr.dot(Yc),u=Cr.dot(Yc);if(h>=0&&u<=h)return t.copy(i);const f=l*u-h*c;if(f<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(Rr,a);Zc.subVectors(e,s);const d=Rr.dot(Zc),p=Cr.dot(Zc);if(p>=0&&d<=p)return t.copy(s);const _=d*c-l*p;if(_<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Cr,o);const g=h*p-d*u;if(g<=0&&u-h>=0&&d-p>=0)return sd.subVectors(s,i),o=(u-h)/(u-h+(d-p)),t.copy(i).addScaledVector(sd,o);const m=1/(g+_+f);return a=_*m,o=f*m,t.copy(n).addScaledVector(Rr,a).addScaledVector(Cr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let z_=0;class Ft extends Zn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:z_++}),this.uuid=on(),this.name="",this.type="Material",this.blending=Ui,this.side=Xn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Kl,this.blendDst=jl,this.blendEquation=Di,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Ma,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Bf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ia,this.stencilZFail=Ia,this.stencilZPass=Ia,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ui&&(n.blending=this.blending),this.side!==Xn&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=this.alphaHash),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(n.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=i(e.textures),a=i(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}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.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 n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,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++}}const ad={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},Tn={h:0,s:0,l:0},Wa={h:0,s:0,l:0};function Jc(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}let ye=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ge){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,gn.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=gn.workingColorSpace){return this.r=e,this.g=t,this.b=n,gn.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=gn.workingColorSpace){if(e=Uc(e,1),t=ft(t,0,1),n=ft(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=Jc(a,s,e+1/3),this.g=Jc(a,s,e),this.b=Jc(a,s,e-1/3)}return gn.toWorkingColorSpace(this,i),this}setStyle(e,t=Ge){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ge){const n=ad[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.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=yr(e.r),this.g=yr(e.g),this.b=yr(e.b),this}copyLinearToSRGB(e){return this.r=Fc(e.r),this.g=Fc(e.g),this.b=Fc(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ge){return gn.fromWorkingColorSpace(Ot.copy(this),e),Math.round(ft(Ot.r*255,0,255))*65536+Math.round(ft(Ot.g*255,0,255))*256+Math.round(ft(Ot.b*255,0,255))}getHexString(e=Ge){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=gn.workingColorSpace){gn.fromWorkingColorSpace(Ot.copy(this),t);const n=Ot.r,i=Ot.g,s=Ot.b,a=Math.max(n,i,s),o=Math.min(n,i,s);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 n:l=(i-s)/u+(i<s?6:0);break;case i:l=(s-n)/u+2;break;case s:l=(n-i)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=gn.workingColorSpace){return gn.fromWorkingColorSpace(Ot.copy(this),t),e.r=Ot.r,e.g=Ot.g,e.b=Ot.b,e}getStyle(e=Ge){gn.fromWorkingColorSpace(Ot.copy(this),e);const t=Ot.r,n=Ot.g,i=Ot.b;return e!==Ge?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Tn),Tn.h+=e,Tn.s+=t,Tn.l+=n,this.setHSL(Tn.h,Tn.s,Tn.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Tn),e.getHSL(Wa);const n=Es(Tn.h,Wa.h,t),i=Es(Tn.s,Wa.s,t),s=Es(Tn.l,Wa.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Ot=new ye;ye.NAMES=ad;class Ai extends Ft{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ye(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.combine=ps,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.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 ni=k_();function k_(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const s=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);)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[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:n,shiftTable:i,mantissaTable:s,exponentTable:a,offsetTable:o}}function Qt(r){Math.abs(r)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),r=ft(r,-65504,65504),ni.floatView[0]=r;const e=ni.uint32View[0],t=e>>23&511;return ni.baseTable[t]+((e&8388607)>>ni.shiftTable[t])}function Is(r){const e=r>>10;return ni.uint32View[0]=ni.mantissaTable[ni.offsetTable[e]+(r&1023)]+ni.exponentTable[e],ni.floatView[0]}const G_={toHalfFloat:Qt,fromHalfFloat:Is},wt=new R,Xa=new q;class Ze{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=bs,this.updateRange={offset:0,count:-1},this.gpuType=On,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}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,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Xa.fromBufferAttribute(this,t),Xa.applyMatrix3(e),this.setXY(t,Xa.x,Xa.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.applyMatrix3(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.applyMatrix4(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.applyNormalMatrix(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.transformDirection(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ln(t,this.array)),t}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ln(t,this.array)),t}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=ln(t,this.array)),t}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=ln(t,this.array)),t}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array),s=We(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==bs&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}}class H_ extends Ze{constructor(e,t,n){super(new Int8Array(e),t,n)}}class V_ extends Ze{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class W_ extends Ze{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class X_ extends Ze{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Kc extends Ze{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class q_ extends Ze{constructor(e,t,n){super(new Int32Array(e),t,n)}}class jc extends Ze{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class $_ extends Ze{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Is(this.array[e*this.itemSize]);return this.normalized&&(t=ln(t,this.array)),t}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize]=Qt(t),this}getY(e){let t=Is(this.array[e*this.itemSize+1]);return this.normalized&&(t=ln(t,this.array)),t}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+1]=Qt(t),this}getZ(e){let t=Is(this.array[e*this.itemSize+2]);return this.normalized&&(t=ln(t,this.array)),t}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+2]=Qt(t),this}getW(e){let t=Is(this.array[e*this.itemSize+3]);return this.normalized&&(t=ln(t,this.array)),t}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+3]=Qt(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array)),this.array[e+0]=Qt(t),this.array[e+1]=Qt(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array)),this.array[e+0]=Qt(t),this.array[e+1]=Qt(n),this.array[e+2]=Qt(i),this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array),s=We(s,this.array)),this.array[e+0]=Qt(t),this.array[e+1]=Qt(n),this.array[e+2]=Qt(i),this.array[e+3]=Qt(s),this}}class ve extends Ze{constructor(e,t,n){super(new Float32Array(e),t,n)}}class Y_ extends Ze{constructor(e,t,n){super(new Float64Array(e),t,n)}}let Z_=0;const xn=new Be,Qc=new tt,Pr=new R,hn=new _n,Us=new _n,Ct=new R;class Fe extends Zn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Z_++}),this.uuid=on(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Zf(e)?jc:Kc)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Xe().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return xn.makeRotationFromQuaternion(e),this.applyMatrix4(xn),this}rotateX(e){return xn.makeRotationX(e),this.applyMatrix4(xn),this}rotateY(e){return xn.makeRotationY(e),this.applyMatrix4(xn),this}rotateZ(e){return xn.makeRotationZ(e),this.applyMatrix4(xn),this}translate(e,t,n){return xn.makeTranslation(e,t,n),this.applyMatrix4(xn),this}scale(e,t,n){return xn.makeScale(e,t,n),this.applyMatrix4(xn),this}lookAt(e){return Qc.lookAt(e),Qc.updateMatrix(),this.applyMatrix4(Qc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Pr).negate(),this.translate(Pr.x,Pr.y,Pr.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new ve(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new _n);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const s=t[n];hn.setFromBufferAttribute(s),this.morphTargetsRelative?(Ct.addVectors(this.boundingBox.min,hn.min),this.boundingBox.expandByPoint(Ct),Ct.addVectors(this.boundingBox.max,hn.max),this.boundingBox.expandByPoint(Ct)):(this.boundingBox.expandByPoint(hn.min),this.boundingBox.expandByPoint(hn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new wn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new R,1/0);return}if(e){const n=this.boundingSphere.center;if(hn.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Us.setFromBufferAttribute(o),this.morphTargetsRelative?(Ct.addVectors(hn.min,Us.min),hn.expandByPoint(Ct),Ct.addVectors(hn.max,Us.max),hn.expandByPoint(Ct)):(hn.expandByPoint(Us.min),hn.expandByPoint(Us.max))}hn.getCenter(n);let i=0;for(let s=0,a=e.count;s<a;s++)Ct.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Ct));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Ct.fromBufferAttribute(o,c),l&&(Pr.fromBufferAttribute(e,c),Ct.add(Pr)),i=Math.max(i,n.distanceToSquared(Ct))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.array,i=t.position.array,s=t.normal.array,a=t.uv.array,o=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ze(new Float32Array(4*o),4));const l=this.getAttribute("tangent").array,c=[],h=[];for(let b=0;b<o;b++)c[b]=new R,h[b]=new R;const u=new R,f=new R,d=new R,p=new q,_=new q,g=new q,m=new R,y=new R;function x(b,L,k){u.fromArray(i,b*3),f.fromArray(i,L*3),d.fromArray(i,k*3),p.fromArray(a,b*2),_.fromArray(a,L*2),g.fromArray(a,k*2),f.sub(u),d.sub(u),_.sub(p),g.sub(p);const U=1/(_.x*g.y-g.x*_.y);isFinite(U)&&(m.copy(f).multiplyScalar(g.y).addScaledVector(d,-_.y).multiplyScalar(U),y.copy(d).multiplyScalar(_.x).addScaledVector(f,-g.x).multiplyScalar(U),c[b].add(m),c[L].add(m),c[k].add(m),h[b].add(y),h[L].add(y),h[k].add(y))}let v=this.groups;v.length===0&&(v=[{start:0,count:n.length}]);for(let b=0,L=v.length;b<L;++b){const k=v[b],U=k.start,N=k.count;for(let I=U,B=U+N;I<B;I+=3)x(n[I+0],n[I+1],n[I+2])}const M=new R,w=new R,A=new R,C=new R;function S(b){A.fromArray(s,b*3),C.copy(A);const L=c[b];M.copy(L),M.sub(A.multiplyScalar(A.dot(L))).normalize(),w.crossVectors(C,L);const U=w.dot(h[b])<0?-1:1;l[b*4]=M.x,l[b*4+1]=M.y,l[b*4+2]=M.z,l[b*4+3]=U}for(let b=0,L=v.length;b<L;++b){const k=v[b],U=k.start,N=k.count;for(let I=U,B=U+N;I<B;I+=3)S(n[I+0]),S(n[I+1]),S(n[I+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Ze(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,d=n.count;f<d;f++)n.setXYZ(f,0,0,0);const i=new R,s=new R,a=new R,o=new R,l=new R,c=new R,h=new R,u=new R;if(e)for(let f=0,d=e.count;f<d;f+=3){const p=e.getX(f+0),_=e.getX(f+1),g=e.getX(f+2);i.fromBufferAttribute(t,p),s.fromBufferAttribute(t,_),a.fromBufferAttribute(t,g),h.subVectors(a,s),u.subVectors(i,s),h.cross(u),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,g),o.add(h),l.add(h),c.add(h),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let f=0,d=t.count;f<d;f+=3)i.fromBufferAttribute(t,f+0),s.fromBufferAttribute(t,f+1),a.fromBufferAttribute(t,f+2),h.subVectors(a,s),u.subVectors(i,s),h.cross(u),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Ct.fromBufferAttribute(e,t),Ct.normalize(),e.setXYZ(t,Ct.x,Ct.y,Ct.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,u=o.normalized,f=new c.constructor(l.length*h);let d=0,p=0;for(let _=0,g=l.length;_<g;_++){o.isInterleavedBufferAttribute?d=l[_]*o.data.stride+o.offset:d=l[_]*h;for(let m=0;m<h;m++)f[p++]=c[d++]}return new Ze(f,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Fe,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,u=c.length;h<u;h++){const f=c[h],d=e(f,n);l.push(d)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>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 n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,f=c.length;u<f;u++){const d=c[u];h.push(d.toJSON(e.data))}h.length>0&&(i[l]=h,s=!0)}s&&(e.data.morphAttributes=i,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={center:o.center.toArray(),radius:o.radius}),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 n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],u=s[c];for(let f=0,d=u.length;f<d;f++)h.push(u[f].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const od=new Be,Hi=new Er,qa=new wn,ld=new R,Lr=new R,Ir=new R,Ur=new R,eh=new R,$a=new R,Ya=new q,Za=new q,Ja=new q,cd=new R,hd=new R,ud=new R,Ka=new R,ja=new R;class It extends tt{constructor(e=new Fe,t=new Ai){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){$a.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],u=s[l];h!==0&&(eh.fromBufferAttribute(u,e),a?$a.addScaledVector(eh,h):$a.addScaledVector(eh.sub(t),h))}t.add($a)}return t}raycast(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),qa.copy(n.boundingSphere),qa.applyMatrix4(s),Hi.copy(e.ray).recast(e.near),!(qa.containsPoint(Hi.origin)===!1&&(Hi.intersectSphere(qa,ld)===null||Hi.origin.distanceToSquared(ld)>us(e.far-e.near,2)))&&(od.copy(s).invert(),Hi.copy(e.ray).applyMatrix4(od),!(n.boundingBox!==null&&Hi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Hi)))}_computeIntersections(e,t,n){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,f=s.groups,d=s.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,_=f.length;p<_;p++){const g=f[p],m=a[g.materialIndex],y=Math.max(g.start,d.start),x=Math.min(o.count,Math.min(g.start+g.count,d.start+d.count));for(let v=y,M=x;v<M;v+=3){const w=o.getX(v),A=o.getX(v+1),C=o.getX(v+2);i=Qa(this,m,e,n,c,h,u,w,A,C),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const p=Math.max(0,d.start),_=Math.min(o.count,d.start+d.count);for(let g=p,m=_;g<m;g+=3){const y=o.getX(g),x=o.getX(g+1),v=o.getX(g+2);i=Qa(this,a,e,n,c,h,u,y,x,v),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let p=0,_=f.length;p<_;p++){const g=f[p],m=a[g.materialIndex],y=Math.max(g.start,d.start),x=Math.min(l.count,Math.min(g.start+g.count,d.start+d.count));for(let v=y,M=x;v<M;v+=3){const w=v,A=v+1,C=v+2;i=Qa(this,m,e,n,c,h,u,w,A,C),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const p=Math.max(0,d.start),_=Math.min(l.count,d.start+d.count);for(let g=p,m=_;g<m;g+=3){const y=g,x=g+1,v=g+2;i=Qa(this,a,e,n,c,h,u,y,x,v),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}}}function J_(r,e,t,n,i,s,a,o){let l;if(e.side===kt?l=n.intersectTriangle(a,s,i,!0,o):l=n.intersectTriangle(i,s,a,e.side===Xn,o),l===null)return null;ja.copy(o),ja.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(ja);return c<t.near||c>t.far?null:{distance:c,point:ja.clone(),object:r}}function Qa(r,e,t,n,i,s,a,o,l,c){r.getVertexPosition(o,Lr),r.getVertexPosition(l,Ir),r.getVertexPosition(c,Ur);const h=J_(r,e,t,n,Lr,Ir,Ur,Ka);if(h){i&&(Ya.fromBufferAttribute(i,o),Za.fromBufferAttribute(i,l),Ja.fromBufferAttribute(i,c),h.uv=jt.getInterpolation(Ka,Lr,Ir,Ur,Ya,Za,Ja,new q)),s&&(Ya.fromBufferAttribute(s,o),Za.fromBufferAttribute(s,l),Ja.fromBufferAttribute(s,c),h.uv1=jt.getInterpolation(Ka,Lr,Ir,Ur,Ya,Za,Ja,new q),h.uv2=h.uv1),a&&(cd.fromBufferAttribute(a,o),hd.fromBufferAttribute(a,l),ud.fromBufferAttribute(a,c),h.normal=jt.getInterpolation(Ka,Lr,Ir,Ur,cd,hd,ud,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new R,materialIndex:0};jt.getNormal(Lr,Ir,Ur,u.normal),h.face=u}return h}class Vi extends Fe{constructor(e=1,t=1,n=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],u=[];let f=0,d=0;p("z","y","x",-1,-1,n,t,e,a,s,0),p("z","y","x",1,-1,n,t,-e,a,s,1),p("x","z","y",1,1,e,n,t,i,a,2),p("x","z","y",1,-1,e,n,-t,i,a,3),p("x","y","z",1,-1,e,t,n,i,s,4),p("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new ve(c,3)),this.setAttribute("normal",new ve(h,3)),this.setAttribute("uv",new ve(u,2));function p(_,g,m,y,x,v,M,w,A,C,S){const b=v/A,L=M/C,k=v/2,U=M/2,N=w/2,I=A+1,B=C+1;let O=0,H=0;const X=new R;for(let ee=0;ee<B;ee++){const z=ee*L-U;for(let Z=0;Z<I;Z++){const le=Z*b-k;X[_]=le*y,X[g]=z*x,X[m]=N,c.push(X.x,X.y,X.z),X[_]=0,X[g]=0,X[m]=w>0?1:-1,h.push(X.x,X.y,X.z),u.push(Z/A),u.push(1-ee/C),O+=1}}for(let ee=0;ee<C;ee++)for(let z=0;z<A;z++){const Z=f+z+I*ee,le=f+z+I*(ee+1),ce=f+(z+1)+I*(ee+1),fe=f+(z+1)+I*ee;l.push(Z,le,fe),l.push(le,ce,fe),H+=6}o.addGroup(d,H,S),d+=H,f+=O}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Dr(r){const e={};for(const t in r){e[t]={};for(const n in r[t]){const i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function Gt(r){const e={};for(let t=0;t<r.length;t++){const n=Dr(r[t]);for(const i in n)e[i]=n[i]}return e}function K_(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function fd(r){return r.getRenderTarget()===null?r.outputColorSpace:Sn}const dd={clone:Dr,merge:Gt};var j_=`void main() {
5
+ */const ot="154",At={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},xt={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Jt=0,dr=1,va=2,Xl=3,ds=0,Mn=1,pr=2,Dn=3,Xn=0,kt=1,Nn=2,P0=2,qn=0,Ui=1,ql=2,$l=3,Yl=4,Ku=5,Di=100,ju=101,Qu=102,Zl=103,Jl=104,ef=200,tf=201,nf=202,rf=203,Kl=204,jl=205,sf=206,af=207,of=208,lf=209,cf=210,hf=0,uf=1,ff=2,Ma=3,df=4,pf=5,mf=6,gf=7,ps=0,_f=1,xf=2,Fn=0,yf=1,vf=2,Mf=3,Sf=4,bf=5,Sa=300,pi=301,mi=302,ms=303,gs=304,mr=306,_s=1e3,Dt=1001,xs=1002,yt=1003,ba=1004,L0=1004,ys=1005,I0=1005,vt=1006,Ql=1007,U0=1007,gi=1008,D0=1008,$n=1009,wf=1010,Ef=1011,wa=1012,ec=1013,Yn=1014,On=1015,gr=1016,tc=1017,nc=1018,_i=1020,Af=1021,an=1023,Tf=1024,Rf=1025,xi=1026,Ni=1027,Cf=1028,ic=1029,Pf=1030,rc=1031,sc=1033,Ea=33776,Aa=33777,Ta=33778,Ra=33779,ac=35840,oc=35841,lc=35842,cc=35843,Lf=36196,hc=37492,uc=37496,fc=37808,dc=37809,pc=37810,mc=37811,gc=37812,_c=37813,xc=37814,yc=37815,vc=37816,Mc=37817,Sc=37818,bc=37819,wc=37820,Ec=37821,Ca=36492,If=36283,Ac=36284,Tc=36285,Rc=36286,Uf=2200,Df=2201,Nf=2202,vs=2300,Ms=2301,Pa=2302,Fi=2400,Oi=2401,Ss=2402,La=2500,Cc=2501,N0=0,F0=1,O0=2,Pc=3e3,yi=3001,Ff=3200,Of=3201,vi=0,Bf=1,Mi="",Ge="srgb",Sn="srgb-linear",Lc="display-p3",B0=0,Ia=7680,z0=7681,k0=7682,G0=7683,H0=34055,V0=34056,W0=5386,X0=512,q0=513,$0=514,Y0=515,Z0=516,J0=517,K0=518,zf=519,kf=512,Gf=513,Hf=514,Vf=515,Wf=516,Xf=517,qf=518,$f=519,bs=35044,j0=35048,Q0=35040,e_=35045,t_=35049,n_=35041,i_=35046,r_=35050,s_=35042,a_="100",Ic="300 es",Ua=1035,Bn=2e3,ws=2001;class Zn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const Nt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Yf=1234567;const Bi=Math.PI/180,_r=180/Math.PI;function on(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Nt[r&255]+Nt[r>>8&255]+Nt[r>>16&255]+Nt[r>>24&255]+"-"+Nt[e&255]+Nt[e>>8&255]+"-"+Nt[e>>16&15|64]+Nt[e>>24&255]+"-"+Nt[t&63|128]+Nt[t>>8&255]+"-"+Nt[t>>16&255]+Nt[t>>24&255]+Nt[n&255]+Nt[n>>8&255]+Nt[n>>16&255]+Nt[n>>24&255]).toLowerCase()}function ft(r,e,t){return Math.max(e,Math.min(t,r))}function Uc(r,e){return(r%e+e)%e}function o_(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function l_(r,e,t){return r!==e?(t-r)/(e-r):0}function Es(r,e,t){return(1-t)*r+t*e}function c_(r,e,t,n){return Es(r,e,1-Math.exp(-t*n))}function h_(r,e=1){return e-Math.abs(Uc(r,e*2)-e)}function u_(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function f_(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function d_(r,e){return r+Math.floor(Math.random()*(e-r+1))}function p_(r,e){return r+Math.random()*(e-r)}function m_(r){return r*(.5-Math.random())}function g_(r){r!==void 0&&(Yf=r);let e=Yf+=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 __(r){return r*Bi}function x_(r){return r*_r}function Dc(r){return(r&r-1)===0&&r!==0}function Zf(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Da(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function y_(r,e,t,n,i){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+n)/2),h=a((e+n)/2),u=s((e-n)/2),f=a((e-n)/2),d=s((n-e)/2),p=a((n-e)/2);switch(i){case"XYX":r.set(o*h,l*u,l*f,o*c);break;case"YZY":r.set(l*f,o*h,l*u,o*c);break;case"ZXZ":r.set(l*u,l*f,o*h,o*c);break;case"XZX":r.set(o*h,l*p,l*d,o*c);break;case"YXY":r.set(l*d,o*h,l*p,o*c);break;case"ZYZ":r.set(l*p,l*d,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function ln(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function We(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const v_={DEG2RAD:Bi,RAD2DEG:_r,generateUUID:on,clamp:ft,euclideanModulo:Uc,mapLinear:o_,inverseLerp:l_,lerp:Es,damp:c_,pingpong:h_,smoothstep:u_,smootherstep:f_,randInt:d_,randFloat:p_,randFloatSpread:m_,seededRandom:g_,degToRad:__,radToDeg:x_,isPowerOfTwo:Dc,ceilPowerOfTwo:Zf,floorPowerOfTwo:Da,setQuaternionFromProperEuler:y_,normalize:We,denormalize:ln};class q{constructor(e=0,t=0){q.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,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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 n=this.dot(e)/t;return Math.acos(ft(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,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 n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*i+e.x,this.y=s*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xe{constructor(e,t,n,i,s,a,o,l,c){Xe.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,l,c)}set(e,t,n,i,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=n,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,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.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 n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],f=n[2],d=n[5],p=n[8],_=i[0],g=i[3],m=i[6],y=i[1],x=i[4],v=i[7],M=i[2],w=i[5],A=i[8];return s[0]=a*_+o*y+l*M,s[3]=a*g+o*x+l*w,s[6]=a*m+o*v+l*A,s[1]=c*_+h*y+u*M,s[4]=c*g+h*x+u*w,s[7]=c*m+h*v+u*A,s[2]=f*_+d*y+p*M,s[5]=f*g+d*x+p*w,s[8]=f*m+d*v+p*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],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*s*h+n*o*l+i*s*c-i*a*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,f=o*l-h*s,d=c*s-a*l,p=t*u+n*f+i*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/p;return e[0]=u*_,e[1]=(i*c-h*n)*_,e[2]=(o*n-i*a)*_,e[3]=f*_,e[4]=(h*t-i*l)*_,e[5]=(i*s-o*t)*_,e[6]=d*_,e[7]=(n*l-c*t)*_,e[8]=(a*t-n*s)*_,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,n,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Nc.makeScale(e,t)),this}rotate(e){return this.premultiply(Nc.makeRotation(-e)),this}translate(e,t){return this.premultiply(Nc.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),n=Math.sin(e);return this.set(t,-n,0,n,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,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Nc=new Xe;function Jf(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}const M_={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function xr(r,e){return new M_[r](e)}function As(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const Kf={};function Ts(r){r in Kf||(Kf[r]=!0,console.warn(r))}function yr(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Fc(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}const S_=new Xe().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),b_=new Xe().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function w_(r){return r.convertSRGBToLinear().applyMatrix3(b_)}function E_(r){return r.applyMatrix3(S_).convertLinearToSRGB()}const A_={[Sn]:r=>r,[Ge]:r=>r.convertSRGBToLinear(),[Lc]:w_},T_={[Sn]:r=>r,[Ge]:r=>r.convertLinearToSRGB(),[Lc]:E_},gn={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(r){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!r},get workingColorSpace(){return Sn},set workingColorSpace(r){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(r,e,t){if(this.enabled===!1||e===t||!e||!t)return r;const n=A_[e],i=T_[t];if(n===void 0||i===void 0)throw new Error(`Unsupported color space conversion, "${e}" to "${t}".`);return i(n(r))},fromWorkingColorSpace:function(r,e){return this.convert(r,this.workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this.workingColorSpace)}};let vr;class Oc{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement=="undefined")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{vr===void 0&&(vr=As("canvas")),vr.width=e.width,vr.height=e.height;const n=vr.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=vr}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){const t=As("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=yr(s[a]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(yr(t[n]/255)*255):t[n]=yr(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let R_=0;class zi{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:R_++}),this.uuid=on(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(Bc(i[a].image)):s.push(Bc(i[a]))}else s=Bc(i);n.url=s}return t||(e.images[this.uuid]=n),n}}function Bc(r){return typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&r instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&r instanceof ImageBitmap?Oc.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let C_=0;class Mt extends Zn{constructor(e=Mt.DEFAULT_IMAGE,t=Mt.DEFAULT_MAPPING,n=Dt,i=Dt,s=vt,a=gi,o=an,l=$n,c=Mt.DEFAULT_ANISOTROPY,h=Mi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:C_++}),this.uuid=on(),this.name="",this.source=new zi(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new q(0,0),this.repeat=new q(1,1),this.center=new q(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Xe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof h=="string"?this.colorSpace=h:(Ts("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===yi?Ge:Mi),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}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)}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.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Sa)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case _s:e.x=e.x-Math.floor(e.x);break;case Dt:e.x=e.x<0?0:1;break;case xs: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 _s:e.y=e.y-Math.floor(e.y);break;case Dt:e.y=e.y<0?0:1;break;case xs: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)}get encoding(){return Ts("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Ge?yi:Pc}set encoding(e){Ts("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===yi?Ge:Mi}}Mt.DEFAULT_IMAGE=null,Mt.DEFAULT_MAPPING=Sa,Mt.DEFAULT_ANISOTROPY=1;class rt{constructor(e=0,t=0,n=0,i=1){rt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw 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,n=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*s,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,n,i,s;const l=e.elements,c=l[0],h=l[4],u=l[8],f=l[1],d=l[5],p=l[9],_=l[2],g=l[6],m=l[10];if(Math.abs(h-f)<.01&&Math.abs(u-_)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+f)<.1&&Math.abs(u+_)<.1&&Math.abs(p+g)<.1&&Math.abs(c+d+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const x=(c+1)/2,v=(d+1)/2,M=(m+1)/2,w=(h+f)/4,A=(u+_)/4,C=(p+g)/4;return x>v&&x>M?x<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(x),i=w/n,s=A/n):v>M?v<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(v),n=w/i,s=C/i):M<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(M),n=A/s,i=C/s),this.set(n,i,s,t),this}let y=Math.sqrt((g-p)*(g-p)+(u-_)*(u-_)+(f-h)*(f-h));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(u-_)/y,this.z=(f-h)/y,this.w=Math.acos((c+d+m-1)/2),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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,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 bn extends Zn{constructor(e=1,t=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new rt(0,0,e,t),this.scissorTest=!1,this.viewport=new rt(0,0,e,t);const i={width:e,height:t,depth:1};n.encoding!==void 0&&(Ts("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===yi?Ge:Mi),this.texture=new Mt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:vt,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,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.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new zi(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Na extends Mt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=yt,this.minFilter=yt,this.wrapR=Dt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class P_ extends bn{constructor(e=1,t=1,n=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Na(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class zc extends Mt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=yt,this.minFilter=yt,this.wrapR=Dt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class L_ extends bn{constructor(e=1,t=1,n=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new zc(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class I_ extends bn{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let a=0;a<n;a++)this.texture[a]=s.clone(),this.texture[a].isRenderTargetTexture=!0}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,s=this.texture.length;i<s;i++)this.texture[i].image.width=e,this.texture[i].image.height=t,this.texture[i].image.depth=n;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),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.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.texture.length=0;for(let t=0,n=e.texture.length;t<n;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}}class Kt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,a,o){let l=n[i+0],c=n[i+1],h=n[i+2],u=n[i+3];const f=s[a+0],d=s[a+1],p=s[a+2],_=s[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]=f,e[t+1]=d,e[t+2]=p,e[t+3]=_;return}if(u!==_||l!==f||c!==d||h!==p){let g=1-o;const m=l*f+c*d+h*p+u*_,y=m>=0?1:-1,x=1-m*m;if(x>Number.EPSILON){const M=Math.sqrt(x),w=Math.atan2(M,m*y);g=Math.sin(g*w)/M,o=Math.sin(o*w)/M}const v=o*y;if(l=l*g+f*v,c=c*g+d*v,h=h*g+p*v,u=u*g+_*v,g===1-o){const M=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=M,c*=M,h*=M,u*=M}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[a],f=s[a+1],d=s[a+2],p=s[a+3];return e[t]=o*p+h*u+l*d-c*f,e[t+1]=l*p+h*f+c*u-o*d,e[t+2]=c*p+h*d+o*f-l*u,e[t+3]=h*p-o*u-l*f-c*d,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,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(i/2),u=o(s/2),f=l(n/2),d=l(i/2),p=l(s/2);switch(a){case"XYZ":this._x=f*h*u+c*d*p,this._y=c*d*u-f*h*p,this._z=c*h*p+f*d*u,this._w=c*h*u-f*d*p;break;case"YXZ":this._x=f*h*u+c*d*p,this._y=c*d*u-f*h*p,this._z=c*h*p-f*d*u,this._w=c*h*u+f*d*p;break;case"ZXY":this._x=f*h*u-c*d*p,this._y=c*d*u+f*h*p,this._z=c*h*p+f*d*u,this._w=c*h*u-f*d*p;break;case"ZYX":this._x=f*h*u-c*d*p,this._y=c*d*u+f*h*p,this._z=c*h*p-f*d*u,this._w=c*h*u+f*d*p;break;case"YZX":this._x=f*h*u+c*d*p,this._y=c*d*u+f*h*p,this._z=c*h*p-f*d*u,this._w=c*h*u-f*d*p;break;case"XZY":this._x=f*h*u-c*d*p,this._y=c*d*u-f*h*p,this._z=c*h*p+f*d*u,this._w=c*h*u+f*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],u=t[10],f=n+o+u;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(h-l)*d,this._y=(s-c)*d,this._z=(a-i)*d}else if(n>o&&n>u){const d=2*Math.sqrt(1+n-o-u);this._w=(h-l)/d,this._x=.25*d,this._y=(i+a)/d,this._z=(s+c)/d}else if(o>u){const d=2*Math.sqrt(1+o-n-u);this._w=(s-c)/d,this._x=(i+a)/d,this._y=.25*d,this._z=(l+h)/d}else{const d=2*Math.sqrt(1+u-n-o);this._w=(a-i)/d,this._x=(s+c)/d,this._y=(l+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ft(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 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 n=e._x,i=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+i*c-s*l,this._y=i*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-i*o,this._w=a*h-n*o-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const d=1-t;return this._w=d*a+t*this._w,this._x=d*n+t*this._x,this._y=d*i+t*this._y,this._z=d*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-t)*h)/c,f=Math.sin(t*h)/c;return this._w=a*u+this._w*f,this._x=n*u+this._x*f,this._y=i*u+this._y*f,this._z=s*u+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}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}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 R{constructor(e=0,t=0,n=0){R.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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(jf.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(jf.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=l*t+a*i-o*n,h=l*n+o*t-s*i,u=l*i+s*n-a*t,f=-s*t-a*n-o*i;return this.x=c*l+f*-s+h*-o-u*-a,this.y=h*l+f*-a+u*-s-c*-o,this.z=u*l+f*-o+c*-a-h*-s,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,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-s*o,this.y=s*a-n*l,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return kc.copy(this).projectOnVector(e),this.sub(kc)}reflect(e){return this.sub(kc.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 n=this.dot(e)/t;return Math.acos(ft(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,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(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-us(e,2));return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const kc=new R,jf=new Kt;class _n{constructor(e=new R(1/0,1/0,1/0),t=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Kn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Kn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Kn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){if(e.updateWorldMatrix(!1,!1),e.boundingBox!==void 0)e.boundingBox===null&&e.computeBoundingBox(),Mr.copy(e.boundingBox),Mr.applyMatrix4(e.matrixWorld),this.union(Mr);else{const i=e.geometry;if(i!==void 0)if(t&&i.attributes!==void 0&&i.attributes.position!==void 0){const s=i.attributes.position;for(let a=0,o=s.count;a<o;a++)Kn.fromBufferAttribute(s,a).applyMatrix4(e.matrixWorld),this.expandByPoint(Kn)}else i.boundingBox===null&&i.computeBoundingBox(),Mr.copy(i.boundingBox),Mr.applyMatrix4(e.matrixWorld),this.union(Mr)}const n=e.children;for(let i=0,s=n.length;i<s;i++)this.expandByObject(n[i],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Kn),Kn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Rs),Fa.subVectors(this.max,Rs),Sr.subVectors(e.a,Rs),br.subVectors(e.b,Rs),wr.subVectors(e.c,Rs),Si.subVectors(br,Sr),bi.subVectors(wr,br),ki.subVectors(Sr,wr);let t=[0,-Si.z,Si.y,0,-bi.z,bi.y,0,-ki.z,ki.y,Si.z,0,-Si.x,bi.z,0,-bi.x,ki.z,0,-ki.x,-Si.y,Si.x,0,-bi.y,bi.x,0,-ki.y,ki.x,0];return!Gc(t,Sr,br,wr,Fa)||(t=[1,0,0,0,1,0,0,0,1],!Gc(t,Sr,br,wr,Fa))?!1:(Oa.crossVectors(Si,bi),t=[Oa.x,Oa.y,Oa.z],Gc(t,Sr,br,wr,Fa))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Kn).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:(Jn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Jn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Jn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Jn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Jn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Jn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Jn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Jn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Jn),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)}}const Jn=[new R,new R,new R,new R,new R,new R,new R,new R],Kn=new R,Mr=new _n,Sr=new R,br=new R,wr=new R,Si=new R,bi=new R,ki=new R,Rs=new R,Fa=new R,Oa=new R,Gi=new R;function Gc(r,e,t,n,i){for(let s=0,a=r.length-3;s<=a;s+=3){Gi.fromArray(r,s);const o=i.x*Math.abs(Gi.x)+i.y*Math.abs(Gi.y)+i.z*Math.abs(Gi.z),l=e.dot(Gi),c=t.dot(Gi),h=n.dot(Gi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const U_=new _n,Cs=new R,Hc=new R;class wn{constructor(e=new R,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):U_.setFromPoints(e).getCenter(n);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(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;Cs.subVectors(e,this.center);const t=Cs.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Cs,i/n),this.radius+=i}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):(Hc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Cs.copy(e.center).add(Hc)),this.expandByPoint(Cs.copy(e.center).sub(Hc))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const jn=new R,Vc=new R,Ba=new R,wi=new R,Wc=new R,za=new R,Xc=new R;class Er{constructor(e=new R,t=new R(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,jn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=jn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(jn.copy(this.origin).addScaledVector(this.direction,t),jn.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Vc.copy(e).add(t).multiplyScalar(.5),Ba.copy(t).sub(e).normalize(),wi.copy(this.origin).sub(Vc);const s=e.distanceTo(t)*.5,a=-this.direction.dot(Ba),o=wi.dot(this.direction),l=-wi.dot(Ba),c=wi.lengthSq(),h=Math.abs(1-a*a);let u,f,d,p;if(h>0)if(u=a*l-o,f=a*o-l,p=s*h,u>=0)if(f>=-p)if(f<=p){const _=1/h;u*=_,f*=_,d=u*(u+a*f+2*o)+f*(a*u+f+2*l)+c}else f=s,u=Math.max(0,-(a*f+o)),d=-u*u+f*(f+2*l)+c;else f=-s,u=Math.max(0,-(a*f+o)),d=-u*u+f*(f+2*l)+c;else f<=-p?(u=Math.max(0,-(-a*s+o)),f=u>0?-s:Math.min(Math.max(-s,-l),s),d=-u*u+f*(f+2*l)+c):f<=p?(u=0,f=Math.min(Math.max(-s,-l),s),d=f*(f+2*l)+c):(u=Math.max(0,-(a*s+o)),f=u>0?s:Math.min(Math.max(-s,-l),s),d=-u*u+f*(f+2*l)+c);else f=a>0?-s:s,u=Math.max(0,-(a*f+o)),d=-u*u+f*(f+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Vc).addScaledVector(Ba,f),d}intersectSphere(e,t){jn.subVectors(e.center,this.origin);const n=jn.dot(this.direction),i=jn.dot(jn)-n*n,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return 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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,f=this.origin;return c>=0?(n=(e.min.x-f.x)*c,i=(e.max.x-f.x)*c):(n=(e.max.x-f.x)*c,i=(e.min.x-f.x)*c),h>=0?(s=(e.min.y-f.y)*h,a=(e.max.y-f.y)*h):(s=(e.max.y-f.y)*h,a=(e.min.y-f.y)*h),n>a||s>i||((s>n||isNaN(n))&&(n=s),(a<i||isNaN(i))&&(i=a),u>=0?(o=(e.min.z-f.z)*u,l=(e.max.z-f.z)*u):(o=(e.max.z-f.z)*u,l=(e.min.z-f.z)*u),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,jn)!==null}intersectTriangle(e,t,n,i,s){Wc.subVectors(t,e),za.subVectors(n,e),Xc.crossVectors(Wc,za);let a=this.direction.dot(Xc),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;wi.subVectors(this.origin,e);const l=o*this.direction.dot(za.crossVectors(wi,za));if(l<0)return null;const c=o*this.direction.dot(Wc.cross(wi));if(c<0||l+c>a)return null;const h=-o*wi.dot(Xc);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Be{constructor(e,t,n,i,s,a,o,l,c,h,u,f,d,p,_,g){Be.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,n,i,s,a,o,l,c,h,u,f,d,p,_,g)}set(e,t,n,i,s,a,o,l,c,h,u,f,d,p,_,g){const m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=s,m[5]=a,m[9]=o,m[13]=l,m[2]=c,m[6]=h,m[10]=u,m[14]=f,m[3]=d,m[7]=p,m[11]=_,m[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Be().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Ar.setFromMatrixColumn(e,0).length(),s=1/Ar.setFromMatrixColumn(e,1).length(),a=1/Ar.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const f=a*h,d=a*u,p=o*h,_=o*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=d+p*c,t[5]=f-_*c,t[9]=-o*l,t[2]=_-f*c,t[6]=p+d*c,t[10]=a*l}else if(e.order==="YXZ"){const f=l*h,d=l*u,p=c*h,_=c*u;t[0]=f+_*o,t[4]=p*o-d,t[8]=a*c,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=d*o-p,t[6]=_+f*o,t[10]=a*l}else if(e.order==="ZXY"){const f=l*h,d=l*u,p=c*h,_=c*u;t[0]=f-_*o,t[4]=-a*u,t[8]=p+d*o,t[1]=d+p*o,t[5]=a*h,t[9]=_-f*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const f=a*h,d=a*u,p=o*h,_=o*u;t[0]=l*h,t[4]=p*c-d,t[8]=f*c+_,t[1]=l*u,t[5]=_*c+f,t[9]=d*c-p,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const f=a*l,d=a*c,p=o*l,_=o*c;t[0]=l*h,t[4]=_-f*u,t[8]=p*u+d,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=d*u+p,t[10]=f-_*u}else if(e.order==="XZY"){const f=a*l,d=a*c,p=o*l,_=o*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=f*u+_,t[5]=a*h,t[9]=d*u-p,t[2]=p*u-d,t[6]=o*h,t[10]=_*u+f}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(D_,e,N_)}lookAt(e,t,n){const i=this.elements;return cn.subVectors(e,t),cn.lengthSq()===0&&(cn.z=1),cn.normalize(),Ei.crossVectors(n,cn),Ei.lengthSq()===0&&(Math.abs(n.z)===1?cn.x+=1e-4:cn.z+=1e-4,cn.normalize(),Ei.crossVectors(n,cn)),Ei.normalize(),ka.crossVectors(cn,Ei),i[0]=Ei.x,i[4]=ka.x,i[8]=cn.x,i[1]=Ei.y,i[5]=ka.y,i[9]=cn.y,i[2]=Ei.z,i[6]=ka.z,i[10]=cn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],f=n[9],d=n[13],p=n[2],_=n[6],g=n[10],m=n[14],y=n[3],x=n[7],v=n[11],M=n[15],w=i[0],A=i[4],C=i[8],S=i[12],b=i[1],L=i[5],k=i[9],U=i[13],N=i[2],I=i[6],B=i[10],O=i[14],H=i[3],X=i[7],ee=i[11],z=i[15];return s[0]=a*w+o*b+l*N+c*H,s[4]=a*A+o*L+l*I+c*X,s[8]=a*C+o*k+l*B+c*ee,s[12]=a*S+o*U+l*O+c*z,s[1]=h*w+u*b+f*N+d*H,s[5]=h*A+u*L+f*I+d*X,s[9]=h*C+u*k+f*B+d*ee,s[13]=h*S+u*U+f*O+d*z,s[2]=p*w+_*b+g*N+m*H,s[6]=p*A+_*L+g*I+m*X,s[10]=p*C+_*k+g*B+m*ee,s[14]=p*S+_*U+g*O+m*z,s[3]=y*w+x*b+v*N+M*H,s[7]=y*A+x*L+v*I+M*X,s[11]=y*C+x*k+v*B+M*ee,s[15]=y*S+x*U+v*O+M*z,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],n=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],u=e[6],f=e[10],d=e[14],p=e[3],_=e[7],g=e[11],m=e[15];return p*(+s*l*u-i*c*u-s*o*f+n*c*f+i*o*d-n*l*d)+_*(+t*l*d-t*c*f+s*a*f-i*a*d+i*c*h-s*l*h)+g*(+t*c*u-t*o*d-s*a*u+n*a*d+s*o*h-n*c*h)+m*(-i*o*h-t*l*u+t*o*f+i*a*u-n*a*f+n*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,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],f=e[10],d=e[11],p=e[12],_=e[13],g=e[14],m=e[15],y=u*g*c-_*f*c+_*l*d-o*g*d-u*l*m+o*f*m,x=p*f*c-h*g*c-p*l*d+a*g*d+h*l*m-a*f*m,v=h*_*c-p*u*c+p*o*d-a*_*d-h*o*m+a*u*m,M=p*u*l-h*_*l-p*o*f+a*_*f+h*o*g-a*u*g,w=t*y+n*x+i*v+s*M;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/w;return e[0]=y*A,e[1]=(_*f*s-u*g*s-_*i*d+n*g*d+u*i*m-n*f*m)*A,e[2]=(o*g*s-_*l*s+_*i*c-n*g*c-o*i*m+n*l*m)*A,e[3]=(u*l*s-o*f*s-u*i*c+n*f*c+o*i*d-n*l*d)*A,e[4]=x*A,e[5]=(h*g*s-p*f*s+p*i*d-t*g*d-h*i*m+t*f*m)*A,e[6]=(p*l*s-a*g*s-p*i*c+t*g*c+a*i*m-t*l*m)*A,e[7]=(a*f*s-h*l*s+h*i*c-t*f*c-a*i*d+t*l*d)*A,e[8]=v*A,e[9]=(p*u*s-h*_*s-p*n*d+t*_*d+h*n*m-t*u*m)*A,e[10]=(a*_*s-p*o*s+p*n*c-t*_*c-a*n*m+t*o*m)*A,e[11]=(h*o*s-a*u*s-h*n*c+t*u*c+a*n*d-t*o*d)*A,e[12]=M*A,e[13]=(h*_*i-p*u*i+p*n*f-t*_*f-h*n*g+t*u*g)*A,e[14]=(p*o*i-a*_*i-p*n*l+t*_*l+a*n*g-t*o*g)*A,e[15]=(a*u*i-h*o*i+h*n*l-t*u*l-a*n*f+t*o*f)*A,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){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,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,h*o+n,h*l-i*a,0,c*l-i*o,h*l+i*a,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,a){return this.set(1,n,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,u=o+o,f=s*c,d=s*h,p=s*u,_=a*h,g=a*u,m=o*u,y=l*c,x=l*h,v=l*u,M=n.x,w=n.y,A=n.z;return i[0]=(1-(_+m))*M,i[1]=(d+v)*M,i[2]=(p-x)*M,i[3]=0,i[4]=(d-v)*w,i[5]=(1-(f+m))*w,i[6]=(g+y)*w,i[7]=0,i[8]=(p+x)*A,i[9]=(g-y)*A,i[10]=(1-(f+_))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=Ar.set(i[0],i[1],i[2]).length();const a=Ar.set(i[4],i[5],i[6]).length(),o=Ar.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],En.copy(this);const c=1/s,h=1/a,u=1/o;return En.elements[0]*=c,En.elements[1]*=c,En.elements[2]*=c,En.elements[4]*=h,En.elements[5]*=h,En.elements[6]*=h,En.elements[8]*=u,En.elements[9]*=u,En.elements[10]*=u,t.setFromRotationMatrix(En),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=Bn){const l=this.elements,c=2*s/(t-e),h=2*s/(n-i),u=(t+e)/(t-e),f=(n+i)/(n-i);let d,p;if(o===Bn)d=-(a+s)/(a-s),p=-2*a*s/(a-s);else if(o===ws)d=-a/(a-s),p=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=d,l[14]=p,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=Bn){const l=this.elements,c=1/(t-e),h=1/(n-i),u=1/(a-s),f=(t+e)*c,d=(n+i)*h;let p,_;if(o===Bn)p=(a+s)*u,_=-2*u;else if(o===ws)p=s*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-d,l[2]=0,l[6]=0,l[10]=_,l[14]=-p,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ar=new R,En=new Be,D_=new R(0,0,0),N_=new R(1,1,1),Ei=new R,ka=new R,cn=new R,Qf=new Be,ed=new Kt;class Ps{constructor(e=0,t=0,n=0,i=Ps.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],h=i[9],u=i[2],f=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(ft(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(f,c),this._z=0);break;case"YXZ":this._x=Math.asin(-ft(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(ft(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-ft(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(ft(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-ft(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Qf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Qf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ed.setFromEuler(this),this.setFromQuaternion(ed,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}}Ps.DEFAULT_ORDER="XYZ";class Ga{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let F_=0;const td=new R,Tr=new Kt,Qn=new Be,Ha=new R,Ls=new R,O_=new R,B_=new Kt,nd=new R(1,0,0),id=new R(0,1,0),rd=new R(0,0,1),z_={type:"added"},sd={type:"removed"};class tt extends Zn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:F_++}),this.uuid=on(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=tt.DEFAULT_UP.clone();const e=new R,t=new Ps,n=new Kt,i=new R(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Be},normalMatrix:{value:new Xe}}),this.matrix=new Be,this.matrixWorld=new Be,this.matrixAutoUpdate=tt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=tt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new Ga,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Tr.setFromAxisAngle(e,t),this.quaternion.multiply(Tr),this}rotateOnWorldAxis(e,t){return Tr.setFromAxisAngle(e,t),this.quaternion.premultiply(Tr),this}rotateX(e){return this.rotateOnAxis(nd,e)}rotateY(e){return this.rotateOnAxis(id,e)}rotateZ(e){return this.rotateOnAxis(rd,e)}translateOnAxis(e,t){return td.copy(e).applyQuaternion(this.quaternion),this.position.add(td.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(nd,e)}translateY(e){return this.translateOnAxis(id,e)}translateZ(e){return this.translateOnAxis(rd,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Qn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ha.copy(e):Ha.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Ls.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Qn.lookAt(Ls,Ha,this.up):Qn.lookAt(Ha,Ls,this.up),this.quaternion.setFromRotationMatrix(Qn),i&&(Qn.extractRotation(i.matrixWorld),Tr.setFromRotationMatrix(Qn),this.quaternion.premultiply(Tr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(z_)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(sd)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(sd)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Qn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Qn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Qn),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t){let n=[];this[e]===t&&n.push(this);for(let i=0,s=this.children.length;i<s;i++){const a=this.children[i].getObjectsByProperty(e,t);a.length>0&&(n=n.concat(a))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,e,O_),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ls,B_,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++){const s=t[n];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++){const o=i[s];o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(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<h;c++){const u=l[c];s(e.shapes,u)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),u=a(e.shapes),f=a(e.skeletons),d=a(e.animations),p=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),p.length>0&&(n.nodes=p)}return n.object=i,n;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.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}tt.DEFAULT_UP=new R(0,1,0),tt.DEFAULT_MATRIX_AUTO_UPDATE=!0,tt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const An=new R,ei=new R,qc=new R,ti=new R,Rr=new R,Cr=new R,ad=new R,$c=new R,Yc=new R,Zc=new R;let Va=!1;class jt{constructor(e=new R,t=new R,n=new R){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),An.subVectors(e,t),i.cross(An);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){An.subVectors(i,t),ei.subVectors(n,t),qc.subVectors(e,t);const a=An.dot(An),o=An.dot(ei),l=An.dot(qc),c=ei.dot(ei),h=ei.dot(qc),u=a*c-o*o;if(u===0)return s.set(-2,-1,-1);const f=1/u,d=(c*l-o*h)*f,p=(a*h-o*l)*f;return s.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,ti),ti.x>=0&&ti.y>=0&&ti.x+ti.y<=1}static getUV(e,t,n,i,s,a,o,l){return Va===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Va=!0),this.getInterpolation(e,t,n,i,s,a,o,l)}static getInterpolation(e,t,n,i,s,a,o,l){return this.getBarycoord(e,t,n,i,ti),l.setScalar(0),l.addScaledVector(s,ti.x),l.addScaledVector(a,ti.y),l.addScaledVector(o,ti.z),l}static isFrontFacing(e,t,n,i){return An.subVectors(n,t),ei.subVectors(e,t),An.cross(ei).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return An.subVectors(this.c,this.b),ei.subVectors(this.a,this.b),An.cross(ei).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return jt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return jt.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return Va===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Va=!0),jt.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}getInterpolation(e,t,n,i,s){return jt.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return jt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return jt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let a,o;Rr.subVectors(i,n),Cr.subVectors(s,n),$c.subVectors(e,n);const l=Rr.dot($c),c=Cr.dot($c);if(l<=0&&c<=0)return t.copy(n);Yc.subVectors(e,i);const h=Rr.dot(Yc),u=Cr.dot(Yc);if(h>=0&&u<=h)return t.copy(i);const f=l*u-h*c;if(f<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(Rr,a);Zc.subVectors(e,s);const d=Rr.dot(Zc),p=Cr.dot(Zc);if(p>=0&&d<=p)return t.copy(s);const _=d*c-l*p;if(_<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Cr,o);const g=h*p-d*u;if(g<=0&&u-h>=0&&d-p>=0)return ad.subVectors(s,i),o=(u-h)/(u-h+(d-p)),t.copy(i).addScaledVector(ad,o);const m=1/(g+_+f);return a=_*m,o=f*m,t.copy(n).addScaledVector(Rr,a).addScaledVector(Cr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let k_=0;class Ft extends Zn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:k_++}),this.uuid=on(),this.name="",this.type="Material",this.blending=Ui,this.side=Xn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Kl,this.blendDst=jl,this.blendEquation=Di,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Ma,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=zf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ia,this.stencilZFail=Ia,this.stencilZPass=Ia,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ui&&(n.blending=this.blending),this.side!==Xn&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=this.alphaHash),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(n.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=i(e.textures),a=i(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}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.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 n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,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++}}const od={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},Tn={h:0,s:0,l:0},Wa={h:0,s:0,l:0};function Jc(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}let ye=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ge){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,gn.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=gn.workingColorSpace){return this.r=e,this.g=t,this.b=n,gn.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=gn.workingColorSpace){if(e=Uc(e,1),t=ft(t,0,1),n=ft(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=Jc(a,s,e+1/3),this.g=Jc(a,s,e),this.b=Jc(a,s,e-1/3)}return gn.toWorkingColorSpace(this,i),this}setStyle(e,t=Ge){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ge){const n=od[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.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=yr(e.r),this.g=yr(e.g),this.b=yr(e.b),this}copyLinearToSRGB(e){return this.r=Fc(e.r),this.g=Fc(e.g),this.b=Fc(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ge){return gn.fromWorkingColorSpace(Ot.copy(this),e),Math.round(ft(Ot.r*255,0,255))*65536+Math.round(ft(Ot.g*255,0,255))*256+Math.round(ft(Ot.b*255,0,255))}getHexString(e=Ge){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=gn.workingColorSpace){gn.fromWorkingColorSpace(Ot.copy(this),t);const n=Ot.r,i=Ot.g,s=Ot.b,a=Math.max(n,i,s),o=Math.min(n,i,s);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 n:l=(i-s)/u+(i<s?6:0);break;case i:l=(s-n)/u+2;break;case s:l=(n-i)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=gn.workingColorSpace){return gn.fromWorkingColorSpace(Ot.copy(this),t),e.r=Ot.r,e.g=Ot.g,e.b=Ot.b,e}getStyle(e=Ge){gn.fromWorkingColorSpace(Ot.copy(this),e);const t=Ot.r,n=Ot.g,i=Ot.b;return e!==Ge?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Tn),Tn.h+=e,Tn.s+=t,Tn.l+=n,this.setHSL(Tn.h,Tn.s,Tn.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Tn),e.getHSL(Wa);const n=Es(Tn.h,Wa.h,t),i=Es(Tn.s,Wa.s,t),s=Es(Tn.l,Wa.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Ot=new ye;ye.NAMES=od;class Ai extends Ft{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ye(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.combine=ps,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.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 ni=G_();function G_(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const s=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);)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[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:n,shiftTable:i,mantissaTable:s,exponentTable:a,offsetTable:o}}function Qt(r){Math.abs(r)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),r=ft(r,-65504,65504),ni.floatView[0]=r;const e=ni.uint32View[0],t=e>>23&511;return ni.baseTable[t]+((e&8388607)>>ni.shiftTable[t])}function Is(r){const e=r>>10;return ni.uint32View[0]=ni.mantissaTable[ni.offsetTable[e]+(r&1023)]+ni.exponentTable[e],ni.floatView[0]}const H_={toHalfFloat:Qt,fromHalfFloat:Is},wt=new R,Xa=new q;class Ze{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=bs,this.updateRange={offset:0,count:-1},this.gpuType=On,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}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,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Xa.fromBufferAttribute(this,t),Xa.applyMatrix3(e),this.setXY(t,Xa.x,Xa.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.applyMatrix3(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.applyMatrix4(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.applyNormalMatrix(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.transformDirection(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ln(t,this.array)),t}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ln(t,this.array)),t}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=ln(t,this.array)),t}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=ln(t,this.array)),t}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array),s=We(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==bs&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}}class V_ extends Ze{constructor(e,t,n){super(new Int8Array(e),t,n)}}class W_ extends Ze{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class X_ extends Ze{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class q_ extends Ze{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Kc extends Ze{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class $_ extends Ze{constructor(e,t,n){super(new Int32Array(e),t,n)}}class jc extends Ze{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Y_ extends Ze{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Is(this.array[e*this.itemSize]);return this.normalized&&(t=ln(t,this.array)),t}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize]=Qt(t),this}getY(e){let t=Is(this.array[e*this.itemSize+1]);return this.normalized&&(t=ln(t,this.array)),t}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+1]=Qt(t),this}getZ(e){let t=Is(this.array[e*this.itemSize+2]);return this.normalized&&(t=ln(t,this.array)),t}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+2]=Qt(t),this}getW(e){let t=Is(this.array[e*this.itemSize+3]);return this.normalized&&(t=ln(t,this.array)),t}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+3]=Qt(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array)),this.array[e+0]=Qt(t),this.array[e+1]=Qt(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array)),this.array[e+0]=Qt(t),this.array[e+1]=Qt(n),this.array[e+2]=Qt(i),this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array),s=We(s,this.array)),this.array[e+0]=Qt(t),this.array[e+1]=Qt(n),this.array[e+2]=Qt(i),this.array[e+3]=Qt(s),this}}class ve extends Ze{constructor(e,t,n){super(new Float32Array(e),t,n)}}class Z_ extends Ze{constructor(e,t,n){super(new Float64Array(e),t,n)}}let J_=0;const xn=new Be,Qc=new tt,Pr=new R,hn=new _n,Us=new _n,Ct=new R;class Fe extends Zn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:J_++}),this.uuid=on(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Jf(e)?jc:Kc)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Xe().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return xn.makeRotationFromQuaternion(e),this.applyMatrix4(xn),this}rotateX(e){return xn.makeRotationX(e),this.applyMatrix4(xn),this}rotateY(e){return xn.makeRotationY(e),this.applyMatrix4(xn),this}rotateZ(e){return xn.makeRotationZ(e),this.applyMatrix4(xn),this}translate(e,t,n){return xn.makeTranslation(e,t,n),this.applyMatrix4(xn),this}scale(e,t,n){return xn.makeScale(e,t,n),this.applyMatrix4(xn),this}lookAt(e){return Qc.lookAt(e),Qc.updateMatrix(),this.applyMatrix4(Qc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Pr).negate(),this.translate(Pr.x,Pr.y,Pr.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new ve(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new _n);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new R(-1/0,-1/0,-1/0),new R(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const s=t[n];hn.setFromBufferAttribute(s),this.morphTargetsRelative?(Ct.addVectors(this.boundingBox.min,hn.min),this.boundingBox.expandByPoint(Ct),Ct.addVectors(this.boundingBox.max,hn.max),this.boundingBox.expandByPoint(Ct)):(this.boundingBox.expandByPoint(hn.min),this.boundingBox.expandByPoint(hn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new wn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new R,1/0);return}if(e){const n=this.boundingSphere.center;if(hn.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Us.setFromBufferAttribute(o),this.morphTargetsRelative?(Ct.addVectors(hn.min,Us.min),hn.expandByPoint(Ct),Ct.addVectors(hn.max,Us.max),hn.expandByPoint(Ct)):(hn.expandByPoint(Us.min),hn.expandByPoint(Us.max))}hn.getCenter(n);let i=0;for(let s=0,a=e.count;s<a;s++)Ct.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Ct));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Ct.fromBufferAttribute(o,c),l&&(Pr.fromBufferAttribute(e,c),Ct.add(Pr)),i=Math.max(i,n.distanceToSquared(Ct))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.array,i=t.position.array,s=t.normal.array,a=t.uv.array,o=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ze(new Float32Array(4*o),4));const l=this.getAttribute("tangent").array,c=[],h=[];for(let b=0;b<o;b++)c[b]=new R,h[b]=new R;const u=new R,f=new R,d=new R,p=new q,_=new q,g=new q,m=new R,y=new R;function x(b,L,k){u.fromArray(i,b*3),f.fromArray(i,L*3),d.fromArray(i,k*3),p.fromArray(a,b*2),_.fromArray(a,L*2),g.fromArray(a,k*2),f.sub(u),d.sub(u),_.sub(p),g.sub(p);const U=1/(_.x*g.y-g.x*_.y);isFinite(U)&&(m.copy(f).multiplyScalar(g.y).addScaledVector(d,-_.y).multiplyScalar(U),y.copy(d).multiplyScalar(_.x).addScaledVector(f,-g.x).multiplyScalar(U),c[b].add(m),c[L].add(m),c[k].add(m),h[b].add(y),h[L].add(y),h[k].add(y))}let v=this.groups;v.length===0&&(v=[{start:0,count:n.length}]);for(let b=0,L=v.length;b<L;++b){const k=v[b],U=k.start,N=k.count;for(let I=U,B=U+N;I<B;I+=3)x(n[I+0],n[I+1],n[I+2])}const M=new R,w=new R,A=new R,C=new R;function S(b){A.fromArray(s,b*3),C.copy(A);const L=c[b];M.copy(L),M.sub(A.multiplyScalar(A.dot(L))).normalize(),w.crossVectors(C,L);const U=w.dot(h[b])<0?-1:1;l[b*4]=M.x,l[b*4+1]=M.y,l[b*4+2]=M.z,l[b*4+3]=U}for(let b=0,L=v.length;b<L;++b){const k=v[b],U=k.start,N=k.count;for(let I=U,B=U+N;I<B;I+=3)S(n[I+0]),S(n[I+1]),S(n[I+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Ze(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,d=n.count;f<d;f++)n.setXYZ(f,0,0,0);const i=new R,s=new R,a=new R,o=new R,l=new R,c=new R,h=new R,u=new R;if(e)for(let f=0,d=e.count;f<d;f+=3){const p=e.getX(f+0),_=e.getX(f+1),g=e.getX(f+2);i.fromBufferAttribute(t,p),s.fromBufferAttribute(t,_),a.fromBufferAttribute(t,g),h.subVectors(a,s),u.subVectors(i,s),h.cross(u),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,g),o.add(h),l.add(h),c.add(h),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let f=0,d=t.count;f<d;f+=3)i.fromBufferAttribute(t,f+0),s.fromBufferAttribute(t,f+1),a.fromBufferAttribute(t,f+2),h.subVectors(a,s),u.subVectors(i,s),h.cross(u),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Ct.fromBufferAttribute(e,t),Ct.normalize(),e.setXYZ(t,Ct.x,Ct.y,Ct.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,u=o.normalized,f=new c.constructor(l.length*h);let d=0,p=0;for(let _=0,g=l.length;_<g;_++){o.isInterleavedBufferAttribute?d=l[_]*o.data.stride+o.offset:d=l[_]*h;for(let m=0;m<h;m++)f[p++]=c[d++]}return new Ze(f,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Fe,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,u=c.length;h<u;h++){const f=c[h],d=e(f,n);l.push(d)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>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 n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,f=c.length;u<f;u++){const d=c[u];h.push(d.toJSON(e.data))}h.length>0&&(i[l]=h,s=!0)}s&&(e.data.morphAttributes=i,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={center:o.center.toArray(),radius:o.radius}),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 n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],u=s[c];for(let f=0,d=u.length;f<d;f++)h.push(u[f].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const ld=new Be,Hi=new Er,qa=new wn,cd=new R,Lr=new R,Ir=new R,Ur=new R,eh=new R,$a=new R,Ya=new q,Za=new q,Ja=new q,hd=new R,ud=new R,fd=new R,Ka=new R,ja=new R;class It extends tt{constructor(e=new Fe,t=new Ai){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){$a.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],u=s[l];h!==0&&(eh.fromBufferAttribute(u,e),a?$a.addScaledVector(eh,h):$a.addScaledVector(eh.sub(t),h))}t.add($a)}return t}raycast(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),qa.copy(n.boundingSphere),qa.applyMatrix4(s),Hi.copy(e.ray).recast(e.near),!(qa.containsPoint(Hi.origin)===!1&&(Hi.intersectSphere(qa,cd)===null||Hi.origin.distanceToSquared(cd)>us(e.far-e.near,2)))&&(ld.copy(s).invert(),Hi.copy(e.ray).applyMatrix4(ld),!(n.boundingBox!==null&&Hi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Hi)))}_computeIntersections(e,t,n){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,f=s.groups,d=s.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,_=f.length;p<_;p++){const g=f[p],m=a[g.materialIndex],y=Math.max(g.start,d.start),x=Math.min(o.count,Math.min(g.start+g.count,d.start+d.count));for(let v=y,M=x;v<M;v+=3){const w=o.getX(v),A=o.getX(v+1),C=o.getX(v+2);i=Qa(this,m,e,n,c,h,u,w,A,C),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const p=Math.max(0,d.start),_=Math.min(o.count,d.start+d.count);for(let g=p,m=_;g<m;g+=3){const y=o.getX(g),x=o.getX(g+1),v=o.getX(g+2);i=Qa(this,a,e,n,c,h,u,y,x,v),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let p=0,_=f.length;p<_;p++){const g=f[p],m=a[g.materialIndex],y=Math.max(g.start,d.start),x=Math.min(l.count,Math.min(g.start+g.count,d.start+d.count));for(let v=y,M=x;v<M;v+=3){const w=v,A=v+1,C=v+2;i=Qa(this,m,e,n,c,h,u,w,A,C),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const p=Math.max(0,d.start),_=Math.min(l.count,d.start+d.count);for(let g=p,m=_;g<m;g+=3){const y=g,x=g+1,v=g+2;i=Qa(this,a,e,n,c,h,u,y,x,v),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}}}function K_(r,e,t,n,i,s,a,o){let l;if(e.side===kt?l=n.intersectTriangle(a,s,i,!0,o):l=n.intersectTriangle(i,s,a,e.side===Xn,o),l===null)return null;ja.copy(o),ja.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(ja);return c<t.near||c>t.far?null:{distance:c,point:ja.clone(),object:r}}function Qa(r,e,t,n,i,s,a,o,l,c){r.getVertexPosition(o,Lr),r.getVertexPosition(l,Ir),r.getVertexPosition(c,Ur);const h=K_(r,e,t,n,Lr,Ir,Ur,Ka);if(h){i&&(Ya.fromBufferAttribute(i,o),Za.fromBufferAttribute(i,l),Ja.fromBufferAttribute(i,c),h.uv=jt.getInterpolation(Ka,Lr,Ir,Ur,Ya,Za,Ja,new q)),s&&(Ya.fromBufferAttribute(s,o),Za.fromBufferAttribute(s,l),Ja.fromBufferAttribute(s,c),h.uv1=jt.getInterpolation(Ka,Lr,Ir,Ur,Ya,Za,Ja,new q),h.uv2=h.uv1),a&&(hd.fromBufferAttribute(a,o),ud.fromBufferAttribute(a,l),fd.fromBufferAttribute(a,c),h.normal=jt.getInterpolation(Ka,Lr,Ir,Ur,hd,ud,fd,new R),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new R,materialIndex:0};jt.getNormal(Lr,Ir,Ur,u.normal),h.face=u}return h}class Vi extends Fe{constructor(e=1,t=1,n=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],u=[];let f=0,d=0;p("z","y","x",-1,-1,n,t,e,a,s,0),p("z","y","x",1,-1,n,t,-e,a,s,1),p("x","z","y",1,1,e,n,t,i,a,2),p("x","z","y",1,-1,e,n,-t,i,a,3),p("x","y","z",1,-1,e,t,n,i,s,4),p("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new ve(c,3)),this.setAttribute("normal",new ve(h,3)),this.setAttribute("uv",new ve(u,2));function p(_,g,m,y,x,v,M,w,A,C,S){const b=v/A,L=M/C,k=v/2,U=M/2,N=w/2,I=A+1,B=C+1;let O=0,H=0;const X=new R;for(let ee=0;ee<B;ee++){const z=ee*L-U;for(let Z=0;Z<I;Z++){const le=Z*b-k;X[_]=le*y,X[g]=z*x,X[m]=N,c.push(X.x,X.y,X.z),X[_]=0,X[g]=0,X[m]=w>0?1:-1,h.push(X.x,X.y,X.z),u.push(Z/A),u.push(1-ee/C),O+=1}}for(let ee=0;ee<C;ee++)for(let z=0;z<A;z++){const Z=f+z+I*ee,le=f+z+I*(ee+1),ce=f+(z+1)+I*(ee+1),fe=f+(z+1)+I*ee;l.push(Z,le,fe),l.push(le,ce,fe),H+=6}o.addGroup(d,H,S),d+=H,f+=O}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Dr(r){const e={};for(const t in r){e[t]={};for(const n in r[t]){const i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function Gt(r){const e={};for(let t=0;t<r.length;t++){const n=Dr(r[t]);for(const i in n)e[i]=n[i]}return e}function j_(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function dd(r){return r.getRenderTarget()===null?r.outputColorSpace:Sn}const pd={clone:Dr,merge:Gt};var Q_=`void main() {
6
6
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
7
- }`,Q_=`void main() {
7
+ }`,ex=`void main() {
8
8
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
9
- }`;class zn extends Ft{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=j_,this.fragmentShader=Q_,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!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=Dr(e.uniforms),this.uniformsGroups=K_(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 i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}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 n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class eo extends tt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Be,this.projectionMatrix=new Be,this.projectionMatrixInverse=new Be,this.coordinateSystem=Bn}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){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}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)}}class Ut extends eo{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=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=_r*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Bi*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return _r*2*Math.atan(Math.tan(Bi*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,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=n,this.view.offsetY=i,this.view.width=s,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(Bi*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*i/l,t-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem),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 Nr=-90,Fr=1;class pd extends tt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;const i=new Ut(Nr,Fr,e,t);i.layers=this.layers,this.add(i);const s=new Ut(Nr,Fr,e,t);s.layers=this.layers,this.add(s);const a=new Ut(Nr,Fr,e,t);a.layers=this.layers,this.add(a);const o=new Ut(Nr,Fr,e,t);o.layers=this.layers,this.add(o);const l=new Ut(Nr,Fr,e,t);l.layers=this.layers,this.add(l);const c=new Ut(Nr,Fr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===Bn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),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===ws)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),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 n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[i,s,a,o,l,c]=this.children,h=e.getRenderTarget(),u=e.toneMapping,f=e.xr.enabled;e.toneMapping=Fn,e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,s),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,l),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,c),e.setRenderTarget(h),e.toneMapping=u,e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class Ds extends Mt{constructor(e,t,n,i,s,a,o,l,c,h){e=e!==void 0?e:[],t=t!==void 0?t:pi,super(e,t,n,i,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class md extends bn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];t.encoding!==void 0&&(Ts("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===yi?Ge:Mi),this.texture=new Ds(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:vt}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 n={uniforms:{tEquirect:{value:null}},vertexShader:`
9
+ }`;class zn extends Ft{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Q_,this.fragmentShader=ex,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!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=Dr(e.uniforms),this.uniformsGroups=j_(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 i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}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 n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class eo extends tt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Be,this.projectionMatrix=new Be,this.projectionMatrixInverse=new Be,this.coordinateSystem=Bn}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){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}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)}}class Ut extends eo{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=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=_r*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Bi*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return _r*2*Math.atan(Math.tan(Bi*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,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=n,this.view.offsetY=i,this.view.width=s,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(Bi*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*i/l,t-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem),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 Nr=-90,Fr=1;class md extends tt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;const i=new Ut(Nr,Fr,e,t);i.layers=this.layers,this.add(i);const s=new Ut(Nr,Fr,e,t);s.layers=this.layers,this.add(s);const a=new Ut(Nr,Fr,e,t);a.layers=this.layers,this.add(a);const o=new Ut(Nr,Fr,e,t);o.layers=this.layers,this.add(o);const l=new Ut(Nr,Fr,e,t);l.layers=this.layers,this.add(l);const c=new Ut(Nr,Fr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===Bn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),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===ws)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),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 n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[i,s,a,o,l,c]=this.children,h=e.getRenderTarget(),u=e.toneMapping,f=e.xr.enabled;e.toneMapping=Fn,e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,s),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,l),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,c),e.setRenderTarget(h),e.toneMapping=u,e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class Ds extends Mt{constructor(e,t,n,i,s,a,o,l,c,h){e=e!==void 0?e:[],t=t!==void 0?t:pi,super(e,t,n,i,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class gd extends bn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];t.encoding!==void 0&&(Ts("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===yi?Ge:Mi),this.texture=new Ds(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:vt}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 n={uniforms:{tEquirect:{value:null}},vertexShader:`
10
10
 
11
11
  varying vec3 vWorldDirection;
12
12
 
@@ -41,9 +41,9 @@ var gA=Object.defineProperty,_A=Object.defineProperties;var xA=Object.getOwnProp
41
41
  gl_FragColor = texture2D( tEquirect, sampleUV );
42
42
 
43
43
  }
44
- `},i=new Vi(5,5,5),s=new zn({name:"CubemapFromEquirect",uniforms:Dr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:kt,blending:qn});s.uniforms.tEquirect.value=t;const a=new It(i,s),o=t.minFilter;return t.minFilter===gi&&(t.minFilter=vt),new pd(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(s)}}const th=new R,ex=new R,tx=new Xe;class Ti{constructor(e=new R(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=th.subVectors(n,t).cross(ex.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(th),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||tx.getNormalMatrix(e),i=this.coplanarPoint(th).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Wi=new wn,to=new R;class no{constructor(e=new Ti,t=new Ti,n=new Ti,i=new Ti,s=new Ti,a=new Ti){this.planes=[e,t,n,i,s,a]}set(e,t,n,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Bn){const n=this.planes,i=e.elements,s=i[0],a=i[1],o=i[2],l=i[3],c=i[4],h=i[5],u=i[6],f=i[7],d=i[8],p=i[9],_=i[10],g=i[11],m=i[12],y=i[13],x=i[14],v=i[15];if(n[0].setComponents(l-s,f-c,g-d,v-m).normalize(),n[1].setComponents(l+s,f+c,g+d,v+m).normalize(),n[2].setComponents(l+a,f+h,g+p,v+y).normalize(),n[3].setComponents(l-a,f-h,g-p,v-y).normalize(),n[4].setComponents(l-o,f-u,g-_,v-x).normalize(),t===Bn)n[5].setComponents(l+o,f+u,g+_,v+x).normalize();else if(t===ws)n[5].setComponents(o,u,_,x).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(),Wi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Wi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Wi)}intersectsSprite(e){return Wi.center.set(0,0,0),Wi.radius=.7071067811865476,Wi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Wi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(to.x=i.normal.x>0?e.max.x:e.min.x,to.y=i.normal.y>0?e.max.y:e.min.y,to.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(to)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function gd(){let r=null,e=!1,t=null,n=null;function i(s,a){t(s,a),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function nx(r,e){const t=e.isWebGL2,n=new WeakMap;function i(c,h){const u=c.array,f=c.usage,d=r.createBuffer();r.bindBuffer(h,d),r.bufferData(h,u,f),c.onUploadCallback();let p;if(u instanceof Float32Array)p=r.FLOAT;else if(u instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(t)p=r.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else p=r.UNSIGNED_SHORT;else if(u instanceof Int16Array)p=r.SHORT;else if(u instanceof Uint32Array)p=r.UNSIGNED_INT;else if(u instanceof Int32Array)p=r.INT;else if(u instanceof Int8Array)p=r.BYTE;else if(u instanceof Uint8Array)p=r.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)p=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:d,type:p,bytesPerElement:u.BYTES_PER_ELEMENT,version:c.version}}function s(c,h,u){const f=h.array,d=h.updateRange;r.bindBuffer(u,c),d.count===-1?r.bufferSubData(u,0,f):(t?r.bufferSubData(u,d.offset*f.BYTES_PER_ELEMENT,f,d.offset,d.count):r.bufferSubData(u,d.offset*f.BYTES_PER_ELEMENT,f.subarray(d.offset,d.offset+d.count)),d.count=-1),h.onUploadCallback()}function a(c){return c.isInterleavedBufferAttribute&&(c=c.data),n.get(c)}function o(c){c.isInterleavedBufferAttribute&&(c=c.data);const h=n.get(c);h&&(r.deleteBuffer(h.buffer),n.delete(c))}function l(c,h){if(c.isGLBufferAttribute){const f=n.get(c);(!f||f.version<c.version)&&n.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);const u=n.get(c);u===void 0?n.set(c,i(c,h)):u.version<c.version&&(s(u.buffer,c,h),u.version=c.version)}return{get:a,remove:o,update:l}}class Ns extends Fe{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(i),c=o+1,h=l+1,u=e/o,f=t/l,d=[],p=[],_=[],g=[];for(let m=0;m<h;m++){const y=m*f-a;for(let x=0;x<c;x++){const v=x*u-s;p.push(v,-y,0),_.push(0,0,1),g.push(x/o),g.push(1-m/l)}}for(let m=0;m<l;m++)for(let y=0;y<o;y++){const x=y+c*m,v=y+c*(m+1),M=y+1+c*(m+1),w=y+1+c*m;d.push(x,v,w),d.push(v,M,w)}this.setIndex(d),this.setAttribute("position",new ve(p,3)),this.setAttribute("normal",new ve(_,3)),this.setAttribute("uv",new ve(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ns(e.width,e.height,e.widthSegments,e.heightSegments)}}var ix=`#ifdef USE_ALPHAHASH
44
+ `},i=new Vi(5,5,5),s=new zn({name:"CubemapFromEquirect",uniforms:Dr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:kt,blending:qn});s.uniforms.tEquirect.value=t;const a=new It(i,s),o=t.minFilter;return t.minFilter===gi&&(t.minFilter=vt),new md(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(s)}}const th=new R,tx=new R,nx=new Xe;class Ti{constructor(e=new R(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=th.subVectors(n,t).cross(tx.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(th),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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 n=t||nx.getNormalMatrix(e),i=this.coplanarPoint(th).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Wi=new wn,to=new R;class no{constructor(e=new Ti,t=new Ti,n=new Ti,i=new Ti,s=new Ti,a=new Ti){this.planes=[e,t,n,i,s,a]}set(e,t,n,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Bn){const n=this.planes,i=e.elements,s=i[0],a=i[1],o=i[2],l=i[3],c=i[4],h=i[5],u=i[6],f=i[7],d=i[8],p=i[9],_=i[10],g=i[11],m=i[12],y=i[13],x=i[14],v=i[15];if(n[0].setComponents(l-s,f-c,g-d,v-m).normalize(),n[1].setComponents(l+s,f+c,g+d,v+m).normalize(),n[2].setComponents(l+a,f+h,g+p,v+y).normalize(),n[3].setComponents(l-a,f-h,g-p,v-y).normalize(),n[4].setComponents(l-o,f-u,g-_,v-x).normalize(),t===Bn)n[5].setComponents(l+o,f+u,g+_,v+x).normalize();else if(t===ws)n[5].setComponents(o,u,_,x).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(),Wi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Wi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Wi)}intersectsSprite(e){return Wi.center.set(0,0,0),Wi.radius=.7071067811865476,Wi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Wi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(to.x=i.normal.x>0?e.max.x:e.min.x,to.y=i.normal.y>0?e.max.y:e.min.y,to.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(to)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function _d(){let r=null,e=!1,t=null,n=null;function i(s,a){t(s,a),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function ix(r,e){const t=e.isWebGL2,n=new WeakMap;function i(c,h){const u=c.array,f=c.usage,d=r.createBuffer();r.bindBuffer(h,d),r.bufferData(h,u,f),c.onUploadCallback();let p;if(u instanceof Float32Array)p=r.FLOAT;else if(u instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(t)p=r.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else p=r.UNSIGNED_SHORT;else if(u instanceof Int16Array)p=r.SHORT;else if(u instanceof Uint32Array)p=r.UNSIGNED_INT;else if(u instanceof Int32Array)p=r.INT;else if(u instanceof Int8Array)p=r.BYTE;else if(u instanceof Uint8Array)p=r.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)p=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:d,type:p,bytesPerElement:u.BYTES_PER_ELEMENT,version:c.version}}function s(c,h,u){const f=h.array,d=h.updateRange;r.bindBuffer(u,c),d.count===-1?r.bufferSubData(u,0,f):(t?r.bufferSubData(u,d.offset*f.BYTES_PER_ELEMENT,f,d.offset,d.count):r.bufferSubData(u,d.offset*f.BYTES_PER_ELEMENT,f.subarray(d.offset,d.offset+d.count)),d.count=-1),h.onUploadCallback()}function a(c){return c.isInterleavedBufferAttribute&&(c=c.data),n.get(c)}function o(c){c.isInterleavedBufferAttribute&&(c=c.data);const h=n.get(c);h&&(r.deleteBuffer(h.buffer),n.delete(c))}function l(c,h){if(c.isGLBufferAttribute){const f=n.get(c);(!f||f.version<c.version)&&n.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);const u=n.get(c);u===void 0?n.set(c,i(c,h)):u.version<c.version&&(s(u.buffer,c,h),u.version=c.version)}return{get:a,remove:o,update:l}}class Ns extends Fe{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(i),c=o+1,h=l+1,u=e/o,f=t/l,d=[],p=[],_=[],g=[];for(let m=0;m<h;m++){const y=m*f-a;for(let x=0;x<c;x++){const v=x*u-s;p.push(v,-y,0),_.push(0,0,1),g.push(x/o),g.push(1-m/l)}}for(let m=0;m<l;m++)for(let y=0;y<o;y++){const x=y+c*m,v=y+c*(m+1),M=y+1+c*(m+1),w=y+1+c*m;d.push(x,v,w),d.push(v,M,w)}this.setIndex(d),this.setAttribute("position",new ve(p,3)),this.setAttribute("normal",new ve(_,3)),this.setAttribute("uv",new ve(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ns(e.width,e.height,e.widthSegments,e.heightSegments)}}var rx=`#ifdef USE_ALPHAHASH
45
45
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
46
- #endif`,rx=`#ifdef USE_ALPHAHASH
46
+ #endif`,sx=`#ifdef USE_ALPHAHASH
47
47
  const float ALPHA_HASH_SCALE = 0.05;
48
48
  float hash2D( vec2 value ) {
49
49
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -78,31 +78,31 @@ var gA=Object.defineProperty,_A=Object.defineProperties;var xA=Object.getOwnProp
78
78
  : cases.z;
79
79
  return clamp( threshold , 1.0e-6, 1.0 );
80
80
  }
81
- #endif`,sx=`#ifdef USE_ALPHAMAP
82
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
83
81
  #endif`,ax=`#ifdef USE_ALPHAMAP
82
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
83
+ #endif`,ox=`#ifdef USE_ALPHAMAP
84
84
  uniform sampler2D alphaMap;
85
- #endif`,ox=`#ifdef USE_ALPHATEST
86
- if ( diffuseColor.a < alphaTest ) discard;
87
85
  #endif`,lx=`#ifdef USE_ALPHATEST
86
+ if ( diffuseColor.a < alphaTest ) discard;
87
+ #endif`,cx=`#ifdef USE_ALPHATEST
88
88
  uniform float alphaTest;
89
- #endif`,cx=`#ifdef USE_AOMAP
89
+ #endif`,hx=`#ifdef USE_AOMAP
90
90
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
91
91
  reflectedLight.indirectDiffuse *= ambientOcclusion;
92
92
  #if defined( USE_ENVMAP ) && defined( STANDARD )
93
93
  float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
94
94
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
95
95
  #endif
96
- #endif`,hx=`#ifdef USE_AOMAP
96
+ #endif`,ux=`#ifdef USE_AOMAP
97
97
  uniform sampler2D aoMap;
98
98
  uniform float aoMapIntensity;
99
- #endif`,ux=`vec3 transformed = vec3( position );
99
+ #endif`,fx=`vec3 transformed = vec3( position );
100
100
  #ifdef USE_ALPHAHASH
101
101
  vPosition = vec3( position );
102
- #endif`,fx=`vec3 objectNormal = vec3( normal );
102
+ #endif`,dx=`vec3 objectNormal = vec3( normal );
103
103
  #ifdef USE_TANGENT
104
104
  vec3 objectTangent = vec3( tangent.xyz );
105
- #endif`,dx=`float G_BlinnPhong_Implicit( ) {
105
+ #endif`,px=`float G_BlinnPhong_Implicit( ) {
106
106
  return 0.25;
107
107
  }
108
108
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -116,7 +116,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
116
116
  float G = G_BlinnPhong_Implicit( );
117
117
  float D = D_BlinnPhong( shininess, dotNH );
118
118
  return F * ( G * D );
119
- } // validated`,px=`#ifdef USE_IRIDESCENCE
119
+ } // validated`,mx=`#ifdef USE_IRIDESCENCE
120
120
  const mat3 XYZ_TO_REC709 = mat3(
121
121
  3.2404542, -0.9692660, 0.0556434,
122
122
  -1.5371385, 1.8760108, -0.2040259,
@@ -180,7 +180,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
180
180
  }
181
181
  return max( I, vec3( 0.0 ) );
182
182
  }
183
- #endif`,mx=`#ifdef USE_BUMPMAP
183
+ #endif`,gx=`#ifdef USE_BUMPMAP
184
184
  uniform sampler2D bumpMap;
185
185
  uniform float bumpScale;
186
186
  vec2 dHdxy_fwd() {
@@ -201,7 +201,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
201
201
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
202
202
  return normalize( abs( fDet ) * surf_norm - vGrad );
203
203
  }
204
- #endif`,gx=`#if NUM_CLIPPING_PLANES > 0
204
+ #endif`,_x=`#if NUM_CLIPPING_PLANES > 0
205
205
  vec4 plane;
206
206
  #pragma unroll_loop_start
207
207
  for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
@@ -219,26 +219,26 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
219
219
  #pragma unroll_loop_end
220
220
  if ( clipped ) discard;
221
221
  #endif
222
- #endif`,_x=`#if NUM_CLIPPING_PLANES > 0
223
- varying vec3 vClipPosition;
224
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
225
222
  #endif`,xx=`#if NUM_CLIPPING_PLANES > 0
226
223
  varying vec3 vClipPosition;
224
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
227
225
  #endif`,yx=`#if NUM_CLIPPING_PLANES > 0
226
+ varying vec3 vClipPosition;
227
+ #endif`,vx=`#if NUM_CLIPPING_PLANES > 0
228
228
  vClipPosition = - mvPosition.xyz;
229
- #endif`,vx=`#if defined( USE_COLOR_ALPHA )
229
+ #endif`,Mx=`#if defined( USE_COLOR_ALPHA )
230
230
  diffuseColor *= vColor;
231
231
  #elif defined( USE_COLOR )
232
232
  diffuseColor.rgb *= vColor;
233
- #endif`,Mx=`#if defined( USE_COLOR_ALPHA )
233
+ #endif`,Sx=`#if defined( USE_COLOR_ALPHA )
234
234
  varying vec4 vColor;
235
235
  #elif defined( USE_COLOR )
236
236
  varying vec3 vColor;
237
- #endif`,Sx=`#if defined( USE_COLOR_ALPHA )
237
+ #endif`,bx=`#if defined( USE_COLOR_ALPHA )
238
238
  varying vec4 vColor;
239
239
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
240
240
  varying vec3 vColor;
241
- #endif`,bx=`#if defined( USE_COLOR_ALPHA )
241
+ #endif`,wx=`#if defined( USE_COLOR_ALPHA )
242
242
  vColor = vec4( 1.0 );
243
243
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
244
244
  vColor = vec3( 1.0 );
@@ -248,7 +248,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
248
248
  #endif
249
249
  #ifdef USE_INSTANCING_COLOR
250
250
  vColor.xyz *= instanceColor.xyz;
251
- #endif`,wx=`#define PI 3.141592653589793
251
+ #endif`,Ex=`#define PI 3.141592653589793
252
252
  #define PI2 6.283185307179586
253
253
  #define PI_HALF 1.5707963267948966
254
254
  #define RECIPROCAL_PI 0.3183098861837907
@@ -334,7 +334,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
334
334
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
335
335
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
336
336
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
337
- } // validated`,Ex=`#ifdef ENVMAP_TYPE_CUBE_UV
337
+ } // validated`,Ax=`#ifdef ENVMAP_TYPE_CUBE_UV
338
338
  #define cubeUV_minMipLevel 4.0
339
339
  #define cubeUV_minTileSize 16.0
340
340
  float getFace( vec3 direction ) {
@@ -432,7 +432,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
432
432
  return vec4( mix( color0, color1, mipF ), 1.0 );
433
433
  }
434
434
  }
435
- #endif`,Ax=`vec3 transformedNormal = objectNormal;
435
+ #endif`,Tx=`vec3 transformedNormal = objectNormal;
436
436
  #ifdef USE_INSTANCING
437
437
  mat3 m = mat3( instanceMatrix );
438
438
  transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
@@ -447,23 +447,23 @@ transformedNormal = normalMatrix * transformedNormal;
447
447
  #ifdef FLIP_SIDED
448
448
  transformedTangent = - transformedTangent;
449
449
  #endif
450
- #endif`,Tx=`#ifdef USE_DISPLACEMENTMAP
450
+ #endif`,Rx=`#ifdef USE_DISPLACEMENTMAP
451
451
  uniform sampler2D displacementMap;
452
452
  uniform float displacementScale;
453
453
  uniform float displacementBias;
454
- #endif`,Rx=`#ifdef USE_DISPLACEMENTMAP
454
+ #endif`,Cx=`#ifdef USE_DISPLACEMENTMAP
455
455
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
456
- #endif`,Cx=`#ifdef USE_EMISSIVEMAP
456
+ #endif`,Px=`#ifdef USE_EMISSIVEMAP
457
457
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
458
458
  totalEmissiveRadiance *= emissiveColor.rgb;
459
- #endif`,Px=`#ifdef USE_EMISSIVEMAP
459
+ #endif`,Lx=`#ifdef USE_EMISSIVEMAP
460
460
  uniform sampler2D emissiveMap;
461
- #endif`,Lx="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ix=`vec4 LinearToLinear( in vec4 value ) {
461
+ #endif`,Ix="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ux=`vec4 LinearToLinear( in vec4 value ) {
462
462
  return value;
463
463
  }
464
464
  vec4 LinearTosRGB( in vec4 value ) {
465
465
  return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
466
- }`,Ux=`#ifdef USE_ENVMAP
466
+ }`,Dx=`#ifdef USE_ENVMAP
467
467
  #ifdef ENV_WORLDPOS
468
468
  vec3 cameraToFrag;
469
469
  if ( isOrthographic ) {
@@ -492,7 +492,7 @@ vec4 LinearTosRGB( in vec4 value ) {
492
492
  #elif defined( ENVMAP_BLENDING_ADD )
493
493
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
494
494
  #endif
495
- #endif`,Dx=`#ifdef USE_ENVMAP
495
+ #endif`,Nx=`#ifdef USE_ENVMAP
496
496
  uniform float envMapIntensity;
497
497
  uniform float flipEnvMap;
498
498
  #ifdef ENVMAP_TYPE_CUBE
@@ -501,7 +501,7 @@ vec4 LinearTosRGB( in vec4 value ) {
501
501
  uniform sampler2D envMap;
502
502
  #endif
503
503
 
504
- #endif`,Nx=`#ifdef USE_ENVMAP
504
+ #endif`,Fx=`#ifdef USE_ENVMAP
505
505
  uniform float reflectivity;
506
506
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
507
507
  #define ENV_WORLDPOS
@@ -512,7 +512,7 @@ vec4 LinearTosRGB( in vec4 value ) {
512
512
  #else
513
513
  varying vec3 vReflect;
514
514
  #endif
515
- #endif`,Fx=`#ifdef USE_ENVMAP
515
+ #endif`,Ox=`#ifdef USE_ENVMAP
516
516
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
517
517
  #define ENV_WORLDPOS
518
518
  #endif
@@ -523,7 +523,7 @@ vec4 LinearTosRGB( in vec4 value ) {
523
523
  varying vec3 vReflect;
524
524
  uniform float refractionRatio;
525
525
  #endif
526
- #endif`,Ox=`#ifdef USE_ENVMAP
526
+ #endif`,Bx=`#ifdef USE_ENVMAP
527
527
  #ifdef ENV_WORLDPOS
528
528
  vWorldPosition = worldPosition.xyz;
529
529
  #else
@@ -540,18 +540,18 @@ vec4 LinearTosRGB( in vec4 value ) {
540
540
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
541
541
  #endif
542
542
  #endif
543
- #endif`,Bx=`#ifdef USE_FOG
544
- vFogDepth = - mvPosition.z;
545
543
  #endif`,zx=`#ifdef USE_FOG
546
- varying float vFogDepth;
544
+ vFogDepth = - mvPosition.z;
547
545
  #endif`,kx=`#ifdef USE_FOG
546
+ varying float vFogDepth;
547
+ #endif`,Gx=`#ifdef USE_FOG
548
548
  #ifdef FOG_EXP2
549
549
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
550
550
  #else
551
551
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
552
552
  #endif
553
553
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
554
- #endif`,Gx=`#ifdef USE_FOG
554
+ #endif`,Hx=`#ifdef USE_FOG
555
555
  uniform vec3 fogColor;
556
556
  varying float vFogDepth;
557
557
  #ifdef FOG_EXP2
@@ -560,7 +560,7 @@ vec4 LinearTosRGB( in vec4 value ) {
560
560
  uniform float fogNear;
561
561
  uniform float fogFar;
562
562
  #endif
563
- #endif`,Hx=`#ifdef USE_GRADIENTMAP
563
+ #endif`,Vx=`#ifdef USE_GRADIENTMAP
564
564
  uniform sampler2D gradientMap;
565
565
  #endif
566
566
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -572,16 +572,16 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
572
572
  vec2 fw = fwidth( coord ) * 0.5;
573
573
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
574
574
  #endif
575
- }`,Vx=`#ifdef USE_LIGHTMAP
575
+ }`,Wx=`#ifdef USE_LIGHTMAP
576
576
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
577
577
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
578
578
  reflectedLight.indirectDiffuse += lightMapIrradiance;
579
- #endif`,Wx=`#ifdef USE_LIGHTMAP
579
+ #endif`,Xx=`#ifdef USE_LIGHTMAP
580
580
  uniform sampler2D lightMap;
581
581
  uniform float lightMapIntensity;
582
- #endif`,Xx=`LambertMaterial material;
582
+ #endif`,qx=`LambertMaterial material;
583
583
  material.diffuseColor = diffuseColor.rgb;
584
- material.specularStrength = specularStrength;`,qx=`varying vec3 vViewPosition;
584
+ material.specularStrength = specularStrength;`,$x=`varying vec3 vViewPosition;
585
585
  struct LambertMaterial {
586
586
  vec3 diffuseColor;
587
587
  float specularStrength;
@@ -595,7 +595,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricCon
595
595
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
596
596
  }
597
597
  #define RE_Direct RE_Direct_Lambert
598
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,$x=`uniform bool receiveShadow;
598
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Yx=`uniform bool receiveShadow;
599
599
  uniform vec3 ambientLightColor;
600
600
  uniform vec3 lightProbe[ 9 ];
601
601
  vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
@@ -716,7 +716,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
716
716
  vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
717
717
  return irradiance;
718
718
  }
719
- #endif`,Yx=`#ifdef USE_ENVMAP
719
+ #endif`,Zx=`#ifdef USE_ENVMAP
720
720
  vec3 getIBLIrradiance( const in vec3 normal ) {
721
721
  #ifdef ENVMAP_TYPE_CUBE_UV
722
722
  vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
@@ -749,8 +749,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
749
749
  #endif
750
750
  }
751
751
  #endif
752
- #endif`,Zx=`ToonMaterial material;
753
- material.diffuseColor = diffuseColor.rgb;`,Jx=`varying vec3 vViewPosition;
752
+ #endif`,Jx=`ToonMaterial material;
753
+ material.diffuseColor = diffuseColor.rgb;`,Kx=`varying vec3 vViewPosition;
754
754
  struct ToonMaterial {
755
755
  vec3 diffuseColor;
756
756
  };
@@ -762,11 +762,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContex
762
762
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
763
763
  }
764
764
  #define RE_Direct RE_Direct_Toon
765
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Kx=`BlinnPhongMaterial material;
765
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,jx=`BlinnPhongMaterial material;
766
766
  material.diffuseColor = diffuseColor.rgb;
767
767
  material.specularColor = specular;
768
768
  material.specularShininess = shininess;
769
- material.specularStrength = specularStrength;`,jx=`varying vec3 vViewPosition;
769
+ material.specularStrength = specularStrength;`,Qx=`varying vec3 vViewPosition;
770
770
  struct BlinnPhongMaterial {
771
771
  vec3 diffuseColor;
772
772
  vec3 specularColor;
@@ -783,7 +783,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in Geometric
783
783
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
784
784
  }
785
785
  #define RE_Direct RE_Direct_BlinnPhong
786
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Qx=`PhysicalMaterial material;
786
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ey=`PhysicalMaterial material;
787
787
  material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
788
788
  vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
789
789
  float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
@@ -862,7 +862,7 @@ material.roughness = min( material.roughness, 1.0 );
862
862
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
863
863
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;
864
864
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;
865
- #endif`,ey=`struct PhysicalMaterial {
865
+ #endif`,ty=`struct PhysicalMaterial {
866
866
  vec3 diffuseColor;
867
867
  float roughness;
868
868
  vec3 specularColor;
@@ -1160,7 +1160,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1160
1160
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1161
1161
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1162
1162
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1163
- }`,ty=`
1163
+ }`,ny=`
1164
1164
  GeometricContext geometry;
1165
1165
  geometry.position = - vViewPosition;
1166
1166
  geometry.normal = normal;
@@ -1273,7 +1273,7 @@ IncidentLight directLight;
1273
1273
  #if defined( RE_IndirectSpecular )
1274
1274
  vec3 radiance = vec3( 0.0 );
1275
1275
  vec3 clearcoatRadiance = vec3( 0.0 );
1276
- #endif`,ny=`#if defined( RE_IndirectDiffuse )
1276
+ #endif`,iy=`#if defined( RE_IndirectDiffuse )
1277
1277
  #ifdef USE_LIGHTMAP
1278
1278
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1279
1279
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1292,25 +1292,25 @@ IncidentLight directLight;
1292
1292
  #ifdef USE_CLEARCOAT
1293
1293
  clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
1294
1294
  #endif
1295
- #endif`,iy=`#if defined( RE_IndirectDiffuse )
1295
+ #endif`,ry=`#if defined( RE_IndirectDiffuse )
1296
1296
  RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
1297
1297
  #endif
1298
1298
  #if defined( RE_IndirectSpecular )
1299
1299
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
1300
- #endif`,ry=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
1301
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1302
1300
  #endif`,sy=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
1301
+ gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1302
+ #endif`,ay=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
1303
1303
  uniform float logDepthBufFC;
1304
1304
  varying float vFragDepth;
1305
1305
  varying float vIsPerspective;
1306
- #endif`,ay=`#ifdef USE_LOGDEPTHBUF
1306
+ #endif`,oy=`#ifdef USE_LOGDEPTHBUF
1307
1307
  #ifdef USE_LOGDEPTHBUF_EXT
1308
1308
  varying float vFragDepth;
1309
1309
  varying float vIsPerspective;
1310
1310
  #else
1311
1311
  uniform float logDepthBufFC;
1312
1312
  #endif
1313
- #endif`,oy=`#ifdef USE_LOGDEPTHBUF
1313
+ #endif`,ly=`#ifdef USE_LOGDEPTHBUF
1314
1314
  #ifdef USE_LOGDEPTHBUF_EXT
1315
1315
  vFragDepth = 1.0 + gl_Position.w;
1316
1316
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
@@ -1320,11 +1320,11 @@ IncidentLight directLight;
1320
1320
  gl_Position.z *= gl_Position.w;
1321
1321
  }
1322
1322
  #endif
1323
- #endif`,ly=`#ifdef USE_MAP
1324
- diffuseColor *= texture2D( map, vMapUv );
1325
1323
  #endif`,cy=`#ifdef USE_MAP
1324
+ diffuseColor *= texture2D( map, vMapUv );
1325
+ #endif`,hy=`#ifdef USE_MAP
1326
1326
  uniform sampler2D map;
1327
- #endif`,hy=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1327
+ #endif`,uy=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1328
1328
  #if defined( USE_POINTS_UV )
1329
1329
  vec2 uv = vUv;
1330
1330
  #else
@@ -1336,7 +1336,7 @@ IncidentLight directLight;
1336
1336
  #endif
1337
1337
  #ifdef USE_ALPHAMAP
1338
1338
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1339
- #endif`,uy=`#if defined( USE_POINTS_UV )
1339
+ #endif`,fy=`#if defined( USE_POINTS_UV )
1340
1340
  varying vec2 vUv;
1341
1341
  #else
1342
1342
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1348,13 +1348,13 @@ IncidentLight directLight;
1348
1348
  #endif
1349
1349
  #ifdef USE_ALPHAMAP
1350
1350
  uniform sampler2D alphaMap;
1351
- #endif`,fy=`float metalnessFactor = metalness;
1351
+ #endif`,dy=`float metalnessFactor = metalness;
1352
1352
  #ifdef USE_METALNESSMAP
1353
1353
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1354
1354
  metalnessFactor *= texelMetalness.b;
1355
- #endif`,dy=`#ifdef USE_METALNESSMAP
1355
+ #endif`,py=`#ifdef USE_METALNESSMAP
1356
1356
  uniform sampler2D metalnessMap;
1357
- #endif`,py=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
1357
+ #endif`,my=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
1358
1358
  vColor *= morphTargetBaseInfluence;
1359
1359
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1360
1360
  #if defined( USE_COLOR_ALPHA )
@@ -1363,7 +1363,7 @@ IncidentLight directLight;
1363
1363
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1364
1364
  #endif
1365
1365
  }
1366
- #endif`,my=`#ifdef USE_MORPHNORMALS
1366
+ #endif`,gy=`#ifdef USE_MORPHNORMALS
1367
1367
  objectNormal *= morphTargetBaseInfluence;
1368
1368
  #ifdef MORPHTARGETS_TEXTURE
1369
1369
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
@@ -1375,7 +1375,7 @@ IncidentLight directLight;
1375
1375
  objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
1376
1376
  objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
1377
1377
  #endif
1378
- #endif`,gy=`#ifdef USE_MORPHTARGETS
1378
+ #endif`,_y=`#ifdef USE_MORPHTARGETS
1379
1379
  uniform float morphTargetBaseInfluence;
1380
1380
  #ifdef MORPHTARGETS_TEXTURE
1381
1381
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1395,7 +1395,7 @@ IncidentLight directLight;
1395
1395
  uniform float morphTargetInfluences[ 4 ];
1396
1396
  #endif
1397
1397
  #endif
1398
- #endif`,_y=`#ifdef USE_MORPHTARGETS
1398
+ #endif`,xy=`#ifdef USE_MORPHTARGETS
1399
1399
  transformed *= morphTargetBaseInfluence;
1400
1400
  #ifdef MORPHTARGETS_TEXTURE
1401
1401
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
@@ -1413,7 +1413,7 @@ IncidentLight directLight;
1413
1413
  transformed += morphTarget7 * morphTargetInfluences[ 7 ];
1414
1414
  #endif
1415
1415
  #endif
1416
- #endif`,xy=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1416
+ #endif`,yy=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1417
1417
  #ifdef FLAT_SHADED
1418
1418
  vec3 fdx = dFdx( vViewPosition );
1419
1419
  vec3 fdy = dFdy( vViewPosition );
@@ -1454,7 +1454,7 @@ IncidentLight directLight;
1454
1454
  tbn2[1] *= faceDirection;
1455
1455
  #endif
1456
1456
  #endif
1457
- vec3 geometryNormal = normal;`,yy=`#ifdef USE_NORMALMAP_OBJECTSPACE
1457
+ vec3 geometryNormal = normal;`,vy=`#ifdef USE_NORMALMAP_OBJECTSPACE
1458
1458
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1459
1459
  #ifdef FLIP_SIDED
1460
1460
  normal = - normal;
@@ -1469,25 +1469,25 @@ vec3 geometryNormal = normal;`,yy=`#ifdef USE_NORMALMAP_OBJECTSPACE
1469
1469
  normal = normalize( tbn * mapN );
1470
1470
  #elif defined( USE_BUMPMAP )
1471
1471
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1472
- #endif`,vy=`#ifndef FLAT_SHADED
1472
+ #endif`,My=`#ifndef FLAT_SHADED
1473
1473
  varying vec3 vNormal;
1474
1474
  #ifdef USE_TANGENT
1475
1475
  varying vec3 vTangent;
1476
1476
  varying vec3 vBitangent;
1477
1477
  #endif
1478
- #endif`,My=`#ifndef FLAT_SHADED
1478
+ #endif`,Sy=`#ifndef FLAT_SHADED
1479
1479
  varying vec3 vNormal;
1480
1480
  #ifdef USE_TANGENT
1481
1481
  varying vec3 vTangent;
1482
1482
  varying vec3 vBitangent;
1483
1483
  #endif
1484
- #endif`,Sy=`#ifndef FLAT_SHADED
1484
+ #endif`,by=`#ifndef FLAT_SHADED
1485
1485
  vNormal = normalize( transformedNormal );
1486
1486
  #ifdef USE_TANGENT
1487
1487
  vTangent = normalize( transformedTangent );
1488
1488
  vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1489
1489
  #endif
1490
- #endif`,by=`#ifdef USE_NORMALMAP
1490
+ #endif`,wy=`#ifdef USE_NORMALMAP
1491
1491
  uniform sampler2D normalMap;
1492
1492
  uniform vec2 normalScale;
1493
1493
  #endif
@@ -1509,13 +1509,13 @@ vec3 geometryNormal = normal;`,yy=`#ifdef USE_NORMALMAP_OBJECTSPACE
1509
1509
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1510
1510
  return mat3( T * scale, B * scale, N );
1511
1511
  }
1512
- #endif`,wy=`#ifdef USE_CLEARCOAT
1512
+ #endif`,Ey=`#ifdef USE_CLEARCOAT
1513
1513
  vec3 clearcoatNormal = geometryNormal;
1514
- #endif`,Ey=`#ifdef USE_CLEARCOAT_NORMALMAP
1514
+ #endif`,Ay=`#ifdef USE_CLEARCOAT_NORMALMAP
1515
1515
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1516
1516
  clearcoatMapN.xy *= clearcoatNormalScale;
1517
1517
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1518
- #endif`,Ay=`#ifdef USE_CLEARCOATMAP
1518
+ #endif`,Ty=`#ifdef USE_CLEARCOATMAP
1519
1519
  uniform sampler2D clearcoatMap;
1520
1520
  #endif
1521
1521
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1524,18 +1524,18 @@ vec3 geometryNormal = normal;`,yy=`#ifdef USE_NORMALMAP_OBJECTSPACE
1524
1524
  #endif
1525
1525
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1526
1526
  uniform sampler2D clearcoatRoughnessMap;
1527
- #endif`,Ty=`#ifdef USE_IRIDESCENCEMAP
1527
+ #endif`,Ry=`#ifdef USE_IRIDESCENCEMAP
1528
1528
  uniform sampler2D iridescenceMap;
1529
1529
  #endif
1530
1530
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1531
1531
  uniform sampler2D iridescenceThicknessMap;
1532
- #endif`,Ry=`#ifdef OPAQUE
1532
+ #endif`,Cy=`#ifdef OPAQUE
1533
1533
  diffuseColor.a = 1.0;
1534
1534
  #endif
1535
1535
  #ifdef USE_TRANSMISSION
1536
1536
  diffuseColor.a *= material.transmissionAlpha;
1537
1537
  #endif
1538
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Cy=`vec3 packNormalToRGB( const in vec3 normal ) {
1538
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Py=`vec3 packNormalToRGB( const in vec3 normal ) {
1539
1539
  return normalize( normal ) * 0.5 + 0.5;
1540
1540
  }
1541
1541
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1576,29 +1576,29 @@ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const
1576
1576
  }
1577
1577
  float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1578
1578
  return ( near * far ) / ( ( far - near ) * depth - far );
1579
- }`,Py=`#ifdef PREMULTIPLIED_ALPHA
1579
+ }`,Ly=`#ifdef PREMULTIPLIED_ALPHA
1580
1580
  gl_FragColor.rgb *= gl_FragColor.a;
1581
- #endif`,Ly=`vec4 mvPosition = vec4( transformed, 1.0 );
1581
+ #endif`,Iy=`vec4 mvPosition = vec4( transformed, 1.0 );
1582
1582
  #ifdef USE_INSTANCING
1583
1583
  mvPosition = instanceMatrix * mvPosition;
1584
1584
  #endif
1585
1585
  mvPosition = modelViewMatrix * mvPosition;
1586
- gl_Position = projectionMatrix * mvPosition;`,Iy=`#ifdef DITHERING
1586
+ gl_Position = projectionMatrix * mvPosition;`,Uy=`#ifdef DITHERING
1587
1587
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1588
- #endif`,Uy=`#ifdef DITHERING
1588
+ #endif`,Dy=`#ifdef DITHERING
1589
1589
  vec3 dithering( vec3 color ) {
1590
1590
  float grid_position = rand( gl_FragCoord.xy );
1591
1591
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1592
1592
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1593
1593
  return color + dither_shift_RGB;
1594
1594
  }
1595
- #endif`,Dy=`float roughnessFactor = roughness;
1595
+ #endif`,Ny=`float roughnessFactor = roughness;
1596
1596
  #ifdef USE_ROUGHNESSMAP
1597
1597
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1598
1598
  roughnessFactor *= texelRoughness.g;
1599
- #endif`,Ny=`#ifdef USE_ROUGHNESSMAP
1599
+ #endif`,Fy=`#ifdef USE_ROUGHNESSMAP
1600
1600
  uniform sampler2D roughnessMap;
1601
- #endif`,Fy=`#if NUM_SPOT_LIGHT_COORDS > 0
1601
+ #endif`,Oy=`#if NUM_SPOT_LIGHT_COORDS > 0
1602
1602
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1603
1603
  #endif
1604
1604
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -1775,7 +1775,7 @@ gl_Position = projectionMatrix * mvPosition;`,Iy=`#ifdef DITHERING
1775
1775
  return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1776
1776
  #endif
1777
1777
  }
1778
- #endif`,Oy=`#if NUM_SPOT_LIGHT_COORDS > 0
1778
+ #endif`,By=`#if NUM_SPOT_LIGHT_COORDS > 0
1779
1779
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1780
1780
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1781
1781
  #endif
@@ -1813,7 +1813,7 @@ gl_Position = projectionMatrix * mvPosition;`,Iy=`#ifdef DITHERING
1813
1813
  };
1814
1814
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1815
1815
  #endif
1816
- #endif`,By=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1816
+ #endif`,zy=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1817
1817
  vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1818
1818
  vec4 shadowWorldPosition;
1819
1819
  #endif
@@ -1845,7 +1845,7 @@ gl_Position = projectionMatrix * mvPosition;`,Iy=`#ifdef DITHERING
1845
1845
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1846
1846
  }
1847
1847
  #pragma unroll_loop_end
1848
- #endif`,zy=`float getShadowMask() {
1848
+ #endif`,ky=`float getShadowMask() {
1849
1849
  float shadow = 1.0;
1850
1850
  #ifdef USE_SHADOWMAP
1851
1851
  #if NUM_DIR_LIGHT_SHADOWS > 0
@@ -1877,12 +1877,12 @@ gl_Position = projectionMatrix * mvPosition;`,Iy=`#ifdef DITHERING
1877
1877
  #endif
1878
1878
  #endif
1879
1879
  return shadow;
1880
- }`,ky=`#ifdef USE_SKINNING
1880
+ }`,Gy=`#ifdef USE_SKINNING
1881
1881
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
1882
1882
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
1883
1883
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1884
1884
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
1885
- #endif`,Gy=`#ifdef USE_SKINNING
1885
+ #endif`,Hy=`#ifdef USE_SKINNING
1886
1886
  uniform mat4 bindMatrix;
1887
1887
  uniform mat4 bindMatrixInverse;
1888
1888
  uniform highp sampler2D boneTexture;
@@ -1901,7 +1901,7 @@ gl_Position = projectionMatrix * mvPosition;`,Iy=`#ifdef DITHERING
1901
1901
  mat4 bone = mat4( v1, v2, v3, v4 );
1902
1902
  return bone;
1903
1903
  }
1904
- #endif`,Hy=`#ifdef USE_SKINNING
1904
+ #endif`,Vy=`#ifdef USE_SKINNING
1905
1905
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
1906
1906
  vec4 skinned = vec4( 0.0 );
1907
1907
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -1909,7 +1909,7 @@ gl_Position = projectionMatrix * mvPosition;`,Iy=`#ifdef DITHERING
1909
1909
  skinned += boneMatZ * skinVertex * skinWeight.z;
1910
1910
  skinned += boneMatW * skinVertex * skinWeight.w;
1911
1911
  transformed = ( bindMatrixInverse * skinned ).xyz;
1912
- #endif`,Vy=`#ifdef USE_SKINNING
1912
+ #endif`,Wy=`#ifdef USE_SKINNING
1913
1913
  mat4 skinMatrix = mat4( 0.0 );
1914
1914
  skinMatrix += skinWeight.x * boneMatX;
1915
1915
  skinMatrix += skinWeight.y * boneMatY;
@@ -1920,17 +1920,17 @@ gl_Position = projectionMatrix * mvPosition;`,Iy=`#ifdef DITHERING
1920
1920
  #ifdef USE_TANGENT
1921
1921
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
1922
1922
  #endif
1923
- #endif`,Wy=`float specularStrength;
1923
+ #endif`,Xy=`float specularStrength;
1924
1924
  #ifdef USE_SPECULARMAP
1925
1925
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
1926
1926
  specularStrength = texelSpecular.r;
1927
1927
  #else
1928
1928
  specularStrength = 1.0;
1929
- #endif`,Xy=`#ifdef USE_SPECULARMAP
1929
+ #endif`,qy=`#ifdef USE_SPECULARMAP
1930
1930
  uniform sampler2D specularMap;
1931
- #endif`,qy=`#if defined( TONE_MAPPING )
1931
+ #endif`,$y=`#if defined( TONE_MAPPING )
1932
1932
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
1933
- #endif`,$y=`#ifndef saturate
1933
+ #endif`,Yy=`#ifndef saturate
1934
1934
  #define saturate( a ) clamp( a, 0.0, 1.0 )
1935
1935
  #endif
1936
1936
  uniform float toneMappingExposure;
@@ -1966,7 +1966,7 @@ vec3 ACESFilmicToneMapping( vec3 color ) {
1966
1966
  color = ACESOutputMat * color;
1967
1967
  return saturate( color );
1968
1968
  }
1969
- vec3 CustomToneMapping( vec3 color ) { return color; }`,Yy=`#ifdef USE_TRANSMISSION
1969
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,Zy=`#ifdef USE_TRANSMISSION
1970
1970
  material.transmission = transmission;
1971
1971
  material.transmissionAlpha = 1.0;
1972
1972
  material.thickness = thickness;
@@ -1987,7 +1987,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Yy=`#ifdef USE_TRANSMISS
1987
1987
  material.attenuationColor, material.attenuationDistance );
1988
1988
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
1989
1989
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
1990
- #endif`,Zy=`#ifdef USE_TRANSMISSION
1990
+ #endif`,Jy=`#ifdef USE_TRANSMISSION
1991
1991
  uniform float transmission;
1992
1992
  uniform float thickness;
1993
1993
  uniform float attenuationDistance;
@@ -2093,7 +2093,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Yy=`#ifdef USE_TRANSMISS
2093
2093
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2094
2094
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2095
2095
  }
2096
- #endif`,Jy=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2096
+ #endif`,Ky=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2097
2097
  varying vec2 vUv;
2098
2098
  #endif
2099
2099
  #ifdef USE_MAP
@@ -2163,7 +2163,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Yy=`#ifdef USE_TRANSMISS
2163
2163
  #ifdef USE_THICKNESSMAP
2164
2164
  uniform mat3 thicknessMapTransform;
2165
2165
  varying vec2 vThicknessMapUv;
2166
- #endif`,Ky=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2166
+ #endif`,jy=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2167
2167
  varying vec2 vUv;
2168
2168
  #endif
2169
2169
  #ifdef USE_MAP
@@ -2257,7 +2257,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Yy=`#ifdef USE_TRANSMISS
2257
2257
  #ifdef USE_THICKNESSMAP
2258
2258
  uniform mat3 thicknessMapTransform;
2259
2259
  varying vec2 vThicknessMapUv;
2260
- #endif`,jy=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2260
+ #endif`,Qy=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2261
2261
  vUv = vec3( uv, 1 ).xy;
2262
2262
  #endif
2263
2263
  #ifdef USE_MAP
@@ -2328,13 +2328,13 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Yy=`#ifdef USE_TRANSMISS
2328
2328
  #endif
2329
2329
  #ifdef USE_THICKNESSMAP
2330
2330
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2331
- #endif`,Qy=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2331
+ #endif`,ev=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2332
2332
  vec4 worldPosition = vec4( transformed, 1.0 );
2333
2333
  #ifdef USE_INSTANCING
2334
2334
  worldPosition = instanceMatrix * worldPosition;
2335
2335
  #endif
2336
2336
  worldPosition = modelMatrix * worldPosition;
2337
- #endif`;const Ve={alphahash_fragment:ix,alphahash_pars_fragment:rx,alphamap_fragment:sx,alphamap_pars_fragment:ax,alphatest_fragment:ox,alphatest_pars_fragment:lx,aomap_fragment:cx,aomap_pars_fragment:hx,begin_vertex:ux,beginnormal_vertex:fx,bsdfs:dx,iridescence_fragment:px,bumpmap_pars_fragment:mx,clipping_planes_fragment:gx,clipping_planes_pars_fragment:_x,clipping_planes_pars_vertex:xx,clipping_planes_vertex:yx,color_fragment:vx,color_pars_fragment:Mx,color_pars_vertex:Sx,color_vertex:bx,common:wx,cube_uv_reflection_fragment:Ex,defaultnormal_vertex:Ax,displacementmap_pars_vertex:Tx,displacementmap_vertex:Rx,emissivemap_fragment:Cx,emissivemap_pars_fragment:Px,colorspace_fragment:Lx,colorspace_pars_fragment:Ix,envmap_fragment:Ux,envmap_common_pars_fragment:Dx,envmap_pars_fragment:Nx,envmap_pars_vertex:Fx,envmap_physical_pars_fragment:Yx,envmap_vertex:Ox,fog_vertex:Bx,fog_pars_vertex:zx,fog_fragment:kx,fog_pars_fragment:Gx,gradientmap_pars_fragment:Hx,lightmap_fragment:Vx,lightmap_pars_fragment:Wx,lights_lambert_fragment:Xx,lights_lambert_pars_fragment:qx,lights_pars_begin:$x,lights_toon_fragment:Zx,lights_toon_pars_fragment:Jx,lights_phong_fragment:Kx,lights_phong_pars_fragment:jx,lights_physical_fragment:Qx,lights_physical_pars_fragment:ey,lights_fragment_begin:ty,lights_fragment_maps:ny,lights_fragment_end:iy,logdepthbuf_fragment:ry,logdepthbuf_pars_fragment:sy,logdepthbuf_pars_vertex:ay,logdepthbuf_vertex:oy,map_fragment:ly,map_pars_fragment:cy,map_particle_fragment:hy,map_particle_pars_fragment:uy,metalnessmap_fragment:fy,metalnessmap_pars_fragment:dy,morphcolor_vertex:py,morphnormal_vertex:my,morphtarget_pars_vertex:gy,morphtarget_vertex:_y,normal_fragment_begin:xy,normal_fragment_maps:yy,normal_pars_fragment:vy,normal_pars_vertex:My,normal_vertex:Sy,normalmap_pars_fragment:by,clearcoat_normal_fragment_begin:wy,clearcoat_normal_fragment_maps:Ey,clearcoat_pars_fragment:Ay,iridescence_pars_fragment:Ty,opaque_fragment:Ry,packing:Cy,premultiplied_alpha_fragment:Py,project_vertex:Ly,dithering_fragment:Iy,dithering_pars_fragment:Uy,roughnessmap_fragment:Dy,roughnessmap_pars_fragment:Ny,shadowmap_pars_fragment:Fy,shadowmap_pars_vertex:Oy,shadowmap_vertex:By,shadowmask_pars_fragment:zy,skinbase_vertex:ky,skinning_pars_vertex:Gy,skinning_vertex:Hy,skinnormal_vertex:Vy,specularmap_fragment:Wy,specularmap_pars_fragment:Xy,tonemapping_fragment:qy,tonemapping_pars_fragment:$y,transmission_fragment:Yy,transmission_pars_fragment:Zy,uv_pars_fragment:Jy,uv_pars_vertex:Ky,uv_vertex:jy,worldpos_vertex:Qy,background_vert:`varying vec2 vUv;
2337
+ #endif`;const Ve={alphahash_fragment:rx,alphahash_pars_fragment:sx,alphamap_fragment:ax,alphamap_pars_fragment:ox,alphatest_fragment:lx,alphatest_pars_fragment:cx,aomap_fragment:hx,aomap_pars_fragment:ux,begin_vertex:fx,beginnormal_vertex:dx,bsdfs:px,iridescence_fragment:mx,bumpmap_pars_fragment:gx,clipping_planes_fragment:_x,clipping_planes_pars_fragment:xx,clipping_planes_pars_vertex:yx,clipping_planes_vertex:vx,color_fragment:Mx,color_pars_fragment:Sx,color_pars_vertex:bx,color_vertex:wx,common:Ex,cube_uv_reflection_fragment:Ax,defaultnormal_vertex:Tx,displacementmap_pars_vertex:Rx,displacementmap_vertex:Cx,emissivemap_fragment:Px,emissivemap_pars_fragment:Lx,colorspace_fragment:Ix,colorspace_pars_fragment:Ux,envmap_fragment:Dx,envmap_common_pars_fragment:Nx,envmap_pars_fragment:Fx,envmap_pars_vertex:Ox,envmap_physical_pars_fragment:Zx,envmap_vertex:Bx,fog_vertex:zx,fog_pars_vertex:kx,fog_fragment:Gx,fog_pars_fragment:Hx,gradientmap_pars_fragment:Vx,lightmap_fragment:Wx,lightmap_pars_fragment:Xx,lights_lambert_fragment:qx,lights_lambert_pars_fragment:$x,lights_pars_begin:Yx,lights_toon_fragment:Jx,lights_toon_pars_fragment:Kx,lights_phong_fragment:jx,lights_phong_pars_fragment:Qx,lights_physical_fragment:ey,lights_physical_pars_fragment:ty,lights_fragment_begin:ny,lights_fragment_maps:iy,lights_fragment_end:ry,logdepthbuf_fragment:sy,logdepthbuf_pars_fragment:ay,logdepthbuf_pars_vertex:oy,logdepthbuf_vertex:ly,map_fragment:cy,map_pars_fragment:hy,map_particle_fragment:uy,map_particle_pars_fragment:fy,metalnessmap_fragment:dy,metalnessmap_pars_fragment:py,morphcolor_vertex:my,morphnormal_vertex:gy,morphtarget_pars_vertex:_y,morphtarget_vertex:xy,normal_fragment_begin:yy,normal_fragment_maps:vy,normal_pars_fragment:My,normal_pars_vertex:Sy,normal_vertex:by,normalmap_pars_fragment:wy,clearcoat_normal_fragment_begin:Ey,clearcoat_normal_fragment_maps:Ay,clearcoat_pars_fragment:Ty,iridescence_pars_fragment:Ry,opaque_fragment:Cy,packing:Py,premultiplied_alpha_fragment:Ly,project_vertex:Iy,dithering_fragment:Uy,dithering_pars_fragment:Dy,roughnessmap_fragment:Ny,roughnessmap_pars_fragment:Fy,shadowmap_pars_fragment:Oy,shadowmap_pars_vertex:By,shadowmap_vertex:zy,shadowmask_pars_fragment:ky,skinbase_vertex:Gy,skinning_pars_vertex:Hy,skinning_vertex:Vy,skinnormal_vertex:Wy,specularmap_fragment:Xy,specularmap_pars_fragment:qy,tonemapping_fragment:$y,tonemapping_pars_fragment:Yy,transmission_fragment:Zy,transmission_pars_fragment:Jy,uv_pars_fragment:Ky,uv_pars_vertex:jy,uv_vertex:Qy,worldpos_vertex:ev,background_vert:`varying vec2 vUv;
2338
2338
  uniform mat3 uvTransform;
2339
2339
  void main() {
2340
2340
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
@@ -3344,7 +3344,7 @@ void main() {
3344
3344
  #include <tonemapping_fragment>
3345
3345
  #include <colorspace_fragment>
3346
3346
  #include <fog_fragment>
3347
- }`},ge={common:{diffuse:{value:new ye(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xe}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xe},normalScale:{value:new q(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ye(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 ye(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0},uvTransform:{value:new Xe}},sprite:{diffuse:{value:new ye(16777215)},opacity:{value:1},center:{value:new q(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}}},Rn={basic:{uniforms:Gt([ge.common,ge.specularmap,ge.envmap,ge.aomap,ge.lightmap,ge.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:Gt([ge.common,ge.specularmap,ge.envmap,ge.aomap,ge.lightmap,ge.emissivemap,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.fog,ge.lights,{emissive:{value:new ye(0)}}]),vertexShader:Ve.meshlambert_vert,fragmentShader:Ve.meshlambert_frag},phong:{uniforms:Gt([ge.common,ge.specularmap,ge.envmap,ge.aomap,ge.lightmap,ge.emissivemap,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.fog,ge.lights,{emissive:{value:new ye(0)},specular:{value:new ye(1118481)},shininess:{value:30}}]),vertexShader:Ve.meshphong_vert,fragmentShader:Ve.meshphong_frag},standard:{uniforms:Gt([ge.common,ge.envmap,ge.aomap,ge.lightmap,ge.emissivemap,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.roughnessmap,ge.metalnessmap,ge.fog,ge.lights,{emissive:{value:new ye(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag},toon:{uniforms:Gt([ge.common,ge.aomap,ge.lightmap,ge.emissivemap,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.gradientmap,ge.fog,ge.lights,{emissive:{value:new ye(0)}}]),vertexShader:Ve.meshtoon_vert,fragmentShader:Ve.meshtoon_frag},matcap:{uniforms:Gt([ge.common,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:Gt([ge.points,ge.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:Gt([ge.common,ge.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:Gt([ge.common,ge.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:Gt([ge.common,ge.bumpmap,ge.normalmap,ge.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:Gt([ge.sprite,ge.fog]),vertexShader:Ve.sprite_vert,fragmentShader:Ve.sprite_frag},background:{uniforms:{uvTransform:{value:new Xe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ve.background_vert,fragmentShader:Ve.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Ve.backgroundCube_vert,fragmentShader:Ve.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ve.cube_vert,fragmentShader:Ve.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ve.equirect_vert,fragmentShader:Ve.equirect_frag},distanceRGBA:{uniforms:Gt([ge.common,ge.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ve.distanceRGBA_vert,fragmentShader:Ve.distanceRGBA_frag},shadow:{uniforms:Gt([ge.lights,ge.fog,{color:{value:new ye(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};Rn.physical={uniforms:Gt([Rn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xe},clearcoatNormalScale:{value:new q(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xe},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xe},sheen:{value:0},sheenColor:{value:new ye(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xe},transmissionSamplerSize:{value:new q},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xe},attenuationDistance:{value:0},attenuationColor:{value:new ye(0)},specularColor:{value:new ye(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xe},anisotropyVector:{value:new q},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xe}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag};const io={r:0,b:0,g:0};function ev(r,e,t,n,i,s,a){const o=new ye(0);let l=s===!0?0:1,c,h,u=null,f=0,d=null;function p(g,m){let y=!1,x=m.isScene===!0?m.background:null;switch(x&&x.isTexture&&(x=(m.backgroundBlurriness>0?t:e).get(x)),x===null?_(o,l):x&&x.isColor&&(_(x,1),y=!0),r.xr.getEnvironmentBlendMode()){case"opaque":y=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,a),y=!0;break;case"alpha-blend":n.buffers.color.setClear(0,0,0,0,a),y=!0;break}(r.autoClear||y)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),x&&(x.isCubeTexture||x.mapping===mr)?(h===void 0&&(h=new It(new Vi(1,1,1),new zn({name:"BackgroundCubeMaterial",uniforms:Dr(Rn.backgroundCube.uniforms),vertexShader:Rn.backgroundCube.vertexShader,fragmentShader:Rn.backgroundCube.fragmentShader,side:kt,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,A,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),h.material.uniforms.envMap.value=x,h.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,h.material.toneMapped=x.colorSpace!==Ge,(u!==x||f!==x.version||d!==r.toneMapping)&&(h.material.needsUpdate=!0,u=x,f=x.version,d=r.toneMapping),h.layers.enableAll(),g.unshift(h,h.geometry,h.material,0,0,null)):x&&x.isTexture&&(c===void 0&&(c=new It(new Ns(2,2),new zn({name:"BackgroundMaterial",uniforms:Dr(Rn.background.uniforms),vertexShader:Rn.background.vertexShader,fragmentShader:Rn.background.fragmentShader,side:Xn,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=x,c.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,c.material.toneMapped=x.colorSpace!==Ge,x.matrixAutoUpdate===!0&&x.updateMatrix(),c.material.uniforms.uvTransform.value.copy(x.matrix),(u!==x||f!==x.version||d!==r.toneMapping)&&(c.material.needsUpdate=!0,u=x,f=x.version,d=r.toneMapping),c.layers.enableAll(),g.unshift(c,c.geometry,c.material,0,0,null))}function _(g,m){g.getRGB(io,fd(r)),n.buffers.color.setClear(io.r,io.g,io.b,m,a)}return{getClearColor:function(){return o},setClearColor:function(g,m=1){o.set(g),l=m,_(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(g){l=g,_(o,l)},render:p}}function tv(r,e,t,n){const i=r.getParameter(r.MAX_VERTEX_ATTRIBS),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),a=n.isWebGL2||s!==null,o={},l=g(null);let c=l,h=!1;function u(N,I,B,O,H){let X=!1;if(a){const ee=_(O,B,I);c!==ee&&(c=ee,d(c.object)),X=m(N,O,B,H),X&&y(N,O,B,H)}else{const ee=I.wireframe===!0;(c.geometry!==O.id||c.program!==B.id||c.wireframe!==ee)&&(c.geometry=O.id,c.program=B.id,c.wireframe=ee,X=!0)}H!==null&&t.update(H,r.ELEMENT_ARRAY_BUFFER),(X||h)&&(h=!1,C(N,I,B,O),H!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(H).buffer))}function f(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function d(N){return n.isWebGL2?r.bindVertexArray(N):s.bindVertexArrayOES(N)}function p(N){return n.isWebGL2?r.deleteVertexArray(N):s.deleteVertexArrayOES(N)}function _(N,I,B){const O=B.wireframe===!0;let H=o[N.id];H===void 0&&(H={},o[N.id]=H);let X=H[I.id];X===void 0&&(X={},H[I.id]=X);let ee=X[O];return ee===void 0&&(ee=g(f()),X[O]=ee),ee}function g(N){const I=[],B=[],O=[];for(let H=0;H<i;H++)I[H]=0,B[H]=0,O[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:B,attributeDivisors:O,object:N,attributes:{},index:null}}function m(N,I,B,O){const H=c.attributes,X=I.attributes;let ee=0;const z=B.getAttributes();for(const Z in z)if(z[Z].location>=0){const ce=H[Z];let fe=X[Z];if(fe===void 0&&(Z==="instanceMatrix"&&N.instanceMatrix&&(fe=N.instanceMatrix),Z==="instanceColor"&&N.instanceColor&&(fe=N.instanceColor)),ce===void 0||ce.attribute!==fe||fe&&ce.data!==fe.data)return!0;ee++}return c.attributesNum!==ee||c.index!==O}function y(N,I,B,O){const H={},X=I.attributes;let ee=0;const z=B.getAttributes();for(const Z in z)if(z[Z].location>=0){let ce=X[Z];ce===void 0&&(Z==="instanceMatrix"&&N.instanceMatrix&&(ce=N.instanceMatrix),Z==="instanceColor"&&N.instanceColor&&(ce=N.instanceColor));const fe={};fe.attribute=ce,ce&&ce.data&&(fe.data=ce.data),H[Z]=fe,ee++}c.attributes=H,c.attributesNum=ee,c.index=O}function x(){const N=c.newAttributes;for(let I=0,B=N.length;I<B;I++)N[I]=0}function v(N){M(N,0)}function M(N,I){const B=c.newAttributes,O=c.enabledAttributes,H=c.attributeDivisors;B[N]=1,O[N]===0&&(r.enableVertexAttribArray(N),O[N]=1),H[N]!==I&&((n.isWebGL2?r:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](N,I),H[N]=I)}function w(){const N=c.newAttributes,I=c.enabledAttributes;for(let B=0,O=I.length;B<O;B++)I[B]!==N[B]&&(r.disableVertexAttribArray(B),I[B]=0)}function A(N,I,B,O,H,X,ee){ee===!0?r.vertexAttribIPointer(N,I,B,H,X):r.vertexAttribPointer(N,I,B,O,H,X)}function C(N,I,B,O){if(n.isWebGL2===!1&&(N.isInstancedMesh||O.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;x();const H=O.attributes,X=B.getAttributes(),ee=I.defaultAttributeValues;for(const z in X){const Z=X[z];if(Z.location>=0){let le=H[z];if(le===void 0&&(z==="instanceMatrix"&&N.instanceMatrix&&(le=N.instanceMatrix),z==="instanceColor"&&N.instanceColor&&(le=N.instanceColor)),le!==void 0){const ce=le.normalized,fe=le.itemSize,Ae=t.get(le);if(Ae===void 0)continue;const Pe=Ae.buffer,Te=Ae.type,Ke=Ae.bytesPerElement,je=n.isWebGL2===!0&&(Te===r.INT||Te===r.UNSIGNED_INT||le.gpuType===ec);if(le.isInterleavedBufferAttribute){const Le=le.data,D=Le.stride,ae=le.offset;if(Le.isInstancedInterleavedBuffer){for(let Q=0;Q<Z.locationSize;Q++)M(Z.location+Q,Le.meshPerAttribute);N.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=Le.meshPerAttribute*Le.count)}else for(let Q=0;Q<Z.locationSize;Q++)v(Z.location+Q);r.bindBuffer(r.ARRAY_BUFFER,Pe);for(let Q=0;Q<Z.locationSize;Q++)A(Z.location+Q,fe/Z.locationSize,Te,ce,D*Ke,(ae+fe/Z.locationSize*Q)*Ke,je)}else{if(le.isInstancedBufferAttribute){for(let Le=0;Le<Z.locationSize;Le++)M(Z.location+Le,le.meshPerAttribute);N.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let Le=0;Le<Z.locationSize;Le++)v(Z.location+Le);r.bindBuffer(r.ARRAY_BUFFER,Pe);for(let Le=0;Le<Z.locationSize;Le++)A(Z.location+Le,fe/Z.locationSize,Te,ce,fe*Ke,fe/Z.locationSize*Le*Ke,je)}}else if(ee!==void 0){const ce=ee[z];if(ce!==void 0)switch(ce.length){case 2:r.vertexAttrib2fv(Z.location,ce);break;case 3:r.vertexAttrib3fv(Z.location,ce);break;case 4:r.vertexAttrib4fv(Z.location,ce);break;default:r.vertexAttrib1fv(Z.location,ce)}}}}w()}function S(){k();for(const N in o){const I=o[N];for(const B in I){const O=I[B];for(const H in O)p(O[H].object),delete O[H];delete I[B]}delete o[N]}}function b(N){if(o[N.id]===void 0)return;const I=o[N.id];for(const B in I){const O=I[B];for(const H in O)p(O[H].object),delete O[H];delete I[B]}delete o[N.id]}function L(N){for(const I in o){const B=o[I];if(B[N.id]===void 0)continue;const O=B[N.id];for(const H in O)p(O[H].object),delete O[H];delete B[N.id]}}function k(){U(),h=!0,c!==l&&(c=l,d(c.object))}function U(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:u,reset:k,resetDefaultState:U,dispose:S,releaseStatesOfGeometry:b,releaseStatesOfProgram:L,initAttributes:x,enableAttribute:v,disableUnusedAttributes:w}}function nv(r,e,t,n){const i=n.isWebGL2;let s;function a(c){s=c}function o(c,h){r.drawArrays(s,c,h),t.update(h,s,1)}function l(c,h,u){if(u===0)return;let f,d;if(i)f=r,d="drawArraysInstanced";else if(f=e.get("ANGLE_instanced_arrays"),d="drawArraysInstancedANGLE",f===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}f[d](s,c,h,u),t.update(h,s,u)}this.setMode=a,this.render=o,this.renderInstances=l}function iv(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(A){if(A==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const a=typeof WebGL2RenderingContext!="undefined"&&r.constructor.name==="WebGL2RenderingContext";let o=t.precision!==void 0?t.precision:"highp";const l=s(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);const c=a||e.has("WEBGL_draw_buffers"),h=t.logarithmicDepthBuffer===!0,u=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),f=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=r.getParameter(r.MAX_TEXTURE_SIZE),p=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),_=r.getParameter(r.MAX_VERTEX_ATTRIBS),g=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),m=r.getParameter(r.MAX_VARYING_VECTORS),y=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),x=f>0,v=a||e.has("OES_texture_float"),M=x&&v,w=a?r.getParameter(r.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:h,maxTextures:u,maxVertexTextures:f,maxTextureSize:d,maxCubemapSize:p,maxAttributes:_,maxVertexUniforms:g,maxVaryings:m,maxFragmentUniforms:y,vertexTextures:x,floatFragmentTextures:v,floatVertexTextures:M,maxSamples:w}}function rv(r){const e=this;let t=null,n=0,i=!1,s=!1;const a=new Ti,o=new Xe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,f){const d=u.length!==0||f||n!==0||i;return i=f,n=u.length,d},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,f){t=h(u,f,0)},this.setState=function(u,f,d){const p=u.clippingPlanes,_=u.clipIntersection,g=u.clipShadows,m=r.get(u);if(!i||p===null||p.length===0||s&&!g)s?h(null):c();else{const y=s?0:n,x=y*4;let v=m.clippingState||null;l.value=v,v=h(p,f,x,d);for(let M=0;M!==x;++M)v[M]=t[M];m.clippingState=v,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,f,d,p){const _=u!==null?u.length:0;let g=null;if(_!==0){if(g=l.value,p!==!0||g===null){const m=d+_*4,y=f.matrixWorldInverse;o.getNormalMatrix(y),(g===null||g.length<m)&&(g=new Float32Array(m));for(let x=0,v=d;x!==_;++x,v+=4)a.copy(u[x]).applyMatrix4(y,o),a.normal.toArray(g,v),g[v+3]=a.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,g}}function sv(r){let e=new WeakMap;function t(a,o){return o===ms?a.mapping=pi:o===gs&&(a.mapping=mi),a}function n(a){if(a&&a.isTexture&&a.isRenderTargetTexture===!1){const o=a.mapping;if(o===ms||o===gs)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new md(l.height/2);return c.fromEquirectangularTexture(r,a),e.set(a,c),a.addEventListener("dispose",i),t(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class ro extends eo{constructor(e=-1,t=1,n=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,a){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=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Or=4,_d=[.125,.215,.35,.446,.526,.582],Xi=20,nh=new ro,xd=new ye;let ih=null;const qi=(1+Math.sqrt(5))/2,Br=1/qi,yd=[new R(1,1,1),new R(-1,1,1),new R(1,1,-1),new R(-1,1,-1),new R(0,qi,Br),new R(0,qi,-Br),new R(Br,0,qi),new R(-Br,0,qi),new R(qi,Br,0),new R(-qi,Br,0)];class rh{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){ih=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Sd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Md(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.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._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(ih),e.scissorTest=!1,so(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===pi||e.mapping===mi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ih=this._renderer.getRenderTarget();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:vt,minFilter:vt,generateMipmaps:!1,type:gr,format:an,colorSpace:Sn,depthBuffer:!1},i=vd(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=vd(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=av(s)),this._blurMaterial=ov(s,e,t)}return i}_compileMaterial(e){const t=new It(this._lodPlanes[0],e);this._renderer.compile(t,nh)}_sceneToCubeUV(e,t,n,i){const o=new Ut(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,f=h.toneMapping;h.getClearColor(xd),h.toneMapping=Fn,h.autoClear=!1;const d=new Ai({name:"PMREM.Background",side:kt,depthWrite:!1,depthTest:!1}),p=new It(new Vi,d);let _=!1;const g=e.background;g?g.isColor&&(d.color.copy(g),e.background=null,_=!0):(d.color.copy(xd),_=!0);for(let m=0;m<6;m++){const y=m%3;y===0?(o.up.set(0,l[m],0),o.lookAt(c[m],0,0)):y===1?(o.up.set(0,0,l[m]),o.lookAt(0,c[m],0)):(o.up.set(0,l[m],0),o.lookAt(0,0,c[m]));const x=this._cubeSize;so(i,y*x,m>2?x:0,x,x),h.setRenderTarget(i),_&&h.render(p,o),h.render(e,o)}p.geometry.dispose(),p.material.dispose(),h.toneMapping=f,h.autoClear=u,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===pi||e.mapping===mi;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Sd()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Md());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new It(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;so(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,nh)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),a=yd[(i-1)%yd.length];this._blur(e,i-1,i,s,a)}t.autoClear=n}_blur(e,t,n,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",s),this._halfBlur(a,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new It(this._lodPlanes[i],c),f=c.uniforms,d=this._sizeLods[n]-1,p=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*Xi-1),_=s/p,g=isFinite(s)?1+Math.floor(h*_):Xi;g>Xi&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Xi}`);const m=[];let y=0;for(let A=0;A<Xi;++A){const C=A/_,S=Math.exp(-C*C/2);m.push(S),A===0?y+=S:A<g&&(y+=2*S)}for(let A=0;A<m.length;A++)m[A]=m[A]/y;f.envMap.value=e.texture,f.samples.value=g,f.weights.value=m,f.latitudinal.value=a==="latitudinal",o&&(f.poleAxis.value=o);const{_lodMax:x}=this;f.dTheta.value=p,f.mipInt.value=x-n;const v=this._sizeLods[i],M=3*v*(i>x-Or?i-x+Or:0),w=4*(this._cubeSize-v);so(t,M,w,3*v,2*v),l.setRenderTarget(t),l.render(u,nh)}}function av(r){const e=[],t=[],n=[];let i=r;const s=r-Or+1+_d.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);t.push(o);let l=1/o;a>r-Or?l=_d[a-r+Or-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,f=[h,h,u,h,u,u,h,h,u,u,h,u],d=6,p=6,_=3,g=2,m=1,y=new Float32Array(_*p*d),x=new Float32Array(g*p*d),v=new Float32Array(m*p*d);for(let w=0;w<d;w++){const A=w%3*2/3-1,C=w>2?0:-1,S=[A,C,0,A+2/3,C,0,A+2/3,C+1,0,A,C,0,A+2/3,C+1,0,A,C+1,0];y.set(S,_*p*w),x.set(f,g*p*w);const b=[w,w,w,w,w,w];v.set(b,m*p*w)}const M=new Fe;M.setAttribute("position",new Ze(y,_)),M.setAttribute("uv",new Ze(x,g)),M.setAttribute("faceIndex",new Ze(v,m)),e.push(M),i>Or&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function vd(r,e,t){const n=new bn(r,e,t);return n.texture.mapping=mr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function so(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function ov(r,e,t){const n=new Float32Array(Xi),i=new R(0,1,0);return new zn({name:"SphericalGaussianBlur",defines:{n:Xi,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:sh(),fragmentShader:`
3347
+ }`},ge={common:{diffuse:{value:new ye(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xe}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xe},normalScale:{value:new q(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ye(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 ye(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0},uvTransform:{value:new Xe}},sprite:{diffuse:{value:new ye(16777215)},opacity:{value:1},center:{value:new q(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}}},Rn={basic:{uniforms:Gt([ge.common,ge.specularmap,ge.envmap,ge.aomap,ge.lightmap,ge.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:Gt([ge.common,ge.specularmap,ge.envmap,ge.aomap,ge.lightmap,ge.emissivemap,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.fog,ge.lights,{emissive:{value:new ye(0)}}]),vertexShader:Ve.meshlambert_vert,fragmentShader:Ve.meshlambert_frag},phong:{uniforms:Gt([ge.common,ge.specularmap,ge.envmap,ge.aomap,ge.lightmap,ge.emissivemap,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.fog,ge.lights,{emissive:{value:new ye(0)},specular:{value:new ye(1118481)},shininess:{value:30}}]),vertexShader:Ve.meshphong_vert,fragmentShader:Ve.meshphong_frag},standard:{uniforms:Gt([ge.common,ge.envmap,ge.aomap,ge.lightmap,ge.emissivemap,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.roughnessmap,ge.metalnessmap,ge.fog,ge.lights,{emissive:{value:new ye(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag},toon:{uniforms:Gt([ge.common,ge.aomap,ge.lightmap,ge.emissivemap,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.gradientmap,ge.fog,ge.lights,{emissive:{value:new ye(0)}}]),vertexShader:Ve.meshtoon_vert,fragmentShader:Ve.meshtoon_frag},matcap:{uniforms:Gt([ge.common,ge.bumpmap,ge.normalmap,ge.displacementmap,ge.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:Gt([ge.points,ge.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:Gt([ge.common,ge.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:Gt([ge.common,ge.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:Gt([ge.common,ge.bumpmap,ge.normalmap,ge.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:Gt([ge.sprite,ge.fog]),vertexShader:Ve.sprite_vert,fragmentShader:Ve.sprite_frag},background:{uniforms:{uvTransform:{value:new Xe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ve.background_vert,fragmentShader:Ve.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Ve.backgroundCube_vert,fragmentShader:Ve.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ve.cube_vert,fragmentShader:Ve.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ve.equirect_vert,fragmentShader:Ve.equirect_frag},distanceRGBA:{uniforms:Gt([ge.common,ge.displacementmap,{referencePosition:{value:new R},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ve.distanceRGBA_vert,fragmentShader:Ve.distanceRGBA_frag},shadow:{uniforms:Gt([ge.lights,ge.fog,{color:{value:new ye(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};Rn.physical={uniforms:Gt([Rn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xe},clearcoatNormalScale:{value:new q(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xe},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xe},sheen:{value:0},sheenColor:{value:new ye(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xe},transmissionSamplerSize:{value:new q},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xe},attenuationDistance:{value:0},attenuationColor:{value:new ye(0)},specularColor:{value:new ye(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xe},anisotropyVector:{value:new q},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xe}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag};const io={r:0,b:0,g:0};function tv(r,e,t,n,i,s,a){const o=new ye(0);let l=s===!0?0:1,c,h,u=null,f=0,d=null;function p(g,m){let y=!1,x=m.isScene===!0?m.background:null;switch(x&&x.isTexture&&(x=(m.backgroundBlurriness>0?t:e).get(x)),x===null?_(o,l):x&&x.isColor&&(_(x,1),y=!0),r.xr.getEnvironmentBlendMode()){case"opaque":y=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,a),y=!0;break;case"alpha-blend":n.buffers.color.setClear(0,0,0,0,a),y=!0;break}(r.autoClear||y)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),x&&(x.isCubeTexture||x.mapping===mr)?(h===void 0&&(h=new It(new Vi(1,1,1),new zn({name:"BackgroundCubeMaterial",uniforms:Dr(Rn.backgroundCube.uniforms),vertexShader:Rn.backgroundCube.vertexShader,fragmentShader:Rn.backgroundCube.fragmentShader,side:kt,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,A,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),h.material.uniforms.envMap.value=x,h.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,h.material.toneMapped=x.colorSpace!==Ge,(u!==x||f!==x.version||d!==r.toneMapping)&&(h.material.needsUpdate=!0,u=x,f=x.version,d=r.toneMapping),h.layers.enableAll(),g.unshift(h,h.geometry,h.material,0,0,null)):x&&x.isTexture&&(c===void 0&&(c=new It(new Ns(2,2),new zn({name:"BackgroundMaterial",uniforms:Dr(Rn.background.uniforms),vertexShader:Rn.background.vertexShader,fragmentShader:Rn.background.fragmentShader,side:Xn,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=x,c.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,c.material.toneMapped=x.colorSpace!==Ge,x.matrixAutoUpdate===!0&&x.updateMatrix(),c.material.uniforms.uvTransform.value.copy(x.matrix),(u!==x||f!==x.version||d!==r.toneMapping)&&(c.material.needsUpdate=!0,u=x,f=x.version,d=r.toneMapping),c.layers.enableAll(),g.unshift(c,c.geometry,c.material,0,0,null))}function _(g,m){g.getRGB(io,dd(r)),n.buffers.color.setClear(io.r,io.g,io.b,m,a)}return{getClearColor:function(){return o},setClearColor:function(g,m=1){o.set(g),l=m,_(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(g){l=g,_(o,l)},render:p}}function nv(r,e,t,n){const i=r.getParameter(r.MAX_VERTEX_ATTRIBS),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),a=n.isWebGL2||s!==null,o={},l=g(null);let c=l,h=!1;function u(N,I,B,O,H){let X=!1;if(a){const ee=_(O,B,I);c!==ee&&(c=ee,d(c.object)),X=m(N,O,B,H),X&&y(N,O,B,H)}else{const ee=I.wireframe===!0;(c.geometry!==O.id||c.program!==B.id||c.wireframe!==ee)&&(c.geometry=O.id,c.program=B.id,c.wireframe=ee,X=!0)}H!==null&&t.update(H,r.ELEMENT_ARRAY_BUFFER),(X||h)&&(h=!1,C(N,I,B,O),H!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(H).buffer))}function f(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function d(N){return n.isWebGL2?r.bindVertexArray(N):s.bindVertexArrayOES(N)}function p(N){return n.isWebGL2?r.deleteVertexArray(N):s.deleteVertexArrayOES(N)}function _(N,I,B){const O=B.wireframe===!0;let H=o[N.id];H===void 0&&(H={},o[N.id]=H);let X=H[I.id];X===void 0&&(X={},H[I.id]=X);let ee=X[O];return ee===void 0&&(ee=g(f()),X[O]=ee),ee}function g(N){const I=[],B=[],O=[];for(let H=0;H<i;H++)I[H]=0,B[H]=0,O[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:B,attributeDivisors:O,object:N,attributes:{},index:null}}function m(N,I,B,O){const H=c.attributes,X=I.attributes;let ee=0;const z=B.getAttributes();for(const Z in z)if(z[Z].location>=0){const ce=H[Z];let fe=X[Z];if(fe===void 0&&(Z==="instanceMatrix"&&N.instanceMatrix&&(fe=N.instanceMatrix),Z==="instanceColor"&&N.instanceColor&&(fe=N.instanceColor)),ce===void 0||ce.attribute!==fe||fe&&ce.data!==fe.data)return!0;ee++}return c.attributesNum!==ee||c.index!==O}function y(N,I,B,O){const H={},X=I.attributes;let ee=0;const z=B.getAttributes();for(const Z in z)if(z[Z].location>=0){let ce=X[Z];ce===void 0&&(Z==="instanceMatrix"&&N.instanceMatrix&&(ce=N.instanceMatrix),Z==="instanceColor"&&N.instanceColor&&(ce=N.instanceColor));const fe={};fe.attribute=ce,ce&&ce.data&&(fe.data=ce.data),H[Z]=fe,ee++}c.attributes=H,c.attributesNum=ee,c.index=O}function x(){const N=c.newAttributes;for(let I=0,B=N.length;I<B;I++)N[I]=0}function v(N){M(N,0)}function M(N,I){const B=c.newAttributes,O=c.enabledAttributes,H=c.attributeDivisors;B[N]=1,O[N]===0&&(r.enableVertexAttribArray(N),O[N]=1),H[N]!==I&&((n.isWebGL2?r:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](N,I),H[N]=I)}function w(){const N=c.newAttributes,I=c.enabledAttributes;for(let B=0,O=I.length;B<O;B++)I[B]!==N[B]&&(r.disableVertexAttribArray(B),I[B]=0)}function A(N,I,B,O,H,X,ee){ee===!0?r.vertexAttribIPointer(N,I,B,H,X):r.vertexAttribPointer(N,I,B,O,H,X)}function C(N,I,B,O){if(n.isWebGL2===!1&&(N.isInstancedMesh||O.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;x();const H=O.attributes,X=B.getAttributes(),ee=I.defaultAttributeValues;for(const z in X){const Z=X[z];if(Z.location>=0){let le=H[z];if(le===void 0&&(z==="instanceMatrix"&&N.instanceMatrix&&(le=N.instanceMatrix),z==="instanceColor"&&N.instanceColor&&(le=N.instanceColor)),le!==void 0){const ce=le.normalized,fe=le.itemSize,Ae=t.get(le);if(Ae===void 0)continue;const Pe=Ae.buffer,Te=Ae.type,Ke=Ae.bytesPerElement,je=n.isWebGL2===!0&&(Te===r.INT||Te===r.UNSIGNED_INT||le.gpuType===ec);if(le.isInterleavedBufferAttribute){const Le=le.data,D=Le.stride,ae=le.offset;if(Le.isInstancedInterleavedBuffer){for(let Q=0;Q<Z.locationSize;Q++)M(Z.location+Q,Le.meshPerAttribute);N.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=Le.meshPerAttribute*Le.count)}else for(let Q=0;Q<Z.locationSize;Q++)v(Z.location+Q);r.bindBuffer(r.ARRAY_BUFFER,Pe);for(let Q=0;Q<Z.locationSize;Q++)A(Z.location+Q,fe/Z.locationSize,Te,ce,D*Ke,(ae+fe/Z.locationSize*Q)*Ke,je)}else{if(le.isInstancedBufferAttribute){for(let Le=0;Le<Z.locationSize;Le++)M(Z.location+Le,le.meshPerAttribute);N.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let Le=0;Le<Z.locationSize;Le++)v(Z.location+Le);r.bindBuffer(r.ARRAY_BUFFER,Pe);for(let Le=0;Le<Z.locationSize;Le++)A(Z.location+Le,fe/Z.locationSize,Te,ce,fe*Ke,fe/Z.locationSize*Le*Ke,je)}}else if(ee!==void 0){const ce=ee[z];if(ce!==void 0)switch(ce.length){case 2:r.vertexAttrib2fv(Z.location,ce);break;case 3:r.vertexAttrib3fv(Z.location,ce);break;case 4:r.vertexAttrib4fv(Z.location,ce);break;default:r.vertexAttrib1fv(Z.location,ce)}}}}w()}function S(){k();for(const N in o){const I=o[N];for(const B in I){const O=I[B];for(const H in O)p(O[H].object),delete O[H];delete I[B]}delete o[N]}}function b(N){if(o[N.id]===void 0)return;const I=o[N.id];for(const B in I){const O=I[B];for(const H in O)p(O[H].object),delete O[H];delete I[B]}delete o[N.id]}function L(N){for(const I in o){const B=o[I];if(B[N.id]===void 0)continue;const O=B[N.id];for(const H in O)p(O[H].object),delete O[H];delete B[N.id]}}function k(){U(),h=!0,c!==l&&(c=l,d(c.object))}function U(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:u,reset:k,resetDefaultState:U,dispose:S,releaseStatesOfGeometry:b,releaseStatesOfProgram:L,initAttributes:x,enableAttribute:v,disableUnusedAttributes:w}}function iv(r,e,t,n){const i=n.isWebGL2;let s;function a(c){s=c}function o(c,h){r.drawArrays(s,c,h),t.update(h,s,1)}function l(c,h,u){if(u===0)return;let f,d;if(i)f=r,d="drawArraysInstanced";else if(f=e.get("ANGLE_instanced_arrays"),d="drawArraysInstancedANGLE",f===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}f[d](s,c,h,u),t.update(h,s,u)}this.setMode=a,this.render=o,this.renderInstances=l}function rv(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(A){if(A==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const a=typeof WebGL2RenderingContext!="undefined"&&r.constructor.name==="WebGL2RenderingContext";let o=t.precision!==void 0?t.precision:"highp";const l=s(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);const c=a||e.has("WEBGL_draw_buffers"),h=t.logarithmicDepthBuffer===!0,u=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),f=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=r.getParameter(r.MAX_TEXTURE_SIZE),p=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),_=r.getParameter(r.MAX_VERTEX_ATTRIBS),g=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),m=r.getParameter(r.MAX_VARYING_VECTORS),y=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),x=f>0,v=a||e.has("OES_texture_float"),M=x&&v,w=a?r.getParameter(r.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:h,maxTextures:u,maxVertexTextures:f,maxTextureSize:d,maxCubemapSize:p,maxAttributes:_,maxVertexUniforms:g,maxVaryings:m,maxFragmentUniforms:y,vertexTextures:x,floatFragmentTextures:v,floatVertexTextures:M,maxSamples:w}}function sv(r){const e=this;let t=null,n=0,i=!1,s=!1;const a=new Ti,o=new Xe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,f){const d=u.length!==0||f||n!==0||i;return i=f,n=u.length,d},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,f){t=h(u,f,0)},this.setState=function(u,f,d){const p=u.clippingPlanes,_=u.clipIntersection,g=u.clipShadows,m=r.get(u);if(!i||p===null||p.length===0||s&&!g)s?h(null):c();else{const y=s?0:n,x=y*4;let v=m.clippingState||null;l.value=v,v=h(p,f,x,d);for(let M=0;M!==x;++M)v[M]=t[M];m.clippingState=v,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,f,d,p){const _=u!==null?u.length:0;let g=null;if(_!==0){if(g=l.value,p!==!0||g===null){const m=d+_*4,y=f.matrixWorldInverse;o.getNormalMatrix(y),(g===null||g.length<m)&&(g=new Float32Array(m));for(let x=0,v=d;x!==_;++x,v+=4)a.copy(u[x]).applyMatrix4(y,o),a.normal.toArray(g,v),g[v+3]=a.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,g}}function av(r){let e=new WeakMap;function t(a,o){return o===ms?a.mapping=pi:o===gs&&(a.mapping=mi),a}function n(a){if(a&&a.isTexture&&a.isRenderTargetTexture===!1){const o=a.mapping;if(o===ms||o===gs)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new gd(l.height/2);return c.fromEquirectangularTexture(r,a),e.set(a,c),a.addEventListener("dispose",i),t(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class ro extends eo{constructor(e=-1,t=1,n=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,a){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=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Or=4,xd=[.125,.215,.35,.446,.526,.582],Xi=20,nh=new ro,yd=new ye;let ih=null;const qi=(1+Math.sqrt(5))/2,Br=1/qi,vd=[new R(1,1,1),new R(-1,1,1),new R(1,1,-1),new R(-1,1,-1),new R(0,qi,Br),new R(0,qi,-Br),new R(Br,0,qi),new R(-Br,0,qi),new R(qi,Br,0),new R(-qi,Br,0)];class rh{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){ih=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=bd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Sd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.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._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(ih),e.scissorTest=!1,so(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===pi||e.mapping===mi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ih=this._renderer.getRenderTarget();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:vt,minFilter:vt,generateMipmaps:!1,type:gr,format:an,colorSpace:Sn,depthBuffer:!1},i=Md(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Md(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=ov(s)),this._blurMaterial=lv(s,e,t)}return i}_compileMaterial(e){const t=new It(this._lodPlanes[0],e);this._renderer.compile(t,nh)}_sceneToCubeUV(e,t,n,i){const o=new Ut(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,f=h.toneMapping;h.getClearColor(yd),h.toneMapping=Fn,h.autoClear=!1;const d=new Ai({name:"PMREM.Background",side:kt,depthWrite:!1,depthTest:!1}),p=new It(new Vi,d);let _=!1;const g=e.background;g?g.isColor&&(d.color.copy(g),e.background=null,_=!0):(d.color.copy(yd),_=!0);for(let m=0;m<6;m++){const y=m%3;y===0?(o.up.set(0,l[m],0),o.lookAt(c[m],0,0)):y===1?(o.up.set(0,0,l[m]),o.lookAt(0,c[m],0)):(o.up.set(0,l[m],0),o.lookAt(0,0,c[m]));const x=this._cubeSize;so(i,y*x,m>2?x:0,x,x),h.setRenderTarget(i),_&&h.render(p,o),h.render(e,o)}p.geometry.dispose(),p.material.dispose(),h.toneMapping=f,h.autoClear=u,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===pi||e.mapping===mi;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=bd()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Sd());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new It(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;so(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,nh)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),a=vd[(i-1)%vd.length];this._blur(e,i-1,i,s,a)}t.autoClear=n}_blur(e,t,n,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",s),this._halfBlur(a,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new It(this._lodPlanes[i],c),f=c.uniforms,d=this._sizeLods[n]-1,p=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*Xi-1),_=s/p,g=isFinite(s)?1+Math.floor(h*_):Xi;g>Xi&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Xi}`);const m=[];let y=0;for(let A=0;A<Xi;++A){const C=A/_,S=Math.exp(-C*C/2);m.push(S),A===0?y+=S:A<g&&(y+=2*S)}for(let A=0;A<m.length;A++)m[A]=m[A]/y;f.envMap.value=e.texture,f.samples.value=g,f.weights.value=m,f.latitudinal.value=a==="latitudinal",o&&(f.poleAxis.value=o);const{_lodMax:x}=this;f.dTheta.value=p,f.mipInt.value=x-n;const v=this._sizeLods[i],M=3*v*(i>x-Or?i-x+Or:0),w=4*(this._cubeSize-v);so(t,M,w,3*v,2*v),l.setRenderTarget(t),l.render(u,nh)}}function ov(r){const e=[],t=[],n=[];let i=r;const s=r-Or+1+xd.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);t.push(o);let l=1/o;a>r-Or?l=xd[a-r+Or-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,f=[h,h,u,h,u,u,h,h,u,u,h,u],d=6,p=6,_=3,g=2,m=1,y=new Float32Array(_*p*d),x=new Float32Array(g*p*d),v=new Float32Array(m*p*d);for(let w=0;w<d;w++){const A=w%3*2/3-1,C=w>2?0:-1,S=[A,C,0,A+2/3,C,0,A+2/3,C+1,0,A,C,0,A+2/3,C+1,0,A,C+1,0];y.set(S,_*p*w),x.set(f,g*p*w);const b=[w,w,w,w,w,w];v.set(b,m*p*w)}const M=new Fe;M.setAttribute("position",new Ze(y,_)),M.setAttribute("uv",new Ze(x,g)),M.setAttribute("faceIndex",new Ze(v,m)),e.push(M),i>Or&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Md(r,e,t){const n=new bn(r,e,t);return n.texture.mapping=mr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function so(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function lv(r,e,t){const n=new Float32Array(Xi),i=new R(0,1,0);return new zn({name:"SphericalGaussianBlur",defines:{n:Xi,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:sh(),fragmentShader:`
3348
3348
 
3349
3349
  precision mediump float;
3350
3350
  precision mediump int;
@@ -3404,7 +3404,7 @@ void main() {
3404
3404
  }
3405
3405
 
3406
3406
  }
3407
- `,blending:qn,depthTest:!1,depthWrite:!1})}function Md(){return new zn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:sh(),fragmentShader:`
3407
+ `,blending:qn,depthTest:!1,depthWrite:!1})}function Sd(){return new zn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:sh(),fragmentShader:`
3408
3408
 
3409
3409
  precision mediump float;
3410
3410
  precision mediump int;
@@ -3423,7 +3423,7 @@ void main() {
3423
3423
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3424
3424
 
3425
3425
  }
3426
- `,blending:qn,depthTest:!1,depthWrite:!1})}function Sd(){return new zn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:sh(),fragmentShader:`
3426
+ `,blending:qn,depthTest:!1,depthWrite:!1})}function bd(){return new zn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:sh(),fragmentShader:`
3427
3427
 
3428
3428
  precision mediump float;
3429
3429
  precision mediump int;
@@ -3494,39 +3494,39 @@ void main() {
3494
3494
  gl_Position = vec4( position, 1.0 );
3495
3495
 
3496
3496
  }
3497
- `}function lv(r){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===ms||l===gs,h=l===pi||l===mi;if(c||h)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let u=e.get(o);return t===null&&(t=new rh(r)),u=c?t.fromEquirectangular(o,u):t.fromCubemap(o,u),e.set(o,u),u.texture}else{if(e.has(o))return e.get(o).texture;{const u=o.image;if(c&&u&&u.height>0||h&&u&&i(u)){t===null&&(t=new rh(r));const f=c?t.fromEquirectangular(o):t.fromCubemap(o);return e.set(o,f),o.addEventListener("dispose",s),f.texture}else return null}}}return o}function i(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function cv(r){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){const i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function hv(r,e,t,n){const i={},s=new WeakMap;function a(u){const f=u.target;f.index!==null&&e.remove(f.index);for(const p in f.attributes)e.remove(f.attributes[p]);for(const p in f.morphAttributes){const _=f.morphAttributes[p];for(let g=0,m=_.length;g<m;g++)e.remove(_[g])}f.removeEventListener("dispose",a),delete i[f.id];const d=s.get(f);d&&(e.remove(d),s.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function o(u,f){return i[f.id]===!0||(f.addEventListener("dispose",a),i[f.id]=!0,t.memory.geometries++),f}function l(u){const f=u.attributes;for(const p in f)e.update(f[p],r.ARRAY_BUFFER);const d=u.morphAttributes;for(const p in d){const _=d[p];for(let g=0,m=_.length;g<m;g++)e.update(_[g],r.ARRAY_BUFFER)}}function c(u){const f=[],d=u.index,p=u.attributes.position;let _=0;if(d!==null){const y=d.array;_=d.version;for(let x=0,v=y.length;x<v;x+=3){const M=y[x+0],w=y[x+1],A=y[x+2];f.push(M,w,w,A,A,M)}}else{const y=p.array;_=p.version;for(let x=0,v=y.length/3-1;x<v;x+=3){const M=x+0,w=x+1,A=x+2;f.push(M,w,w,A,A,M)}}const g=new(Zf(f)?jc:Kc)(f,1);g.version=_;const m=s.get(u);m&&e.remove(m),s.set(u,g)}function h(u){const f=s.get(u);if(f){const d=u.index;d!==null&&f.version<d.version&&c(u)}else c(u);return s.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function uv(r,e,t,n){const i=n.isWebGL2;let s;function a(f){s=f}let o,l;function c(f){o=f.type,l=f.bytesPerElement}function h(f,d){r.drawElements(s,d,o,f*l),t.update(d,s,1)}function u(f,d,p){if(p===0)return;let _,g;if(i)_=r,g="drawElementsInstanced";else if(_=e.get("ANGLE_instanced_arrays"),g="drawElementsInstancedANGLE",_===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}_[g](s,d,o,f*l,p),t.update(d,s,p)}this.setMode=a,this.setIndex=c,this.render=h,this.renderInstances=u}function fv(r){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case r.TRIANGLES:t.triangles+=o*(s/3);break;case r.LINES:t.lines+=o*(s/2);break;case r.LINE_STRIP:t.lines+=o*(s-1);break;case r.LINE_LOOP:t.lines+=o*s;break;case r.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function dv(r,e){return r[0]-e[0]}function pv(r,e){return Math.abs(e[1])-Math.abs(r[1])}function mv(r,e,t){const n={},i=new Float32Array(8),s=new WeakMap,a=new rt,o=[];for(let c=0;c<8;c++)o[c]=[c,0];function l(c,h,u){const f=c.morphTargetInfluences;if(e.isWebGL2===!0){const d=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,p=d!==void 0?d.length:0;let _=s.get(h);if(_===void 0||_.count!==p){let N=function(){k.dispose(),s.delete(h),h.removeEventListener("dispose",N)};_!==void 0&&_.texture.dispose();const y=h.morphAttributes.position!==void 0,x=h.morphAttributes.normal!==void 0,v=h.morphAttributes.color!==void 0,M=h.morphAttributes.position||[],w=h.morphAttributes.normal||[],A=h.morphAttributes.color||[];let C=0;y===!0&&(C=1),x===!0&&(C=2),v===!0&&(C=3);let S=h.attributes.position.count*C,b=1;S>e.maxTextureSize&&(b=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);const L=new Float32Array(S*b*4*p),k=new Na(L,S,b,p);k.type=On,k.needsUpdate=!0;const U=C*4;for(let I=0;I<p;I++){const B=M[I],O=w[I],H=A[I],X=S*b*4*I;for(let ee=0;ee<B.count;ee++){const z=ee*U;y===!0&&(a.fromBufferAttribute(B,ee),L[X+z+0]=a.x,L[X+z+1]=a.y,L[X+z+2]=a.z,L[X+z+3]=0),x===!0&&(a.fromBufferAttribute(O,ee),L[X+z+4]=a.x,L[X+z+5]=a.y,L[X+z+6]=a.z,L[X+z+7]=0),v===!0&&(a.fromBufferAttribute(H,ee),L[X+z+8]=a.x,L[X+z+9]=a.y,L[X+z+10]=a.z,L[X+z+11]=H.itemSize===4?a.w:1)}}_={count:p,texture:k,size:new q(S,b)},s.set(h,_),h.addEventListener("dispose",N)}let g=0;for(let y=0;y<f.length;y++)g+=f[y];const m=h.morphTargetsRelative?1:1-g;u.getUniforms().setValue(r,"morphTargetBaseInfluence",m),u.getUniforms().setValue(r,"morphTargetInfluences",f),u.getUniforms().setValue(r,"morphTargetsTexture",_.texture,t),u.getUniforms().setValue(r,"morphTargetsTextureSize",_.size)}else{const d=f===void 0?0:f.length;let p=n[h.id];if(p===void 0||p.length!==d){p=[];for(let x=0;x<d;x++)p[x]=[x,0];n[h.id]=p}for(let x=0;x<d;x++){const v=p[x];v[0]=x,v[1]=f[x]}p.sort(pv);for(let x=0;x<8;x++)x<d&&p[x][1]?(o[x][0]=p[x][0],o[x][1]=p[x][1]):(o[x][0]=Number.MAX_SAFE_INTEGER,o[x][1]=0);o.sort(dv);const _=h.morphAttributes.position,g=h.morphAttributes.normal;let m=0;for(let x=0;x<8;x++){const v=o[x],M=v[0],w=v[1];M!==Number.MAX_SAFE_INTEGER&&w?(_&&h.getAttribute("morphTarget"+x)!==_[M]&&h.setAttribute("morphTarget"+x,_[M]),g&&h.getAttribute("morphNormal"+x)!==g[M]&&h.setAttribute("morphNormal"+x,g[M]),i[x]=w,m+=w):(_&&h.hasAttribute("morphTarget"+x)===!0&&h.deleteAttribute("morphTarget"+x),g&&h.hasAttribute("morphNormal"+x)===!0&&h.deleteAttribute("morphNormal"+x),i[x]=0)}const y=h.morphTargetsRelative?1:1-m;u.getUniforms().setValue(r,"morphTargetBaseInfluence",y),u.getUniforms().setValue(r,"morphTargetInfluences",i)}}return{update:l}}function gv(r,e,t,n){let i=new WeakMap;function s(l){const c=n.render.frame,h=l.geometry,u=e.get(l,h);if(i.get(u)!==c&&(e.update(u),i.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(t.update(l.instanceMatrix,r.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,r.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const f=l.skeleton;i.get(f)!==c&&(f.update(),i.set(f,c))}return u}function a(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}const bd=new Mt,wd=new Na,Ed=new zc,Ad=new Ds,Td=[],Rd=[],Cd=new Float32Array(16),Pd=new Float32Array(9),Ld=new Float32Array(4);function zr(r,e,t){const n=r[0];if(n<=0||n>0)return r;const i=e*t;let s=Td[i];if(s===void 0&&(s=new Float32Array(i),Td[i]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,r[a].toArray(s,o)}return s}function Tt(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function Rt(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function ao(r,e){let t=Rd[e];t===void 0&&(t=new Int32Array(e),Rd[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function _v(r,e){const t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function xv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Tt(t,e))return;r.uniform2fv(this.addr,e),Rt(t,e)}}function yv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Tt(t,e))return;r.uniform3fv(this.addr,e),Rt(t,e)}}function vv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Tt(t,e))return;r.uniform4fv(this.addr,e),Rt(t,e)}}function Mv(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Tt(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),Rt(t,e)}else{if(Tt(t,n))return;Ld.set(n),r.uniformMatrix2fv(this.addr,!1,Ld),Rt(t,n)}}function Sv(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Tt(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),Rt(t,e)}else{if(Tt(t,n))return;Pd.set(n),r.uniformMatrix3fv(this.addr,!1,Pd),Rt(t,n)}}function bv(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Tt(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),Rt(t,e)}else{if(Tt(t,n))return;Cd.set(n),r.uniformMatrix4fv(this.addr,!1,Cd),Rt(t,n)}}function wv(r,e){const t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function Ev(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Tt(t,e))return;r.uniform2iv(this.addr,e),Rt(t,e)}}function Av(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Tt(t,e))return;r.uniform3iv(this.addr,e),Rt(t,e)}}function Tv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Tt(t,e))return;r.uniform4iv(this.addr,e),Rt(t,e)}}function Rv(r,e){const t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function Cv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Tt(t,e))return;r.uniform2uiv(this.addr,e),Rt(t,e)}}function Pv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Tt(t,e))return;r.uniform3uiv(this.addr,e),Rt(t,e)}}function Lv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Tt(t,e))return;r.uniform4uiv(this.addr,e),Rt(t,e)}}function Iv(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2D(e||bd,i)}function Uv(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Ed,i)}function Dv(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Ad,i)}function Nv(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||wd,i)}function Fv(r){switch(r){case 5126:return _v;case 35664:return xv;case 35665:return yv;case 35666:return vv;case 35674:return Mv;case 35675:return Sv;case 35676:return bv;case 5124:case 35670:return wv;case 35667:case 35671:return Ev;case 35668:case 35672:return Av;case 35669:case 35673:return Tv;case 5125:return Rv;case 36294:return Cv;case 36295:return Pv;case 36296:return Lv;case 35678:case 36198:case 36298:case 36306:case 35682:return Iv;case 35679:case 36299:case 36307:return Uv;case 35680:case 36300:case 36308:case 36293:return Dv;case 36289:case 36303:case 36311:case 36292:return Nv}}function Ov(r,e){r.uniform1fv(this.addr,e)}function Bv(r,e){const t=zr(e,this.size,2);r.uniform2fv(this.addr,t)}function zv(r,e){const t=zr(e,this.size,3);r.uniform3fv(this.addr,t)}function kv(r,e){const t=zr(e,this.size,4);r.uniform4fv(this.addr,t)}function Gv(r,e){const t=zr(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function Hv(r,e){const t=zr(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function Vv(r,e){const t=zr(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function Wv(r,e){r.uniform1iv(this.addr,e)}function Xv(r,e){r.uniform2iv(this.addr,e)}function qv(r,e){r.uniform3iv(this.addr,e)}function $v(r,e){r.uniform4iv(this.addr,e)}function Yv(r,e){r.uniform1uiv(this.addr,e)}function Zv(r,e){r.uniform2uiv(this.addr,e)}function Jv(r,e){r.uniform3uiv(this.addr,e)}function Kv(r,e){r.uniform4uiv(this.addr,e)}function jv(r,e,t){const n=this.cache,i=e.length,s=ao(t,i);Tt(n,s)||(r.uniform1iv(this.addr,s),Rt(n,s));for(let a=0;a!==i;++a)t.setTexture2D(e[a]||bd,s[a])}function Qv(r,e,t){const n=this.cache,i=e.length,s=ao(t,i);Tt(n,s)||(r.uniform1iv(this.addr,s),Rt(n,s));for(let a=0;a!==i;++a)t.setTexture3D(e[a]||Ed,s[a])}function eM(r,e,t){const n=this.cache,i=e.length,s=ao(t,i);Tt(n,s)||(r.uniform1iv(this.addr,s),Rt(n,s));for(let a=0;a!==i;++a)t.setTextureCube(e[a]||Ad,s[a])}function tM(r,e,t){const n=this.cache,i=e.length,s=ao(t,i);Tt(n,s)||(r.uniform1iv(this.addr,s),Rt(n,s));for(let a=0;a!==i;++a)t.setTexture2DArray(e[a]||wd,s[a])}function nM(r){switch(r){case 5126:return Ov;case 35664:return Bv;case 35665:return zv;case 35666:return kv;case 35674:return Gv;case 35675:return Hv;case 35676:return Vv;case 5124:case 35670:return Wv;case 35667:case 35671:return Xv;case 35668:case 35672:return qv;case 35669:case 35673:return $v;case 5125:return Yv;case 36294:return Zv;case 36295:return Jv;case 36296:return Kv;case 35678:case 36198:case 36298:case 36306:case 35682:return jv;case 35679:case 36299:case 36307:return Qv;case 35680:case 36300:case 36308:case 36293:return eM;case 36289:case 36303:case 36311:case 36292:return tM}}class iM{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=Fv(t.type)}}class rM{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=nM(t.type)}}class sM{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(e,t[o.id],n)}}}const ah=/(\w+)(\])?(\[|\.)?/g;function Id(r,e){r.seq.push(e),r.map[e.id]=e}function aM(r,e,t){const n=r.name,i=n.length;for(ah.lastIndex=0;;){const s=ah.exec(n),a=ah.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){Id(t,c===void 0?new iM(o,r,e):new rM(o,r,e));break}else{let u=t.map[o];u===void 0&&(u=new sM(o),Id(t,u)),t=u}}}class oo{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const s=e.getActiveUniform(t,i),a=e.getUniformLocation(t,s.name);aM(s,a,this)}}setValue(e,t,n,i){const s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in t&&n.push(a)}return n}}function Ud(r,e,t){const n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}let oM=0;function lM(r,e){const t=r.split(`
3497
+ `}function cv(r){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===ms||l===gs,h=l===pi||l===mi;if(c||h)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let u=e.get(o);return t===null&&(t=new rh(r)),u=c?t.fromEquirectangular(o,u):t.fromCubemap(o,u),e.set(o,u),u.texture}else{if(e.has(o))return e.get(o).texture;{const u=o.image;if(c&&u&&u.height>0||h&&u&&i(u)){t===null&&(t=new rh(r));const f=c?t.fromEquirectangular(o):t.fromCubemap(o);return e.set(o,f),o.addEventListener("dispose",s),f.texture}else return null}}}return o}function i(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function hv(r){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){const i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function uv(r,e,t,n){const i={},s=new WeakMap;function a(u){const f=u.target;f.index!==null&&e.remove(f.index);for(const p in f.attributes)e.remove(f.attributes[p]);for(const p in f.morphAttributes){const _=f.morphAttributes[p];for(let g=0,m=_.length;g<m;g++)e.remove(_[g])}f.removeEventListener("dispose",a),delete i[f.id];const d=s.get(f);d&&(e.remove(d),s.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function o(u,f){return i[f.id]===!0||(f.addEventListener("dispose",a),i[f.id]=!0,t.memory.geometries++),f}function l(u){const f=u.attributes;for(const p in f)e.update(f[p],r.ARRAY_BUFFER);const d=u.morphAttributes;for(const p in d){const _=d[p];for(let g=0,m=_.length;g<m;g++)e.update(_[g],r.ARRAY_BUFFER)}}function c(u){const f=[],d=u.index,p=u.attributes.position;let _=0;if(d!==null){const y=d.array;_=d.version;for(let x=0,v=y.length;x<v;x+=3){const M=y[x+0],w=y[x+1],A=y[x+2];f.push(M,w,w,A,A,M)}}else{const y=p.array;_=p.version;for(let x=0,v=y.length/3-1;x<v;x+=3){const M=x+0,w=x+1,A=x+2;f.push(M,w,w,A,A,M)}}const g=new(Jf(f)?jc:Kc)(f,1);g.version=_;const m=s.get(u);m&&e.remove(m),s.set(u,g)}function h(u){const f=s.get(u);if(f){const d=u.index;d!==null&&f.version<d.version&&c(u)}else c(u);return s.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function fv(r,e,t,n){const i=n.isWebGL2;let s;function a(f){s=f}let o,l;function c(f){o=f.type,l=f.bytesPerElement}function h(f,d){r.drawElements(s,d,o,f*l),t.update(d,s,1)}function u(f,d,p){if(p===0)return;let _,g;if(i)_=r,g="drawElementsInstanced";else if(_=e.get("ANGLE_instanced_arrays"),g="drawElementsInstancedANGLE",_===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}_[g](s,d,o,f*l,p),t.update(d,s,p)}this.setMode=a,this.setIndex=c,this.render=h,this.renderInstances=u}function dv(r){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case r.TRIANGLES:t.triangles+=o*(s/3);break;case r.LINES:t.lines+=o*(s/2);break;case r.LINE_STRIP:t.lines+=o*(s-1);break;case r.LINE_LOOP:t.lines+=o*s;break;case r.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function pv(r,e){return r[0]-e[0]}function mv(r,e){return Math.abs(e[1])-Math.abs(r[1])}function gv(r,e,t){const n={},i=new Float32Array(8),s=new WeakMap,a=new rt,o=[];for(let c=0;c<8;c++)o[c]=[c,0];function l(c,h,u){const f=c.morphTargetInfluences;if(e.isWebGL2===!0){const d=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,p=d!==void 0?d.length:0;let _=s.get(h);if(_===void 0||_.count!==p){let N=function(){k.dispose(),s.delete(h),h.removeEventListener("dispose",N)};_!==void 0&&_.texture.dispose();const y=h.morphAttributes.position!==void 0,x=h.morphAttributes.normal!==void 0,v=h.morphAttributes.color!==void 0,M=h.morphAttributes.position||[],w=h.morphAttributes.normal||[],A=h.morphAttributes.color||[];let C=0;y===!0&&(C=1),x===!0&&(C=2),v===!0&&(C=3);let S=h.attributes.position.count*C,b=1;S>e.maxTextureSize&&(b=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);const L=new Float32Array(S*b*4*p),k=new Na(L,S,b,p);k.type=On,k.needsUpdate=!0;const U=C*4;for(let I=0;I<p;I++){const B=M[I],O=w[I],H=A[I],X=S*b*4*I;for(let ee=0;ee<B.count;ee++){const z=ee*U;y===!0&&(a.fromBufferAttribute(B,ee),L[X+z+0]=a.x,L[X+z+1]=a.y,L[X+z+2]=a.z,L[X+z+3]=0),x===!0&&(a.fromBufferAttribute(O,ee),L[X+z+4]=a.x,L[X+z+5]=a.y,L[X+z+6]=a.z,L[X+z+7]=0),v===!0&&(a.fromBufferAttribute(H,ee),L[X+z+8]=a.x,L[X+z+9]=a.y,L[X+z+10]=a.z,L[X+z+11]=H.itemSize===4?a.w:1)}}_={count:p,texture:k,size:new q(S,b)},s.set(h,_),h.addEventListener("dispose",N)}let g=0;for(let y=0;y<f.length;y++)g+=f[y];const m=h.morphTargetsRelative?1:1-g;u.getUniforms().setValue(r,"morphTargetBaseInfluence",m),u.getUniforms().setValue(r,"morphTargetInfluences",f),u.getUniforms().setValue(r,"morphTargetsTexture",_.texture,t),u.getUniforms().setValue(r,"morphTargetsTextureSize",_.size)}else{const d=f===void 0?0:f.length;let p=n[h.id];if(p===void 0||p.length!==d){p=[];for(let x=0;x<d;x++)p[x]=[x,0];n[h.id]=p}for(let x=0;x<d;x++){const v=p[x];v[0]=x,v[1]=f[x]}p.sort(mv);for(let x=0;x<8;x++)x<d&&p[x][1]?(o[x][0]=p[x][0],o[x][1]=p[x][1]):(o[x][0]=Number.MAX_SAFE_INTEGER,o[x][1]=0);o.sort(pv);const _=h.morphAttributes.position,g=h.morphAttributes.normal;let m=0;for(let x=0;x<8;x++){const v=o[x],M=v[0],w=v[1];M!==Number.MAX_SAFE_INTEGER&&w?(_&&h.getAttribute("morphTarget"+x)!==_[M]&&h.setAttribute("morphTarget"+x,_[M]),g&&h.getAttribute("morphNormal"+x)!==g[M]&&h.setAttribute("morphNormal"+x,g[M]),i[x]=w,m+=w):(_&&h.hasAttribute("morphTarget"+x)===!0&&h.deleteAttribute("morphTarget"+x),g&&h.hasAttribute("morphNormal"+x)===!0&&h.deleteAttribute("morphNormal"+x),i[x]=0)}const y=h.morphTargetsRelative?1:1-m;u.getUniforms().setValue(r,"morphTargetBaseInfluence",y),u.getUniforms().setValue(r,"morphTargetInfluences",i)}}return{update:l}}function _v(r,e,t,n){let i=new WeakMap;function s(l){const c=n.render.frame,h=l.geometry,u=e.get(l,h);if(i.get(u)!==c&&(e.update(u),i.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(t.update(l.instanceMatrix,r.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,r.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const f=l.skeleton;i.get(f)!==c&&(f.update(),i.set(f,c))}return u}function a(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}const wd=new Mt,Ed=new Na,Ad=new zc,Td=new Ds,Rd=[],Cd=[],Pd=new Float32Array(16),Ld=new Float32Array(9),Id=new Float32Array(4);function zr(r,e,t){const n=r[0];if(n<=0||n>0)return r;const i=e*t;let s=Rd[i];if(s===void 0&&(s=new Float32Array(i),Rd[i]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,r[a].toArray(s,o)}return s}function Tt(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function Rt(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function ao(r,e){let t=Cd[e];t===void 0&&(t=new Int32Array(e),Cd[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function xv(r,e){const t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function yv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Tt(t,e))return;r.uniform2fv(this.addr,e),Rt(t,e)}}function vv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Tt(t,e))return;r.uniform3fv(this.addr,e),Rt(t,e)}}function Mv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Tt(t,e))return;r.uniform4fv(this.addr,e),Rt(t,e)}}function Sv(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Tt(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),Rt(t,e)}else{if(Tt(t,n))return;Id.set(n),r.uniformMatrix2fv(this.addr,!1,Id),Rt(t,n)}}function bv(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Tt(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),Rt(t,e)}else{if(Tt(t,n))return;Ld.set(n),r.uniformMatrix3fv(this.addr,!1,Ld),Rt(t,n)}}function wv(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Tt(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),Rt(t,e)}else{if(Tt(t,n))return;Pd.set(n),r.uniformMatrix4fv(this.addr,!1,Pd),Rt(t,n)}}function Ev(r,e){const t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function Av(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Tt(t,e))return;r.uniform2iv(this.addr,e),Rt(t,e)}}function Tv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Tt(t,e))return;r.uniform3iv(this.addr,e),Rt(t,e)}}function Rv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Tt(t,e))return;r.uniform4iv(this.addr,e),Rt(t,e)}}function Cv(r,e){const t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function Pv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Tt(t,e))return;r.uniform2uiv(this.addr,e),Rt(t,e)}}function Lv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Tt(t,e))return;r.uniform3uiv(this.addr,e),Rt(t,e)}}function Iv(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Tt(t,e))return;r.uniform4uiv(this.addr,e),Rt(t,e)}}function Uv(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2D(e||wd,i)}function Dv(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Ad,i)}function Nv(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Td,i)}function Fv(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Ed,i)}function Ov(r){switch(r){case 5126:return xv;case 35664:return yv;case 35665:return vv;case 35666:return Mv;case 35674:return Sv;case 35675:return bv;case 35676:return wv;case 5124:case 35670:return Ev;case 35667:case 35671:return Av;case 35668:case 35672:return Tv;case 35669:case 35673:return Rv;case 5125:return Cv;case 36294:return Pv;case 36295:return Lv;case 36296:return Iv;case 35678:case 36198:case 36298:case 36306:case 35682:return Uv;case 35679:case 36299:case 36307:return Dv;case 35680:case 36300:case 36308:case 36293:return Nv;case 36289:case 36303:case 36311:case 36292:return Fv}}function Bv(r,e){r.uniform1fv(this.addr,e)}function zv(r,e){const t=zr(e,this.size,2);r.uniform2fv(this.addr,t)}function kv(r,e){const t=zr(e,this.size,3);r.uniform3fv(this.addr,t)}function Gv(r,e){const t=zr(e,this.size,4);r.uniform4fv(this.addr,t)}function Hv(r,e){const t=zr(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function Vv(r,e){const t=zr(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function Wv(r,e){const t=zr(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function Xv(r,e){r.uniform1iv(this.addr,e)}function qv(r,e){r.uniform2iv(this.addr,e)}function $v(r,e){r.uniform3iv(this.addr,e)}function Yv(r,e){r.uniform4iv(this.addr,e)}function Zv(r,e){r.uniform1uiv(this.addr,e)}function Jv(r,e){r.uniform2uiv(this.addr,e)}function Kv(r,e){r.uniform3uiv(this.addr,e)}function jv(r,e){r.uniform4uiv(this.addr,e)}function Qv(r,e,t){const n=this.cache,i=e.length,s=ao(t,i);Tt(n,s)||(r.uniform1iv(this.addr,s),Rt(n,s));for(let a=0;a!==i;++a)t.setTexture2D(e[a]||wd,s[a])}function eM(r,e,t){const n=this.cache,i=e.length,s=ao(t,i);Tt(n,s)||(r.uniform1iv(this.addr,s),Rt(n,s));for(let a=0;a!==i;++a)t.setTexture3D(e[a]||Ad,s[a])}function tM(r,e,t){const n=this.cache,i=e.length,s=ao(t,i);Tt(n,s)||(r.uniform1iv(this.addr,s),Rt(n,s));for(let a=0;a!==i;++a)t.setTextureCube(e[a]||Td,s[a])}function nM(r,e,t){const n=this.cache,i=e.length,s=ao(t,i);Tt(n,s)||(r.uniform1iv(this.addr,s),Rt(n,s));for(let a=0;a!==i;++a)t.setTexture2DArray(e[a]||Ed,s[a])}function iM(r){switch(r){case 5126:return Bv;case 35664:return zv;case 35665:return kv;case 35666:return Gv;case 35674:return Hv;case 35675:return Vv;case 35676:return Wv;case 5124:case 35670:return Xv;case 35667:case 35671:return qv;case 35668:case 35672:return $v;case 35669:case 35673:return Yv;case 5125:return Zv;case 36294:return Jv;case 36295:return Kv;case 36296:return jv;case 35678:case 36198:case 36298:case 36306:case 35682:return Qv;case 35679:case 36299:case 36307:return eM;case 35680:case 36300:case 36308:case 36293:return tM;case 36289:case 36303:case 36311:case 36292:return nM}}class rM{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=Ov(t.type)}}class sM{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=iM(t.type)}}class aM{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(e,t[o.id],n)}}}const ah=/(\w+)(\])?(\[|\.)?/g;function Ud(r,e){r.seq.push(e),r.map[e.id]=e}function oM(r,e,t){const n=r.name,i=n.length;for(ah.lastIndex=0;;){const s=ah.exec(n),a=ah.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){Ud(t,c===void 0?new rM(o,r,e):new sM(o,r,e));break}else{let u=t.map[o];u===void 0&&(u=new aM(o),Ud(t,u)),t=u}}}class oo{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const s=e.getActiveUniform(t,i),a=e.getUniformLocation(t,s.name);oM(s,a,this)}}setValue(e,t,n,i){const s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in t&&n.push(a)}return n}}function Dd(r,e,t){const n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}let lM=0;function cM(r,e){const t=r.split(`
3498
3498
  `),n=[],i=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=i;a<s;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
3499
- `)}function cM(r){switch(r){case Sn:return["Linear","( value )"];case Ge:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",r),["Linear","( value )"]}}function Dd(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const a=parseInt(s[1]);return t.toUpperCase()+`
3499
+ `)}function hM(r){switch(r){case Sn:return["Linear","( value )"];case Ge:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",r),["Linear","( value )"]}}function Nd(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const a=parseInt(s[1]);return t.toUpperCase()+`
3500
3500
 
3501
3501
  `+i+`
3502
3502
 
3503
- `+lM(r.getShaderSource(e),a)}else return i}function hM(r,e){const t=cM(e);return"vec4 "+r+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function uM(r,e){let t;switch(e){case xf:t="Linear";break;case yf:t="Reinhard";break;case vf:t="OptimizedCineon";break;case Mf:t="ACESFilmic";break;case Sf:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function fM(r){return[r.extensionDerivatives||r.envMapCubeUVHeight||r.bumpMap||r.normalMapTangentSpace||r.clearcoatNormalMap||r.flatShading||r.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(r.extensionFragDepth||r.logarithmicDepthBuffer)&&r.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",r.extensionDrawBuffers&&r.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(r.extensionShaderTextureLOD||r.envMap||r.transmission)&&r.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Fs).join(`
3504
- `)}function dM(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3505
- `)}function pM(r,e){const t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const s=r.getActiveAttrib(e,i),a=s.name;let o=1;s.type===r.FLOAT_MAT2&&(o=2),s.type===r.FLOAT_MAT3&&(o=3),s.type===r.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:r.getAttribLocation(e,a),locationSize:o}}return t}function Fs(r){return r!==""}function Nd(r,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return r.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Fd(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const mM=/^[ \t]*#include +<([\w\d./]+)>/gm;function oh(r){return r.replace(mM,_M)}const gM=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function _M(r,e){let t=Ve[e];if(t===void 0){const n=gM.get(e);if(n!==void 0)t=Ve[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return oh(t)}const xM=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Od(r){return r.replace(xM,yM)}function yM(r,e,t,n){let i="";for(let s=parseInt(e);s<parseInt(t);s++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function Bd(r){let e="precision "+r.precision+` float;
3503
+ `+cM(r.getShaderSource(e),a)}else return i}function uM(r,e){const t=hM(e);return"vec4 "+r+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function fM(r,e){let t;switch(e){case yf:t="Linear";break;case vf:t="Reinhard";break;case Mf:t="OptimizedCineon";break;case Sf:t="ACESFilmic";break;case bf:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function dM(r){return[r.extensionDerivatives||r.envMapCubeUVHeight||r.bumpMap||r.normalMapTangentSpace||r.clearcoatNormalMap||r.flatShading||r.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(r.extensionFragDepth||r.logarithmicDepthBuffer)&&r.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",r.extensionDrawBuffers&&r.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(r.extensionShaderTextureLOD||r.envMap||r.transmission)&&r.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Fs).join(`
3504
+ `)}function pM(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3505
+ `)}function mM(r,e){const t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const s=r.getActiveAttrib(e,i),a=s.name;let o=1;s.type===r.FLOAT_MAT2&&(o=2),s.type===r.FLOAT_MAT3&&(o=3),s.type===r.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:r.getAttribLocation(e,a),locationSize:o}}return t}function Fs(r){return r!==""}function Fd(r,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return r.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Od(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const gM=/^[ \t]*#include +<([\w\d./]+)>/gm;function oh(r){return r.replace(gM,xM)}const _M=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function xM(r,e){let t=Ve[e];if(t===void 0){const n=_M.get(e);if(n!==void 0)t=Ve[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return oh(t)}const yM=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Bd(r){return r.replace(yM,vM)}function vM(r,e,t,n){let i="";for(let s=parseInt(e);s<parseInt(t);s++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function zd(r){let e="precision "+r.precision+` float;
3506
3506
  precision `+r.precision+" int;";return r.precision==="highp"?e+=`
3507
3507
  #define HIGH_PRECISION`:r.precision==="mediump"?e+=`
3508
3508
  #define MEDIUM_PRECISION`:r.precision==="lowp"&&(e+=`
3509
- #define LOW_PRECISION`),e}function vM(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===Mn?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===pr?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===Dn&&(e="SHADOWMAP_TYPE_VSM"),e}function MM(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case pi:case mi:e="ENVMAP_TYPE_CUBE";break;case mr:e="ENVMAP_TYPE_CUBE_UV";break}return e}function SM(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case mi:e="ENVMAP_MODE_REFRACTION";break}return e}function bM(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case ps:e="ENVMAP_BLENDING_MULTIPLY";break;case gf:e="ENVMAP_BLENDING_MIX";break;case _f:e="ENVMAP_BLENDING_ADD";break}return e}function wM(r){const e=r.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function EM(r,e,t,n){const i=r.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=vM(t),c=MM(t),h=SM(t),u=bM(t),f=wM(t),d=t.isWebGL2?"":fM(t),p=dM(s),_=i.createProgram();let g,m,y=t.glslVersion?"#version "+t.glslVersion+`
3509
+ #define LOW_PRECISION`),e}function MM(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===Mn?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===pr?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===Dn&&(e="SHADOWMAP_TYPE_VSM"),e}function SM(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case pi:case mi:e="ENVMAP_TYPE_CUBE";break;case mr:e="ENVMAP_TYPE_CUBE_UV";break}return e}function bM(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case mi:e="ENVMAP_MODE_REFRACTION";break}return e}function wM(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case ps:e="ENVMAP_BLENDING_MULTIPLY";break;case _f:e="ENVMAP_BLENDING_MIX";break;case xf:e="ENVMAP_BLENDING_ADD";break}return e}function EM(r){const e=r.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function AM(r,e,t,n){const i=r.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=MM(t),c=SM(t),h=bM(t),u=wM(t),f=EM(t),d=t.isWebGL2?"":dM(t),p=pM(s),_=i.createProgram();let g,m,y=t.glslVersion?"#version "+t.glslVersion+`
3510
3510
  `:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(Fs).join(`
3511
3511
  `),g.length>0&&(g+=`
3512
3512
  `),m=[d,"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(Fs).join(`
3513
3513
  `),m.length>0&&(m+=`
3514
- `)):(g=[Bd(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3514
+ `)):(g=[zd(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3515
3515
  `].filter(Fs).join(`
3516
- `),m=[d,Bd(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Fn?"#define TONE_MAPPING":"",t.toneMapping!==Fn?Ve.tonemapping_pars_fragment:"",t.toneMapping!==Fn?uM("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,hM("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3516
+ `),m=[d,zd(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Fn?"#define TONE_MAPPING":"",t.toneMapping!==Fn?Ve.tonemapping_pars_fragment:"",t.toneMapping!==Fn?fM("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,uM("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3517
3517
  `].filter(Fs).join(`
3518
- `)),a=oh(a),a=Nd(a,t),a=Fd(a,t),o=oh(o),o=Nd(o,t),o=Fd(o,t),a=Od(a),o=Od(o),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(y=`#version 300 es
3518
+ `)),a=oh(a),a=Fd(a,t),a=Od(a,t),o=oh(o),o=Fd(o,t),o=Od(o,t),a=Bd(a),o=Bd(o),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(y=`#version 300 es
3519
3519
  `,g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
3520
3520
  `)+`
3521
3521
  `+g,m=["#define varying in",t.glslVersion===Ic?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Ic?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
3522
3522
  `)+`
3523
- `+m);const x=y+g+a,v=y+m+o,M=Ud(i,i.VERTEX_SHADER,x),w=Ud(i,i.FRAGMENT_SHADER,v);if(i.attachShader(_,M),i.attachShader(_,w),t.index0AttributeName!==void 0?i.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_),r.debug.checkShaderErrors){const S=i.getProgramInfoLog(_).trim(),b=i.getShaderInfoLog(M).trim(),L=i.getShaderInfoLog(w).trim();let k=!0,U=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(k=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,_,M,w);else{const N=Dd(i,M,"vertex"),I=Dd(i,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+`
3523
+ `+m);const x=y+g+a,v=y+m+o,M=Dd(i,i.VERTEX_SHADER,x),w=Dd(i,i.FRAGMENT_SHADER,v);if(i.attachShader(_,M),i.attachShader(_,w),t.index0AttributeName!==void 0?i.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_),r.debug.checkShaderErrors){const S=i.getProgramInfoLog(_).trim(),b=i.getShaderInfoLog(M).trim(),L=i.getShaderInfoLog(w).trim();let k=!0,U=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(k=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,_,M,w);else{const N=Nd(i,M,"vertex"),I=Nd(i,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+`
3524
3524
 
3525
3525
  Program Info Log: `+S+`
3526
3526
  `+N+`
3527
- `+I)}else S!==""?console.warn("THREE.WebGLProgram: Program Info Log:",S):(b===""||L==="")&&(U=!1);U&&(this.diagnostics={runnable:k,programLog:S,vertexShader:{log:b,prefix:g},fragmentShader:{log:L,prefix:m}})}i.deleteShader(M),i.deleteShader(w);let A;this.getUniforms=function(){return A===void 0&&(A=new oo(i,_)),A};let C;return this.getAttributes=function(){return C===void 0&&(C=pM(i,_)),C},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=oM++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=M,this.fragmentShader=w,this}let AM=0;class TM{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.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 n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new RM(e),t.set(e,n)),n}}class RM{constructor(e){this.id=AM++,this.code=e,this.usedTimes=0}}function CM(r,e,t,n,i,s,a){const o=new Ga,l=new TM,c=[],h=i.isWebGL2,u=i.logarithmicDepthBuffer,f=i.vertexTextures;let d=i.precision;const p={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 _(S){return S===0?"uv":`uv${S}`}function g(S,b,L,k,U){const N=k.fog,I=U.geometry,B=S.isMeshStandardMaterial?k.environment:null,O=(S.isMeshStandardMaterial?t:e).get(S.envMap||B),H=O&&O.mapping===mr?O.image.height:null,X=p[S.type];S.precision!==null&&(d=i.getMaxPrecision(S.precision),d!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",d,"instead."));const ee=I.morphAttributes.position||I.morphAttributes.normal||I.morphAttributes.color,z=ee!==void 0?ee.length:0;let Z=0;I.morphAttributes.position!==void 0&&(Z=1),I.morphAttributes.normal!==void 0&&(Z=2),I.morphAttributes.color!==void 0&&(Z=3);let le,ce,fe,Ae;if(X){const Vn=Rn[X];le=Vn.vertexShader,ce=Vn.fragmentShader}else le=S.vertexShader,ce=S.fragmentShader,l.update(S),fe=l.getVertexShaderID(S),Ae=l.getFragmentShaderID(S);const Pe=r.getRenderTarget(),Te=U.isInstancedMesh===!0,Ke=!!S.map,je=!!S.matcap,Le=!!O,D=!!S.aoMap,ae=!!S.lightMap,Q=!!S.bumpMap,oe=!!S.normalMap,re=!!S.displacementMap,Ee=!!S.emissiveMap,$=!!S.metalnessMap,J=!!S.roughnessMap,ne=S.anisotropy>0,de=S.clearcoat>0,pe=S.iridescence>0,T=S.sheen>0,E=S.transmission>0,W=ne&&!!S.anisotropyMap,se=de&&!!S.clearcoatMap,ie=de&&!!S.clearcoatNormalMap,me=de&&!!S.clearcoatRoughnessMap,we=pe&&!!S.iridescenceMap,he=pe&&!!S.iridescenceThicknessMap,K=T&&!!S.sheenColorMap,Re=T&&!!S.sheenRoughnessMap,Ce=!!S.specularMap,Ie=!!S.specularColorMap,be=!!S.specularIntensityMap,Me=E&&!!S.transmissionMap,qe=E&&!!S.thicknessMap,at=!!S.gradientMap,F=!!S.alphaMap,_e=S.alphaTest>0,Y=!!S.alphaHash,ue=!!S.extensions,xe=!!I.attributes.uv1,nt=!!I.attributes.uv2,ut=!!I.attributes.uv3;return{isWebGL2:h,shaderID:X,shaderType:S.type,shaderName:S.name,vertexShader:le,fragmentShader:ce,defines:S.defines,customVertexShaderID:fe,customFragmentShaderID:Ae,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:d,instancing:Te,instancingColor:Te&&U.instanceColor!==null,supportsVertexTextures:f,outputColorSpace:Pe===null?r.outputColorSpace:Pe.isXRRenderTarget===!0?Pe.texture.colorSpace:Sn,map:Ke,matcap:je,envMap:Le,envMapMode:Le&&O.mapping,envMapCubeUVHeight:H,aoMap:D,lightMap:ae,bumpMap:Q,normalMap:oe,displacementMap:f&&re,emissiveMap:Ee,normalMapObjectSpace:oe&&S.normalMapType===Of,normalMapTangentSpace:oe&&S.normalMapType===vi,metalnessMap:$,roughnessMap:J,anisotropy:ne,anisotropyMap:W,clearcoat:de,clearcoatMap:se,clearcoatNormalMap:ie,clearcoatRoughnessMap:me,iridescence:pe,iridescenceMap:we,iridescenceThicknessMap:he,sheen:T,sheenColorMap:K,sheenRoughnessMap:Re,specularMap:Ce,specularColorMap:Ie,specularIntensityMap:be,transmission:E,transmissionMap:Me,thicknessMap:qe,gradientMap:at,opaque:S.transparent===!1&&S.blending===Ui,alphaMap:F,alphaTest:_e,alphaHash:Y,combine:S.combine,mapUv:Ke&&_(S.map.channel),aoMapUv:D&&_(S.aoMap.channel),lightMapUv:ae&&_(S.lightMap.channel),bumpMapUv:Q&&_(S.bumpMap.channel),normalMapUv:oe&&_(S.normalMap.channel),displacementMapUv:re&&_(S.displacementMap.channel),emissiveMapUv:Ee&&_(S.emissiveMap.channel),metalnessMapUv:$&&_(S.metalnessMap.channel),roughnessMapUv:J&&_(S.roughnessMap.channel),anisotropyMapUv:W&&_(S.anisotropyMap.channel),clearcoatMapUv:se&&_(S.clearcoatMap.channel),clearcoatNormalMapUv:ie&&_(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:me&&_(S.clearcoatRoughnessMap.channel),iridescenceMapUv:we&&_(S.iridescenceMap.channel),iridescenceThicknessMapUv:he&&_(S.iridescenceThicknessMap.channel),sheenColorMapUv:K&&_(S.sheenColorMap.channel),sheenRoughnessMapUv:Re&&_(S.sheenRoughnessMap.channel),specularMapUv:Ce&&_(S.specularMap.channel),specularColorMapUv:Ie&&_(S.specularColorMap.channel),specularIntensityMapUv:be&&_(S.specularIntensityMap.channel),transmissionMapUv:Me&&_(S.transmissionMap.channel),thicknessMapUv:qe&&_(S.thicknessMap.channel),alphaMapUv:F&&_(S.alphaMap.channel),vertexTangents:!!I.attributes.tangent&&(oe||ne),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!I.attributes.color&&I.attributes.color.itemSize===4,vertexUv1s:xe,vertexUv2s:nt,vertexUv3s:ut,pointsUvs:U.isPoints===!0&&!!I.attributes.uv&&(Ke||F),fog:!!N,useFog:S.fog===!0,fogExp2:N&&N.isFogExp2,flatShading:S.flatShading===!0,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:u,skinning:U.isSkinnedMesh===!0,morphTargets:I.morphAttributes.position!==void 0,morphNormals:I.morphAttributes.normal!==void 0,morphColors:I.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:Z,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:r.shadowMap.enabled&&L.length>0,shadowMapType:r.shadowMap.type,toneMapping:S.toneMapped?r.toneMapping:Fn,useLegacyLights:r.useLegacyLights,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Nn,flipSided:S.side===kt,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionDerivatives:ue&&S.extensions.derivatives===!0,extensionFragDepth:ue&&S.extensions.fragDepth===!0,extensionDrawBuffers:ue&&S.extensions.drawBuffers===!0,extensionShaderTextureLOD:ue&&S.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),customProgramCacheKey:S.customProgramCacheKey()}}function m(S){const b=[];if(S.shaderID?b.push(S.shaderID):(b.push(S.customVertexShaderID),b.push(S.customFragmentShaderID)),S.defines!==void 0)for(const L in S.defines)b.push(L),b.push(S.defines[L]);return S.isRawShaderMaterial===!1&&(y(b,S),x(b,S),b.push(r.outputColorSpace)),b.push(S.customProgramCacheKey),b.join()}function y(S,b){S.push(b.precision),S.push(b.outputColorSpace),S.push(b.envMapMode),S.push(b.envMapCubeUVHeight),S.push(b.mapUv),S.push(b.alphaMapUv),S.push(b.lightMapUv),S.push(b.aoMapUv),S.push(b.bumpMapUv),S.push(b.normalMapUv),S.push(b.displacementMapUv),S.push(b.emissiveMapUv),S.push(b.metalnessMapUv),S.push(b.roughnessMapUv),S.push(b.anisotropyMapUv),S.push(b.clearcoatMapUv),S.push(b.clearcoatNormalMapUv),S.push(b.clearcoatRoughnessMapUv),S.push(b.iridescenceMapUv),S.push(b.iridescenceThicknessMapUv),S.push(b.sheenColorMapUv),S.push(b.sheenRoughnessMapUv),S.push(b.specularMapUv),S.push(b.specularColorMapUv),S.push(b.specularIntensityMapUv),S.push(b.transmissionMapUv),S.push(b.thicknessMapUv),S.push(b.combine),S.push(b.fogExp2),S.push(b.sizeAttenuation),S.push(b.morphTargetsCount),S.push(b.morphAttributeCount),S.push(b.numDirLights),S.push(b.numPointLights),S.push(b.numSpotLights),S.push(b.numSpotLightMaps),S.push(b.numHemiLights),S.push(b.numRectAreaLights),S.push(b.numDirLightShadows),S.push(b.numPointLightShadows),S.push(b.numSpotLightShadows),S.push(b.numSpotLightShadowsWithMaps),S.push(b.shadowMapType),S.push(b.toneMapping),S.push(b.numClippingPlanes),S.push(b.numClipIntersection),S.push(b.depthPacking)}function x(S,b){o.disableAll(),b.isWebGL2&&o.enable(0),b.supportsVertexTextures&&o.enable(1),b.instancing&&o.enable(2),b.instancingColor&&o.enable(3),b.matcap&&o.enable(4),b.envMap&&o.enable(5),b.normalMapObjectSpace&&o.enable(6),b.normalMapTangentSpace&&o.enable(7),b.clearcoat&&o.enable(8),b.iridescence&&o.enable(9),b.alphaTest&&o.enable(10),b.vertexColors&&o.enable(11),b.vertexAlphas&&o.enable(12),b.vertexUv1s&&o.enable(13),b.vertexUv2s&&o.enable(14),b.vertexUv3s&&o.enable(15),b.vertexTangents&&o.enable(16),b.anisotropy&&o.enable(17),S.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.skinning&&o.enable(4),b.morphTargets&&o.enable(5),b.morphNormals&&o.enable(6),b.morphColors&&o.enable(7),b.premultipliedAlpha&&o.enable(8),b.shadowMapEnabled&&o.enable(9),b.useLegacyLights&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),S.push(o.mask)}function v(S){const b=p[S.type];let L;if(b){const k=Rn[b];L=dd.clone(k.uniforms)}else L=S.uniforms;return L}function M(S,b){let L;for(let k=0,U=c.length;k<U;k++){const N=c[k];if(N.cacheKey===b){L=N,++L.usedTimes;break}}return L===void 0&&(L=new EM(r,b,S,s),c.push(L)),L}function w(S){if(--S.usedTimes===0){const b=c.indexOf(S);c[b]=c[c.length-1],c.pop(),S.destroy()}}function A(S){l.remove(S)}function C(){l.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:v,acquireProgram:M,releaseProgram:w,releaseShaderCache:A,programs:c,dispose:C}}function PM(){let r=new WeakMap;function e(s){let a=r.get(s);return a===void 0&&(a={},r.set(s,a)),a}function t(s){r.delete(s)}function n(s,a,o){r.get(s)[a]=o}function i(){r=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function LM(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function zd(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function kd(){const r=[];let e=0;const t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function a(u,f,d,p,_,g){let m=r[e];return m===void 0?(m={id:u.id,object:u,geometry:f,material:d,groupOrder:p,renderOrder:u.renderOrder,z:_,group:g},r[e]=m):(m.id=u.id,m.object=u,m.geometry=f,m.material=d,m.groupOrder=p,m.renderOrder=u.renderOrder,m.z=_,m.group=g),e++,m}function o(u,f,d,p,_,g){const m=a(u,f,d,p,_,g);d.transmission>0?n.push(m):d.transparent===!0?i.push(m):t.push(m)}function l(u,f,d,p,_,g){const m=a(u,f,d,p,_,g);d.transmission>0?n.unshift(m):d.transparent===!0?i.unshift(m):t.unshift(m)}function c(u,f){t.length>1&&t.sort(u||LM),n.length>1&&n.sort(f||zd),i.length>1&&i.sort(f||zd)}function h(){for(let u=e,f=r.length;u<f;u++){const d=r[u];if(d.id===null)break;d.id=null,d.object=null,d.geometry=null,d.material=null,d.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:o,unshift:l,finish:h,sort:c}}function IM(){let r=new WeakMap;function e(n,i){const s=r.get(n);let a;return s===void 0?(a=new kd,r.set(n,[a])):i>=s.length?(a=new kd,s.push(a)):a=s[i],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function UM(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new R,color:new ye};break;case"SpotLight":t={position:new R,direction:new R,color:new ye,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new R,color:new ye,distance:0,decay:0};break;case"HemisphereLight":t={direction:new R,skyColor:new ye,groundColor:new ye};break;case"RectAreaLight":t={color:new ye,position:new R,halfWidth:new R,halfHeight:new R};break}return r[e.id]=t,t}}}function DM(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new q};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new q};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new q,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let NM=0;function FM(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function OM(r,e){const t=new UM,n=DM(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-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};for(let h=0;h<9;h++)i.probe.push(new R);const s=new R,a=new Be,o=new Be;function l(h,u){let f=0,d=0,p=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let _=0,g=0,m=0,y=0,x=0,v=0,M=0,w=0,A=0,C=0;h.sort(FM);const S=u===!0?Math.PI:1;for(let L=0,k=h.length;L<k;L++){const U=h[L],N=U.color,I=U.intensity,B=U.distance,O=U.shadow&&U.shadow.map?U.shadow.map.texture:null;if(U.isAmbientLight)f+=N.r*I*S,d+=N.g*I*S,p+=N.b*I*S;else if(U.isLightProbe)for(let H=0;H<9;H++)i.probe[H].addScaledVector(U.sh.coefficients[H],I);else if(U.isDirectionalLight){const H=t.get(U);if(H.color.copy(U.color).multiplyScalar(U.intensity*S),U.castShadow){const X=U.shadow,ee=n.get(U);ee.shadowBias=X.bias,ee.shadowNormalBias=X.normalBias,ee.shadowRadius=X.radius,ee.shadowMapSize=X.mapSize,i.directionalShadow[_]=ee,i.directionalShadowMap[_]=O,i.directionalShadowMatrix[_]=U.shadow.matrix,v++}i.directional[_]=H,_++}else if(U.isSpotLight){const H=t.get(U);H.position.setFromMatrixPosition(U.matrixWorld),H.color.copy(N).multiplyScalar(I*S),H.distance=B,H.coneCos=Math.cos(U.angle),H.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),H.decay=U.decay,i.spot[m]=H;const X=U.shadow;if(U.map&&(i.spotLightMap[A]=U.map,A++,X.updateMatrices(U),U.castShadow&&C++),i.spotLightMatrix[m]=X.matrix,U.castShadow){const ee=n.get(U);ee.shadowBias=X.bias,ee.shadowNormalBias=X.normalBias,ee.shadowRadius=X.radius,ee.shadowMapSize=X.mapSize,i.spotShadow[m]=ee,i.spotShadowMap[m]=O,w++}m++}else if(U.isRectAreaLight){const H=t.get(U);H.color.copy(N).multiplyScalar(I),H.halfWidth.set(U.width*.5,0,0),H.halfHeight.set(0,U.height*.5,0),i.rectArea[y]=H,y++}else if(U.isPointLight){const H=t.get(U);if(H.color.copy(U.color).multiplyScalar(U.intensity*S),H.distance=U.distance,H.decay=U.decay,U.castShadow){const X=U.shadow,ee=n.get(U);ee.shadowBias=X.bias,ee.shadowNormalBias=X.normalBias,ee.shadowRadius=X.radius,ee.shadowMapSize=X.mapSize,ee.shadowCameraNear=X.camera.near,ee.shadowCameraFar=X.camera.far,i.pointShadow[g]=ee,i.pointShadowMap[g]=O,i.pointShadowMatrix[g]=U.shadow.matrix,M++}i.point[g]=H,g++}else if(U.isHemisphereLight){const H=t.get(U);H.skyColor.copy(U.color).multiplyScalar(I*S),H.groundColor.copy(U.groundColor).multiplyScalar(I*S),i.hemi[x]=H,x++}}y>0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ge.LTC_FLOAT_1,i.rectAreaLTC2=ge.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=ge.LTC_HALF_1,i.rectAreaLTC2=ge.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=p;const b=i.hash;(b.directionalLength!==_||b.pointLength!==g||b.spotLength!==m||b.rectAreaLength!==y||b.hemiLength!==x||b.numDirectionalShadows!==v||b.numPointShadows!==M||b.numSpotShadows!==w||b.numSpotMaps!==A)&&(i.directional.length=_,i.spot.length=m,i.rectArea.length=y,i.point.length=g,i.hemi.length=x,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=M,i.pointShadowMap.length=M,i.spotShadow.length=w,i.spotShadowMap.length=w,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=M,i.spotLightMatrix.length=w+A-C,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=C,b.directionalLength=_,b.pointLength=g,b.spotLength=m,b.rectAreaLength=y,b.hemiLength=x,b.numDirectionalShadows=v,b.numPointShadows=M,b.numSpotShadows=w,b.numSpotMaps=A,i.version=NM++)}function c(h,u){let f=0,d=0,p=0,_=0,g=0;const m=u.matrixWorldInverse;for(let y=0,x=h.length;y<x;y++){const v=h[y];if(v.isDirectionalLight){const M=i.directional[f];M.direction.setFromMatrixPosition(v.matrixWorld),s.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),f++}else if(v.isSpotLight){const M=i.spot[p];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(v.matrixWorld),s.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),p++}else if(v.isRectAreaLight){const M=i.rectArea[_];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),o.identity(),a.copy(v.matrixWorld),a.premultiply(m),o.extractRotation(a),M.halfWidth.set(v.width*.5,0,0),M.halfHeight.set(0,v.height*.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),_++}else if(v.isPointLight){const M=i.point[d];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),d++}else if(v.isHemisphereLight){const M=i.hemi[g];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(m),g++}}}return{setup:l,setupView:c,state:i}}function Gd(r,e){const t=new OM(r,e),n=[],i=[];function s(){n.length=0,i.length=0}function a(u){n.push(u)}function o(u){i.push(u)}function l(u){t.setup(n,u)}function c(u){t.setupView(n,u)}return{init:s,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:l,setupLightsView:c,pushLight:a,pushShadow:o}}function BM(r,e){let t=new WeakMap;function n(s,a=0){const o=t.get(s);let l;return o===void 0?(l=new Gd(r,e),t.set(s,[l])):a>=o.length?(l=new Gd(r,e),o.push(l)):l=o[a],l}function i(){t=new WeakMap}return{get:n,dispose:i}}class lh extends Ft{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Nf,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 ch extends Ft{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}}const zM=`void main() {
3527
+ `+I)}else S!==""?console.warn("THREE.WebGLProgram: Program Info Log:",S):(b===""||L==="")&&(U=!1);U&&(this.diagnostics={runnable:k,programLog:S,vertexShader:{log:b,prefix:g},fragmentShader:{log:L,prefix:m}})}i.deleteShader(M),i.deleteShader(w);let A;this.getUniforms=function(){return A===void 0&&(A=new oo(i,_)),A};let C;return this.getAttributes=function(){return C===void 0&&(C=mM(i,_)),C},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=lM++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=M,this.fragmentShader=w,this}let TM=0;class RM{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.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 n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new CM(e),t.set(e,n)),n}}class CM{constructor(e){this.id=TM++,this.code=e,this.usedTimes=0}}function PM(r,e,t,n,i,s,a){const o=new Ga,l=new RM,c=[],h=i.isWebGL2,u=i.logarithmicDepthBuffer,f=i.vertexTextures;let d=i.precision;const p={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 _(S){return S===0?"uv":`uv${S}`}function g(S,b,L,k,U){const N=k.fog,I=U.geometry,B=S.isMeshStandardMaterial?k.environment:null,O=(S.isMeshStandardMaterial?t:e).get(S.envMap||B),H=O&&O.mapping===mr?O.image.height:null,X=p[S.type];S.precision!==null&&(d=i.getMaxPrecision(S.precision),d!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",d,"instead."));const ee=I.morphAttributes.position||I.morphAttributes.normal||I.morphAttributes.color,z=ee!==void 0?ee.length:0;let Z=0;I.morphAttributes.position!==void 0&&(Z=1),I.morphAttributes.normal!==void 0&&(Z=2),I.morphAttributes.color!==void 0&&(Z=3);let le,ce,fe,Ae;if(X){const Vn=Rn[X];le=Vn.vertexShader,ce=Vn.fragmentShader}else le=S.vertexShader,ce=S.fragmentShader,l.update(S),fe=l.getVertexShaderID(S),Ae=l.getFragmentShaderID(S);const Pe=r.getRenderTarget(),Te=U.isInstancedMesh===!0,Ke=!!S.map,je=!!S.matcap,Le=!!O,D=!!S.aoMap,ae=!!S.lightMap,Q=!!S.bumpMap,oe=!!S.normalMap,re=!!S.displacementMap,Ee=!!S.emissiveMap,$=!!S.metalnessMap,J=!!S.roughnessMap,ne=S.anisotropy>0,de=S.clearcoat>0,pe=S.iridescence>0,T=S.sheen>0,E=S.transmission>0,W=ne&&!!S.anisotropyMap,se=de&&!!S.clearcoatMap,ie=de&&!!S.clearcoatNormalMap,me=de&&!!S.clearcoatRoughnessMap,we=pe&&!!S.iridescenceMap,he=pe&&!!S.iridescenceThicknessMap,K=T&&!!S.sheenColorMap,Re=T&&!!S.sheenRoughnessMap,Ce=!!S.specularMap,Ie=!!S.specularColorMap,be=!!S.specularIntensityMap,Me=E&&!!S.transmissionMap,qe=E&&!!S.thicknessMap,at=!!S.gradientMap,F=!!S.alphaMap,_e=S.alphaTest>0,Y=!!S.alphaHash,ue=!!S.extensions,xe=!!I.attributes.uv1,nt=!!I.attributes.uv2,ut=!!I.attributes.uv3;return{isWebGL2:h,shaderID:X,shaderType:S.type,shaderName:S.name,vertexShader:le,fragmentShader:ce,defines:S.defines,customVertexShaderID:fe,customFragmentShaderID:Ae,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:d,instancing:Te,instancingColor:Te&&U.instanceColor!==null,supportsVertexTextures:f,outputColorSpace:Pe===null?r.outputColorSpace:Pe.isXRRenderTarget===!0?Pe.texture.colorSpace:Sn,map:Ke,matcap:je,envMap:Le,envMapMode:Le&&O.mapping,envMapCubeUVHeight:H,aoMap:D,lightMap:ae,bumpMap:Q,normalMap:oe,displacementMap:f&&re,emissiveMap:Ee,normalMapObjectSpace:oe&&S.normalMapType===Bf,normalMapTangentSpace:oe&&S.normalMapType===vi,metalnessMap:$,roughnessMap:J,anisotropy:ne,anisotropyMap:W,clearcoat:de,clearcoatMap:se,clearcoatNormalMap:ie,clearcoatRoughnessMap:me,iridescence:pe,iridescenceMap:we,iridescenceThicknessMap:he,sheen:T,sheenColorMap:K,sheenRoughnessMap:Re,specularMap:Ce,specularColorMap:Ie,specularIntensityMap:be,transmission:E,transmissionMap:Me,thicknessMap:qe,gradientMap:at,opaque:S.transparent===!1&&S.blending===Ui,alphaMap:F,alphaTest:_e,alphaHash:Y,combine:S.combine,mapUv:Ke&&_(S.map.channel),aoMapUv:D&&_(S.aoMap.channel),lightMapUv:ae&&_(S.lightMap.channel),bumpMapUv:Q&&_(S.bumpMap.channel),normalMapUv:oe&&_(S.normalMap.channel),displacementMapUv:re&&_(S.displacementMap.channel),emissiveMapUv:Ee&&_(S.emissiveMap.channel),metalnessMapUv:$&&_(S.metalnessMap.channel),roughnessMapUv:J&&_(S.roughnessMap.channel),anisotropyMapUv:W&&_(S.anisotropyMap.channel),clearcoatMapUv:se&&_(S.clearcoatMap.channel),clearcoatNormalMapUv:ie&&_(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:me&&_(S.clearcoatRoughnessMap.channel),iridescenceMapUv:we&&_(S.iridescenceMap.channel),iridescenceThicknessMapUv:he&&_(S.iridescenceThicknessMap.channel),sheenColorMapUv:K&&_(S.sheenColorMap.channel),sheenRoughnessMapUv:Re&&_(S.sheenRoughnessMap.channel),specularMapUv:Ce&&_(S.specularMap.channel),specularColorMapUv:Ie&&_(S.specularColorMap.channel),specularIntensityMapUv:be&&_(S.specularIntensityMap.channel),transmissionMapUv:Me&&_(S.transmissionMap.channel),thicknessMapUv:qe&&_(S.thicknessMap.channel),alphaMapUv:F&&_(S.alphaMap.channel),vertexTangents:!!I.attributes.tangent&&(oe||ne),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!I.attributes.color&&I.attributes.color.itemSize===4,vertexUv1s:xe,vertexUv2s:nt,vertexUv3s:ut,pointsUvs:U.isPoints===!0&&!!I.attributes.uv&&(Ke||F),fog:!!N,useFog:S.fog===!0,fogExp2:N&&N.isFogExp2,flatShading:S.flatShading===!0,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:u,skinning:U.isSkinnedMesh===!0,morphTargets:I.morphAttributes.position!==void 0,morphNormals:I.morphAttributes.normal!==void 0,morphColors:I.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:Z,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:r.shadowMap.enabled&&L.length>0,shadowMapType:r.shadowMap.type,toneMapping:S.toneMapped?r.toneMapping:Fn,useLegacyLights:r.useLegacyLights,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Nn,flipSided:S.side===kt,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionDerivatives:ue&&S.extensions.derivatives===!0,extensionFragDepth:ue&&S.extensions.fragDepth===!0,extensionDrawBuffers:ue&&S.extensions.drawBuffers===!0,extensionShaderTextureLOD:ue&&S.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),customProgramCacheKey:S.customProgramCacheKey()}}function m(S){const b=[];if(S.shaderID?b.push(S.shaderID):(b.push(S.customVertexShaderID),b.push(S.customFragmentShaderID)),S.defines!==void 0)for(const L in S.defines)b.push(L),b.push(S.defines[L]);return S.isRawShaderMaterial===!1&&(y(b,S),x(b,S),b.push(r.outputColorSpace)),b.push(S.customProgramCacheKey),b.join()}function y(S,b){S.push(b.precision),S.push(b.outputColorSpace),S.push(b.envMapMode),S.push(b.envMapCubeUVHeight),S.push(b.mapUv),S.push(b.alphaMapUv),S.push(b.lightMapUv),S.push(b.aoMapUv),S.push(b.bumpMapUv),S.push(b.normalMapUv),S.push(b.displacementMapUv),S.push(b.emissiveMapUv),S.push(b.metalnessMapUv),S.push(b.roughnessMapUv),S.push(b.anisotropyMapUv),S.push(b.clearcoatMapUv),S.push(b.clearcoatNormalMapUv),S.push(b.clearcoatRoughnessMapUv),S.push(b.iridescenceMapUv),S.push(b.iridescenceThicknessMapUv),S.push(b.sheenColorMapUv),S.push(b.sheenRoughnessMapUv),S.push(b.specularMapUv),S.push(b.specularColorMapUv),S.push(b.specularIntensityMapUv),S.push(b.transmissionMapUv),S.push(b.thicknessMapUv),S.push(b.combine),S.push(b.fogExp2),S.push(b.sizeAttenuation),S.push(b.morphTargetsCount),S.push(b.morphAttributeCount),S.push(b.numDirLights),S.push(b.numPointLights),S.push(b.numSpotLights),S.push(b.numSpotLightMaps),S.push(b.numHemiLights),S.push(b.numRectAreaLights),S.push(b.numDirLightShadows),S.push(b.numPointLightShadows),S.push(b.numSpotLightShadows),S.push(b.numSpotLightShadowsWithMaps),S.push(b.shadowMapType),S.push(b.toneMapping),S.push(b.numClippingPlanes),S.push(b.numClipIntersection),S.push(b.depthPacking)}function x(S,b){o.disableAll(),b.isWebGL2&&o.enable(0),b.supportsVertexTextures&&o.enable(1),b.instancing&&o.enable(2),b.instancingColor&&o.enable(3),b.matcap&&o.enable(4),b.envMap&&o.enable(5),b.normalMapObjectSpace&&o.enable(6),b.normalMapTangentSpace&&o.enable(7),b.clearcoat&&o.enable(8),b.iridescence&&o.enable(9),b.alphaTest&&o.enable(10),b.vertexColors&&o.enable(11),b.vertexAlphas&&o.enable(12),b.vertexUv1s&&o.enable(13),b.vertexUv2s&&o.enable(14),b.vertexUv3s&&o.enable(15),b.vertexTangents&&o.enable(16),b.anisotropy&&o.enable(17),S.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.skinning&&o.enable(4),b.morphTargets&&o.enable(5),b.morphNormals&&o.enable(6),b.morphColors&&o.enable(7),b.premultipliedAlpha&&o.enable(8),b.shadowMapEnabled&&o.enable(9),b.useLegacyLights&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),S.push(o.mask)}function v(S){const b=p[S.type];let L;if(b){const k=Rn[b];L=pd.clone(k.uniforms)}else L=S.uniforms;return L}function M(S,b){let L;for(let k=0,U=c.length;k<U;k++){const N=c[k];if(N.cacheKey===b){L=N,++L.usedTimes;break}}return L===void 0&&(L=new AM(r,b,S,s),c.push(L)),L}function w(S){if(--S.usedTimes===0){const b=c.indexOf(S);c[b]=c[c.length-1],c.pop(),S.destroy()}}function A(S){l.remove(S)}function C(){l.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:v,acquireProgram:M,releaseProgram:w,releaseShaderCache:A,programs:c,dispose:C}}function LM(){let r=new WeakMap;function e(s){let a=r.get(s);return a===void 0&&(a={},r.set(s,a)),a}function t(s){r.delete(s)}function n(s,a,o){r.get(s)[a]=o}function i(){r=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function IM(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function kd(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function Gd(){const r=[];let e=0;const t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function a(u,f,d,p,_,g){let m=r[e];return m===void 0?(m={id:u.id,object:u,geometry:f,material:d,groupOrder:p,renderOrder:u.renderOrder,z:_,group:g},r[e]=m):(m.id=u.id,m.object=u,m.geometry=f,m.material=d,m.groupOrder=p,m.renderOrder=u.renderOrder,m.z=_,m.group=g),e++,m}function o(u,f,d,p,_,g){const m=a(u,f,d,p,_,g);d.transmission>0?n.push(m):d.transparent===!0?i.push(m):t.push(m)}function l(u,f,d,p,_,g){const m=a(u,f,d,p,_,g);d.transmission>0?n.unshift(m):d.transparent===!0?i.unshift(m):t.unshift(m)}function c(u,f){t.length>1&&t.sort(u||IM),n.length>1&&n.sort(f||kd),i.length>1&&i.sort(f||kd)}function h(){for(let u=e,f=r.length;u<f;u++){const d=r[u];if(d.id===null)break;d.id=null,d.object=null,d.geometry=null,d.material=null,d.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:o,unshift:l,finish:h,sort:c}}function UM(){let r=new WeakMap;function e(n,i){const s=r.get(n);let a;return s===void 0?(a=new Gd,r.set(n,[a])):i>=s.length?(a=new Gd,s.push(a)):a=s[i],a}function t(){r=new WeakMap}return{get:e,dispose:t}}function DM(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new R,color:new ye};break;case"SpotLight":t={position:new R,direction:new R,color:new ye,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new R,color:new ye,distance:0,decay:0};break;case"HemisphereLight":t={direction:new R,skyColor:new ye,groundColor:new ye};break;case"RectAreaLight":t={color:new ye,position:new R,halfWidth:new R,halfHeight:new R};break}return r[e.id]=t,t}}}function NM(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new q};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new q};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new q,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let FM=0;function OM(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function BM(r,e){const t=new DM,n=NM(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-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};for(let h=0;h<9;h++)i.probe.push(new R);const s=new R,a=new Be,o=new Be;function l(h,u){let f=0,d=0,p=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let _=0,g=0,m=0,y=0,x=0,v=0,M=0,w=0,A=0,C=0;h.sort(OM);const S=u===!0?Math.PI:1;for(let L=0,k=h.length;L<k;L++){const U=h[L],N=U.color,I=U.intensity,B=U.distance,O=U.shadow&&U.shadow.map?U.shadow.map.texture:null;if(U.isAmbientLight)f+=N.r*I*S,d+=N.g*I*S,p+=N.b*I*S;else if(U.isLightProbe)for(let H=0;H<9;H++)i.probe[H].addScaledVector(U.sh.coefficients[H],I);else if(U.isDirectionalLight){const H=t.get(U);if(H.color.copy(U.color).multiplyScalar(U.intensity*S),U.castShadow){const X=U.shadow,ee=n.get(U);ee.shadowBias=X.bias,ee.shadowNormalBias=X.normalBias,ee.shadowRadius=X.radius,ee.shadowMapSize=X.mapSize,i.directionalShadow[_]=ee,i.directionalShadowMap[_]=O,i.directionalShadowMatrix[_]=U.shadow.matrix,v++}i.directional[_]=H,_++}else if(U.isSpotLight){const H=t.get(U);H.position.setFromMatrixPosition(U.matrixWorld),H.color.copy(N).multiplyScalar(I*S),H.distance=B,H.coneCos=Math.cos(U.angle),H.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),H.decay=U.decay,i.spot[m]=H;const X=U.shadow;if(U.map&&(i.spotLightMap[A]=U.map,A++,X.updateMatrices(U),U.castShadow&&C++),i.spotLightMatrix[m]=X.matrix,U.castShadow){const ee=n.get(U);ee.shadowBias=X.bias,ee.shadowNormalBias=X.normalBias,ee.shadowRadius=X.radius,ee.shadowMapSize=X.mapSize,i.spotShadow[m]=ee,i.spotShadowMap[m]=O,w++}m++}else if(U.isRectAreaLight){const H=t.get(U);H.color.copy(N).multiplyScalar(I),H.halfWidth.set(U.width*.5,0,0),H.halfHeight.set(0,U.height*.5,0),i.rectArea[y]=H,y++}else if(U.isPointLight){const H=t.get(U);if(H.color.copy(U.color).multiplyScalar(U.intensity*S),H.distance=U.distance,H.decay=U.decay,U.castShadow){const X=U.shadow,ee=n.get(U);ee.shadowBias=X.bias,ee.shadowNormalBias=X.normalBias,ee.shadowRadius=X.radius,ee.shadowMapSize=X.mapSize,ee.shadowCameraNear=X.camera.near,ee.shadowCameraFar=X.camera.far,i.pointShadow[g]=ee,i.pointShadowMap[g]=O,i.pointShadowMatrix[g]=U.shadow.matrix,M++}i.point[g]=H,g++}else if(U.isHemisphereLight){const H=t.get(U);H.skyColor.copy(U.color).multiplyScalar(I*S),H.groundColor.copy(U.groundColor).multiplyScalar(I*S),i.hemi[x]=H,x++}}y>0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ge.LTC_FLOAT_1,i.rectAreaLTC2=ge.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=ge.LTC_HALF_1,i.rectAreaLTC2=ge.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=p;const b=i.hash;(b.directionalLength!==_||b.pointLength!==g||b.spotLength!==m||b.rectAreaLength!==y||b.hemiLength!==x||b.numDirectionalShadows!==v||b.numPointShadows!==M||b.numSpotShadows!==w||b.numSpotMaps!==A)&&(i.directional.length=_,i.spot.length=m,i.rectArea.length=y,i.point.length=g,i.hemi.length=x,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=M,i.pointShadowMap.length=M,i.spotShadow.length=w,i.spotShadowMap.length=w,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=M,i.spotLightMatrix.length=w+A-C,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=C,b.directionalLength=_,b.pointLength=g,b.spotLength=m,b.rectAreaLength=y,b.hemiLength=x,b.numDirectionalShadows=v,b.numPointShadows=M,b.numSpotShadows=w,b.numSpotMaps=A,i.version=FM++)}function c(h,u){let f=0,d=0,p=0,_=0,g=0;const m=u.matrixWorldInverse;for(let y=0,x=h.length;y<x;y++){const v=h[y];if(v.isDirectionalLight){const M=i.directional[f];M.direction.setFromMatrixPosition(v.matrixWorld),s.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),f++}else if(v.isSpotLight){const M=i.spot[p];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(v.matrixWorld),s.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),p++}else if(v.isRectAreaLight){const M=i.rectArea[_];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),o.identity(),a.copy(v.matrixWorld),a.premultiply(m),o.extractRotation(a),M.halfWidth.set(v.width*.5,0,0),M.halfHeight.set(0,v.height*.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),_++}else if(v.isPointLight){const M=i.point[d];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(m),d++}else if(v.isHemisphereLight){const M=i.hemi[g];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(m),g++}}}return{setup:l,setupView:c,state:i}}function Hd(r,e){const t=new BM(r,e),n=[],i=[];function s(){n.length=0,i.length=0}function a(u){n.push(u)}function o(u){i.push(u)}function l(u){t.setup(n,u)}function c(u){t.setupView(n,u)}return{init:s,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:l,setupLightsView:c,pushLight:a,pushShadow:o}}function zM(r,e){let t=new WeakMap;function n(s,a=0){const o=t.get(s);let l;return o===void 0?(l=new Hd(r,e),t.set(s,[l])):a>=o.length?(l=new Hd(r,e),o.push(l)):l=o[a],l}function i(){t=new WeakMap}return{get:n,dispose:i}}class lh extends Ft{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Ff,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 ch extends Ft{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}}const kM=`void main() {
3528
3528
  gl_Position = vec4( position, 1.0 );
3529
- }`,kM=`uniform sampler2D shadow_pass;
3529
+ }`,GM=`uniform sampler2D shadow_pass;
3530
3530
  uniform vec2 resolution;
3531
3531
  uniform float radius;
3532
3532
  #include <packing>
@@ -3552,4 +3552,4 @@ void main() {
3552
3552
  squared_mean = squared_mean / samples;
3553
3553
  float std_dev = sqrt( squared_mean - mean * mean );
3554
3554
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3555
- }`;function GM(r,e,t){let n=new no;const i=new q,s=new q,a=new rt,o=new lh({depthPacking:Ff}),l=new ch,c={},h=t.maxTextureSize,u={[Xn]:kt,[kt]:Xn,[Nn]:Nn},f=new zn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new q},radius:{value:4}},vertexShader:zM,fragmentShader:kM}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const p=new Fe;p.setAttribute("position",new Ze(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new It(p,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Mn;let m=this.type;this.render=function(M,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||M.length===0)return;const C=r.getRenderTarget(),S=r.getActiveCubeFace(),b=r.getActiveMipmapLevel(),L=r.state;L.setBlending(qn),L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const k=m!==Dn&&this.type===Dn,U=m===Dn&&this.type!==Dn;for(let N=0,I=M.length;N<I;N++){const B=M[N],O=B.shadow;if(O===void 0){console.warn("THREE.WebGLShadowMap:",B,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;i.copy(O.mapSize);const H=O.getFrameExtents();if(i.multiply(H),s.copy(O.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/H.x),i.x=s.x*H.x,O.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/H.y),i.y=s.y*H.y,O.mapSize.y=s.y)),O.map===null||k===!0||U===!0){const ee=this.type!==Dn?{minFilter:yt,magFilter:yt}:{};O.map!==null&&O.map.dispose(),O.map=new bn(i.x,i.y,ee),O.map.texture.name=B.name+".shadowMap",O.camera.updateProjectionMatrix()}r.setRenderTarget(O.map),r.clear();const X=O.getViewportCount();for(let ee=0;ee<X;ee++){const z=O.getViewport(ee);a.set(s.x*z.x,s.y*z.y,s.x*z.z,s.y*z.w),L.viewport(a),O.updateMatrices(B,ee),n=O.getFrustum(),v(w,A,O.camera,B,this.type)}O.isPointLightShadow!==!0&&this.type===Dn&&y(O,A),O.needsUpdate=!1}m=this.type,g.needsUpdate=!1,r.setRenderTarget(C,S,b)};function y(M,w){const A=e.update(_);f.defines.VSM_SAMPLES!==M.blurSamples&&(f.defines.VSM_SAMPLES=M.blurSamples,d.defines.VSM_SAMPLES=M.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),M.mapPass===null&&(M.mapPass=new bn(i.x,i.y)),f.uniforms.shadow_pass.value=M.map.texture,f.uniforms.resolution.value=M.mapSize,f.uniforms.radius.value=M.radius,r.setRenderTarget(M.mapPass),r.clear(),r.renderBufferDirect(w,null,A,f,_,null),d.uniforms.shadow_pass.value=M.mapPass.texture,d.uniforms.resolution.value=M.mapSize,d.uniforms.radius.value=M.radius,r.setRenderTarget(M.map),r.clear(),r.renderBufferDirect(w,null,A,d,_,null)}function x(M,w,A,C){let S=null;const b=A.isPointLight===!0?M.customDistanceMaterial:M.customDepthMaterial;if(b!==void 0)S=b;else if(S=A.isPointLight===!0?l:o,r.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const L=S.uuid,k=w.uuid;let U=c[L];U===void 0&&(U={},c[L]=U);let N=U[k];N===void 0&&(N=S.clone(),U[k]=N),S=N}if(S.visible=w.visible,S.wireframe=w.wireframe,C===Dn?S.side=w.shadowSide!==null?w.shadowSide:w.side:S.side=w.shadowSide!==null?w.shadowSide:u[w.side],S.alphaMap=w.alphaMap,S.alphaTest=w.alphaTest,S.map=w.map,S.clipShadows=w.clipShadows,S.clippingPlanes=w.clippingPlanes,S.clipIntersection=w.clipIntersection,S.displacementMap=w.displacementMap,S.displacementScale=w.displacementScale,S.displacementBias=w.displacementBias,S.wireframeLinewidth=w.wireframeLinewidth,S.linewidth=w.linewidth,A.isPointLight===!0&&S.isMeshDistanceMaterial===!0){const L=r.properties.get(S);L.light=A}return S}function v(M,w,A,C,S){if(M.visible===!1)return;if(M.layers.test(w.layers)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&S===Dn)&&(!M.frustumCulled||n.intersectsObject(M))){M.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,M.matrixWorld);const k=e.update(M),U=M.material;if(Array.isArray(U)){const N=k.groups;for(let I=0,B=N.length;I<B;I++){const O=N[I],H=U[O.materialIndex];if(H&&H.visible){const X=x(M,H,C,S);r.renderBufferDirect(A,null,k,X,M,O)}}}else if(U.visible){const N=x(M,U,C,S);r.renderBufferDirect(A,null,k,N,M,null)}}const L=M.children;for(let k=0,U=L.length;k<U;k++)v(L[k],w,A,C,S)}}function HM(r,e,t){const n=t.isWebGL2;function i(){let F=!1;const _e=new rt;let Y=null;const ue=new rt(0,0,0,0);return{setMask:function(xe){Y!==xe&&!F&&(r.colorMask(xe,xe,xe,xe),Y=xe)},setLocked:function(xe){F=xe},setClear:function(xe,nt,ut,Pt,Vn){Vn===!0&&(xe*=Pt,nt*=Pt,ut*=Pt),_e.set(xe,nt,ut,Pt),ue.equals(_e)===!1&&(r.clearColor(xe,nt,ut,Pt),ue.copy(_e))},reset:function(){F=!1,Y=null,ue.set(-1,0,0,0)}}}function s(){let F=!1,_e=null,Y=null,ue=null;return{setTest:function(xe){xe?Pe(r.DEPTH_TEST):Te(r.DEPTH_TEST)},setMask:function(xe){_e!==xe&&!F&&(r.depthMask(xe),_e=xe)},setFunc:function(xe){if(Y!==xe){switch(xe){case cf:r.depthFunc(r.NEVER);break;case hf:r.depthFunc(r.ALWAYS);break;case uf:r.depthFunc(r.LESS);break;case Ma:r.depthFunc(r.LEQUAL);break;case ff:r.depthFunc(r.EQUAL);break;case df:r.depthFunc(r.GEQUAL);break;case pf:r.depthFunc(r.GREATER);break;case mf:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}Y=xe}},setLocked:function(xe){F=xe},setClear:function(xe){ue!==xe&&(r.clearDepth(xe),ue=xe)},reset:function(){F=!1,_e=null,Y=null,ue=null}}}function a(){let F=!1,_e=null,Y=null,ue=null,xe=null,nt=null,ut=null,Pt=null,Vn=null;return{setTest:function(gt){F||(gt?Pe(r.STENCIL_TEST):Te(r.STENCIL_TEST))},setMask:function(gt){_e!==gt&&!F&&(r.stencilMask(gt),_e=gt)},setFunc:function(gt,Wn,Yt){(Y!==gt||ue!==Wn||xe!==Yt)&&(r.stencilFunc(gt,Wn,Yt),Y=gt,ue=Wn,xe=Yt)},setOp:function(gt,Wn,Yt){(nt!==gt||ut!==Wn||Pt!==Yt)&&(r.stencilOp(gt,Wn,Yt),nt=gt,ut=Wn,Pt=Yt)},setLocked:function(gt){F=gt},setClear:function(gt){Vn!==gt&&(r.clearStencil(gt),Vn=gt)},reset:function(){F=!1,_e=null,Y=null,ue=null,xe=null,nt=null,ut=null,Pt=null,Vn=null}}}const o=new i,l=new s,c=new a,h=new WeakMap,u=new WeakMap;let f={},d={},p=new WeakMap,_=[],g=null,m=!1,y=null,x=null,v=null,M=null,w=null,A=null,C=null,S=!1,b=null,L=null,k=null,U=null,N=null;const I=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let B=!1,O=0;const H=r.getParameter(r.VERSION);H.indexOf("WebGL")!==-1?(O=parseFloat(/^WebGL (\d)/.exec(H)[1]),B=O>=1):H.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),B=O>=2);let X=null,ee={};const z=r.getParameter(r.SCISSOR_BOX),Z=r.getParameter(r.VIEWPORT),le=new rt().fromArray(z),ce=new rt().fromArray(Z);function fe(F,_e,Y,ue){const xe=new Uint8Array(4),nt=r.createTexture();r.bindTexture(F,nt),r.texParameteri(F,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(F,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let ut=0;ut<Y;ut++)n&&(F===r.TEXTURE_3D||F===r.TEXTURE_2D_ARRAY)?r.texImage3D(_e,0,r.RGBA,1,1,ue,0,r.RGBA,r.UNSIGNED_BYTE,xe):r.texImage2D(_e+ut,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,xe);return nt}const Ae={};Ae[r.TEXTURE_2D]=fe(r.TEXTURE_2D,r.TEXTURE_2D,1),Ae[r.TEXTURE_CUBE_MAP]=fe(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(Ae[r.TEXTURE_2D_ARRAY]=fe(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),Ae[r.TEXTURE_3D]=fe(r.TEXTURE_3D,r.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),l.setClear(1),c.setClear(0),Pe(r.DEPTH_TEST),l.setFunc(Ma),re(!1),Ee(dr),Pe(r.CULL_FACE),Q(qn);function Pe(F){f[F]!==!0&&(r.enable(F),f[F]=!0)}function Te(F){f[F]!==!1&&(r.disable(F),f[F]=!1)}function Ke(F,_e){return d[F]!==_e?(r.bindFramebuffer(F,_e),d[F]=_e,n&&(F===r.DRAW_FRAMEBUFFER&&(d[r.FRAMEBUFFER]=_e),F===r.FRAMEBUFFER&&(d[r.DRAW_FRAMEBUFFER]=_e)),!0):!1}function je(F,_e){let Y=_,ue=!1;if(F)if(Y=p.get(_e),Y===void 0&&(Y=[],p.set(_e,Y)),F.isWebGLMultipleRenderTargets){const xe=F.texture;if(Y.length!==xe.length||Y[0]!==r.COLOR_ATTACHMENT0){for(let nt=0,ut=xe.length;nt<ut;nt++)Y[nt]=r.COLOR_ATTACHMENT0+nt;Y.length=xe.length,ue=!0}}else Y[0]!==r.COLOR_ATTACHMENT0&&(Y[0]=r.COLOR_ATTACHMENT0,ue=!0);else Y[0]!==r.BACK&&(Y[0]=r.BACK,ue=!0);ue&&(t.isWebGL2?r.drawBuffers(Y):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Y))}function Le(F){return g!==F?(r.useProgram(F),g=F,!0):!1}const D={[Di]:r.FUNC_ADD,[Ku]:r.FUNC_SUBTRACT,[ju]:r.FUNC_REVERSE_SUBTRACT};if(n)D[Zl]=r.MIN,D[Jl]=r.MAX;else{const F=e.get("EXT_blend_minmax");F!==null&&(D[Zl]=F.MIN_EXT,D[Jl]=F.MAX_EXT)}const ae={[Qu]:r.ZERO,[ef]:r.ONE,[tf]:r.SRC_COLOR,[Kl]:r.SRC_ALPHA,[lf]:r.SRC_ALPHA_SATURATE,[af]:r.DST_COLOR,[rf]:r.DST_ALPHA,[nf]:r.ONE_MINUS_SRC_COLOR,[jl]:r.ONE_MINUS_SRC_ALPHA,[of]:r.ONE_MINUS_DST_COLOR,[sf]:r.ONE_MINUS_DST_ALPHA};function Q(F,_e,Y,ue,xe,nt,ut,Pt){if(F===qn){m===!0&&(Te(r.BLEND),m=!1);return}if(m===!1&&(Pe(r.BLEND),m=!0),F!==Ju){if(F!==y||Pt!==S){if((x!==Di||w!==Di)&&(r.blendEquation(r.FUNC_ADD),x=Di,w=Di),Pt)switch(F){case Ui:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case ql:r.blendFunc(r.ONE,r.ONE);break;case $l:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Yl:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",F);break}else switch(F){case Ui:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case ql:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case $l:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Yl:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",F);break}v=null,M=null,A=null,C=null,y=F,S=Pt}return}xe=xe||_e,nt=nt||Y,ut=ut||ue,(_e!==x||xe!==w)&&(r.blendEquationSeparate(D[_e],D[xe]),x=_e,w=xe),(Y!==v||ue!==M||nt!==A||ut!==C)&&(r.blendFuncSeparate(ae[Y],ae[ue],ae[nt],ae[ut]),v=Y,M=ue,A=nt,C=ut),y=F,S=!1}function oe(F,_e){F.side===Nn?Te(r.CULL_FACE):Pe(r.CULL_FACE);let Y=F.side===kt;_e&&(Y=!Y),re(Y),F.blending===Ui&&F.transparent===!1?Q(qn):Q(F.blending,F.blendEquation,F.blendSrc,F.blendDst,F.blendEquationAlpha,F.blendSrcAlpha,F.blendDstAlpha,F.premultipliedAlpha),l.setFunc(F.depthFunc),l.setTest(F.depthTest),l.setMask(F.depthWrite),o.setMask(F.colorWrite);const ue=F.stencilWrite;c.setTest(ue),ue&&(c.setMask(F.stencilWriteMask),c.setFunc(F.stencilFunc,F.stencilRef,F.stencilFuncMask),c.setOp(F.stencilFail,F.stencilZFail,F.stencilZPass)),J(F.polygonOffset,F.polygonOffsetFactor,F.polygonOffsetUnits),F.alphaToCoverage===!0?Pe(r.SAMPLE_ALPHA_TO_COVERAGE):Te(r.SAMPLE_ALPHA_TO_COVERAGE)}function re(F){b!==F&&(F?r.frontFace(r.CW):r.frontFace(r.CCW),b=F)}function Ee(F){F!==Jt?(Pe(r.CULL_FACE),F!==L&&(F===dr?r.cullFace(r.BACK):F===va?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):Te(r.CULL_FACE),L=F}function $(F){F!==k&&(B&&r.lineWidth(F),k=F)}function J(F,_e,Y){F?(Pe(r.POLYGON_OFFSET_FILL),(U!==_e||N!==Y)&&(r.polygonOffset(_e,Y),U=_e,N=Y)):Te(r.POLYGON_OFFSET_FILL)}function ne(F){F?Pe(r.SCISSOR_TEST):Te(r.SCISSOR_TEST)}function de(F){F===void 0&&(F=r.TEXTURE0+I-1),X!==F&&(r.activeTexture(F),X=F)}function pe(F,_e,Y){Y===void 0&&(X===null?Y=r.TEXTURE0+I-1:Y=X);let ue=ee[Y];ue===void 0&&(ue={type:void 0,texture:void 0},ee[Y]=ue),(ue.type!==F||ue.texture!==_e)&&(X!==Y&&(r.activeTexture(Y),X=Y),r.bindTexture(F,_e||Ae[F]),ue.type=F,ue.texture=_e)}function T(){const F=ee[X];F!==void 0&&F.type!==void 0&&(r.bindTexture(F.type,null),F.type=void 0,F.texture=void 0)}function E(){try{r.compressedTexImage2D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function W(){try{r.compressedTexImage3D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function se(){try{r.texSubImage2D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function ie(){try{r.texSubImage3D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function me(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function we(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function he(){try{r.texStorage2D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function K(){try{r.texStorage3D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function Re(){try{r.texImage2D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function Ce(){try{r.texImage3D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function Ie(F){le.equals(F)===!1&&(r.scissor(F.x,F.y,F.z,F.w),le.copy(F))}function be(F){ce.equals(F)===!1&&(r.viewport(F.x,F.y,F.z,F.w),ce.copy(F))}function Me(F,_e){let Y=u.get(_e);Y===void 0&&(Y=new WeakMap,u.set(_e,Y));let ue=Y.get(F);ue===void 0&&(ue=r.getUniformBlockIndex(_e,F.name),Y.set(F,ue))}function qe(F,_e){const ue=u.get(_e).get(F);h.get(_e)!==ue&&(r.uniformBlockBinding(_e,ue,F.__bindingPointIndex),h.set(_e,ue))}function at(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),n===!0&&(r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),f={},X=null,ee={},d={},p=new WeakMap,_=[],g=null,m=!1,y=null,x=null,v=null,M=null,w=null,A=null,C=null,S=!1,b=null,L=null,k=null,U=null,N=null,le.set(0,0,r.canvas.width,r.canvas.height),ce.set(0,0,r.canvas.width,r.canvas.height),o.reset(),l.reset(),c.reset()}return{buffers:{color:o,depth:l,stencil:c},enable:Pe,disable:Te,bindFramebuffer:Ke,drawBuffers:je,useProgram:Le,setBlending:Q,setMaterial:oe,setFlipSided:re,setCullFace:Ee,setLineWidth:$,setPolygonOffset:J,setScissorTest:ne,activeTexture:de,bindTexture:pe,unbindTexture:T,compressedTexImage2D:E,compressedTexImage3D:W,texImage2D:Re,texImage3D:Ce,updateUBOMapping:Me,uniformBlockBinding:qe,texStorage2D:he,texStorage3D:K,texSubImage2D:se,texSubImage3D:ie,compressedTexSubImage2D:me,compressedTexSubImage3D:we,scissor:Ie,viewport:be,reset:at}}function VM(r,e,t,n,i,s,a){const o=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,h=i.maxTextureSize,u=i.maxSamples,f=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,d=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap;let _;const g=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(T){}function y(T,E){return m?new OffscreenCanvas(T,E):As("canvas")}function x(T,E,W,se){let ie=1;if((T.width>se||T.height>se)&&(ie=se/Math.max(T.width,T.height)),ie<1||E===!0)if(typeof HTMLImageElement!="undefined"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&T instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&T instanceof ImageBitmap){const me=E?Da:Math.floor,we=me(ie*T.width),he=me(ie*T.height);_===void 0&&(_=y(we,he));const K=W?y(we,he):_;return K.width=we,K.height=he,K.getContext("2d").drawImage(T,0,0,we,he),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+T.width+"x"+T.height+") to ("+we+"x"+he+")."),K}else return"data"in T&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+T.width+"x"+T.height+")."),T;return T}function v(T){return Dc(T.width)&&Dc(T.height)}function M(T){return o?!1:T.wrapS!==Dt||T.wrapT!==Dt||T.minFilter!==yt&&T.minFilter!==vt}function w(T,E){return T.generateMipmaps&&E&&T.minFilter!==yt&&T.minFilter!==vt}function A(T){r.generateMipmap(T)}function C(T,E,W,se,ie=!1){if(o===!1)return E;if(T!==null){if(r[T]!==void 0)return r[T];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let me=E;return E===r.RED&&(W===r.FLOAT&&(me=r.R32F),W===r.HALF_FLOAT&&(me=r.R16F),W===r.UNSIGNED_BYTE&&(me=r.R8)),E===r.RG&&(W===r.FLOAT&&(me=r.RG32F),W===r.HALF_FLOAT&&(me=r.RG16F),W===r.UNSIGNED_BYTE&&(me=r.RG8)),E===r.RGBA&&(W===r.FLOAT&&(me=r.RGBA32F),W===r.HALF_FLOAT&&(me=r.RGBA16F),W===r.UNSIGNED_BYTE&&(me=se===Ge&&ie===!1?r.SRGB8_ALPHA8:r.RGBA8),W===r.UNSIGNED_SHORT_4_4_4_4&&(me=r.RGBA4),W===r.UNSIGNED_SHORT_5_5_5_1&&(me=r.RGB5_A1)),(me===r.R16F||me===r.R32F||me===r.RG16F||me===r.RG32F||me===r.RGBA16F||me===r.RGBA32F)&&e.get("EXT_color_buffer_float"),me}function S(T,E,W){return w(T,W)===!0||T.isFramebufferTexture&&T.minFilter!==yt&&T.minFilter!==vt?Math.log2(Math.max(E.width,E.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?E.mipmaps.length:1}function b(T){return T===yt||T===ba||T===ys?r.NEAREST:r.LINEAR}function L(T){const E=T.target;E.removeEventListener("dispose",L),U(E),E.isVideoTexture&&p.delete(E)}function k(T){const E=T.target;E.removeEventListener("dispose",k),I(E)}function U(T){const E=n.get(T);if(E.__webglInit===void 0)return;const W=T.source,se=g.get(W);if(se){const ie=se[E.__cacheKey];ie.usedTimes--,ie.usedTimes===0&&N(T),Object.keys(se).length===0&&g.delete(W)}n.remove(T)}function N(T){const E=n.get(T);r.deleteTexture(E.__webglTexture);const W=T.source,se=g.get(W);delete se[E.__cacheKey],a.memory.textures--}function I(T){const E=T.texture,W=n.get(T),se=n.get(E);if(se.__webglTexture!==void 0&&(r.deleteTexture(se.__webglTexture),a.memory.textures--),T.depthTexture&&T.depthTexture.dispose(),T.isWebGLCubeRenderTarget)for(let ie=0;ie<6;ie++)r.deleteFramebuffer(W.__webglFramebuffer[ie]),W.__webglDepthbuffer&&r.deleteRenderbuffer(W.__webglDepthbuffer[ie]);else{if(r.deleteFramebuffer(W.__webglFramebuffer),W.__webglDepthbuffer&&r.deleteRenderbuffer(W.__webglDepthbuffer),W.__webglMultisampledFramebuffer&&r.deleteFramebuffer(W.__webglMultisampledFramebuffer),W.__webglColorRenderbuffer)for(let ie=0;ie<W.__webglColorRenderbuffer.length;ie++)W.__webglColorRenderbuffer[ie]&&r.deleteRenderbuffer(W.__webglColorRenderbuffer[ie]);W.__webglDepthRenderbuffer&&r.deleteRenderbuffer(W.__webglDepthRenderbuffer)}if(T.isWebGLMultipleRenderTargets)for(let ie=0,me=E.length;ie<me;ie++){const we=n.get(E[ie]);we.__webglTexture&&(r.deleteTexture(we.__webglTexture),a.memory.textures--),n.remove(E[ie])}n.remove(E),n.remove(T)}let B=0;function O(){B=0}function H(){const T=B;return T>=l&&console.warn("THREE.WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+l),B+=1,T}function X(T){const E=[];return E.push(T.wrapS),E.push(T.wrapT),E.push(T.wrapR||0),E.push(T.magFilter),E.push(T.minFilter),E.push(T.anisotropy),E.push(T.internalFormat),E.push(T.format),E.push(T.type),E.push(T.generateMipmaps),E.push(T.premultiplyAlpha),E.push(T.flipY),E.push(T.unpackAlignment),E.push(T.colorSpace),E.join()}function ee(T,E){const W=n.get(T);if(T.isVideoTexture&&de(T),T.isRenderTargetTexture===!1&&T.version>0&&W.__version!==T.version){const se=T.image;if(se===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(se.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ke(W,T,E);return}}t.bindTexture(r.TEXTURE_2D,W.__webglTexture,r.TEXTURE0+E)}function z(T,E){const W=n.get(T);if(T.version>0&&W.__version!==T.version){Ke(W,T,E);return}t.bindTexture(r.TEXTURE_2D_ARRAY,W.__webglTexture,r.TEXTURE0+E)}function Z(T,E){const W=n.get(T);if(T.version>0&&W.__version!==T.version){Ke(W,T,E);return}t.bindTexture(r.TEXTURE_3D,W.__webglTexture,r.TEXTURE0+E)}function le(T,E){const W=n.get(T);if(T.version>0&&W.__version!==T.version){je(W,T,E);return}t.bindTexture(r.TEXTURE_CUBE_MAP,W.__webglTexture,r.TEXTURE0+E)}const ce={[_s]:r.REPEAT,[Dt]:r.CLAMP_TO_EDGE,[xs]:r.MIRRORED_REPEAT},fe={[yt]:r.NEAREST,[ba]:r.NEAREST_MIPMAP_NEAREST,[ys]:r.NEAREST_MIPMAP_LINEAR,[vt]:r.LINEAR,[Ql]:r.LINEAR_MIPMAP_NEAREST,[gi]:r.LINEAR_MIPMAP_LINEAR},Ae={[zf]:r.NEVER,[qf]:r.ALWAYS,[kf]:r.LESS,[Hf]:r.LEQUAL,[Gf]:r.EQUAL,[Xf]:r.GEQUAL,[Vf]:r.GREATER,[Wf]:r.NOTEQUAL};function Pe(T,E,W){if(W?(r.texParameteri(T,r.TEXTURE_WRAP_S,ce[E.wrapS]),r.texParameteri(T,r.TEXTURE_WRAP_T,ce[E.wrapT]),(T===r.TEXTURE_3D||T===r.TEXTURE_2D_ARRAY)&&r.texParameteri(T,r.TEXTURE_WRAP_R,ce[E.wrapR]),r.texParameteri(T,r.TEXTURE_MAG_FILTER,fe[E.magFilter]),r.texParameteri(T,r.TEXTURE_MIN_FILTER,fe[E.minFilter])):(r.texParameteri(T,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(T,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),(T===r.TEXTURE_3D||T===r.TEXTURE_2D_ARRAY)&&r.texParameteri(T,r.TEXTURE_WRAP_R,r.CLAMP_TO_EDGE),(E.wrapS!==Dt||E.wrapT!==Dt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(T,r.TEXTURE_MAG_FILTER,b(E.magFilter)),r.texParameteri(T,r.TEXTURE_MIN_FILTER,b(E.minFilter)),E.minFilter!==yt&&E.minFilter!==vt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),E.compareFunction&&(r.texParameteri(T,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(T,r.TEXTURE_COMPARE_FUNC,Ae[E.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const se=e.get("EXT_texture_filter_anisotropic");if(E.magFilter===yt||E.minFilter!==ys&&E.minFilter!==gi||E.type===On&&e.has("OES_texture_float_linear")===!1||o===!1&&E.type===gr&&e.has("OES_texture_half_float_linear")===!1)return;(E.anisotropy>1||n.get(E).__currentAnisotropy)&&(r.texParameterf(T,se.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(E.anisotropy,i.getMaxAnisotropy())),n.get(E).__currentAnisotropy=E.anisotropy)}}function Te(T,E){let W=!1;T.__webglInit===void 0&&(T.__webglInit=!0,E.addEventListener("dispose",L));const se=E.source;let ie=g.get(se);ie===void 0&&(ie={},g.set(se,ie));const me=X(E);if(me!==T.__cacheKey){ie[me]===void 0&&(ie[me]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,W=!0),ie[me].usedTimes++;const we=ie[T.__cacheKey];we!==void 0&&(ie[T.__cacheKey].usedTimes--,we.usedTimes===0&&N(E)),T.__cacheKey=me,T.__webglTexture=ie[me].texture}return W}function Ke(T,E,W){let se=r.TEXTURE_2D;(E.isDataArrayTexture||E.isCompressedArrayTexture)&&(se=r.TEXTURE_2D_ARRAY),E.isData3DTexture&&(se=r.TEXTURE_3D);const ie=Te(T,E),me=E.source;t.bindTexture(se,T.__webglTexture,r.TEXTURE0+W);const we=n.get(me);if(me.version!==we.__version||ie===!0){t.activeTexture(r.TEXTURE0+W),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,E.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE);const he=M(E)&&v(E.image)===!1;let K=x(E.image,he,!1,h);K=pe(E,K);const Re=v(K)||o,Ce=s.convert(E.format,E.colorSpace);let Ie=s.convert(E.type),be=C(E.internalFormat,Ce,Ie,E.colorSpace);Pe(se,E,Re);let Me;const qe=E.mipmaps,at=o&&E.isVideoTexture!==!0,F=we.__version===void 0||ie===!0,_e=S(E,K,Re);if(E.isDepthTexture)be=r.DEPTH_COMPONENT,o?E.type===On?be=r.DEPTH_COMPONENT32F:E.type===Yn?be=r.DEPTH_COMPONENT24:E.type===_i?be=r.DEPTH24_STENCIL8:be=r.DEPTH_COMPONENT16:E.type===On&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),E.format===xi&&be===r.DEPTH_COMPONENT&&E.type!==wa&&E.type!==Yn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),E.type=Yn,Ie=s.convert(E.type)),E.format===Ni&&be===r.DEPTH_COMPONENT&&(be=r.DEPTH_STENCIL,E.type!==_i&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),E.type=_i,Ie=s.convert(E.type))),F&&(at?t.texStorage2D(r.TEXTURE_2D,1,be,K.width,K.height):t.texImage2D(r.TEXTURE_2D,0,be,K.width,K.height,0,Ce,Ie,null));else if(E.isDataTexture)if(qe.length>0&&Re){at&&F&&t.texStorage2D(r.TEXTURE_2D,_e,be,qe[0].width,qe[0].height);for(let Y=0,ue=qe.length;Y<ue;Y++)Me=qe[Y],at?t.texSubImage2D(r.TEXTURE_2D,Y,0,0,Me.width,Me.height,Ce,Ie,Me.data):t.texImage2D(r.TEXTURE_2D,Y,be,Me.width,Me.height,0,Ce,Ie,Me.data);E.generateMipmaps=!1}else at?(F&&t.texStorage2D(r.TEXTURE_2D,_e,be,K.width,K.height),t.texSubImage2D(r.TEXTURE_2D,0,0,0,K.width,K.height,Ce,Ie,K.data)):t.texImage2D(r.TEXTURE_2D,0,be,K.width,K.height,0,Ce,Ie,K.data);else if(E.isCompressedTexture)if(E.isCompressedArrayTexture){at&&F&&t.texStorage3D(r.TEXTURE_2D_ARRAY,_e,be,qe[0].width,qe[0].height,K.depth);for(let Y=0,ue=qe.length;Y<ue;Y++)Me=qe[Y],E.format!==an?Ce!==null?at?t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,Y,0,0,0,Me.width,Me.height,K.depth,Ce,Me.data,0,0):t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,Y,be,Me.width,Me.height,K.depth,0,Me.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):at?t.texSubImage3D(r.TEXTURE_2D_ARRAY,Y,0,0,0,Me.width,Me.height,K.depth,Ce,Ie,Me.data):t.texImage3D(r.TEXTURE_2D_ARRAY,Y,be,Me.width,Me.height,K.depth,0,Ce,Ie,Me.data)}else{at&&F&&t.texStorage2D(r.TEXTURE_2D,_e,be,qe[0].width,qe[0].height);for(let Y=0,ue=qe.length;Y<ue;Y++)Me=qe[Y],E.format!==an?Ce!==null?at?t.compressedTexSubImage2D(r.TEXTURE_2D,Y,0,0,Me.width,Me.height,Ce,Me.data):t.compressedTexImage2D(r.TEXTURE_2D,Y,be,Me.width,Me.height,0,Me.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):at?t.texSubImage2D(r.TEXTURE_2D,Y,0,0,Me.width,Me.height,Ce,Ie,Me.data):t.texImage2D(r.TEXTURE_2D,Y,be,Me.width,Me.height,0,Ce,Ie,Me.data)}else if(E.isDataArrayTexture)at?(F&&t.texStorage3D(r.TEXTURE_2D_ARRAY,_e,be,K.width,K.height,K.depth),t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,K.width,K.height,K.depth,Ce,Ie,K.data)):t.texImage3D(r.TEXTURE_2D_ARRAY,0,be,K.width,K.height,K.depth,0,Ce,Ie,K.data);else if(E.isData3DTexture)at?(F&&t.texStorage3D(r.TEXTURE_3D,_e,be,K.width,K.height,K.depth),t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,K.width,K.height,K.depth,Ce,Ie,K.data)):t.texImage3D(r.TEXTURE_3D,0,be,K.width,K.height,K.depth,0,Ce,Ie,K.data);else if(E.isFramebufferTexture){if(F)if(at)t.texStorage2D(r.TEXTURE_2D,_e,be,K.width,K.height);else{let Y=K.width,ue=K.height;for(let xe=0;xe<_e;xe++)t.texImage2D(r.TEXTURE_2D,xe,be,Y,ue,0,Ce,Ie,null),Y>>=1,ue>>=1}}else if(qe.length>0&&Re){at&&F&&t.texStorage2D(r.TEXTURE_2D,_e,be,qe[0].width,qe[0].height);for(let Y=0,ue=qe.length;Y<ue;Y++)Me=qe[Y],at?t.texSubImage2D(r.TEXTURE_2D,Y,0,0,Ce,Ie,Me):t.texImage2D(r.TEXTURE_2D,Y,be,Ce,Ie,Me);E.generateMipmaps=!1}else at?(F&&t.texStorage2D(r.TEXTURE_2D,_e,be,K.width,K.height),t.texSubImage2D(r.TEXTURE_2D,0,0,0,Ce,Ie,K)):t.texImage2D(r.TEXTURE_2D,0,be,Ce,Ie,K);w(E,Re)&&A(se),we.__version=me.version,E.onUpdate&&E.onUpdate(E)}T.__version=E.version}function je(T,E,W){if(E.image.length!==6)return;const se=Te(T,E),ie=E.source;t.bindTexture(r.TEXTURE_CUBE_MAP,T.__webglTexture,r.TEXTURE0+W);const me=n.get(ie);if(ie.version!==me.__version||se===!0){t.activeTexture(r.TEXTURE0+W),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,E.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE);const we=E.isCompressedTexture||E.image[0].isCompressedTexture,he=E.image[0]&&E.image[0].isDataTexture,K=[];for(let Y=0;Y<6;Y++)!we&&!he?K[Y]=x(E.image[Y],!1,!0,c):K[Y]=he?E.image[Y].image:E.image[Y],K[Y]=pe(E,K[Y]);const Re=K[0],Ce=v(Re)||o,Ie=s.convert(E.format,E.colorSpace),be=s.convert(E.type),Me=C(E.internalFormat,Ie,be,E.colorSpace),qe=o&&E.isVideoTexture!==!0,at=me.__version===void 0||se===!0;let F=S(E,Re,Ce);Pe(r.TEXTURE_CUBE_MAP,E,Ce);let _e;if(we){qe&&at&&t.texStorage2D(r.TEXTURE_CUBE_MAP,F,Me,Re.width,Re.height);for(let Y=0;Y<6;Y++){_e=K[Y].mipmaps;for(let ue=0;ue<_e.length;ue++){const xe=_e[ue];E.format!==an?Ie!==null?qe?t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue,0,0,xe.width,xe.height,Ie,xe.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue,Me,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):qe?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue,0,0,xe.width,xe.height,Ie,be,xe.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue,Me,xe.width,xe.height,0,Ie,be,xe.data)}}}else{_e=E.mipmaps,qe&&at&&(_e.length>0&&F++,t.texStorage2D(r.TEXTURE_CUBE_MAP,F,Me,K[0].width,K[0].height));for(let Y=0;Y<6;Y++)if(he){qe?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,K[Y].width,K[Y].height,Ie,be,K[Y].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,Me,K[Y].width,K[Y].height,0,Ie,be,K[Y].data);for(let ue=0;ue<_e.length;ue++){const nt=_e[ue].image[Y].image;qe?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue+1,0,0,nt.width,nt.height,Ie,be,nt.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue+1,Me,nt.width,nt.height,0,Ie,be,nt.data)}}else{qe?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,Ie,be,K[Y]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,Me,Ie,be,K[Y]);for(let ue=0;ue<_e.length;ue++){const xe=_e[ue];qe?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue+1,0,0,Ie,be,xe.image[Y]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue+1,Me,Ie,be,xe.image[Y])}}}w(E,Ce)&&A(r.TEXTURE_CUBE_MAP),me.__version=ie.version,E.onUpdate&&E.onUpdate(E)}T.__version=E.version}function Le(T,E,W,se,ie){const me=s.convert(W.format,W.colorSpace),we=s.convert(W.type),he=C(W.internalFormat,me,we,W.colorSpace);n.get(E).__hasExternalTextures||(ie===r.TEXTURE_3D||ie===r.TEXTURE_2D_ARRAY?t.texImage3D(ie,0,he,E.width,E.height,E.depth,0,me,we,null):t.texImage2D(ie,0,he,E.width,E.height,0,me,we,null)),t.bindFramebuffer(r.FRAMEBUFFER,T),ne(E)?f.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,se,ie,n.get(W).__webglTexture,0,J(E)):(ie===r.TEXTURE_2D||ie>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,se,ie,n.get(W).__webglTexture,0),t.bindFramebuffer(r.FRAMEBUFFER,null)}function D(T,E,W){if(r.bindRenderbuffer(r.RENDERBUFFER,T),E.depthBuffer&&!E.stencilBuffer){let se=r.DEPTH_COMPONENT16;if(W||ne(E)){const ie=E.depthTexture;ie&&ie.isDepthTexture&&(ie.type===On?se=r.DEPTH_COMPONENT32F:ie.type===Yn&&(se=r.DEPTH_COMPONENT24));const me=J(E);ne(E)?f.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,me,se,E.width,E.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,me,se,E.width,E.height)}else r.renderbufferStorage(r.RENDERBUFFER,se,E.width,E.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,T)}else if(E.depthBuffer&&E.stencilBuffer){const se=J(E);W&&ne(E)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,se,r.DEPTH24_STENCIL8,E.width,E.height):ne(E)?f.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,se,r.DEPTH24_STENCIL8,E.width,E.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,E.width,E.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,T)}else{const se=E.isWebGLMultipleRenderTargets===!0?E.texture:[E.texture];for(let ie=0;ie<se.length;ie++){const me=se[ie],we=s.convert(me.format,me.colorSpace),he=s.convert(me.type),K=C(me.internalFormat,we,he,me.colorSpace),Re=J(E);W&&ne(E)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,Re,K,E.width,E.height):ne(E)?f.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Re,K,E.width,E.height):r.renderbufferStorage(r.RENDERBUFFER,K,E.width,E.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function ae(T,E){if(E&&E.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(r.FRAMEBUFFER,T),!(E.depthTexture&&E.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(E.depthTexture).__webglTexture||E.depthTexture.image.width!==E.width||E.depthTexture.image.height!==E.height)&&(E.depthTexture.image.width=E.width,E.depthTexture.image.height=E.height,E.depthTexture.needsUpdate=!0),ee(E.depthTexture,0);const se=n.get(E.depthTexture).__webglTexture,ie=J(E);if(E.depthTexture.format===xi)ne(E)?f.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,se,0,ie):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,se,0);else if(E.depthTexture.format===Ni)ne(E)?f.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,se,0,ie):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,se,0);else throw new Error("Unknown depthTexture format")}function Q(T){const E=n.get(T),W=T.isWebGLCubeRenderTarget===!0;if(T.depthTexture&&!E.__autoAllocateDepthBuffer){if(W)throw new Error("target.depthTexture not supported in Cube render targets");ae(E.__webglFramebuffer,T)}else if(W){E.__webglDepthbuffer=[];for(let se=0;se<6;se++)t.bindFramebuffer(r.FRAMEBUFFER,E.__webglFramebuffer[se]),E.__webglDepthbuffer[se]=r.createRenderbuffer(),D(E.__webglDepthbuffer[se],T,!1)}else t.bindFramebuffer(r.FRAMEBUFFER,E.__webglFramebuffer),E.__webglDepthbuffer=r.createRenderbuffer(),D(E.__webglDepthbuffer,T,!1);t.bindFramebuffer(r.FRAMEBUFFER,null)}function oe(T,E,W){const se=n.get(T);E!==void 0&&Le(se.__webglFramebuffer,T,T.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D),W!==void 0&&Q(T)}function re(T){const E=T.texture,W=n.get(T),se=n.get(E);T.addEventListener("dispose",k),T.isWebGLMultipleRenderTargets!==!0&&(se.__webglTexture===void 0&&(se.__webglTexture=r.createTexture()),se.__version=E.version,a.memory.textures++);const ie=T.isWebGLCubeRenderTarget===!0,me=T.isWebGLMultipleRenderTargets===!0,we=v(T)||o;if(ie){W.__webglFramebuffer=[];for(let he=0;he<6;he++)W.__webglFramebuffer[he]=r.createFramebuffer()}else{if(W.__webglFramebuffer=r.createFramebuffer(),me)if(i.drawBuffers){const he=T.texture;for(let K=0,Re=he.length;K<Re;K++){const Ce=n.get(he[K]);Ce.__webglTexture===void 0&&(Ce.__webglTexture=r.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&T.samples>0&&ne(T)===!1){const he=me?E:[E];W.__webglMultisampledFramebuffer=r.createFramebuffer(),W.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,W.__webglMultisampledFramebuffer);for(let K=0;K<he.length;K++){const Re=he[K];W.__webglColorRenderbuffer[K]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,W.__webglColorRenderbuffer[K]);const Ce=s.convert(Re.format,Re.colorSpace),Ie=s.convert(Re.type),be=C(Re.internalFormat,Ce,Ie,Re.colorSpace,T.isXRRenderTarget===!0),Me=J(T);r.renderbufferStorageMultisample(r.RENDERBUFFER,Me,be,T.width,T.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+K,r.RENDERBUFFER,W.__webglColorRenderbuffer[K])}r.bindRenderbuffer(r.RENDERBUFFER,null),T.depthBuffer&&(W.__webglDepthRenderbuffer=r.createRenderbuffer(),D(W.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(ie){t.bindTexture(r.TEXTURE_CUBE_MAP,se.__webglTexture),Pe(r.TEXTURE_CUBE_MAP,E,we);for(let he=0;he<6;he++)Le(W.__webglFramebuffer[he],T,E,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+he);w(E,we)&&A(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(me){const he=T.texture;for(let K=0,Re=he.length;K<Re;K++){const Ce=he[K],Ie=n.get(Ce);t.bindTexture(r.TEXTURE_2D,Ie.__webglTexture),Pe(r.TEXTURE_2D,Ce,we),Le(W.__webglFramebuffer,T,Ce,r.COLOR_ATTACHMENT0+K,r.TEXTURE_2D),w(Ce,we)&&A(r.TEXTURE_2D)}t.unbindTexture()}else{let he=r.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(o?he=T.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(he,se.__webglTexture),Pe(he,E,we),Le(W.__webglFramebuffer,T,E,r.COLOR_ATTACHMENT0,he),w(E,we)&&A(he),t.unbindTexture()}T.depthBuffer&&Q(T)}function Ee(T){const E=v(T)||o,W=T.isWebGLMultipleRenderTargets===!0?T.texture:[T.texture];for(let se=0,ie=W.length;se<ie;se++){const me=W[se];if(w(me,E)){const we=T.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D,he=n.get(me).__webglTexture;t.bindTexture(we,he),A(we),t.unbindTexture()}}}function $(T){if(o&&T.samples>0&&ne(T)===!1){const E=T.isWebGLMultipleRenderTargets?T.texture:[T.texture],W=T.width,se=T.height;let ie=r.COLOR_BUFFER_BIT;const me=[],we=T.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,he=n.get(T),K=T.isWebGLMultipleRenderTargets===!0;if(K)for(let Re=0;Re<E.length;Re++)t.bindFramebuffer(r.FRAMEBUFFER,he.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Re,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,he.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Re,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,he.__webglMultisampledFramebuffer),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,he.__webglFramebuffer);for(let Re=0;Re<E.length;Re++){me.push(r.COLOR_ATTACHMENT0+Re),T.depthBuffer&&me.push(we);const Ce=he.__ignoreDepthValues!==void 0?he.__ignoreDepthValues:!1;if(Ce===!1&&(T.depthBuffer&&(ie|=r.DEPTH_BUFFER_BIT),T.stencilBuffer&&(ie|=r.STENCIL_BUFFER_BIT)),K&&r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,he.__webglColorRenderbuffer[Re]),Ce===!0&&(r.invalidateFramebuffer(r.READ_FRAMEBUFFER,[we]),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[we])),K){const Ie=n.get(E[Re]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,Ie,0)}r.blitFramebuffer(0,0,W,se,0,0,W,se,ie,r.NEAREST),d&&r.invalidateFramebuffer(r.READ_FRAMEBUFFER,me)}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),K)for(let Re=0;Re<E.length;Re++){t.bindFramebuffer(r.FRAMEBUFFER,he.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Re,r.RENDERBUFFER,he.__webglColorRenderbuffer[Re]);const Ce=n.get(E[Re]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,he.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Re,r.TEXTURE_2D,Ce,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}}function J(T){return Math.min(u,T.samples)}function ne(T){const E=n.get(T);return o&&T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&E.__useRenderToTexture!==!1}function de(T){const E=a.render.frame;p.get(T)!==E&&(p.set(T,E),T.update())}function pe(T,E){const W=T.colorSpace,se=T.format,ie=T.type;return T.isCompressedTexture===!0||T.format===Ua||W!==Sn&&W!==Mi&&(W===Ge?o===!1?e.has("EXT_sRGB")===!0&&se===an?(T.format=Ua,T.minFilter=vt,T.generateMipmaps=!1):E=Oc.sRGBToLinear(E):(se!==an||ie!==$n)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",W)),E}this.allocateTextureUnit=H,this.resetTextureUnits=O,this.setTexture2D=ee,this.setTexture2DArray=z,this.setTexture3D=Z,this.setTextureCube=le,this.rebindTextures=oe,this.setupRenderTarget=re,this.updateRenderTargetMipmap=Ee,this.updateMultisampleRenderTarget=$,this.setupDepthRenderbuffer=Q,this.setupFrameBufferTexture=Le,this.useMultisampledRTT=ne}function Hd(r,e,t){const n=t.isWebGL2;function i(s,a=Mi){let o;if(s===$n)return r.UNSIGNED_BYTE;if(s===tc)return r.UNSIGNED_SHORT_4_4_4_4;if(s===nc)return r.UNSIGNED_SHORT_5_5_5_1;if(s===bf)return r.BYTE;if(s===wf)return r.SHORT;if(s===wa)return r.UNSIGNED_SHORT;if(s===ec)return r.INT;if(s===Yn)return r.UNSIGNED_INT;if(s===On)return r.FLOAT;if(s===gr)return n?r.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===Ef)return r.ALPHA;if(s===an)return r.RGBA;if(s===Af)return r.LUMINANCE;if(s===Tf)return r.LUMINANCE_ALPHA;if(s===xi)return r.DEPTH_COMPONENT;if(s===Ni)return r.DEPTH_STENCIL;if(s===Ua)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===Rf)return r.RED;if(s===ic)return r.RED_INTEGER;if(s===Cf)return r.RG;if(s===rc)return r.RG_INTEGER;if(s===sc)return r.RGBA_INTEGER;if(s===Ea||s===Aa||s===Ta||s===Ra)if(a===Ge)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===Ea)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Aa)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Ta)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Ra)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===Ea)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Aa)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Ta)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Ra)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===ac||s===oc||s===lc||s===cc)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===ac)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===oc)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===lc)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===cc)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Pf)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===hc||s===uc)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===hc)return a===Ge?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===uc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===fc||s===dc||s===pc||s===mc||s===gc||s===_c||s===xc||s===yc||s===vc||s===Mc||s===Sc||s===bc||s===wc||s===Ec)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===fc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===dc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===pc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===mc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===gc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===_c)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===xc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===yc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===vc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===Mc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Sc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===bc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===wc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Ec)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Ca)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===Ca)return a===Ge?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===Lf||s===Ac||s===Tc||s===Rc)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(s===Ca)return o.COMPRESSED_RED_RGTC1_EXT;if(s===Ac)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Tc)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Rc)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===_i?n?r.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}class Vd extends Ut{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class kr extends tt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const WM={type:"move"};class hh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new kr,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 kr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new kr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R),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 n of e.hand.values())this._getHandJoint(t,n)}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,n){let i=null,s=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 _ of e.hand.values()){const g=t.getJointPose(_,n),m=this._getHandJoint(c,_);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=h.position.distanceTo(u.position),d=.02,p=.005;c.inputState.pinching&&f>d+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=d-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(WM)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new kr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Wd extends Mt{constructor(e,t,n,i,s,a,o,l,c,h){if(h=h!==void 0?h:xi,h!==xi&&h!==Ni)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===xi&&(n=Yn),n===void 0&&h===Ni&&(n=_i),super(null,i,s,a,o,l,h,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:yt,this.minFilter=l!==void 0?l:yt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class XM extends Zn{constructor(e,t){super();const n=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,f=null,d=null,p=null;const _=t.getContextAttributes();let g=null,m=null;const y=[],x=[],v=new Ut;v.layers.enable(1),v.viewport=new rt;const M=new Ut;M.layers.enable(2),M.viewport=new rt;const w=[v,M],A=new Vd;A.layers.enable(1),A.layers.enable(2);let C=null,S=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let Z=y[z];return Z===void 0&&(Z=new hh,y[z]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(z){let Z=y[z];return Z===void 0&&(Z=new hh,y[z]=Z),Z.getGripSpace()},this.getHand=function(z){let Z=y[z];return Z===void 0&&(Z=new hh,y[z]=Z),Z.getHandSpace()};function b(z){const Z=x.indexOf(z.inputSource);if(Z===-1)return;const le=y[Z];le!==void 0&&(le.update(z.inputSource,z.frame,c||a),le.dispatchEvent({type:z.type,data:z.inputSource}))}function L(){i.removeEventListener("select",b),i.removeEventListener("selectstart",b),i.removeEventListener("selectend",b),i.removeEventListener("squeeze",b),i.removeEventListener("squeezestart",b),i.removeEventListener("squeezeend",b),i.removeEventListener("end",L),i.removeEventListener("inputsourceschange",k);for(let z=0;z<y.length;z++){const Z=x[z];Z!==null&&(x[z]=null,y[z].disconnect(Z))}C=null,S=null,e.setRenderTarget(g),d=null,f=null,u=null,i=null,m=null,ee.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(z){s=z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(z){o=z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(z){c=z},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=function(z){return fs(this,null,function*(){if(i=z,i!==null){if(g=e.getRenderTarget(),i.addEventListener("select",b),i.addEventListener("selectstart",b),i.addEventListener("selectend",b),i.addEventListener("squeeze",b),i.addEventListener("squeezestart",b),i.addEventListener("squeezeend",b),i.addEventListener("end",L),i.addEventListener("inputsourceschange",k),_.xrCompatible!==!0&&(yield t.makeXRCompatible()),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const Z={antialias:i.renderState.layers===void 0?_.antialias:!0,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,t,Z),i.updateRenderState({baseLayer:d}),m=new bn(d.framebufferWidth,d.framebufferHeight,{format:an,type:$n,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil})}else{let Z=null,le=null,ce=null;_.depth&&(ce=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Z=_.stencil?Ni:xi,le=_.stencil?_i:Yn);const fe={colorFormat:t.RGBA8,depthFormat:ce,scaleFactor:s};u=new XRWebGLBinding(i,t),f=u.createProjectionLayer(fe),i.updateRenderState({layers:[f]}),m=new bn(f.textureWidth,f.textureHeight,{format:an,type:$n,depthTexture:new Wd(f.textureWidth,f.textureHeight,le,void 0,void 0,void 0,void 0,void 0,void 0,Z),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0});const Ae=e.properties.get(m);Ae.__ignoreDepthValues=f.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=yield i.requestReferenceSpace(o),ee.setContext(i),ee.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function k(z){for(let Z=0;Z<z.removed.length;Z++){const le=z.removed[Z],ce=x.indexOf(le);ce>=0&&(x[ce]=null,y[ce].disconnect(le))}for(let Z=0;Z<z.added.length;Z++){const le=z.added[Z];let ce=x.indexOf(le);if(ce===-1){for(let Ae=0;Ae<y.length;Ae++)if(Ae>=x.length){x.push(le),ce=Ae;break}else if(x[Ae]===null){x[Ae]=le,ce=Ae;break}if(ce===-1)break}const fe=y[ce];fe&&fe.connect(le)}}const U=new R,N=new R;function I(z,Z,le){U.setFromMatrixPosition(Z.matrixWorld),N.setFromMatrixPosition(le.matrixWorld);const ce=U.distanceTo(N),fe=Z.projectionMatrix.elements,Ae=le.projectionMatrix.elements,Pe=fe[14]/(fe[10]-1),Te=fe[14]/(fe[10]+1),Ke=(fe[9]+1)/fe[5],je=(fe[9]-1)/fe[5],Le=(fe[8]-1)/fe[0],D=(Ae[8]+1)/Ae[0],ae=Pe*Le,Q=Pe*D,oe=ce/(-Le+D),re=oe*-Le;Z.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(re),z.translateZ(oe),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert();const Ee=Pe+oe,$=Te+oe,J=ae-re,ne=Q+(ce-re),de=Ke*Te/$*Ee,pe=je*Te/$*Ee;z.projectionMatrix.makePerspective(J,ne,de,pe,Ee,$),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}function B(z,Z){Z===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(Z.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(i===null)return;A.near=M.near=v.near=z.near,A.far=M.far=v.far=z.far,(C!==A.near||S!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,S=A.far);const Z=z.parent,le=A.cameras;B(A,Z);for(let ce=0;ce<le.length;ce++)B(le[ce],Z);le.length===2?I(A,v,M):A.projectionMatrix.copy(v.projectionMatrix),O(z,A,Z)};function O(z,Z,le){le===null?z.matrix.copy(Z.matrixWorld):(z.matrix.copy(le.matrixWorld),z.matrix.invert(),z.matrix.multiply(Z.matrixWorld)),z.matrix.decompose(z.position,z.quaternion,z.scale),z.updateMatrixWorld(!0);const ce=z.children;for(let fe=0,Ae=ce.length;fe<Ae;fe++)ce[fe].updateMatrixWorld(!0);z.projectionMatrix.copy(Z.projectionMatrix),z.projectionMatrixInverse.copy(Z.projectionMatrixInverse),z.isPerspectiveCamera&&(z.fov=_r*2*Math.atan(1/z.projectionMatrix.elements[5]),z.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(f===null&&d===null))return l},this.setFoveation=function(z){l=z,f!==null&&(f.fixedFoveation=z),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=z)};let H=null;function X(z,Z){if(h=Z.getViewerPose(c||a),p=Z,h!==null){const le=h.views;d!==null&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let ce=!1;le.length!==A.cameras.length&&(A.cameras.length=0,ce=!0);for(let fe=0;fe<le.length;fe++){const Ae=le[fe];let Pe=null;if(d!==null)Pe=d.getViewport(Ae);else{const Ke=u.getViewSubImage(f,Ae);Pe=Ke.viewport,fe===0&&(e.setRenderTargetTextures(m,Ke.colorTexture,f.ignoreDepthValues?void 0:Ke.depthStencilTexture),e.setRenderTarget(m))}let Te=w[fe];Te===void 0&&(Te=new Ut,Te.layers.enable(fe),Te.viewport=new rt,w[fe]=Te),Te.matrix.fromArray(Ae.transform.matrix),Te.matrix.decompose(Te.position,Te.quaternion,Te.scale),Te.projectionMatrix.fromArray(Ae.projectionMatrix),Te.projectionMatrixInverse.copy(Te.projectionMatrix).invert(),Te.viewport.set(Pe.x,Pe.y,Pe.width,Pe.height),fe===0&&(A.matrix.copy(Te.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),ce===!0&&A.cameras.push(Te)}}for(let le=0;le<y.length;le++){const ce=x[le],fe=y[le];ce!==null&&fe!==void 0&&fe.update(ce,Z,c||a)}H&&H(z,Z),Z.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Z}),p=null}const ee=new gd;ee.setAnimationLoop(X),this.setAnimationLoop=function(z){H=z},this.dispose=function(){}}}function qM(r,e){function t(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function n(g,m){m.color.getRGB(g.fogColor.value,fd(r)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function i(g,m,y,x,v){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),u(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),f(g,m),m.isMeshPhysicalMaterial&&d(g,m,v)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),_(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(a(g,m),m.isLineDashedMaterial&&o(g,m)):m.isPointsMaterial?l(g,m,y,x):m.isSpriteMaterial?c(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,t(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===kt&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===kt&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,t(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,t(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);const y=e.get(m).envMap;if(y&&(g.envMap.value=y,g.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;const x=r.useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*x,t(m.lightMap,g.lightMapTransform)}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,g.aoMapTransform))}function a(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform))}function o(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function l(g,m,y,x){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*y,g.scale.value=x*.5,m.map&&(g.map.value=m.map,t(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function c(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function f(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,g.roughnessMapTransform)),e.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function d(g,m,y){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===kt&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function _(g,m){const y=e.get(m).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function $M(r,e,t,n){let i={},s={},a=[];const o=t.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(y,x){const v=x.program;n.uniformBlockBinding(y,v)}function c(y,x){let v=i[y.id];v===void 0&&(p(y),v=h(y),i[y.id]=v,y.addEventListener("dispose",g));const M=x.program;n.updateUBOMapping(y,M);const w=e.render.frame;s[y.id]!==w&&(f(y),s[y.id]=w)}function h(y){const x=u();y.__bindingPointIndex=x;const v=r.createBuffer(),M=y.__size,w=y.usage;return r.bindBuffer(r.UNIFORM_BUFFER,v),r.bufferData(r.UNIFORM_BUFFER,M,w),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,x,v),v}function u(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(y){const x=i[y.id],v=y.uniforms,M=y.__cache;r.bindBuffer(r.UNIFORM_BUFFER,x);for(let w=0,A=v.length;w<A;w++){const C=v[w];if(d(C,w,M)===!0){const S=C.__offset,b=Array.isArray(C.value)?C.value:[C.value];let L=0;for(let k=0;k<b.length;k++){const U=b[k],N=_(U);typeof U=="number"?(C.__data[0]=U,r.bufferSubData(r.UNIFORM_BUFFER,S+L,C.__data)):U.isMatrix3?(C.__data[0]=U.elements[0],C.__data[1]=U.elements[1],C.__data[2]=U.elements[2],C.__data[3]=U.elements[0],C.__data[4]=U.elements[3],C.__data[5]=U.elements[4],C.__data[6]=U.elements[5],C.__data[7]=U.elements[0],C.__data[8]=U.elements[6],C.__data[9]=U.elements[7],C.__data[10]=U.elements[8],C.__data[11]=U.elements[0]):(U.toArray(C.__data,L),L+=N.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,S,C.__data)}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function d(y,x,v){const M=y.value;if(v[x]===void 0){if(typeof M=="number")v[x]=M;else{const w=Array.isArray(M)?M:[M],A=[];for(let C=0;C<w.length;C++)A.push(w[C].clone());v[x]=A}return!0}else if(typeof M=="number"){if(v[x]!==M)return v[x]=M,!0}else{const w=Array.isArray(v[x])?v[x]:[v[x]],A=Array.isArray(M)?M:[M];for(let C=0;C<w.length;C++){const S=w[C];if(S.equals(A[C])===!1)return S.copy(A[C]),!0}}return!1}function p(y){const x=y.uniforms;let v=0;const M=16;let w=0;for(let A=0,C=x.length;A<C;A++){const S=x[A],b={boundary:0,storage:0},L=Array.isArray(S.value)?S.value:[S.value];for(let k=0,U=L.length;k<U;k++){const N=L[k],I=_(N);b.boundary+=I.boundary,b.storage+=I.storage}if(S.__data=new Float32Array(b.storage/Float32Array.BYTES_PER_ELEMENT),S.__offset=v,A>0){w=v%M;const k=M-w;w!==0&&k-b.boundary<0&&(v+=M-w,S.__offset=v)}v+=b.storage}return w=v%M,w>0&&(v+=M-w),y.__size=v,y.__cache={},this}function _(y){const x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function g(y){const x=y.target;x.removeEventListener("dispose",g);const v=a.indexOf(x.__bindingPointIndex);a.splice(v,1),r.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function m(){for(const y in i)r.deleteBuffer(i[y]);a=[],i={},s={}}return{bind:l,update:c,dispose:m}}function YM(){const r=As("canvas");return r.style.display="block",r}class Xd{constructor(e={}){const{canvas:t=YM(),context:n=null,depth:i=!0,stencil:s=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let f;n!==null?f=n.getContextAttributes().alpha:f=a;const d=new Uint32Array(4),p=new Int32Array(4);let _=null,g=null;const m=[],y=[];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.outputColorSpace=Ge,this.useLegacyLights=!0,this.toneMapping=Fn,this.toneMappingExposure=1;const x=this;let v=!1,M=0,w=0,A=null,C=-1,S=null;const b=new rt,L=new rt;let k=null;const U=new ye(0);let N=0,I=t.width,B=t.height,O=1,H=null,X=null;const ee=new rt(0,0,I,B),z=new rt(0,0,I,B);let Z=!1;const le=new no;let ce=!1,fe=!1,Ae=null;const Pe=new Be,Te=new q,Ke=new R,je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Le(){return A===null?O:1}let D=n;function ae(P,V){for(let j=0;j<P.length;j++){const G=P[j],te=t.getContext(G,V);if(te!==null)return te}return null}try{const P={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ot}`),t.addEventListener("webglcontextlost",_e,!1),t.addEventListener("webglcontextrestored",Y,!1),t.addEventListener("webglcontextcreationerror",ue,!1),D===null){const V=["webgl2","webgl","experimental-webgl"];if(x.isWebGL1Renderer===!0&&V.shift(),D=ae(V,P),D===null)throw ae(V)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext!="undefined"&&D instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),D.getShaderPrecisionFormat===void 0&&(D.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(P){throw console.error("THREE.WebGLRenderer: "+P.message),P}let Q,oe,re,Ee,$,J,ne,de,pe,T,E,W,se,ie,me,we,he,K,Re,Ce,Ie,be,Me,qe;function at(){Q=new cv(D),oe=new iv(D,Q,e),Q.init(oe),be=new Hd(D,Q,oe),re=new HM(D,Q,oe),Ee=new fv(D),$=new PM,J=new VM(D,Q,re,$,oe,be,Ee),ne=new sv(x),de=new lv(x),pe=new nx(D,oe),Me=new tv(D,Q,pe,oe),T=new hv(D,pe,Ee,Me),E=new gv(D,T,pe,Ee),Re=new mv(D,oe,J),we=new rv($),W=new CM(x,ne,de,Q,oe,Me,we),se=new qM(x,$),ie=new IM,me=new BM(Q,oe),K=new ev(x,ne,de,re,E,f,l),he=new GM(x,E,oe),qe=new $M(D,Ee,oe,re),Ce=new nv(D,Q,Ee,oe),Ie=new uv(D,Q,Ee,oe),Ee.programs=W.programs,x.capabilities=oe,x.extensions=Q,x.properties=$,x.renderLists=ie,x.shadowMap=he,x.state=re,x.info=Ee}at();const F=new XM(x,D);this.xr=F,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const P=Q.get("WEBGL_lose_context");P&&P.loseContext()},this.forceContextRestore=function(){const P=Q.get("WEBGL_lose_context");P&&P.restoreContext()},this.getPixelRatio=function(){return O},this.setPixelRatio=function(P){P!==void 0&&(O=P,this.setSize(I,B,!1))},this.getSize=function(P){return P.set(I,B)},this.setSize=function(P,V,j=!0){if(F.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}I=P,B=V,t.width=Math.floor(P*O),t.height=Math.floor(V*O),j===!0&&(t.style.width=P+"px",t.style.height=V+"px"),this.setViewport(0,0,P,V)},this.getDrawingBufferSize=function(P){return P.set(I*O,B*O).floor()},this.setDrawingBufferSize=function(P,V,j){I=P,B=V,O=j,t.width=Math.floor(P*j),t.height=Math.floor(V*j),this.setViewport(0,0,P,V)},this.getCurrentViewport=function(P){return P.copy(b)},this.getViewport=function(P){return P.copy(ee)},this.setViewport=function(P,V,j,G){P.isVector4?ee.set(P.x,P.y,P.z,P.w):ee.set(P,V,j,G),re.viewport(b.copy(ee).multiplyScalar(O).floor())},this.getScissor=function(P){return P.copy(z)},this.setScissor=function(P,V,j,G){P.isVector4?z.set(P.x,P.y,P.z,P.w):z.set(P,V,j,G),re.scissor(L.copy(z).multiplyScalar(O).floor())},this.getScissorTest=function(){return Z},this.setScissorTest=function(P){re.setScissorTest(Z=P)},this.setOpaqueSort=function(P){H=P},this.setTransparentSort=function(P){X=P},this.getClearColor=function(P){return P.copy(K.getClearColor())},this.setClearColor=function(){K.setClearColor.apply(K,arguments)},this.getClearAlpha=function(){return K.getClearAlpha()},this.setClearAlpha=function(){K.setClearAlpha.apply(K,arguments)},this.clear=function(P=!0,V=!0,j=!0){let G=0;if(P){let te=!1;if(A!==null){const Se=A.texture.format;te=Se===sc||Se===rc||Se===ic}if(te){const Se=A.texture.type,Ue=Se===$n||Se===Yn||Se===wa||Se===_i||Se===tc||Se===nc,Oe=K.getClearColor(),ke=K.getClearAlpha(),Ye=Oe.r,He=Oe.g,$e=Oe.b;Ue?(d[0]=Ye,d[1]=He,d[2]=$e,d[3]=ke,D.clearBufferuiv(D.COLOR,0,d)):(p[0]=Ye,p[1]=He,p[2]=$e,p[3]=ke,D.clearBufferiv(D.COLOR,0,p))}else G|=D.COLOR_BUFFER_BIT}V&&(G|=D.DEPTH_BUFFER_BIT),j&&(G|=D.STENCIL_BUFFER_BIT),D.clear(G)},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",_e,!1),t.removeEventListener("webglcontextrestored",Y,!1),t.removeEventListener("webglcontextcreationerror",ue,!1),ie.dispose(),me.dispose(),$.dispose(),ne.dispose(),de.dispose(),E.dispose(),Me.dispose(),qe.dispose(),W.dispose(),F.dispose(),F.removeEventListener("sessionstart",gt),F.removeEventListener("sessionend",Wn),Ae&&(Ae.dispose(),Ae=null),Yt.stop()};function _e(P){P.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function Y(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1;const P=Ee.autoReset,V=he.enabled,j=he.autoUpdate,G=he.needsUpdate,te=he.type;at(),Ee.autoReset=P,he.enabled=V,he.autoUpdate=j,he.needsUpdate=G,he.type=te}function ue(P){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",P.statusMessage)}function xe(P){const V=P.target;V.removeEventListener("dispose",xe),nt(V)}function nt(P){ut(P),$.remove(P)}function ut(P){const V=$.get(P).programs;V!==void 0&&(V.forEach(function(j){W.releaseProgram(j)}),P.isShaderMaterial&&W.releaseShaderCache(P))}this.renderBufferDirect=function(P,V,j,G,te,Se){V===null&&(V=je);const Ue=te.isMesh&&te.matrixWorld.determinant()<0,Oe=fA(P,V,j,G,te);re.setMaterial(G,Ue);let ke=j.index,Ye=1;G.wireframe===!0&&(ke=T.getWireframeAttribute(j),Ye=2);const He=j.drawRange,$e=j.attributes.position;let _t=He.start*Ye,bt=(He.start+He.count)*Ye;Se!==null&&(_t=Math.max(_t,Se.start*Ye),bt=Math.min(bt,(Se.start+Se.count)*Ye)),ke!==null?(_t=Math.max(_t,0),bt=Math.min(bt,ke.count)):$e!=null&&(_t=Math.max(_t,0),bt=Math.min(bt,$e.count));const Un=bt-_t;if(Un<0||Un===1/0)return;Me.setup(te,G,Oe,j,ke);let di,Et=Ce;if(ke!==null&&(di=pe.get(ke),Et=Ie,Et.setIndex(di)),te.isMesh)G.wireframe===!0?(re.setLineWidth(G.wireframeLinewidth*Le()),Et.setMode(D.LINES)):Et.setMode(D.TRIANGLES);else if(te.isLine){let Qe=G.linewidth;Qe===void 0&&(Qe=1),re.setLineWidth(Qe*Le()),te.isLineSegments?Et.setMode(D.LINES):te.isLineLoop?Et.setMode(D.LINE_LOOP):Et.setMode(D.LINE_STRIP)}else te.isPoints?Et.setMode(D.POINTS):te.isSprite&&Et.setMode(D.TRIANGLES);if(te.isInstancedMesh)Et.renderInstances(_t,Un,te.count);else if(j.isInstancedBufferGeometry){const Qe=j._maxInstanceCount!==void 0?j._maxInstanceCount:1/0,qu=Math.min(j.instanceCount,Qe);Et.renderInstances(_t,Un,qu)}else Et.render(_t,Un)},this.compile=function(P,V){function j(G,te,Se){G.transparent===!0&&G.side===Nn&&G.forceSinglePass===!1?(G.side=kt,G.needsUpdate=!0,Hl(G,te,Se),G.side=Xn,G.needsUpdate=!0,Hl(G,te,Se),G.side=Nn):Hl(G,te,Se)}g=me.get(P),g.init(),y.push(g),P.traverseVisible(function(G){G.isLight&&G.layers.test(V.layers)&&(g.pushLight(G),G.castShadow&&g.pushShadow(G))}),g.setupLights(x.useLegacyLights),P.traverse(function(G){const te=G.material;if(te)if(Array.isArray(te))for(let Se=0;Se<te.length;Se++){const Ue=te[Se];j(Ue,P,G)}else j(te,P,G)}),y.pop(),g=null};let Pt=null;function Vn(P){Pt&&Pt(P)}function gt(){Yt.stop()}function Wn(){Yt.start()}const Yt=new gd;Yt.setAnimationLoop(Vn),typeof self!="undefined"&&Yt.setContext(self),this.setAnimationLoop=function(P){Pt=P,F.setAnimationLoop(P),P===null?Yt.stop():Yt.start()},F.addEventListener("sessionstart",gt),F.addEventListener("sessionend",Wn),this.render=function(P,V){if(V!==void 0&&V.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;P.matrixWorldAutoUpdate===!0&&P.updateMatrixWorld(),V.parent===null&&V.matrixWorldAutoUpdate===!0&&V.updateMatrixWorld(),F.enabled===!0&&F.isPresenting===!0&&(F.cameraAutoUpdate===!0&&F.updateCamera(V),V=F.getCamera()),P.isScene===!0&&P.onBeforeRender(x,P,V,A),g=me.get(P,y.length),g.init(),y.push(g),Pe.multiplyMatrices(V.projectionMatrix,V.matrixWorldInverse),le.setFromProjectionMatrix(Pe),fe=this.localClippingEnabled,ce=we.init(this.clippingPlanes,fe),_=ie.get(P,m.length),_.init(),m.push(_),_0(P,V,0,x.sortObjects),_.finish(),x.sortObjects===!0&&_.sort(H,X),this.info.render.frame++,ce===!0&&we.beginShadows();const j=g.state.shadowsArray;if(he.render(j,P,V),ce===!0&&we.endShadows(),this.info.autoReset===!0&&this.info.reset(),K.render(_,P),g.setupLights(x.useLegacyLights),V.isArrayCamera){const G=V.cameras;for(let te=0,Se=G.length;te<Se;te++){const Ue=G[te];x0(_,P,Ue,Ue.viewport)}}else x0(_,P,V);A!==null&&(J.updateMultisampleRenderTarget(A),J.updateRenderTargetMipmap(A)),P.isScene===!0&&P.onAfterRender(x,P,V),Me.resetDefaultState(),C=-1,S=null,y.pop(),y.length>0?g=y[y.length-1]:g=null,m.pop(),m.length>0?_=m[m.length-1]:_=null};function _0(P,V,j,G){if(P.visible===!1)return;if(P.layers.test(V.layers)){if(P.isGroup)j=P.renderOrder;else if(P.isLOD)P.autoUpdate===!0&&P.update(V);else if(P.isLight)g.pushLight(P),P.castShadow&&g.pushShadow(P);else if(P.isSprite){if(!P.frustumCulled||le.intersectsSprite(P)){G&&Ke.setFromMatrixPosition(P.matrixWorld).applyMatrix4(Pe);const Ue=E.update(P),Oe=P.material;Oe.visible&&_.push(P,Ue,Oe,j,Ke.z,null)}}else if((P.isMesh||P.isLine||P.isPoints)&&(!P.frustumCulled||le.intersectsObject(P))){const Ue=E.update(P),Oe=P.material;if(G&&(P.boundingSphere!==void 0?(P.boundingSphere===null&&P.computeBoundingSphere(),Ke.copy(P.boundingSphere.center)):(Ue.boundingSphere===null&&Ue.computeBoundingSphere(),Ke.copy(Ue.boundingSphere.center)),Ke.applyMatrix4(P.matrixWorld).applyMatrix4(Pe)),Array.isArray(Oe)){const ke=Ue.groups;for(let Ye=0,He=ke.length;Ye<He;Ye++){const $e=ke[Ye],_t=Oe[$e.materialIndex];_t&&_t.visible&&_.push(P,Ue,_t,j,Ke.z,$e)}}else Oe.visible&&_.push(P,Ue,Oe,j,Ke.z,null)}}const Se=P.children;for(let Ue=0,Oe=Se.length;Ue<Oe;Ue++)_0(Se[Ue],V,j,G)}function x0(P,V,j,G){const te=P.opaque,Se=P.transmissive,Ue=P.transparent;g.setupLightsView(j),ce===!0&&we.setGlobalState(x.clippingPlanes,j),Se.length>0&&uA(te,Se,V,j),G&&re.viewport(b.copy(G)),te.length>0&&Gl(te,V,j),Se.length>0&&Gl(Se,V,j),Ue.length>0&&Gl(Ue,V,j),re.buffers.depth.setTest(!0),re.buffers.depth.setMask(!0),re.buffers.color.setMask(!0),re.setPolygonOffset(!1)}function uA(P,V,j,G){const te=oe.isWebGL2;Ae===null&&(Ae=new bn(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?gr:$n,minFilter:gi,samples:te?4:0})),x.getDrawingBufferSize(Te),te?Ae.setSize(Te.x,Te.y):Ae.setSize(Da(Te.x),Da(Te.y));const Se=x.getRenderTarget();x.setRenderTarget(Ae),x.getClearColor(U),N=x.getClearAlpha(),N<1&&x.setClearColor(16777215,.5),x.clear();const Ue=x.toneMapping;x.toneMapping=Fn,Gl(P,j,G),J.updateMultisampleRenderTarget(Ae),J.updateRenderTargetMipmap(Ae);let Oe=!1;for(let ke=0,Ye=V.length;ke<Ye;ke++){const He=V[ke],$e=He.object,_t=He.geometry,bt=He.material,Un=He.group;if(bt.side===Nn&&$e.layers.test(G.layers)){const di=bt.side;bt.side=kt,bt.needsUpdate=!0,y0($e,j,G,_t,bt,Un),bt.side=di,bt.needsUpdate=!0,Oe=!0}}Oe===!0&&(J.updateMultisampleRenderTarget(Ae),J.updateRenderTargetMipmap(Ae)),x.setRenderTarget(Se),x.setClearColor(U,N),x.toneMapping=Ue}function Gl(P,V,j){const G=V.isScene===!0?V.overrideMaterial:null;for(let te=0,Se=P.length;te<Se;te++){const Ue=P[te],Oe=Ue.object,ke=Ue.geometry,Ye=G===null?Ue.material:G,He=Ue.group;Oe.layers.test(j.layers)&&y0(Oe,V,j,ke,Ye,He)}}function y0(P,V,j,G,te,Se){P.onBeforeRender(x,V,j,G,te,Se),P.modelViewMatrix.multiplyMatrices(j.matrixWorldInverse,P.matrixWorld),P.normalMatrix.getNormalMatrix(P.modelViewMatrix),te.onBeforeRender(x,V,j,G,P,Se),te.transparent===!0&&te.side===Nn&&te.forceSinglePass===!1?(te.side=kt,te.needsUpdate=!0,x.renderBufferDirect(j,V,G,te,P,Se),te.side=Xn,te.needsUpdate=!0,x.renderBufferDirect(j,V,G,te,P,Se),te.side=Nn):x.renderBufferDirect(j,V,G,te,P,Se),P.onAfterRender(x,V,j,G,te,Se)}function Hl(P,V,j){V.isScene!==!0&&(V=je);const G=$.get(P),te=g.state.lights,Se=g.state.shadowsArray,Ue=te.state.version,Oe=W.getParameters(P,te.state,Se,V,j),ke=W.getProgramCacheKey(Oe);let Ye=G.programs;G.environment=P.isMeshStandardMaterial?V.environment:null,G.fog=V.fog,G.envMap=(P.isMeshStandardMaterial?de:ne).get(P.envMap||G.environment),Ye===void 0&&(P.addEventListener("dispose",xe),Ye=new Map,G.programs=Ye);let He=Ye.get(ke);if(He!==void 0){if(G.currentProgram===He&&G.lightsStateVersion===Ue)return v0(P,Oe),He}else Oe.uniforms=W.getUniforms(P),P.onBuild(j,Oe,x),P.onBeforeCompile(Oe,x),He=W.acquireProgram(Oe,ke),Ye.set(ke,He),G.uniforms=Oe.uniforms;const $e=G.uniforms;(!P.isShaderMaterial&&!P.isRawShaderMaterial||P.clipping===!0)&&($e.clippingPlanes=we.uniform),v0(P,Oe),G.needsLights=pA(P),G.lightsStateVersion=Ue,G.needsLights&&($e.ambientLightColor.value=te.state.ambient,$e.lightProbe.value=te.state.probe,$e.directionalLights.value=te.state.directional,$e.directionalLightShadows.value=te.state.directionalShadow,$e.spotLights.value=te.state.spot,$e.spotLightShadows.value=te.state.spotShadow,$e.rectAreaLights.value=te.state.rectArea,$e.ltc_1.value=te.state.rectAreaLTC1,$e.ltc_2.value=te.state.rectAreaLTC2,$e.pointLights.value=te.state.point,$e.pointLightShadows.value=te.state.pointShadow,$e.hemisphereLights.value=te.state.hemi,$e.directionalShadowMap.value=te.state.directionalShadowMap,$e.directionalShadowMatrix.value=te.state.directionalShadowMatrix,$e.spotShadowMap.value=te.state.spotShadowMap,$e.spotLightMatrix.value=te.state.spotLightMatrix,$e.spotLightMap.value=te.state.spotLightMap,$e.pointShadowMap.value=te.state.pointShadowMap,$e.pointShadowMatrix.value=te.state.pointShadowMatrix);const _t=He.getUniforms(),bt=oo.seqWithValue(_t.seq,$e);return G.currentProgram=He,G.uniformsList=bt,He}function v0(P,V){const j=$.get(P);j.outputColorSpace=V.outputColorSpace,j.instancing=V.instancing,j.skinning=V.skinning,j.morphTargets=V.morphTargets,j.morphNormals=V.morphNormals,j.morphColors=V.morphColors,j.morphTargetsCount=V.morphTargetsCount,j.numClippingPlanes=V.numClippingPlanes,j.numIntersection=V.numClipIntersection,j.vertexAlphas=V.vertexAlphas,j.vertexTangents=V.vertexTangents,j.toneMapping=V.toneMapping}function fA(P,V,j,G,te){V.isScene!==!0&&(V=je),J.resetTextureUnits();const Se=V.fog,Ue=G.isMeshStandardMaterial?V.environment:null,Oe=A===null?x.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:Sn,ke=(G.isMeshStandardMaterial?de:ne).get(G.envMap||Ue),Ye=G.vertexColors===!0&&!!j.attributes.color&&j.attributes.color.itemSize===4,He=!!j.attributes.tangent&&(!!G.normalMap||G.anisotropy>0),$e=!!j.morphAttributes.position,_t=!!j.morphAttributes.normal,bt=!!j.morphAttributes.color,Un=G.toneMapped?x.toneMapping:Fn,di=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,Et=di!==void 0?di.length:0,Qe=$.get(G),qu=g.state.lights;if(ce===!0&&(fe===!0||P!==S)){const mn=P===S&&G.id===C;we.setState(G,P,mn)}let Lt=!1;G.version===Qe.__version?(Qe.needsLights&&Qe.lightsStateVersion!==qu.state.version||Qe.outputColorSpace!==Oe||te.isInstancedMesh&&Qe.instancing===!1||!te.isInstancedMesh&&Qe.instancing===!0||te.isSkinnedMesh&&Qe.skinning===!1||!te.isSkinnedMesh&&Qe.skinning===!0||Qe.envMap!==ke||G.fog===!0&&Qe.fog!==Se||Qe.numClippingPlanes!==void 0&&(Qe.numClippingPlanes!==we.numPlanes||Qe.numIntersection!==we.numIntersection)||Qe.vertexAlphas!==Ye||Qe.vertexTangents!==He||Qe.morphTargets!==$e||Qe.morphNormals!==_t||Qe.morphColors!==bt||Qe.toneMapping!==Un||oe.isWebGL2===!0&&Qe.morphTargetsCount!==Et)&&(Lt=!0):(Lt=!0,Qe.__version=G.version);let ur=Qe.currentProgram;Lt===!0&&(ur=Hl(G,V,te));let M0=!1,ya=!1,$u=!1;const Zt=ur.getUniforms(),fr=Qe.uniforms;if(re.useProgram(ur.program)&&(M0=!0,ya=!0,$u=!0),G.id!==C&&(C=G.id,ya=!0),M0||S!==P){if(Zt.setValue(D,"projectionMatrix",P.projectionMatrix),oe.logarithmicDepthBuffer&&Zt.setValue(D,"logDepthBufFC",2/(Math.log(P.far+1)/Math.LN2)),S!==P&&(S=P,ya=!0,$u=!0),G.isShaderMaterial||G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshStandardMaterial||G.envMap){const mn=Zt.map.cameraPosition;mn!==void 0&&mn.setValue(D,Ke.setFromMatrixPosition(P.matrixWorld))}(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&Zt.setValue(D,"isOrthographic",P.isOrthographicCamera===!0),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial||G.isShadowMaterial||te.isSkinnedMesh)&&Zt.setValue(D,"viewMatrix",P.matrixWorldInverse)}if(te.isSkinnedMesh){Zt.setOptional(D,te,"bindMatrix"),Zt.setOptional(D,te,"bindMatrixInverse");const mn=te.skeleton;mn&&(oe.floatVertexTextures?(mn.boneTexture===null&&mn.computeBoneTexture(),Zt.setValue(D,"boneTexture",mn.boneTexture,J),Zt.setValue(D,"boneTextureSize",mn.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const Yu=j.morphAttributes;if((Yu.position!==void 0||Yu.normal!==void 0||Yu.color!==void 0&&oe.isWebGL2===!0)&&Re.update(te,j,ur),(ya||Qe.receiveShadow!==te.receiveShadow)&&(Qe.receiveShadow=te.receiveShadow,Zt.setValue(D,"receiveShadow",te.receiveShadow)),G.isMeshGouraudMaterial&&G.envMap!==null&&(fr.envMap.value=ke,fr.flipEnvMap.value=ke.isCubeTexture&&ke.isRenderTargetTexture===!1?-1:1),ya&&(Zt.setValue(D,"toneMappingExposure",x.toneMappingExposure),Qe.needsLights&&dA(fr,$u),Se&&G.fog===!0&&se.refreshFogUniforms(fr,Se),se.refreshMaterialUniforms(fr,G,O,B,Ae),oo.upload(D,Qe.uniformsList,fr,J)),G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(oo.upload(D,Qe.uniformsList,fr,J),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&Zt.setValue(D,"center",te.center),Zt.setValue(D,"modelViewMatrix",te.modelViewMatrix),Zt.setValue(D,"normalMatrix",te.normalMatrix),Zt.setValue(D,"modelMatrix",te.matrixWorld),G.isShaderMaterial||G.isRawShaderMaterial){const mn=G.uniformsGroups;for(let Zu=0,mA=mn.length;Zu<mA;Zu++)if(oe.isWebGL2){const S0=mn[Zu];qe.update(S0,ur),qe.bind(S0,ur)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return ur}function dA(P,V){P.ambientLightColor.needsUpdate=V,P.lightProbe.needsUpdate=V,P.directionalLights.needsUpdate=V,P.directionalLightShadows.needsUpdate=V,P.pointLights.needsUpdate=V,P.pointLightShadows.needsUpdate=V,P.spotLights.needsUpdate=V,P.spotLightShadows.needsUpdate=V,P.rectAreaLights.needsUpdate=V,P.hemisphereLights.needsUpdate=V}function pA(P){return P.isMeshLambertMaterial||P.isMeshToonMaterial||P.isMeshPhongMaterial||P.isMeshStandardMaterial||P.isShadowMaterial||P.isShaderMaterial&&P.lights===!0}this.getActiveCubeFace=function(){return M},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(P,V,j){$.get(P.texture).__webglTexture=V,$.get(P.depthTexture).__webglTexture=j;const G=$.get(P);G.__hasExternalTextures=!0,G.__hasExternalTextures&&(G.__autoAllocateDepthBuffer=j===void 0,G.__autoAllocateDepthBuffer||Q.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),G.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(P,V){const j=$.get(P);j.__webglFramebuffer=V,j.__useDefaultFramebuffer=V===void 0},this.setRenderTarget=function(P,V=0,j=0){A=P,M=V,w=j;let G=!0,te=null,Se=!1,Ue=!1;if(P){const ke=$.get(P);ke.__useDefaultFramebuffer!==void 0?(re.bindFramebuffer(D.FRAMEBUFFER,null),G=!1):ke.__webglFramebuffer===void 0?J.setupRenderTarget(P):ke.__hasExternalTextures&&J.rebindTextures(P,$.get(P.texture).__webglTexture,$.get(P.depthTexture).__webglTexture);const Ye=P.texture;(Ye.isData3DTexture||Ye.isDataArrayTexture||Ye.isCompressedArrayTexture)&&(Ue=!0);const He=$.get(P).__webglFramebuffer;P.isWebGLCubeRenderTarget?(te=He[V],Se=!0):oe.isWebGL2&&P.samples>0&&J.useMultisampledRTT(P)===!1?te=$.get(P).__webglMultisampledFramebuffer:te=He,b.copy(P.viewport),L.copy(P.scissor),k=P.scissorTest}else b.copy(ee).multiplyScalar(O).floor(),L.copy(z).multiplyScalar(O).floor(),k=Z;if(re.bindFramebuffer(D.FRAMEBUFFER,te)&&oe.drawBuffers&&G&&re.drawBuffers(P,te),re.viewport(b),re.scissor(L),re.setScissorTest(k),Se){const ke=$.get(P.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+V,ke.__webglTexture,j)}else if(Ue){const ke=$.get(P.texture),Ye=V||0;D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,ke.__webglTexture,j||0,Ye)}C=-1},this.readRenderTargetPixels=function(P,V,j,G,te,Se,Ue){if(!(P&&P.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Oe=$.get(P).__webglFramebuffer;if(P.isWebGLCubeRenderTarget&&Ue!==void 0&&(Oe=Oe[Ue]),Oe){re.bindFramebuffer(D.FRAMEBUFFER,Oe);try{const ke=P.texture,Ye=ke.format,He=ke.type;if(Ye!==an&&be.convert(Ye)!==D.getParameter(D.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const $e=He===gr&&(Q.has("EXT_color_buffer_half_float")||oe.isWebGL2&&Q.has("EXT_color_buffer_float"));if(He!==$n&&be.convert(He)!==D.getParameter(D.IMPLEMENTATION_COLOR_READ_TYPE)&&!(He===On&&(oe.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!$e){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}V>=0&&V<=P.width-G&&j>=0&&j<=P.height-te&&D.readPixels(V,j,G,te,be.convert(Ye),be.convert(He),Se)}finally{const ke=A!==null?$.get(A).__webglFramebuffer:null;re.bindFramebuffer(D.FRAMEBUFFER,ke)}}},this.copyFramebufferToTexture=function(P,V,j=0){const G=Math.pow(2,-j),te=Math.floor(V.image.width*G),Se=Math.floor(V.image.height*G);J.setTexture2D(V,0),D.copyTexSubImage2D(D.TEXTURE_2D,j,0,0,P.x,P.y,te,Se),re.unbindTexture()},this.copyTextureToTexture=function(P,V,j,G=0){const te=V.image.width,Se=V.image.height,Ue=be.convert(j.format),Oe=be.convert(j.type);J.setTexture2D(j,0),D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,j.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,j.unpackAlignment),V.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,G,P.x,P.y,te,Se,Ue,Oe,V.image.data):V.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,G,P.x,P.y,V.mipmaps[0].width,V.mipmaps[0].height,Ue,V.mipmaps[0].data):D.texSubImage2D(D.TEXTURE_2D,G,P.x,P.y,Ue,Oe,V.image),G===0&&j.generateMipmaps&&D.generateMipmap(D.TEXTURE_2D),re.unbindTexture()},this.copyTextureToTexture3D=function(P,V,j,G,te=0){if(x.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Se=P.max.x-P.min.x+1,Ue=P.max.y-P.min.y+1,Oe=P.max.z-P.min.z+1,ke=be.convert(G.format),Ye=be.convert(G.type);let He;if(G.isData3DTexture)J.setTexture3D(G,0),He=D.TEXTURE_3D;else if(G.isDataArrayTexture)J.setTexture2DArray(G,0),He=D.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,G.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,G.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,G.unpackAlignment);const $e=D.getParameter(D.UNPACK_ROW_LENGTH),_t=D.getParameter(D.UNPACK_IMAGE_HEIGHT),bt=D.getParameter(D.UNPACK_SKIP_PIXELS),Un=D.getParameter(D.UNPACK_SKIP_ROWS),di=D.getParameter(D.UNPACK_SKIP_IMAGES),Et=j.isCompressedTexture?j.mipmaps[0]:j.image;D.pixelStorei(D.UNPACK_ROW_LENGTH,Et.width),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Et.height),D.pixelStorei(D.UNPACK_SKIP_PIXELS,P.min.x),D.pixelStorei(D.UNPACK_SKIP_ROWS,P.min.y),D.pixelStorei(D.UNPACK_SKIP_IMAGES,P.min.z),j.isDataTexture||j.isData3DTexture?D.texSubImage3D(He,te,V.x,V.y,V.z,Se,Ue,Oe,ke,Ye,Et.data):j.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),D.compressedTexSubImage3D(He,te,V.x,V.y,V.z,Se,Ue,Oe,ke,Et.data)):D.texSubImage3D(He,te,V.x,V.y,V.z,Se,Ue,Oe,ke,Ye,Et),D.pixelStorei(D.UNPACK_ROW_LENGTH,$e),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,_t),D.pixelStorei(D.UNPACK_SKIP_PIXELS,bt),D.pixelStorei(D.UNPACK_SKIP_ROWS,Un),D.pixelStorei(D.UNPACK_SKIP_IMAGES,di),te===0&&G.generateMipmaps&&D.generateMipmap(He),re.unbindTexture()},this.initTexture=function(P){P.isCubeTexture?J.setTextureCube(P,0):P.isData3DTexture?J.setTexture3D(P,0):P.isDataArrayTexture||P.isCompressedArrayTexture?J.setTexture2DArray(P,0):J.setTexture2D(P,0),re.unbindTexture()},this.resetState=function(){M=0,w=0,A=null,re.reset(),Me.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Bn}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Ge?yi:Pc}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===yi?Ge:Sn}}class qd extends Xd{}qd.prototype.isWebGL1Renderer=!0;class lo{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ye(e),this.density=t}clone(){return new lo(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class co{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ye(e),this.near=t,this.far=n}clone(){return new co(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class $d extends tt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__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,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}}class ho{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=bs,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=on()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}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,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=on()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=on()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Ht=new R;class $i{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Ht.fromBufferAttribute(this,t),Ht.applyMatrix4(e),this.setXYZ(t,Ht.x,Ht.y,Ht.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ht.fromBufferAttribute(this,t),Ht.applyNormalMatrix(e),this.setXYZ(t,Ht.x,Ht.y,Ht.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ht.fromBufferAttribute(this,t),Ht.transformDirection(e),this.setXYZ(t,Ht.x,Ht.y,Ht.z);return this}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=ln(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ln(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ln(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ln(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),n=We(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array),s=We(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new Ze(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new $i(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class uh extends Ft{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ye(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Gr;const Os=new R,Hr=new R,Vr=new R,Wr=new q,Bs=new q,Yd=new Be,uo=new R,zs=new R,fo=new R,Zd=new q,fh=new q,Jd=new q;class Kd extends tt{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",Gr===void 0){Gr=new Fe;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new ho(t,5);Gr.setIndex([0,1,2,0,2,3]),Gr.setAttribute("position",new $i(n,3,0,!1)),Gr.setAttribute("uv",new $i(n,2,3,!1))}this.geometry=Gr,this.material=e!==void 0?e:new uh,this.center=new q(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Hr.setFromMatrixScale(this.matrixWorld),Yd.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Vr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Hr.multiplyScalar(-Vr.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const a=this.center;po(uo.set(-.5,-.5,0),Vr,a,Hr,i,s),po(zs.set(.5,-.5,0),Vr,a,Hr,i,s),po(fo.set(.5,.5,0),Vr,a,Hr,i,s),Zd.set(0,0),fh.set(1,0),Jd.set(1,1);let o=e.ray.intersectTriangle(uo,zs,fo,!1,Os);if(o===null&&(po(zs.set(-.5,.5,0),Vr,a,Hr,i,s),fh.set(0,1),o=e.ray.intersectTriangle(uo,fo,zs,!1,Os),o===null))return;const l=e.ray.origin.distanceTo(Os);l<e.near||l>e.far||t.push({distance:l,point:Os.clone(),uv:jt.getInterpolation(Os,uo,zs,fo,Zd,fh,Jd,new q),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function po(r,e,t,n,i,s){Wr.subVectors(r,t).addScalar(.5).multiply(n),i!==void 0?(Bs.x=s*Wr.x-i*Wr.y,Bs.y=i*Wr.x+s*Wr.y):Bs.copy(Wr),r.copy(e),r.x+=Bs.x,r.y+=Bs.y,r.applyMatrix4(Yd)}const mo=new R,jd=new R;class Qd extends tt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n<i;n++){const s=t[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let s;for(s=0;s<i.length&&!(t<i[s].distance);s++);return i.splice(s,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let s=t[n].distance;if(t[n].object.visible&&(s-=s*t[n].hysteresis),e<s)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){mo.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(mo);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){mo.setFromMatrixPosition(e.matrixWorld),jd.setFromMatrixPosition(this.matrixWorld);const n=mo.distanceTo(jd)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i<s;i++){let a=t[i].distance;if(t[i].object.visible&&(a-=a*t[i].hysteresis),n>=a)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<s;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let i=0,s=n.length;i<s;i++){const a=n[i];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const ep=new R,tp=new rt,np=new rt,ZM=new R,ip=new Be,Xr=new R,dh=new wn,rp=new Be,ph=new Er;class sp extends It{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Be,this.bindMatrixInverse=new Be,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new _n),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)Xr.fromBufferAttribute(t,n),this.applyBoneTransform(n,Xr),this.boundingBox.expandByPoint(Xr)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new wn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)Xr.fromBufferAttribute(t,n),this.applyBoneTransform(n,Xr),this.boundingSphere.expandByPoint(Xr)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),dh.copy(this.boundingSphere),dh.applyMatrix4(i),e.ray.intersectsSphere(dh)!==!1&&(rp.copy(i).invert(),ph.copy(e.ray).applyMatrix4(rp),!(this.boundingBox!==null&&ph.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ph)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new rt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;tp.fromBufferAttribute(i.attributes.skinIndex,e),np.fromBufferAttribute(i.attributes.skinWeight,e),ep.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=np.getComponent(s);if(a!==0){const o=tp.getComponent(s);ip.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(ZM.copy(ep).applyMatrix4(ip),a)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}}class mh extends tt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class qr extends Mt{constructor(e=null,t=1,n=1,i,s,a,o,l,c=yt,h=yt,u,f){super(null,a,o,l,c,h,i,s,u,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const ap=new Be,JM=new Be;class go{constructor(e=[],t=[]){this.uuid=on(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Be)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Be;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:JM;ap.multiplyMatrices(o,t[s]),ap.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new go(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Yf(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new qr(t,e,e,an,On);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const s=e.bones[n];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new mh),this.bones.push(a),this.boneInverses.push(new Be().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class $r extends Ze{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Yr=new Be,op=new Be,_o=[],lp=new _n,KM=new Be,ks=new It,Gs=new wn;class cp extends It{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new $r(new Float32Array(n*16),16),this.instanceColor=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,KM)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new _n),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Yr),lp.copy(e.boundingBox).applyMatrix4(Yr),this.boundingBox.union(lp)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new wn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Yr),Gs.copy(e.boundingSphere).applyMatrix4(Yr),this.boundingSphere.union(Gs)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){const n=this.matrixWorld,i=this.count;if(ks.geometry=this.geometry,ks.material=this.material,ks.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Gs.copy(this.boundingSphere),Gs.applyMatrix4(n),e.ray.intersectsSphere(Gs)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,Yr),op.multiplyMatrices(n,Yr),ks.matrixWorld=op,ks.raycast(e,_o);for(let a=0,o=_o.length;a<o;a++){const l=_o[a];l.instanceId=s,l.object=this,t.push(l)}_o.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new $r(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class Vt extends Ft{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ye(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 hp=new R,up=new R,fp=new Be,gh=new Er,xo=new wn;class Ri extends tt{constructor(e=new Fe,t=new Vt){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)hp.fromBufferAttribute(t,i-1),up.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=hp.distanceTo(up);e.setAttribute("lineDistance",new ve(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),xo.copy(n.boundingSphere),xo.applyMatrix4(i),xo.radius+=s,e.ray.intersectsSphere(xo)===!1)return;fp.copy(i).invert(),gh.copy(e.ray).applyMatrix4(fp);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=new R,h=new R,u=new R,f=new R,d=this.isLineSegments?2:1,p=n.index,g=n.attributes.position;if(p!==null){const m=Math.max(0,a.start),y=Math.min(p.count,a.start+a.count);for(let x=m,v=y-1;x<v;x+=d){const M=p.getX(x),w=p.getX(x+1);if(c.fromBufferAttribute(g,M),h.fromBufferAttribute(g,w),gh.distanceSqToSegment(c,h,f,u)>l)continue;f.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(f);C<e.near||C>e.far||t.push({distance:C,point:u.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{const m=Math.max(0,a.start),y=Math.min(g.count,a.start+a.count);for(let x=m,v=y-1;x<v;x+=d){if(c.fromBufferAttribute(g,x),h.fromBufferAttribute(g,x+1),gh.distanceSqToSegment(c,h,f,u)>l)continue;f.applyMatrix4(this.matrixWorld);const w=e.ray.origin.distanceTo(f);w<e.near||w>e.far||t.push({distance:w,point:u.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}const dp=new R,pp=new R;class kn extends Ri{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,n=[];for(let i=0,s=t.count;i<s;i+=2)dp.fromBufferAttribute(t,i),pp.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+dp.distanceTo(pp);e.setAttribute("lineDistance",new ve(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class mp extends Ri{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class _h extends Ft{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ye(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const gp=new Be,xh=new Er,yo=new wn,vo=new R;class _p extends tt{constructor(e=new Fe,t=new _h){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),yo.copy(n.boundingSphere),yo.applyMatrix4(i),yo.radius+=s,e.ray.intersectsSphere(yo)===!1)return;gp.copy(i).invert(),xh.copy(e.ray).applyMatrix4(gp);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,u=n.attributes.position;if(c!==null){const f=Math.max(0,a.start),d=Math.min(c.count,a.start+a.count);for(let p=f,_=d;p<_;p++){const g=c.getX(p);vo.fromBufferAttribute(u,g),xp(vo,g,l,i,e,t,this)}}else{const f=Math.max(0,a.start),d=Math.min(u.count,a.start+a.count);for(let p=f,_=d;p<_;p++)vo.fromBufferAttribute(u,p),xp(vo,p,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function xp(r,e,t,n,i,s,a){const o=xh.distanceSqToPoint(r);if(o<t){const l=new R;xh.closestPointToPoint(r,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,object:a})}}class jM extends Mt{constructor(e,t,n,i,s,a,o,l,c){super(e,t,n,i,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:vt,this.magFilter=s!==void 0?s:vt,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class QM extends Mt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=yt,this.minFilter=yt,this.generateMipmaps=!1,this.needsUpdate=!0}}class yh extends Mt{constructor(e,t,n,i,s,a,o,l,c,h,u,f){super(null,a,o,l,c,h,i,s,u,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class eS extends yh{constructor(e,t,n,i,s,a){super(e,t,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Dt}}class tS extends Mt{constructor(e,t,n,i,s,a,o,l,c){super(e,t,n,i,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Cn{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),c=n[i]-a,c<0)o=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(s-1);const h=n[i],f=n[i+1]-h,d=(a-h)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const a=this.getPoint(i),o=this.getPoint(s),l=t||(a.isVector2?new q:new R);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new R,i=[],s=[],a=[],o=new R,l=new Be;for(let d=0;d<=e;d++){const p=d/e;i[d]=this.getTangentAt(p,new R)}s[0]=new R,a[0]=new R;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),u=Math.abs(i[0].y),f=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),f<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),a[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),a[d]=a[d-1].clone(),o.crossVectors(i[d-1],i[d]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(ft(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(l.makeRotationAxis(o,p))}a[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(ft(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(o.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(l.makeRotationAxis(i[p],d*p)),a[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Mo extends Cn{constructor(e=0,t=0,n=1,i=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t){const n=t||new q,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(a?s=0:s=i),this.aClockwise===!0&&!a&&(s===i?s=-i:s=s-i);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),f=l-this.aX,d=c-this.aY;l=f*h-d*u+this.aX,c=f*u+d*h+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class yp extends Mo{constructor(e,t,n,i,s,a){super(e,t,n,n,i,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function vh(){let r=0,e=0,t=0,n=0;function i(s,a,o,l){r=s,e=o,t=-3*s+3*a-2*o-l,n=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){i(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,h,u){let f=(a-s)/c-(o-s)/(c+h)+(o-a)/h,d=(o-a)/h-(l-a)/(h+u)+(l-o)/u;f*=h,d*=h,i(a,o,f,d)},calc:function(s){const a=s*s,o=a*s;return r+e*s+t*a+n*o}}}const So=new R,Mh=new vh,Sh=new vh,bh=new vh;class vp extends Cn{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new R){const n=t,i=this.points,s=i.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,h;this.closed||o>0?c=i[(o-1)%s]:(So.subVectors(i[0],i[1]).add(i[0]),c=So);const u=i[o%s],f=i[(o+1)%s];if(this.closed||o+2<s?h=i[(o+2)%s]:(So.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=So),this.curveType==="centripetal"||this.curveType==="chordal"){const d=this.curveType==="chordal"?.5:.25;let p=Math.pow(c.distanceToSquared(u),d),_=Math.pow(u.distanceToSquared(f),d),g=Math.pow(f.distanceToSquared(h),d);_<1e-4&&(_=1),p<1e-4&&(p=_),g<1e-4&&(g=_),Mh.initNonuniformCatmullRom(c.x,u.x,f.x,h.x,p,_,g),Sh.initNonuniformCatmullRom(c.y,u.y,f.y,h.y,p,_,g),bh.initNonuniformCatmullRom(c.z,u.z,f.z,h.z,p,_,g)}else this.curveType==="catmullrom"&&(Mh.initCatmullRom(c.x,u.x,f.x,h.x,this.tension),Sh.initCatmullRom(c.y,u.y,f.y,h.y,this.tension),bh.initCatmullRom(c.z,u.z,f.z,h.z,this.tension));return n.set(Mh.calc(l),Sh.calc(l),bh.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new R().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Mp(r,e,t,n,i){const s=(n-e)*.5,a=(i-t)*.5,o=r*r,l=r*o;return(2*t-2*n+s+a)*l+(-3*t+3*n-2*s-a)*o+s*r+t}function nS(r,e){const t=1-r;return t*t*e}function iS(r,e){return 2*(1-r)*r*e}function rS(r,e){return r*r*e}function Hs(r,e,t,n){return nS(r,e)+iS(r,t)+rS(r,n)}function sS(r,e){const t=1-r;return t*t*t*e}function aS(r,e){const t=1-r;return 3*t*t*r*e}function oS(r,e){return 3*(1-r)*r*r*e}function lS(r,e){return r*r*r*e}function Vs(r,e,t,n,i){return sS(r,e)+aS(r,t)+oS(r,n)+lS(r,i)}class wh extends Cn{constructor(e=new q,t=new q,n=new q,i=new q){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new q){const n=t,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(Vs(e,i.x,s.x,a.x,o.x),Vs(e,i.y,s.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Sp extends Cn{constructor(e=new R,t=new R,n=new R,i=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new R){const n=t,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(Vs(e,i.x,s.x,a.x,o.x),Vs(e,i.y,s.y,a.y,o.y),Vs(e,i.z,s.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class bo extends Cn{constructor(e=new q,t=new q){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new q){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new q){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class bp extends Cn{constructor(e=new R,t=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new R){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new R){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Eh extends Cn{constructor(e=new q,t=new q,n=new q){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new q){const n=t,i=this.v0,s=this.v1,a=this.v2;return n.set(Hs(e,i.x,s.x,a.x),Hs(e,i.y,s.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Ah extends Cn{constructor(e=new R,t=new R,n=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new R){const n=t,i=this.v0,s=this.v1,a=this.v2;return n.set(Hs(e,i.x,s.x,a.x),Hs(e,i.y,s.y,a.y),Hs(e,i.z,s.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Th extends Cn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new q){const n=t,i=this.points,s=(i.length-1)*e,a=Math.floor(s),o=s-a,l=i[a===0?a:a-1],c=i[a],h=i[a>i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(Mp(o,l.x,c.x,h.x,u.x),Mp(o,l.y,c.y,h.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new q().fromArray(i))}return this}}var Rh=Object.freeze({__proto__:null,ArcCurve:yp,CatmullRomCurve3:vp,CubicBezierCurve:wh,CubicBezierCurve3:Sp,EllipseCurve:Mo,LineCurve:bo,LineCurve3:bp,QuadraticBezierCurve:Eh,QuadraticBezierCurve3:Ah,SplineCurve:Th});class wp extends Cn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new bo(t,e))}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const a=i[s]-n,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const a=s[i],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const h=l[c];n&&n.equals(h)||(t.push(h),n=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new Rh[i.type]().fromJSON(i))}return this}}let Ws=class extends wp{constructor(e){super(),this.type="Path",this.currentPoint=new q,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new bo(this.currentPoint.clone(),new q(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const s=new Eh(this.currentPoint.clone(),new q(e,t),new q(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,a){const o=new wh(this.currentPoint.clone(),new q(e,t),new q(n,i),new q(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Th(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,n,i,s,a),this}absarc(e,t,n,i,s,a){return this.absellipse(e,t,n,n,i,s,a),this}ellipse(e,t,n,i,s,a,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,n,i,s,a,o,l),this}absellipse(e,t,n,i,s,a,o,l){const c=new Mo(e,t,n,i,s,a,o,l);if(this.curves.length>0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class Xs extends Fe{constructor(e=[new q(0,-.5),new q(.5,0),new q(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=ft(i,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],h=1/t,u=new R,f=new q,d=new R,p=new R,_=new R;let g=0,m=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,d.x=m*1,d.y=-g,d.z=m*0,_.copy(d),d.normalize(),l.push(d.x,d.y,d.z);break;case e.length-1:l.push(_.x,_.y,_.z);break;default:g=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,d.x=m*1,d.y=-g,d.z=m*0,p.copy(d),d.x+=_.x,d.y+=_.y,d.z+=_.z,d.normalize(),l.push(d.x,d.y,d.z),_.copy(p)}for(let y=0;y<=t;y++){const x=n+y*h*i,v=Math.sin(x),M=Math.cos(x);for(let w=0;w<=e.length-1;w++){u.x=e[w].x*v,u.y=e[w].y,u.z=e[w].x*M,a.push(u.x,u.y,u.z),f.x=y/t,f.y=w/(e.length-1),o.push(f.x,f.y);const A=l[3*w+0]*v,C=l[3*w+1],S=l[3*w+0]*M;c.push(A,C,S)}}for(let y=0;y<t;y++)for(let x=0;x<e.length-1;x++){const v=x+y*e.length,M=v,w=v+e.length,A=v+e.length+1,C=v+1;s.push(M,w,C),s.push(A,C,w)}this.setIndex(s),this.setAttribute("position",new ve(a,3)),this.setAttribute("uv",new ve(o,2)),this.setAttribute("normal",new ve(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xs(e.points,e.segments,e.phiStart,e.phiLength)}}class wo extends Xs{constructor(e=1,t=1,n=4,i=8){const s=new Ws;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new wo(e.radius,e.length,e.capSegments,e.radialSegments)}}class Eo extends Fe{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new R,h=new q;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,f=3;u<=t;u++,f+=3){const d=n+u/t*i;c.x=e*Math.cos(d),c.y=e*Math.sin(d),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[f]/e+1)/2,h.y=(a[f+1]/e+1)/2,l.push(h.x,h.y)}for(let u=1;u<=t;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new ve(a,3)),this.setAttribute("normal",new ve(o,3)),this.setAttribute("uv",new ve(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Eo(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Zr extends Fe{constructor(e=1,t=1,n=1,i=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),s=Math.floor(s);const h=[],u=[],f=[],d=[];let p=0;const _=[],g=n/2;let m=0;y(),a===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new ve(u,3)),this.setAttribute("normal",new ve(f,3)),this.setAttribute("uv",new ve(d,2));function y(){const v=new R,M=new R;let w=0;const A=(t-e)/n;for(let C=0;C<=s;C++){const S=[],b=C/s,L=b*(t-e)+e;for(let k=0;k<=i;k++){const U=k/i,N=U*l+o,I=Math.sin(N),B=Math.cos(N);M.x=L*I,M.y=-b*n+g,M.z=L*B,u.push(M.x,M.y,M.z),v.set(I,A,B).normalize(),f.push(v.x,v.y,v.z),d.push(U,1-b),S.push(p++)}_.push(S)}for(let C=0;C<i;C++)for(let S=0;S<s;S++){const b=_[S][C],L=_[S+1][C],k=_[S+1][C+1],U=_[S][C+1];h.push(b,L,U),h.push(L,k,U),w+=6}c.addGroup(m,w,0),m+=w}function x(v){const M=p,w=new q,A=new R;let C=0;const S=v===!0?e:t,b=v===!0?1:-1;for(let k=1;k<=i;k++)u.push(0,g*b,0),f.push(0,b,0),d.push(.5,.5),p++;const L=p;for(let k=0;k<=i;k++){const N=k/i*l+o,I=Math.cos(N),B=Math.sin(N);A.x=S*B,A.y=g*b,A.z=S*I,u.push(A.x,A.y,A.z),f.push(0,b,0),w.x=I*.5+.5,w.y=B*.5*b+.5,d.push(w.x,w.y),p++}for(let k=0;k<i;k++){const U=M+k,N=L+k;v===!0?h.push(N,N+1,U):h.push(N+1,N,U),C+=3}c.addGroup(m,C,v===!0?1:2),m+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zr(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ao extends Zr{constructor(e=1,t=1,n=32,i=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,n,i,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Ao(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ci extends Fe{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const s=[],a=[];o(i),c(n),h(),this.setAttribute("position",new ve(s,3)),this.setAttribute("normal",new ve(s.slice(),3)),this.setAttribute("uv",new ve(a,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function o(y){const x=new R,v=new R,M=new R;for(let w=0;w<t.length;w+=3)d(t[w+0],x),d(t[w+1],v),d(t[w+2],M),l(x,v,M,y)}function l(y,x,v,M){const w=M+1,A=[];for(let C=0;C<=w;C++){A[C]=[];const S=y.clone().lerp(v,C/w),b=x.clone().lerp(v,C/w),L=w-C;for(let k=0;k<=L;k++)k===0&&C===w?A[C][k]=S:A[C][k]=S.clone().lerp(b,k/L)}for(let C=0;C<w;C++)for(let S=0;S<2*(w-C)-1;S++){const b=Math.floor(S/2);S%2===0?(f(A[C][b+1]),f(A[C+1][b]),f(A[C][b])):(f(A[C][b+1]),f(A[C+1][b+1]),f(A[C+1][b]))}}function c(y){const x=new R;for(let v=0;v<s.length;v+=3)x.x=s[v+0],x.y=s[v+1],x.z=s[v+2],x.normalize().multiplyScalar(y),s[v+0]=x.x,s[v+1]=x.y,s[v+2]=x.z}function h(){const y=new R;for(let x=0;x<s.length;x+=3){y.x=s[x+0],y.y=s[x+1],y.z=s[x+2];const v=g(y)/2/Math.PI+.5,M=m(y)/Math.PI+.5;a.push(v,1-M)}p(),u()}function u(){for(let y=0;y<a.length;y+=6){const x=a[y+0],v=a[y+2],M=a[y+4],w=Math.max(x,v,M),A=Math.min(x,v,M);w>.9&&A<.1&&(x<.2&&(a[y+0]+=1),v<.2&&(a[y+2]+=1),M<.2&&(a[y+4]+=1))}}function f(y){s.push(y.x,y.y,y.z)}function d(y,x){const v=y*3;x.x=e[v+0],x.y=e[v+1],x.z=e[v+2]}function p(){const y=new R,x=new R,v=new R,M=new R,w=new q,A=new q,C=new q;for(let S=0,b=0;S<s.length;S+=9,b+=6){y.set(s[S+0],s[S+1],s[S+2]),x.set(s[S+3],s[S+4],s[S+5]),v.set(s[S+6],s[S+7],s[S+8]),w.set(a[b+0],a[b+1]),A.set(a[b+2],a[b+3]),C.set(a[b+4],a[b+5]),M.copy(y).add(x).add(v).divideScalar(3);const L=g(M);_(w,b+0,y,L),_(A,b+2,x,L),_(C,b+4,v,L)}}function _(y,x,v,M){M<0&&y.x===1&&(a[x]=y.x-1),v.x===0&&v.z===0&&(a[x]=M/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function m(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ci(e.vertices,e.indices,e.radius,e.details)}}class To extends Ci{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new To(e.radius,e.detail)}}const Ro=new R,Co=new R,Ch=new R,Po=new jt;class Ep extends Fe{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),s=Math.cos(Bi*t),a=e.getIndex(),o=e.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],h=["a","b","c"],u=new Array(3),f={},d=[];for(let p=0;p<l;p+=3){a?(c[0]=a.getX(p),c[1]=a.getX(p+1),c[2]=a.getX(p+2)):(c[0]=p,c[1]=p+1,c[2]=p+2);const{a:_,b:g,c:m}=Po;if(_.fromBufferAttribute(o,c[0]),g.fromBufferAttribute(o,c[1]),m.fromBufferAttribute(o,c[2]),Po.getNormal(Ch),u[0]=`${Math.round(_.x*i)},${Math.round(_.y*i)},${Math.round(_.z*i)}`,u[1]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,u[2]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let y=0;y<3;y++){const x=(y+1)%3,v=u[y],M=u[x],w=Po[h[y]],A=Po[h[x]],C=`${v}_${M}`,S=`${M}_${v}`;S in f&&f[S]?(Ch.dot(f[S].normal)<=s&&(d.push(w.x,w.y,w.z),d.push(A.x,A.y,A.z)),f[S]=null):C in f||(f[C]={index0:c[y],index1:c[x],normal:Ch.clone()})}}for(const p in f)if(f[p]){const{index0:_,index1:g}=f[p];Ro.fromBufferAttribute(o,_),Co.fromBufferAttribute(o,g),d.push(Ro.x,Ro.y,Ro.z),d.push(Co.x,Co.y,Co.z)}this.setAttribute("position",new ve(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class ii extends Ws{constructor(e){super(e),this.uuid=on(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new Ws().fromJSON(i))}return this}}const cS={triangulate:function(r,e,t=2){const n=e&&e.length,i=n?e[0]*t:r.length;let s=Ap(r,0,i,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c,h,u,f,d;if(n&&(s=pS(r,e,s,t)),r.length>80*t){o=c=r[0],l=h=r[1];for(let p=t;p<i;p+=t)u=r[p],f=r[p+1],u<o&&(o=u),f<l&&(l=f),u>c&&(c=u),f>h&&(h=f);d=Math.max(c-o,h-l),d=d!==0?32767/d:0}return qs(s,a,t,o,l,d,0),a}};function Ap(r,e,t,n,i){let s,a;if(i===ES(r,e,t,n)>0)for(s=e;s<t;s+=n)a=Cp(s,r[s],r[s+1],a);else for(s=t-n;s>=e;s-=n)a=Cp(s,r[s],r[s+1],a);return a&&Lo(a,a.next)&&(Ys(a),a=a.next),a}function Yi(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(Lo(t,t.next)||lt(t.prev,t,t.next)===0)){if(Ys(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function qs(r,e,t,n,i,s,a){if(!r)return;!a&&s&&yS(r,n,i,s);let o=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?uS(r,n,i,s):hS(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(c.i/t|0),Ys(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=fS(Yi(r),e,t),qs(r,e,t,n,i,s,2)):a===2&&dS(r,e,t,n,i,s):qs(Yi(r),e,t,n,i,s,1);break}}}function hS(r){const e=r.prev,t=r,n=r.next;if(lt(e,t,n)>=0)return!1;const i=e.x,s=t.x,a=n.x,o=e.y,l=t.y,c=n.y,h=i<s?i<a?i:a:s<a?s:a,u=o<l?o<c?o:c:l<c?l:c,f=i>s?i>a?i:a:s>a?s:a,d=o>l?o>c?o:c:l>c?l:c;let p=n.next;for(;p!==e;){if(p.x>=h&&p.x<=f&&p.y>=u&&p.y<=d&&Jr(i,o,s,l,a,c,p.x,p.y)&&lt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function uS(r,e,t,n){const i=r.prev,s=r,a=r.next;if(lt(i,s,a)>=0)return!1;const o=i.x,l=s.x,c=a.x,h=i.y,u=s.y,f=a.y,d=o<l?o<c?o:c:l<c?l:c,p=h<u?h<f?h:f:u<f?u:f,_=o>l?o>c?o:c:l>c?l:c,g=h>u?h>f?h:f:u>f?u:f,m=Ph(d,p,e,t,n),y=Ph(_,g,e,t,n);let x=r.prevZ,v=r.nextZ;for(;x&&x.z>=m&&v&&v.z<=y;){if(x.x>=d&&x.x<=_&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&Jr(o,h,l,u,c,f,x.x,x.y)&&lt(x.prev,x,x.next)>=0||(x=x.prevZ,v.x>=d&&v.x<=_&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&Jr(o,h,l,u,c,f,v.x,v.y)&&lt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;x&&x.z>=m;){if(x.x>=d&&x.x<=_&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&Jr(o,h,l,u,c,f,x.x,x.y)&&lt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=d&&v.x<=_&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&Jr(o,h,l,u,c,f,v.x,v.y)&&lt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function fS(r,e,t){let n=r;do{const i=n.prev,s=n.next.next;!Lo(i,s)&&Tp(i,n,n.next,s)&&$s(i,s)&&$s(s,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),Ys(n),Ys(n.next),n=r=s),n=n.next}while(n!==r);return Yi(n)}function dS(r,e,t,n,i,s){let a=r;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&SS(a,o)){let l=Rp(a,o);a=Yi(a,a.next),l=Yi(l,l.next),qs(a,e,t,n,i,s,0),qs(l,e,t,n,i,s,0);return}o=o.next}a=a.next}while(a!==r)}function pS(r,e,t,n){const i=[];let s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*n,l=s<a-1?e[s+1]*n:r.length,c=Ap(r,o,l,n,!1),c===c.next&&(c.steiner=!0),i.push(MS(c));for(i.sort(mS),s=0;s<i.length;s++)t=gS(i[s],t);return t}function mS(r,e){return r.x-e.x}function gS(r,e){const t=_S(r,e);if(!t)return e;const n=Rp(t,r);return Yi(n,n.next),Yi(t,t.next)}function _S(r,e){let t=e,n=-1/0,i;const s=r.x,a=r.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const f=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=s&&f>n&&(n=f,i=t.x<t.next.x?t:t.next,f===s))return i}t=t.next}while(t!==e);if(!i)return null;const o=i,l=i.x,c=i.y;let h=1/0,u;t=i;do s>=t.x&&t.x>=l&&s!==t.x&&Jr(a<c?s:n,a,l,c,a<c?n:s,a,t.x,t.y)&&(u=Math.abs(a-t.y)/(s-t.x),$s(t,r)&&(u<h||u===h&&(t.x>i.x||t.x===i.x&&xS(i,t)))&&(i=t,h=u)),t=t.next;while(t!==o);return i}function xS(r,e){return lt(r.prev,r,e.prev)<0&&lt(e.next,r,r.next)<0}function yS(r,e,t,n){let i=r;do i.z===0&&(i.z=Ph(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,vS(i)}function vS(r){let e,t,n,i,s,a,o,l,c=1;do{for(t=r,r=null,s=null,a=0;t;){for(a++,n=t,o=0,e=0;e<c&&(o++,n=n.nextZ,!!n);e++);for(l=c;o>0||l>0&&n;)o!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,o--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(a>1);return r}function Ph(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function MS(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function Jr(r,e,t,n,i,s,a,o){return(i-a)*(e-o)>=(r-a)*(s-o)&&(r-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(i-a)*(n-o)}function SS(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!bS(r,e)&&($s(r,e)&&$s(e,r)&&wS(r,e)&&(lt(r.prev,r,e.prev)||lt(r,e.prev,e))||Lo(r,e)&&lt(r.prev,r,r.next)>0&&lt(e.prev,e,e.next)>0)}function lt(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function Lo(r,e){return r.x===e.x&&r.y===e.y}function Tp(r,e,t,n){const i=Uo(lt(r,e,t)),s=Uo(lt(r,e,n)),a=Uo(lt(t,n,r)),o=Uo(lt(t,n,e));return!!(i!==s&&a!==o||i===0&&Io(r,t,e)||s===0&&Io(r,n,e)||a===0&&Io(t,r,n)||o===0&&Io(t,e,n))}function Io(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Uo(r){return r>0?1:r<0?-1:0}function bS(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Tp(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function $s(r,e){return lt(r.prev,r,r.next)<0?lt(r,e,r.next)>=0&&lt(r,r.prev,e)>=0:lt(r,e,r.prev)<0||lt(r,r.next,e)<0}function wS(r,e){let t=r,n=!1;const i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function Rp(r,e){const t=new Lh(r.i,r.x,r.y),n=new Lh(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Cp(r,e,t,n){const i=new Lh(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ys(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Lh(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ES(r,e,t,n){let i=0;for(let s=e,a=t-n;s<t;s+=n)i+=(r[a]-r[s])*(r[s+1]+r[a+1]),a=s;return i}class un{static area(e){const t=e.length;let n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return un.area(e)<0}static triangulateShape(e,t){const n=[],i=[],s=[];Pp(e),Lp(n,e);let a=e.length;t.forEach(Pp);for(let l=0;l<t.length;l++)i.push(a),a+=t[l].length,Lp(n,t[l]);const o=cS.triangulate(n,i);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function Pp(r){const e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function Lp(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}let Ip=class R0 extends Fe{constructor(e=new ii([new q(.5,.5),new q(-.5,.5),new q(-.5,-.5),new q(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new ve(i,3)),this.setAttribute("uv",new ve(s,2)),this.computeVertexNormals();function a(o){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1,u=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:d-.1,_=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const m=t.extrudePath,y=t.UVGenerator!==void 0?t.UVGenerator:AS;let x,v=!1,M,w,A,C;m&&(x=m.getSpacedPoints(h),v=!0,f=!1,M=m.computeFrenetFrames(h,!1),w=new R,A=new R,C=new R),f||(g=0,d=0,p=0,_=0);const S=o.extractPoints(c);let b=S.shape;const L=S.holes;if(!un.isClockWise(b)){b=b.reverse();for(let D=0,ae=L.length;D<ae;D++){const Q=L[D];un.isClockWise(Q)&&(L[D]=Q.reverse())}}const U=un.triangulateShape(b,L),N=b;for(let D=0,ae=L.length;D<ae;D++){const Q=L[D];b=b.concat(Q)}function I(D,ae,Q){return ae||console.error("THREE.ExtrudeGeometry: vec does not exist"),D.clone().addScaledVector(ae,Q)}const B=b.length,O=U.length;function H(D,ae,Q){let oe,re,Ee;const $=D.x-ae.x,J=D.y-ae.y,ne=Q.x-D.x,de=Q.y-D.y,pe=$*$+J*J,T=$*de-J*ne;if(Math.abs(T)>Number.EPSILON){const E=Math.sqrt(pe),W=Math.sqrt(ne*ne+de*de),se=ae.x-J/E,ie=ae.y+$/E,me=Q.x-de/W,we=Q.y+ne/W,he=((me-se)*de-(we-ie)*ne)/($*de-J*ne);oe=se+$*he-D.x,re=ie+J*he-D.y;const K=oe*oe+re*re;if(K<=2)return new q(oe,re);Ee=Math.sqrt(K/2)}else{let E=!1;$>Number.EPSILON?ne>Number.EPSILON&&(E=!0):$<-Number.EPSILON?ne<-Number.EPSILON&&(E=!0):Math.sign(J)===Math.sign(de)&&(E=!0),E?(oe=-J,re=$,Ee=Math.sqrt(pe)):(oe=$,re=J,Ee=Math.sqrt(pe/2))}return new q(oe/Ee,re/Ee)}const X=[];for(let D=0,ae=N.length,Q=ae-1,oe=D+1;D<ae;D++,Q++,oe++)Q===ae&&(Q=0),oe===ae&&(oe=0),X[D]=H(N[D],N[Q],N[oe]);const ee=[];let z,Z=X.concat();for(let D=0,ae=L.length;D<ae;D++){const Q=L[D];z=[];for(let oe=0,re=Q.length,Ee=re-1,$=oe+1;oe<re;oe++,Ee++,$++)Ee===re&&(Ee=0),$===re&&($=0),z[oe]=H(Q[oe],Q[Ee],Q[$]);ee.push(z),Z=Z.concat(z)}for(let D=0;D<g;D++){const ae=D/g,Q=d*Math.cos(ae*Math.PI/2),oe=p*Math.sin(ae*Math.PI/2)+_;for(let re=0,Ee=N.length;re<Ee;re++){const $=I(N[re],X[re],oe);Pe($.x,$.y,-Q)}for(let re=0,Ee=L.length;re<Ee;re++){const $=L[re];z=ee[re];for(let J=0,ne=$.length;J<ne;J++){const de=I($[J],z[J],oe);Pe(de.x,de.y,-Q)}}}const le=p+_;for(let D=0;D<B;D++){const ae=f?I(b[D],Z[D],le):b[D];v?(A.copy(M.normals[0]).multiplyScalar(ae.x),w.copy(M.binormals[0]).multiplyScalar(ae.y),C.copy(x[0]).add(A).add(w),Pe(C.x,C.y,C.z)):Pe(ae.x,ae.y,0)}for(let D=1;D<=h;D++)for(let ae=0;ae<B;ae++){const Q=f?I(b[ae],Z[ae],le):b[ae];v?(A.copy(M.normals[D]).multiplyScalar(Q.x),w.copy(M.binormals[D]).multiplyScalar(Q.y),C.copy(x[D]).add(A).add(w),Pe(C.x,C.y,C.z)):Pe(Q.x,Q.y,u/h*D)}for(let D=g-1;D>=0;D--){const ae=D/g,Q=d*Math.cos(ae*Math.PI/2),oe=p*Math.sin(ae*Math.PI/2)+_;for(let re=0,Ee=N.length;re<Ee;re++){const $=I(N[re],X[re],oe);Pe($.x,$.y,u+Q)}for(let re=0,Ee=L.length;re<Ee;re++){const $=L[re];z=ee[re];for(let J=0,ne=$.length;J<ne;J++){const de=I($[J],z[J],oe);v?Pe(de.x,de.y+x[h-1].y,x[h-1].x+Q):Pe(de.x,de.y,u+Q)}}}ce(),fe();function ce(){const D=i.length/3;if(f){let ae=0,Q=B*ae;for(let oe=0;oe<O;oe++){const re=U[oe];Te(re[2]+Q,re[1]+Q,re[0]+Q)}ae=h+g*2,Q=B*ae;for(let oe=0;oe<O;oe++){const re=U[oe];Te(re[0]+Q,re[1]+Q,re[2]+Q)}}else{for(let ae=0;ae<O;ae++){const Q=U[ae];Te(Q[2],Q[1],Q[0])}for(let ae=0;ae<O;ae++){const Q=U[ae];Te(Q[0]+B*h,Q[1]+B*h,Q[2]+B*h)}}n.addGroup(D,i.length/3-D,0)}function fe(){const D=i.length/3;let ae=0;Ae(N,ae),ae+=N.length;for(let Q=0,oe=L.length;Q<oe;Q++){const re=L[Q];Ae(re,ae),ae+=re.length}n.addGroup(D,i.length/3-D,1)}function Ae(D,ae){let Q=D.length;for(;--Q>=0;){const oe=Q;let re=Q-1;re<0&&(re=D.length-1);for(let Ee=0,$=h+g*2;Ee<$;Ee++){const J=B*Ee,ne=B*(Ee+1),de=ae+oe+J,pe=ae+re+J,T=ae+re+ne,E=ae+oe+ne;Ke(de,pe,T,E)}}}function Pe(D,ae,Q){l.push(D),l.push(ae),l.push(Q)}function Te(D,ae,Q){je(D),je(ae),je(Q);const oe=i.length/3,re=y.generateTopUV(n,i,oe-3,oe-2,oe-1);Le(re[0]),Le(re[1]),Le(re[2])}function Ke(D,ae,Q,oe){je(D),je(ae),je(oe),je(ae),je(Q),je(oe);const re=i.length/3,Ee=y.generateSideWallUV(n,i,re-6,re-3,re-2,re-1);Le(Ee[0]),Le(Ee[1]),Le(Ee[3]),Le(Ee[1]),Le(Ee[2]),Le(Ee[3])}function je(D){i.push(l[D*3+0]),i.push(l[D*3+1]),i.push(l[D*3+2])}function Le(D){s.push(D.x),s.push(D.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return TS(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];n.push(o)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new Rh[i.type]().fromJSON(i)),new R0(n,e.options)}};const AS={generateTopUV:function(r,e,t,n,i){const s=e[t*3],a=e[t*3+1],o=e[n*3],l=e[n*3+1],c=e[i*3],h=e[i*3+1];return[new q(s,a),new q(o,l),new q(c,h)]},generateSideWallUV:function(r,e,t,n,i,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[n*3],h=e[n*3+1],u=e[n*3+2],f=e[i*3],d=e[i*3+1],p=e[i*3+2],_=e[s*3],g=e[s*3+1],m=e[s*3+2];return Math.abs(o-h)<Math.abs(a-c)?[new q(a,1-l),new q(c,1-u),new q(f,1-p),new q(_,1-m)]:[new q(o,1-l),new q(h,1-u),new q(d,1-p),new q(g,1-m)]}};function TS(r,e,t){if(t.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){const s=r[n];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Do extends Ci{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Do(e.radius,e.detail)}}class Zs extends Ci{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Zs(e.radius,e.detail)}}class No extends Fe{constructor(e=.5,t=1,n=32,i=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:a},n=Math.max(3,n),i=Math.max(1,i);const o=[],l=[],c=[],h=[];let u=e;const f=(t-e)/i,d=new R,p=new q;for(let _=0;_<=i;_++){for(let g=0;g<=n;g++){const m=s+g/n*a;d.x=u*Math.cos(m),d.y=u*Math.sin(m),l.push(d.x,d.y,d.z),c.push(0,0,1),p.x=(d.x/t+1)/2,p.y=(d.y/t+1)/2,h.push(p.x,p.y)}u+=f}for(let _=0;_<i;_++){const g=_*(n+1);for(let m=0;m<n;m++){const y=m+g,x=y,v=y+n+1,M=y+n+2,w=y+1;o.push(x,v,w),o.push(v,M,w)}}this.setIndex(o),this.setAttribute("position",new ve(l,3)),this.setAttribute("normal",new ve(c,3)),this.setAttribute("uv",new ve(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new No(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Fo extends Fe{constructor(e=new ii([new q(0,.5),new q(-.5,-.5),new q(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let h=0;h<e.length;h++)c(e[h]),this.addGroup(o,l,h),o+=l,l=0;this.setIndex(n),this.setAttribute("position",new ve(i,3)),this.setAttribute("normal",new ve(s,3)),this.setAttribute("uv",new ve(a,2));function c(h){const u=i.length/3,f=h.extractPoints(t);let d=f.shape;const p=f.holes;un.isClockWise(d)===!1&&(d=d.reverse());for(let g=0,m=p.length;g<m;g++){const y=p[g];un.isClockWise(y)===!0&&(p[g]=y.reverse())}const _=un.triangulateShape(d,p);for(let g=0,m=p.length;g<m;g++){const y=p[g];d=d.concat(y)}for(let g=0,m=d.length;g<m;g++){const y=d[g];i.push(y.x,y.y,0),s.push(0,0,1),a.push(y.x,y.y)}for(let g=0,m=_.length;g<m;g++){const y=_[g],x=y[0]+u,v=y[1]+u,M=y[2]+u;n.push(x,v,M),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return RS(t,e)}static fromJSON(e,t){const n=[];for(let i=0,s=e.shapes.length;i<s;i++){const a=t[e.shapes[i]];n.push(a)}return new Fo(n,e.curveSegments)}}function RS(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,n=r.length;t<n;t++){const i=r[t];e.shapes.push(i.uuid)}else e.shapes.push(r.uuid);return e}class Js extends Fe{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const h=[],u=new R,f=new R,d=[],p=[],_=[],g=[];for(let m=0;m<=n;m++){const y=[],x=m/n;let v=0;m===0&&a===0?v=.5/t:m===n&&l===Math.PI&&(v=-.5/t);for(let M=0;M<=t;M++){const w=M/t;u.x=-e*Math.cos(i+w*s)*Math.sin(a+x*o),u.y=e*Math.cos(a+x*o),u.z=e*Math.sin(i+w*s)*Math.sin(a+x*o),p.push(u.x,u.y,u.z),f.copy(u).normalize(),_.push(f.x,f.y,f.z),g.push(w+v,1-x),y.push(c++)}h.push(y)}for(let m=0;m<n;m++)for(let y=0;y<t;y++){const x=h[m][y+1],v=h[m][y],M=h[m+1][y],w=h[m+1][y+1];(m!==0||a>0)&&d.push(x,v,w),(m!==n-1||l<Math.PI)&&d.push(v,M,w)}this.setIndex(d),this.setAttribute("position",new ve(p,3)),this.setAttribute("normal",new ve(_,3)),this.setAttribute("uv",new ve(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Js(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Oo extends Ci{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Oo(e.radius,e.detail)}}class Bo extends Fe{constructor(e=1,t=.4,n=12,i=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:s},n=Math.floor(n),i=Math.floor(i);const a=[],o=[],l=[],c=[],h=new R,u=new R,f=new R;for(let d=0;d<=n;d++)for(let p=0;p<=i;p++){const _=p/i*s,g=d/n*Math.PI*2;u.x=(e+t*Math.cos(g))*Math.cos(_),u.y=(e+t*Math.cos(g))*Math.sin(_),u.z=t*Math.sin(g),o.push(u.x,u.y,u.z),h.x=e*Math.cos(_),h.y=e*Math.sin(_),f.subVectors(u,h).normalize(),l.push(f.x,f.y,f.z),c.push(p/i),c.push(d/n)}for(let d=1;d<=n;d++)for(let p=1;p<=i;p++){const _=(i+1)*d+p-1,g=(i+1)*(d-1)+p-1,m=(i+1)*(d-1)+p,y=(i+1)*d+p;a.push(_,g,y),a.push(g,m,y)}this.setIndex(a),this.setAttribute("position",new ve(o,3)),this.setAttribute("normal",new ve(l,3)),this.setAttribute("uv",new ve(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Bo(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class zo extends Fe{constructor(e=1,t=.4,n=64,i=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:a},n=Math.floor(n),i=Math.floor(i);const o=[],l=[],c=[],h=[],u=new R,f=new R,d=new R,p=new R,_=new R,g=new R,m=new R;for(let x=0;x<=n;++x){const v=x/n*s*Math.PI*2;y(v,s,a,e,d),y(v+.01,s,a,e,p),g.subVectors(p,d),m.addVectors(p,d),_.crossVectors(g,m),m.crossVectors(_,g),_.normalize(),m.normalize();for(let M=0;M<=i;++M){const w=M/i*Math.PI*2,A=-t*Math.cos(w),C=t*Math.sin(w);u.x=d.x+(A*m.x+C*_.x),u.y=d.y+(A*m.y+C*_.y),u.z=d.z+(A*m.z+C*_.z),l.push(u.x,u.y,u.z),f.subVectors(u,d).normalize(),c.push(f.x,f.y,f.z),h.push(x/n),h.push(M/i)}}for(let x=1;x<=n;x++)for(let v=1;v<=i;v++){const M=(i+1)*(x-1)+(v-1),w=(i+1)*x+(v-1),A=(i+1)*x+v,C=(i+1)*(x-1)+v;o.push(M,w,C),o.push(w,A,C)}this.setIndex(o),this.setAttribute("position",new ve(l,3)),this.setAttribute("normal",new ve(c,3)),this.setAttribute("uv",new ve(h,2));function y(x,v,M,w,A){const C=Math.cos(x),S=Math.sin(x),b=M/v*x,L=Math.cos(b);A.x=w*(2+L)*.5*C,A.y=w*(2+L)*S*.5,A.z=w*Math.sin(b)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new zo(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class ko extends Fe{constructor(e=new Ah(new R(-1,-1,0),new R(-1,1,0),new R(1,1,0)),t=64,n=1,i=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new R,l=new R,c=new q;let h=new R;const u=[],f=[],d=[],p=[];_(),this.setIndex(p),this.setAttribute("position",new ve(u,3)),this.setAttribute("normal",new ve(f,3)),this.setAttribute("uv",new ve(d,2));function _(){for(let x=0;x<t;x++)g(x);g(s===!1?t:0),y(),m()}function g(x){h=e.getPointAt(x/t,h);const v=a.normals[x],M=a.binormals[x];for(let w=0;w<=i;w++){const A=w/i*Math.PI*2,C=Math.sin(A),S=-Math.cos(A);l.x=S*v.x+C*M.x,l.y=S*v.y+C*M.y,l.z=S*v.z+C*M.z,l.normalize(),f.push(l.x,l.y,l.z),o.x=h.x+n*l.x,o.y=h.y+n*l.y,o.z=h.z+n*l.z,u.push(o.x,o.y,o.z)}}function m(){for(let x=1;x<=t;x++)for(let v=1;v<=i;v++){const M=(i+1)*(x-1)+(v-1),w=(i+1)*x+(v-1),A=(i+1)*x+v,C=(i+1)*(x-1)+v;p.push(M,w,C),p.push(w,A,C)}}function y(){for(let x=0;x<=t;x++)for(let v=0;v<=i;v++)c.x=x/t,c.y=v/i,d.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new ko(new Rh[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Up extends Fe{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new R,s=new R;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,h=l.length;c<h;++c){const u=l[c],f=u.start,d=u.count;for(let p=f,_=f+d;p<_;p+=3)for(let g=0;g<3;g++){const m=o.getX(p+g),y=o.getX(p+(g+1)%3);i.fromBufferAttribute(a,m),s.fromBufferAttribute(a,y),Dp(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const h=3*o+c,u=3*o+(c+1)%3;i.fromBufferAttribute(a,h),s.fromBufferAttribute(a,u),Dp(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new ve(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Dp(r,e,t){const n=`${r.x},${r.y},${r.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${r.x},${r.y},${r.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}var Np=Object.freeze({__proto__:null,BoxGeometry:Vi,CapsuleGeometry:wo,CircleGeometry:Eo,ConeGeometry:Ao,CylinderGeometry:Zr,DodecahedronGeometry:To,EdgesGeometry:Ep,ExtrudeGeometry:Ip,IcosahedronGeometry:Do,LatheGeometry:Xs,OctahedronGeometry:Zs,PlaneGeometry:Ns,PolyhedronGeometry:Ci,RingGeometry:No,ShapeGeometry:Fo,SphereGeometry:Js,TetrahedronGeometry:Oo,TorusGeometry:Bo,TorusKnotGeometry:zo,TubeGeometry:ko,WireframeGeometry:Up});class Fp extends Ft{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ye(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Op extends zn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ih extends Ft{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new ye(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vi,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Bp extends Ih{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new q(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ft(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ye(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ye(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ye(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get 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.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 zp extends Ft{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ye(16777215),this.specular=new ye(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vi,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ps,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.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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 kp extends Ft{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ye(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vi,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Gp extends Ft{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vi,this.normalScale=new q(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 Hp extends Ft{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ye(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vi,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ps,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.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 Vp extends Ft{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ye(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vi,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Wp extends Vt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function yn(r,e,t){return Uh(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)}function Zi(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function Uh(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Xp(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function Dh(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let l=0;l!==e;++l)i[a++]=r[o+l]}return i}function Nh(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=r[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=r[i++];while(s!==void 0)}function CS(r,e,t,n,i=30){const s=r.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],h=c.getValueSize(),u=[],f=[];for(let d=0;d<c.times.length;++d){const p=c.times[d]*i;if(!(p<t||p>=n)){u.push(c.times[d]);for(let _=0;_<h;++_)f.push(c.values[d*h+_])}}u.length!==0&&(c.times=Zi(u,c.times.constructor),c.values=Zi(f,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function PS(r,e=0,t=r,n=30){n<=0&&(n=30);const i=t.tracks.length,s=e/n;for(let a=0;a<i;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=r.tracks.find(function(m){return m.name===o.name&&m.ValueTypeName===l});if(c===void 0)continue;let h=0;const u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let f=0;const d=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);const p=o.times.length-1;let _;if(s<=o.times[0]){const m=h,y=u-h;_=yn(o.values,m,y)}else if(s>=o.times[p]){const m=p*u+h,y=m+u-h;_=yn(o.values,m,y)}else{const m=o.createInterpolant(),y=h,x=u-h;m.evaluate(s),_=yn(m.resultBuffer,y,x)}l==="quaternion"&&new Kt().fromArray(_).normalize().conjugate().toArray(_);const g=c.times.length;for(let m=0;m<g;++m){const y=m*d+f;if(l==="quaternion")Kt.multiplyQuaternionsFlat(c.values,y,_,0,c.values,y);else{const x=d-f*2;for(let v=0;v<x;++v)c.values[y+v]-=_[v]}}}return r.blendMode=Cc,r}const LS={arraySlice:yn,convertArray:Zi,isTypedArray:Uh,getKeyframeOrder:Xp,sortedArray:Dh,flattenJSON:Nh,subclip:CS,makeClipAdditive:PS};class Ks{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];e:{t:{let a;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=i,i=t[++n],e<i)break t}a=t.length;break n}if(!(e>=s)){const o=t[1];e<o&&(n=2,s=o);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break t}a=n,n=0;break n}break e}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let a=0;a!==i;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class qp extends Ks{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Fi,endingEnd:Fi}}intervalChanged_(e,t,n){const i=this.parameterPositions;let s=e-2,a=e+1,o=i[s],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case Oi:s=e,o=2*t-n;break;case Ss:s=i.length-2,o=t+i[s]-i[s+1];break;default:s=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Oi:a=e,l=2*n-t;break;case Ss:a=1,l=n+i[1]-i[0];break;default:a=e-1,l=t}const c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,d=this._weightNext,p=(n-t)/(i-t),_=p*p,g=_*p,m=-f*g+2*f*_-f*p,y=(1+f)*g+(-1.5-2*f)*_+(-.5+f)*p+1,x=(-1-d)*g+(1.5+d)*_+.5*p,v=d*g-d*_;for(let M=0;M!==o;++M)s[M]=m*a[h+M]+y*a[c+M]+x*a[l+M]+v*a[u+M];return s}}class Fh extends Ks{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(n-t)/(i-t),u=1-h;for(let f=0;f!==o;++f)s[f]=a[c+f]*u+a[l+f]*h;return s}}class $p extends Ks{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Pn{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Zi(t,this.TimeBufferType),this.values=Zi(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Zi(e.times,Array),values:Zi(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new $p(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Fh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new qp(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case vs:t=this.InterpolantFactoryMethodDiscrete;break;case Ms:t=this.InterpolantFactoryMethodLinear;break;case Pa:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return vs;case this.InterpolantFactoryMethodLinear:return Ms;case this.InterpolantFactoryMethodSmooth:return Pa}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let s=0,a=i-1;for(;s!==i&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=yn(n,s,a),this.values=yn(this.values,s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&Uh(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=yn(this.times),t=yn(this.values),n=this.getValueSize(),i=this.getInterpolation()===Pa,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(i)l=!0;else{const u=o*n,f=u-n,d=u+n;for(let p=0;p!==n;++p){const _=t[u+p];if(_!==t[f+p]||_!==t[d+p]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const u=o*n,f=a*n;for(let d=0;d!==n;++d)t[f+d]=t[u+d]}++a}}if(s>0){e[a]=e[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=yn(e,0,a),this.values=yn(t,0,a*n)):(this.times=e,this.values=t),this}clone(){const e=yn(this.times,0),t=yn(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Pn.prototype.TimeBufferType=Float32Array,Pn.prototype.ValueBufferType=Float32Array,Pn.prototype.DefaultInterpolation=Ms;class Ji extends Pn{}Ji.prototype.ValueTypeName="bool",Ji.prototype.ValueBufferType=Array,Ji.prototype.DefaultInterpolation=vs,Ji.prototype.InterpolantFactoryMethodLinear=void 0,Ji.prototype.InterpolantFactoryMethodSmooth=void 0;class Oh extends Pn{}Oh.prototype.ValueTypeName="color";class js extends Pn{}js.prototype.ValueTypeName="number";class Yp extends Ks{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let h=c+o;c!==h;c+=4)Kt.slerpFlat(s,0,a,c-o,a,c,l);return s}}class Kr extends Pn{InterpolantFactoryMethodLinear(e){return new Yp(this.times,this.values,this.getValueSize(),e)}}Kr.prototype.ValueTypeName="quaternion",Kr.prototype.DefaultInterpolation=Ms,Kr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ki extends Pn{}Ki.prototype.ValueTypeName="string",Ki.prototype.ValueBufferType=Array,Ki.prototype.DefaultInterpolation=vs,Ki.prototype.InterpolantFactoryMethodLinear=void 0,Ki.prototype.InterpolantFactoryMethodSmooth=void 0;class Qs extends Pn{}Qs.prototype.ValueTypeName="vector";class ea{constructor(e,t=-1,n,i=La){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=on(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(US(n[a]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(Pn.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const h=Xp(l);l=Dh(l,1,h),c=Dh(c,1,h),!i&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new js(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c.name.match(s);if(h&&h.length>1){const u=h[1];let f=i[u];f||(i[u]=f=[]),f.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,f,d,p,_){if(d.length!==0){const g=[],m=[];Nh(d,g,m,p),g.length!==0&&_.push(new u(f,g,m))}},i=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u<c.length;u++){const f=c[u].keys;if(!(!f||f.length===0))if(f[0].morphTargets){const d={};let p;for(p=0;p<f.length;p++)if(f[p].morphTargets)for(let _=0;_<f[p].morphTargets.length;_++)d[f[p].morphTargets[_]]=-1;for(const _ in d){const g=[],m=[];for(let y=0;y!==f[p].morphTargets.length;++y){const x=f[p];g.push(x.time),m.push(x.morphTarget===_?1:0)}i.push(new js(".morphTargetInfluence["+_+"]",g,m))}l=d.length*a}else{const d=".bones["+t[u].name+"]";n(Qs,d+".position",f,"pos",i),n(Kr,d+".quaternion",f,"rot",i),n(Qs,d+".scale",f,"scl",i)}}return i.length===0?null:new this(s,l,i,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function IS(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return js;case"vector":case"vector2":case"vector3":case"vector4":return Qs;case"color":return Oh;case"quaternion":return Kr;case"bool":case"boolean":return Ji;case"string":return Ki}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function US(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=IS(r.type);if(r.times===void 0){const t=[],n=[];Nh(r.keys,t,n,"value"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const ji={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class Bh{constructor(e,t,n){const i=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){o++,s===!1&&i.onStart!==void 0&&i.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,f=c.length;u<f;u+=2){const d=c[u],p=c[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}}const Zp=new Bh;class en{constructor(e){this.manager=e!==void 0?e:Zp,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}en.DEFAULT_MATERIAL_NAME="__DEFAULT";const ri={};class DS extends Error{constructor(e,t){super(e),this.response=t}}class si extends en{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=ji.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ri[e]!==void 0){ri[e].push({onLoad:t,onProgress:n,onError:i});return}ri[e]=[],ri[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||c.body===void 0||c.body.getReader===void 0)return c;const h=ri[e],u=c.body.getReader(),f=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),d=f?parseInt(f):0,p=d!==0;let _=0;const g=new ReadableStream({start(m){y();function y(){u.read().then(({done:x,value:v})=>{if(x)m.close();else{_+=v.byteLength;const M=new ProgressEvent("progress",{lengthComputable:p,loaded:_,total:d});for(let w=0,A=h.length;w<A;w++){const C=h[w];C.onProgress&&C.onProgress(M)}m.enqueue(v),y()}})}}});return new Response(g)}else throw new DS(`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===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),f=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(f);return c.arrayBuffer().then(p=>d.decode(p))}}}).then(c=>{ji.add(e,c);const h=ri[e];delete ri[e];for(let u=0,f=h.length;u<f;u++){const d=h[u];d.onLoad&&d.onLoad(c)}}).catch(c=>{const h=ri[e];if(h===void 0)throw this.manager.itemError(e),c;delete ri[e];for(let u=0,f=h.length;u<f;u++){const d=h[u];d.onError&&d.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class NS extends en{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new si(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n<e.length;n++){const i=ea.parse(e[n]);t.push(i)}return t}}class FS extends en{constructor(e){super(e)}load(e,t,n,i){const s=this,a=[],o=new yh,l=new si(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function h(u){l.load(e[u],function(f){const d=s.parse(f,!0);a[u]={width:d.width,height:d.height,format:d.format,mipmaps:d.mipmaps},c+=1,c===6&&(d.mipmapCount===1&&(o.minFilter=vt),o.image=a,o.format=d.format,o.needsUpdate=!0,t&&t(o))},n,i)}if(Array.isArray(e))for(let u=0,f=e.length;u<f;++u)h(u);else l.load(e,function(u){const f=s.parse(u,!0);if(f.isCubemap){const d=f.mipmaps.length/f.mipmapCount;for(let p=0;p<d;p++){a[p]={mipmaps:[]};for(let _=0;_<f.mipmapCount;_++)a[p].mipmaps.push(f.mipmaps[p*f.mipmapCount+_]),a[p].format=f.format,a[p].width=f.width,a[p].height=f.height}o.image=a}else o.image.width=f.width,o.image.height=f.height,o.mipmaps=f.mipmaps;f.mipmapCount===1&&(o.minFilter=vt),o.format=f.format,o.needsUpdate=!0,t&&t(o)},n,i);return o}}class ta extends en{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=ji.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=As("img");function l(){h(),ji.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(u){h(),i&&i(u),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class OS extends en{constructor(e){super(e)}load(e,t,n,i){const s=new Ds;s.colorSpace=Ge;const a=new ta(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(h){s.images[c]=h,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,i)}for(let c=0;c<e.length;++c)l(c);return s}}class BS extends en{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new qr,o=new si(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){const c=s.parse(l);c&&(c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:Dt,a.wrapT=c.wrapT!==void 0?c.wrapT:Dt,a.magFilter=c.magFilter!==void 0?c.magFilter:vt,a.minFilter=c.minFilter!==void 0?c.minFilter:vt,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0?a.colorSpace=c.colorSpace:c.encoding!==void 0&&(a.encoding=c.encoding),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=gi),c.mipmapCount===1&&(a.minFilter=vt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c))},n,i),a}}class zS extends en{constructor(e){super(e)}load(e,t,n,i){const s=new Mt,a=new ta(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class Pi extends tt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ye(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}class Jp extends Pi{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(tt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ye(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const zh=new Be,Kp=new R,jp=new R;class kh{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new q(512,512),this.map=null,this.mapPass=null,this.matrix=new Be,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new no,this._frameExtents=new q(1,1),this._viewportCount=1,this._viewports=[new rt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Kp.setFromMatrixPosition(e.matrixWorld),t.position.copy(Kp),jp.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(jp),t.updateMatrixWorld(),zh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(zh),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(zh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class kS extends kh{constructor(){super(new Ut(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=_r*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Qp extends Pi{constructor(e,t,n=0,i=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(tt.DEFAULT_UP),this.updateMatrix(),this.target=new tt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new kS}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const em=new Be,na=new R,Gh=new R;class GS extends kh{constructor(){super(new Ut(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new q(4,2),this._viewportCount=6,this._viewports=[new rt(2,1,1,1),new rt(0,1,1,1),new rt(3,1,1,1),new rt(1,1,1,1),new rt(3,0,1,1),new rt(1,0,1,1)],this._cubeDirections=[new R(1,0,0),new R(-1,0,0),new R(0,0,1),new R(0,0,-1),new R(0,1,0),new R(0,-1,0)],this._cubeUps=[new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,0,1),new R(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),na.setFromMatrixPosition(e.matrixWorld),n.position.copy(na),Gh.copy(n.position),Gh.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Gh),n.updateMatrixWorld(),i.makeTranslation(-na.x,-na.y,-na.z),em.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(em)}}class tm extends Pi{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new GS}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class HS extends kh{constructor(){super(new ro(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class nm extends Pi{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(tt.DEFAULT_UP),this.updateMatrix(),this.target=new tt,this.shadow=new HS}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class im extends Pi{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class rm extends Pi{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class sm{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new R)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*i),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*i)),t.addScaledVector(a[5],1.092548*(i*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(n*s)),t.addScaledVector(a[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*i),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*i),t.addScaledVector(a[5],2*.429043*i*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*n*s),t.addScaledVector(a[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+i*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+i*3);return e}static getBasisAt(e,t){const n=e.x,i=e.y,s=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-i*i)}}class Go extends Pi{constructor(e=new sm,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Ho extends en{constructor(e){super(e),this.textures={}}load(e,t,n,i){const s=this,a=new si(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t=this.textures;function n(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const i=Ho.createMaterialFromType(e.type);if(e.uuid!==void 0&&(i.uuid=e.uuid),e.name!==void 0&&(i.name=e.name),e.color!==void 0&&i.color!==void 0&&i.color.setHex(e.color),e.roughness!==void 0&&(i.roughness=e.roughness),e.metalness!==void 0&&(i.metalness=e.metalness),e.sheen!==void 0&&(i.sheen=e.sheen),e.sheenColor!==void 0&&(i.sheenColor=new ye().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(i.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(e.emissive),e.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(e.specular),e.specularIntensity!==void 0&&(i.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(i.shininess=e.shininess),e.clearcoat!==void 0&&(i.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=e.clearcoatRoughness),e.iridescence!==void 0&&(i.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(i.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(i.transmission=e.transmission),e.thickness!==void 0&&(i.thickness=e.thickness),e.attenuationDistance!==void 0&&(i.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(i.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(i.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(i.fog=e.fog),e.flatShading!==void 0&&(i.flatShading=e.flatShading),e.blending!==void 0&&(i.blending=e.blending),e.combine!==void 0&&(i.combine=e.combine),e.side!==void 0&&(i.side=e.side),e.shadowSide!==void 0&&(i.shadowSide=e.shadowSide),e.opacity!==void 0&&(i.opacity=e.opacity),e.transparent!==void 0&&(i.transparent=e.transparent),e.alphaTest!==void 0&&(i.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(i.alphaHash=e.alphaHash),e.depthTest!==void 0&&(i.depthTest=e.depthTest),e.depthWrite!==void 0&&(i.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(i.colorWrite=e.colorWrite),e.stencilWrite!==void 0&&(i.stencilWrite=e.stencilWrite),e.stencilWriteMask!==void 0&&(i.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(i.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(i.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(i.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(i.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(i.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(i.stencilZPass=e.stencilZPass),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(i.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(i.rotation=e.rotation),e.linewidth!==1&&(i.linewidth=e.linewidth),e.dashSize!==void 0&&(i.dashSize=e.dashSize),e.gapSize!==void 0&&(i.gapSize=e.gapSize),e.scale!==void 0&&(i.scale=e.scale),e.polygonOffset!==void 0&&(i.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(i.dithering=e.dithering),e.alphaToCoverage!==void 0&&(i.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(i.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(i.visible=e.visible),e.toneMapped!==void 0&&(i.toneMapped=e.toneMapped),e.userData!==void 0&&(i.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(i.uniforms[s]={},a.type){case"t":i.uniforms[s].value=n(a.value);break;case"c":i.uniforms[s].value=new ye().setHex(a.value);break;case"v2":i.uniforms[s].value=new q().fromArray(a.value);break;case"v3":i.uniforms[s].value=new R().fromArray(a.value);break;case"v4":i.uniforms[s].value=new rt().fromArray(a.value);break;case"m3":i.uniforms[s].value=new Xe().fromArray(a.value);break;case"m4":i.uniforms[s].value=new Be().fromArray(a.value);break;default:i.uniforms[s].value=a.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(i.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)i.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(i.lights=e.lights),e.clipping!==void 0&&(i.clipping=e.clipping),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new q().fromArray(s)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new q().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(i.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:Fp,SpriteMaterial:uh,RawShaderMaterial:Op,ShaderMaterial:zn,PointsMaterial:_h,MeshPhysicalMaterial:Bp,MeshStandardMaterial:Ih,MeshPhongMaterial:zp,MeshToonMaterial:kp,MeshNormalMaterial:Gp,MeshLambertMaterial:Hp,MeshDepthMaterial:lh,MeshDistanceMaterial:ch,MeshBasicMaterial:Ai,MeshMatcapMaterial:Vp,LineDashedMaterial:Wp,LineBasicMaterial:Vt,Material:Ft};return new t[e]}}class Hh{static decodeText(e){if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch(n){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class am extends Fe{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class om extends en{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new si(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t={},n={};function i(d,p){if(t[p]!==void 0)return t[p];const g=d.interleavedBuffers[p],m=s(d,g.buffer),y=xr(g.type,m),x=new ho(y,g.stride);return x.uuid=g.uuid,t[p]=x,x}function s(d,p){if(n[p]!==void 0)return n[p];const g=d.arrayBuffers[p],m=new Uint32Array(g).buffer;return n[p]=m,m}const a=e.isInstancedBufferGeometry?new am:new Fe,o=e.data.index;if(o!==void 0){const d=xr(o.type,o.array);a.setIndex(new Ze(d,1))}const l=e.data.attributes;for(const d in l){const p=l[d];let _;if(p.isInterleavedBufferAttribute){const g=i(e.data,p.data);_=new $i(g,p.itemSize,p.offset,p.normalized)}else{const g=xr(p.type,p.array),m=p.isInstancedBufferAttribute?$r:Ze;_=new m(g,p.itemSize,p.normalized)}p.name!==void 0&&(_.name=p.name),p.usage!==void 0&&_.setUsage(p.usage),p.updateRange!==void 0&&(_.updateRange.offset=p.updateRange.offset,_.updateRange.count=p.updateRange.count),a.setAttribute(d,_)}const c=e.data.morphAttributes;if(c)for(const d in c){const p=c[d],_=[];for(let g=0,m=p.length;g<m;g++){const y=p[g];let x;if(y.isInterleavedBufferAttribute){const v=i(e.data,y.data);x=new $i(v,y.itemSize,y.offset,y.normalized)}else{const v=xr(y.type,y.array);x=new Ze(v,y.itemSize,y.normalized)}y.name!==void 0&&(x.name=y.name),_.push(x)}a.morphAttributes[d]=_}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let d=0,p=u.length;d!==p;++d){const _=u[d];a.addGroup(_.start,_.count,_.materialIndex)}const f=e.data.boundingSphere;if(f!==void 0){const d=new R;f.center!==void 0&&d.fromArray(f.center),a.boundingSphere=new wn(d,f.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class VS extends en{constructor(e){super(e)}load(e,t,n,i){const s=this,a=this.path===""?Hh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new si(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(u){i!==void 0&&i(u),console.error("THREE:ObjectLoader: Can't parse "+e+".",u.message);return}const h=c.metadata;if(h===void 0||h.type===void 0||h.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},n,i)}loadAsync(e,t){return fs(this,null,function*(){const n=this,i=this.path===""?Hh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;const s=new si(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=yield s.loadAsync(e,t),o=JSON.parse(a),l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return yield n.parseAsync(o)})}parse(e,t){const n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,i),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,n),h=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,h),t!==void 0){let u=!1;for(const f in a)if(a[f].data instanceof HTMLImageElement){u=!0;break}u===!1&&t(c)}return c}parseAsync(e){return fs(this,null,function*(){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),s=yield this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,i,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),l})}parseShapes(e){const t={};if(e!==void 0)for(let n=0,i=e.length;n<i;n++){const s=new ii().fromJSON(e[n]);t[s.uuid]=s}return t}parseSkeletons(e,t){const n={},i={};if(t.traverse(function(s){s.isBone&&(i[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=new go().fromJSON(e[s],i);n[o.uuid]=o}return n}parseGeometries(e,t){const n={};if(e!==void 0){const i=new om;for(let s=0,a=e.length;s<a;s++){let o;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=i.parse(l);break;default:l.type in Np?o=Np[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),n[l.uuid]=o}}return n}parseMaterials(e,t){const n={},i={};if(e!==void 0){const s=new Ho;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];n[l.uuid]===void 0&&(n[l.uuid]=s.parse(l)),i[l.uuid]=n[l.uuid]}}return i}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const i=e[n],s=ea.parse(i);t[s.uuid]=s}return t}parseImages(e,t){const n=this,i={};let s;function a(l){return n.manager.itemStart(l),s.load(l,function(){n.manager.itemEnd(l)},void 0,function(){n.manager.itemError(l),n.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const c=l,h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:n.resourcePath+c;return a(h)}else return l.data?{data:xr(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new Bh(t);s=new ta(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,h=e.length;c<h;c++){const u=e[c],f=u.url;if(Array.isArray(f)){const d=[];for(let p=0,_=f.length;p<_;p++){const g=f[p],m=o(g);m!==null&&(m instanceof HTMLImageElement?d.push(m):d.push(new qr(m.data,m.width,m.height)))}i[u.uuid]=new zi(d)}else{const d=o(u.url);i[u.uuid]=new zi(d)}}}return i}parseImagesAsync(e){return fs(this,null,function*(){const t=this,n={};let i;function s(a){return fs(this,null,function*(){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return yield i.loadAsync(l)}else return a.data?{data:xr(a.type,a.data),width:a.width,height:a.height}:null})}if(e!==void 0&&e.length>0){i=new ta(this.manager),i.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],c=l.url;if(Array.isArray(c)){const h=[];for(let u=0,f=c.length;u<f;u++){const d=c[u],p=yield s(d);p!==null&&(p instanceof HTMLImageElement?h.push(p):h.push(new qr(p.data,p.width,p.height)))}n[l.uuid]=new zi(h)}else{const h=yield s(l.url);n[l.uuid]=new zi(h)}}}return n})}parseTextures(e,t){function n(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const i={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=e[s];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const l=t[o.image],c=l.data;let h;Array.isArray(c)?(h=new Ds,c.length===6&&(h.needsUpdate=!0)):(c&&c.data?h=new qr:h=new Mt,c&&(h.needsUpdate=!0)),h.source=l,h.uuid=o.uuid,o.name!==void 0&&(h.name=o.name),o.mapping!==void 0&&(h.mapping=n(o.mapping,WS)),o.channel!==void 0&&(h.channel=o.channel),o.offset!==void 0&&h.offset.fromArray(o.offset),o.repeat!==void 0&&h.repeat.fromArray(o.repeat),o.center!==void 0&&h.center.fromArray(o.center),o.rotation!==void 0&&(h.rotation=o.rotation),o.wrap!==void 0&&(h.wrapS=n(o.wrap[0],lm),h.wrapT=n(o.wrap[1],lm)),o.format!==void 0&&(h.format=o.format),o.internalFormat!==void 0&&(h.internalFormat=o.internalFormat),o.type!==void 0&&(h.type=o.type),o.colorSpace!==void 0&&(h.colorSpace=o.colorSpace),o.encoding!==void 0&&(h.encoding=o.encoding),o.minFilter!==void 0&&(h.minFilter=n(o.minFilter,cm)),o.magFilter!==void 0&&(h.magFilter=n(o.magFilter,cm)),o.anisotropy!==void 0&&(h.anisotropy=o.anisotropy),o.flipY!==void 0&&(h.flipY=o.flipY),o.generateMipmaps!==void 0&&(h.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(h.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(h.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(h.compareFunction=o.compareFunction),o.userData!==void 0&&(h.userData=o.userData),i[o.uuid]=h}return i}parseObject(e,t,n,i,s){let a;function o(f){return t[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",f),t[f]}function l(f){if(f!==void 0){if(Array.isArray(f)){const d=[];for(let p=0,_=f.length;p<_;p++){const g=f[p];n[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),d.push(n[g])}return d}return n[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),n[f]}}function c(f){return i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",f),i[f]}let h,u;switch(e.type){case"Scene":a=new $d,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new ye(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new co(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new lo(e.fog.color,e.fog.density))),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity);break;case"PerspectiveCamera":a=new Ut(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new ro(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new im(e.color,e.intensity);break;case"DirectionalLight":a=new nm(e.color,e.intensity);break;case"PointLight":a=new tm(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new rm(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Qp(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":a=new Jp(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new Go().fromJSON(e);break;case"SkinnedMesh":h=o(e.geometry),u=l(e.material),a=new sp(h,u),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":h=o(e.geometry),u=l(e.material),a=new It(h,u);break;case"InstancedMesh":h=o(e.geometry),u=l(e.material);const f=e.count,d=e.instanceMatrix,p=e.instanceColor;a=new cp(h,u,f),a.instanceMatrix=new $r(new Float32Array(d.array),16),p!==void 0&&(a.instanceColor=new $r(new Float32Array(p.array),p.itemSize));break;case"LOD":a=new Qd;break;case"Line":a=new Ri(o(e.geometry),l(e.material));break;case"LineLoop":a=new mp(o(e.geometry),l(e.material));break;case"LineSegments":a=new kn(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new _p(o(e.geometry),l(e.material));break;case"Sprite":a=new Kd(l(e.material));break;case"Group":a=new kr;break;case"Bone":a=new mh;break;default:a=new tt}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const f=e.children;for(let d=0;d<f.length;d++)a.add(this.parseObject(f[d],t,n,i,s))}if(e.animations!==void 0){const f=e.animations;for(let d=0;d<f.length;d++){const p=f[d];a.animations.push(s[p])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const f=e.levels;for(let d=0;d<f.length;d++){const p=f[d],_=a.getObjectByProperty("uuid",p.object);_!==void 0&&a.addLevel(_,p.distance,p.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const i=t[n.skeleton];i===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}}const WS={UVMapping:Sa,CubeReflectionMapping:pi,CubeRefractionMapping:mi,EquirectangularReflectionMapping:ms,EquirectangularRefractionMapping:gs,CubeUVReflectionMapping:mr},lm={RepeatWrapping:_s,ClampToEdgeWrapping:Dt,MirroredRepeatWrapping:xs},cm={NearestFilter:yt,NearestMipmapNearestFilter:ba,NearestMipmapLinearFilter:ys,LinearFilter:vt,LinearMipmapNearestFilter:Ql,LinearMipmapLinearFilter:gi};class XS extends en{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap=="undefined"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=ji.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){ji.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){i&&i(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}let Vo;class Vh{static getContext(){return Vo===void 0&&(Vo=new(window.AudioContext||window.webkitAudioContext)),Vo}static setContext(e){Vo=e}}class qS extends en{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new si(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);Vh.getContext().decodeAudioData(c,function(u){t(u)},o)}catch(c){o(c)}},n,i);function o(l){i?i(l):console.error(l),s.manager.itemError(e)}}}class $S extends Go{constructor(e,t,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;const i=new ye().set(e),s=new ye().set(t),a=new R(i.r,i.g,i.b),o=new R(s.r,s.g,s.b),l=Math.sqrt(Math.PI),c=l*Math.sqrt(.75);this.sh.coefficients[0].copy(a).add(o).multiplyScalar(l),this.sh.coefficients[1].copy(a).sub(o).multiplyScalar(c)}}class YS extends Go{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const n=new ye().set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const hm=new Be,um=new Be,Qi=new Be;class ZS{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Ut,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Ut,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Qi.copy(e.projectionMatrix);const i=t.eyeSep/2,s=i*t.near/t.focus,a=t.near*Math.tan(Bi*t.fov*.5)/t.zoom;let o,l;um.elements[12]=-i,hm.elements[12]=i,o=-a*t.aspect+s,l=a*t.aspect+s,Qi.elements[0]=2*t.near/(l-o),Qi.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(Qi),o=-a*t.aspect-s,l=a*t.aspect-s,Qi.elements[0]=2*t.near/(l-o),Qi.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(Qi)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(um),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(hm)}}class fm{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=dm(),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=dm();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function dm(){return(typeof performance=="undefined"?Date:performance).now()}const er=new R,pm=new Kt,JS=new R,tr=new R;class KS extends tt{constructor(){super(),this.type="AudioListener",this.context=Vh.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new fm}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(er,pm,JS),tr.set(0,0,-1).applyQuaternion(pm),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(er.x,i),t.positionY.linearRampToValueAtTime(er.y,i),t.positionZ.linearRampToValueAtTime(er.z,i),t.forwardX.linearRampToValueAtTime(tr.x,i),t.forwardY.linearRampToValueAtTime(tr.y,i),t.forwardZ.linearRampToValueAtTime(tr.z,i),t.upX.linearRampToValueAtTime(n.x,i),t.upY.linearRampToValueAtTime(n.y,i),t.upZ.linearRampToValueAtTime(n.z,i)}else t.setPosition(er.x,er.y,er.z),t.setOrientation(tr.x,tr.y,tr.z,n.x,n.y,n.z)}}class mm extends tt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const nr=new R,gm=new Kt,jS=new R,ir=new R;class QS extends mm{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(nr,gm,jS),ir.set(0,0,1).applyQuaternion(gm);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(nr.x,n),t.positionY.linearRampToValueAtTime(nr.y,n),t.positionZ.linearRampToValueAtTime(nr.z,n),t.orientationX.linearRampToValueAtTime(ir.x,n),t.orientationY.linearRampToValueAtTime(ir.y,n),t.orientationZ.linearRampToValueAtTime(ir.z,n)}else t.setPosition(nr.x,nr.y,nr.z),t.setOrientation(ir.x,ir.y,ir.z)}}class eb{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class _m{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,s,a;switch(t){case"quaternion":i=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,s=e*i+i;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==i;++o)n[s+o]=n[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(n,s,0,o,i)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(n,i,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,a=i;s!==a;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,s){if(i>=.5)for(let a=0;a!==s;++a)e[t+a]=e[n+a]}_slerp(e,t,n,i){Kt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){const a=this._workIndex*s;Kt.multiplyQuaternionsFlat(e,a,e,t,e,n),Kt.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,s){const a=1-i;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[n+o]*i}}_lerpAdditive(e,t,n,i,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[n+a]*i}}}const Wh="\\[\\]\\.:\\/",tb=new RegExp("["+Wh+"]","g"),Xh="[^"+Wh+"]",nb="[^"+Wh.replace("\\.","")+"]",ib=/((?:WC+[\/:])*)/.source.replace("WC",Xh),rb=/(WCOD+)?/.source.replace("WCOD",nb),sb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Xh),ab=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Xh),ob=new RegExp("^"+ib+rb+sb+ab+"$"),lb=["material","materials","bones","map"];class cb{constructor(e,t,n){const i=n||et.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class et{constructor(e,t,n){this.path=t,this.parsedPath=n||et.parseTrackName(t),this.node=et.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new et.Composite(e,t,n):new et(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(tb,"")}static parseTrackName(e){const t=ob.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);lb.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let s=t.propertyIndex;if(e||(e=et.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[i];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}et.Composite=cb,et.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},et.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},et.prototype.GetterByBindingType=[et.prototype._getValue_direct,et.prototype._getValue_array,et.prototype._getValue_arrayElement,et.prototype._getValue_toArray],et.prototype.SetterByBindingTypeAndVersioning=[[et.prototype._setValue_direct,et.prototype._setValue_direct_setNeedsUpdate,et.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[et.prototype._setValue_array,et.prototype._setValue_array_setNeedsUpdate,et.prototype._setValue_array_setMatrixWorldNeedsUpdate],[et.prototype._setValue_arrayElement,et.prototype._setValue_arrayElement_setNeedsUpdate,et.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[et.prototype._setValue_fromArray,et.prototype._setValue_fromArray_setNeedsUpdate,et.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class hb{constructor(){this.isAnimationObjectGroup=!0,this.uuid=on(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,i=arguments.length;n!==i;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,s=this._bindings,a=s.length;let o,l=e.length,c=this.nCachedObjects_;for(let h=0,u=arguments.length;h!==u;++h){const f=arguments[h],d=f.uuid;let p=t[d];if(p===void 0){p=l++,t[d]=p,e.push(f);for(let _=0,g=a;_!==g;++_)s[_].push(new et(f,n[_],i[_]))}else if(p<c){o=e[p];const _=--c,g=e[_];t[g.uuid]=p,e[p]=g,t[d]=_,e[_]=f;for(let m=0,y=a;m!==y;++m){const x=s[m],v=x[_];let M=x[p];x[p]=v,M===void 0&&(M=new et(f,n[m],i[m])),x[_]=M}}else e[p]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,h=t[c];if(h!==void 0&&h>=s){const u=s++,f=e[u];t[f.uuid]=h,e[h]=f,t[c]=u,e[u]=l;for(let d=0,p=i;d!==p;++d){const _=n[d],g=_[u],m=_[h];_[h]=g,_[u]=m}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],h=c.uuid,u=t[h];if(u!==void 0)if(delete t[h],u<s){const f=--s,d=e[f],p=--a,_=e[p];t[d.uuid]=u,e[u]=d,t[_.uuid]=f,e[f]=_,e.pop();for(let g=0,m=i;g!==m;++g){const y=n[g],x=y[f],v=y[p];y[u]=x,y[f]=v,y.pop()}}else{const f=--a,d=e[f];f>0&&(t[d.uuid]=u),e[u]=d,e.pop();for(let p=0,_=i;p!==_;++p){const g=n[p];g[u]=g[f],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const s=this._bindings;if(i!==void 0)return s[i];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,u=new Array(c);i=s.length,n[e]=i,a.push(e),o.push(t),s.push(u);for(let f=h,d=l.length;f!==d;++f){const p=l[f];u[f]=new et(p,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=n,a[n]=l,a.pop(),s[n]=s[o],s.pop(),i[n]=i[o],i.pop()}}}class xm{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:Fi,endingEnd:Fi};for(let c=0;c!==a;++c){const h=s[c].createInterpolant(null);o[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Uf,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,s=e._clip.duration,a=s/i,o=i/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,s=i.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Cc:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case La:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,s=this._loopCount;const a=n===Df;if(e===0)return s===-1?i:a&&(s&1)===1?t-i:i;if(n===If){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),i>=t||i<0){const o=Math.floor(i/t);i-=t*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(a&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=Oi,i.endingEnd=Oi):(e?i.endingStart=this.zeroSlopeAtStart?Oi:Fi:i.endingStart=Ss,t?i.endingEnd=this.zeroSlopeAtEnd?Oi:Fi:i.endingEnd=Ss)}_scheduleFading(e,t,n){const i=this._mixer,s=i.time;let a=this._weightInterpolant;a===null&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=n,this}}const ub=new Float32Array(1);class fb extends Zn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,a=e._propertyBindings,o=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==s;++u){const f=i[u],d=f.name;let p=h[d];if(p!==void 0)++p.referenceCount,a[u]=p;else{if(p=a[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,d));continue}const _=t&&t._propertyBindings[u].binding.parsedPath;p=new _m(et.create(n,d,_),f.ValueTypeName,f.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,d),a[u]=p}o[u].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],h=e._byClipCacheIndex;c._byClipCacheIndex=h,l[h]=c,l.pop(),e._byClipCacheIndex=null;const u=o.actionByRoot,f=(e._localRoot||this._root).uuid;delete u[f],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,s=this._bindings;let a=i[t];a===void 0&&(a={},i[t]=a),a[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,s=n.path,a=this._bindingsByRootAndName,o=a[i],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new Fh(new Float32Array(2),new Float32Array(2),1,ub),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,s=t[i];e.__cacheIndex=i,t[i]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){const i=t||this._root,s=i.uuid;let a=typeof e=="string"?ea.findByName(i,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let c=null;if(n===void 0&&(a!==null?n=a.blendMode:n=La),l!==void 0){const u=l.actionByRoot[s];if(u!==void 0&&u.blendMode===n)return u;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const h=new xm(this,a,t,n);return this._bindAction(h,c),this._addInactiveAction(h,o,s),h}existingAction(e,t){const n=t||this._root,i=n.uuid,s=typeof e=="string"?ea.findByName(n,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[i]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,s=i[n];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const h=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const a in n){const o=n[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const i=this._bindingsByRootAndName,s=i[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class qh{constructor(e){this.value=e}clone(){return new qh(this.value.clone===void 0?this.value:this.value.clone())}}let db=0;class pb extends Zn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:db++}),this.name="",this.usage=bs,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,i=t.length;n<i;n++)this.uniforms.push(t[n].clone());return this}clone(){return new this.constructor().copy(this)}}class mb extends ho{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class gb{constructor(e,t,n,i,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}class _b{constructor(e,t,n=0,i=1/0){this.ray=new Er(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Ga,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return $h(e,this,n,t),n.sort(ym),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)$h(e[i],this,n,t);return n.sort(ym),n}}function ym(r,e){return r.distance-e.distance}function $h(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){const i=r.children;for(let s=0,a=i.length;s<a;s++)$h(i[s],e,t,!0)}}class xb{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(ft(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class yb{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}const vm=new q;class vb{constructor(e=new q(1/0,1/0),t=new q(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=vm.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}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}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))}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)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vm).distanceTo(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}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)}}const Mm=new R,Wo=new R;class Mb{constructor(e=new R,t=new R){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Mm.subVectors(e,this.start),Wo.subVectors(this.end,this.start);const n=Wo.dot(Wo);let s=Wo.dot(Mm)/n;return t&&(s=ft(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Sm=new R;class Sb extends tt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Fe,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a<l;a++,o++){const c=a/l*Math.PI*2,h=o/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(h),Math.sin(h),1)}n.setAttribute("position",new ve(i,3));const s=new Vt({fog:!1,toneMapped:!1});this.cone=new kn(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Sm.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Sm),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Li=new R,Xo=new Be,Yh=new Be;class bb extends kn{constructor(e){const t=bm(e),n=new Fe,i=[],s=[],a=new ye(0,0,1),o=new ye(0,1,0);for(let c=0;c<t.length;c++){const h=t[c];h.parent&&h.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}n.setAttribute("position",new ve(i,3)),n.setAttribute("color",new ve(s,3));const l=new Vt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");Yh.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(Xo.multiplyMatrices(Yh,o.matrixWorld),Li.setFromMatrixPosition(Xo),i.setXYZ(a,Li.x,Li.y,Li.z),Xo.multiplyMatrices(Yh,o.parent.matrixWorld),Li.setFromMatrixPosition(Xo),i.setXYZ(a+1,Li.x,Li.y,Li.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function bm(r){const e=[];r.isBone===!0&&e.push(r);for(let t=0;t<r.children.length;t++)e.push.apply(e,bm(r.children[t]));return e}class wb extends It{constructor(e,t,n){const i=new Js(t,4,2),s=new Ai({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const Eb=new R,wm=new ye,Em=new ye;class Ab extends tt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new Zs(t);i.rotateY(Math.PI*.5),this.material=new Ai({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=i.getAttribute("position"),a=new Float32Array(s.count*3);i.setAttribute("color",new Ze(a,3)),this.add(new It(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");wm.copy(this.light.color),Em.copy(this.light.groundColor);for(let n=0,i=t.count;n<i;n++){const s=n<i/2?wm:Em;t.setXYZ(n,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(Eb.setFromMatrixPosition(this.light.matrixWorld).negate())}}class Tb extends kn{constructor(e=10,t=10,n=4473924,i=8947848){n=new ye(n),i=new ye(i);const s=t/2,a=e/t,o=e/2,l=[],c=[];for(let f=0,d=0,p=-o;f<=t;f++,p+=a){l.push(-o,0,p,o,0,p),l.push(p,0,-o,p,0,o);const _=f===s?n:i;_.toArray(c,d),d+=3,_.toArray(c,d),d+=3,_.toArray(c,d),d+=3,_.toArray(c,d),d+=3}const h=new Fe;h.setAttribute("position",new ve(l,3)),h.setAttribute("color",new ve(c,3));const u=new Vt({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Rb extends kn{constructor(e=10,t=16,n=8,i=64,s=4473924,a=8947848){s=new ye(s),a=new ye(a);const o=[],l=[];if(t>1)for(let u=0;u<t;u++){const f=u/t*(Math.PI*2),d=Math.sin(f)*e,p=Math.cos(f)*e;o.push(0,0,0),o.push(d,0,p);const _=u&1?s:a;l.push(_.r,_.g,_.b),l.push(_.r,_.g,_.b)}for(let u=0;u<n;u++){const f=u&1?s:a,d=e-e/n*u;for(let p=0;p<i;p++){let _=p/i*(Math.PI*2),g=Math.sin(_)*d,m=Math.cos(_)*d;o.push(g,0,m),l.push(f.r,f.g,f.b),_=(p+1)/i*(Math.PI*2),g=Math.sin(_)*d,m=Math.cos(_)*d,o.push(g,0,m),l.push(f.r,f.g,f.b)}}const c=new Fe;c.setAttribute("position",new ve(o,3)),c.setAttribute("color",new ve(l,3));const h=new Vt({vertexColors:!0,toneMapped:!1});super(c,h),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Am=new R,qo=new R,Tm=new R;class Cb extends tt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let i=new Fe;i.setAttribute("position",new ve([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Vt({fog:!1,toneMapped:!1});this.lightPlane=new Ri(i,s),this.add(this.lightPlane),i=new Fe,i.setAttribute("position",new ve([0,0,0,0,0,1],3)),this.targetLine=new Ri(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Am.setFromMatrixPosition(this.light.matrixWorld),qo.setFromMatrixPosition(this.light.target.matrixWorld),Tm.subVectors(qo,Am),this.lightPlane.lookAt(qo),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(qo),this.targetLine.scale.z=Tm.length()}}const $o=new R,dt=new eo;class Pb extends kn{constructor(e){const t=new Fe,n=new Vt({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(p,_){l(p),l(_)}function l(p){i.push(0,0,0),s.push(0,0,0),a[p]===void 0&&(a[p]=[]),a[p].push(i.length/3-1)}t.setAttribute("position",new ve(i,3)),t.setAttribute("color",new ve(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const c=new ye(16755200),h=new ye(16711680),u=new ye(43775),f=new ye(16777215),d=new ye(3355443);this.setColors(c,h,u,f,d)}setColors(e,t,n,i,s){const o=this.geometry.getAttribute("color");o.setXYZ(0,e.r,e.g,e.b),o.setXYZ(1,e.r,e.g,e.b),o.setXYZ(2,e.r,e.g,e.b),o.setXYZ(3,e.r,e.g,e.b),o.setXYZ(4,e.r,e.g,e.b),o.setXYZ(5,e.r,e.g,e.b),o.setXYZ(6,e.r,e.g,e.b),o.setXYZ(7,e.r,e.g,e.b),o.setXYZ(8,e.r,e.g,e.b),o.setXYZ(9,e.r,e.g,e.b),o.setXYZ(10,e.r,e.g,e.b),o.setXYZ(11,e.r,e.g,e.b),o.setXYZ(12,e.r,e.g,e.b),o.setXYZ(13,e.r,e.g,e.b),o.setXYZ(14,e.r,e.g,e.b),o.setXYZ(15,e.r,e.g,e.b),o.setXYZ(16,e.r,e.g,e.b),o.setXYZ(17,e.r,e.g,e.b),o.setXYZ(18,e.r,e.g,e.b),o.setXYZ(19,e.r,e.g,e.b),o.setXYZ(20,e.r,e.g,e.b),o.setXYZ(21,e.r,e.g,e.b),o.setXYZ(22,e.r,e.g,e.b),o.setXYZ(23,e.r,e.g,e.b),o.setXYZ(24,t.r,t.g,t.b),o.setXYZ(25,t.r,t.g,t.b),o.setXYZ(26,t.r,t.g,t.b),o.setXYZ(27,t.r,t.g,t.b),o.setXYZ(28,t.r,t.g,t.b),o.setXYZ(29,t.r,t.g,t.b),o.setXYZ(30,t.r,t.g,t.b),o.setXYZ(31,t.r,t.g,t.b),o.setXYZ(32,n.r,n.g,n.b),o.setXYZ(33,n.r,n.g,n.b),o.setXYZ(34,n.r,n.g,n.b),o.setXYZ(35,n.r,n.g,n.b),o.setXYZ(36,n.r,n.g,n.b),o.setXYZ(37,n.r,n.g,n.b),o.setXYZ(38,i.r,i.g,i.b),o.setXYZ(39,i.r,i.g,i.b),o.setXYZ(40,s.r,s.g,s.b),o.setXYZ(41,s.r,s.g,s.b),o.setXYZ(42,s.r,s.g,s.b),o.setXYZ(43,s.r,s.g,s.b),o.setXYZ(44,s.r,s.g,s.b),o.setXYZ(45,s.r,s.g,s.b),o.setXYZ(46,s.r,s.g,s.b),o.setXYZ(47,s.r,s.g,s.b),o.setXYZ(48,s.r,s.g,s.b),o.setXYZ(49,s.r,s.g,s.b),o.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,i=1;dt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),St("c",t,e,dt,0,0,-1),St("t",t,e,dt,0,0,1),St("n1",t,e,dt,-n,-i,-1),St("n2",t,e,dt,n,-i,-1),St("n3",t,e,dt,-n,i,-1),St("n4",t,e,dt,n,i,-1),St("f1",t,e,dt,-n,-i,1),St("f2",t,e,dt,n,-i,1),St("f3",t,e,dt,-n,i,1),St("f4",t,e,dt,n,i,1),St("u1",t,e,dt,n*.7,i*1.1,-1),St("u2",t,e,dt,-n*.7,i*1.1,-1),St("u3",t,e,dt,0,i*2,-1),St("cf1",t,e,dt,-n,0,1),St("cf2",t,e,dt,n,0,1),St("cf3",t,e,dt,0,-i,1),St("cf4",t,e,dt,0,i,1),St("cn1",t,e,dt,-n,0,-1),St("cn2",t,e,dt,n,0,-1),St("cn3",t,e,dt,0,-i,-1),St("cn4",t,e,dt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function St(r,e,t,n,i,s,a){$o.set(i,s,a).unproject(n);const o=e[r];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,h=o.length;c<h;c++)l.setXYZ(o[c],$o.x,$o.y,$o.z)}}const Yo=new _n;class Lb extends kn{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(8*3),s=new Fe;s.setIndex(new Ze(n,1)),s.setAttribute("position",new Ze(i,3)),super(s,new Vt({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Yo.setFromObject(this.object),Yo.isEmpty())return;const t=Yo.min,n=Yo.max,i=this.geometry.attributes.position,s=i.array;s[0]=n.x,s[1]=n.y,s[2]=n.z,s[3]=t.x,s[4]=n.y,s[5]=n.z,s[6]=t.x,s[7]=t.y,s[8]=n.z,s[9]=n.x,s[10]=t.y,s[11]=n.z,s[12]=n.x,s[13]=n.y,s[14]=t.z,s[15]=t.x,s[16]=n.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=n.x,s[22]=t.y,s[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ib extends kn{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Fe;s.setIndex(new Ze(n,1)),s.setAttribute("position",new ve(i,3)),super(s,new Vt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ub extends Ri{constructor(e,t=1,n=16776960){const i=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new Fe;a.setAttribute("position",new ve(s,3)),a.computeBoundingSphere(),super(a,new Vt({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new Fe;l.setAttribute("position",new ve(o,3)),l.computeBoundingSphere(),this.add(new It(l,new Ai({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Rm=new R;let Zo,Zh;class Db extends tt{constructor(e=new R(0,0,1),t=new R(0,0,0),n=1,i=16776960,s=n*.2,a=s*.2){super(),this.type="ArrowHelper",Zo===void 0&&(Zo=new Fe,Zo.setAttribute("position",new ve([0,0,0,0,1,0],3)),Zh=new Zr(0,.5,1,5,1),Zh.translate(0,-.5,0)),this.position.copy(t),this.line=new Ri(Zo,new Vt({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new It(Zh,new Ai({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Rm.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Rm,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Nb extends kn{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Fe;i.setAttribute("position",new ve(t,3)),i.setAttribute("color",new ve(n,3));const s=new Vt({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){const i=new ye,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Fb{constructor(){this.type="ShapePath",this.color=new ye,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Ws,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,a){return this.currentPath.bezierCurveTo(e,t,n,i,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(m){const y=[];for(let x=0,v=m.length;x<v;x++){const M=m[x],w=new ii;w.curves=M.curves,y.push(w)}return y}function n(m,y){const x=y.length;let v=!1;for(let M=x-1,w=0;w<x;M=w++){let A=y[M],C=y[w],S=C.x-A.x,b=C.y-A.y;if(Math.abs(b)>Number.EPSILON){if(b<0&&(A=y[w],S=-S,C=y[M],b=-b),m.y<A.y||m.y>C.y)continue;if(m.y===A.y){if(m.x===A.x)return!0}else{const L=b*(m.x-A.x)-S*(m.y-A.y);if(L===0)return!0;if(L<0)continue;v=!v}}else{if(m.y!==A.y)continue;if(C.x<=m.x&&m.x<=A.x||A.x<=m.x&&m.x<=C.x)return!0}}return v}const i=un.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new ii,l.curves=o.curves,c.push(l),c;let h=!i(s[0].getPoints());h=e?!h:h;const u=[],f=[];let d=[],p=0,_;f[p]=void 0,d[p]=[];for(let m=0,y=s.length;m<y;m++)o=s[m],_=o.getPoints(),a=i(_),a=e?!a:a,a?(!h&&f[p]&&p++,f[p]={s:new ii,p:_},f[p].s.curves=o.curves,h&&p++,d[p]=[]):d[p].push({h:o,p:_[0]});if(!f[0])return t(s);if(f.length>1){let m=!1,y=0;for(let x=0,v=f.length;x<v;x++)u[x]=[];for(let x=0,v=f.length;x<v;x++){const M=d[x];for(let w=0;w<M.length;w++){const A=M[w];let C=!0;for(let S=0;S<f.length;S++)n(A.p,f[S].p)&&(x!==S&&y++,C?(C=!1,u[S].push(A)):m=!0);C&&u[x].push(A)}}y>0&&m===!1&&(d=u)}let g;for(let m=0,y=f.length;m<y;m++){l=f[m].s,c.push(l),g=d[m];for(let x=0,v=g.length;x<v;x++)l.holes.push(g[x].h)}return c}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ot}})),typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ot);var Ob=Object.freeze({__proto__:null,ACESFilmicToneMapping:Mf,AddEquation:Di,AddOperation:_f,AdditiveAnimationBlendMode:Cc,AdditiveBlending:ql,AlphaFormat:Ef,AlwaysCompare:qf,AlwaysDepth:hf,AlwaysStencilFunc:Bf,AmbientLight:im,AmbientLightProbe:YS,AnimationAction:xm,AnimationClip:ea,AnimationLoader:NS,AnimationMixer:fb,AnimationObjectGroup:hb,AnimationUtils:LS,ArcCurve:yp,ArrayCamera:Vd,ArrowHelper:Db,Audio:mm,AudioAnalyser:eb,AudioContext:Vh,AudioListener:KS,AudioLoader:qS,AxesHelper:Nb,BackSide:kt,BasicDepthPacking:Nf,BasicShadowMap:ds,Bone:mh,BooleanKeyframeTrack:Ji,Box2:vb,Box3:_n,Box3Helper:Ib,BoxGeometry:Vi,BoxHelper:Lb,BufferAttribute:Ze,BufferGeometry:Fe,BufferGeometryLoader:om,ByteType:bf,Cache:ji,Camera:eo,CameraHelper:Pb,CanvasTexture:tS,CapsuleGeometry:wo,CatmullRomCurve3:vp,CineonToneMapping:vf,CircleGeometry:Eo,ClampToEdgeWrapping:Dt,Clock:fm,Color:ye,ColorKeyframeTrack:Oh,ColorManagement:gn,CompressedArrayTexture:eS,CompressedTexture:yh,CompressedTextureLoader:FS,ConeGeometry:Ao,CubeCamera:pd,CubeReflectionMapping:pi,CubeRefractionMapping:mi,CubeTexture:Ds,CubeTextureLoader:OS,CubeUVReflectionMapping:mr,CubicBezierCurve:wh,CubicBezierCurve3:Sp,CubicInterpolant:qp,CullFaceBack:dr,CullFaceFront:va,CullFaceFrontBack:Xl,CullFaceNone:Jt,Curve:Cn,CurvePath:wp,CustomBlending:Ju,CustomToneMapping:Sf,CylinderGeometry:Zr,Cylindrical:yb,Data3DTexture:zc,DataArrayTexture:Na,DataTexture:qr,DataTextureLoader:BS,DataUtils:G_,DecrementStencilOp:k0,DecrementWrapStencilOp:H0,DefaultLoadingManager:Zp,DepthFormat:xi,DepthStencilFormat:Ni,DepthTexture:Wd,DirectionalLight:nm,DirectionalLightHelper:Cb,DiscreteInterpolant:$p,DisplayP3ColorSpace:Lc,DodecahedronGeometry:To,DoubleSide:Nn,DstAlphaFactor:rf,DstColorFactor:af,DynamicCopyUsage:i_,DynamicDrawUsage:K0,DynamicReadUsage:e_,EdgesGeometry:Ep,EllipseCurve:Mo,EqualCompare:Gf,EqualDepth:ff,EqualStencilFunc:q0,EquirectangularReflectionMapping:ms,EquirectangularRefractionMapping:gs,Euler:Ps,EventDispatcher:Zn,ExtrudeGeometry:Ip,FileLoader:si,Float16BufferAttribute:$_,Float32BufferAttribute:ve,Float64BufferAttribute:Y_,FloatType:On,Fog:co,FogExp2:lo,FramebufferTexture:QM,FrontSide:Xn,Frustum:no,GLBufferAttribute:gb,GLSL1:s_,GLSL3:Ic,GreaterCompare:Vf,GreaterDepth:pf,GreaterEqualCompare:Xf,GreaterEqualDepth:df,GreaterEqualStencilFunc:J0,GreaterStencilFunc:Y0,GridHelper:Tb,Group:kr,HalfFloatType:gr,HemisphereLight:Jp,HemisphereLightHelper:Ab,HemisphereLightProbe:$S,IcosahedronGeometry:Do,ImageBitmapLoader:XS,ImageLoader:ta,ImageUtils:Oc,IncrementStencilOp:z0,IncrementWrapStencilOp:G0,InstancedBufferAttribute:$r,InstancedBufferGeometry:am,InstancedInterleavedBuffer:mb,InstancedMesh:cp,Int16BufferAttribute:X_,Int32BufferAttribute:q_,Int8BufferAttribute:H_,IntType:ec,InterleavedBuffer:ho,InterleavedBufferAttribute:$i,Interpolant:Ks,InterpolateDiscrete:vs,InterpolateLinear:Ms,InterpolateSmooth:Pa,InvertStencilOp:V0,KeepStencilOp:Ia,KeyframeTrack:Pn,LOD:Qd,LatheGeometry:Xs,Layers:Ga,LessCompare:kf,LessDepth:uf,LessEqualCompare:Hf,LessEqualDepth:Ma,LessEqualStencilFunc:$0,LessStencilFunc:X0,Light:Pi,LightProbe:Go,Line:Ri,Line3:Mb,LineBasicMaterial:Vt,LineCurve:bo,LineCurve3:bp,LineDashedMaterial:Wp,LineLoop:mp,LineSegments:kn,LinearEncoding:Pc,LinearFilter:vt,LinearInterpolant:Fh,LinearMipMapLinearFilter:U0,LinearMipMapNearestFilter:I0,LinearMipmapLinearFilter:gi,LinearMipmapNearestFilter:Ql,LinearSRGBColorSpace:Sn,LinearToneMapping:xf,Loader:en,LoaderUtils:Hh,LoadingManager:Bh,LoopOnce:If,LoopPingPong:Df,LoopRepeat:Uf,LuminanceAlphaFormat:Tf,LuminanceFormat:Af,MOUSE:At,Material:Ft,MaterialLoader:Ho,MathUtils:y_,Matrix3:Xe,Matrix4:Be,MaxEquation:Jl,Mesh:It,MeshBasicMaterial:Ai,MeshDepthMaterial:lh,MeshDistanceMaterial:ch,MeshLambertMaterial:Hp,MeshMatcapMaterial:Vp,MeshNormalMaterial:Gp,MeshPhongMaterial:zp,MeshPhysicalMaterial:Bp,MeshStandardMaterial:Ih,MeshToonMaterial:kp,MinEquation:Zl,MirroredRepeatWrapping:xs,MixOperation:gf,MultiplyBlending:Yl,MultiplyOperation:ps,NearestFilter:yt,NearestMipMapLinearFilter:L0,NearestMipMapNearestFilter:P0,NearestMipmapLinearFilter:ys,NearestMipmapNearestFilter:ba,NeverCompare:zf,NeverDepth:cf,NeverStencilFunc:W0,NoBlending:qn,NoColorSpace:Mi,NoToneMapping:Fn,NormalAnimationBlendMode:La,NormalBlending:Ui,NotEqualCompare:Wf,NotEqualDepth:mf,NotEqualStencilFunc:Z0,NumberKeyframeTrack:js,Object3D:tt,ObjectLoader:VS,ObjectSpaceNormalMap:Of,OctahedronGeometry:Zs,OneFactor:ef,OneMinusDstAlphaFactor:sf,OneMinusDstColorFactor:of,OneMinusSrcAlphaFactor:jl,OneMinusSrcColorFactor:nf,OrthographicCamera:ro,PCFShadowMap:Mn,PCFSoftShadowMap:pr,PMREMGenerator:rh,Path:Ws,PerspectiveCamera:Ut,Plane:Ti,PlaneGeometry:Ns,PlaneHelper:Ub,PointLight:tm,PointLightHelper:wb,Points:_p,PointsMaterial:_h,PolarGridHelper:Rb,PolyhedronGeometry:Ci,PositionalAudio:QS,PropertyBinding:et,PropertyMixer:_m,QuadraticBezierCurve:Eh,QuadraticBezierCurve3:Ah,Quaternion:Kt,QuaternionKeyframeTrack:Kr,QuaternionLinearInterpolant:Yp,RED_GREEN_RGTC2_Format:Tc,RED_RGTC1_Format:Lf,REVISION:ot,RGBADepthPacking:Ff,RGBAFormat:an,RGBAIntegerFormat:sc,RGBA_ASTC_10x10_Format:bc,RGBA_ASTC_10x5_Format:vc,RGBA_ASTC_10x6_Format:Mc,RGBA_ASTC_10x8_Format:Sc,RGBA_ASTC_12x10_Format:wc,RGBA_ASTC_12x12_Format:Ec,RGBA_ASTC_4x4_Format:fc,RGBA_ASTC_5x4_Format:dc,RGBA_ASTC_5x5_Format:pc,RGBA_ASTC_6x5_Format:mc,RGBA_ASTC_6x6_Format:gc,RGBA_ASTC_8x5_Format:_c,RGBA_ASTC_8x6_Format:xc,RGBA_ASTC_8x8_Format:yc,RGBA_BPTC_Format:Ca,RGBA_ETC2_EAC_Format:uc,RGBA_PVRTC_2BPPV1_Format:cc,RGBA_PVRTC_4BPPV1_Format:lc,RGBA_S3TC_DXT1_Format:Aa,RGBA_S3TC_DXT3_Format:Ta,RGBA_S3TC_DXT5_Format:Ra,RGB_ETC1_Format:Pf,RGB_ETC2_Format:hc,RGB_PVRTC_2BPPV1_Format:oc,RGB_PVRTC_4BPPV1_Format:ac,RGB_S3TC_DXT1_Format:Ea,RGFormat:Cf,RGIntegerFormat:rc,RawShaderMaterial:Op,Ray:Er,Raycaster:_b,RectAreaLight:rm,RedFormat:Rf,RedIntegerFormat:ic,ReinhardToneMapping:yf,RepeatWrapping:_s,ReplaceStencilOp:B0,ReverseSubtractEquation:ju,RingGeometry:No,SIGNED_RED_GREEN_RGTC2_Format:Rc,SIGNED_RED_RGTC1_Format:Ac,SRGBColorSpace:Ge,Scene:$d,ShaderChunk:Ve,ShaderLib:Rn,ShaderMaterial:zn,ShadowMaterial:Fp,Shape:ii,ShapeGeometry:Fo,ShapePath:Fb,ShapeUtils:un,ShortType:wf,Skeleton:go,SkeletonHelper:bb,SkinnedMesh:sp,Source:zi,Sphere:wn,SphereGeometry:Js,Spherical:xb,SphericalHarmonics3:sm,SplineCurve:Th,SpotLight:Qp,SpotLightHelper:Sb,Sprite:Kd,SpriteMaterial:uh,SrcAlphaFactor:Kl,SrcAlphaSaturateFactor:lf,SrcColorFactor:tf,StaticCopyUsage:n_,StaticDrawUsage:bs,StaticReadUsage:Q0,StereoCamera:ZS,StreamCopyUsage:r_,StreamDrawUsage:j0,StreamReadUsage:t_,StringKeyframeTrack:Ki,SubtractEquation:Ku,SubtractiveBlending:$l,TOUCH:xt,TangentSpaceNormalMap:vi,TetrahedronGeometry:Oo,Texture:Mt,TextureLoader:zS,TorusGeometry:Bo,TorusKnotGeometry:zo,Triangle:jt,TriangleFanDrawMode:F0,TriangleStripDrawMode:N0,TrianglesDrawMode:D0,TubeGeometry:ko,TwoPassDoubleSide:C0,UVMapping:Sa,Uint16BufferAttribute:Kc,Uint32BufferAttribute:jc,Uint8BufferAttribute:V_,Uint8ClampedBufferAttribute:W_,Uniform:qh,UniformsGroup:pb,UniformsLib:ge,UniformsUtils:dd,UnsignedByteType:$n,UnsignedInt248Type:_i,UnsignedIntType:Yn,UnsignedShort4444Type:tc,UnsignedShort5551Type:nc,UnsignedShortType:wa,VSMShadowMap:Dn,Vector2:q,Vector3:R,Vector4:rt,VectorKeyframeTrack:Qs,VideoTexture:jM,WebGL1Renderer:qd,WebGL3DRenderTarget:P_,WebGLArrayRenderTarget:C_,WebGLCoordinateSystem:Bn,WebGLCubeRenderTarget:md,WebGLMultipleRenderTargets:L_,WebGLRenderTarget:bn,WebGLRenderer:Xd,WebGLUtils:Hd,WebGPUCoordinateSystem:ws,WireframeGeometry:Up,WrapAroundEnding:Ss,ZeroCurvatureEnding:Fi,ZeroFactor:Qu,ZeroSlopeEnding:Oi,ZeroStencilOp:O0,_SRGBAFormat:Ua,sRGBEncoding:yi});const rr=new Map,Bb=(r={})=>({generateTopUV(e,t,n,i,s){const a=t[n*3],o=t[n*3+1],l=t[i*3],c=t[i*3+1],h=t[s*3],u=t[s*3+1];let f;if(rr.has(e))f=rr.get(e);else{let g=r.box3;if(!g)if(g=new _n,r.box3Set){const{min:y,max:x}=r.box3Set;g.set(new R(y.x,y.y,0),new R(x.x,x.y,0))}else{const x=e.parameters.shapes.getPoints().map(v=>[v.x,v.y,0]).flat();g.setFromArray(x)}const m=g.getSize(new R);r.split&&(m.y/=r.split),f={box:g,size:m},rr.set(e,f)}const{box:d,size:p}=f,_=r.split?1-r.split:0;return[new q((a-d.min.x)/p.x,(o-d.min.y)/p.y+_),new q((l-d.min.x)/p.x,(c-d.min.y)/p.y+_),new q((h-d.min.x)/p.x,(u-d.min.y)/p.y+_)]},generateSideWallUV(e,t,n,i,s,a){const o=t[n*3],l=t[n*3+1],c=t[n*3+2],h=t[i*3],u=t[i*3+1],f=t[i*3+2],d=t[s*3],p=t[s*3+1],_=t[s*3+2],g=t[a*3],m=t[a*3+1],y=t[a*3+2];let x;if(rr.has(t))x=rr.get(t);else{const w=new _n;w.setFromArray(t);const A=w.getSize(new R);r.split&&(A.z/=1-r.split),x={box:w,size:A},rr.set(t,x)}const{box:v,size:M}=x;return Math.abs(l-u)<Math.abs(o-h)?[new q((o-v.min.x)/M.x,(c-v.min.z)/M.z),new q((h-v.min.x)/M.x,(f-v.min.z)/M.z),new q((d-v.min.x)/M.x,(_-v.min.z)/M.z),new q((g-v.min.x)/M.x,(y-v.min.z)/M.z)]:[new q((l-v.min.y)/M.y,(c-v.min.z)/M.z),new q((u-v.min.y)/M.y,(f-v.min.z)/M.z),new q((p-v.min.y)/M.y,(_-v.min.z)/M.z),new q((m-v.min.y)/M.y,(y-v.min.z)/M.z)]}}),zb=()=>{rr.clear()};class Jh extends Fe{constructor(e=new ii([new q(.5,.5),new q(-.5,.5),new q(-.5,-.5),new q(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new ve(i,3)),this.setAttribute("uv",new ve(s,2)),this.computeVertexNormals();function a(o){var oe,re,Ee;const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1,u=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:d-.1,_=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const m=t.extrudePath,y=t.UVGenerator!==void 0?t.UVGenerator:kb,x=(oe=t.hasTop)!=null?oe:!0,v=(re=t.hasBottom)!=null?re:!0,M=(Ee=t.hasSide)!=null?Ee:!0;let w,A=!1,C,S,b,L;m&&(w=m.getSpacedPoints(h),A=!0,f=!1,C=m.computeFrenetFrames(h,!1),S=new R,b=new R,L=new R),f||(g=0,d=0,p=0,_=0);const k=o.extractPoints(c);let U=k.shape;const N=k.holes;if(!un.isClockWise(U)){U=U.reverse();for(let $=0,J=N.length;$<J;$++){const ne=N[$];un.isClockWise(ne)&&(N[$]=ne.reverse())}}const B=un.triangulateShape(U,N),O=U;for(let $=0,J=N.length;$<J;$++){const ne=N[$];U=U.concat(ne)}function H($,J,ne){return J||console.error("THREE.ExtrudeGeometry: vec does not exist"),$.clone().addScaledVector(J,ne)}const X=U.length,ee=B.length;function z($,J,ne){let de,pe,T;const E=$.x-J.x,W=$.y-J.y,se=ne.x-$.x,ie=ne.y-$.y,me=E*E+W*W,we=E*ie-W*se;if(Math.abs(we)>Number.EPSILON){const he=Math.sqrt(me),K=Math.sqrt(se*se+ie*ie),Re=J.x-W/he,Ce=J.y+E/he,Ie=ne.x-ie/K,be=ne.y+se/K,Me=((Ie-Re)*ie-(be-Ce)*se)/(E*ie-W*se);de=Re+E*Me-$.x,pe=Ce+W*Me-$.y;const qe=de*de+pe*pe;if(qe<=2)return new q(de,pe);T=Math.sqrt(qe/2)}else{let he=!1;E>Number.EPSILON?se>Number.EPSILON&&(he=!0):E<-Number.EPSILON?se<-Number.EPSILON&&(he=!0):Math.sign(W)===Math.sign(ie)&&(he=!0),he?(de=-W,pe=E,T=Math.sqrt(me)):(de=E,pe=W,T=Math.sqrt(me/2))}return new q(de/T,pe/T)}const Z=[];for(let $=0,J=O.length,ne=J-1,de=$+1;$<J;$++,ne++,de++)ne===J&&(ne=0),de===J&&(de=0),Z[$]=z(O[$],O[ne],O[de]);const le=[];let ce,fe=Z.concat();for(let $=0,J=N.length;$<J;$++){const ne=N[$];ce=[];for(let de=0,pe=ne.length,T=pe-1,E=de+1;de<pe;de++,T++,E++)T===pe&&(T=0),E===pe&&(E=0),ce[de]=z(ne[de],ne[T],ne[E]);le.push(ce),fe=fe.concat(ce)}for(let $=0;$<g;$++){const J=$/g,ne=d*Math.cos(J*Math.PI/2),de=p*Math.sin(J*Math.PI/2)+_;for(let pe=0,T=O.length;pe<T;pe++){const E=H(O[pe],Z[pe],de);je(E.x,E.y,-ne)}for(let pe=0,T=N.length;pe<T;pe++){const E=N[pe];ce=le[pe];for(let W=0,se=E.length;W<se;W++){const ie=H(E[W],ce[W],de);je(ie.x,ie.y,-ne)}}}const Ae=p+_;for(let $=0;$<X;$++){const J=f?H(U[$],fe[$],Ae):U[$];A?(b.copy(C.normals[0]).multiplyScalar(J.x),S.copy(C.binormals[0]).multiplyScalar(J.y),L.copy(w[0]).add(b).add(S),je(L.x,L.y,L.z)):je(J.x,J.y,0)}for(let $=1;$<=h;$++)for(let J=0;J<X;J++){const ne=f?H(U[J],fe[J],Ae):U[J];A?(b.copy(C.normals[$]).multiplyScalar(ne.x),S.copy(C.binormals[$]).multiplyScalar(ne.y),L.copy(w[$]).add(b).add(S),je(L.x,L.y,L.z)):je(ne.x,ne.y,u/h*$)}for(let $=g-1;$>=0;$--){const J=$/g,ne=d*Math.cos(J*Math.PI/2),de=p*Math.sin(J*Math.PI/2)+_;for(let pe=0,T=O.length;pe<T;pe++){const E=H(O[pe],Z[pe],de);je(E.x,E.y,u+ne)}for(let pe=0,T=N.length;pe<T;pe++){const E=N[pe];ce=le[pe];for(let W=0,se=E.length;W<se;W++){const ie=H(E[W],ce[W],de);A?je(ie.x,ie.y+w[h-1].y,w[h-1].x+ne):je(ie.x,ie.y,u+ne)}}}Pe(),M&&Te();function Pe(){const $=i.length/3;if(f){let J=0,ne=X*J;if(v)for(let de=0;de<ee;de++){const pe=B[de];Le(pe[2]+ne,pe[1]+ne,pe[0]+ne)}if(J=h+g*2,ne=X*J,x)for(let de=0;de<ee;de++){const pe=B[de];Le(pe[0]+ne,pe[1]+ne,pe[2]+ne)}}else{if(v)for(let J=0;J<ee;J++){const ne=B[J];Le(ne[2],ne[1],ne[0])}if(x)for(let J=0;J<ee;J++){const ne=B[J];Le(ne[0]+X*h,ne[1]+X*h,ne[2]+X*h)}}n.addGroup($,i.length/3-$,0)}function Te(){const $=i.length/3;let J=0;Ke(O,J),J+=O.length;for(let ne=0,de=N.length;ne<de;ne++){const pe=N[ne];Ke(pe,J),J+=pe.length}n.addGroup($,i.length/3-$,1)}function Ke($,J){let ne=$.length;for(;--ne>=0;){const de=ne;let pe=ne-1;pe<0&&(pe=$.length-1);for(let T=0,E=h+g*2;T<E;T++){const W=X*T,se=X*(T+1),ie=J+de+W,me=J+pe+W,we=J+pe+se,he=J+de+se;D(ie,me,we,he)}}}function je($,J,ne){l.push($),l.push(J),l.push(ne)}function Le($,J,ne){ae($),ae(J),ae(ne);const de=i.length/3,pe=y.generateTopUV(n,i,de-3,de-2,de-1);Q(pe[0]),Q(pe[1]),Q(pe[2])}function D($,J,ne,de){ae($),ae(J),ae(de),ae(J),ae(ne),ae(de);const pe=i.length/3,T=y.generateSideWallUV(n,i,pe-6,pe-3,pe-2,pe-1);Q(T[0]),Q(T[1]),Q(T[3]),Q(T[1]),Q(T[2]),Q(T[3])}function ae($){i.push(l[$*3+0]),i.push(l[$*3+1]),i.push(l[$*3+2])}function Q($){s.push($.x),s.push($.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return Gb(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];n.push(o)}const i=e.options.extrudePath;return console.log(i.type),i!==void 0&&(e.options.extrudePath=new Ob[`${i.type}Curve`]().fromJSON(i)),new Jh(n,e.options)}}const kb={generateTopUV:function(r,e,t,n,i){const s=e[t*3],a=e[t*3+1],o=e[n*3],l=e[n*3+1],c=e[i*3],h=e[i*3+1];return[new q(s,a),new q(o,l),new q(c,h)]},generateSideWallUV:function(r,e,t,n,i,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[n*3],h=e[n*3+1],u=e[n*3+2],f=e[i*3],d=e[i*3+1],p=e[i*3+2],_=e[s*3],g=e[s*3+1],m=e[s*3+2];return Math.abs(o-h)<Math.abs(a-c)?[new q(a,1-l),new q(c,1-u),new q(f,1-p),new q(_,1-m)]:[new q(o,1-l),new q(h,1-u),new q(d,1-p),new q(g,1-m)]}};function Gb(r,e,t){if(t.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){const s=r[n];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}var Hb=r=>{const{split:e,depth:t,points:n,box3:i,hasTop:s,hasBottom:a,hasSide:o,box3Set:l}=r,c=new Jh(new ii(n),{depth:t,bevelEnabled:!1,UVGenerator:Bb({split:e,box3:i,box3Set:l}),hasTop:s,hasBottom:a,hasSide:o});return zb(),c};function Jo(r,e){return r==null||e==null?NaN:r<e?-1:r>e?1:r>=e?0:NaN}function Vb(r,e){return r==null||e==null?NaN:e<r?-1:e>r?1:e>=r?0:NaN}function Cm(r){let e,t,n;r.length!==2?(e=Jo,t=(o,l)=>Jo(r(o),l),n=(o,l)=>r(o)-l):(e=r===Jo||r===Vb?r:Wb,t=r,n=r);function i(o,l,c=0,h=o.length){if(c<h){if(e(l,l)!==0)return h;do{const u=c+h>>>1;t(o[u],l)<0?c=u+1:h=u}while(c<h)}return c}function s(o,l,c=0,h=o.length){if(c<h){if(e(l,l)!==0)return h;do{const u=c+h>>>1;t(o[u],l)<=0?c=u+1:h=u}while(c<h)}return c}function a(o,l,c=0,h=o.length){const u=i(o,l,c,h-1);return u>c&&n(o[u-1],l)>-n(o[u],l)?u-1:u}return{left:i,center:a,right:s}}function Wb(){return 0}function Xb(r){return r===null?NaN:+r}const qb=Cm(Jo).right;Cm(Xb).center;var $b=qb;function Ko(r,e){let t,n;if(e===void 0)for(const i of r)i!=null&&(t===void 0?i>=i&&(t=n=i):(t>i&&(t=i),n<i&&(n=i)));else{let i=-1;for(let s of r)(s=e(s,++i,r))!=null&&(t===void 0?s>=s&&(t=n=s):(t>s&&(t=s),n<s&&(n=s)))}return[t,n]}class ai{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){const t=this._partials;let n=0;for(let i=0;i<this._n&&i<32;i++){const s=t[i],a=e+s,o=Math.abs(e)<Math.abs(s)?e-(a-s):s-(a-e);o&&(t[n++]=o),e=a}return t[n]=e,this._n=n+1,this}valueOf(){const e=this._partials;let t=this._n,n,i,s,a=0;if(t>0){for(a=e[--t];t>0&&(n=a,i=e[--t],a=n+i,s=i-(a-n),!s););t>0&&(s<0&&e[t-1]<0||s>0&&e[t-1]>0)&&(i=s*2,n=a+i,i==n-a&&(a=n))}return a}}const Yb=Math.sqrt(50),Zb=Math.sqrt(10),Jb=Math.sqrt(2);function jo(r,e,t){const n=(e-r)/Math.max(0,t),i=Math.floor(Math.log10(n)),s=n/Math.pow(10,i),a=s>=Yb?10:s>=Zb?5:s>=Jb?2:1;let o,l,c;return i<0?(c=Math.pow(10,-i)/a,o=Math.round(r*c),l=Math.round(e*c),o/c<r&&++o,l/c>e&&--l,c=-c):(c=Math.pow(10,i)*a,o=Math.round(r/c),l=Math.round(e/c),o*c<r&&++o,l*c>e&&--l),l<o&&.5<=t&&t<2?jo(r,e,t*2):[o,l,c]}function Kb(r,e,t){if(e=+e,r=+r,t=+t,!(t>0))return[];if(r===e)return[r];const n=e<r,[i,s,a]=n?jo(e,r,t):jo(r,e,t);if(!(s>=i))return[];const o=s-i+1,l=new Array(o);if(n)if(a<0)for(let c=0;c<o;++c)l[c]=(s-c)/-a;else for(let c=0;c<o;++c)l[c]=(s-c)*a;else if(a<0)for(let c=0;c<o;++c)l[c]=(i+c)/-a;else for(let c=0;c<o;++c)l[c]=(i+c)*a;return l}function Kh(r,e,t){return e=+e,r=+r,t=+t,jo(r,e,t)[2]}function jb(r,e,t){e=+e,r=+r,t=+t;const n=e<r,i=n?Kh(e,r,t):Kh(r,e,t);return(n?-1:1)*(i<0?1/-i:i)}function Qb(r,e){let t=0,n=0;if(e===void 0)for(let i of r)i!=null&&(i=+i)>=i&&(++t,n+=i);else{let i=-1;for(let s of r)(s=e(s,++i,r))!=null&&(s=+s)>=s&&(++t,n+=s)}if(t)return n/t}function*e1(r){for(const e of r)yield*e}function ia(r){return Array.from(e1(r))}var it=1e-6,Qo=1e-12,Je=Math.PI,tn=Je/2,el=Je/4,nn=Je*2,pt=180/Je,Ne=Je/180,st=Math.abs,jh=Math.atan,vn=Math.atan2,ze=Math.cos,t1=Math.exp,Qh=Math.hypot,n1=Math.log,De=Math.sin,i1=Math.sign||function(r){return r>0?1:r<0?-1:0},oi=Math.sqrt,r1=Math.tan;function s1(r){return r>1?0:r<-1?Je:Math.acos(r)}function li(r){return r>1?tn:r<-1?-tn:Math.asin(r)}function Pm(r){return(r=De(r/2))*r}function Bt(){}function tl(r,e){r&&Im.hasOwnProperty(r.type)&&Im[r.type](r,e)}var Lm={Feature:function(r,e){tl(r.geometry,e)},FeatureCollection:function(r,e){for(var t=r.features,n=-1,i=t.length;++n<i;)tl(t[n].geometry,e)}},Im={Sphere:function(r,e){e.sphere()},Point:function(r,e){r=r.coordinates,e.point(r[0],r[1],r[2])},MultiPoint:function(r,e){for(var t=r.coordinates,n=-1,i=t.length;++n<i;)r=t[n],e.point(r[0],r[1],r[2])},LineString:function(r,e){eu(r.coordinates,e,0)},MultiLineString:function(r,e){for(var t=r.coordinates,n=-1,i=t.length;++n<i;)eu(t[n],e,0)},Polygon:function(r,e){Um(r.coordinates,e)},MultiPolygon:function(r,e){for(var t=r.coordinates,n=-1,i=t.length;++n<i;)Um(t[n],e)},GeometryCollection:function(r,e){for(var t=r.geometries,n=-1,i=t.length;++n<i;)tl(t[n],e)}};function eu(r,e,t){var n=-1,i=r.length-t,s;for(e.lineStart();++n<i;)s=r[n],e.point(s[0],s[1],s[2]);e.lineEnd()}function Um(r,e){var t=-1,n=r.length;for(e.polygonStart();++t<n;)eu(r[t],e,1);e.polygonEnd()}function nl(r,e){r&&Lm.hasOwnProperty(r.type)?Lm[r.type](r,e):tl(r,e)}var il=new ai,Dm=new ai,Nm,Fm,tu,nu,iu,ci={point:Bt,lineStart:Bt,lineEnd:Bt,polygonStart:function(){il=new ai,ci.lineStart=a1,ci.lineEnd=o1},polygonEnd:function(){var r=+il;Dm.add(r<0?nn+r:r),this.lineStart=this.lineEnd=this.point=Bt},sphere:function(){Dm.add(nn)}};function a1(){ci.point=l1}function o1(){Om(Nm,Fm)}function l1(r,e){ci.point=Om,Nm=r,Fm=e,r*=Ne,e*=Ne,tu=r,nu=ze(e=e/2+el),iu=De(e)}function Om(r,e){r*=Ne,e*=Ne,e=e/2+el;var t=r-tu,n=t>=0?1:-1,i=n*t,s=ze(e),a=De(e),o=iu*a,l=nu*s+o*ze(i),c=o*n*De(i);il.add(vn(c,l)),tu=r,nu=s,iu=a}function rl(r){return[vn(r[1],r[0]),li(r[2])]}function sr(r){var e=r[0],t=r[1],n=ze(t);return[n*ze(e),n*De(e),De(t)]}function sl(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]}function jr(r,e){return[r[1]*e[2]-r[2]*e[1],r[2]*e[0]-r[0]*e[2],r[0]*e[1]-r[1]*e[0]]}function ru(r,e){r[0]+=e[0],r[1]+=e[1],r[2]+=e[2]}function al(r,e){return[r[0]*e,r[1]*e,r[2]*e]}function ol(r){var e=oi(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);r[0]/=e,r[1]/=e,r[2]/=e}var ct,rn,mt,fn,ar,Bm,zm,Qr,ra,Ii,hi,ui={point:su,lineStart:Gm,lineEnd:Hm,polygonStart:function(){ui.point=Vm,ui.lineStart=c1,ui.lineEnd=h1,ra=new ai,ci.polygonStart()},polygonEnd:function(){ci.polygonEnd(),ui.point=su,ui.lineStart=Gm,ui.lineEnd=Hm,il<0?(ct=-(mt=180),rn=-(fn=90)):ra>it?fn=90:ra<-it&&(rn=-90),hi[0]=ct,hi[1]=mt},sphere:function(){ct=-(mt=180),rn=-(fn=90)}};function su(r,e){Ii.push(hi=[ct=r,mt=r]),e<rn&&(rn=e),e>fn&&(fn=e)}function km(r,e){var t=sr([r*Ne,e*Ne]);if(Qr){var n=jr(Qr,t),i=[n[1],-n[0],0],s=jr(i,n);ol(s),s=rl(s);var a=r-ar,o=a>0?1:-1,l=s[0]*pt*o,c,h=st(a)>180;h^(o*ar<l&&l<o*r)?(c=s[1]*pt,c>fn&&(fn=c)):(l=(l+360)%360-180,h^(o*ar<l&&l<o*r)?(c=-s[1]*pt,c<rn&&(rn=c)):(e<rn&&(rn=e),e>fn&&(fn=e))),h?r<ar?dn(ct,r)>dn(ct,mt)&&(mt=r):dn(r,mt)>dn(ct,mt)&&(ct=r):mt>=ct?(r<ct&&(ct=r),r>mt&&(mt=r)):r>ar?dn(ct,r)>dn(ct,mt)&&(mt=r):dn(r,mt)>dn(ct,mt)&&(ct=r)}else Ii.push(hi=[ct=r,mt=r]);e<rn&&(rn=e),e>fn&&(fn=e),Qr=t,ar=r}function Gm(){ui.point=km}function Hm(){hi[0]=ct,hi[1]=mt,ui.point=su,Qr=null}function Vm(r,e){if(Qr){var t=r-ar;ra.add(st(t)>180?t+(t>0?360:-360):t)}else Bm=r,zm=e;ci.point(r,e),km(r,e)}function c1(){ci.lineStart()}function h1(){Vm(Bm,zm),ci.lineEnd(),st(ra)>it&&(ct=-(mt=180)),hi[0]=ct,hi[1]=mt,Qr=null}function dn(r,e){return(e-=r)<0?e+360:e}function u1(r,e){return r[0]-e[0]}function Wm(r,e){return r[0]<=r[1]?r[0]<=e&&e<=r[1]:e<r[0]||r[1]<e}function Xm(r){var e,t,n,i,s,a,o;if(fn=mt=-(ct=rn=1/0),Ii=[],nl(r,ui),t=Ii.length){for(Ii.sort(u1),e=1,n=Ii[0],s=[n];e<t;++e)i=Ii[e],Wm(n,i[0])||Wm(n,i[1])?(dn(n[0],i[1])>dn(n[0],n[1])&&(n[1]=i[1]),dn(i[0],n[1])>dn(n[0],n[1])&&(n[0]=i[0])):s.push(n=i);for(a=-1/0,t=s.length-1,e=0,n=s[t];e<=t;n=i,++e)i=s[e],(o=dn(n[1],i[0]))>a&&(a=o,ct=i[0],mt=n[1])}return Ii=hi=null,ct===1/0||rn===1/0?[[NaN,NaN],[NaN,NaN]]:[[ct,rn],[mt,fn]]}var sa,ll,cl,hl,ul,fl,dl,pl,au,ou,lu,qm,$m,Wt,Xt,qt,Ln={sphere:Bt,point:cu,lineStart:Ym,lineEnd:Zm,polygonStart:function(){Ln.lineStart=p1,Ln.lineEnd=m1},polygonEnd:function(){Ln.lineStart=Ym,Ln.lineEnd=Zm}};function cu(r,e){r*=Ne,e*=Ne;var t=ze(e);aa(t*ze(r),t*De(r),De(e))}function aa(r,e,t){++sa,cl+=(r-cl)/sa,hl+=(e-hl)/sa,ul+=(t-ul)/sa}function Ym(){Ln.point=f1}function f1(r,e){r*=Ne,e*=Ne;var t=ze(e);Wt=t*ze(r),Xt=t*De(r),qt=De(e),Ln.point=d1,aa(Wt,Xt,qt)}function d1(r,e){r*=Ne,e*=Ne;var t=ze(e),n=t*ze(r),i=t*De(r),s=De(e),a=vn(oi((a=Xt*s-qt*i)*a+(a=qt*n-Wt*s)*a+(a=Wt*i-Xt*n)*a),Wt*n+Xt*i+qt*s);ll+=a,fl+=a*(Wt+(Wt=n)),dl+=a*(Xt+(Xt=i)),pl+=a*(qt+(qt=s)),aa(Wt,Xt,qt)}function Zm(){Ln.point=cu}function p1(){Ln.point=g1}function m1(){Jm(qm,$m),Ln.point=cu}function g1(r,e){qm=r,$m=e,r*=Ne,e*=Ne,Ln.point=Jm;var t=ze(e);Wt=t*ze(r),Xt=t*De(r),qt=De(e),aa(Wt,Xt,qt)}function Jm(r,e){r*=Ne,e*=Ne;var t=ze(e),n=t*ze(r),i=t*De(r),s=De(e),a=Xt*s-qt*i,o=qt*n-Wt*s,l=Wt*i-Xt*n,c=Qh(a,o,l),h=li(c),u=c&&-h/c;au.add(u*a),ou.add(u*o),lu.add(u*l),ll+=h,fl+=h*(Wt+(Wt=n)),dl+=h*(Xt+(Xt=i)),pl+=h*(qt+(qt=s)),aa(Wt,Xt,qt)}function Km(r){sa=ll=cl=hl=ul=fl=dl=pl=0,au=new ai,ou=new ai,lu=new ai,nl(r,Ln);var e=+au,t=+ou,n=+lu,i=Qh(e,t,n);return i<Qo&&(e=fl,t=dl,n=pl,ll<it&&(e=cl,t=hl,n=ul),i=Qh(e,t,n),i<Qo)?[NaN,NaN]:[vn(t,e)*pt,li(n/i)*pt]}function hu(r,e){function t(n,i){return n=r(n,i),e(n[0],n[1])}return r.invert&&e.invert&&(t.invert=function(n,i){return n=e.invert(n,i),n&&r.invert(n[0],n[1])}),t}function uu(r,e){return st(r)>Je&&(r-=Math.round(r/nn)*nn),[r,e]}uu.invert=uu;function jm(r,e,t){return(r%=nn)?e||t?hu(eg(r),tg(e,t)):eg(r):e||t?tg(e,t):uu}function Qm(r){return function(e,t){return e+=r,st(e)>Je&&(e-=Math.round(e/nn)*nn),[e,t]}}function eg(r){var e=Qm(r);return e.invert=Qm(-r),e}function tg(r,e){var t=ze(r),n=De(r),i=ze(e),s=De(e);function a(o,l){var c=ze(l),h=ze(o)*c,u=De(o)*c,f=De(l),d=f*t+h*n;return[vn(u*i-d*s,h*t-f*n),li(d*i+u*s)]}return a.invert=function(o,l){var c=ze(l),h=ze(o)*c,u=De(o)*c,f=De(l),d=f*i-u*s;return[vn(u*i+f*s,h*t+d*n),li(d*t-h*n)]},a}function ng(r){r=jm(r[0]*Ne,r[1]*Ne,r.length>2?r[2]*Ne:0);function e(t){return t=r(t[0]*Ne,t[1]*Ne),t[0]*=pt,t[1]*=pt,t}return e.invert=function(t){return t=r.invert(t[0]*Ne,t[1]*Ne),t[0]*=pt,t[1]*=pt,t},e}function _1(r,e,t,n,i,s){if(t){var a=ze(e),o=De(e),l=n*t;i==null?(i=e+n*nn,s=e-l/2):(i=ig(a,i),s=ig(a,s),(n>0?i<s:i>s)&&(i+=n*nn));for(var c,h=i;n>0?h>s:h<s;h-=l)c=rl([a,-o*ze(h),-o*De(h)]),r.point(c[0],c[1])}}function ig(r,e){e=sr(e),e[0]-=r,ol(e);var t=s1(-e[1]);return((-e[2]<0?-t:t)+nn-it)%nn}function rg(){var r=[],e;return{point:function(t,n,i){e.push([t,n,i])},lineStart:function(){r.push(e=[])},lineEnd:Bt,rejoin:function(){r.length>1&&r.push(r.pop().concat(r.shift()))},result:function(){var t=r;return r=[],e=null,t}}}function ml(r,e){return st(r[0]-e[0])<it&&st(r[1]-e[1])<it}function gl(r,e,t,n){this.x=r,this.z=e,this.o=t,this.e=n,this.v=!1,this.n=this.p=null}function sg(r,e,t,n,i){var s=[],a=[],o,l;if(r.forEach(function(p){if(!((_=p.length-1)<=0)){var _,g=p[0],m=p[_],y;if(ml(g,m)){if(!g[2]&&!m[2]){for(i.lineStart(),o=0;o<_;++o)i.point((g=p[o])[0],g[1]);i.lineEnd();return}m[0]+=2*it}s.push(y=new gl(g,p,null,!0)),a.push(y.o=new gl(g,null,y,!1)),s.push(y=new gl(m,p,null,!1)),a.push(y.o=new gl(m,null,y,!0))}}),!!s.length){for(a.sort(e),ag(s),ag(a),o=0,l=a.length;o<l;++o)a[o].e=t=!t;for(var c=s[0],h,u;;){for(var f=c,d=!0;f.v;)if((f=f.n)===c)return;h=f.z,i.lineStart();do{if(f.v=f.o.v=!0,f.e){if(d)for(o=0,l=h.length;o<l;++o)i.point((u=h[o])[0],u[1]);else n(f.x,f.n.x,1,i);f=f.n}else{if(d)for(h=f.p.z,o=h.length-1;o>=0;--o)i.point((u=h[o])[0],u[1]);else n(f.x,f.p.x,-1,i);f=f.p}f=f.o,h=f.z,d=!d}while(!f.v);i.lineEnd()}}}function ag(r){if(e=r.length){for(var e,t=0,n=r[0],i;++t<e;)n.n=i=r[t],i.p=n,n=i;n.n=i=r[0],i.p=n}}function fu(r){return st(r[0])<=Je?r[0]:i1(r[0])*((st(r[0])+Je)%nn-Je)}function og(r,e){var t=fu(e),n=e[1],i=De(n),s=[De(t),-ze(t),0],a=0,o=0,l=new ai;i===1?n=tn+it:i===-1&&(n=-tn-it);for(var c=0,h=r.length;c<h;++c)if(f=(u=r[c]).length)for(var u,f,d=u[f-1],p=fu(d),_=d[1]/2+el,g=De(_),m=ze(_),y=0;y<f;++y,p=v,g=w,m=A,d=x){var x=u[y],v=fu(x),M=x[1]/2+el,w=De(M),A=ze(M),C=v-p,S=C>=0?1:-1,b=S*C,L=b>Je,k=g*w;if(l.add(vn(k*S*De(b),m*A+k*ze(b))),a+=L?C+S*nn:C,L^p>=t^v>=t){var U=jr(sr(d),sr(x));ol(U);var N=jr(s,U);ol(N);var I=(L^C>=0?-1:1)*li(N[2]);(n>I||n===I&&(U[0]||U[1]))&&(o+=L^C>=0?1:-1)}}return(a<-it||a<it&&l<-Qo)^o&1}function lg(r,e,t,n){return function(i){var s=e(i),a=rg(),o=e(a),l=!1,c,h,u,f={point:d,lineStart:_,lineEnd:g,polygonStart:function(){f.point=m,f.lineStart=y,f.lineEnd=x,h=[],c=[]},polygonEnd:function(){f.point=d,f.lineStart=_,f.lineEnd=g,h=ia(h);var v=og(c,n);h.length?(l||(i.polygonStart(),l=!0),sg(h,y1,v,t,i)):v&&(l||(i.polygonStart(),l=!0),i.lineStart(),t(null,null,1,i),i.lineEnd()),l&&(i.polygonEnd(),l=!1),h=c=null},sphere:function(){i.polygonStart(),i.lineStart(),t(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function d(v,M){r(v,M)&&i.point(v,M)}function p(v,M){s.point(v,M)}function _(){f.point=p,s.lineStart()}function g(){f.point=d,s.lineEnd()}function m(v,M){u.push([v,M]),o.point(v,M)}function y(){o.lineStart(),u=[]}function x(){m(u[0][0],u[0][1]),o.lineEnd();var v=o.clean(),M=a.result(),w,A=M.length,C,S,b;if(u.pop(),c.push(u),u=null,!!A){if(v&1){if(S=M[0],(C=S.length-1)>0){for(l||(i.polygonStart(),l=!0),i.lineStart(),w=0;w<C;++w)i.point((b=S[w])[0],b[1]);i.lineEnd()}return}A>1&&v&2&&M.push(M.pop().concat(M.shift())),h.push(M.filter(x1))}}return f}}function x1(r){return r.length>1}function y1(r,e){return((r=r.x)[0]<0?r[1]-tn-it:tn-r[1])-((e=e.x)[0]<0?e[1]-tn-it:tn-e[1])}var cg=lg(function(){return!0},v1,S1,[-Je,-tn]);function v1(r){var e=NaN,t=NaN,n=NaN,i;return{lineStart:function(){r.lineStart(),i=1},point:function(s,a){var o=s>0?Je:-Je,l=st(s-e);st(l-Je)<it?(r.point(e,t=(t+a)/2>0?tn:-tn),r.point(n,t),r.lineEnd(),r.lineStart(),r.point(o,t),r.point(s,t),i=0):n!==o&&l>=Je&&(st(e-n)<it&&(e-=n*it),st(s-o)<it&&(s-=o*it),t=M1(e,t,s,a),r.point(n,t),r.lineEnd(),r.lineStart(),r.point(o,t),i=0),r.point(e=s,t=a),n=o},lineEnd:function(){r.lineEnd(),e=t=NaN},clean:function(){return 2-i}}}function M1(r,e,t,n){var i,s,a=De(r-t);return st(a)>it?jh((De(e)*(s=ze(n))*De(t)-De(n)*(i=ze(e))*De(r))/(i*s*a)):(e+n)/2}function S1(r,e,t,n){var i;if(r==null)i=t*tn,n.point(-Je,i),n.point(0,i),n.point(Je,i),n.point(Je,0),n.point(Je,-i),n.point(0,-i),n.point(-Je,-i),n.point(-Je,0),n.point(-Je,i);else if(st(r[0]-e[0])>it){var s=r[0]<e[0]?Je:-Je;i=t*s/2,n.point(-s,i),n.point(0,i),n.point(s,i)}else n.point(e[0],e[1])}function b1(r){var e=ze(r),t=6*Ne,n=e>0,i=st(e)>it;function s(h,u,f,d){_1(d,r,t,f,h,u)}function a(h,u){return ze(h)*ze(u)>e}function o(h){var u,f,d,p,_;return{lineStart:function(){p=d=!1,_=1},point:function(g,m){var y=[g,m],x,v=a(g,m),M=n?v?0:c(g,m):v?c(g+(g<0?Je:-Je),m):0;if(!u&&(p=d=v)&&h.lineStart(),v!==d&&(x=l(u,y),(!x||ml(u,x)||ml(y,x))&&(y[2]=1)),v!==d)_=0,v?(h.lineStart(),x=l(y,u),h.point(x[0],x[1])):(x=l(u,y),h.point(x[0],x[1],2),h.lineEnd()),u=x;else if(i&&u&&n^v){var w;!(M&f)&&(w=l(y,u,!0))&&(_=0,n?(h.lineStart(),h.point(w[0][0],w[0][1]),h.point(w[1][0],w[1][1]),h.lineEnd()):(h.point(w[1][0],w[1][1]),h.lineEnd(),h.lineStart(),h.point(w[0][0],w[0][1],3)))}v&&(!u||!ml(u,y))&&h.point(y[0],y[1]),u=y,d=v,f=M},lineEnd:function(){d&&h.lineEnd(),u=null},clean:function(){return _|(p&&d)<<1}}}function l(h,u,f){var d=sr(h),p=sr(u),_=[1,0,0],g=jr(d,p),m=sl(g,g),y=g[0],x=m-y*y;if(!x)return!f&&h;var v=e*m/x,M=-e*y/x,w=jr(_,g),A=al(_,v),C=al(g,M);ru(A,C);var S=w,b=sl(A,S),L=sl(S,S),k=b*b-L*(sl(A,A)-1);if(!(k<0)){var U=oi(k),N=al(S,(-b-U)/L);if(ru(N,A),N=rl(N),!f)return N;var I=h[0],B=u[0],O=h[1],H=u[1],X;B<I&&(X=I,I=B,B=X);var ee=B-I,z=st(ee-Je)<it,Z=z||ee<it;if(!z&&H<O&&(X=O,O=H,H=X),Z?z?O+H>0^N[1]<(st(N[0]-I)<it?O:H):O<=N[1]&&N[1]<=H:ee>Je^(I<=N[0]&&N[0]<=B)){var le=al(S,(-b+U)/L);return ru(le,A),[N,rl(le)]}}}function c(h,u){var f=n?r:Je-r,d=0;return h<-f?d|=1:h>f&&(d|=2),u<-f?d|=4:u>f&&(d|=8),d}return lg(a,o,s,n?[0,-r]:[-Je,r-Je])}function w1(r,e,t,n,i,s){var a=r[0],o=r[1],l=e[0],c=e[1],h=0,u=1,f=l-a,d=c-o,p;if(p=t-a,!(!f&&p>0)){if(p/=f,f<0){if(p<h)return;p<u&&(u=p)}else if(f>0){if(p>u)return;p>h&&(h=p)}if(p=i-a,!(!f&&p<0)){if(p/=f,f<0){if(p>u)return;p>h&&(h=p)}else if(f>0){if(p<h)return;p<u&&(u=p)}if(p=n-o,!(!d&&p>0)){if(p/=d,d<0){if(p<h)return;p<u&&(u=p)}else if(d>0){if(p>u)return;p>h&&(h=p)}if(p=s-o,!(!d&&p<0)){if(p/=d,d<0){if(p>u)return;p>h&&(h=p)}else if(d>0){if(p<h)return;p<u&&(u=p)}return h>0&&(r[0]=a+h*f,r[1]=o+h*d),u<1&&(e[0]=a+u*f,e[1]=o+u*d),!0}}}}}var oa=1e9,_l=-oa;function E1(r,e,t,n){function i(c,h){return r<=c&&c<=t&&e<=h&&h<=n}function s(c,h,u,f){var d=0,p=0;if(c==null||(d=a(c,u))!==(p=a(h,u))||l(c,h)<0^u>0)do f.point(d===0||d===3?r:t,d>1?n:e);while((d=(d+u+4)%4)!==p);else f.point(h[0],h[1])}function a(c,h){return st(c[0]-r)<it?h>0?0:3:st(c[0]-t)<it?h>0?2:1:st(c[1]-e)<it?h>0?1:0:h>0?3:2}function o(c,h){return l(c.x,h.x)}function l(c,h){var u=a(c,1),f=a(h,1);return u!==f?u-f:u===0?h[1]-c[1]:u===1?c[0]-h[0]:u===2?c[1]-h[1]:h[0]-c[0]}return function(c){var h=c,u=rg(),f,d,p,_,g,m,y,x,v,M,w,A={point:C,lineStart:k,lineEnd:U,polygonStart:b,polygonEnd:L};function C(I,B){i(I,B)&&h.point(I,B)}function S(){for(var I=0,B=0,O=d.length;B<O;++B)for(var H=d[B],X=1,ee=H.length,z=H[0],Z,le,ce=z[0],fe=z[1];X<ee;++X)Z=ce,le=fe,z=H[X],ce=z[0],fe=z[1],le<=n?fe>n&&(ce-Z)*(n-le)>(fe-le)*(r-Z)&&++I:fe<=n&&(ce-Z)*(n-le)<(fe-le)*(r-Z)&&--I;return I}function b(){h=u,f=[],d=[],w=!0}function L(){var I=S(),B=w&&I,O=(f=ia(f)).length;(B||O)&&(c.polygonStart(),B&&(c.lineStart(),s(null,null,1,c),c.lineEnd()),O&&sg(f,o,I,s,c),c.polygonEnd()),h=c,f=d=p=null}function k(){A.point=N,d&&d.push(p=[]),M=!0,v=!1,y=x=NaN}function U(){f&&(N(_,g),m&&v&&u.rejoin(),f.push(u.result())),A.point=C,v&&h.lineEnd()}function N(I,B){var O=i(I,B);if(d&&p.push([I,B]),M)_=I,g=B,m=O,M=!1,O&&(h.lineStart(),h.point(I,B));else if(O&&v)h.point(I,B);else{var H=[y=Math.max(_l,Math.min(oa,y)),x=Math.max(_l,Math.min(oa,x))],X=[I=Math.max(_l,Math.min(oa,I)),B=Math.max(_l,Math.min(oa,B))];w1(H,X,r,e,t,n)?(v||(h.lineStart(),h.point(H[0],H[1])),h.point(X[0],X[1]),O||h.lineEnd(),w=!1):O&&(h.lineStart(),h.point(I,B),w=!1)}y=I,x=B,v=O}return A}}var du,pu,xl,yl,es={sphere:Bt,point:Bt,lineStart:A1,lineEnd:Bt,polygonStart:Bt,polygonEnd:Bt};function A1(){es.point=R1,es.lineEnd=T1}function T1(){es.point=es.lineEnd=Bt}function R1(r,e){r*=Ne,e*=Ne,pu=r,xl=De(e),yl=ze(e),es.point=C1}function C1(r,e){r*=Ne,e*=Ne;var t=De(e),n=ze(e),i=st(r-pu),s=ze(i),a=De(i),o=n*a,l=yl*t-xl*n*s,c=xl*t+yl*n*s;du.add(vn(oi(o*o+l*l),c)),pu=r,xl=t,yl=n}function P1(r){return du=new ai,nl(r,es),+du}var mu=[null,null],L1={type:"LineString",coordinates:mu};function ts(r,e){return mu[0]=r,mu[1]=e,P1(L1)}var hg={Feature:function(r,e){return vl(r.geometry,e)},FeatureCollection:function(r,e){for(var t=r.features,n=-1,i=t.length;++n<i;)if(vl(t[n].geometry,e))return!0;return!1}},ug={Sphere:function(){return!0},Point:function(r,e){return fg(r.coordinates,e)},MultiPoint:function(r,e){for(var t=r.coordinates,n=-1,i=t.length;++n<i;)if(fg(t[n],e))return!0;return!1},LineString:function(r,e){return dg(r.coordinates,e)},MultiLineString:function(r,e){for(var t=r.coordinates,n=-1,i=t.length;++n<i;)if(dg(t[n],e))return!0;return!1},Polygon:function(r,e){return pg(r.coordinates,e)},MultiPolygon:function(r,e){for(var t=r.coordinates,n=-1,i=t.length;++n<i;)if(pg(t[n],e))return!0;return!1},GeometryCollection:function(r,e){for(var t=r.geometries,n=-1,i=t.length;++n<i;)if(vl(t[n],e))return!0;return!1}};function vl(r,e){return r&&ug.hasOwnProperty(r.type)?ug[r.type](r,e):!1}function fg(r,e){return ts(r,e)===0}function dg(r,e){for(var t,n,i,s=0,a=r.length;s<a;s++){if(n=ts(r[s],e),n===0||s>0&&(i=ts(r[s],r[s-1]),i>0&&t<=i&&n<=i&&(t+n-i)*(1-Math.pow((t-n)/i,2))<Qo*i))return!0;t=n}return!1}function pg(r,e){return!!og(r.map(I1),mg(e))}function I1(r){return r=r.map(mg),r.pop(),r}function mg(r){return[r[0]*Ne,r[1]*Ne]}function U1(r,e){return(r&&hg.hasOwnProperty(r.type)?hg[r.type]:vl)(r,e)}function D1(r,e){var t=r[0]*Ne,n=r[1]*Ne,i=e[0]*Ne,s=e[1]*Ne,a=ze(n),o=De(n),l=ze(s),c=De(s),h=a*ze(t),u=a*De(t),f=l*ze(i),d=l*De(i),p=2*li(oi(Pm(s-n)+a*l*Pm(i-t))),_=De(p),g=p?function(m){var y=De(m*=p)/_,x=De(p-m)/_,v=x*h+y*f,M=x*u+y*d,w=x*o+y*c;return[vn(M,v)*pt,vn(w,oi(v*v+M*M))*pt]}:function(){return[t*pt,n*pt]};return g.distance=p,g}var gg=r=>r,ns=1/0,Ml=ns,la=-ns,Sl=la,N1={point:F1,lineStart:Bt,lineEnd:Bt,polygonStart:Bt,polygonEnd:Bt,result:function(){var r=[[ns,Ml],[la,Sl]];return la=Sl=-(Ml=ns=1/0),r}};function F1(r,e){r<ns&&(ns=r),r>la&&(la=r),e<Ml&&(Ml=e),e>Sl&&(Sl=e)}var _g=N1;function gu(r){return function(e){var t=new _u;for(var n in r)t[n]=r[n];return t.stream=e,t}}function _u(){}_u.prototype={constructor:_u,point:function(r,e){this.stream.point(r,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function xu(r,e,t){var n=r.clipExtent&&r.clipExtent();return r.scale(150).translate([0,0]),n!=null&&r.clipExtent(null),nl(t,r.stream(_g)),e(_g.result()),n!=null&&r.clipExtent(n),r}function xg(r,e,t){return xu(r,function(n){var i=e[1][0]-e[0][0],s=e[1][1]-e[0][1],a=Math.min(i/(n[1][0]-n[0][0]),s/(n[1][1]-n[0][1])),o=+e[0][0]+(i-a*(n[1][0]+n[0][0]))/2,l=+e[0][1]+(s-a*(n[1][1]+n[0][1]))/2;r.scale(150*a).translate([o,l])},t)}function O1(r,e,t){return xg(r,[[0,0],e],t)}function B1(r,e,t){return xu(r,function(n){var i=+e,s=i/(n[1][0]-n[0][0]),a=(i-s*(n[1][0]+n[0][0]))/2,o=-s*n[0][1];r.scale(150*s).translate([a,o])},t)}function z1(r,e,t){return xu(r,function(n){var i=+e,s=i/(n[1][1]-n[0][1]),a=-s*n[0][0],o=(i-s*(n[1][1]+n[0][1]))/2;r.scale(150*s).translate([a,o])},t)}var yg=16,k1=ze(30*Ne);function vg(r,e){return+e?H1(r,e):G1(r)}function G1(r){return gu({point:function(e,t){e=r(e,t),this.stream.point(e[0],e[1])}})}function H1(r,e){function t(n,i,s,a,o,l,c,h,u,f,d,p,_,g){var m=c-n,y=h-i,x=m*m+y*y;if(x>4*e&&_--){var v=a+f,M=o+d,w=l+p,A=oi(v*v+M*M+w*w),C=li(w/=A),S=st(st(w)-1)<it||st(s-u)<it?(s+u)/2:vn(M,v),b=r(S,C),L=b[0],k=b[1],U=L-n,N=k-i,I=y*U-m*N;(I*I/x>e||st((m*U+y*N)/x-.5)>.3||a*f+o*d+l*p<k1)&&(t(n,i,s,a,o,l,L,k,S,v/=A,M/=A,w,_,g),g.point(L,k),t(L,k,S,v,M,w,c,h,u,f,d,p,_,g))}}return function(n){var i,s,a,o,l,c,h,u,f,d,p,_,g={point:m,lineStart:y,lineEnd:v,polygonStart:function(){n.polygonStart(),g.lineStart=M},polygonEnd:function(){n.polygonEnd(),g.lineStart=y}};function m(C,S){C=r(C,S),n.point(C[0],C[1])}function y(){u=NaN,g.point=x,n.lineStart()}function x(C,S){var b=sr([C,S]),L=r(C,S);t(u,f,h,d,p,_,u=L[0],f=L[1],h=C,d=b[0],p=b[1],_=b[2],yg,n),n.point(u,f)}function v(){g.point=m,n.lineEnd()}function M(){y(),g.point=w,g.lineEnd=A}function w(C,S){x(i=C,S),s=u,a=f,o=d,l=p,c=_,g.point=x}function A(){t(u,f,h,d,p,_,s,a,i,o,l,c,yg,n),g.lineEnd=v,v()}return g}}var V1=gu({point:function(r,e){this.stream.point(r*Ne,e*Ne)}});function W1(r){return gu({point:function(e,t){var n=r(e,t);return this.stream.point(n[0],n[1])}})}function X1(r,e,t,n,i){function s(a,o){return a*=n,o*=i,[e+r*a,t-r*o]}return s.invert=function(a,o){return[(a-e)/r*n,(t-o)/r*i]},s}function Mg(r,e,t,n,i,s){if(!s)return X1(r,e,t,n,i);var a=ze(s),o=De(s),l=a*r,c=o*r,h=a/r,u=o/r,f=(o*t-a*e)/r,d=(o*e+a*t)/r;function p(_,g){return _*=n,g*=i,[l*_-c*g+e,t-c*_-l*g]}return p.invert=function(_,g){return[n*(h*_-u*g+f),i*(d-u*_-h*g)]},p}function Sg(r){return q1(function(){return r})()}function q1(r){var e,t=150,n=480,i=250,s=0,a=0,o=0,l=0,c=0,h,u=0,f=1,d=1,p=null,_=cg,g=null,m,y,x,v=gg,M=.5,w,A,C,S,b;function L(I){return C(I[0]*Ne,I[1]*Ne)}function k(I){return I=C.invert(I[0],I[1]),I&&[I[0]*pt,I[1]*pt]}L.stream=function(I){return S&&b===I?S:S=V1(W1(h)(_(w(v(b=I)))))},L.preclip=function(I){return arguments.length?(_=I,p=void 0,N()):_},L.postclip=function(I){return arguments.length?(v=I,g=m=y=x=null,N()):v},L.clipAngle=function(I){return arguments.length?(_=+I?b1(p=I*Ne):(p=null,cg),N()):p*pt},L.clipExtent=function(I){return arguments.length?(v=I==null?(g=m=y=x=null,gg):E1(g=+I[0][0],m=+I[0][1],y=+I[1][0],x=+I[1][1]),N()):g==null?null:[[g,m],[y,x]]},L.scale=function(I){return arguments.length?(t=+I,U()):t},L.translate=function(I){return arguments.length?(n=+I[0],i=+I[1],U()):[n,i]},L.center=function(I){return arguments.length?(s=I[0]%360*Ne,a=I[1]%360*Ne,U()):[s*pt,a*pt]},L.rotate=function(I){return arguments.length?(o=I[0]%360*Ne,l=I[1]%360*Ne,c=I.length>2?I[2]%360*Ne:0,U()):[o*pt,l*pt,c*pt]},L.angle=function(I){return arguments.length?(u=I%360*Ne,U()):u*pt},L.reflectX=function(I){return arguments.length?(f=I?-1:1,U()):f<0},L.reflectY=function(I){return arguments.length?(d=I?-1:1,U()):d<0},L.precision=function(I){return arguments.length?(w=vg(A,M=I*I),N()):oi(M)},L.fitExtent=function(I,B){return xg(L,I,B)},L.fitSize=function(I,B){return O1(L,I,B)},L.fitWidth=function(I,B){return B1(L,I,B)},L.fitHeight=function(I,B){return z1(L,I,B)};function U(){var I=Mg(t,0,0,f,d,u).apply(null,e(s,a)),B=Mg(t,n-I[0],i-I[1],f,d,u);return h=jm(o,l,c),A=hu(e,B),C=hu(h,A),w=vg(A,M),N()}function N(){return S=b=null,L}return function(){return e=r.apply(this,arguments),L.invert=e.invert&&k,U()}}function $1(r){return function(e,t){var n=oi(e*e+t*t),i=r(n),s=De(i),a=ze(i);return[vn(e*s,n*a),li(n&&t*s/n)]}}function yu(r,e){return[r,n1(r1((tn+e)/2))]}yu.invert=function(r,e){return[r,2*jh(t1(e))-tn]};function Y1(){return Z1(yu).scale(961/nn)}function Z1(r){var e=Sg(r),t=e.center,n=e.scale,i=e.translate,s=e.clipExtent,a=null,o,l,c;e.scale=function(u){return arguments.length?(n(u),h()):n()},e.translate=function(u){return arguments.length?(i(u),h()):i()},e.center=function(u){return arguments.length?(t(u),h()):t()},e.clipExtent=function(u){return arguments.length?(u==null?a=o=l=c=null:(a=+u[0][0],o=+u[0][1],l=+u[1][0],c=+u[1][1]),h()):a==null?null:[[a,o],[l,c]]};function h(){var u=Je*n(),f=e(ng(e.rotate()).invert([0,0]));return s(a==null?[[f[0]-u,f[1]-u],[f[0]+u,f[1]+u]]:r===yu?[[Math.max(f[0]-u,a),o],[Math.min(f[0]+u,l),c]]:[[a,Math.max(f[1]-u,o)],[l,Math.min(f[1]+u,c)]])}return h()}function bg(r,e){var t=ze(e),n=1+ze(r)*t;return[t*De(r)/n,De(e)/n]}bg.invert=$1(function(r){return 2*jh(r)});function J1(){return Sg(bg).scale(250).clipAngle(142)}const wg=r=>Y1().center(r.center).scale(r.scale).translate([0,0]).precision(.1),Eg=(r,e)=>r.map(([t,n])=>{if(e){const[i,s]=e([t,n]);return new q(i,-s)}else return new q(t,n)});function K1(r,e=0){const t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},a={},o=r[0].morphTargetsRelative,l=new Fe;let c=0;for(let h=0;h<r.length;++h){const u=r[h];let f=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const d in u.attributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;s[d]===void 0&&(s[d]=[]),s[d].push(u.attributes[d]),f++}if(f!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(o!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const d in u.morphAttributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[d]===void 0&&(a[d]=[]),a[d].push(u.morphAttributes[d])}if(e){let d;if(t)d=u.index.count;else if(u.attributes.position!==void 0)d=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;if(e===1)l.addGroup(c,d,h);else if(e===2&&u.groups.length>0)for(let p of u.groups){let _=p.materialIndex;l.addGroup(c+p.start,Math.min(p.count,d),_)}c+=d}}if(t){let h=0;const u=[];for(let f=0;f<r.length;++f){const d=r[f].index;for(let p=0;p<d.count;++p)u.push(d.getX(p)+h);h+=r[f].attributes.position.count}l.setIndex(u)}for(const h in s){const u=Ag(s[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,u)}for(const h in a){const u=a[h][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let f=0;f<u;++f){const d=[];for(let _=0;_<a[h].length;++_)d.push(a[h][_][f]);const p=Ag(d);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(p)}}return e===2?j1(l):l}function Ag(r){let e,t,n,i=-1,s=0;for(let c=0;c<r.length;++c){const h=r[c];if(h.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.array.length}const a=new e(s);let o=0;for(let c=0;c<r.length;++c)a.set(r[c].array,o),o+=r[c].array.length;const l=new Ze(a,t,n);return i!==void 0&&(l.gpuType=i),l}function j1(r){if(r.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),r;let e=r.groups;if(e=e.sort((a,o)=>a.materialIndex!==o.materialIndex?a.materialIndex-o.materialIndex:a.start-o.start),r.getIndex()===null){const a=r.getAttribute("position"),o=[];for(let l=0;l<a.count;l+=3)o.push(l,l+1,l+2);r.setIndex(o)}const t=r.getIndex(),n=[];for(let a=0;a<e.length;a++){const o=e[a],l=o.start,c=l+o.count;for(let h=l;h<c;h++)n.push(t.getX(h))}r.dispose(),r.setIndex(n);let i=0;for(let a=0;a<e.length;a++){const o=e[a];o.start=i,i+=o.count}let s=e[0];r.groups=[s];for(let a=1;a<e.length;a++){const o=e[a];s.materialIndex===o.materialIndex?s.count+=o.count:(s=o,r.groups.push(s))}return r}var bl=(r,e)=>{const t=K1(r,e!=null?e:0),n={},i=[],s=Object.keys(t.attributes);return t.index&&s.push("index"),s.forEach(a=>{const o=a==="index"?t.index:t.attributes[a];n[a]={array:o.array,itemSize:o.itemSize},i.push(o.array.buffer)}),e&&(n.groups=t.groups),t.dispose(),r.forEach(a=>{a.dispose()}),{message:n,transfer:i}};const Q1=({coordinatesArr:r,split:e,box3Set:t,depth:n,projection:i,useGroups:s,hasTop:a,hasBottom:o,hasSide:l})=>{const c=i&&wg({center:i.center,scale:i.scale}),u=r.map(f=>Eg(f,c)).map((f,d)=>{var p;return Hb({points:f,split:e,depth:(p=n[d])!=null?p:n[0],hasTop:a,hasBottom:o,hasSide:l,box3Set:t})});return bl(u,s)};function vu(r,e,t,n,i){let s;if(r=r.subarray||r.slice?r:r.buffer,t=t.subarray||t.slice?t:t.buffer,r=e?r.subarray?r.subarray(e,i&&e+i):r.slice(e,i&&e+i):r,t.set)t.set(r,n);else for(s=0;s<r.length;s++)t[s+n]=r[s];return t}function ew(r){return r instanceof Float32Array?r:r instanceof Fe?r.getAttribute("position").array:r.map(e=>{const t=Array.isArray(e);return e instanceof R?[e.x,e.y,e.z]:e instanceof q?[e.x,e.y,0]:t&&e.length===3?[e[0],e[1],e[2]]:t&&e.length===2?[e[0],e[1],0]:e}).flat()}class tw extends Fe{constructor(){super(),this.type="MeshLine",this.isMeshLine=!0,this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this.widthCallback=null,this._points=[],this.matrixWorld=new Be,Object.defineProperties(this,{points:{enumerable:!0,get(){return this._points},set(e){this.setPoints(e,this.widthCallback)}}})}setMatrixWorld(e){this.matrixWorld=e}setPoints(e,t){if(e=ew(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof R)for(let n=0;n<e.length;n++){const i=e[n],s=n/(e.length-1);this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(s),this.counters.push(s)}else for(let n=0;n<e.length;n+=3){const i=n/(e.length-1);this.positions.push(e[n],e[n+1],e[n+2]),this.positions.push(e[n],e[n+1],e[n+2]),this.counters.push(i),this.counters.push(i)}this.process()}compareV3(e,t){const n=e*6,i=t*6;return this.positions[n]===this.positions[i]&&this.positions[n+1]===this.positions[i+1]&&this.positions[n+2]===this.positions[i+2]}copyV3(e){const t=e*6;return[this.positions[t],this.positions[t+1],this.positions[t+2]]}process(){const e=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];let t,n;this.compareV3(0,e-1)?n=this.copyV3(e-2):n=this.copyV3(0),this.previous.push(n[0],n[1],n[2]),this.previous.push(n[0],n[1],n[2]);for(let i=0;i<e;i++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(i/(e-1)):t=1,this.width.push(t),this.width.push(t),this.uvs.push(i/(e-1),0),this.uvs.push(i/(e-1),1),i<e-1){n=this.copyV3(i),this.previous.push(n[0],n[1],n[2]),this.previous.push(n[0],n[1],n[2]);const s=i*2;this.indices_array.push(s,s+1,s+2),this.indices_array.push(s+2,s+1,s+3)}i>0&&(n=this.copyV3(i),this.next.push(n[0],n[1],n[2]),this.next.push(n[0],n[1],n[2]))}this.compareV3(e-1,0)?n=this.copyV3(1):n=this.copyV3(e-1),this.next.push(n[0],n[1],n[2]),this.next.push(n[0],n[1],n[2]),!this._attributes||this._attributes.position.count!==this.positions.length?this._attributes={position:new Ze(new Float32Array(this.positions),3),previous:new Ze(new Float32Array(this.previous),3),next:new Ze(new Float32Array(this.next),3),side:new Ze(new Float32Array(this.side),1),width:new Ze(new Float32Array(this.width),1),uv:new Ze(new Float32Array(this.uvs),2),index:new Ze(new Uint16Array(this.indices_array),1),counters:new Ze(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()}advance({x:e,y:t,z:n}){const i=this._attributes.position.array,s=this._attributes.previous.array,a=this._attributes.next.array,o=i.length;vu(i,0,s,0,o),vu(i,6,i,0,o-6),i[o-6]=e,i[o-5]=t,i[o-4]=n,i[o-3]=e,i[o-2]=t,i[o-1]=n,vu(i,6,a,0,o-6),a[o-6]=e,a[o-5]=t,a[o-4]=n,a[o-3]=e,a[o-2]=t,a[o-1]=n,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}var Tg=r=>{const{setPointWidth:e,nodes:t}=r,n=new tw;return n.setPoints(t,e),n};const nw=({coordinatesArr:r,projection:e,lineWidth:t,useGroups:n})=>{const i=e&&wg({center:e.center,scale:e.scale}),a=r.map(o=>Eg(o,i)).map((o,l)=>{var h;const c=(h=t[l])!=null?h:t[0];return Tg({nodes:o,setPointWidth:()=>c})});return bl(a,n)};var is={},iw={get exports(){return is},set exports(r){is=r}};iw.exports=wl,is.default=wl;function wl(r,e,t){t=t||2;var n=e&&e.length,i=n?e[0]*t:r.length,s=Rg(r,0,i,t,!0),a=[];if(!s||s.next===s.prev)return a;var o,l,c,h,u,f,d;if(n&&(s=lw(r,e,s,t)),r.length>80*t){o=c=r[0],l=h=r[1];for(var p=t;p<i;p+=t)u=r[p],f=r[p+1],u<o&&(o=u),f<l&&(l=f),u>c&&(c=u),f>h&&(h=f);d=Math.max(c-o,h-l),d=d!==0?32767/d:0}return ca(s,a,t,o,l,d,0),a}function Rg(r,e,t,n,i){var s,a;if(i===bu(r,e,t,n)>0)for(s=e;s<t;s+=n)a=Lg(s,r[s],r[s+1],a);else for(s=t-n;s>=e;s-=n)a=Lg(s,r[s],r[s+1],a);return a&&El(a,a.next)&&(ua(a),a=a.next),a}function or(r,e){if(!r)return r;e||(e=r);var t=r,n;do if(n=!1,!t.steiner&&(El(t,t.next)||ht(t.prev,t,t.next)===0)){if(ua(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function ca(r,e,t,n,i,s,a){if(r){!a&&s&&dw(r,n,i,s);for(var o=r,l,c;r.prev!==r.next;){if(l=r.prev,c=r.next,s?sw(r,n,i,s):rw(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(c.i/t|0),ua(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=aw(or(r),e,t),ca(r,e,t,n,i,s,2)):a===2&&ow(r,e,t,n,i,s):ca(or(r),e,t,n,i,s,1);break}}}}function rw(r){var e=r.prev,t=r,n=r.next;if(ht(e,t,n)>=0)return!1;for(var i=e.x,s=t.x,a=n.x,o=e.y,l=t.y,c=n.y,h=i<s?i<a?i:a:s<a?s:a,u=o<l?o<c?o:c:l<c?l:c,f=i>s?i>a?i:a:s>a?s:a,d=o>l?o>c?o:c:l>c?l:c,p=n.next;p!==e;){if(p.x>=h&&p.x<=f&&p.y>=u&&p.y<=d&&rs(i,o,s,l,a,c,p.x,p.y)&&ht(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function sw(r,e,t,n){var i=r.prev,s=r,a=r.next;if(ht(i,s,a)>=0)return!1;for(var o=i.x,l=s.x,c=a.x,h=i.y,u=s.y,f=a.y,d=o<l?o<c?o:c:l<c?l:c,p=h<u?h<f?h:f:u<f?u:f,_=o>l?o>c?o:c:l>c?l:c,g=h>u?h>f?h:f:u>f?u:f,m=Mu(d,p,e,t,n),y=Mu(_,g,e,t,n),x=r.prevZ,v=r.nextZ;x&&x.z>=m&&v&&v.z<=y;){if(x.x>=d&&x.x<=_&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&rs(o,h,l,u,c,f,x.x,x.y)&&ht(x.prev,x,x.next)>=0||(x=x.prevZ,v.x>=d&&v.x<=_&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&rs(o,h,l,u,c,f,v.x,v.y)&&ht(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;x&&x.z>=m;){if(x.x>=d&&x.x<=_&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&rs(o,h,l,u,c,f,x.x,x.y)&&ht(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=d&&v.x<=_&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&rs(o,h,l,u,c,f,v.x,v.y)&&ht(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function aw(r,e,t){var n=r;do{var i=n.prev,s=n.next.next;!El(i,s)&&Cg(i,n,n.next,s)&&ha(i,s)&&ha(s,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),ua(n),ua(n.next),n=r=s),n=n.next}while(n!==r);return or(n)}function ow(r,e,t,n,i,s){var a=r;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&gw(a,o)){var l=Pg(a,o);a=or(a,a.next),l=or(l,l.next),ca(a,e,t,n,i,s,0),ca(l,e,t,n,i,s,0);return}o=o.next}a=a.next}while(a!==r)}function lw(r,e,t,n){var i=[],s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*n,l=s<a-1?e[s+1]*n:r.length,c=Rg(r,o,l,n,!1),c===c.next&&(c.steiner=!0),i.push(mw(c));for(i.sort(cw),s=0;s<i.length;s++)t=hw(i[s],t);return t}function cw(r,e){return r.x-e.x}function hw(r,e){var t=uw(r,e);if(!t)return e;var n=Pg(t,r);return or(n,n.next),or(t,t.next)}function uw(r,e){var t=e,n=r.x,i=r.y,s=-1/0,a;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){var o=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(o<=n&&o>s&&(s=o,a=t.x<t.next.x?t:t.next,o===n))return a}t=t.next}while(t!==e);if(!a)return null;var l=a,c=a.x,h=a.y,u=1/0,f;t=a;do n>=t.x&&t.x>=c&&n!==t.x&&rs(i<h?n:s,i,c,h,i<h?s:n,i,t.x,t.y)&&(f=Math.abs(i-t.y)/(n-t.x),ha(t,r)&&(f<u||f===u&&(t.x>a.x||t.x===a.x&&fw(a,t)))&&(a=t,u=f)),t=t.next;while(t!==l);return a}function fw(r,e){return ht(r.prev,r,e.prev)<0&&ht(e.next,r,r.next)<0}function dw(r,e,t,n){var i=r;do i.z===0&&(i.z=Mu(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,pw(i)}function pw(r){var e,t,n,i,s,a,o,l,c=1;do{for(t=r,r=null,s=null,a=0;t;){for(a++,n=t,o=0,e=0;e<c&&(o++,n=n.nextZ,!!n);e++);for(l=c;o>0||l>0&&n;)o!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,o--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(a>1);return r}function Mu(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function mw(r){var e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function rs(r,e,t,n,i,s,a,o){return(i-a)*(e-o)>=(r-a)*(s-o)&&(r-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(i-a)*(n-o)}function gw(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!_w(r,e)&&(ha(r,e)&&ha(e,r)&&xw(r,e)&&(ht(r.prev,r,e.prev)||ht(r,e.prev,e))||El(r,e)&&ht(r.prev,r,r.next)>0&&ht(e.prev,e,e.next)>0)}function ht(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function El(r,e){return r.x===e.x&&r.y===e.y}function Cg(r,e,t,n){var i=Tl(ht(r,e,t)),s=Tl(ht(r,e,n)),a=Tl(ht(t,n,r)),o=Tl(ht(t,n,e));return!!(i!==s&&a!==o||i===0&&Al(r,t,e)||s===0&&Al(r,n,e)||a===0&&Al(t,r,n)||o===0&&Al(t,e,n))}function Al(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Tl(r){return r>0?1:r<0?-1:0}function _w(r,e){var t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Cg(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function ha(r,e){return ht(r.prev,r,r.next)<0?ht(r,e,r.next)>=0&&ht(r,r.prev,e)>=0:ht(r,e,r.prev)<0||ht(r,r.next,e)<0}function xw(r,e){var t=r,n=!1,i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function Pg(r,e){var t=new Su(r.i,r.x,r.y),n=new Su(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Lg(r,e,t,n){var i=new Su(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function ua(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Su(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}wl.deviation=function(r,e,t,n){var i=e&&e.length,s=i?e[0]*t:r.length,a=Math.abs(bu(r,0,s,t));if(i)for(var o=0,l=e.length;o<l;o++){var c=e[o]*t,h=o<l-1?e[o+1]*t:r.length;a-=Math.abs(bu(r,c,h,t))}var u=0;for(o=0;o<n.length;o+=3){var f=n[o]*t,d=n[o+1]*t,p=n[o+2]*t;u+=Math.abs((r[f]-r[p])*(r[d+1]-r[f+1])-(r[f]-r[d])*(r[p+1]-r[f+1]))}return a===0&&u===0?0:Math.abs((u-a)/a)};function bu(r,e,t,n){for(var i=0,s=e,a=t-n;s<t;s+=n)i+=(r[a]-r[s])*(r[s+1]+r[a+1]),a=s;return i}wl.flatten=function(r){for(var e=r[0][0].length,t={vertices:[],holes:[],dimensions:e},n=0,i=0;i<r.length;i++){for(var s=0;s<r[i].length;s++)for(var a=0;a<e;a++)t.vertices.push(r[i][s][a]);i>0&&(n+=r[i-1].length,t.holes.push(n))}return t};function yw(r){if(!r)throw new Error("coord is required");if(!Array.isArray(r)){if(r.type==="Feature"&&r.geometry!==null&&r.geometry.type==="Point")return r.geometry.coordinates;if(r.type==="Point")return r.coordinates}if(Array.isArray(r)&&r.length>=2&&!Array.isArray(r[0])&&!Array.isArray(r[1]))return r;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function vw(r){if(Array.isArray(r))return r;if(r.type==="Feature"){if(r.geometry!==null)return r.geometry.coordinates}else if(r.coordinates)return r.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Mw(r){return r.type==="Feature"?r.geometry:r}function Sw(r){for(var e=vw(r),t=0,n=1,i,s;n<e.length;)i=s||e[0],s=e[n],t+=(s[0]-i[0])*(s[1]+i[1]),n++;return t>0}function bw(r,e,t=0){const n=(90-e)*Math.PI/180,i=(90-r)*Math.PI/180;return[t*Math.sin(n)*Math.cos(i),t*Math.cos(n),t*Math.sin(n)*Math.sin(i)]}const fi=11102230246251565e-32,zt=134217729,ww=(3+8*fi)*fi;function wu(r,e,t,n,i){let s,a,o,l,c=e[0],h=n[0],u=0,f=0;h>c==h>-c?(s=c,c=e[++u]):(s=h,h=n[++f]);let d=0;if(u<r&&f<t)for(h>c==h>-c?(a=c+s,o=s-(a-c),c=e[++u]):(a=h+s,o=s-(a-h),h=n[++f]),s=a,o!==0&&(i[d++]=o);u<r&&f<t;)h>c==h>-c?(a=s+c,l=a-s,o=s-(a-l)+(c-l),c=e[++u]):(a=s+h,l=a-s,o=s-(a-l)+(h-l),h=n[++f]),s=a,o!==0&&(i[d++]=o);for(;u<r;)a=s+c,l=a-s,o=s-(a-l)+(c-l),c=e[++u],s=a,o!==0&&(i[d++]=o);for(;f<t;)a=s+h,l=a-s,o=s-(a-l)+(h-l),h=n[++f],s=a,o!==0&&(i[d++]=o);return(s!==0||d===0)&&(i[d++]=s),d}function Ew(r,e){let t=e[0];for(let n=1;n<r;n++)t+=e[n];return t}function fa(r){return new Float64Array(r)}const Aw=(3+16*fi)*fi,Tw=(2+12*fi)*fi,Rw=(9+64*fi)*fi*fi,ss=fa(4),Ig=fa(8),Ug=fa(12),Dg=fa(16),$t=fa(4);function Cw(r,e,t,n,i,s,a){let o,l,c,h,u,f,d,p,_,g,m,y,x,v,M,w,A,C;const S=r-i,b=t-i,L=e-s,k=n-s;v=S*k,f=zt*S,d=f-(f-S),p=S-d,f=zt*k,_=f-(f-k),g=k-_,M=p*g-(v-d*_-p*_-d*g),w=L*b,f=zt*L,d=f-(f-L),p=L-d,f=zt*b,_=f-(f-b),g=b-_,A=p*g-(w-d*_-p*_-d*g),m=M-A,u=M-m,ss[0]=M-(m+u)+(u-A),y=v+m,u=y-v,x=v-(y-u)+(m-u),m=x-w,u=x-m,ss[1]=x-(m+u)+(u-w),C=y+m,u=C-y,ss[2]=y-(C-u)+(m-u),ss[3]=C;let U=Ew(4,ss),N=Tw*a;if(U>=N||-U>=N||(u=r-S,o=r-(S+u)+(u-i),u=t-b,c=t-(b+u)+(u-i),u=e-L,l=e-(L+u)+(u-s),u=n-k,h=n-(k+u)+(u-s),o===0&&l===0&&c===0&&h===0)||(N=Rw*a+ww*Math.abs(U),U+=S*h+k*o-(L*c+b*l),U>=N||-U>=N))return U;v=o*k,f=zt*o,d=f-(f-o),p=o-d,f=zt*k,_=f-(f-k),g=k-_,M=p*g-(v-d*_-p*_-d*g),w=l*b,f=zt*l,d=f-(f-l),p=l-d,f=zt*b,_=f-(f-b),g=b-_,A=p*g-(w-d*_-p*_-d*g),m=M-A,u=M-m,$t[0]=M-(m+u)+(u-A),y=v+m,u=y-v,x=v-(y-u)+(m-u),m=x-w,u=x-m,$t[1]=x-(m+u)+(u-w),C=y+m,u=C-y,$t[2]=y-(C-u)+(m-u),$t[3]=C;const I=wu(4,ss,4,$t,Ig);v=S*h,f=zt*S,d=f-(f-S),p=S-d,f=zt*h,_=f-(f-h),g=h-_,M=p*g-(v-d*_-p*_-d*g),w=L*c,f=zt*L,d=f-(f-L),p=L-d,f=zt*c,_=f-(f-c),g=c-_,A=p*g-(w-d*_-p*_-d*g),m=M-A,u=M-m,$t[0]=M-(m+u)+(u-A),y=v+m,u=y-v,x=v-(y-u)+(m-u),m=x-w,u=x-m,$t[1]=x-(m+u)+(u-w),C=y+m,u=C-y,$t[2]=y-(C-u)+(m-u),$t[3]=C;const B=wu(I,Ig,4,$t,Ug);v=o*h,f=zt*o,d=f-(f-o),p=o-d,f=zt*h,_=f-(f-h),g=h-_,M=p*g-(v-d*_-p*_-d*g),w=l*c,f=zt*l,d=f-(f-l),p=l-d,f=zt*c,_=f-(f-c),g=c-_,A=p*g-(w-d*_-p*_-d*g),m=M-A,u=M-m,$t[0]=M-(m+u)+(u-A),y=v+m,u=y-v,x=v-(y-u)+(m-u),m=x-w,u=x-m,$t[1]=x-(m+u)+(u-w),C=y+m,u=C-y,$t[2]=y-(C-u)+(m-u),$t[3]=C;const O=wu(B,Ug,4,$t,Dg);return Dg[O-1]}function Rl(r,e,t,n,i,s){const a=(e-s)*(t-i),o=(r-i)*(n-s),l=a-o;if(a===0||o===0||a>0!=o>0)return l;const c=Math.abs(a+o);return Math.abs(l)>=Aw*c?l:-Cw(r,e,t,n,i,s,c)}const Ng=Math.pow(2,-52),Cl=new Uint32Array(512);class da{static from(e,t=Dw,n=Nw){const i=e.length,s=new Float64Array(i*2);for(let a=0;a<i;a++){const o=e[a];s[2*a]=t(o),s[2*a+1]=n(o)}return new da(s)}constructor(e){const t=e.length>>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:n,_hullTri:i,_hullHash:s}=this,a=e.length>>1;let o=1/0,l=1/0,c=-1/0,h=-1/0;for(let b=0;b<a;b++){const L=e[2*b],k=e[2*b+1];L<o&&(o=L),k<l&&(l=k),L>c&&(c=L),k>h&&(h=k),this._ids[b]=b}const u=(o+c)/2,f=(l+h)/2;let d=1/0,p,_,g;for(let b=0;b<a;b++){const L=Eu(u,f,e[2*b],e[2*b+1]);L<d&&(p=b,d=L)}const m=e[2*p],y=e[2*p+1];d=1/0;for(let b=0;b<a;b++){if(b===p)continue;const L=Eu(m,y,e[2*b],e[2*b+1]);L<d&&L>0&&(_=b,d=L)}let x=e[2*_],v=e[2*_+1],M=1/0;for(let b=0;b<a;b++){if(b===p||b===_)continue;const L=Iw(m,y,x,v,e[2*b],e[2*b+1]);L<M&&(g=b,M=L)}let w=e[2*g],A=e[2*g+1];if(M===1/0){for(let k=0;k<a;k++)this._dists[k]=e[2*k]-e[0]||e[2*k+1]-e[1];as(this._ids,this._dists,0,a-1);const b=new Uint32Array(a);let L=0;for(let k=0,U=-1/0;k<a;k++){const N=this._ids[k];this._dists[N]>U&&(b[L++]=N,U=this._dists[N])}this.hull=b.subarray(0,L),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(Rl(m,y,x,v,w,A)<0){const b=_,L=x,k=v;_=g,x=w,v=A,g=b,w=L,A=k}const C=Uw(m,y,x,v,w,A);this._cx=C.x,this._cy=C.y;for(let b=0;b<a;b++)this._dists[b]=Eu(e[2*b],e[2*b+1],C.x,C.y);as(this._ids,this._dists,0,a-1),this._hullStart=p;let S=3;n[p]=t[g]=_,n[_]=t[p]=g,n[g]=t[_]=p,i[p]=0,i[_]=1,i[g]=2,s.fill(-1),s[this._hashKey(m,y)]=p,s[this._hashKey(x,v)]=_,s[this._hashKey(w,A)]=g,this.trianglesLen=0,this._addTriangle(p,_,g,-1,-1,-1);for(let b=0,L,k;b<this._ids.length;b++){const U=this._ids[b],N=e[2*U],I=e[2*U+1];if(b>0&&Math.abs(N-L)<=Ng&&Math.abs(I-k)<=Ng||(L=N,k=I,U===p||U===_||U===g))continue;let B=0;for(let z=0,Z=this._hashKey(N,I);z<this._hashSize&&(B=s[(Z+z)%this._hashSize],!(B!==-1&&B!==n[B]));z++);B=t[B];let O=B,H;for(;H=n[O],Rl(N,I,e[2*O],e[2*O+1],e[2*H],e[2*H+1])>=0;)if(O=H,O===B){O=-1;break}if(O===-1)continue;let X=this._addTriangle(O,U,n[O],-1,-1,i[O]);i[U]=this._legalize(X+2),i[O]=X,S++;let ee=n[O];for(;H=n[ee],Rl(N,I,e[2*ee],e[2*ee+1],e[2*H],e[2*H+1])<0;)X=this._addTriangle(ee,U,H,i[U],-1,i[ee]),i[U]=this._legalize(X+2),n[ee]=ee,S--,ee=H;if(O===B)for(;H=t[O],Rl(N,I,e[2*H],e[2*H+1],e[2*O],e[2*O+1])<0;)X=this._addTriangle(H,U,O,-1,i[O],i[H]),this._legalize(X+2),i[H]=X,n[O]=O,S--,O=H;this._hullStart=t[U]=O,n[O]=t[ee]=U,n[U]=ee,s[this._hashKey(N,I)]=U,s[this._hashKey(e[2*O],e[2*O+1])]=O}this.hull=new Uint32Array(S);for(let b=0,L=this._hullStart;b<S;b++)this.hull[b]=L,L=n[L];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(e,t){return Math.floor(Pw(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){const{_triangles:t,_halfedges:n,coords:i}=this;let s=0,a=0;for(;;){const o=n[e],l=e-e%3;if(a=l+(e+2)%3,o===-1){if(s===0)break;e=Cl[--s];continue}const c=o-o%3,h=l+(e+1)%3,u=c+(o+2)%3,f=t[a],d=t[e],p=t[h],_=t[u];if(Lw(i[2*f],i[2*f+1],i[2*d],i[2*d+1],i[2*p],i[2*p+1],i[2*_],i[2*_+1])){t[e]=_,t[o]=f;const m=n[u];if(m===-1){let x=this._hullStart;do{if(this._hullTri[x]===u){this._hullTri[x]=e;break}x=this._hullPrev[x]}while(x!==this._hullStart)}this._link(e,m),this._link(o,n[a]),this._link(a,u);const y=c+(o+1)%3;s<Cl.length&&(Cl[s++]=y)}else{if(s===0)break;e=Cl[--s]}}return a}_link(e,t){this._halfedges[e]=t,t!==-1&&(this._halfedges[t]=e)}_addTriangle(e,t,n,i,s,a){const o=this.trianglesLen;return this._triangles[o]=e,this._triangles[o+1]=t,this._triangles[o+2]=n,this._link(o,i),this._link(o+1,s),this._link(o+2,a),this.trianglesLen+=3,o}}function Pw(r,e){const t=r/(Math.abs(r)+Math.abs(e));return(e>0?3-t:1+t)/4}function Eu(r,e,t,n){const i=r-t,s=e-n;return i*i+s*s}function Lw(r,e,t,n,i,s,a,o){const l=r-a,c=e-o,h=t-a,u=n-o,f=i-a,d=s-o,p=l*l+c*c,_=h*h+u*u,g=f*f+d*d;return l*(u*g-_*d)-c*(h*g-_*f)+p*(h*d-u*f)<0}function Iw(r,e,t,n,i,s){const a=t-r,o=n-e,l=i-r,c=s-e,h=a*a+o*o,u=l*l+c*c,f=.5/(a*c-o*l),d=(c*h-o*u)*f,p=(a*u-l*h)*f;return d*d+p*p}function Uw(r,e,t,n,i,s){const a=t-r,o=n-e,l=i-r,c=s-e,h=a*a+o*o,u=l*l+c*c,f=.5/(a*c-o*l),d=r+(c*h-o*u)*f,p=e+(a*u-l*h)*f;return{x:d,y:p}}function as(r,e,t,n){if(n-t<=20)for(let i=t+1;i<=n;i++){const s=r[i],a=e[s];let o=i-1;for(;o>=t&&e[r[o]]>a;)r[o+1]=r[o--];r[o+1]=s}else{const i=t+n>>1;let s=t+1,a=n;pa(r,i,s),e[r[t]]>e[r[n]]&&pa(r,t,n),e[r[s]]>e[r[n]]&&pa(r,s,n),e[r[t]]>e[r[s]]&&pa(r,t,s);const o=r[s],l=e[o];for(;;){do s++;while(e[r[s]]<l);do a--;while(e[r[a]]>l);if(a<s)break;pa(r,s,a)}r[t+1]=r[a],r[a]=o,n-s+1>=a-t?(as(r,e,s,n),as(r,e,t,a-1)):(as(r,e,t,a-1),as(r,e,s,n))}}function pa(r,e,t){const n=r[e];r[e]=r[t],r[t]=n}function Dw(r){return r[0]}function Nw(r){return r[1]}function Fw(r,e,t){if(t===void 0&&(t={}),!r)throw new Error("point is required");if(!e)throw new Error("polygon is required");var n=yw(r),i=Mw(e),s=i.type,a=e.bbox,o=i.coordinates;if(a&&Ow(n,a)===!1)return!1;s==="Polygon"&&(o=[o]);for(var l=!1,c=0;c<o.length&&!l;c++)if(Fg(n,o[c][0],t.ignoreBoundary)){for(var h=!1,u=1;u<o[c].length&&!h;)Fg(n,o[c][u],!t.ignoreBoundary)&&(h=!0),u++;h||(l=!0)}return l}function Fg(r,e,t){var n=!1;e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]&&(e=e.slice(0,e.length-1));for(var i=0,s=e.length-1;i<e.length;s=i++){var a=e[i][0],o=e[i][1],l=e[s][0],c=e[s][1],h=r[1]*(a-l)+o*(l-r[0])+c*(r[0]-a)===0&&(a-r[0])*(l-r[0])<=0&&(o-r[1])*(c-r[1])<=0;if(h)return!t;var u=o>r[1]!=c>r[1]&&r[0]<(l-a)*(r[1]-o)/(c-o)+a;u&&(n=!n)}return n}function Ow(r,e){return e[0]<=r[0]&&e[1]<=r[1]&&e[2]>=r[0]&&e[3]>=r[1]}const Og=1e-6;class lr{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;const i=e+n,s=t;if(n<0)throw new Error("negative radius");this._x1===null?this._+=`M${i},${s}`:(Math.abs(this._x1-i)>Og||Math.abs(this._y1-s)>Og)&&(this._+="L"+i+","+s),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=i},${this._y1=s}`)}rect(e,t,n,i){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+i}h${-n}Z`}value(){return this._||null}}class Au{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class Bw{constructor(e,[t,n,i,s]=[0,0,960,500]){if(!((i=+i)>=(t=+t))||!((s=+s)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=i,this.xmin=t,this.ymax=s,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:i}=this,s=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let d=0,p=0,_=n.length,g,m;d<_;d+=3,p+=2){const y=n[d]*2,x=n[d+1]*2,v=n[d+2]*2,M=e[y],w=e[y+1],A=e[x],C=e[x+1],S=e[v],b=e[v+1],L=A-M,k=C-w,U=S-M,N=b-w,I=(L*N-k*U)*2;if(Math.abs(I)<1e-9){let B=1e9;const O=n[0]*2;B*=Math.sign((e[O]-M)*N-(e[O+1]-w)*U),g=(M+S)/2-B*N,m=(w+b)/2+B*U}else{const B=1/I,O=L*L+k*k,H=U*U+N*N;g=M+(N*O-k*H)*B,m=w+(L*H-U*O)*B}s[p]=g,s[p+1]=m}let a=t[t.length-1],o,l=a*4,c,h=e[2*a],u,f=e[2*a+1];i.fill(0);for(let d=0;d<t.length;++d)a=t[d],o=l,c=h,u=f,l=a*4,h=e[2*a],f=e[2*a+1],i[o+2]=i[l]=u-f,i[o+3]=i[l+1]=h-c}render(e){const t=e==null?e=new lr:void 0,{delaunay:{halfedges:n,inedges:i,hull:s},circumcenters:a,vectors:o}=this;if(s.length<=1)return null;for(let h=0,u=n.length;h<u;++h){const f=n[h];if(f<h)continue;const d=Math.floor(h/3)*2,p=Math.floor(f/3)*2,_=a[d],g=a[d+1],m=a[p],y=a[p+1];this._renderSegment(_,g,m,y,e)}let l,c=s[s.length-1];for(let h=0;h<s.length;++h){l=c,c=s[h];const u=Math.floor(i[c]/3)*2,f=a[u],d=a[u+1],p=l*4,_=this._project(f,d,o[p+2],o[p+3]);_&&this._renderSegment(f,d,_[0],_[1],e)}return t&&t.value()}renderBounds(e){const t=e==null?e=new lr:void 0;return e.rect(this.xmin,this.ymin,this.xmax-this.xmin,this.ymax-this.ymin),t&&t.value()}renderCell(e,t){const n=t==null?t=new lr:void 0,i=this._clip(e);if(i===null||!i.length)return;t.moveTo(i[0],i[1]);let s=i.length;for(;i[0]===i[s-2]&&i[1]===i[s-1]&&s>1;)s-=2;for(let a=2;a<s;a+=2)(i[a]!==i[a-2]||i[a+1]!==i[a-1])&&t.lineTo(i[a],i[a+1]);return t.closePath(),n&&n.value()}*cellPolygons(){const{delaunay:{points:e}}=this;for(let t=0,n=e.length/2;t<n;++t){const i=this.cellPolygon(t);i&&(i.index=t,yield i)}}cellPolygon(e){const t=new Au;return this.renderCell(e,t),t.value()}_renderSegment(e,t,n,i,s){let a;const o=this._regioncode(e,t),l=this._regioncode(n,i);o===0&&l===0?(s.moveTo(e,t),s.lineTo(n,i)):(a=this._clipSegment(e,t,n,i,o,l))&&(s.moveTo(a[0],a[1]),s.lineTo(a[2],a[3]))}contains(e,t,n){return t=+t,t!==t||(n=+n,n!==n)?!1:this.delaunay._step(e,t,n)===e}*neighbors(e){const t=this._clip(e);if(t)for(const n of this.delaunay.neighbors(e)){const i=this._clip(n);if(i){e:for(let s=0,a=t.length;s<a;s+=2)for(let o=0,l=i.length;o<l;o+=2)if(t[s]==i[o]&&t[s+1]==i[o+1]&&t[(s+2)%a]==i[(o+l-2)%l]&&t[(s+3)%a]==i[(o+l-1)%l]){yield n;break e}}}}_cell(e){const{circumcenters:t,delaunay:{inedges:n,halfedges:i,triangles:s}}=this,a=n[e];if(a===-1)return null;const o=[];let l=a;do{const c=Math.floor(l/3);if(o.push(t[c*2],t[c*2+1]),l=l%3===2?l-2:l+1,s[l]!==e)break;l=i[l]}while(l!==a&&l!==-1);return o}_clip(e){if(e===0&&this.delaunay.hull.length===1)return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];const t=this._cell(e);if(t===null)return null;const{vectors:n}=this,i=e*4;return n[i]||n[i+1]?this._clipInfinite(e,t,n[i],n[i+1],n[i+2],n[i+3]):this._clipFinite(e,t)}_clipFinite(e,t){const n=t.length;let i=null,s,a,o=t[n-2],l=t[n-1],c,h=this._regioncode(o,l),u,f=0;for(let d=0;d<n;d+=2)if(s=o,a=l,o=t[d],l=t[d+1],c=h,h=this._regioncode(o,l),c===0&&h===0)u=f,f=0,i?i.push(o,l):i=[o,l];else{let p,_,g,m,y;if(c===0){if((p=this._clipSegment(s,a,o,l,c,h))===null)continue;[_,g,m,y]=p}else{if((p=this._clipSegment(o,l,s,a,h,c))===null)continue;[m,y,_,g]=p,u=f,f=this._edgecode(_,g),u&&f&&this._edge(e,u,f,i,i.length),i?i.push(_,g):i=[_,g]}u=f,f=this._edgecode(m,y),u&&f&&this._edge(e,u,f,i,i.length),i?i.push(m,y):i=[m,y]}if(i)u=f,f=this._edgecode(i[0],i[1]),u&&f&&this._edge(e,u,f,i,i.length);else if(this.contains(e,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2))return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];return i}_clipSegment(e,t,n,i,s,a){for(;;){if(s===0&&a===0)return[e,t,n,i];if(s&a)return null;let o,l,c=s||a;c&8?(o=e+(n-e)*(this.ymax-t)/(i-t),l=this.ymax):c&4?(o=e+(n-e)*(this.ymin-t)/(i-t),l=this.ymin):c&2?(l=t+(i-t)*(this.xmax-e)/(n-e),o=this.xmax):(l=t+(i-t)*(this.xmin-e)/(n-e),o=this.xmin),s?(e=o,t=l,s=this._regioncode(e,t)):(n=o,i=l,a=this._regioncode(n,i))}}_clipInfinite(e,t,n,i,s,a){let o=Array.from(t),l;if((l=this._project(o[0],o[1],n,i))&&o.unshift(l[0],l[1]),(l=this._project(o[o.length-2],o[o.length-1],s,a))&&o.push(l[0],l[1]),o=this._clipFinite(e,o))for(let c=0,h=o.length,u,f=this._edgecode(o[h-2],o[h-1]);c<h;c+=2)u=f,f=this._edgecode(o[c],o[c+1]),u&&f&&(c=this._edge(e,u,f,o,c),h=o.length);else this.contains(e,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2)&&(o=[this.xmin,this.ymin,this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax]);return o}_edge(e,t,n,i,s){for(;t!==n;){let a,o;switch(t){case 5:t=4;continue;case 4:t=6,a=this.xmax,o=this.ymin;break;case 6:t=2;continue;case 2:t=10,a=this.xmax,o=this.ymax;break;case 10:t=8;continue;case 8:t=9,a=this.xmin,o=this.ymax;break;case 9:t=1;continue;case 1:t=5,a=this.xmin,o=this.ymin;break}(i[s]!==a||i[s+1]!==o)&&this.contains(e,a,o)&&(i.splice(s,0,a,o),s+=2)}if(i.length>4)for(let a=0;a<i.length;a+=2){const o=(a+2)%i.length,l=(a+4)%i.length;(i[a]===i[o]&&i[o]===i[l]||i[a+1]===i[o+1]&&i[o+1]===i[l+1])&&(i.splice(o,2),a-=2)}return s}_project(e,t,n,i){let s=1/0,a,o,l;if(i<0){if(t<=this.ymin)return null;(a=(this.ymin-t)/i)<s&&(l=this.ymin,o=e+(s=a)*n)}else if(i>0){if(t>=this.ymax)return null;(a=(this.ymax-t)/i)<s&&(l=this.ymax,o=e+(s=a)*n)}if(n>0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)<s&&(o=this.xmax,l=t+(s=a)*i)}else if(n<0){if(e<=this.xmin)return null;(a=(this.xmin-e)/n)<s&&(o=this.xmin,l=t+(s=a)*i)}return[o,l]}_edgecode(e,t){return(e===this.xmin?1:e===this.xmax?2:0)|(t===this.ymin?4:t===this.ymax?8:0)}_regioncode(e,t){return(e<this.xmin?1:e>this.xmax?2:0)|(t<this.ymin?4:t>this.ymax?8:0)}}const zw=2*Math.PI,os=Math.pow;function kw(r){return r[0]}function Gw(r){return r[1]}function Hw(r){const{triangles:e,coords:t}=r;for(let n=0;n<e.length;n+=3){const i=2*e[n],s=2*e[n+1],a=2*e[n+2];if((t[a]-t[i])*(t[s+1]-t[i+1])-(t[s]-t[i])*(t[a+1]-t[i+1])>1e-10)return!1}return!0}function Vw(r,e,t){return[r+Math.sin(r+e)*t,e+Math.cos(r-e)*t]}class Tu{static from(e,t=kw,n=Gw,i){return new Tu("length"in e?Ww(e,t,n,i):Float64Array.from(Xw(e,t,n,i)))}constructor(e){this._delaunator=new da(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&Hw(e)){this.collinear=Int32Array.from({length:t.length/2},(f,d)=>d).sort((f,d)=>t[2*f]-t[2*d]||t[2*f+1]-t[2*d+1]);const l=this.collinear[0],c=this.collinear[this.collinear.length-1],h=[t[2*l],t[2*l+1],t[2*c],t[2*c+1]],u=1e-8*Math.hypot(h[3]-h[1],h[2]-h[0]);for(let f=0,d=t.length/2;f<d;++f){const p=Vw(t[2*f],t[2*f+1],u);t[2*f]=p[0],t[2*f+1]=p[1]}this._delaunator=new da(t)}else delete this.collinear;const n=this.halfedges=this._delaunator.halfedges,i=this.hull=this._delaunator.hull,s=this.triangles=this._delaunator.triangles,a=this.inedges.fill(-1),o=this._hullIndex.fill(-1);for(let l=0,c=n.length;l<c;++l){const h=s[l%3===2?l-2:l+1];(n[l]===-1||a[h]===-1)&&(a[h]=l)}for(let l=0,c=i.length;l<c;++l)o[i[l]]=l;i.length<=2&&i.length>0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=i[0],a[i[0]]=1,i.length===2&&(a[i[1]]=0,this.triangles[1]=i[1],this.triangles[2]=i[1]))}voronoi(e){return new Bw(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:i,halfedges:s,triangles:a,collinear:o}=this;if(o){const u=o.indexOf(e);u>0&&(yield o[u-1]),u<o.length-1&&(yield o[u+1]);return}const l=t[e];if(l===-1)return;let c=l,h=-1;do{if(yield h=a[c],c=c%3===2?c-2:c+1,a[c]!==e)return;if(c=s[c],c===-1){const u=n[(i[e]+1)%n.length];u!==h&&(yield u);return}}while(c!==l)}find(e,t,n=0){if(e=+e,e!==e||(t=+t,t!==t))return-1;const i=n;let s;for(;(s=this._step(n,e,t))>=0&&s!==n&&s!==i;)n=s;return s}_step(e,t,n){const{inedges:i,hull:s,_hullIndex:a,halfedges:o,triangles:l,points:c}=this;if(i[e]===-1||!c.length)return(e+1)%(c.length>>1);let h=e,u=os(t-c[e*2],2)+os(n-c[e*2+1],2);const f=i[e];let d=f;do{let p=l[d];const _=os(t-c[p*2],2)+os(n-c[p*2+1],2);if(_<u&&(u=_,h=p),d=d%3===2?d-2:d+1,l[d]!==e)break;if(d=o[d],d===-1){if(d=s[(a[e]+1)%s.length],d!==p&&os(t-c[d*2],2)+os(n-c[d*2+1],2)<u)return d;break}}while(d!==f);return h}render(e){const t=e==null?e=new lr:void 0,{points:n,halfedges:i,triangles:s}=this;for(let a=0,o=i.length;a<o;++a){const l=i[a];if(l<a)continue;const c=s[a]*2,h=s[l]*2;e.moveTo(n[c],n[c+1]),e.lineTo(n[h],n[h+1])}return this.renderHull(e),t&&t.value()}renderPoints(e,t){t===void 0&&(!e||typeof e.moveTo!="function")&&(t=e,e=null),t=t==null?2:+t;const n=e==null?e=new lr:void 0,{points:i}=this;for(let s=0,a=i.length;s<a;s+=2){const o=i[s],l=i[s+1];e.moveTo(o+t,l),e.arc(o,l,t,0,zw)}return n&&n.value()}renderHull(e){const t=e==null?e=new lr:void 0,{hull:n,points:i}=this,s=n[0]*2,a=n.length;e.moveTo(i[s],i[s+1]);for(let o=1;o<a;++o){const l=2*n[o];e.lineTo(i[l],i[l+1])}return e.closePath(),t&&t.value()}hullPolygon(){const e=new Au;return this.renderHull(e),e.value()}renderTriangle(e,t){const n=t==null?t=new lr:void 0,{points:i,triangles:s}=this,a=s[e*=3]*2,o=s[e+1]*2,l=s[e+2]*2;return t.moveTo(i[a],i[a+1]),t.lineTo(i[o],i[o+1]),t.lineTo(i[l],i[l+1]),t.closePath(),n&&n.value()}*trianglePolygons(){const{triangles:e}=this;for(let t=0,n=e.length/3;t<n;++t)yield this.trianglePolygon(t)}trianglePolygon(e){const t=new Au;return this.renderTriangle(e,t),t.value()}}function Ww(r,e,t,n){const i=r.length,s=new Float64Array(i*2);for(let a=0;a<i;++a){const o=r[a];s[a*2]=e.call(n,o,a,r),s[a*2+1]=t.call(n,o,a,r)}return s}function*Xw(r,e,t,n){let i=0;for(const s of r)yield e.call(n,s,i,r),yield t.call(n,s,i,r),++i}const Ru=Math.PI,Bg=Ru/2,zg=180/Ru,kg=Ru/180,qw=Math.atan2,Gg=Math.cos,$w=Math.max,Yw=Math.min,Hg=Math.sin,Zw=Math.sign||function(r){return r>0?1:r<0?-1:0},Vg=Math.sqrt;function Jw(r){return r>1?Bg:r<-1?-Bg:Math.asin(r)}function Wg(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]}function pn(r,e){return[r[1]*e[2]-r[2]*e[1],r[2]*e[0]-r[0]*e[2],r[0]*e[1]-r[1]*e[0]]}function Pl(r,e){return[r[0]+e[0],r[1]+e[1],r[2]+e[2]]}function Ll(r){var e=Vg(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);return[r[0]/e,r[1]/e,r[2]/e]}function Cu(r){return[qw(r[1],r[0])*zg,Jw($w(-1,Yw(1,r[2])))*zg]}function Gn(r){const e=r[0]*kg,t=r[1]*kg,n=Gg(t);return[n*Gg(e),n*Hg(e),Hg(t)]}function Pu(r){return r=r.map(e=>Gn(e)),Wg(r[0],pn(r[2],r[1]))}function Kw(r){const e=Qw(r),t=tE(e),n=eE(t,r),i=iE(t,r.length),s=jw(i,r),a=nE(t,r),{polygons:o,centers:l}=rE(a,t,r),c=sE(o),h=oE(t,r),u=aE(n,t);return{delaunay:e,edges:n,triangles:t,centers:l,neighbors:i,polygons:o,mesh:c,hull:h,urquhart:u,find:s}}function jw(r,e){function t(n,i){let s=n[0]-i[0],a=n[1]-i[1],o=n[2]-i[2];return s*s+a*a+o*o}return function(i,s,a){a===void 0&&(a=0);let o,l,c=a;const h=Gn([i,s]);do o=a,a=null,l=t(h,Gn(e[o])),r[o].forEach(u=>{let f=t(h,Gn(e[u]));if(f<l){l=f,a=u,c=u;return}});while(a!==null);return c}}function Qw(r){if(r.length<2)return{};let e=0;for(;isNaN(r[e][0]+r[e][1])&&e++<r.length;);const t=ng(r[e]),n=J1().translate([0,0]).scale(1).rotate(t.invert([180,0]));r=r.map(n);const i=[];let s=1;for(let u=0,f=r.length;u<f;u++){let d=us(r[u][0],2)+us(r[u][1],2);!isFinite(d)||d>1e32?i.push(u):d>s&&(s=d)}const a=1e6*Vg(s);i.forEach(u=>r[u]=[a,0]),r.push([0,a]),r.push([-a,0]),r.push([0,-a]);const o=Tu.from(r);o.projection=n;const{triangles:l,halfedges:c,inedges:h}=o;for(let u=0,f=c.length;u<f;u++)if(c[u]<0){const d=u%3==2?u-2:u+1,p=u%3==0?u+2:u-1,_=c[d],g=c[p];c[_]=g,c[g]=_,c[d]=c[p]=-1,l[u]=l[d]=l[p]=e,h[l[_]]=_%3==0?_+2:_-1,h[l[g]]=g%3==0?g+2:g-1,u+=2-u%3}else l[u]>r.length-3-1&&(l[u]=e);return o}function eE(r,e){const t=new Set;return e.length===2?[[0,1]]:(r.forEach(n=>{if(n[0]!==n[1]&&!(Pu(n.map(i=>e[i]))<0))for(let i=0,s;i<3;i++)s=(i+1)%3,t.add(Ko([n[i],n[s]]).join("-"))}),Array.from(t,n=>n.split("-").map(Number)))}function tE(r){const{triangles:e}=r;if(!e)return[];const t=[];for(let n=0,i=e.length/3;n<i;n++){const s=e[3*n],a=e[3*n+1],o=e[3*n+2];s!==a&&a!==o&&t.push([s,o,a])}return t}function nE(r,e){return r.map(t=>{const n=t.map(s=>e[s]).map(Gn),i=Pl(Pl(pn(n[1],n[0]),pn(n[2],n[1])),pn(n[0],n[2]));return Cu(Ll(i))})}function iE(r,e){const t=[];return r.forEach(n=>{for(let i=0;i<3;i++){const s=n[i],a=n[(i+1)%3];t[s]=t[s]||[],t[s].push(a)}}),r.length===0&&(e===2?(t[0]=[1],t[1]=[0]):e===1&&(t[0]=[])),t}function rE(r,e,t){const n=[],i=r.slice();if(e.length===0){if(t.length<2)return{polygons:n,centers:i};if(t.length===2){const o=Gn(t[0]),l=Gn(t[1]),c=Ll(Pl(o,l)),h=Ll(pn(o,l)),u=pn(c,h),f=[c,pn(c,u),pn(pn(c,u),u),pn(pn(pn(c,u),u),u)].map(Cu).map(a);return n.push(f),n.push(f.slice().reverse()),{polygons:n,centers:i}}}e.forEach((o,l)=>{for(let c=0;c<3;c++){const h=o[c],u=o[(c+1)%3],f=o[(c+2)%3];n[h]=n[h]||[],n[h].push([u,f,l,[h,u,f]])}});const s=n.map(o=>{const l=[o[0][2]];let c=o[0][1];for(let h=1;h<o.length;h++)for(let u=0;u<o.length;u++)if(o[u][0]==c){c=o[u][1],l.push(o[u][2]);break}if(l.length>2)return l;if(l.length==2){const h=Xg(t[o[0][3][0]],t[o[0][3][1]],i[l[0]]),u=Xg(t[o[0][3][2]],t[o[0][3][0]],i[l[0]]),f=a(h),d=a(u);return[l[0],d,l[1],f]}});function a(o){let l=-1;return i.slice(e.length,1/0).forEach((c,h)=>{c[0]===o[0]&&c[1]===o[1]&&(l=h+e.length)}),l<0&&(l=i.length,i.push(o)),l}return{polygons:s,centers:i}}function Xg(r,e,t){r=Gn(r),e=Gn(e),t=Gn(t);const n=Zw(Wg(pn(e,r),t));return Cu(Ll(Pl(r,e)).map(i=>n*i))}function sE(r){const e=[];return r.forEach(t=>{if(!t)return;let n=t[t.length-1];for(let i of t)i>n&&e.push([n,i]),n=i}),e}function aE(r,e){return function(t){const n=new Map,i=new Map;return r.forEach((s,a)=>{const o=s.join("-");n.set(o,t[a]),i.set(o,!0)}),e.forEach(s=>{let a=0,o=-1;for(let l=0;l<3;l++){let c=Ko([s[l],s[(l+1)%3]]).join("-");n.get(c)>a&&(a=n.get(c),o=c)}i.set(o,!1)}),r.map(s=>i.get(s.join("-")))}}function oE(r,e){const t=new Set,n=[];r.map(o=>{if(!(Pu(o.map(l=>e[l>e.length?0:l]))>1e-12))for(let l=0;l<3;l++){let c=[o[l],o[(l+1)%3]],h=`${c[0]}-${c[1]}`;t.has(h)?t.delete(h):t.add(`${c[1]}-${c[0]}`)}});const i=new Map;let s;if(t.forEach(o=>{o=o.split("-").map(Number),i.set(o[0],o[1]),s=o[0]}),s===void 0)return n;let a=s;do{n.push(a);let o=i.get(a);i.set(a,-1),a=o}while(a>-1&&a!==s);return n}function lE(r){const e=function(t){if(e.delaunay=null,e._data=t,typeof e._data=="object"&&e._data.type==="FeatureCollection"&&(e._data=e._data.features),typeof e._data=="object"){const n=e._data.map(i=>[e._vx(i),e._vy(i),i]).filter(i=>isFinite(i[0]+i[1]));e.points=n.map(i=>[i[0],i[1]]),e.valid=n.map(i=>i[2]),e.delaunay=Kw(e.points)}return e};return e._vx=function(t){if(typeof t=="object"&&"type"in t)return Km(t)[0];if(0 in t)return t[0]},e._vy=function(t){if(typeof t=="object"&&"type"in t)return Km(t)[1];if(1 in t)return t[1]},e.x=function(t){return t?(e._vx=t,e):e._vx},e.y=function(t){return t?(e._vy=t,e):e._vy},e.polygons=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n={type:"FeatureCollection",features:[]};return e.valid.length===0||(e.delaunay.polygons.forEach((i,s)=>n.features.push({type:"Feature",geometry:i?{type:"Polygon",coordinates:[[...i,i[0]].map(a=>e.delaunay.centers[a])]}:null,properties:{site:e.valid[s],sitecoordinates:e.points[s],neighbours:e.delaunay.neighbors[s]}})),e.valid.length===1&&n.features.push({type:"Feature",geometry:{type:"Sphere"},properties:{site:e.valid[0],sitecoordinates:e.points[0],neighbours:[]}})),n},e.triangles=function(t){return t!==void 0&&e(t),e.delaunay?{type:"FeatureCollection",features:e.delaunay.triangles.map((n,i)=>(n=n.map(s=>e.points[s]),n.center=e.delaunay.centers[i],n)).filter(n=>Pu(n)>0).map(n=>({type:"Feature",properties:{circumcenter:n.center},geometry:{type:"Polygon",coordinates:[[...n,n[0]]]}}))}:!1},e.links=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n=e.delaunay.edges.map(s=>ts(e.points[s[0]],e.points[s[1]])),i=e.delaunay.urquhart(n);return{type:"FeatureCollection",features:e.delaunay.edges.map((s,a)=>({type:"Feature",properties:{source:e.valid[s[0]],target:e.valid[s[1]],length:n[a],urquhart:!!i[a]},geometry:{type:"LineString",coordinates:[e.points[s[0]],e.points[s[1]]]}}))}},e.mesh=function(t){return t!==void 0&&e(t),e.delaunay?{type:"MultiLineString",coordinates:e.delaunay.edges.map(n=>[e.points[n[0]],e.points[n[1]]])}:!1},e.cellMesh=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const{centers:n,polygons:i}=e.delaunay,s=[];for(const a of i)if(a)for(let o=a.length,l=a[o-1],c=a[0],h=0;h<o;l=c,c=a[++h])c>l&&s.push([n[l],n[c]]);return{type:"MultiLineString",coordinates:s}},e._found=void 0,e.find=function(t,n,i){if(e._found=e.delaunay.find(t,n,e._found),!i||ts([t,n],e.points[e._found])<i)return e._found},e.hull=function(t){t!==void 0&&e(t);const n=e.delaunay.hull,i=e.points;return n.length===0?null:{type:"Polygon",coordinates:[[...n.map(s=>i[s]),i[n[0]]]]}},r?e(r):e}function cE(r,e){switch(arguments.length){case 0:break;case 1:this.range(r);break;default:this.range(e).domain(r);break}return this}function Lu(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function qg(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function ma(){}var ga=.7,Il=1/ga,ls="\\s*([+-]?\\d+)\\s*",_a="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Hn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",hE=/^#([0-9a-f]{3,8})$/,uE=new RegExp(`^rgb\\(${ls},${ls},${ls}\\)$`),fE=new RegExp(`^rgb\\(${Hn},${Hn},${Hn}\\)$`),dE=new RegExp(`^rgba\\(${ls},${ls},${ls},${_a}\\)$`),pE=new RegExp(`^rgba\\(${Hn},${Hn},${Hn},${_a}\\)$`),mE=new RegExp(`^hsl\\(${_a},${Hn},${Hn}\\)$`),gE=new RegExp(`^hsla\\(${_a},${Hn},${Hn},${_a}\\)$`),$g={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};Lu(ma,xa,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:Yg,formatHex:Yg,formatHex8:_E,formatHsl:xE,formatRgb:Zg,toString:Zg});function Yg(){return this.rgb().formatHex()}function _E(){return this.rgb().formatHex8()}function xE(){return e0(this).formatHsl()}function Zg(){return this.rgb().formatRgb()}function xa(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=hE.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Jg(e):t===3?new sn(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?Ul(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?Ul(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=uE.exec(r))?new sn(e[1],e[2],e[3],1):(e=fE.exec(r))?new sn(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=dE.exec(r))?Ul(e[1],e[2],e[3],e[4]):(e=pE.exec(r))?Ul(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=mE.exec(r))?Qg(e[1],e[2]/100,e[3]/100,1):(e=gE.exec(r))?Qg(e[1],e[2]/100,e[3]/100,e[4]):$g.hasOwnProperty(r)?Jg($g[r]):r==="transparent"?new sn(NaN,NaN,NaN,0):null}function Jg(r){return new sn(r>>16&255,r>>8&255,r&255,1)}function Ul(r,e,t,n){return n<=0&&(r=e=t=NaN),new sn(r,e,t,n)}function yE(r){return r instanceof ma||(r=xa(r)),r?(r=r.rgb(),new sn(r.r,r.g,r.b,r.opacity)):new sn}function Iu(r,e,t,n){return arguments.length===1?yE(r):new sn(r,e,t,n==null?1:n)}function sn(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}Lu(sn,Iu,qg(ma,{brighter(r){return r=r==null?Il:Math.pow(Il,r),new sn(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?ga:Math.pow(ga,r),new sn(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new sn(cr(this.r),cr(this.g),cr(this.b),Dl(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Kg,formatHex:Kg,formatHex8:vE,formatRgb:jg,toString:jg}));function Kg(){return`#${hr(this.r)}${hr(this.g)}${hr(this.b)}`}function vE(){return`#${hr(this.r)}${hr(this.g)}${hr(this.b)}${hr((isNaN(this.opacity)?1:this.opacity)*255)}`}function jg(){const r=Dl(this.opacity);return`${r===1?"rgb(":"rgba("}${cr(this.r)}, ${cr(this.g)}, ${cr(this.b)}${r===1?")":`, ${r})`}`}function Dl(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function cr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function hr(r){return r=cr(r),(r<16?"0":"")+r.toString(16)}function Qg(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new In(r,e,t,n)}function e0(r){if(r instanceof In)return new In(r.h,r.s,r.l,r.opacity);if(r instanceof ma||(r=xa(r)),!r)return new In;if(r instanceof In)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,i=Math.min(e,t,n),s=Math.max(e,t,n),a=NaN,o=s-i,l=(s+i)/2;return o?(e===s?a=(t-n)/o+(t<n)*6:t===s?a=(n-e)/o+2:a=(e-t)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new In(a,o,l,r.opacity)}function ME(r,e,t,n){return arguments.length===1?e0(r):new In(r,e,t,n==null?1:n)}function In(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}Lu(In,ME,qg(ma,{brighter(r){return r=r==null?Il:Math.pow(Il,r),new In(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?ga:Math.pow(ga,r),new In(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,i=2*t-n;return new sn(Uu(r>=240?r-240:r+120,i,n),Uu(r,i,n),Uu(r<120?r+240:r-120,i,n),this.opacity)},clamp(){return new In(t0(this.h),Nl(this.s),Nl(this.l),Dl(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Dl(this.opacity);return`${r===1?"hsl(":"hsla("}${t0(this.h)}, ${Nl(this.s)*100}%, ${Nl(this.l)*100}%${r===1?")":`, ${r})`}`}}));function t0(r){return r=(r||0)%360,r<0?r+360:r}function Nl(r){return Math.max(0,Math.min(1,r||0))}function Uu(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}var Du=r=>()=>r;function SE(r,e){return function(t){return r+t*e}}function bE(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function wE(r){return(r=+r)==1?n0:function(e,t){return t-e?bE(e,t,r):Du(isNaN(e)?t:e)}}function n0(r,e){var t=e-r;return t?SE(r,t):Du(isNaN(r)?e:r)}var i0=function r(e){var t=wE(e);function n(i,s){var a=t((i=Iu(i)).r,(s=Iu(s)).r),o=t(i.g,s.g),l=t(i.b,s.b),c=n0(i.opacity,s.opacity);return function(h){return i.r=a(h),i.g=o(h),i.b=l(h),i.opacity=c(h),i+""}}return n.gamma=r,n}(1);function EE(r,e){e||(e=[]);var t=r?Math.min(e.length,r.length):0,n=e.slice(),i;return function(s){for(i=0;i<t;++i)n[i]=r[i]*(1-s)+e[i]*s;return n}}function AE(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function TE(r,e){var t=e?e.length:0,n=r?Math.min(t,r.length):0,i=new Array(n),s=new Array(t),a;for(a=0;a<n;++a)i[a]=Ou(r[a],e[a]);for(;a<t;++a)s[a]=e[a];return function(o){for(a=0;a<n;++a)s[a]=i[a](o);return s}}function RE(r,e){var t=new Date;return r=+r,e=+e,function(n){return t.setTime(r*(1-n)+e*n),t}}function Fl(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}function CE(r,e){var t={},n={},i;(r===null||typeof r!="object")&&(r={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in r?t[i]=Ou(r[i],e[i]):n[i]=e[i];return function(s){for(i in t)n[i]=t[i](s);return n}}var Nu=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fu=new RegExp(Nu.source,"g");function PE(r){return function(){return r}}function LE(r){return function(e){return r(e)+""}}function IE(r,e){var t=Nu.lastIndex=Fu.lastIndex=0,n,i,s,a=-1,o=[],l=[];for(r=r+"",e=e+"";(n=Nu.exec(r))&&(i=Fu.exec(e));)(s=i.index)>t&&(s=e.slice(t,s),o[a]?o[a]+=s:o[++a]=s),(n=n[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:Fl(n,i)})),t=Fu.lastIndex;return t<e.length&&(s=e.slice(t),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?LE(l[0].x):PE(e):(e=l.length,function(c){for(var h=0,u;h<e;++h)o[(u=l[h]).i]=u.x(c);return o.join("")})}function Ou(r,e){var t=typeof e,n;return e==null||t==="boolean"?Du(e):(t==="number"?Fl:t==="string"?(n=xa(e))?(e=n,i0):IE:e instanceof xa?i0:e instanceof Date?RE:AE(e)?EE:Array.isArray(e)?TE:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?CE:Fl)(r,e)}function UE(r,e){return r=+r,e=+e,function(t){return Math.round(r*(1-t)+e*t)}}function DE(r){return function(){return r}}function NE(r){return+r}var r0=[0,1];function cs(r){return r}function Bu(r,e){return(e-=r=+r)?function(t){return(t-r)/e}:DE(isNaN(e)?NaN:.5)}function FE(r,e){var t;return r>e&&(t=r,r=e,e=t),function(n){return Math.max(r,Math.min(e,n))}}function OE(r,e,t){var n=r[0],i=r[1],s=e[0],a=e[1];return i<n?(n=Bu(i,n),s=t(a,s)):(n=Bu(n,i),s=t(s,a)),function(o){return s(n(o))}}function BE(r,e,t){var n=Math.min(r.length,e.length)-1,i=new Array(n),s=new Array(n),a=-1;for(r[n]<r[0]&&(r=r.slice().reverse(),e=e.slice().reverse());++a<n;)i[a]=Bu(r[a],r[a+1]),s[a]=t(e[a],e[a+1]);return function(o){var l=$b(r,o,1,n)-1;return s[l](i[l](o))}}function zE(r,e){return e.domain(r.domain()).range(r.range()).interpolate(r.interpolate()).clamp(r.clamp()).unknown(r.unknown())}function kE(){var r=r0,e=r0,t=Ou,n,i,s,a=cs,o,l,c;function h(){var f=Math.min(r.length,e.length);return a!==cs&&(a=FE(r[0],r[f-1])),o=f>2?BE:OE,l=c=null,u}function u(f){return f==null||isNaN(f=+f)?s:(l||(l=o(r.map(n),e,t)))(n(a(f)))}return u.invert=function(f){return a(i((c||(c=o(e,r.map(n),Fl)))(f)))},u.domain=function(f){return arguments.length?(r=Array.from(f,NE),h()):r.slice()},u.range=function(f){return arguments.length?(e=Array.from(f),h()):e.slice()},u.rangeRound=function(f){return e=Array.from(f),t=UE,h()},u.clamp=function(f){return arguments.length?(a=f?!0:cs,h()):a!==cs},u.interpolate=function(f){return arguments.length?(t=f,h()):t},u.unknown=function(f){return arguments.length?(s=f,u):s},function(f,d){return n=f,i=d,h()}}function GE(){return kE()(cs,cs)}function HE(r){return Math.abs(r=Math.round(r))>=1e21?r.toLocaleString("en").replace(/,/g,""):r.toString(10)}function Ol(r,e){if((t=(r=e?r.toExponential(e-1):r.toExponential()).indexOf("e"))<0)return null;var t,n=r.slice(0,t);return[n.length>1?n[0]+n.slice(2):n,+r.slice(t+1)]}function hs(r){return r=Ol(Math.abs(r)),r?r[1]:NaN}function VE(r,e){return function(t,n){for(var i=t.length,s=[],a=0,o=r[0],l=0;i>0&&o>0&&(l+o+1>n&&(o=Math.max(1,n-l)),s.push(t.substring(i-=o,i+o)),!((l+=o+1)>n));)o=r[a=(a+1)%r.length];return s.reverse().join(e)}}function WE(r){return function(e){return e.replace(/[0-9]/g,function(t){return r[+t]})}}var XE=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Bl(r){if(!(e=XE.exec(r)))throw new Error("invalid format: "+r);var e;return new zu({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}Bl.prototype=zu.prototype;function zu(r){this.fill=r.fill===void 0?" ":r.fill+"",this.align=r.align===void 0?">":r.align+"",this.sign=r.sign===void 0?"-":r.sign+"",this.symbol=r.symbol===void 0?"":r.symbol+"",this.zero=!!r.zero,this.width=r.width===void 0?void 0:+r.width,this.comma=!!r.comma,this.precision=r.precision===void 0?void 0:+r.precision,this.trim=!!r.trim,this.type=r.type===void 0?"":r.type+""}zu.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function qE(r){e:for(var e=r.length,t=1,n=-1,i;t<e;++t)switch(r[t]){case".":n=i=t;break;case"0":n===0&&(n=t),i=t;break;default:if(!+r[t])break e;n>0&&(n=0);break}return n>0?r.slice(0,n)+r.slice(i+1):r}var s0;function $E(r,e){var t=Ol(r,e);if(!t)return r+"";var n=t[0],i=t[1],s=i-(s0=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,a=n.length;return s===a?n:s>a?n+new Array(s-a+1).join("0"):s>0?n.slice(0,s)+"."+n.slice(s):"0."+new Array(1-s).join("0")+Ol(r,Math.max(0,e+s-1))[0]}function a0(r,e){var t=Ol(r,e);if(!t)return r+"";var n=t[0],i=t[1];return i<0?"0."+new Array(-i).join("0")+n:n.length>i+1?n.slice(0,i+1)+"."+n.slice(i+1):n+new Array(i-n.length+2).join("0")}var o0={"%":(r,e)=>(r*100).toFixed(e),b:r=>Math.round(r).toString(2),c:r=>r+"",d:HE,e:(r,e)=>r.toExponential(e),f:(r,e)=>r.toFixed(e),g:(r,e)=>r.toPrecision(e),o:r=>Math.round(r).toString(8),p:(r,e)=>a0(r*100,e),r:a0,s:$E,X:r=>Math.round(r).toString(16).toUpperCase(),x:r=>Math.round(r).toString(16)};function l0(r){return r}var c0=Array.prototype.map,h0=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function YE(r){var e=r.grouping===void 0||r.thousands===void 0?l0:VE(c0.call(r.grouping,Number),r.thousands+""),t=r.currency===void 0?"":r.currency[0]+"",n=r.currency===void 0?"":r.currency[1]+"",i=r.decimal===void 0?".":r.decimal+"",s=r.numerals===void 0?l0:WE(c0.call(r.numerals,String)),a=r.percent===void 0?"%":r.percent+"",o=r.minus===void 0?"−":r.minus+"",l=r.nan===void 0?"NaN":r.nan+"";function c(u){u=Bl(u);var f=u.fill,d=u.align,p=u.sign,_=u.symbol,g=u.zero,m=u.width,y=u.comma,x=u.precision,v=u.trim,M=u.type;M==="n"?(y=!0,M="g"):o0[M]||(x===void 0&&(x=12),v=!0,M="g"),(g||f==="0"&&d==="=")&&(g=!0,f="0",d="=");var w=_==="$"?t:_==="#"&&/[boxX]/.test(M)?"0"+M.toLowerCase():"",A=_==="$"?n:/[%p]/.test(M)?a:"",C=o0[M],S=/[defgprs%]/.test(M);x=x===void 0?6:/[gprs]/.test(M)?Math.max(1,Math.min(21,x)):Math.max(0,Math.min(20,x));function b(L){var k=w,U=A,N,I,B;if(M==="c")U=C(L)+U,L="";else{L=+L;var O=L<0||1/L<0;if(L=isNaN(L)?l:C(Math.abs(L),x),v&&(L=qE(L)),O&&+L==0&&p!=="+"&&(O=!1),k=(O?p==="("?p:o:p==="-"||p==="("?"":p)+k,U=(M==="s"?h0[8+s0/3]:"")+U+(O&&p==="("?")":""),S){for(N=-1,I=L.length;++N<I;)if(B=L.charCodeAt(N),48>B||B>57){U=(B===46?i+L.slice(N+1):L.slice(N))+U,L=L.slice(0,N);break}}}y&&!g&&(L=e(L,1/0));var H=k.length+L.length+U.length,X=H<m?new Array(m-H+1).join(f):"";switch(y&&g&&(L=e(X+L,X.length?m-U.length:1/0),X=""),d){case"<":L=k+L+U+X;break;case"=":L=k+X+L+U;break;case"^":L=X.slice(0,H=X.length>>1)+k+L+U+X.slice(H);break;default:L=X+k+L+U;break}return s(L)}return b.toString=function(){return u+""},b}function h(u,f){var d=c((u=Bl(u),u.type="f",u)),p=Math.max(-8,Math.min(8,Math.floor(hs(f)/3)))*3,_=Math.pow(10,-p),g=h0[8+p/3];return function(m){return d(_*m)+g}}return{format:c,formatPrefix:h}}var zl,u0,f0;ZE({thousands:",",grouping:[3],currency:["$",""]});function ZE(r){return zl=YE(r),u0=zl.format,f0=zl.formatPrefix,zl}function JE(r){return Math.max(0,-hs(Math.abs(r)))}function KE(r,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(hs(e)/3)))*3-hs(Math.abs(r)))}function jE(r,e){return r=Math.abs(r),e=Math.abs(e)-r,Math.max(0,hs(e)-hs(r))+1}function QE(r,e,t,n){var i=jb(r,e,t),s;switch(n=Bl(n==null?",f":n),n.type){case"s":{var a=Math.max(Math.abs(r),Math.abs(e));return n.precision==null&&!isNaN(s=KE(i,a))&&(n.precision=s),f0(n,a)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(s=jE(i,Math.max(Math.abs(r),Math.abs(e))))&&(n.precision=s-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(s=JE(i))&&(n.precision=s-(n.type==="%")*2);break}}return u0(n)}function eA(r){var e=r.domain;return r.ticks=function(t){var n=e();return Kb(n[0],n[n.length-1],t==null?10:t)},r.tickFormat=function(t,n){var i=e();return QE(i[0],i[i.length-1],t==null?10:t,n)},r.nice=function(t){t==null&&(t=10);var n=e(),i=0,s=n.length-1,a=n[i],o=n[s],l,c,h=10;for(o<a&&(c=a,a=o,o=c,c=i,i=s,s=c);h-- >0;){if(c=Kh(a,o,t),c===l)return n[i]=a,n[s]=o,e(n);if(c>0)a=Math.floor(a/c)*c,o=Math.ceil(o/c)*c;else if(c<0)a=Math.ceil(a*c)/c,o=Math.floor(o*c)/c;else break;l=c}return r},r}function ku(){var r=GE();return r.copy=function(){return zE(r,ku())},cE.apply(r,arguments),eA(r)}function tA(r,e){return r.map(t=>{const n=[];let i;return t.forEach(s=>{if(i){const a=ts(s,i)*180/Math.PI;if(a>e){const o=D1(i,s),l=1/Math.ceil(a/e);let c=l;for(;c<1;)n.push(o(c)),c+=l}}n.push(i=s)}),n})}function nA(r,{minLng:e,maxLng:t,minLat:n,maxLat:i}={}){const s=Math.round(us(360/r,2)/Math.PI),a=(1+Math.sqrt(5))/2,o=d=>d/a*360%360-180,l=d=>Math.acos(2*d/s-1)/Math.PI*180-90,c=d=>s*(Math.cos((d+90)*Math.PI/180)+1)/2,h=[i!==void 0?Math.ceil(c(i)):0,n!==void 0?Math.floor(c(n)):s-1],u=e===void 0&&t===void 0?()=>!0:e===void 0?d=>d<=t:t===void 0?d=>d>=e:t>=e?d=>d>=e&&d<=t:d=>d>=e||d<=t,f=[];for(let d=h[0];d<=h[1];d++){const p=o(d);u(p)&&f.push([p,l(d)])}return f}function Gu(r,e,t=!1){return t?U1(e,r):Fw(r,e)}function iA(r,e){const t={type:"Polygon",coordinates:r},[[n,i],[s,a]]=Xm(t);if(Math.min(Math.abs(s-n),Math.abs(a-i))<e)return[];const o=n>s||a>=89||i<=-89;return nA(e,{minLng:n,maxLng:s,minLat:i,maxLat:a}).filter(l=>Gu(l,t,o))}function rA(r,{resolution:e=1/0}={}){const t=tA(r,e),n=ia(t),i=iA(r,e),s=[...n,...i],a={type:"Polygon",coordinates:r},[[o,l],[c,h]]=Xm(a),u=o>c||h>=89||l<=-89;let f=[];if(u){const m=lE(s).triangles(),y=new Map(s.map(([x,v],M)=>[`${x}-${v}`,M]));m.features.forEach(x=>{const v=x.geometry.coordinates[0].slice(0,3).reverse(),M=[];if(v.forEach(([w,A])=>{const C=`${w}-${A}`;y.has(C)&&M.push(y.get(C))}),M.length===3){if(M.some(w=>w<n.length)){const w=x.properties.circumcenter;if(!Gu(w,a,u))return}f.push(...M)}})}else if(i.length){const m=da.from(s);for(let y=0,x=m.triangles.length;y<x;y+=3){const v=[2,1,0].map(w=>m.triangles[y+w]),M=v.map(w=>s[w]);if(v.some(w=>w<n.length)){const w=[0,1].map(A=>Qb(M,C=>C[A]));if(!Gu(w,a,u))continue}f.push(...v)}}else{const{vertices:m,holes:y=[]}=is.flatten(t);f=is(m,y,2)}const d=ku(Ko(s,m=>m[0]),[0,1]),p=ku(Ko(s,m=>m[1]),[0,1]),_=s.map(([m,y])=>[d(m),p(y)]);return{contour:t,triangles:{points:s,indices:f,uvs:_}}}const d0=new Fe().setAttribute?"setAttribute":"addAttribute";function kl(r,e,t=!0){const n=r.map(i=>i.map(([s,a])=>t?bw(s,a,e):[s,a,e]));return is.flatten(n)}function sA(r,e,t,n=!0){const{vertices:i,holes:s}=kl(r,e,n),{vertices:a}=kl(r,t,n),o=ia([a,i]),l=Math.round(a.length/3),c=new Set(s);let h=0;const u=[];for(let d=0;d<l;d++){let p=d+1;if(p===l)p=h;else if(c.has(p)){const _=p;p=h,h=_}u.push(d,d+l,p+l),u.push(p+l,p,d)}const f=[];for(let d=1;d>=0;d--)for(let p=0;p<l;p+=1)f.push(p/(l-1),d);return{indices:u,vertices:o,uvs:f,topVerts:a}}function p0(r,e,t,n=!0,i=!0){return{indices:n?r.indices:r.indices.slice().reverse(),vertices:kl([r.points],e,i).vertices,uvs:t}}const m0=({polygonGeoJson:r,startHeight:e,endHeight:t,curvatureResolution:n=1,cartesian:i=!0,hasSide:s=!0,hasBottom:a=!1,hasTop:o=!1})=>{r.forEach(_=>{Sw(_)||_.reverse()});const{contour:l,triangles:c}=rA(r,{resolution:n});let h={},u;s&&(h=sA(l,e!=null?e:t,t!=null?t:e,i),u=h.topVerts);let f=[];(a||o)&&(f=ia(c.uvs));let d={};a&&(d=p0(c,e,f,!1,i));let p={};return o&&(p=p0(c,t,f,!0,i)),{contour:l,triangles:c,sideTorso:h,bottomCap:d,topCap:p,topVerts:u}};class aA extends Fe{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=Wl({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:n,hasTop:i,hasBottom:s,hasSide:a,cartesian:o,userDataRsoOffset:l}=this.parameters,{contour:c,sideTorso:h,topVerts:u,bottomCap:f,topCap:d}=m0(Wl({},this.parameters));let p=[],_=[],g=[],m=0;const y=x=>{const v=Math.round(p.length/3),M=g.length;p=p.concat(x.vertices),_=_.concat(x.uvs),g=g.concat(v?x.indices.map(w=>w+v):x.indices),this.addGroup(M,g.length-M,m++)};a&&(y(h),this.userData.topVerts=l?kl(c,n+l,o).vertices:u),s&&y(f),i&&y(d),this.setIndex(g),this[d0]("position",new ve(p,3)),this[d0]("uv",new ve(_,2)),this.computeVertexNormals()}}var oA=r=>{const o=r,{coordinate:e,startHeight:t,height:n}=o,i=T0(o,["coordinate","startHeight","height"]);let s=t||0;return typeof t!="undefined"&&typeof n!="undefined"&&(s=t+n),new aA([e],A0(Wl({},i),{startHeight:t,endHeight:s}))};const lA=({coordinatesArr:r,start:e,height:t,useGroups:n,hasTop:i,hasBottom:s,hasSide:a})=>{const o=r.map((l,c)=>{var h,u;return oA({coordinate:l,startHeight:(h=e[c])!=null?h:e[0],height:(u=t[c])!=null?u:t[0],hasTop:i!=null?i:!0,hasBottom:s!=null?s:!0,hasSide:a!=null?a:!0})});return bl(o,n)},cA=({coordinatesArr:r,lineWidth:e,start:t,useGroups:n})=>{const s=r.map((a,o)=>{var l;return m0({polygonGeoJson:[a],startHeight:(l=t[o])!=null?l:t[0]}).topVerts}).map((a,o)=>{var c;const l=(c=e[o])!=null?c:e[0];return Tg({nodes:a,setPointWidth:()=>l})});return bl(s,n)};var hA=(r,e,t)=>new Promise((n,i)=>{var s=l=>{try{o(t.next(l))}catch(c){i(c)}},a=l=>{try{o(t.throw(l))}catch(c){i(c)}},o=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);o((t=t.apply(r,e)).next())});function Hu(r){this.message=r||"promise cancelled",this.stack=new Error().stack}Hu.prototype=new Error,Hu.prototype.constructor=Error,Hu.prototype.name="CancellationError";function Vu(r){this.message=r||"timeout exceeded",this.stack=new Error().stack}Vu.prototype=new Error,Vu.prototype.constructor=Error,Vu.prototype.name="TimeoutError";function g0(r){return Object.getOwnPropertyNames(r).reduce(function(e,t){return Object.defineProperty(e,t,{value:r[t],enumerable:!0})},{})}let Wu=null;const Xu={run(r,e){const t=new Function("return ("+r+").apply(null, arguments);");return t.apply(t,e)},methods(){return Object.keys(Xu)}};addEventListener("message",r=>hA(void 0,[r],function*({data:e}){try{const t=Xu[e.method];if(t){Wu=e.id;try{const n=yield t.apply(t,e.params);n.transfer&&n.message?postMessage({id:e.id,result:n.message,error:null},n.transfer):postMessage({id:e.id,result:n,error:null}),Wu=null}catch(n){postMessage({id:e.id,result:null,error:g0(n)}),Wu=null}}else throw new Error('Unknown method "'+e.method+'"')}catch(t){postMessage({id:e.id,result:null,error:g0(t)})}})),(r=>{Object.keys(r).forEach(e=>{Xu[e]=r[e]}),postMessage("ready")})({extrudePolygon:Q1,line:nw,conicPolygon:lA,conicLine:cA})})();
3555
+ }`;function HM(r,e,t){let n=new no;const i=new q,s=new q,a=new rt,o=new lh({depthPacking:Of}),l=new ch,c={},h=t.maxTextureSize,u={[Xn]:kt,[kt]:Xn,[Nn]:Nn},f=new zn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new q},radius:{value:4}},vertexShader:kM,fragmentShader:GM}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const p=new Fe;p.setAttribute("position",new Ze(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new It(p,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Mn;let m=this.type;this.render=function(M,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||M.length===0)return;const C=r.getRenderTarget(),S=r.getActiveCubeFace(),b=r.getActiveMipmapLevel(),L=r.state;L.setBlending(qn),L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const k=m!==Dn&&this.type===Dn,U=m===Dn&&this.type!==Dn;for(let N=0,I=M.length;N<I;N++){const B=M[N],O=B.shadow;if(O===void 0){console.warn("THREE.WebGLShadowMap:",B,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;i.copy(O.mapSize);const H=O.getFrameExtents();if(i.multiply(H),s.copy(O.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/H.x),i.x=s.x*H.x,O.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/H.y),i.y=s.y*H.y,O.mapSize.y=s.y)),O.map===null||k===!0||U===!0){const ee=this.type!==Dn?{minFilter:yt,magFilter:yt}:{};O.map!==null&&O.map.dispose(),O.map=new bn(i.x,i.y,ee),O.map.texture.name=B.name+".shadowMap",O.camera.updateProjectionMatrix()}r.setRenderTarget(O.map),r.clear();const X=O.getViewportCount();for(let ee=0;ee<X;ee++){const z=O.getViewport(ee);a.set(s.x*z.x,s.y*z.y,s.x*z.z,s.y*z.w),L.viewport(a),O.updateMatrices(B,ee),n=O.getFrustum(),v(w,A,O.camera,B,this.type)}O.isPointLightShadow!==!0&&this.type===Dn&&y(O,A),O.needsUpdate=!1}m=this.type,g.needsUpdate=!1,r.setRenderTarget(C,S,b)};function y(M,w){const A=e.update(_);f.defines.VSM_SAMPLES!==M.blurSamples&&(f.defines.VSM_SAMPLES=M.blurSamples,d.defines.VSM_SAMPLES=M.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),M.mapPass===null&&(M.mapPass=new bn(i.x,i.y)),f.uniforms.shadow_pass.value=M.map.texture,f.uniforms.resolution.value=M.mapSize,f.uniforms.radius.value=M.radius,r.setRenderTarget(M.mapPass),r.clear(),r.renderBufferDirect(w,null,A,f,_,null),d.uniforms.shadow_pass.value=M.mapPass.texture,d.uniforms.resolution.value=M.mapSize,d.uniforms.radius.value=M.radius,r.setRenderTarget(M.map),r.clear(),r.renderBufferDirect(w,null,A,d,_,null)}function x(M,w,A,C){let S=null;const b=A.isPointLight===!0?M.customDistanceMaterial:M.customDepthMaterial;if(b!==void 0)S=b;else if(S=A.isPointLight===!0?l:o,r.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const L=S.uuid,k=w.uuid;let U=c[L];U===void 0&&(U={},c[L]=U);let N=U[k];N===void 0&&(N=S.clone(),U[k]=N),S=N}if(S.visible=w.visible,S.wireframe=w.wireframe,C===Dn?S.side=w.shadowSide!==null?w.shadowSide:w.side:S.side=w.shadowSide!==null?w.shadowSide:u[w.side],S.alphaMap=w.alphaMap,S.alphaTest=w.alphaTest,S.map=w.map,S.clipShadows=w.clipShadows,S.clippingPlanes=w.clippingPlanes,S.clipIntersection=w.clipIntersection,S.displacementMap=w.displacementMap,S.displacementScale=w.displacementScale,S.displacementBias=w.displacementBias,S.wireframeLinewidth=w.wireframeLinewidth,S.linewidth=w.linewidth,A.isPointLight===!0&&S.isMeshDistanceMaterial===!0){const L=r.properties.get(S);L.light=A}return S}function v(M,w,A,C,S){if(M.visible===!1)return;if(M.layers.test(w.layers)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&S===Dn)&&(!M.frustumCulled||n.intersectsObject(M))){M.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,M.matrixWorld);const k=e.update(M),U=M.material;if(Array.isArray(U)){const N=k.groups;for(let I=0,B=N.length;I<B;I++){const O=N[I],H=U[O.materialIndex];if(H&&H.visible){const X=x(M,H,C,S);r.renderBufferDirect(A,null,k,X,M,O)}}}else if(U.visible){const N=x(M,U,C,S);r.renderBufferDirect(A,null,k,N,M,null)}}const L=M.children;for(let k=0,U=L.length;k<U;k++)v(L[k],w,A,C,S)}}function VM(r,e,t){const n=t.isWebGL2;function i(){let F=!1;const _e=new rt;let Y=null;const ue=new rt(0,0,0,0);return{setMask:function(xe){Y!==xe&&!F&&(r.colorMask(xe,xe,xe,xe),Y=xe)},setLocked:function(xe){F=xe},setClear:function(xe,nt,ut,Pt,Vn){Vn===!0&&(xe*=Pt,nt*=Pt,ut*=Pt),_e.set(xe,nt,ut,Pt),ue.equals(_e)===!1&&(r.clearColor(xe,nt,ut,Pt),ue.copy(_e))},reset:function(){F=!1,Y=null,ue.set(-1,0,0,0)}}}function s(){let F=!1,_e=null,Y=null,ue=null;return{setTest:function(xe){xe?Pe(r.DEPTH_TEST):Te(r.DEPTH_TEST)},setMask:function(xe){_e!==xe&&!F&&(r.depthMask(xe),_e=xe)},setFunc:function(xe){if(Y!==xe){switch(xe){case hf:r.depthFunc(r.NEVER);break;case uf:r.depthFunc(r.ALWAYS);break;case ff:r.depthFunc(r.LESS);break;case Ma:r.depthFunc(r.LEQUAL);break;case df:r.depthFunc(r.EQUAL);break;case pf:r.depthFunc(r.GEQUAL);break;case mf:r.depthFunc(r.GREATER);break;case gf:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}Y=xe}},setLocked:function(xe){F=xe},setClear:function(xe){ue!==xe&&(r.clearDepth(xe),ue=xe)},reset:function(){F=!1,_e=null,Y=null,ue=null}}}function a(){let F=!1,_e=null,Y=null,ue=null,xe=null,nt=null,ut=null,Pt=null,Vn=null;return{setTest:function(gt){F||(gt?Pe(r.STENCIL_TEST):Te(r.STENCIL_TEST))},setMask:function(gt){_e!==gt&&!F&&(r.stencilMask(gt),_e=gt)},setFunc:function(gt,Wn,Yt){(Y!==gt||ue!==Wn||xe!==Yt)&&(r.stencilFunc(gt,Wn,Yt),Y=gt,ue=Wn,xe=Yt)},setOp:function(gt,Wn,Yt){(nt!==gt||ut!==Wn||Pt!==Yt)&&(r.stencilOp(gt,Wn,Yt),nt=gt,ut=Wn,Pt=Yt)},setLocked:function(gt){F=gt},setClear:function(gt){Vn!==gt&&(r.clearStencil(gt),Vn=gt)},reset:function(){F=!1,_e=null,Y=null,ue=null,xe=null,nt=null,ut=null,Pt=null,Vn=null}}}const o=new i,l=new s,c=new a,h=new WeakMap,u=new WeakMap;let f={},d={},p=new WeakMap,_=[],g=null,m=!1,y=null,x=null,v=null,M=null,w=null,A=null,C=null,S=!1,b=null,L=null,k=null,U=null,N=null;const I=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let B=!1,O=0;const H=r.getParameter(r.VERSION);H.indexOf("WebGL")!==-1?(O=parseFloat(/^WebGL (\d)/.exec(H)[1]),B=O>=1):H.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),B=O>=2);let X=null,ee={};const z=r.getParameter(r.SCISSOR_BOX),Z=r.getParameter(r.VIEWPORT),le=new rt().fromArray(z),ce=new rt().fromArray(Z);function fe(F,_e,Y,ue){const xe=new Uint8Array(4),nt=r.createTexture();r.bindTexture(F,nt),r.texParameteri(F,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(F,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let ut=0;ut<Y;ut++)n&&(F===r.TEXTURE_3D||F===r.TEXTURE_2D_ARRAY)?r.texImage3D(_e,0,r.RGBA,1,1,ue,0,r.RGBA,r.UNSIGNED_BYTE,xe):r.texImage2D(_e+ut,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,xe);return nt}const Ae={};Ae[r.TEXTURE_2D]=fe(r.TEXTURE_2D,r.TEXTURE_2D,1),Ae[r.TEXTURE_CUBE_MAP]=fe(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(Ae[r.TEXTURE_2D_ARRAY]=fe(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),Ae[r.TEXTURE_3D]=fe(r.TEXTURE_3D,r.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),l.setClear(1),c.setClear(0),Pe(r.DEPTH_TEST),l.setFunc(Ma),re(!1),Ee(dr),Pe(r.CULL_FACE),Q(qn);function Pe(F){f[F]!==!0&&(r.enable(F),f[F]=!0)}function Te(F){f[F]!==!1&&(r.disable(F),f[F]=!1)}function Ke(F,_e){return d[F]!==_e?(r.bindFramebuffer(F,_e),d[F]=_e,n&&(F===r.DRAW_FRAMEBUFFER&&(d[r.FRAMEBUFFER]=_e),F===r.FRAMEBUFFER&&(d[r.DRAW_FRAMEBUFFER]=_e)),!0):!1}function je(F,_e){let Y=_,ue=!1;if(F)if(Y=p.get(_e),Y===void 0&&(Y=[],p.set(_e,Y)),F.isWebGLMultipleRenderTargets){const xe=F.texture;if(Y.length!==xe.length||Y[0]!==r.COLOR_ATTACHMENT0){for(let nt=0,ut=xe.length;nt<ut;nt++)Y[nt]=r.COLOR_ATTACHMENT0+nt;Y.length=xe.length,ue=!0}}else Y[0]!==r.COLOR_ATTACHMENT0&&(Y[0]=r.COLOR_ATTACHMENT0,ue=!0);else Y[0]!==r.BACK&&(Y[0]=r.BACK,ue=!0);ue&&(t.isWebGL2?r.drawBuffers(Y):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Y))}function Le(F){return g!==F?(r.useProgram(F),g=F,!0):!1}const D={[Di]:r.FUNC_ADD,[ju]:r.FUNC_SUBTRACT,[Qu]:r.FUNC_REVERSE_SUBTRACT};if(n)D[Zl]=r.MIN,D[Jl]=r.MAX;else{const F=e.get("EXT_blend_minmax");F!==null&&(D[Zl]=F.MIN_EXT,D[Jl]=F.MAX_EXT)}const ae={[ef]:r.ZERO,[tf]:r.ONE,[nf]:r.SRC_COLOR,[Kl]:r.SRC_ALPHA,[cf]:r.SRC_ALPHA_SATURATE,[of]:r.DST_COLOR,[sf]:r.DST_ALPHA,[rf]:r.ONE_MINUS_SRC_COLOR,[jl]:r.ONE_MINUS_SRC_ALPHA,[lf]:r.ONE_MINUS_DST_COLOR,[af]:r.ONE_MINUS_DST_ALPHA};function Q(F,_e,Y,ue,xe,nt,ut,Pt){if(F===qn){m===!0&&(Te(r.BLEND),m=!1);return}if(m===!1&&(Pe(r.BLEND),m=!0),F!==Ku){if(F!==y||Pt!==S){if((x!==Di||w!==Di)&&(r.blendEquation(r.FUNC_ADD),x=Di,w=Di),Pt)switch(F){case Ui:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case ql:r.blendFunc(r.ONE,r.ONE);break;case $l:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Yl:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",F);break}else switch(F){case Ui:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case ql:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case $l:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Yl:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",F);break}v=null,M=null,A=null,C=null,y=F,S=Pt}return}xe=xe||_e,nt=nt||Y,ut=ut||ue,(_e!==x||xe!==w)&&(r.blendEquationSeparate(D[_e],D[xe]),x=_e,w=xe),(Y!==v||ue!==M||nt!==A||ut!==C)&&(r.blendFuncSeparate(ae[Y],ae[ue],ae[nt],ae[ut]),v=Y,M=ue,A=nt,C=ut),y=F,S=!1}function oe(F,_e){F.side===Nn?Te(r.CULL_FACE):Pe(r.CULL_FACE);let Y=F.side===kt;_e&&(Y=!Y),re(Y),F.blending===Ui&&F.transparent===!1?Q(qn):Q(F.blending,F.blendEquation,F.blendSrc,F.blendDst,F.blendEquationAlpha,F.blendSrcAlpha,F.blendDstAlpha,F.premultipliedAlpha),l.setFunc(F.depthFunc),l.setTest(F.depthTest),l.setMask(F.depthWrite),o.setMask(F.colorWrite);const ue=F.stencilWrite;c.setTest(ue),ue&&(c.setMask(F.stencilWriteMask),c.setFunc(F.stencilFunc,F.stencilRef,F.stencilFuncMask),c.setOp(F.stencilFail,F.stencilZFail,F.stencilZPass)),J(F.polygonOffset,F.polygonOffsetFactor,F.polygonOffsetUnits),F.alphaToCoverage===!0?Pe(r.SAMPLE_ALPHA_TO_COVERAGE):Te(r.SAMPLE_ALPHA_TO_COVERAGE)}function re(F){b!==F&&(F?r.frontFace(r.CW):r.frontFace(r.CCW),b=F)}function Ee(F){F!==Jt?(Pe(r.CULL_FACE),F!==L&&(F===dr?r.cullFace(r.BACK):F===va?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):Te(r.CULL_FACE),L=F}function $(F){F!==k&&(B&&r.lineWidth(F),k=F)}function J(F,_e,Y){F?(Pe(r.POLYGON_OFFSET_FILL),(U!==_e||N!==Y)&&(r.polygonOffset(_e,Y),U=_e,N=Y)):Te(r.POLYGON_OFFSET_FILL)}function ne(F){F?Pe(r.SCISSOR_TEST):Te(r.SCISSOR_TEST)}function de(F){F===void 0&&(F=r.TEXTURE0+I-1),X!==F&&(r.activeTexture(F),X=F)}function pe(F,_e,Y){Y===void 0&&(X===null?Y=r.TEXTURE0+I-1:Y=X);let ue=ee[Y];ue===void 0&&(ue={type:void 0,texture:void 0},ee[Y]=ue),(ue.type!==F||ue.texture!==_e)&&(X!==Y&&(r.activeTexture(Y),X=Y),r.bindTexture(F,_e||Ae[F]),ue.type=F,ue.texture=_e)}function T(){const F=ee[X];F!==void 0&&F.type!==void 0&&(r.bindTexture(F.type,null),F.type=void 0,F.texture=void 0)}function E(){try{r.compressedTexImage2D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function W(){try{r.compressedTexImage3D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function se(){try{r.texSubImage2D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function ie(){try{r.texSubImage3D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function me(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function we(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function he(){try{r.texStorage2D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function K(){try{r.texStorage3D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function Re(){try{r.texImage2D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function Ce(){try{r.texImage3D.apply(r,arguments)}catch(F){console.error("THREE.WebGLState:",F)}}function Ie(F){le.equals(F)===!1&&(r.scissor(F.x,F.y,F.z,F.w),le.copy(F))}function be(F){ce.equals(F)===!1&&(r.viewport(F.x,F.y,F.z,F.w),ce.copy(F))}function Me(F,_e){let Y=u.get(_e);Y===void 0&&(Y=new WeakMap,u.set(_e,Y));let ue=Y.get(F);ue===void 0&&(ue=r.getUniformBlockIndex(_e,F.name),Y.set(F,ue))}function qe(F,_e){const ue=u.get(_e).get(F);h.get(_e)!==ue&&(r.uniformBlockBinding(_e,ue,F.__bindingPointIndex),h.set(_e,ue))}function at(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),n===!0&&(r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),f={},X=null,ee={},d={},p=new WeakMap,_=[],g=null,m=!1,y=null,x=null,v=null,M=null,w=null,A=null,C=null,S=!1,b=null,L=null,k=null,U=null,N=null,le.set(0,0,r.canvas.width,r.canvas.height),ce.set(0,0,r.canvas.width,r.canvas.height),o.reset(),l.reset(),c.reset()}return{buffers:{color:o,depth:l,stencil:c},enable:Pe,disable:Te,bindFramebuffer:Ke,drawBuffers:je,useProgram:Le,setBlending:Q,setMaterial:oe,setFlipSided:re,setCullFace:Ee,setLineWidth:$,setPolygonOffset:J,setScissorTest:ne,activeTexture:de,bindTexture:pe,unbindTexture:T,compressedTexImage2D:E,compressedTexImage3D:W,texImage2D:Re,texImage3D:Ce,updateUBOMapping:Me,uniformBlockBinding:qe,texStorage2D:he,texStorage3D:K,texSubImage2D:se,texSubImage3D:ie,compressedTexSubImage2D:me,compressedTexSubImage3D:we,scissor:Ie,viewport:be,reset:at}}function WM(r,e,t,n,i,s,a){const o=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,h=i.maxTextureSize,u=i.maxSamples,f=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,d=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap;let _;const g=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(T){}function y(T,E){return m?new OffscreenCanvas(T,E):As("canvas")}function x(T,E,W,se){let ie=1;if((T.width>se||T.height>se)&&(ie=se/Math.max(T.width,T.height)),ie<1||E===!0)if(typeof HTMLImageElement!="undefined"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&T instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&T instanceof ImageBitmap){const me=E?Da:Math.floor,we=me(ie*T.width),he=me(ie*T.height);_===void 0&&(_=y(we,he));const K=W?y(we,he):_;return K.width=we,K.height=he,K.getContext("2d").drawImage(T,0,0,we,he),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+T.width+"x"+T.height+") to ("+we+"x"+he+")."),K}else return"data"in T&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+T.width+"x"+T.height+")."),T;return T}function v(T){return Dc(T.width)&&Dc(T.height)}function M(T){return o?!1:T.wrapS!==Dt||T.wrapT!==Dt||T.minFilter!==yt&&T.minFilter!==vt}function w(T,E){return T.generateMipmaps&&E&&T.minFilter!==yt&&T.minFilter!==vt}function A(T){r.generateMipmap(T)}function C(T,E,W,se,ie=!1){if(o===!1)return E;if(T!==null){if(r[T]!==void 0)return r[T];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let me=E;return E===r.RED&&(W===r.FLOAT&&(me=r.R32F),W===r.HALF_FLOAT&&(me=r.R16F),W===r.UNSIGNED_BYTE&&(me=r.R8)),E===r.RG&&(W===r.FLOAT&&(me=r.RG32F),W===r.HALF_FLOAT&&(me=r.RG16F),W===r.UNSIGNED_BYTE&&(me=r.RG8)),E===r.RGBA&&(W===r.FLOAT&&(me=r.RGBA32F),W===r.HALF_FLOAT&&(me=r.RGBA16F),W===r.UNSIGNED_BYTE&&(me=se===Ge&&ie===!1?r.SRGB8_ALPHA8:r.RGBA8),W===r.UNSIGNED_SHORT_4_4_4_4&&(me=r.RGBA4),W===r.UNSIGNED_SHORT_5_5_5_1&&(me=r.RGB5_A1)),(me===r.R16F||me===r.R32F||me===r.RG16F||me===r.RG32F||me===r.RGBA16F||me===r.RGBA32F)&&e.get("EXT_color_buffer_float"),me}function S(T,E,W){return w(T,W)===!0||T.isFramebufferTexture&&T.minFilter!==yt&&T.minFilter!==vt?Math.log2(Math.max(E.width,E.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?E.mipmaps.length:1}function b(T){return T===yt||T===ba||T===ys?r.NEAREST:r.LINEAR}function L(T){const E=T.target;E.removeEventListener("dispose",L),U(E),E.isVideoTexture&&p.delete(E)}function k(T){const E=T.target;E.removeEventListener("dispose",k),I(E)}function U(T){const E=n.get(T);if(E.__webglInit===void 0)return;const W=T.source,se=g.get(W);if(se){const ie=se[E.__cacheKey];ie.usedTimes--,ie.usedTimes===0&&N(T),Object.keys(se).length===0&&g.delete(W)}n.remove(T)}function N(T){const E=n.get(T);r.deleteTexture(E.__webglTexture);const W=T.source,se=g.get(W);delete se[E.__cacheKey],a.memory.textures--}function I(T){const E=T.texture,W=n.get(T),se=n.get(E);if(se.__webglTexture!==void 0&&(r.deleteTexture(se.__webglTexture),a.memory.textures--),T.depthTexture&&T.depthTexture.dispose(),T.isWebGLCubeRenderTarget)for(let ie=0;ie<6;ie++)r.deleteFramebuffer(W.__webglFramebuffer[ie]),W.__webglDepthbuffer&&r.deleteRenderbuffer(W.__webglDepthbuffer[ie]);else{if(r.deleteFramebuffer(W.__webglFramebuffer),W.__webglDepthbuffer&&r.deleteRenderbuffer(W.__webglDepthbuffer),W.__webglMultisampledFramebuffer&&r.deleteFramebuffer(W.__webglMultisampledFramebuffer),W.__webglColorRenderbuffer)for(let ie=0;ie<W.__webglColorRenderbuffer.length;ie++)W.__webglColorRenderbuffer[ie]&&r.deleteRenderbuffer(W.__webglColorRenderbuffer[ie]);W.__webglDepthRenderbuffer&&r.deleteRenderbuffer(W.__webglDepthRenderbuffer)}if(T.isWebGLMultipleRenderTargets)for(let ie=0,me=E.length;ie<me;ie++){const we=n.get(E[ie]);we.__webglTexture&&(r.deleteTexture(we.__webglTexture),a.memory.textures--),n.remove(E[ie])}n.remove(E),n.remove(T)}let B=0;function O(){B=0}function H(){const T=B;return T>=l&&console.warn("THREE.WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+l),B+=1,T}function X(T){const E=[];return E.push(T.wrapS),E.push(T.wrapT),E.push(T.wrapR||0),E.push(T.magFilter),E.push(T.minFilter),E.push(T.anisotropy),E.push(T.internalFormat),E.push(T.format),E.push(T.type),E.push(T.generateMipmaps),E.push(T.premultiplyAlpha),E.push(T.flipY),E.push(T.unpackAlignment),E.push(T.colorSpace),E.join()}function ee(T,E){const W=n.get(T);if(T.isVideoTexture&&de(T),T.isRenderTargetTexture===!1&&T.version>0&&W.__version!==T.version){const se=T.image;if(se===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(se.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ke(W,T,E);return}}t.bindTexture(r.TEXTURE_2D,W.__webglTexture,r.TEXTURE0+E)}function z(T,E){const W=n.get(T);if(T.version>0&&W.__version!==T.version){Ke(W,T,E);return}t.bindTexture(r.TEXTURE_2D_ARRAY,W.__webglTexture,r.TEXTURE0+E)}function Z(T,E){const W=n.get(T);if(T.version>0&&W.__version!==T.version){Ke(W,T,E);return}t.bindTexture(r.TEXTURE_3D,W.__webglTexture,r.TEXTURE0+E)}function le(T,E){const W=n.get(T);if(T.version>0&&W.__version!==T.version){je(W,T,E);return}t.bindTexture(r.TEXTURE_CUBE_MAP,W.__webglTexture,r.TEXTURE0+E)}const ce={[_s]:r.REPEAT,[Dt]:r.CLAMP_TO_EDGE,[xs]:r.MIRRORED_REPEAT},fe={[yt]:r.NEAREST,[ba]:r.NEAREST_MIPMAP_NEAREST,[ys]:r.NEAREST_MIPMAP_LINEAR,[vt]:r.LINEAR,[Ql]:r.LINEAR_MIPMAP_NEAREST,[gi]:r.LINEAR_MIPMAP_LINEAR},Ae={[kf]:r.NEVER,[$f]:r.ALWAYS,[Gf]:r.LESS,[Vf]:r.LEQUAL,[Hf]:r.EQUAL,[qf]:r.GEQUAL,[Wf]:r.GREATER,[Xf]:r.NOTEQUAL};function Pe(T,E,W){if(W?(r.texParameteri(T,r.TEXTURE_WRAP_S,ce[E.wrapS]),r.texParameteri(T,r.TEXTURE_WRAP_T,ce[E.wrapT]),(T===r.TEXTURE_3D||T===r.TEXTURE_2D_ARRAY)&&r.texParameteri(T,r.TEXTURE_WRAP_R,ce[E.wrapR]),r.texParameteri(T,r.TEXTURE_MAG_FILTER,fe[E.magFilter]),r.texParameteri(T,r.TEXTURE_MIN_FILTER,fe[E.minFilter])):(r.texParameteri(T,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(T,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),(T===r.TEXTURE_3D||T===r.TEXTURE_2D_ARRAY)&&r.texParameteri(T,r.TEXTURE_WRAP_R,r.CLAMP_TO_EDGE),(E.wrapS!==Dt||E.wrapT!==Dt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(T,r.TEXTURE_MAG_FILTER,b(E.magFilter)),r.texParameteri(T,r.TEXTURE_MIN_FILTER,b(E.minFilter)),E.minFilter!==yt&&E.minFilter!==vt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),E.compareFunction&&(r.texParameteri(T,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(T,r.TEXTURE_COMPARE_FUNC,Ae[E.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const se=e.get("EXT_texture_filter_anisotropic");if(E.magFilter===yt||E.minFilter!==ys&&E.minFilter!==gi||E.type===On&&e.has("OES_texture_float_linear")===!1||o===!1&&E.type===gr&&e.has("OES_texture_half_float_linear")===!1)return;(E.anisotropy>1||n.get(E).__currentAnisotropy)&&(r.texParameterf(T,se.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(E.anisotropy,i.getMaxAnisotropy())),n.get(E).__currentAnisotropy=E.anisotropy)}}function Te(T,E){let W=!1;T.__webglInit===void 0&&(T.__webglInit=!0,E.addEventListener("dispose",L));const se=E.source;let ie=g.get(se);ie===void 0&&(ie={},g.set(se,ie));const me=X(E);if(me!==T.__cacheKey){ie[me]===void 0&&(ie[me]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,W=!0),ie[me].usedTimes++;const we=ie[T.__cacheKey];we!==void 0&&(ie[T.__cacheKey].usedTimes--,we.usedTimes===0&&N(E)),T.__cacheKey=me,T.__webglTexture=ie[me].texture}return W}function Ke(T,E,W){let se=r.TEXTURE_2D;(E.isDataArrayTexture||E.isCompressedArrayTexture)&&(se=r.TEXTURE_2D_ARRAY),E.isData3DTexture&&(se=r.TEXTURE_3D);const ie=Te(T,E),me=E.source;t.bindTexture(se,T.__webglTexture,r.TEXTURE0+W);const we=n.get(me);if(me.version!==we.__version||ie===!0){t.activeTexture(r.TEXTURE0+W),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,E.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE);const he=M(E)&&v(E.image)===!1;let K=x(E.image,he,!1,h);K=pe(E,K);const Re=v(K)||o,Ce=s.convert(E.format,E.colorSpace);let Ie=s.convert(E.type),be=C(E.internalFormat,Ce,Ie,E.colorSpace);Pe(se,E,Re);let Me;const qe=E.mipmaps,at=o&&E.isVideoTexture!==!0,F=we.__version===void 0||ie===!0,_e=S(E,K,Re);if(E.isDepthTexture)be=r.DEPTH_COMPONENT,o?E.type===On?be=r.DEPTH_COMPONENT32F:E.type===Yn?be=r.DEPTH_COMPONENT24:E.type===_i?be=r.DEPTH24_STENCIL8:be=r.DEPTH_COMPONENT16:E.type===On&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),E.format===xi&&be===r.DEPTH_COMPONENT&&E.type!==wa&&E.type!==Yn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),E.type=Yn,Ie=s.convert(E.type)),E.format===Ni&&be===r.DEPTH_COMPONENT&&(be=r.DEPTH_STENCIL,E.type!==_i&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),E.type=_i,Ie=s.convert(E.type))),F&&(at?t.texStorage2D(r.TEXTURE_2D,1,be,K.width,K.height):t.texImage2D(r.TEXTURE_2D,0,be,K.width,K.height,0,Ce,Ie,null));else if(E.isDataTexture)if(qe.length>0&&Re){at&&F&&t.texStorage2D(r.TEXTURE_2D,_e,be,qe[0].width,qe[0].height);for(let Y=0,ue=qe.length;Y<ue;Y++)Me=qe[Y],at?t.texSubImage2D(r.TEXTURE_2D,Y,0,0,Me.width,Me.height,Ce,Ie,Me.data):t.texImage2D(r.TEXTURE_2D,Y,be,Me.width,Me.height,0,Ce,Ie,Me.data);E.generateMipmaps=!1}else at?(F&&t.texStorage2D(r.TEXTURE_2D,_e,be,K.width,K.height),t.texSubImage2D(r.TEXTURE_2D,0,0,0,K.width,K.height,Ce,Ie,K.data)):t.texImage2D(r.TEXTURE_2D,0,be,K.width,K.height,0,Ce,Ie,K.data);else if(E.isCompressedTexture)if(E.isCompressedArrayTexture){at&&F&&t.texStorage3D(r.TEXTURE_2D_ARRAY,_e,be,qe[0].width,qe[0].height,K.depth);for(let Y=0,ue=qe.length;Y<ue;Y++)Me=qe[Y],E.format!==an?Ce!==null?at?t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,Y,0,0,0,Me.width,Me.height,K.depth,Ce,Me.data,0,0):t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,Y,be,Me.width,Me.height,K.depth,0,Me.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):at?t.texSubImage3D(r.TEXTURE_2D_ARRAY,Y,0,0,0,Me.width,Me.height,K.depth,Ce,Ie,Me.data):t.texImage3D(r.TEXTURE_2D_ARRAY,Y,be,Me.width,Me.height,K.depth,0,Ce,Ie,Me.data)}else{at&&F&&t.texStorage2D(r.TEXTURE_2D,_e,be,qe[0].width,qe[0].height);for(let Y=0,ue=qe.length;Y<ue;Y++)Me=qe[Y],E.format!==an?Ce!==null?at?t.compressedTexSubImage2D(r.TEXTURE_2D,Y,0,0,Me.width,Me.height,Ce,Me.data):t.compressedTexImage2D(r.TEXTURE_2D,Y,be,Me.width,Me.height,0,Me.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):at?t.texSubImage2D(r.TEXTURE_2D,Y,0,0,Me.width,Me.height,Ce,Ie,Me.data):t.texImage2D(r.TEXTURE_2D,Y,be,Me.width,Me.height,0,Ce,Ie,Me.data)}else if(E.isDataArrayTexture)at?(F&&t.texStorage3D(r.TEXTURE_2D_ARRAY,_e,be,K.width,K.height,K.depth),t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,K.width,K.height,K.depth,Ce,Ie,K.data)):t.texImage3D(r.TEXTURE_2D_ARRAY,0,be,K.width,K.height,K.depth,0,Ce,Ie,K.data);else if(E.isData3DTexture)at?(F&&t.texStorage3D(r.TEXTURE_3D,_e,be,K.width,K.height,K.depth),t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,K.width,K.height,K.depth,Ce,Ie,K.data)):t.texImage3D(r.TEXTURE_3D,0,be,K.width,K.height,K.depth,0,Ce,Ie,K.data);else if(E.isFramebufferTexture){if(F)if(at)t.texStorage2D(r.TEXTURE_2D,_e,be,K.width,K.height);else{let Y=K.width,ue=K.height;for(let xe=0;xe<_e;xe++)t.texImage2D(r.TEXTURE_2D,xe,be,Y,ue,0,Ce,Ie,null),Y>>=1,ue>>=1}}else if(qe.length>0&&Re){at&&F&&t.texStorage2D(r.TEXTURE_2D,_e,be,qe[0].width,qe[0].height);for(let Y=0,ue=qe.length;Y<ue;Y++)Me=qe[Y],at?t.texSubImage2D(r.TEXTURE_2D,Y,0,0,Ce,Ie,Me):t.texImage2D(r.TEXTURE_2D,Y,be,Ce,Ie,Me);E.generateMipmaps=!1}else at?(F&&t.texStorage2D(r.TEXTURE_2D,_e,be,K.width,K.height),t.texSubImage2D(r.TEXTURE_2D,0,0,0,Ce,Ie,K)):t.texImage2D(r.TEXTURE_2D,0,be,Ce,Ie,K);w(E,Re)&&A(se),we.__version=me.version,E.onUpdate&&E.onUpdate(E)}T.__version=E.version}function je(T,E,W){if(E.image.length!==6)return;const se=Te(T,E),ie=E.source;t.bindTexture(r.TEXTURE_CUBE_MAP,T.__webglTexture,r.TEXTURE0+W);const me=n.get(ie);if(ie.version!==me.__version||se===!0){t.activeTexture(r.TEXTURE0+W),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,E.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE);const we=E.isCompressedTexture||E.image[0].isCompressedTexture,he=E.image[0]&&E.image[0].isDataTexture,K=[];for(let Y=0;Y<6;Y++)!we&&!he?K[Y]=x(E.image[Y],!1,!0,c):K[Y]=he?E.image[Y].image:E.image[Y],K[Y]=pe(E,K[Y]);const Re=K[0],Ce=v(Re)||o,Ie=s.convert(E.format,E.colorSpace),be=s.convert(E.type),Me=C(E.internalFormat,Ie,be,E.colorSpace),qe=o&&E.isVideoTexture!==!0,at=me.__version===void 0||se===!0;let F=S(E,Re,Ce);Pe(r.TEXTURE_CUBE_MAP,E,Ce);let _e;if(we){qe&&at&&t.texStorage2D(r.TEXTURE_CUBE_MAP,F,Me,Re.width,Re.height);for(let Y=0;Y<6;Y++){_e=K[Y].mipmaps;for(let ue=0;ue<_e.length;ue++){const xe=_e[ue];E.format!==an?Ie!==null?qe?t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue,0,0,xe.width,xe.height,Ie,xe.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue,Me,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):qe?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue,0,0,xe.width,xe.height,Ie,be,xe.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue,Me,xe.width,xe.height,0,Ie,be,xe.data)}}}else{_e=E.mipmaps,qe&&at&&(_e.length>0&&F++,t.texStorage2D(r.TEXTURE_CUBE_MAP,F,Me,K[0].width,K[0].height));for(let Y=0;Y<6;Y++)if(he){qe?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,K[Y].width,K[Y].height,Ie,be,K[Y].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,Me,K[Y].width,K[Y].height,0,Ie,be,K[Y].data);for(let ue=0;ue<_e.length;ue++){const nt=_e[ue].image[Y].image;qe?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue+1,0,0,nt.width,nt.height,Ie,be,nt.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue+1,Me,nt.width,nt.height,0,Ie,be,nt.data)}}else{qe?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,Ie,be,K[Y]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,Me,Ie,be,K[Y]);for(let ue=0;ue<_e.length;ue++){const xe=_e[ue];qe?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue+1,0,0,Ie,be,xe.image[Y]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Y,ue+1,Me,Ie,be,xe.image[Y])}}}w(E,Ce)&&A(r.TEXTURE_CUBE_MAP),me.__version=ie.version,E.onUpdate&&E.onUpdate(E)}T.__version=E.version}function Le(T,E,W,se,ie){const me=s.convert(W.format,W.colorSpace),we=s.convert(W.type),he=C(W.internalFormat,me,we,W.colorSpace);n.get(E).__hasExternalTextures||(ie===r.TEXTURE_3D||ie===r.TEXTURE_2D_ARRAY?t.texImage3D(ie,0,he,E.width,E.height,E.depth,0,me,we,null):t.texImage2D(ie,0,he,E.width,E.height,0,me,we,null)),t.bindFramebuffer(r.FRAMEBUFFER,T),ne(E)?f.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,se,ie,n.get(W).__webglTexture,0,J(E)):(ie===r.TEXTURE_2D||ie>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,se,ie,n.get(W).__webglTexture,0),t.bindFramebuffer(r.FRAMEBUFFER,null)}function D(T,E,W){if(r.bindRenderbuffer(r.RENDERBUFFER,T),E.depthBuffer&&!E.stencilBuffer){let se=r.DEPTH_COMPONENT16;if(W||ne(E)){const ie=E.depthTexture;ie&&ie.isDepthTexture&&(ie.type===On?se=r.DEPTH_COMPONENT32F:ie.type===Yn&&(se=r.DEPTH_COMPONENT24));const me=J(E);ne(E)?f.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,me,se,E.width,E.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,me,se,E.width,E.height)}else r.renderbufferStorage(r.RENDERBUFFER,se,E.width,E.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,T)}else if(E.depthBuffer&&E.stencilBuffer){const se=J(E);W&&ne(E)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,se,r.DEPTH24_STENCIL8,E.width,E.height):ne(E)?f.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,se,r.DEPTH24_STENCIL8,E.width,E.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,E.width,E.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,T)}else{const se=E.isWebGLMultipleRenderTargets===!0?E.texture:[E.texture];for(let ie=0;ie<se.length;ie++){const me=se[ie],we=s.convert(me.format,me.colorSpace),he=s.convert(me.type),K=C(me.internalFormat,we,he,me.colorSpace),Re=J(E);W&&ne(E)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,Re,K,E.width,E.height):ne(E)?f.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Re,K,E.width,E.height):r.renderbufferStorage(r.RENDERBUFFER,K,E.width,E.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function ae(T,E){if(E&&E.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(r.FRAMEBUFFER,T),!(E.depthTexture&&E.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(E.depthTexture).__webglTexture||E.depthTexture.image.width!==E.width||E.depthTexture.image.height!==E.height)&&(E.depthTexture.image.width=E.width,E.depthTexture.image.height=E.height,E.depthTexture.needsUpdate=!0),ee(E.depthTexture,0);const se=n.get(E.depthTexture).__webglTexture,ie=J(E);if(E.depthTexture.format===xi)ne(E)?f.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,se,0,ie):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,se,0);else if(E.depthTexture.format===Ni)ne(E)?f.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,se,0,ie):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,se,0);else throw new Error("Unknown depthTexture format")}function Q(T){const E=n.get(T),W=T.isWebGLCubeRenderTarget===!0;if(T.depthTexture&&!E.__autoAllocateDepthBuffer){if(W)throw new Error("target.depthTexture not supported in Cube render targets");ae(E.__webglFramebuffer,T)}else if(W){E.__webglDepthbuffer=[];for(let se=0;se<6;se++)t.bindFramebuffer(r.FRAMEBUFFER,E.__webglFramebuffer[se]),E.__webglDepthbuffer[se]=r.createRenderbuffer(),D(E.__webglDepthbuffer[se],T,!1)}else t.bindFramebuffer(r.FRAMEBUFFER,E.__webglFramebuffer),E.__webglDepthbuffer=r.createRenderbuffer(),D(E.__webglDepthbuffer,T,!1);t.bindFramebuffer(r.FRAMEBUFFER,null)}function oe(T,E,W){const se=n.get(T);E!==void 0&&Le(se.__webglFramebuffer,T,T.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D),W!==void 0&&Q(T)}function re(T){const E=T.texture,W=n.get(T),se=n.get(E);T.addEventListener("dispose",k),T.isWebGLMultipleRenderTargets!==!0&&(se.__webglTexture===void 0&&(se.__webglTexture=r.createTexture()),se.__version=E.version,a.memory.textures++);const ie=T.isWebGLCubeRenderTarget===!0,me=T.isWebGLMultipleRenderTargets===!0,we=v(T)||o;if(ie){W.__webglFramebuffer=[];for(let he=0;he<6;he++)W.__webglFramebuffer[he]=r.createFramebuffer()}else{if(W.__webglFramebuffer=r.createFramebuffer(),me)if(i.drawBuffers){const he=T.texture;for(let K=0,Re=he.length;K<Re;K++){const Ce=n.get(he[K]);Ce.__webglTexture===void 0&&(Ce.__webglTexture=r.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&T.samples>0&&ne(T)===!1){const he=me?E:[E];W.__webglMultisampledFramebuffer=r.createFramebuffer(),W.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,W.__webglMultisampledFramebuffer);for(let K=0;K<he.length;K++){const Re=he[K];W.__webglColorRenderbuffer[K]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,W.__webglColorRenderbuffer[K]);const Ce=s.convert(Re.format,Re.colorSpace),Ie=s.convert(Re.type),be=C(Re.internalFormat,Ce,Ie,Re.colorSpace,T.isXRRenderTarget===!0),Me=J(T);r.renderbufferStorageMultisample(r.RENDERBUFFER,Me,be,T.width,T.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+K,r.RENDERBUFFER,W.__webglColorRenderbuffer[K])}r.bindRenderbuffer(r.RENDERBUFFER,null),T.depthBuffer&&(W.__webglDepthRenderbuffer=r.createRenderbuffer(),D(W.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(ie){t.bindTexture(r.TEXTURE_CUBE_MAP,se.__webglTexture),Pe(r.TEXTURE_CUBE_MAP,E,we);for(let he=0;he<6;he++)Le(W.__webglFramebuffer[he],T,E,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+he);w(E,we)&&A(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(me){const he=T.texture;for(let K=0,Re=he.length;K<Re;K++){const Ce=he[K],Ie=n.get(Ce);t.bindTexture(r.TEXTURE_2D,Ie.__webglTexture),Pe(r.TEXTURE_2D,Ce,we),Le(W.__webglFramebuffer,T,Ce,r.COLOR_ATTACHMENT0+K,r.TEXTURE_2D),w(Ce,we)&&A(r.TEXTURE_2D)}t.unbindTexture()}else{let he=r.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(o?he=T.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(he,se.__webglTexture),Pe(he,E,we),Le(W.__webglFramebuffer,T,E,r.COLOR_ATTACHMENT0,he),w(E,we)&&A(he),t.unbindTexture()}T.depthBuffer&&Q(T)}function Ee(T){const E=v(T)||o,W=T.isWebGLMultipleRenderTargets===!0?T.texture:[T.texture];for(let se=0,ie=W.length;se<ie;se++){const me=W[se];if(w(me,E)){const we=T.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D,he=n.get(me).__webglTexture;t.bindTexture(we,he),A(we),t.unbindTexture()}}}function $(T){if(o&&T.samples>0&&ne(T)===!1){const E=T.isWebGLMultipleRenderTargets?T.texture:[T.texture],W=T.width,se=T.height;let ie=r.COLOR_BUFFER_BIT;const me=[],we=T.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,he=n.get(T),K=T.isWebGLMultipleRenderTargets===!0;if(K)for(let Re=0;Re<E.length;Re++)t.bindFramebuffer(r.FRAMEBUFFER,he.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Re,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,he.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Re,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,he.__webglMultisampledFramebuffer),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,he.__webglFramebuffer);for(let Re=0;Re<E.length;Re++){me.push(r.COLOR_ATTACHMENT0+Re),T.depthBuffer&&me.push(we);const Ce=he.__ignoreDepthValues!==void 0?he.__ignoreDepthValues:!1;if(Ce===!1&&(T.depthBuffer&&(ie|=r.DEPTH_BUFFER_BIT),T.stencilBuffer&&(ie|=r.STENCIL_BUFFER_BIT)),K&&r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,he.__webglColorRenderbuffer[Re]),Ce===!0&&(r.invalidateFramebuffer(r.READ_FRAMEBUFFER,[we]),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[we])),K){const Ie=n.get(E[Re]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,Ie,0)}r.blitFramebuffer(0,0,W,se,0,0,W,se,ie,r.NEAREST),d&&r.invalidateFramebuffer(r.READ_FRAMEBUFFER,me)}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),K)for(let Re=0;Re<E.length;Re++){t.bindFramebuffer(r.FRAMEBUFFER,he.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Re,r.RENDERBUFFER,he.__webglColorRenderbuffer[Re]);const Ce=n.get(E[Re]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,he.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Re,r.TEXTURE_2D,Ce,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,he.__webglMultisampledFramebuffer)}}function J(T){return Math.min(u,T.samples)}function ne(T){const E=n.get(T);return o&&T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&E.__useRenderToTexture!==!1}function de(T){const E=a.render.frame;p.get(T)!==E&&(p.set(T,E),T.update())}function pe(T,E){const W=T.colorSpace,se=T.format,ie=T.type;return T.isCompressedTexture===!0||T.format===Ua||W!==Sn&&W!==Mi&&(W===Ge?o===!1?e.has("EXT_sRGB")===!0&&se===an?(T.format=Ua,T.minFilter=vt,T.generateMipmaps=!1):E=Oc.sRGBToLinear(E):(se!==an||ie!==$n)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",W)),E}this.allocateTextureUnit=H,this.resetTextureUnits=O,this.setTexture2D=ee,this.setTexture2DArray=z,this.setTexture3D=Z,this.setTextureCube=le,this.rebindTextures=oe,this.setupRenderTarget=re,this.updateRenderTargetMipmap=Ee,this.updateMultisampleRenderTarget=$,this.setupDepthRenderbuffer=Q,this.setupFrameBufferTexture=Le,this.useMultisampledRTT=ne}function Vd(r,e,t){const n=t.isWebGL2;function i(s,a=Mi){let o;if(s===$n)return r.UNSIGNED_BYTE;if(s===tc)return r.UNSIGNED_SHORT_4_4_4_4;if(s===nc)return r.UNSIGNED_SHORT_5_5_5_1;if(s===wf)return r.BYTE;if(s===Ef)return r.SHORT;if(s===wa)return r.UNSIGNED_SHORT;if(s===ec)return r.INT;if(s===Yn)return r.UNSIGNED_INT;if(s===On)return r.FLOAT;if(s===gr)return n?r.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===Af)return r.ALPHA;if(s===an)return r.RGBA;if(s===Tf)return r.LUMINANCE;if(s===Rf)return r.LUMINANCE_ALPHA;if(s===xi)return r.DEPTH_COMPONENT;if(s===Ni)return r.DEPTH_STENCIL;if(s===Ua)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===Cf)return r.RED;if(s===ic)return r.RED_INTEGER;if(s===Pf)return r.RG;if(s===rc)return r.RG_INTEGER;if(s===sc)return r.RGBA_INTEGER;if(s===Ea||s===Aa||s===Ta||s===Ra)if(a===Ge)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===Ea)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Aa)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Ta)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Ra)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===Ea)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Aa)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Ta)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Ra)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===ac||s===oc||s===lc||s===cc)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===ac)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===oc)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===lc)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===cc)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Lf)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===hc||s===uc)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===hc)return a===Ge?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===uc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===fc||s===dc||s===pc||s===mc||s===gc||s===_c||s===xc||s===yc||s===vc||s===Mc||s===Sc||s===bc||s===wc||s===Ec)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===fc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===dc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===pc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===mc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===gc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===_c)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===xc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===yc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===vc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===Mc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Sc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===bc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===wc)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Ec)return a===Ge?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Ca)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===Ca)return a===Ge?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===If||s===Ac||s===Tc||s===Rc)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(s===Ca)return o.COMPRESSED_RED_RGTC1_EXT;if(s===Ac)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Tc)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Rc)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===_i?n?r.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}class Wd extends Ut{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class kr extends tt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const XM={type:"move"};class hh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new kr,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 kr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new R,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new R),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new kr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new R,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new R),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 n of e.hand.values())this._getHandJoint(t,n)}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,n){let i=null,s=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 _ of e.hand.values()){const g=t.getJointPose(_,n),m=this._getHandJoint(c,_);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],f=h.position.distanceTo(u.position),d=.02,p=.005;c.inputState.pinching&&f>d+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=d-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(XM)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new kr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Xd extends Mt{constructor(e,t,n,i,s,a,o,l,c,h){if(h=h!==void 0?h:xi,h!==xi&&h!==Ni)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===xi&&(n=Yn),n===void 0&&h===Ni&&(n=_i),super(null,i,s,a,o,l,h,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=o!==void 0?o:yt,this.minFilter=l!==void 0?l:yt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class qM extends Zn{constructor(e,t){super();const n=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,f=null,d=null,p=null;const _=t.getContextAttributes();let g=null,m=null;const y=[],x=[],v=new Ut;v.layers.enable(1),v.viewport=new rt;const M=new Ut;M.layers.enable(2),M.viewport=new rt;const w=[v,M],A=new Wd;A.layers.enable(1),A.layers.enable(2);let C=null,S=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let Z=y[z];return Z===void 0&&(Z=new hh,y[z]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(z){let Z=y[z];return Z===void 0&&(Z=new hh,y[z]=Z),Z.getGripSpace()},this.getHand=function(z){let Z=y[z];return Z===void 0&&(Z=new hh,y[z]=Z),Z.getHandSpace()};function b(z){const Z=x.indexOf(z.inputSource);if(Z===-1)return;const le=y[Z];le!==void 0&&(le.update(z.inputSource,z.frame,c||a),le.dispatchEvent({type:z.type,data:z.inputSource}))}function L(){i.removeEventListener("select",b),i.removeEventListener("selectstart",b),i.removeEventListener("selectend",b),i.removeEventListener("squeeze",b),i.removeEventListener("squeezestart",b),i.removeEventListener("squeezeend",b),i.removeEventListener("end",L),i.removeEventListener("inputsourceschange",k);for(let z=0;z<y.length;z++){const Z=x[z];Z!==null&&(x[z]=null,y[z].disconnect(Z))}C=null,S=null,e.setRenderTarget(g),d=null,f=null,u=null,i=null,m=null,ee.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(z){s=z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(z){o=z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(z){c=z},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=function(z){return fs(this,null,function*(){if(i=z,i!==null){if(g=e.getRenderTarget(),i.addEventListener("select",b),i.addEventListener("selectstart",b),i.addEventListener("selectend",b),i.addEventListener("squeeze",b),i.addEventListener("squeezestart",b),i.addEventListener("squeezeend",b),i.addEventListener("end",L),i.addEventListener("inputsourceschange",k),_.xrCompatible!==!0&&(yield t.makeXRCompatible()),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const Z={antialias:i.renderState.layers===void 0?_.antialias:!0,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,t,Z),i.updateRenderState({baseLayer:d}),m=new bn(d.framebufferWidth,d.framebufferHeight,{format:an,type:$n,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil})}else{let Z=null,le=null,ce=null;_.depth&&(ce=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Z=_.stencil?Ni:xi,le=_.stencil?_i:Yn);const fe={colorFormat:t.RGBA8,depthFormat:ce,scaleFactor:s};u=new XRWebGLBinding(i,t),f=u.createProjectionLayer(fe),i.updateRenderState({layers:[f]}),m=new bn(f.textureWidth,f.textureHeight,{format:an,type:$n,depthTexture:new Xd(f.textureWidth,f.textureHeight,le,void 0,void 0,void 0,void 0,void 0,void 0,Z),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0});const Ae=e.properties.get(m);Ae.__ignoreDepthValues=f.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=yield i.requestReferenceSpace(o),ee.setContext(i),ee.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function k(z){for(let Z=0;Z<z.removed.length;Z++){const le=z.removed[Z],ce=x.indexOf(le);ce>=0&&(x[ce]=null,y[ce].disconnect(le))}for(let Z=0;Z<z.added.length;Z++){const le=z.added[Z];let ce=x.indexOf(le);if(ce===-1){for(let Ae=0;Ae<y.length;Ae++)if(Ae>=x.length){x.push(le),ce=Ae;break}else if(x[Ae]===null){x[Ae]=le,ce=Ae;break}if(ce===-1)break}const fe=y[ce];fe&&fe.connect(le)}}const U=new R,N=new R;function I(z,Z,le){U.setFromMatrixPosition(Z.matrixWorld),N.setFromMatrixPosition(le.matrixWorld);const ce=U.distanceTo(N),fe=Z.projectionMatrix.elements,Ae=le.projectionMatrix.elements,Pe=fe[14]/(fe[10]-1),Te=fe[14]/(fe[10]+1),Ke=(fe[9]+1)/fe[5],je=(fe[9]-1)/fe[5],Le=(fe[8]-1)/fe[0],D=(Ae[8]+1)/Ae[0],ae=Pe*Le,Q=Pe*D,oe=ce/(-Le+D),re=oe*-Le;Z.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(re),z.translateZ(oe),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert();const Ee=Pe+oe,$=Te+oe,J=ae-re,ne=Q+(ce-re),de=Ke*Te/$*Ee,pe=je*Te/$*Ee;z.projectionMatrix.makePerspective(J,ne,de,pe,Ee,$),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}function B(z,Z){Z===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(Z.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(i===null)return;A.near=M.near=v.near=z.near,A.far=M.far=v.far=z.far,(C!==A.near||S!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,S=A.far);const Z=z.parent,le=A.cameras;B(A,Z);for(let ce=0;ce<le.length;ce++)B(le[ce],Z);le.length===2?I(A,v,M):A.projectionMatrix.copy(v.projectionMatrix),O(z,A,Z)};function O(z,Z,le){le===null?z.matrix.copy(Z.matrixWorld):(z.matrix.copy(le.matrixWorld),z.matrix.invert(),z.matrix.multiply(Z.matrixWorld)),z.matrix.decompose(z.position,z.quaternion,z.scale),z.updateMatrixWorld(!0);const ce=z.children;for(let fe=0,Ae=ce.length;fe<Ae;fe++)ce[fe].updateMatrixWorld(!0);z.projectionMatrix.copy(Z.projectionMatrix),z.projectionMatrixInverse.copy(Z.projectionMatrixInverse),z.isPerspectiveCamera&&(z.fov=_r*2*Math.atan(1/z.projectionMatrix.elements[5]),z.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(f===null&&d===null))return l},this.setFoveation=function(z){l=z,f!==null&&(f.fixedFoveation=z),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=z)};let H=null;function X(z,Z){if(h=Z.getViewerPose(c||a),p=Z,h!==null){const le=h.views;d!==null&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let ce=!1;le.length!==A.cameras.length&&(A.cameras.length=0,ce=!0);for(let fe=0;fe<le.length;fe++){const Ae=le[fe];let Pe=null;if(d!==null)Pe=d.getViewport(Ae);else{const Ke=u.getViewSubImage(f,Ae);Pe=Ke.viewport,fe===0&&(e.setRenderTargetTextures(m,Ke.colorTexture,f.ignoreDepthValues?void 0:Ke.depthStencilTexture),e.setRenderTarget(m))}let Te=w[fe];Te===void 0&&(Te=new Ut,Te.layers.enable(fe),Te.viewport=new rt,w[fe]=Te),Te.matrix.fromArray(Ae.transform.matrix),Te.matrix.decompose(Te.position,Te.quaternion,Te.scale),Te.projectionMatrix.fromArray(Ae.projectionMatrix),Te.projectionMatrixInverse.copy(Te.projectionMatrix).invert(),Te.viewport.set(Pe.x,Pe.y,Pe.width,Pe.height),fe===0&&(A.matrix.copy(Te.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),ce===!0&&A.cameras.push(Te)}}for(let le=0;le<y.length;le++){const ce=x[le],fe=y[le];ce!==null&&fe!==void 0&&fe.update(ce,Z,c||a)}H&&H(z,Z),Z.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Z}),p=null}const ee=new _d;ee.setAnimationLoop(X),this.setAnimationLoop=function(z){H=z},this.dispose=function(){}}}function $M(r,e){function t(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function n(g,m){m.color.getRGB(g.fogColor.value,dd(r)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function i(g,m,y,x,v){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),u(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),f(g,m),m.isMeshPhysicalMaterial&&d(g,m,v)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),_(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(a(g,m),m.isLineDashedMaterial&&o(g,m)):m.isPointsMaterial?l(g,m,y,x):m.isSpriteMaterial?c(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,t(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===kt&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===kt&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,t(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,t(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);const y=e.get(m).envMap;if(y&&(g.envMap.value=y,g.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;const x=r.useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*x,t(m.lightMap,g.lightMapTransform)}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,g.aoMapTransform))}function a(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform))}function o(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function l(g,m,y,x){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*y,g.scale.value=x*.5,m.map&&(g.map.value=m.map,t(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function c(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function f(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,g.roughnessMapTransform)),e.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function d(g,m,y){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===kt&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function _(g,m){const y=e.get(m).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function YM(r,e,t,n){let i={},s={},a=[];const o=t.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(y,x){const v=x.program;n.uniformBlockBinding(y,v)}function c(y,x){let v=i[y.id];v===void 0&&(p(y),v=h(y),i[y.id]=v,y.addEventListener("dispose",g));const M=x.program;n.updateUBOMapping(y,M);const w=e.render.frame;s[y.id]!==w&&(f(y),s[y.id]=w)}function h(y){const x=u();y.__bindingPointIndex=x;const v=r.createBuffer(),M=y.__size,w=y.usage;return r.bindBuffer(r.UNIFORM_BUFFER,v),r.bufferData(r.UNIFORM_BUFFER,M,w),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,x,v),v}function u(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(y){const x=i[y.id],v=y.uniforms,M=y.__cache;r.bindBuffer(r.UNIFORM_BUFFER,x);for(let w=0,A=v.length;w<A;w++){const C=v[w];if(d(C,w,M)===!0){const S=C.__offset,b=Array.isArray(C.value)?C.value:[C.value];let L=0;for(let k=0;k<b.length;k++){const U=b[k],N=_(U);typeof U=="number"?(C.__data[0]=U,r.bufferSubData(r.UNIFORM_BUFFER,S+L,C.__data)):U.isMatrix3?(C.__data[0]=U.elements[0],C.__data[1]=U.elements[1],C.__data[2]=U.elements[2],C.__data[3]=U.elements[0],C.__data[4]=U.elements[3],C.__data[5]=U.elements[4],C.__data[6]=U.elements[5],C.__data[7]=U.elements[0],C.__data[8]=U.elements[6],C.__data[9]=U.elements[7],C.__data[10]=U.elements[8],C.__data[11]=U.elements[0]):(U.toArray(C.__data,L),L+=N.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,S,C.__data)}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function d(y,x,v){const M=y.value;if(v[x]===void 0){if(typeof M=="number")v[x]=M;else{const w=Array.isArray(M)?M:[M],A=[];for(let C=0;C<w.length;C++)A.push(w[C].clone());v[x]=A}return!0}else if(typeof M=="number"){if(v[x]!==M)return v[x]=M,!0}else{const w=Array.isArray(v[x])?v[x]:[v[x]],A=Array.isArray(M)?M:[M];for(let C=0;C<w.length;C++){const S=w[C];if(S.equals(A[C])===!1)return S.copy(A[C]),!0}}return!1}function p(y){const x=y.uniforms;let v=0;const M=16;let w=0;for(let A=0,C=x.length;A<C;A++){const S=x[A],b={boundary:0,storage:0},L=Array.isArray(S.value)?S.value:[S.value];for(let k=0,U=L.length;k<U;k++){const N=L[k],I=_(N);b.boundary+=I.boundary,b.storage+=I.storage}if(S.__data=new Float32Array(b.storage/Float32Array.BYTES_PER_ELEMENT),S.__offset=v,A>0){w=v%M;const k=M-w;w!==0&&k-b.boundary<0&&(v+=M-w,S.__offset=v)}v+=b.storage}return w=v%M,w>0&&(v+=M-w),y.__size=v,y.__cache={},this}function _(y){const x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function g(y){const x=y.target;x.removeEventListener("dispose",g);const v=a.indexOf(x.__bindingPointIndex);a.splice(v,1),r.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function m(){for(const y in i)r.deleteBuffer(i[y]);a=[],i={},s={}}return{bind:l,update:c,dispose:m}}function ZM(){const r=As("canvas");return r.style.display="block",r}class qd{constructor(e={}){const{canvas:t=ZM(),context:n=null,depth:i=!0,stencil:s=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let f;n!==null?f=n.getContextAttributes().alpha:f=a;const d=new Uint32Array(4),p=new Int32Array(4);let _=null,g=null;const m=[],y=[];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.outputColorSpace=Ge,this.useLegacyLights=!0,this.toneMapping=Fn,this.toneMappingExposure=1;const x=this;let v=!1,M=0,w=0,A=null,C=-1,S=null;const b=new rt,L=new rt;let k=null;const U=new ye(0);let N=0,I=t.width,B=t.height,O=1,H=null,X=null;const ee=new rt(0,0,I,B),z=new rt(0,0,I,B);let Z=!1;const le=new no;let ce=!1,fe=!1,Ae=null;const Pe=new Be,Te=new q,Ke=new R,je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Le(){return A===null?O:1}let D=n;function ae(P,V){for(let j=0;j<P.length;j++){const G=P[j],te=t.getContext(G,V);if(te!==null)return te}return null}try{const P={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ot}`),t.addEventListener("webglcontextlost",_e,!1),t.addEventListener("webglcontextrestored",Y,!1),t.addEventListener("webglcontextcreationerror",ue,!1),D===null){const V=["webgl2","webgl","experimental-webgl"];if(x.isWebGL1Renderer===!0&&V.shift(),D=ae(V,P),D===null)throw ae(V)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext!="undefined"&&D instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),D.getShaderPrecisionFormat===void 0&&(D.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(P){throw console.error("THREE.WebGLRenderer: "+P.message),P}let Q,oe,re,Ee,$,J,ne,de,pe,T,E,W,se,ie,me,we,he,K,Re,Ce,Ie,be,Me,qe;function at(){Q=new hv(D),oe=new rv(D,Q,e),Q.init(oe),be=new Vd(D,Q,oe),re=new VM(D,Q,oe),Ee=new dv(D),$=new LM,J=new WM(D,Q,re,$,oe,be,Ee),ne=new av(x),de=new cv(x),pe=new ix(D,oe),Me=new nv(D,Q,pe,oe),T=new uv(D,pe,Ee,Me),E=new _v(D,T,pe,Ee),Re=new gv(D,oe,J),we=new sv($),W=new PM(x,ne,de,Q,oe,Me,we),se=new $M(x,$),ie=new UM,me=new zM(Q,oe),K=new tv(x,ne,de,re,E,f,l),he=new HM(x,E,oe),qe=new YM(D,Ee,oe,re),Ce=new iv(D,Q,Ee,oe),Ie=new fv(D,Q,Ee,oe),Ee.programs=W.programs,x.capabilities=oe,x.extensions=Q,x.properties=$,x.renderLists=ie,x.shadowMap=he,x.state=re,x.info=Ee}at();const F=new qM(x,D);this.xr=F,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const P=Q.get("WEBGL_lose_context");P&&P.loseContext()},this.forceContextRestore=function(){const P=Q.get("WEBGL_lose_context");P&&P.restoreContext()},this.getPixelRatio=function(){return O},this.setPixelRatio=function(P){P!==void 0&&(O=P,this.setSize(I,B,!1))},this.getSize=function(P){return P.set(I,B)},this.setSize=function(P,V,j=!0){if(F.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}I=P,B=V,t.width=Math.floor(P*O),t.height=Math.floor(V*O),j===!0&&(t.style.width=P+"px",t.style.height=V+"px"),this.setViewport(0,0,P,V)},this.getDrawingBufferSize=function(P){return P.set(I*O,B*O).floor()},this.setDrawingBufferSize=function(P,V,j){I=P,B=V,O=j,t.width=Math.floor(P*j),t.height=Math.floor(V*j),this.setViewport(0,0,P,V)},this.getCurrentViewport=function(P){return P.copy(b)},this.getViewport=function(P){return P.copy(ee)},this.setViewport=function(P,V,j,G){P.isVector4?ee.set(P.x,P.y,P.z,P.w):ee.set(P,V,j,G),re.viewport(b.copy(ee).multiplyScalar(O).floor())},this.getScissor=function(P){return P.copy(z)},this.setScissor=function(P,V,j,G){P.isVector4?z.set(P.x,P.y,P.z,P.w):z.set(P,V,j,G),re.scissor(L.copy(z).multiplyScalar(O).floor())},this.getScissorTest=function(){return Z},this.setScissorTest=function(P){re.setScissorTest(Z=P)},this.setOpaqueSort=function(P){H=P},this.setTransparentSort=function(P){X=P},this.getClearColor=function(P){return P.copy(K.getClearColor())},this.setClearColor=function(){K.setClearColor.apply(K,arguments)},this.getClearAlpha=function(){return K.getClearAlpha()},this.setClearAlpha=function(){K.setClearAlpha.apply(K,arguments)},this.clear=function(P=!0,V=!0,j=!0){let G=0;if(P){let te=!1;if(A!==null){const Se=A.texture.format;te=Se===sc||Se===rc||Se===ic}if(te){const Se=A.texture.type,Ue=Se===$n||Se===Yn||Se===wa||Se===_i||Se===tc||Se===nc,Oe=K.getClearColor(),ke=K.getClearAlpha(),Ye=Oe.r,He=Oe.g,$e=Oe.b;Ue?(d[0]=Ye,d[1]=He,d[2]=$e,d[3]=ke,D.clearBufferuiv(D.COLOR,0,d)):(p[0]=Ye,p[1]=He,p[2]=$e,p[3]=ke,D.clearBufferiv(D.COLOR,0,p))}else G|=D.COLOR_BUFFER_BIT}V&&(G|=D.DEPTH_BUFFER_BIT),j&&(G|=D.STENCIL_BUFFER_BIT),D.clear(G)},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",_e,!1),t.removeEventListener("webglcontextrestored",Y,!1),t.removeEventListener("webglcontextcreationerror",ue,!1),ie.dispose(),me.dispose(),$.dispose(),ne.dispose(),de.dispose(),E.dispose(),Me.dispose(),qe.dispose(),W.dispose(),F.dispose(),F.removeEventListener("sessionstart",gt),F.removeEventListener("sessionend",Wn),Ae&&(Ae.dispose(),Ae=null),Yt.stop()};function _e(P){P.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function Y(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1;const P=Ee.autoReset,V=he.enabled,j=he.autoUpdate,G=he.needsUpdate,te=he.type;at(),Ee.autoReset=P,he.enabled=V,he.autoUpdate=j,he.needsUpdate=G,he.type=te}function ue(P){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",P.statusMessage)}function xe(P){const V=P.target;V.removeEventListener("dispose",xe),nt(V)}function nt(P){ut(P),$.remove(P)}function ut(P){const V=$.get(P).programs;V!==void 0&&(V.forEach(function(j){W.releaseProgram(j)}),P.isShaderMaterial&&W.releaseShaderCache(P))}this.renderBufferDirect=function(P,V,j,G,te,Se){V===null&&(V=je);const Ue=te.isMesh&&te.matrixWorld.determinant()<0,Oe=dA(P,V,j,G,te);re.setMaterial(G,Ue);let ke=j.index,Ye=1;G.wireframe===!0&&(ke=T.getWireframeAttribute(j),Ye=2);const He=j.drawRange,$e=j.attributes.position;let _t=He.start*Ye,bt=(He.start+He.count)*Ye;Se!==null&&(_t=Math.max(_t,Se.start*Ye),bt=Math.min(bt,(Se.start+Se.count)*Ye)),ke!==null?(_t=Math.max(_t,0),bt=Math.min(bt,ke.count)):$e!=null&&(_t=Math.max(_t,0),bt=Math.min(bt,$e.count));const Un=bt-_t;if(Un<0||Un===1/0)return;Me.setup(te,G,Oe,j,ke);let di,Et=Ce;if(ke!==null&&(di=pe.get(ke),Et=Ie,Et.setIndex(di)),te.isMesh)G.wireframe===!0?(re.setLineWidth(G.wireframeLinewidth*Le()),Et.setMode(D.LINES)):Et.setMode(D.TRIANGLES);else if(te.isLine){let Qe=G.linewidth;Qe===void 0&&(Qe=1),re.setLineWidth(Qe*Le()),te.isLineSegments?Et.setMode(D.LINES):te.isLineLoop?Et.setMode(D.LINE_LOOP):Et.setMode(D.LINE_STRIP)}else te.isPoints?Et.setMode(D.POINTS):te.isSprite&&Et.setMode(D.TRIANGLES);if(te.isInstancedMesh)Et.renderInstances(_t,Un,te.count);else if(j.isInstancedBufferGeometry){const Qe=j._maxInstanceCount!==void 0?j._maxInstanceCount:1/0,$u=Math.min(j.instanceCount,Qe);Et.renderInstances(_t,Un,$u)}else Et.render(_t,Un)},this.compile=function(P,V){function j(G,te,Se){G.transparent===!0&&G.side===Nn&&G.forceSinglePass===!1?(G.side=kt,G.needsUpdate=!0,Hl(G,te,Se),G.side=Xn,G.needsUpdate=!0,Hl(G,te,Se),G.side=Nn):Hl(G,te,Se)}g=me.get(P),g.init(),y.push(g),P.traverseVisible(function(G){G.isLight&&G.layers.test(V.layers)&&(g.pushLight(G),G.castShadow&&g.pushShadow(G))}),g.setupLights(x.useLegacyLights),P.traverse(function(G){const te=G.material;if(te)if(Array.isArray(te))for(let Se=0;Se<te.length;Se++){const Ue=te[Se];j(Ue,P,G)}else j(te,P,G)}),y.pop(),g=null};let Pt=null;function Vn(P){Pt&&Pt(P)}function gt(){Yt.stop()}function Wn(){Yt.start()}const Yt=new _d;Yt.setAnimationLoop(Vn),typeof self!="undefined"&&Yt.setContext(self),this.setAnimationLoop=function(P){Pt=P,F.setAnimationLoop(P),P===null?Yt.stop():Yt.start()},F.addEventListener("sessionstart",gt),F.addEventListener("sessionend",Wn),this.render=function(P,V){if(V!==void 0&&V.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;P.matrixWorldAutoUpdate===!0&&P.updateMatrixWorld(),V.parent===null&&V.matrixWorldAutoUpdate===!0&&V.updateMatrixWorld(),F.enabled===!0&&F.isPresenting===!0&&(F.cameraAutoUpdate===!0&&F.updateCamera(V),V=F.getCamera()),P.isScene===!0&&P.onBeforeRender(x,P,V,A),g=me.get(P,y.length),g.init(),y.push(g),Pe.multiplyMatrices(V.projectionMatrix,V.matrixWorldInverse),le.setFromProjectionMatrix(Pe),fe=this.localClippingEnabled,ce=we.init(this.clippingPlanes,fe),_=ie.get(P,m.length),_.init(),m.push(_),x0(P,V,0,x.sortObjects),_.finish(),x.sortObjects===!0&&_.sort(H,X),this.info.render.frame++,ce===!0&&we.beginShadows();const j=g.state.shadowsArray;if(he.render(j,P,V),ce===!0&&we.endShadows(),this.info.autoReset===!0&&this.info.reset(),K.render(_,P),g.setupLights(x.useLegacyLights),V.isArrayCamera){const G=V.cameras;for(let te=0,Se=G.length;te<Se;te++){const Ue=G[te];y0(_,P,Ue,Ue.viewport)}}else y0(_,P,V);A!==null&&(J.updateMultisampleRenderTarget(A),J.updateRenderTargetMipmap(A)),P.isScene===!0&&P.onAfterRender(x,P,V),Me.resetDefaultState(),C=-1,S=null,y.pop(),y.length>0?g=y[y.length-1]:g=null,m.pop(),m.length>0?_=m[m.length-1]:_=null};function x0(P,V,j,G){if(P.visible===!1)return;if(P.layers.test(V.layers)){if(P.isGroup)j=P.renderOrder;else if(P.isLOD)P.autoUpdate===!0&&P.update(V);else if(P.isLight)g.pushLight(P),P.castShadow&&g.pushShadow(P);else if(P.isSprite){if(!P.frustumCulled||le.intersectsSprite(P)){G&&Ke.setFromMatrixPosition(P.matrixWorld).applyMatrix4(Pe);const Ue=E.update(P),Oe=P.material;Oe.visible&&_.push(P,Ue,Oe,j,Ke.z,null)}}else if((P.isMesh||P.isLine||P.isPoints)&&(!P.frustumCulled||le.intersectsObject(P))){const Ue=E.update(P),Oe=P.material;if(G&&(P.boundingSphere!==void 0?(P.boundingSphere===null&&P.computeBoundingSphere(),Ke.copy(P.boundingSphere.center)):(Ue.boundingSphere===null&&Ue.computeBoundingSphere(),Ke.copy(Ue.boundingSphere.center)),Ke.applyMatrix4(P.matrixWorld).applyMatrix4(Pe)),Array.isArray(Oe)){const ke=Ue.groups;for(let Ye=0,He=ke.length;Ye<He;Ye++){const $e=ke[Ye],_t=Oe[$e.materialIndex];_t&&_t.visible&&_.push(P,Ue,_t,j,Ke.z,$e)}}else Oe.visible&&_.push(P,Ue,Oe,j,Ke.z,null)}}const Se=P.children;for(let Ue=0,Oe=Se.length;Ue<Oe;Ue++)x0(Se[Ue],V,j,G)}function y0(P,V,j,G){const te=P.opaque,Se=P.transmissive,Ue=P.transparent;g.setupLightsView(j),ce===!0&&we.setGlobalState(x.clippingPlanes,j),Se.length>0&&fA(te,Se,V,j),G&&re.viewport(b.copy(G)),te.length>0&&Gl(te,V,j),Se.length>0&&Gl(Se,V,j),Ue.length>0&&Gl(Ue,V,j),re.buffers.depth.setTest(!0),re.buffers.depth.setMask(!0),re.buffers.color.setMask(!0),re.setPolygonOffset(!1)}function fA(P,V,j,G){const te=oe.isWebGL2;Ae===null&&(Ae=new bn(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?gr:$n,minFilter:gi,samples:te?4:0})),x.getDrawingBufferSize(Te),te?Ae.setSize(Te.x,Te.y):Ae.setSize(Da(Te.x),Da(Te.y));const Se=x.getRenderTarget();x.setRenderTarget(Ae),x.getClearColor(U),N=x.getClearAlpha(),N<1&&x.setClearColor(16777215,.5),x.clear();const Ue=x.toneMapping;x.toneMapping=Fn,Gl(P,j,G),J.updateMultisampleRenderTarget(Ae),J.updateRenderTargetMipmap(Ae);let Oe=!1;for(let ke=0,Ye=V.length;ke<Ye;ke++){const He=V[ke],$e=He.object,_t=He.geometry,bt=He.material,Un=He.group;if(bt.side===Nn&&$e.layers.test(G.layers)){const di=bt.side;bt.side=kt,bt.needsUpdate=!0,v0($e,j,G,_t,bt,Un),bt.side=di,bt.needsUpdate=!0,Oe=!0}}Oe===!0&&(J.updateMultisampleRenderTarget(Ae),J.updateRenderTargetMipmap(Ae)),x.setRenderTarget(Se),x.setClearColor(U,N),x.toneMapping=Ue}function Gl(P,V,j){const G=V.isScene===!0?V.overrideMaterial:null;for(let te=0,Se=P.length;te<Se;te++){const Ue=P[te],Oe=Ue.object,ke=Ue.geometry,Ye=G===null?Ue.material:G,He=Ue.group;Oe.layers.test(j.layers)&&v0(Oe,V,j,ke,Ye,He)}}function v0(P,V,j,G,te,Se){P.onBeforeRender(x,V,j,G,te,Se),P.modelViewMatrix.multiplyMatrices(j.matrixWorldInverse,P.matrixWorld),P.normalMatrix.getNormalMatrix(P.modelViewMatrix),te.onBeforeRender(x,V,j,G,P,Se),te.transparent===!0&&te.side===Nn&&te.forceSinglePass===!1?(te.side=kt,te.needsUpdate=!0,x.renderBufferDirect(j,V,G,te,P,Se),te.side=Xn,te.needsUpdate=!0,x.renderBufferDirect(j,V,G,te,P,Se),te.side=Nn):x.renderBufferDirect(j,V,G,te,P,Se),P.onAfterRender(x,V,j,G,te,Se)}function Hl(P,V,j){V.isScene!==!0&&(V=je);const G=$.get(P),te=g.state.lights,Se=g.state.shadowsArray,Ue=te.state.version,Oe=W.getParameters(P,te.state,Se,V,j),ke=W.getProgramCacheKey(Oe);let Ye=G.programs;G.environment=P.isMeshStandardMaterial?V.environment:null,G.fog=V.fog,G.envMap=(P.isMeshStandardMaterial?de:ne).get(P.envMap||G.environment),Ye===void 0&&(P.addEventListener("dispose",xe),Ye=new Map,G.programs=Ye);let He=Ye.get(ke);if(He!==void 0){if(G.currentProgram===He&&G.lightsStateVersion===Ue)return M0(P,Oe),He}else Oe.uniforms=W.getUniforms(P),P.onBuild(j,Oe,x),P.onBeforeCompile(Oe,x),He=W.acquireProgram(Oe,ke),Ye.set(ke,He),G.uniforms=Oe.uniforms;const $e=G.uniforms;(!P.isShaderMaterial&&!P.isRawShaderMaterial||P.clipping===!0)&&($e.clippingPlanes=we.uniform),M0(P,Oe),G.needsLights=mA(P),G.lightsStateVersion=Ue,G.needsLights&&($e.ambientLightColor.value=te.state.ambient,$e.lightProbe.value=te.state.probe,$e.directionalLights.value=te.state.directional,$e.directionalLightShadows.value=te.state.directionalShadow,$e.spotLights.value=te.state.spot,$e.spotLightShadows.value=te.state.spotShadow,$e.rectAreaLights.value=te.state.rectArea,$e.ltc_1.value=te.state.rectAreaLTC1,$e.ltc_2.value=te.state.rectAreaLTC2,$e.pointLights.value=te.state.point,$e.pointLightShadows.value=te.state.pointShadow,$e.hemisphereLights.value=te.state.hemi,$e.directionalShadowMap.value=te.state.directionalShadowMap,$e.directionalShadowMatrix.value=te.state.directionalShadowMatrix,$e.spotShadowMap.value=te.state.spotShadowMap,$e.spotLightMatrix.value=te.state.spotLightMatrix,$e.spotLightMap.value=te.state.spotLightMap,$e.pointShadowMap.value=te.state.pointShadowMap,$e.pointShadowMatrix.value=te.state.pointShadowMatrix);const _t=He.getUniforms(),bt=oo.seqWithValue(_t.seq,$e);return G.currentProgram=He,G.uniformsList=bt,He}function M0(P,V){const j=$.get(P);j.outputColorSpace=V.outputColorSpace,j.instancing=V.instancing,j.skinning=V.skinning,j.morphTargets=V.morphTargets,j.morphNormals=V.morphNormals,j.morphColors=V.morphColors,j.morphTargetsCount=V.morphTargetsCount,j.numClippingPlanes=V.numClippingPlanes,j.numIntersection=V.numClipIntersection,j.vertexAlphas=V.vertexAlphas,j.vertexTangents=V.vertexTangents,j.toneMapping=V.toneMapping}function dA(P,V,j,G,te){V.isScene!==!0&&(V=je),J.resetTextureUnits();const Se=V.fog,Ue=G.isMeshStandardMaterial?V.environment:null,Oe=A===null?x.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:Sn,ke=(G.isMeshStandardMaterial?de:ne).get(G.envMap||Ue),Ye=G.vertexColors===!0&&!!j.attributes.color&&j.attributes.color.itemSize===4,He=!!j.attributes.tangent&&(!!G.normalMap||G.anisotropy>0),$e=!!j.morphAttributes.position,_t=!!j.morphAttributes.normal,bt=!!j.morphAttributes.color,Un=G.toneMapped?x.toneMapping:Fn,di=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,Et=di!==void 0?di.length:0,Qe=$.get(G),$u=g.state.lights;if(ce===!0&&(fe===!0||P!==S)){const mn=P===S&&G.id===C;we.setState(G,P,mn)}let Lt=!1;G.version===Qe.__version?(Qe.needsLights&&Qe.lightsStateVersion!==$u.state.version||Qe.outputColorSpace!==Oe||te.isInstancedMesh&&Qe.instancing===!1||!te.isInstancedMesh&&Qe.instancing===!0||te.isSkinnedMesh&&Qe.skinning===!1||!te.isSkinnedMesh&&Qe.skinning===!0||Qe.envMap!==ke||G.fog===!0&&Qe.fog!==Se||Qe.numClippingPlanes!==void 0&&(Qe.numClippingPlanes!==we.numPlanes||Qe.numIntersection!==we.numIntersection)||Qe.vertexAlphas!==Ye||Qe.vertexTangents!==He||Qe.morphTargets!==$e||Qe.morphNormals!==_t||Qe.morphColors!==bt||Qe.toneMapping!==Un||oe.isWebGL2===!0&&Qe.morphTargetsCount!==Et)&&(Lt=!0):(Lt=!0,Qe.__version=G.version);let ur=Qe.currentProgram;Lt===!0&&(ur=Hl(G,V,te));let S0=!1,ya=!1,Yu=!1;const Zt=ur.getUniforms(),fr=Qe.uniforms;if(re.useProgram(ur.program)&&(S0=!0,ya=!0,Yu=!0),G.id!==C&&(C=G.id,ya=!0),S0||S!==P){if(Zt.setValue(D,"projectionMatrix",P.projectionMatrix),oe.logarithmicDepthBuffer&&Zt.setValue(D,"logDepthBufFC",2/(Math.log(P.far+1)/Math.LN2)),S!==P&&(S=P,ya=!0,Yu=!0),G.isShaderMaterial||G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshStandardMaterial||G.envMap){const mn=Zt.map.cameraPosition;mn!==void 0&&mn.setValue(D,Ke.setFromMatrixPosition(P.matrixWorld))}(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&Zt.setValue(D,"isOrthographic",P.isOrthographicCamera===!0),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial||G.isShadowMaterial||te.isSkinnedMesh)&&Zt.setValue(D,"viewMatrix",P.matrixWorldInverse)}if(te.isSkinnedMesh){Zt.setOptional(D,te,"bindMatrix"),Zt.setOptional(D,te,"bindMatrixInverse");const mn=te.skeleton;mn&&(oe.floatVertexTextures?(mn.boneTexture===null&&mn.computeBoneTexture(),Zt.setValue(D,"boneTexture",mn.boneTexture,J),Zt.setValue(D,"boneTextureSize",mn.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const Zu=j.morphAttributes;if((Zu.position!==void 0||Zu.normal!==void 0||Zu.color!==void 0&&oe.isWebGL2===!0)&&Re.update(te,j,ur),(ya||Qe.receiveShadow!==te.receiveShadow)&&(Qe.receiveShadow=te.receiveShadow,Zt.setValue(D,"receiveShadow",te.receiveShadow)),G.isMeshGouraudMaterial&&G.envMap!==null&&(fr.envMap.value=ke,fr.flipEnvMap.value=ke.isCubeTexture&&ke.isRenderTargetTexture===!1?-1:1),ya&&(Zt.setValue(D,"toneMappingExposure",x.toneMappingExposure),Qe.needsLights&&pA(fr,Yu),Se&&G.fog===!0&&se.refreshFogUniforms(fr,Se),se.refreshMaterialUniforms(fr,G,O,B,Ae),oo.upload(D,Qe.uniformsList,fr,J)),G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(oo.upload(D,Qe.uniformsList,fr,J),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&Zt.setValue(D,"center",te.center),Zt.setValue(D,"modelViewMatrix",te.modelViewMatrix),Zt.setValue(D,"normalMatrix",te.normalMatrix),Zt.setValue(D,"modelMatrix",te.matrixWorld),G.isShaderMaterial||G.isRawShaderMaterial){const mn=G.uniformsGroups;for(let Ju=0,gA=mn.length;Ju<gA;Ju++)if(oe.isWebGL2){const b0=mn[Ju];qe.update(b0,ur),qe.bind(b0,ur)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return ur}function pA(P,V){P.ambientLightColor.needsUpdate=V,P.lightProbe.needsUpdate=V,P.directionalLights.needsUpdate=V,P.directionalLightShadows.needsUpdate=V,P.pointLights.needsUpdate=V,P.pointLightShadows.needsUpdate=V,P.spotLights.needsUpdate=V,P.spotLightShadows.needsUpdate=V,P.rectAreaLights.needsUpdate=V,P.hemisphereLights.needsUpdate=V}function mA(P){return P.isMeshLambertMaterial||P.isMeshToonMaterial||P.isMeshPhongMaterial||P.isMeshStandardMaterial||P.isShadowMaterial||P.isShaderMaterial&&P.lights===!0}this.getActiveCubeFace=function(){return M},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(P,V,j){$.get(P.texture).__webglTexture=V,$.get(P.depthTexture).__webglTexture=j;const G=$.get(P);G.__hasExternalTextures=!0,G.__hasExternalTextures&&(G.__autoAllocateDepthBuffer=j===void 0,G.__autoAllocateDepthBuffer||Q.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),G.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(P,V){const j=$.get(P);j.__webglFramebuffer=V,j.__useDefaultFramebuffer=V===void 0},this.setRenderTarget=function(P,V=0,j=0){A=P,M=V,w=j;let G=!0,te=null,Se=!1,Ue=!1;if(P){const ke=$.get(P);ke.__useDefaultFramebuffer!==void 0?(re.bindFramebuffer(D.FRAMEBUFFER,null),G=!1):ke.__webglFramebuffer===void 0?J.setupRenderTarget(P):ke.__hasExternalTextures&&J.rebindTextures(P,$.get(P.texture).__webglTexture,$.get(P.depthTexture).__webglTexture);const Ye=P.texture;(Ye.isData3DTexture||Ye.isDataArrayTexture||Ye.isCompressedArrayTexture)&&(Ue=!0);const He=$.get(P).__webglFramebuffer;P.isWebGLCubeRenderTarget?(te=He[V],Se=!0):oe.isWebGL2&&P.samples>0&&J.useMultisampledRTT(P)===!1?te=$.get(P).__webglMultisampledFramebuffer:te=He,b.copy(P.viewport),L.copy(P.scissor),k=P.scissorTest}else b.copy(ee).multiplyScalar(O).floor(),L.copy(z).multiplyScalar(O).floor(),k=Z;if(re.bindFramebuffer(D.FRAMEBUFFER,te)&&oe.drawBuffers&&G&&re.drawBuffers(P,te),re.viewport(b),re.scissor(L),re.setScissorTest(k),Se){const ke=$.get(P.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+V,ke.__webglTexture,j)}else if(Ue){const ke=$.get(P.texture),Ye=V||0;D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,ke.__webglTexture,j||0,Ye)}C=-1},this.readRenderTargetPixels=function(P,V,j,G,te,Se,Ue){if(!(P&&P.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Oe=$.get(P).__webglFramebuffer;if(P.isWebGLCubeRenderTarget&&Ue!==void 0&&(Oe=Oe[Ue]),Oe){re.bindFramebuffer(D.FRAMEBUFFER,Oe);try{const ke=P.texture,Ye=ke.format,He=ke.type;if(Ye!==an&&be.convert(Ye)!==D.getParameter(D.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const $e=He===gr&&(Q.has("EXT_color_buffer_half_float")||oe.isWebGL2&&Q.has("EXT_color_buffer_float"));if(He!==$n&&be.convert(He)!==D.getParameter(D.IMPLEMENTATION_COLOR_READ_TYPE)&&!(He===On&&(oe.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!$e){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}V>=0&&V<=P.width-G&&j>=0&&j<=P.height-te&&D.readPixels(V,j,G,te,be.convert(Ye),be.convert(He),Se)}finally{const ke=A!==null?$.get(A).__webglFramebuffer:null;re.bindFramebuffer(D.FRAMEBUFFER,ke)}}},this.copyFramebufferToTexture=function(P,V,j=0){const G=Math.pow(2,-j),te=Math.floor(V.image.width*G),Se=Math.floor(V.image.height*G);J.setTexture2D(V,0),D.copyTexSubImage2D(D.TEXTURE_2D,j,0,0,P.x,P.y,te,Se),re.unbindTexture()},this.copyTextureToTexture=function(P,V,j,G=0){const te=V.image.width,Se=V.image.height,Ue=be.convert(j.format),Oe=be.convert(j.type);J.setTexture2D(j,0),D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,j.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,j.unpackAlignment),V.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,G,P.x,P.y,te,Se,Ue,Oe,V.image.data):V.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,G,P.x,P.y,V.mipmaps[0].width,V.mipmaps[0].height,Ue,V.mipmaps[0].data):D.texSubImage2D(D.TEXTURE_2D,G,P.x,P.y,Ue,Oe,V.image),G===0&&j.generateMipmaps&&D.generateMipmap(D.TEXTURE_2D),re.unbindTexture()},this.copyTextureToTexture3D=function(P,V,j,G,te=0){if(x.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Se=P.max.x-P.min.x+1,Ue=P.max.y-P.min.y+1,Oe=P.max.z-P.min.z+1,ke=be.convert(G.format),Ye=be.convert(G.type);let He;if(G.isData3DTexture)J.setTexture3D(G,0),He=D.TEXTURE_3D;else if(G.isDataArrayTexture)J.setTexture2DArray(G,0),He=D.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,G.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,G.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,G.unpackAlignment);const $e=D.getParameter(D.UNPACK_ROW_LENGTH),_t=D.getParameter(D.UNPACK_IMAGE_HEIGHT),bt=D.getParameter(D.UNPACK_SKIP_PIXELS),Un=D.getParameter(D.UNPACK_SKIP_ROWS),di=D.getParameter(D.UNPACK_SKIP_IMAGES),Et=j.isCompressedTexture?j.mipmaps[0]:j.image;D.pixelStorei(D.UNPACK_ROW_LENGTH,Et.width),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Et.height),D.pixelStorei(D.UNPACK_SKIP_PIXELS,P.min.x),D.pixelStorei(D.UNPACK_SKIP_ROWS,P.min.y),D.pixelStorei(D.UNPACK_SKIP_IMAGES,P.min.z),j.isDataTexture||j.isData3DTexture?D.texSubImage3D(He,te,V.x,V.y,V.z,Se,Ue,Oe,ke,Ye,Et.data):j.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),D.compressedTexSubImage3D(He,te,V.x,V.y,V.z,Se,Ue,Oe,ke,Et.data)):D.texSubImage3D(He,te,V.x,V.y,V.z,Se,Ue,Oe,ke,Ye,Et),D.pixelStorei(D.UNPACK_ROW_LENGTH,$e),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,_t),D.pixelStorei(D.UNPACK_SKIP_PIXELS,bt),D.pixelStorei(D.UNPACK_SKIP_ROWS,Un),D.pixelStorei(D.UNPACK_SKIP_IMAGES,di),te===0&&G.generateMipmaps&&D.generateMipmap(He),re.unbindTexture()},this.initTexture=function(P){P.isCubeTexture?J.setTextureCube(P,0):P.isData3DTexture?J.setTexture3D(P,0):P.isDataArrayTexture||P.isCompressedArrayTexture?J.setTexture2DArray(P,0):J.setTexture2D(P,0),re.unbindTexture()},this.resetState=function(){M=0,w=0,A=null,re.reset(),Me.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Bn}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Ge?yi:Pc}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===yi?Ge:Sn}}class $d extends qd{}$d.prototype.isWebGL1Renderer=!0;class lo{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ye(e),this.density=t}clone(){return new lo(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class co{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ye(e),this.near=t,this.far=n}clone(){return new co(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class Yd extends tt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__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,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}}class ho{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=bs,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=on()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}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,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=on()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=on()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Ht=new R;class $i{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Ht.fromBufferAttribute(this,t),Ht.applyMatrix4(e),this.setXYZ(t,Ht.x,Ht.y,Ht.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ht.fromBufferAttribute(this,t),Ht.applyNormalMatrix(e),this.setXYZ(t,Ht.x,Ht.y,Ht.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ht.fromBufferAttribute(this,t),Ht.transformDirection(e),this.setXYZ(t,Ht.x,Ht.y,Ht.z);return this}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=ln(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ln(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ln(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ln(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),n=We(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array),s=We(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new Ze(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new $i(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class uh extends Ft{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ye(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Gr;const Os=new R,Hr=new R,Vr=new R,Wr=new q,Bs=new q,Zd=new Be,uo=new R,zs=new R,fo=new R,Jd=new q,fh=new q,Kd=new q;class jd extends tt{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",Gr===void 0){Gr=new Fe;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new ho(t,5);Gr.setIndex([0,1,2,0,2,3]),Gr.setAttribute("position",new $i(n,3,0,!1)),Gr.setAttribute("uv",new $i(n,2,3,!1))}this.geometry=Gr,this.material=e!==void 0?e:new uh,this.center=new q(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Hr.setFromMatrixScale(this.matrixWorld),Zd.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Vr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Hr.multiplyScalar(-Vr.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const a=this.center;po(uo.set(-.5,-.5,0),Vr,a,Hr,i,s),po(zs.set(.5,-.5,0),Vr,a,Hr,i,s),po(fo.set(.5,.5,0),Vr,a,Hr,i,s),Jd.set(0,0),fh.set(1,0),Kd.set(1,1);let o=e.ray.intersectTriangle(uo,zs,fo,!1,Os);if(o===null&&(po(zs.set(-.5,.5,0),Vr,a,Hr,i,s),fh.set(0,1),o=e.ray.intersectTriangle(uo,fo,zs,!1,Os),o===null))return;const l=e.ray.origin.distanceTo(Os);l<e.near||l>e.far||t.push({distance:l,point:Os.clone(),uv:jt.getInterpolation(Os,uo,zs,fo,Jd,fh,Kd,new q),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function po(r,e,t,n,i,s){Wr.subVectors(r,t).addScalar(.5).multiply(n),i!==void 0?(Bs.x=s*Wr.x-i*Wr.y,Bs.y=i*Wr.x+s*Wr.y):Bs.copy(Wr),r.copy(e),r.x+=Bs.x,r.y+=Bs.y,r.applyMatrix4(Zd)}const mo=new R,Qd=new R;class ep extends tt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n<i;n++){const s=t[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let s;for(s=0;s<i.length&&!(t<i[s].distance);s++);return i.splice(s,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let s=t[n].distance;if(t[n].object.visible&&(s-=s*t[n].hysteresis),e<s)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){mo.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(mo);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){mo.setFromMatrixPosition(e.matrixWorld),Qd.setFromMatrixPosition(this.matrixWorld);const n=mo.distanceTo(Qd)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i<s;i++){let a=t[i].distance;if(t[i].object.visible&&(a-=a*t[i].hysteresis),n>=a)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<s;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let i=0,s=n.length;i<s;i++){const a=n[i];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const tp=new R,np=new rt,ip=new rt,JM=new R,rp=new Be,Xr=new R,dh=new wn,sp=new Be,ph=new Er;class ap extends It{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Be,this.bindMatrixInverse=new Be,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new _n),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)Xr.fromBufferAttribute(t,n),this.applyBoneTransform(n,Xr),this.boundingBox.expandByPoint(Xr)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new wn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)Xr.fromBufferAttribute(t,n),this.applyBoneTransform(n,Xr),this.boundingSphere.expandByPoint(Xr)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),dh.copy(this.boundingSphere),dh.applyMatrix4(i),e.ray.intersectsSphere(dh)!==!1&&(sp.copy(i).invert(),ph.copy(e.ray).applyMatrix4(sp),!(this.boundingBox!==null&&ph.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ph)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new rt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;np.fromBufferAttribute(i.attributes.skinIndex,e),ip.fromBufferAttribute(i.attributes.skinWeight,e),tp.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=ip.getComponent(s);if(a!==0){const o=np.getComponent(s);rp.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(JM.copy(tp).applyMatrix4(rp),a)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}}class mh extends tt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class qr extends Mt{constructor(e=null,t=1,n=1,i,s,a,o,l,c=yt,h=yt,u,f){super(null,a,o,l,c,h,i,s,u,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const op=new Be,KM=new Be;class go{constructor(e=[],t=[]){this.uuid=on(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Be)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Be;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:KM;op.multiplyMatrices(o,t[s]),op.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new go(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Zf(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new qr(t,e,e,an,On);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const s=e.bones[n];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new mh),this.bones.push(a),this.boneInverses.push(new Be().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class $r extends Ze{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Yr=new Be,lp=new Be,_o=[],cp=new _n,jM=new Be,ks=new It,Gs=new wn;class hp extends It{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new $r(new Float32Array(n*16),16),this.instanceColor=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,jM)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new _n),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Yr),cp.copy(e.boundingBox).applyMatrix4(Yr),this.boundingBox.union(cp)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new wn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Yr),Gs.copy(e.boundingSphere).applyMatrix4(Yr),this.boundingSphere.union(Gs)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){const n=this.matrixWorld,i=this.count;if(ks.geometry=this.geometry,ks.material=this.material,ks.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Gs.copy(this.boundingSphere),Gs.applyMatrix4(n),e.ray.intersectsSphere(Gs)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,Yr),lp.multiplyMatrices(n,Yr),ks.matrixWorld=lp,ks.raycast(e,_o);for(let a=0,o=_o.length;a<o;a++){const l=_o[a];l.instanceId=s,l.object=this,t.push(l)}_o.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new $r(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class Vt extends Ft{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ye(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 up=new R,fp=new R,dp=new Be,gh=new Er,xo=new wn;class Ri extends tt{constructor(e=new Fe,t=new Vt){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)up.fromBufferAttribute(t,i-1),fp.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=up.distanceTo(fp);e.setAttribute("lineDistance",new ve(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),xo.copy(n.boundingSphere),xo.applyMatrix4(i),xo.radius+=s,e.ray.intersectsSphere(xo)===!1)return;dp.copy(i).invert(),gh.copy(e.ray).applyMatrix4(dp);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=new R,h=new R,u=new R,f=new R,d=this.isLineSegments?2:1,p=n.index,g=n.attributes.position;if(p!==null){const m=Math.max(0,a.start),y=Math.min(p.count,a.start+a.count);for(let x=m,v=y-1;x<v;x+=d){const M=p.getX(x),w=p.getX(x+1);if(c.fromBufferAttribute(g,M),h.fromBufferAttribute(g,w),gh.distanceSqToSegment(c,h,f,u)>l)continue;f.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(f);C<e.near||C>e.far||t.push({distance:C,point:u.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{const m=Math.max(0,a.start),y=Math.min(g.count,a.start+a.count);for(let x=m,v=y-1;x<v;x+=d){if(c.fromBufferAttribute(g,x),h.fromBufferAttribute(g,x+1),gh.distanceSqToSegment(c,h,f,u)>l)continue;f.applyMatrix4(this.matrixWorld);const w=e.ray.origin.distanceTo(f);w<e.near||w>e.far||t.push({distance:w,point:u.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}const pp=new R,mp=new R;class kn extends Ri{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,n=[];for(let i=0,s=t.count;i<s;i+=2)pp.fromBufferAttribute(t,i),mp.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+pp.distanceTo(mp);e.setAttribute("lineDistance",new ve(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class gp extends Ri{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class _h extends Ft{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ye(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const _p=new Be,xh=new Er,yo=new wn,vo=new R;class xp extends tt{constructor(e=new Fe,t=new _h){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),yo.copy(n.boundingSphere),yo.applyMatrix4(i),yo.radius+=s,e.ray.intersectsSphere(yo)===!1)return;_p.copy(i).invert(),xh.copy(e.ray).applyMatrix4(_p);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,u=n.attributes.position;if(c!==null){const f=Math.max(0,a.start),d=Math.min(c.count,a.start+a.count);for(let p=f,_=d;p<_;p++){const g=c.getX(p);vo.fromBufferAttribute(u,g),yp(vo,g,l,i,e,t,this)}}else{const f=Math.max(0,a.start),d=Math.min(u.count,a.start+a.count);for(let p=f,_=d;p<_;p++)vo.fromBufferAttribute(u,p),yp(vo,p,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function yp(r,e,t,n,i,s,a){const o=xh.distanceSqToPoint(r);if(o<t){const l=new R;xh.closestPointToPoint(r,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,object:a})}}class QM extends Mt{constructor(e,t,n,i,s,a,o,l,c){super(e,t,n,i,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:vt,this.magFilter=s!==void 0?s:vt,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class eS extends Mt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=yt,this.minFilter=yt,this.generateMipmaps=!1,this.needsUpdate=!0}}class yh extends Mt{constructor(e,t,n,i,s,a,o,l,c,h,u,f){super(null,a,o,l,c,h,i,s,u,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class tS extends yh{constructor(e,t,n,i,s,a){super(e,t,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Dt}}class nS extends Mt{constructor(e,t,n,i,s,a,o,l,c){super(e,t,n,i,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Cn{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),c=n[i]-a,c<0)o=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(s-1);const h=n[i],f=n[i+1]-h,d=(a-h)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const a=this.getPoint(i),o=this.getPoint(s),l=t||(a.isVector2?new q:new R);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new R,i=[],s=[],a=[],o=new R,l=new Be;for(let d=0;d<=e;d++){const p=d/e;i[d]=this.getTangentAt(p,new R)}s[0]=new R,a[0]=new R;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),u=Math.abs(i[0].y),f=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),f<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),a[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),a[d]=a[d-1].clone(),o.crossVectors(i[d-1],i[d]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(ft(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(l.makeRotationAxis(o,p))}a[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(ft(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(o.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(l.makeRotationAxis(i[p],d*p)),a[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Mo extends Cn{constructor(e=0,t=0,n=1,i=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t){const n=t||new q,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(a?s=0:s=i),this.aClockwise===!0&&!a&&(s===i?s=-i:s=s-i);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),f=l-this.aX,d=c-this.aY;l=f*h-d*u+this.aX,c=f*u+d*h+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class vp extends Mo{constructor(e,t,n,i,s,a){super(e,t,n,n,i,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function vh(){let r=0,e=0,t=0,n=0;function i(s,a,o,l){r=s,e=o,t=-3*s+3*a-2*o-l,n=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){i(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,h,u){let f=(a-s)/c-(o-s)/(c+h)+(o-a)/h,d=(o-a)/h-(l-a)/(h+u)+(l-o)/u;f*=h,d*=h,i(a,o,f,d)},calc:function(s){const a=s*s,o=a*s;return r+e*s+t*a+n*o}}}const So=new R,Mh=new vh,Sh=new vh,bh=new vh;class Mp extends Cn{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new R){const n=t,i=this.points,s=i.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,h;this.closed||o>0?c=i[(o-1)%s]:(So.subVectors(i[0],i[1]).add(i[0]),c=So);const u=i[o%s],f=i[(o+1)%s];if(this.closed||o+2<s?h=i[(o+2)%s]:(So.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=So),this.curveType==="centripetal"||this.curveType==="chordal"){const d=this.curveType==="chordal"?.5:.25;let p=Math.pow(c.distanceToSquared(u),d),_=Math.pow(u.distanceToSquared(f),d),g=Math.pow(f.distanceToSquared(h),d);_<1e-4&&(_=1),p<1e-4&&(p=_),g<1e-4&&(g=_),Mh.initNonuniformCatmullRom(c.x,u.x,f.x,h.x,p,_,g),Sh.initNonuniformCatmullRom(c.y,u.y,f.y,h.y,p,_,g),bh.initNonuniformCatmullRom(c.z,u.z,f.z,h.z,p,_,g)}else this.curveType==="catmullrom"&&(Mh.initCatmullRom(c.x,u.x,f.x,h.x,this.tension),Sh.initCatmullRom(c.y,u.y,f.y,h.y,this.tension),bh.initCatmullRom(c.z,u.z,f.z,h.z,this.tension));return n.set(Mh.calc(l),Sh.calc(l),bh.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new R().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Sp(r,e,t,n,i){const s=(n-e)*.5,a=(i-t)*.5,o=r*r,l=r*o;return(2*t-2*n+s+a)*l+(-3*t+3*n-2*s-a)*o+s*r+t}function iS(r,e){const t=1-r;return t*t*e}function rS(r,e){return 2*(1-r)*r*e}function sS(r,e){return r*r*e}function Hs(r,e,t,n){return iS(r,e)+rS(r,t)+sS(r,n)}function aS(r,e){const t=1-r;return t*t*t*e}function oS(r,e){const t=1-r;return 3*t*t*r*e}function lS(r,e){return 3*(1-r)*r*r*e}function cS(r,e){return r*r*r*e}function Vs(r,e,t,n,i){return aS(r,e)+oS(r,t)+lS(r,n)+cS(r,i)}class wh extends Cn{constructor(e=new q,t=new q,n=new q,i=new q){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new q){const n=t,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(Vs(e,i.x,s.x,a.x,o.x),Vs(e,i.y,s.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class bp extends Cn{constructor(e=new R,t=new R,n=new R,i=new R){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new R){const n=t,i=this.v0,s=this.v1,a=this.v2,o=this.v3;return n.set(Vs(e,i.x,s.x,a.x,o.x),Vs(e,i.y,s.y,a.y,o.y),Vs(e,i.z,s.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class bo extends Cn{constructor(e=new q,t=new q){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new q){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new q){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class wp extends Cn{constructor(e=new R,t=new R){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new R){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new R){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Eh extends Cn{constructor(e=new q,t=new q,n=new q){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new q){const n=t,i=this.v0,s=this.v1,a=this.v2;return n.set(Hs(e,i.x,s.x,a.x),Hs(e,i.y,s.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Ah extends Cn{constructor(e=new R,t=new R,n=new R){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new R){const n=t,i=this.v0,s=this.v1,a=this.v2;return n.set(Hs(e,i.x,s.x,a.x),Hs(e,i.y,s.y,a.y),Hs(e,i.z,s.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Th extends Cn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new q){const n=t,i=this.points,s=(i.length-1)*e,a=Math.floor(s),o=s-a,l=i[a===0?a:a-1],c=i[a],h=i[a>i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(Sp(o,l.x,c.x,h.x,u.x),Sp(o,l.y,c.y,h.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new q().fromArray(i))}return this}}var Rh=Object.freeze({__proto__:null,ArcCurve:vp,CatmullRomCurve3:Mp,CubicBezierCurve:wh,CubicBezierCurve3:bp,EllipseCurve:Mo,LineCurve:bo,LineCurve3:wp,QuadraticBezierCurve:Eh,QuadraticBezierCurve3:Ah,SplineCurve:Th});class Ep extends Cn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new bo(t,e))}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const a=i[s]-n,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const a=s[i],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const h=l[c];n&&n.equals(h)||(t.push(h),n=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new Rh[i.type]().fromJSON(i))}return this}}let Ws=class extends Ep{constructor(e){super(),this.type="Path",this.currentPoint=new q,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new bo(this.currentPoint.clone(),new q(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const s=new Eh(this.currentPoint.clone(),new q(e,t),new q(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,a){const o=new wh(this.currentPoint.clone(),new q(e,t),new q(n,i),new q(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Th(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,n,i,s,a),this}absarc(e,t,n,i,s,a){return this.absellipse(e,t,n,n,i,s,a),this}ellipse(e,t,n,i,s,a,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,n,i,s,a,o,l),this}absellipse(e,t,n,i,s,a,o,l){const c=new Mo(e,t,n,i,s,a,o,l);if(this.curves.length>0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class Xs extends Fe{constructor(e=[new q(0,-.5),new q(.5,0),new q(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=ft(i,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],h=1/t,u=new R,f=new q,d=new R,p=new R,_=new R;let g=0,m=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,d.x=m*1,d.y=-g,d.z=m*0,_.copy(d),d.normalize(),l.push(d.x,d.y,d.z);break;case e.length-1:l.push(_.x,_.y,_.z);break;default:g=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,d.x=m*1,d.y=-g,d.z=m*0,p.copy(d),d.x+=_.x,d.y+=_.y,d.z+=_.z,d.normalize(),l.push(d.x,d.y,d.z),_.copy(p)}for(let y=0;y<=t;y++){const x=n+y*h*i,v=Math.sin(x),M=Math.cos(x);for(let w=0;w<=e.length-1;w++){u.x=e[w].x*v,u.y=e[w].y,u.z=e[w].x*M,a.push(u.x,u.y,u.z),f.x=y/t,f.y=w/(e.length-1),o.push(f.x,f.y);const A=l[3*w+0]*v,C=l[3*w+1],S=l[3*w+0]*M;c.push(A,C,S)}}for(let y=0;y<t;y++)for(let x=0;x<e.length-1;x++){const v=x+y*e.length,M=v,w=v+e.length,A=v+e.length+1,C=v+1;s.push(M,w,C),s.push(A,C,w)}this.setIndex(s),this.setAttribute("position",new ve(a,3)),this.setAttribute("uv",new ve(o,2)),this.setAttribute("normal",new ve(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xs(e.points,e.segments,e.phiStart,e.phiLength)}}class wo extends Xs{constructor(e=1,t=1,n=4,i=8){const s=new Ws;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new wo(e.radius,e.length,e.capSegments,e.radialSegments)}}class Eo extends Fe{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new R,h=new q;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,f=3;u<=t;u++,f+=3){const d=n+u/t*i;c.x=e*Math.cos(d),c.y=e*Math.sin(d),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[f]/e+1)/2,h.y=(a[f+1]/e+1)/2,l.push(h.x,h.y)}for(let u=1;u<=t;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new ve(a,3)),this.setAttribute("normal",new ve(o,3)),this.setAttribute("uv",new ve(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Eo(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Zr extends Fe{constructor(e=1,t=1,n=1,i=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;i=Math.floor(i),s=Math.floor(s);const h=[],u=[],f=[],d=[];let p=0;const _=[],g=n/2;let m=0;y(),a===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new ve(u,3)),this.setAttribute("normal",new ve(f,3)),this.setAttribute("uv",new ve(d,2));function y(){const v=new R,M=new R;let w=0;const A=(t-e)/n;for(let C=0;C<=s;C++){const S=[],b=C/s,L=b*(t-e)+e;for(let k=0;k<=i;k++){const U=k/i,N=U*l+o,I=Math.sin(N),B=Math.cos(N);M.x=L*I,M.y=-b*n+g,M.z=L*B,u.push(M.x,M.y,M.z),v.set(I,A,B).normalize(),f.push(v.x,v.y,v.z),d.push(U,1-b),S.push(p++)}_.push(S)}for(let C=0;C<i;C++)for(let S=0;S<s;S++){const b=_[S][C],L=_[S+1][C],k=_[S+1][C+1],U=_[S][C+1];h.push(b,L,U),h.push(L,k,U),w+=6}c.addGroup(m,w,0),m+=w}function x(v){const M=p,w=new q,A=new R;let C=0;const S=v===!0?e:t,b=v===!0?1:-1;for(let k=1;k<=i;k++)u.push(0,g*b,0),f.push(0,b,0),d.push(.5,.5),p++;const L=p;for(let k=0;k<=i;k++){const N=k/i*l+o,I=Math.cos(N),B=Math.sin(N);A.x=S*B,A.y=g*b,A.z=S*I,u.push(A.x,A.y,A.z),f.push(0,b,0),w.x=I*.5+.5,w.y=B*.5*b+.5,d.push(w.x,w.y),p++}for(let k=0;k<i;k++){const U=M+k,N=L+k;v===!0?h.push(N,N+1,U):h.push(N+1,N,U),C+=3}c.addGroup(m,C,v===!0?1:2),m+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zr(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ao extends Zr{constructor(e=1,t=1,n=32,i=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,n,i,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Ao(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ci extends Fe{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const s=[],a=[];o(i),c(n),h(),this.setAttribute("position",new ve(s,3)),this.setAttribute("normal",new ve(s.slice(),3)),this.setAttribute("uv",new ve(a,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function o(y){const x=new R,v=new R,M=new R;for(let w=0;w<t.length;w+=3)d(t[w+0],x),d(t[w+1],v),d(t[w+2],M),l(x,v,M,y)}function l(y,x,v,M){const w=M+1,A=[];for(let C=0;C<=w;C++){A[C]=[];const S=y.clone().lerp(v,C/w),b=x.clone().lerp(v,C/w),L=w-C;for(let k=0;k<=L;k++)k===0&&C===w?A[C][k]=S:A[C][k]=S.clone().lerp(b,k/L)}for(let C=0;C<w;C++)for(let S=0;S<2*(w-C)-1;S++){const b=Math.floor(S/2);S%2===0?(f(A[C][b+1]),f(A[C+1][b]),f(A[C][b])):(f(A[C][b+1]),f(A[C+1][b+1]),f(A[C+1][b]))}}function c(y){const x=new R;for(let v=0;v<s.length;v+=3)x.x=s[v+0],x.y=s[v+1],x.z=s[v+2],x.normalize().multiplyScalar(y),s[v+0]=x.x,s[v+1]=x.y,s[v+2]=x.z}function h(){const y=new R;for(let x=0;x<s.length;x+=3){y.x=s[x+0],y.y=s[x+1],y.z=s[x+2];const v=g(y)/2/Math.PI+.5,M=m(y)/Math.PI+.5;a.push(v,1-M)}p(),u()}function u(){for(let y=0;y<a.length;y+=6){const x=a[y+0],v=a[y+2],M=a[y+4],w=Math.max(x,v,M),A=Math.min(x,v,M);w>.9&&A<.1&&(x<.2&&(a[y+0]+=1),v<.2&&(a[y+2]+=1),M<.2&&(a[y+4]+=1))}}function f(y){s.push(y.x,y.y,y.z)}function d(y,x){const v=y*3;x.x=e[v+0],x.y=e[v+1],x.z=e[v+2]}function p(){const y=new R,x=new R,v=new R,M=new R,w=new q,A=new q,C=new q;for(let S=0,b=0;S<s.length;S+=9,b+=6){y.set(s[S+0],s[S+1],s[S+2]),x.set(s[S+3],s[S+4],s[S+5]),v.set(s[S+6],s[S+7],s[S+8]),w.set(a[b+0],a[b+1]),A.set(a[b+2],a[b+3]),C.set(a[b+4],a[b+5]),M.copy(y).add(x).add(v).divideScalar(3);const L=g(M);_(w,b+0,y,L),_(A,b+2,x,L),_(C,b+4,v,L)}}function _(y,x,v,M){M<0&&y.x===1&&(a[x]=y.x-1),v.x===0&&v.z===0&&(a[x]=M/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function m(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ci(e.vertices,e.indices,e.radius,e.details)}}class To extends Ci{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new To(e.radius,e.detail)}}const Ro=new R,Co=new R,Ch=new R,Po=new jt;class Ap extends Fe{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),s=Math.cos(Bi*t),a=e.getIndex(),o=e.getAttribute("position"),l=a?a.count:o.count,c=[0,0,0],h=["a","b","c"],u=new Array(3),f={},d=[];for(let p=0;p<l;p+=3){a?(c[0]=a.getX(p),c[1]=a.getX(p+1),c[2]=a.getX(p+2)):(c[0]=p,c[1]=p+1,c[2]=p+2);const{a:_,b:g,c:m}=Po;if(_.fromBufferAttribute(o,c[0]),g.fromBufferAttribute(o,c[1]),m.fromBufferAttribute(o,c[2]),Po.getNormal(Ch),u[0]=`${Math.round(_.x*i)},${Math.round(_.y*i)},${Math.round(_.z*i)}`,u[1]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,u[2]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let y=0;y<3;y++){const x=(y+1)%3,v=u[y],M=u[x],w=Po[h[y]],A=Po[h[x]],C=`${v}_${M}`,S=`${M}_${v}`;S in f&&f[S]?(Ch.dot(f[S].normal)<=s&&(d.push(w.x,w.y,w.z),d.push(A.x,A.y,A.z)),f[S]=null):C in f||(f[C]={index0:c[y],index1:c[x],normal:Ch.clone()})}}for(const p in f)if(f[p]){const{index0:_,index1:g}=f[p];Ro.fromBufferAttribute(o,_),Co.fromBufferAttribute(o,g),d.push(Ro.x,Ro.y,Ro.z),d.push(Co.x,Co.y,Co.z)}this.setAttribute("position",new ve(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class ii extends Ws{constructor(e){super(e),this.uuid=on(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new Ws().fromJSON(i))}return this}}const hS={triangulate:function(r,e,t=2){const n=e&&e.length,i=n?e[0]*t:r.length;let s=Tp(r,0,i,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c,h,u,f,d;if(n&&(s=mS(r,e,s,t)),r.length>80*t){o=c=r[0],l=h=r[1];for(let p=t;p<i;p+=t)u=r[p],f=r[p+1],u<o&&(o=u),f<l&&(l=f),u>c&&(c=u),f>h&&(h=f);d=Math.max(c-o,h-l),d=d!==0?32767/d:0}return qs(s,a,t,o,l,d,0),a}};function Tp(r,e,t,n,i){let s,a;if(i===AS(r,e,t,n)>0)for(s=e;s<t;s+=n)a=Pp(s,r[s],r[s+1],a);else for(s=t-n;s>=e;s-=n)a=Pp(s,r[s],r[s+1],a);return a&&Lo(a,a.next)&&(Ys(a),a=a.next),a}function Yi(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(Lo(t,t.next)||lt(t.prev,t,t.next)===0)){if(Ys(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function qs(r,e,t,n,i,s,a){if(!r)return;!a&&s&&vS(r,n,i,s);let o=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?fS(r,n,i,s):uS(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(c.i/t|0),Ys(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=dS(Yi(r),e,t),qs(r,e,t,n,i,s,2)):a===2&&pS(r,e,t,n,i,s):qs(Yi(r),e,t,n,i,s,1);break}}}function uS(r){const e=r.prev,t=r,n=r.next;if(lt(e,t,n)>=0)return!1;const i=e.x,s=t.x,a=n.x,o=e.y,l=t.y,c=n.y,h=i<s?i<a?i:a:s<a?s:a,u=o<l?o<c?o:c:l<c?l:c,f=i>s?i>a?i:a:s>a?s:a,d=o>l?o>c?o:c:l>c?l:c;let p=n.next;for(;p!==e;){if(p.x>=h&&p.x<=f&&p.y>=u&&p.y<=d&&Jr(i,o,s,l,a,c,p.x,p.y)&&lt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function fS(r,e,t,n){const i=r.prev,s=r,a=r.next;if(lt(i,s,a)>=0)return!1;const o=i.x,l=s.x,c=a.x,h=i.y,u=s.y,f=a.y,d=o<l?o<c?o:c:l<c?l:c,p=h<u?h<f?h:f:u<f?u:f,_=o>l?o>c?o:c:l>c?l:c,g=h>u?h>f?h:f:u>f?u:f,m=Ph(d,p,e,t,n),y=Ph(_,g,e,t,n);let x=r.prevZ,v=r.nextZ;for(;x&&x.z>=m&&v&&v.z<=y;){if(x.x>=d&&x.x<=_&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&Jr(o,h,l,u,c,f,x.x,x.y)&&lt(x.prev,x,x.next)>=0||(x=x.prevZ,v.x>=d&&v.x<=_&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&Jr(o,h,l,u,c,f,v.x,v.y)&&lt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;x&&x.z>=m;){if(x.x>=d&&x.x<=_&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&Jr(o,h,l,u,c,f,x.x,x.y)&&lt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=d&&v.x<=_&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&Jr(o,h,l,u,c,f,v.x,v.y)&&lt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function dS(r,e,t){let n=r;do{const i=n.prev,s=n.next.next;!Lo(i,s)&&Rp(i,n,n.next,s)&&$s(i,s)&&$s(s,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),Ys(n),Ys(n.next),n=r=s),n=n.next}while(n!==r);return Yi(n)}function pS(r,e,t,n,i,s){let a=r;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&bS(a,o)){let l=Cp(a,o);a=Yi(a,a.next),l=Yi(l,l.next),qs(a,e,t,n,i,s,0),qs(l,e,t,n,i,s,0);return}o=o.next}a=a.next}while(a!==r)}function mS(r,e,t,n){const i=[];let s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*n,l=s<a-1?e[s+1]*n:r.length,c=Tp(r,o,l,n,!1),c===c.next&&(c.steiner=!0),i.push(SS(c));for(i.sort(gS),s=0;s<i.length;s++)t=_S(i[s],t);return t}function gS(r,e){return r.x-e.x}function _S(r,e){const t=xS(r,e);if(!t)return e;const n=Cp(t,r);return Yi(n,n.next),Yi(t,t.next)}function xS(r,e){let t=e,n=-1/0,i;const s=r.x,a=r.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const f=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=s&&f>n&&(n=f,i=t.x<t.next.x?t:t.next,f===s))return i}t=t.next}while(t!==e);if(!i)return null;const o=i,l=i.x,c=i.y;let h=1/0,u;t=i;do s>=t.x&&t.x>=l&&s!==t.x&&Jr(a<c?s:n,a,l,c,a<c?n:s,a,t.x,t.y)&&(u=Math.abs(a-t.y)/(s-t.x),$s(t,r)&&(u<h||u===h&&(t.x>i.x||t.x===i.x&&yS(i,t)))&&(i=t,h=u)),t=t.next;while(t!==o);return i}function yS(r,e){return lt(r.prev,r,e.prev)<0&&lt(e.next,r,r.next)<0}function vS(r,e,t,n){let i=r;do i.z===0&&(i.z=Ph(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,MS(i)}function MS(r){let e,t,n,i,s,a,o,l,c=1;do{for(t=r,r=null,s=null,a=0;t;){for(a++,n=t,o=0,e=0;e<c&&(o++,n=n.nextZ,!!n);e++);for(l=c;o>0||l>0&&n;)o!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,o--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(a>1);return r}function Ph(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function SS(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function Jr(r,e,t,n,i,s,a,o){return(i-a)*(e-o)>=(r-a)*(s-o)&&(r-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(i-a)*(n-o)}function bS(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!wS(r,e)&&($s(r,e)&&$s(e,r)&&ES(r,e)&&(lt(r.prev,r,e.prev)||lt(r,e.prev,e))||Lo(r,e)&&lt(r.prev,r,r.next)>0&&lt(e.prev,e,e.next)>0)}function lt(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function Lo(r,e){return r.x===e.x&&r.y===e.y}function Rp(r,e,t,n){const i=Uo(lt(r,e,t)),s=Uo(lt(r,e,n)),a=Uo(lt(t,n,r)),o=Uo(lt(t,n,e));return!!(i!==s&&a!==o||i===0&&Io(r,t,e)||s===0&&Io(r,n,e)||a===0&&Io(t,r,n)||o===0&&Io(t,e,n))}function Io(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Uo(r){return r>0?1:r<0?-1:0}function wS(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Rp(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function $s(r,e){return lt(r.prev,r,r.next)<0?lt(r,e,r.next)>=0&&lt(r,r.prev,e)>=0:lt(r,e,r.prev)<0||lt(r,r.next,e)<0}function ES(r,e){let t=r,n=!1;const i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function Cp(r,e){const t=new Lh(r.i,r.x,r.y),n=new Lh(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Pp(r,e,t,n){const i=new Lh(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ys(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Lh(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function AS(r,e,t,n){let i=0;for(let s=e,a=t-n;s<t;s+=n)i+=(r[a]-r[s])*(r[s+1]+r[a+1]),a=s;return i}class un{static area(e){const t=e.length;let n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return un.area(e)<0}static triangulateShape(e,t){const n=[],i=[],s=[];Lp(e),Ip(n,e);let a=e.length;t.forEach(Lp);for(let l=0;l<t.length;l++)i.push(a),a+=t[l].length,Ip(n,t[l]);const o=hS.triangulate(n,i);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function Lp(r){const e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function Ip(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}let Up=class C0 extends Fe{constructor(e=new ii([new q(.5,.5),new q(-.5,.5),new q(-.5,-.5),new q(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new ve(i,3)),this.setAttribute("uv",new ve(s,2)),this.computeVertexNormals();function a(o){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1,u=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:d-.1,_=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const m=t.extrudePath,y=t.UVGenerator!==void 0?t.UVGenerator:TS;let x,v=!1,M,w,A,C;m&&(x=m.getSpacedPoints(h),v=!0,f=!1,M=m.computeFrenetFrames(h,!1),w=new R,A=new R,C=new R),f||(g=0,d=0,p=0,_=0);const S=o.extractPoints(c);let b=S.shape;const L=S.holes;if(!un.isClockWise(b)){b=b.reverse();for(let D=0,ae=L.length;D<ae;D++){const Q=L[D];un.isClockWise(Q)&&(L[D]=Q.reverse())}}const U=un.triangulateShape(b,L),N=b;for(let D=0,ae=L.length;D<ae;D++){const Q=L[D];b=b.concat(Q)}function I(D,ae,Q){return ae||console.error("THREE.ExtrudeGeometry: vec does not exist"),D.clone().addScaledVector(ae,Q)}const B=b.length,O=U.length;function H(D,ae,Q){let oe,re,Ee;const $=D.x-ae.x,J=D.y-ae.y,ne=Q.x-D.x,de=Q.y-D.y,pe=$*$+J*J,T=$*de-J*ne;if(Math.abs(T)>Number.EPSILON){const E=Math.sqrt(pe),W=Math.sqrt(ne*ne+de*de),se=ae.x-J/E,ie=ae.y+$/E,me=Q.x-de/W,we=Q.y+ne/W,he=((me-se)*de-(we-ie)*ne)/($*de-J*ne);oe=se+$*he-D.x,re=ie+J*he-D.y;const K=oe*oe+re*re;if(K<=2)return new q(oe,re);Ee=Math.sqrt(K/2)}else{let E=!1;$>Number.EPSILON?ne>Number.EPSILON&&(E=!0):$<-Number.EPSILON?ne<-Number.EPSILON&&(E=!0):Math.sign(J)===Math.sign(de)&&(E=!0),E?(oe=-J,re=$,Ee=Math.sqrt(pe)):(oe=$,re=J,Ee=Math.sqrt(pe/2))}return new q(oe/Ee,re/Ee)}const X=[];for(let D=0,ae=N.length,Q=ae-1,oe=D+1;D<ae;D++,Q++,oe++)Q===ae&&(Q=0),oe===ae&&(oe=0),X[D]=H(N[D],N[Q],N[oe]);const ee=[];let z,Z=X.concat();for(let D=0,ae=L.length;D<ae;D++){const Q=L[D];z=[];for(let oe=0,re=Q.length,Ee=re-1,$=oe+1;oe<re;oe++,Ee++,$++)Ee===re&&(Ee=0),$===re&&($=0),z[oe]=H(Q[oe],Q[Ee],Q[$]);ee.push(z),Z=Z.concat(z)}for(let D=0;D<g;D++){const ae=D/g,Q=d*Math.cos(ae*Math.PI/2),oe=p*Math.sin(ae*Math.PI/2)+_;for(let re=0,Ee=N.length;re<Ee;re++){const $=I(N[re],X[re],oe);Pe($.x,$.y,-Q)}for(let re=0,Ee=L.length;re<Ee;re++){const $=L[re];z=ee[re];for(let J=0,ne=$.length;J<ne;J++){const de=I($[J],z[J],oe);Pe(de.x,de.y,-Q)}}}const le=p+_;for(let D=0;D<B;D++){const ae=f?I(b[D],Z[D],le):b[D];v?(A.copy(M.normals[0]).multiplyScalar(ae.x),w.copy(M.binormals[0]).multiplyScalar(ae.y),C.copy(x[0]).add(A).add(w),Pe(C.x,C.y,C.z)):Pe(ae.x,ae.y,0)}for(let D=1;D<=h;D++)for(let ae=0;ae<B;ae++){const Q=f?I(b[ae],Z[ae],le):b[ae];v?(A.copy(M.normals[D]).multiplyScalar(Q.x),w.copy(M.binormals[D]).multiplyScalar(Q.y),C.copy(x[D]).add(A).add(w),Pe(C.x,C.y,C.z)):Pe(Q.x,Q.y,u/h*D)}for(let D=g-1;D>=0;D--){const ae=D/g,Q=d*Math.cos(ae*Math.PI/2),oe=p*Math.sin(ae*Math.PI/2)+_;for(let re=0,Ee=N.length;re<Ee;re++){const $=I(N[re],X[re],oe);Pe($.x,$.y,u+Q)}for(let re=0,Ee=L.length;re<Ee;re++){const $=L[re];z=ee[re];for(let J=0,ne=$.length;J<ne;J++){const de=I($[J],z[J],oe);v?Pe(de.x,de.y+x[h-1].y,x[h-1].x+Q):Pe(de.x,de.y,u+Q)}}}ce(),fe();function ce(){const D=i.length/3;if(f){let ae=0,Q=B*ae;for(let oe=0;oe<O;oe++){const re=U[oe];Te(re[2]+Q,re[1]+Q,re[0]+Q)}ae=h+g*2,Q=B*ae;for(let oe=0;oe<O;oe++){const re=U[oe];Te(re[0]+Q,re[1]+Q,re[2]+Q)}}else{for(let ae=0;ae<O;ae++){const Q=U[ae];Te(Q[2],Q[1],Q[0])}for(let ae=0;ae<O;ae++){const Q=U[ae];Te(Q[0]+B*h,Q[1]+B*h,Q[2]+B*h)}}n.addGroup(D,i.length/3-D,0)}function fe(){const D=i.length/3;let ae=0;Ae(N,ae),ae+=N.length;for(let Q=0,oe=L.length;Q<oe;Q++){const re=L[Q];Ae(re,ae),ae+=re.length}n.addGroup(D,i.length/3-D,1)}function Ae(D,ae){let Q=D.length;for(;--Q>=0;){const oe=Q;let re=Q-1;re<0&&(re=D.length-1);for(let Ee=0,$=h+g*2;Ee<$;Ee++){const J=B*Ee,ne=B*(Ee+1),de=ae+oe+J,pe=ae+re+J,T=ae+re+ne,E=ae+oe+ne;Ke(de,pe,T,E)}}}function Pe(D,ae,Q){l.push(D),l.push(ae),l.push(Q)}function Te(D,ae,Q){je(D),je(ae),je(Q);const oe=i.length/3,re=y.generateTopUV(n,i,oe-3,oe-2,oe-1);Le(re[0]),Le(re[1]),Le(re[2])}function Ke(D,ae,Q,oe){je(D),je(ae),je(oe),je(ae),je(Q),je(oe);const re=i.length/3,Ee=y.generateSideWallUV(n,i,re-6,re-3,re-2,re-1);Le(Ee[0]),Le(Ee[1]),Le(Ee[3]),Le(Ee[1]),Le(Ee[2]),Le(Ee[3])}function je(D){i.push(l[D*3+0]),i.push(l[D*3+1]),i.push(l[D*3+2])}function Le(D){s.push(D.x),s.push(D.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return RS(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];n.push(o)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new Rh[i.type]().fromJSON(i)),new C0(n,e.options)}};const TS={generateTopUV:function(r,e,t,n,i){const s=e[t*3],a=e[t*3+1],o=e[n*3],l=e[n*3+1],c=e[i*3],h=e[i*3+1];return[new q(s,a),new q(o,l),new q(c,h)]},generateSideWallUV:function(r,e,t,n,i,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[n*3],h=e[n*3+1],u=e[n*3+2],f=e[i*3],d=e[i*3+1],p=e[i*3+2],_=e[s*3],g=e[s*3+1],m=e[s*3+2];return Math.abs(o-h)<Math.abs(a-c)?[new q(a,1-l),new q(c,1-u),new q(f,1-p),new q(_,1-m)]:[new q(o,1-l),new q(h,1-u),new q(d,1-p),new q(g,1-m)]}};function RS(r,e,t){if(t.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){const s=r[n];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Do extends Ci{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Do(e.radius,e.detail)}}class Zs extends Ci{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Zs(e.radius,e.detail)}}class No extends Fe{constructor(e=.5,t=1,n=32,i=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:a},n=Math.max(3,n),i=Math.max(1,i);const o=[],l=[],c=[],h=[];let u=e;const f=(t-e)/i,d=new R,p=new q;for(let _=0;_<=i;_++){for(let g=0;g<=n;g++){const m=s+g/n*a;d.x=u*Math.cos(m),d.y=u*Math.sin(m),l.push(d.x,d.y,d.z),c.push(0,0,1),p.x=(d.x/t+1)/2,p.y=(d.y/t+1)/2,h.push(p.x,p.y)}u+=f}for(let _=0;_<i;_++){const g=_*(n+1);for(let m=0;m<n;m++){const y=m+g,x=y,v=y+n+1,M=y+n+2,w=y+1;o.push(x,v,w),o.push(v,M,w)}}this.setIndex(o),this.setAttribute("position",new ve(l,3)),this.setAttribute("normal",new ve(c,3)),this.setAttribute("uv",new ve(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new No(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Fo extends Fe{constructor(e=new ii([new q(0,.5),new q(-.5,-.5),new q(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let h=0;h<e.length;h++)c(e[h]),this.addGroup(o,l,h),o+=l,l=0;this.setIndex(n),this.setAttribute("position",new ve(i,3)),this.setAttribute("normal",new ve(s,3)),this.setAttribute("uv",new ve(a,2));function c(h){const u=i.length/3,f=h.extractPoints(t);let d=f.shape;const p=f.holes;un.isClockWise(d)===!1&&(d=d.reverse());for(let g=0,m=p.length;g<m;g++){const y=p[g];un.isClockWise(y)===!0&&(p[g]=y.reverse())}const _=un.triangulateShape(d,p);for(let g=0,m=p.length;g<m;g++){const y=p[g];d=d.concat(y)}for(let g=0,m=d.length;g<m;g++){const y=d[g];i.push(y.x,y.y,0),s.push(0,0,1),a.push(y.x,y.y)}for(let g=0,m=_.length;g<m;g++){const y=_[g],x=y[0]+u,v=y[1]+u,M=y[2]+u;n.push(x,v,M),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return CS(t,e)}static fromJSON(e,t){const n=[];for(let i=0,s=e.shapes.length;i<s;i++){const a=t[e.shapes[i]];n.push(a)}return new Fo(n,e.curveSegments)}}function CS(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,n=r.length;t<n;t++){const i=r[t];e.shapes.push(i.uuid)}else e.shapes.push(r.uuid);return e}class Js extends Fe{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const h=[],u=new R,f=new R,d=[],p=[],_=[],g=[];for(let m=0;m<=n;m++){const y=[],x=m/n;let v=0;m===0&&a===0?v=.5/t:m===n&&l===Math.PI&&(v=-.5/t);for(let M=0;M<=t;M++){const w=M/t;u.x=-e*Math.cos(i+w*s)*Math.sin(a+x*o),u.y=e*Math.cos(a+x*o),u.z=e*Math.sin(i+w*s)*Math.sin(a+x*o),p.push(u.x,u.y,u.z),f.copy(u).normalize(),_.push(f.x,f.y,f.z),g.push(w+v,1-x),y.push(c++)}h.push(y)}for(let m=0;m<n;m++)for(let y=0;y<t;y++){const x=h[m][y+1],v=h[m][y],M=h[m+1][y],w=h[m+1][y+1];(m!==0||a>0)&&d.push(x,v,w),(m!==n-1||l<Math.PI)&&d.push(v,M,w)}this.setIndex(d),this.setAttribute("position",new ve(p,3)),this.setAttribute("normal",new ve(_,3)),this.setAttribute("uv",new ve(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Js(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Oo extends Ci{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Oo(e.radius,e.detail)}}class Bo extends Fe{constructor(e=1,t=.4,n=12,i=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:s},n=Math.floor(n),i=Math.floor(i);const a=[],o=[],l=[],c=[],h=new R,u=new R,f=new R;for(let d=0;d<=n;d++)for(let p=0;p<=i;p++){const _=p/i*s,g=d/n*Math.PI*2;u.x=(e+t*Math.cos(g))*Math.cos(_),u.y=(e+t*Math.cos(g))*Math.sin(_),u.z=t*Math.sin(g),o.push(u.x,u.y,u.z),h.x=e*Math.cos(_),h.y=e*Math.sin(_),f.subVectors(u,h).normalize(),l.push(f.x,f.y,f.z),c.push(p/i),c.push(d/n)}for(let d=1;d<=n;d++)for(let p=1;p<=i;p++){const _=(i+1)*d+p-1,g=(i+1)*(d-1)+p-1,m=(i+1)*(d-1)+p,y=(i+1)*d+p;a.push(_,g,y),a.push(g,m,y)}this.setIndex(a),this.setAttribute("position",new ve(o,3)),this.setAttribute("normal",new ve(l,3)),this.setAttribute("uv",new ve(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Bo(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class zo extends Fe{constructor(e=1,t=.4,n=64,i=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:a},n=Math.floor(n),i=Math.floor(i);const o=[],l=[],c=[],h=[],u=new R,f=new R,d=new R,p=new R,_=new R,g=new R,m=new R;for(let x=0;x<=n;++x){const v=x/n*s*Math.PI*2;y(v,s,a,e,d),y(v+.01,s,a,e,p),g.subVectors(p,d),m.addVectors(p,d),_.crossVectors(g,m),m.crossVectors(_,g),_.normalize(),m.normalize();for(let M=0;M<=i;++M){const w=M/i*Math.PI*2,A=-t*Math.cos(w),C=t*Math.sin(w);u.x=d.x+(A*m.x+C*_.x),u.y=d.y+(A*m.y+C*_.y),u.z=d.z+(A*m.z+C*_.z),l.push(u.x,u.y,u.z),f.subVectors(u,d).normalize(),c.push(f.x,f.y,f.z),h.push(x/n),h.push(M/i)}}for(let x=1;x<=n;x++)for(let v=1;v<=i;v++){const M=(i+1)*(x-1)+(v-1),w=(i+1)*x+(v-1),A=(i+1)*x+v,C=(i+1)*(x-1)+v;o.push(M,w,C),o.push(w,A,C)}this.setIndex(o),this.setAttribute("position",new ve(l,3)),this.setAttribute("normal",new ve(c,3)),this.setAttribute("uv",new ve(h,2));function y(x,v,M,w,A){const C=Math.cos(x),S=Math.sin(x),b=M/v*x,L=Math.cos(b);A.x=w*(2+L)*.5*C,A.y=w*(2+L)*S*.5,A.z=w*Math.sin(b)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new zo(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class ko extends Fe{constructor(e=new Ah(new R(-1,-1,0),new R(-1,1,0),new R(1,1,0)),t=64,n=1,i=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new R,l=new R,c=new q;let h=new R;const u=[],f=[],d=[],p=[];_(),this.setIndex(p),this.setAttribute("position",new ve(u,3)),this.setAttribute("normal",new ve(f,3)),this.setAttribute("uv",new ve(d,2));function _(){for(let x=0;x<t;x++)g(x);g(s===!1?t:0),y(),m()}function g(x){h=e.getPointAt(x/t,h);const v=a.normals[x],M=a.binormals[x];for(let w=0;w<=i;w++){const A=w/i*Math.PI*2,C=Math.sin(A),S=-Math.cos(A);l.x=S*v.x+C*M.x,l.y=S*v.y+C*M.y,l.z=S*v.z+C*M.z,l.normalize(),f.push(l.x,l.y,l.z),o.x=h.x+n*l.x,o.y=h.y+n*l.y,o.z=h.z+n*l.z,u.push(o.x,o.y,o.z)}}function m(){for(let x=1;x<=t;x++)for(let v=1;v<=i;v++){const M=(i+1)*(x-1)+(v-1),w=(i+1)*x+(v-1),A=(i+1)*x+v,C=(i+1)*(x-1)+v;p.push(M,w,C),p.push(w,A,C)}}function y(){for(let x=0;x<=t;x++)for(let v=0;v<=i;v++)c.x=x/t,c.y=v/i,d.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new ko(new Rh[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Dp extends Fe{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new R,s=new R;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,h=l.length;c<h;++c){const u=l[c],f=u.start,d=u.count;for(let p=f,_=f+d;p<_;p+=3)for(let g=0;g<3;g++){const m=o.getX(p+g),y=o.getX(p+(g+1)%3);i.fromBufferAttribute(a,m),s.fromBufferAttribute(a,y),Np(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const h=3*o+c,u=3*o+(c+1)%3;i.fromBufferAttribute(a,h),s.fromBufferAttribute(a,u),Np(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new ve(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Np(r,e,t){const n=`${r.x},${r.y},${r.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${r.x},${r.y},${r.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}var Fp=Object.freeze({__proto__:null,BoxGeometry:Vi,CapsuleGeometry:wo,CircleGeometry:Eo,ConeGeometry:Ao,CylinderGeometry:Zr,DodecahedronGeometry:To,EdgesGeometry:Ap,ExtrudeGeometry:Up,IcosahedronGeometry:Do,LatheGeometry:Xs,OctahedronGeometry:Zs,PlaneGeometry:Ns,PolyhedronGeometry:Ci,RingGeometry:No,ShapeGeometry:Fo,SphereGeometry:Js,TetrahedronGeometry:Oo,TorusGeometry:Bo,TorusKnotGeometry:zo,TubeGeometry:ko,WireframeGeometry:Dp});class Op extends Ft{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ye(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Bp extends zn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ih extends Ft{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new ye(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vi,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class zp extends Ih{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new q(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ft(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ye(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new ye(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ye(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get 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.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 kp extends Ft{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ye(16777215),this.specular=new ye(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vi,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ps,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.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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 Gp extends Ft{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ye(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vi,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Hp extends Ft{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vi,this.normalScale=new q(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 Vp extends Ft{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ye(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vi,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ps,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.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 Wp extends Ft{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ye(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vi,this.normalScale=new q(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Xp extends Vt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function yn(r,e,t){return Uh(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)}function Zi(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function Uh(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function qp(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function Dh(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let l=0;l!==e;++l)i[a++]=r[o+l]}return i}function Nh(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=r[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=r[i++];while(s!==void 0)}function PS(r,e,t,n,i=30){const s=r.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],h=c.getValueSize(),u=[],f=[];for(let d=0;d<c.times.length;++d){const p=c.times[d]*i;if(!(p<t||p>=n)){u.push(c.times[d]);for(let _=0;_<h;++_)f.push(c.values[d*h+_])}}u.length!==0&&(c.times=Zi(u,c.times.constructor),c.values=Zi(f,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function LS(r,e=0,t=r,n=30){n<=0&&(n=30);const i=t.tracks.length,s=e/n;for(let a=0;a<i;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=r.tracks.find(function(m){return m.name===o.name&&m.ValueTypeName===l});if(c===void 0)continue;let h=0;const u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let f=0;const d=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);const p=o.times.length-1;let _;if(s<=o.times[0]){const m=h,y=u-h;_=yn(o.values,m,y)}else if(s>=o.times[p]){const m=p*u+h,y=m+u-h;_=yn(o.values,m,y)}else{const m=o.createInterpolant(),y=h,x=u-h;m.evaluate(s),_=yn(m.resultBuffer,y,x)}l==="quaternion"&&new Kt().fromArray(_).normalize().conjugate().toArray(_);const g=c.times.length;for(let m=0;m<g;++m){const y=m*d+f;if(l==="quaternion")Kt.multiplyQuaternionsFlat(c.values,y,_,0,c.values,y);else{const x=d-f*2;for(let v=0;v<x;++v)c.values[y+v]-=_[v]}}}return r.blendMode=Cc,r}const IS={arraySlice:yn,convertArray:Zi,isTypedArray:Uh,getKeyframeOrder:qp,sortedArray:Dh,flattenJSON:Nh,subclip:PS,makeClipAdditive:LS};class Ks{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];e:{t:{let a;n:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=i,i=t[++n],e<i)break t}a=t.length;break n}if(!(e>=s)){const o=t[1];e<o&&(n=2,s=o);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break t}a=n,n=0;break n}break e}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let a=0;a!==i;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class $p extends Ks{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Fi,endingEnd:Fi}}intervalChanged_(e,t,n){const i=this.parameterPositions;let s=e-2,a=e+1,o=i[s],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case Oi:s=e,o=2*t-n;break;case Ss:s=i.length-2,o=t+i[s]-i[s+1];break;default:s=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Oi:a=e,l=2*n-t;break;case Ss:a=1,l=n+i[1]-i[0];break;default:a=e-1,l=t}const c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,d=this._weightNext,p=(n-t)/(i-t),_=p*p,g=_*p,m=-f*g+2*f*_-f*p,y=(1+f)*g+(-1.5-2*f)*_+(-.5+f)*p+1,x=(-1-d)*g+(1.5+d)*_+.5*p,v=d*g-d*_;for(let M=0;M!==o;++M)s[M]=m*a[h+M]+y*a[c+M]+x*a[l+M]+v*a[u+M];return s}}class Fh extends Ks{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(n-t)/(i-t),u=1-h;for(let f=0;f!==o;++f)s[f]=a[c+f]*u+a[l+f]*h;return s}}class Yp extends Ks{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Pn{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Zi(t,this.TimeBufferType),this.values=Zi(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Zi(e.times,Array),values:Zi(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Yp(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Fh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new $p(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case vs:t=this.InterpolantFactoryMethodDiscrete;break;case Ms:t=this.InterpolantFactoryMethodLinear;break;case Pa:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return vs;case this.InterpolantFactoryMethodLinear:return Ms;case this.InterpolantFactoryMethodSmooth:return Pa}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let s=0,a=i-1;for(;s!==i&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=yn(n,s,a),this.values=yn(this.values,s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&Uh(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=yn(this.times),t=yn(this.values),n=this.getValueSize(),i=this.getInterpolation()===Pa,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(i)l=!0;else{const u=o*n,f=u-n,d=u+n;for(let p=0;p!==n;++p){const _=t[u+p];if(_!==t[f+p]||_!==t[d+p]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const u=o*n,f=a*n;for(let d=0;d!==n;++d)t[f+d]=t[u+d]}++a}}if(s>0){e[a]=e[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=yn(e,0,a),this.values=yn(t,0,a*n)):(this.times=e,this.values=t),this}clone(){const e=yn(this.times,0),t=yn(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Pn.prototype.TimeBufferType=Float32Array,Pn.prototype.ValueBufferType=Float32Array,Pn.prototype.DefaultInterpolation=Ms;class Ji extends Pn{}Ji.prototype.ValueTypeName="bool",Ji.prototype.ValueBufferType=Array,Ji.prototype.DefaultInterpolation=vs,Ji.prototype.InterpolantFactoryMethodLinear=void 0,Ji.prototype.InterpolantFactoryMethodSmooth=void 0;class Oh extends Pn{}Oh.prototype.ValueTypeName="color";class js extends Pn{}js.prototype.ValueTypeName="number";class Zp extends Ks{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let h=c+o;c!==h;c+=4)Kt.slerpFlat(s,0,a,c-o,a,c,l);return s}}class Kr extends Pn{InterpolantFactoryMethodLinear(e){return new Zp(this.times,this.values,this.getValueSize(),e)}}Kr.prototype.ValueTypeName="quaternion",Kr.prototype.DefaultInterpolation=Ms,Kr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ki extends Pn{}Ki.prototype.ValueTypeName="string",Ki.prototype.ValueBufferType=Array,Ki.prototype.DefaultInterpolation=vs,Ki.prototype.InterpolantFactoryMethodLinear=void 0,Ki.prototype.InterpolantFactoryMethodSmooth=void 0;class Qs extends Pn{}Qs.prototype.ValueTypeName="vector";class ea{constructor(e,t=-1,n,i=La){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=on(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(DS(n[a]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(Pn.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const h=qp(l);l=Dh(l,1,h),c=Dh(c,1,h),!i&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new js(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c.name.match(s);if(h&&h.length>1){const u=h[1];let f=i[u];f||(i[u]=f=[]),f.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,f,d,p,_){if(d.length!==0){const g=[],m=[];Nh(d,g,m,p),g.length!==0&&_.push(new u(f,g,m))}},i=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u<c.length;u++){const f=c[u].keys;if(!(!f||f.length===0))if(f[0].morphTargets){const d={};let p;for(p=0;p<f.length;p++)if(f[p].morphTargets)for(let _=0;_<f[p].morphTargets.length;_++)d[f[p].morphTargets[_]]=-1;for(const _ in d){const g=[],m=[];for(let y=0;y!==f[p].morphTargets.length;++y){const x=f[p];g.push(x.time),m.push(x.morphTarget===_?1:0)}i.push(new js(".morphTargetInfluence["+_+"]",g,m))}l=d.length*a}else{const d=".bones["+t[u].name+"]";n(Qs,d+".position",f,"pos",i),n(Kr,d+".quaternion",f,"rot",i),n(Qs,d+".scale",f,"scl",i)}}return i.length===0?null:new this(s,l,i,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function US(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return js;case"vector":case"vector2":case"vector3":case"vector4":return Qs;case"color":return Oh;case"quaternion":return Kr;case"bool":case"boolean":return Ji;case"string":return Ki}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function DS(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=US(r.type);if(r.times===void 0){const t=[],n=[];Nh(r.keys,t,n,"value"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const ji={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class Bh{constructor(e,t,n){const i=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){o++,s===!1&&i.onStart!==void 0&&i.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,f=c.length;u<f;u+=2){const d=c[u],p=c[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}}const Jp=new Bh;class en{constructor(e){this.manager=e!==void 0?e:Jp,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}en.DEFAULT_MATERIAL_NAME="__DEFAULT";const ri={};class NS extends Error{constructor(e,t){super(e),this.response=t}}class si extends en{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=ji.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ri[e]!==void 0){ri[e].push({onLoad:t,onProgress:n,onError:i});return}ri[e]=[],ri[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||c.body===void 0||c.body.getReader===void 0)return c;const h=ri[e],u=c.body.getReader(),f=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),d=f?parseInt(f):0,p=d!==0;let _=0;const g=new ReadableStream({start(m){y();function y(){u.read().then(({done:x,value:v})=>{if(x)m.close();else{_+=v.byteLength;const M=new ProgressEvent("progress",{lengthComputable:p,loaded:_,total:d});for(let w=0,A=h.length;w<A;w++){const C=h[w];C.onProgress&&C.onProgress(M)}m.enqueue(v),y()}})}}});return new Response(g)}else throw new NS(`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===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),f=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(f);return c.arrayBuffer().then(p=>d.decode(p))}}}).then(c=>{ji.add(e,c);const h=ri[e];delete ri[e];for(let u=0,f=h.length;u<f;u++){const d=h[u];d.onLoad&&d.onLoad(c)}}).catch(c=>{const h=ri[e];if(h===void 0)throw this.manager.itemError(e),c;delete ri[e];for(let u=0,f=h.length;u<f;u++){const d=h[u];d.onError&&d.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class FS extends en{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new si(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n<e.length;n++){const i=ea.parse(e[n]);t.push(i)}return t}}class OS extends en{constructor(e){super(e)}load(e,t,n,i){const s=this,a=[],o=new yh,l=new si(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function h(u){l.load(e[u],function(f){const d=s.parse(f,!0);a[u]={width:d.width,height:d.height,format:d.format,mipmaps:d.mipmaps},c+=1,c===6&&(d.mipmapCount===1&&(o.minFilter=vt),o.image=a,o.format=d.format,o.needsUpdate=!0,t&&t(o))},n,i)}if(Array.isArray(e))for(let u=0,f=e.length;u<f;++u)h(u);else l.load(e,function(u){const f=s.parse(u,!0);if(f.isCubemap){const d=f.mipmaps.length/f.mipmapCount;for(let p=0;p<d;p++){a[p]={mipmaps:[]};for(let _=0;_<f.mipmapCount;_++)a[p].mipmaps.push(f.mipmaps[p*f.mipmapCount+_]),a[p].format=f.format,a[p].width=f.width,a[p].height=f.height}o.image=a}else o.image.width=f.width,o.image.height=f.height,o.mipmaps=f.mipmaps;f.mipmapCount===1&&(o.minFilter=vt),o.format=f.format,o.needsUpdate=!0,t&&t(o)},n,i);return o}}class ta extends en{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=ji.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=As("img");function l(){h(),ji.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(u){h(),i&&i(u),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class BS extends en{constructor(e){super(e)}load(e,t,n,i){const s=new Ds;s.colorSpace=Ge;const a=new ta(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(h){s.images[c]=h,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,i)}for(let c=0;c<e.length;++c)l(c);return s}}class zS extends en{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new qr,o=new si(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){const c=s.parse(l);c&&(c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:Dt,a.wrapT=c.wrapT!==void 0?c.wrapT:Dt,a.magFilter=c.magFilter!==void 0?c.magFilter:vt,a.minFilter=c.minFilter!==void 0?c.minFilter:vt,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0?a.colorSpace=c.colorSpace:c.encoding!==void 0&&(a.encoding=c.encoding),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=gi),c.mipmapCount===1&&(a.minFilter=vt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c))},n,i),a}}class kS extends en{constructor(e){super(e)}load(e,t,n,i){const s=new Mt,a=new ta(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class Pi extends tt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ye(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}class Kp extends Pi{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(tt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ye(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const zh=new Be,jp=new R,Qp=new R;class kh{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new q(512,512),this.map=null,this.mapPass=null,this.matrix=new Be,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new no,this._frameExtents=new q(1,1),this._viewportCount=1,this._viewports=[new rt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;jp.setFromMatrixPosition(e.matrixWorld),t.position.copy(jp),Qp.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Qp),t.updateMatrixWorld(),zh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(zh),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(zh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class GS extends kh{constructor(){super(new Ut(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=_r*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class em extends Pi{constructor(e,t,n=0,i=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(tt.DEFAULT_UP),this.updateMatrix(),this.target=new tt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new GS}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const tm=new Be,na=new R,Gh=new R;class HS extends kh{constructor(){super(new Ut(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new q(4,2),this._viewportCount=6,this._viewports=[new rt(2,1,1,1),new rt(0,1,1,1),new rt(3,1,1,1),new rt(1,1,1,1),new rt(3,0,1,1),new rt(1,0,1,1)],this._cubeDirections=[new R(1,0,0),new R(-1,0,0),new R(0,0,1),new R(0,0,-1),new R(0,1,0),new R(0,-1,0)],this._cubeUps=[new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,1,0),new R(0,0,1),new R(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),na.setFromMatrixPosition(e.matrixWorld),n.position.copy(na),Gh.copy(n.position),Gh.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Gh),n.updateMatrixWorld(),i.makeTranslation(-na.x,-na.y,-na.z),tm.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tm)}}class nm extends Pi{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new HS}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class VS extends kh{constructor(){super(new ro(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class im extends Pi{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(tt.DEFAULT_UP),this.updateMatrix(),this.target=new tt,this.shadow=new VS}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class rm extends Pi{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class sm extends Pi{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class am{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new R)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*i),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*i)),t.addScaledVector(a[5],1.092548*(i*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(n*s)),t.addScaledVector(a[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*i),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*i),t.addScaledVector(a[5],2*.429043*i*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*n*s),t.addScaledVector(a[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+i*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+i*3);return e}static getBasisAt(e,t){const n=e.x,i=e.y,s=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-i*i)}}class Go extends Pi{constructor(e=new am,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Ho extends en{constructor(e){super(e),this.textures={}}load(e,t,n,i){const s=this,a=new si(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t=this.textures;function n(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const i=Ho.createMaterialFromType(e.type);if(e.uuid!==void 0&&(i.uuid=e.uuid),e.name!==void 0&&(i.name=e.name),e.color!==void 0&&i.color!==void 0&&i.color.setHex(e.color),e.roughness!==void 0&&(i.roughness=e.roughness),e.metalness!==void 0&&(i.metalness=e.metalness),e.sheen!==void 0&&(i.sheen=e.sheen),e.sheenColor!==void 0&&(i.sheenColor=new ye().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(i.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(e.emissive),e.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(e.specular),e.specularIntensity!==void 0&&(i.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(i.shininess=e.shininess),e.clearcoat!==void 0&&(i.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=e.clearcoatRoughness),e.iridescence!==void 0&&(i.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(i.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(i.transmission=e.transmission),e.thickness!==void 0&&(i.thickness=e.thickness),e.attenuationDistance!==void 0&&(i.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(i.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(i.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(i.fog=e.fog),e.flatShading!==void 0&&(i.flatShading=e.flatShading),e.blending!==void 0&&(i.blending=e.blending),e.combine!==void 0&&(i.combine=e.combine),e.side!==void 0&&(i.side=e.side),e.shadowSide!==void 0&&(i.shadowSide=e.shadowSide),e.opacity!==void 0&&(i.opacity=e.opacity),e.transparent!==void 0&&(i.transparent=e.transparent),e.alphaTest!==void 0&&(i.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(i.alphaHash=e.alphaHash),e.depthTest!==void 0&&(i.depthTest=e.depthTest),e.depthWrite!==void 0&&(i.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(i.colorWrite=e.colorWrite),e.stencilWrite!==void 0&&(i.stencilWrite=e.stencilWrite),e.stencilWriteMask!==void 0&&(i.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(i.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(i.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(i.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(i.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(i.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(i.stencilZPass=e.stencilZPass),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(i.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(i.rotation=e.rotation),e.linewidth!==1&&(i.linewidth=e.linewidth),e.dashSize!==void 0&&(i.dashSize=e.dashSize),e.gapSize!==void 0&&(i.gapSize=e.gapSize),e.scale!==void 0&&(i.scale=e.scale),e.polygonOffset!==void 0&&(i.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(i.dithering=e.dithering),e.alphaToCoverage!==void 0&&(i.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(i.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(i.visible=e.visible),e.toneMapped!==void 0&&(i.toneMapped=e.toneMapped),e.userData!==void 0&&(i.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(i.uniforms[s]={},a.type){case"t":i.uniforms[s].value=n(a.value);break;case"c":i.uniforms[s].value=new ye().setHex(a.value);break;case"v2":i.uniforms[s].value=new q().fromArray(a.value);break;case"v3":i.uniforms[s].value=new R().fromArray(a.value);break;case"v4":i.uniforms[s].value=new rt().fromArray(a.value);break;case"m3":i.uniforms[s].value=new Xe().fromArray(a.value);break;case"m4":i.uniforms[s].value=new Be().fromArray(a.value);break;default:i.uniforms[s].value=a.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(i.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)i.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(i.lights=e.lights),e.clipping!==void 0&&(i.clipping=e.clipping),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new q().fromArray(s)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new q().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(i.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:Op,SpriteMaterial:uh,RawShaderMaterial:Bp,ShaderMaterial:zn,PointsMaterial:_h,MeshPhysicalMaterial:zp,MeshStandardMaterial:Ih,MeshPhongMaterial:kp,MeshToonMaterial:Gp,MeshNormalMaterial:Hp,MeshLambertMaterial:Vp,MeshDepthMaterial:lh,MeshDistanceMaterial:ch,MeshBasicMaterial:Ai,MeshMatcapMaterial:Wp,LineDashedMaterial:Xp,LineBasicMaterial:Vt,Material:Ft};return new t[e]}}class Hh{static decodeText(e){if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch(n){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class om extends Fe{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class lm extends en{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new si(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t={},n={};function i(d,p){if(t[p]!==void 0)return t[p];const g=d.interleavedBuffers[p],m=s(d,g.buffer),y=xr(g.type,m),x=new ho(y,g.stride);return x.uuid=g.uuid,t[p]=x,x}function s(d,p){if(n[p]!==void 0)return n[p];const g=d.arrayBuffers[p],m=new Uint32Array(g).buffer;return n[p]=m,m}const a=e.isInstancedBufferGeometry?new om:new Fe,o=e.data.index;if(o!==void 0){const d=xr(o.type,o.array);a.setIndex(new Ze(d,1))}const l=e.data.attributes;for(const d in l){const p=l[d];let _;if(p.isInterleavedBufferAttribute){const g=i(e.data,p.data);_=new $i(g,p.itemSize,p.offset,p.normalized)}else{const g=xr(p.type,p.array),m=p.isInstancedBufferAttribute?$r:Ze;_=new m(g,p.itemSize,p.normalized)}p.name!==void 0&&(_.name=p.name),p.usage!==void 0&&_.setUsage(p.usage),p.updateRange!==void 0&&(_.updateRange.offset=p.updateRange.offset,_.updateRange.count=p.updateRange.count),a.setAttribute(d,_)}const c=e.data.morphAttributes;if(c)for(const d in c){const p=c[d],_=[];for(let g=0,m=p.length;g<m;g++){const y=p[g];let x;if(y.isInterleavedBufferAttribute){const v=i(e.data,y.data);x=new $i(v,y.itemSize,y.offset,y.normalized)}else{const v=xr(y.type,y.array);x=new Ze(v,y.itemSize,y.normalized)}y.name!==void 0&&(x.name=y.name),_.push(x)}a.morphAttributes[d]=_}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let d=0,p=u.length;d!==p;++d){const _=u[d];a.addGroup(_.start,_.count,_.materialIndex)}const f=e.data.boundingSphere;if(f!==void 0){const d=new R;f.center!==void 0&&d.fromArray(f.center),a.boundingSphere=new wn(d,f.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class WS extends en{constructor(e){super(e)}load(e,t,n,i){const s=this,a=this.path===""?Hh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new si(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(u){i!==void 0&&i(u),console.error("THREE:ObjectLoader: Can't parse "+e+".",u.message);return}const h=c.metadata;if(h===void 0||h.type===void 0||h.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},n,i)}loadAsync(e,t){return fs(this,null,function*(){const n=this,i=this.path===""?Hh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;const s=new si(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=yield s.loadAsync(e,t),o=JSON.parse(a),l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return yield n.parseAsync(o)})}parse(e,t){const n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,i),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,n),h=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,h),t!==void 0){let u=!1;for(const f in a)if(a[f].data instanceof HTMLImageElement){u=!0;break}u===!1&&t(c)}return c}parseAsync(e){return fs(this,null,function*(){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),s=yield this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,i,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),l})}parseShapes(e){const t={};if(e!==void 0)for(let n=0,i=e.length;n<i;n++){const s=new ii().fromJSON(e[n]);t[s.uuid]=s}return t}parseSkeletons(e,t){const n={},i={};if(t.traverse(function(s){s.isBone&&(i[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=new go().fromJSON(e[s],i);n[o.uuid]=o}return n}parseGeometries(e,t){const n={};if(e!==void 0){const i=new lm;for(let s=0,a=e.length;s<a;s++){let o;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=i.parse(l);break;default:l.type in Fp?o=Fp[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),n[l.uuid]=o}}return n}parseMaterials(e,t){const n={},i={};if(e!==void 0){const s=new Ho;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];n[l.uuid]===void 0&&(n[l.uuid]=s.parse(l)),i[l.uuid]=n[l.uuid]}}return i}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const i=e[n],s=ea.parse(i);t[s.uuid]=s}return t}parseImages(e,t){const n=this,i={};let s;function a(l){return n.manager.itemStart(l),s.load(l,function(){n.manager.itemEnd(l)},void 0,function(){n.manager.itemError(l),n.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const c=l,h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:n.resourcePath+c;return a(h)}else return l.data?{data:xr(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new Bh(t);s=new ta(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,h=e.length;c<h;c++){const u=e[c],f=u.url;if(Array.isArray(f)){const d=[];for(let p=0,_=f.length;p<_;p++){const g=f[p],m=o(g);m!==null&&(m instanceof HTMLImageElement?d.push(m):d.push(new qr(m.data,m.width,m.height)))}i[u.uuid]=new zi(d)}else{const d=o(u.url);i[u.uuid]=new zi(d)}}}return i}parseImagesAsync(e){return fs(this,null,function*(){const t=this,n={};let i;function s(a){return fs(this,null,function*(){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return yield i.loadAsync(l)}else return a.data?{data:xr(a.type,a.data),width:a.width,height:a.height}:null})}if(e!==void 0&&e.length>0){i=new ta(this.manager),i.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],c=l.url;if(Array.isArray(c)){const h=[];for(let u=0,f=c.length;u<f;u++){const d=c[u],p=yield s(d);p!==null&&(p instanceof HTMLImageElement?h.push(p):h.push(new qr(p.data,p.width,p.height)))}n[l.uuid]=new zi(h)}else{const h=yield s(l.url);n[l.uuid]=new zi(h)}}}return n})}parseTextures(e,t){function n(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const i={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=e[s];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const l=t[o.image],c=l.data;let h;Array.isArray(c)?(h=new Ds,c.length===6&&(h.needsUpdate=!0)):(c&&c.data?h=new qr:h=new Mt,c&&(h.needsUpdate=!0)),h.source=l,h.uuid=o.uuid,o.name!==void 0&&(h.name=o.name),o.mapping!==void 0&&(h.mapping=n(o.mapping,XS)),o.channel!==void 0&&(h.channel=o.channel),o.offset!==void 0&&h.offset.fromArray(o.offset),o.repeat!==void 0&&h.repeat.fromArray(o.repeat),o.center!==void 0&&h.center.fromArray(o.center),o.rotation!==void 0&&(h.rotation=o.rotation),o.wrap!==void 0&&(h.wrapS=n(o.wrap[0],cm),h.wrapT=n(o.wrap[1],cm)),o.format!==void 0&&(h.format=o.format),o.internalFormat!==void 0&&(h.internalFormat=o.internalFormat),o.type!==void 0&&(h.type=o.type),o.colorSpace!==void 0&&(h.colorSpace=o.colorSpace),o.encoding!==void 0&&(h.encoding=o.encoding),o.minFilter!==void 0&&(h.minFilter=n(o.minFilter,hm)),o.magFilter!==void 0&&(h.magFilter=n(o.magFilter,hm)),o.anisotropy!==void 0&&(h.anisotropy=o.anisotropy),o.flipY!==void 0&&(h.flipY=o.flipY),o.generateMipmaps!==void 0&&(h.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(h.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(h.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(h.compareFunction=o.compareFunction),o.userData!==void 0&&(h.userData=o.userData),i[o.uuid]=h}return i}parseObject(e,t,n,i,s){let a;function o(f){return t[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",f),t[f]}function l(f){if(f!==void 0){if(Array.isArray(f)){const d=[];for(let p=0,_=f.length;p<_;p++){const g=f[p];n[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),d.push(n[g])}return d}return n[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),n[f]}}function c(f){return i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",f),i[f]}let h,u;switch(e.type){case"Scene":a=new Yd,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new ye(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new co(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new lo(e.fog.color,e.fog.density))),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity);break;case"PerspectiveCamera":a=new Ut(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new ro(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new rm(e.color,e.intensity);break;case"DirectionalLight":a=new im(e.color,e.intensity);break;case"PointLight":a=new nm(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new sm(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new em(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":a=new Kp(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new Go().fromJSON(e);break;case"SkinnedMesh":h=o(e.geometry),u=l(e.material),a=new ap(h,u),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":h=o(e.geometry),u=l(e.material),a=new It(h,u);break;case"InstancedMesh":h=o(e.geometry),u=l(e.material);const f=e.count,d=e.instanceMatrix,p=e.instanceColor;a=new hp(h,u,f),a.instanceMatrix=new $r(new Float32Array(d.array),16),p!==void 0&&(a.instanceColor=new $r(new Float32Array(p.array),p.itemSize));break;case"LOD":a=new ep;break;case"Line":a=new Ri(o(e.geometry),l(e.material));break;case"LineLoop":a=new gp(o(e.geometry),l(e.material));break;case"LineSegments":a=new kn(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new xp(o(e.geometry),l(e.material));break;case"Sprite":a=new jd(l(e.material));break;case"Group":a=new kr;break;case"Bone":a=new mh;break;default:a=new tt}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const f=e.children;for(let d=0;d<f.length;d++)a.add(this.parseObject(f[d],t,n,i,s))}if(e.animations!==void 0){const f=e.animations;for(let d=0;d<f.length;d++){const p=f[d];a.animations.push(s[p])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const f=e.levels;for(let d=0;d<f.length;d++){const p=f[d],_=a.getObjectByProperty("uuid",p.object);_!==void 0&&a.addLevel(_,p.distance,p.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const i=t[n.skeleton];i===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}}const XS={UVMapping:Sa,CubeReflectionMapping:pi,CubeRefractionMapping:mi,EquirectangularReflectionMapping:ms,EquirectangularRefractionMapping:gs,CubeUVReflectionMapping:mr},cm={RepeatWrapping:_s,ClampToEdgeWrapping:Dt,MirroredRepeatWrapping:xs},hm={NearestFilter:yt,NearestMipmapNearestFilter:ba,NearestMipmapLinearFilter:ys,LinearFilter:vt,LinearMipmapNearestFilter:Ql,LinearMipmapLinearFilter:gi};class qS extends en{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap=="undefined"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=ji.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){ji.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){i&&i(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}let Vo;class Vh{static getContext(){return Vo===void 0&&(Vo=new(window.AudioContext||window.webkitAudioContext)),Vo}static setContext(e){Vo=e}}class $S extends en{constructor(e){super(e)}load(e,t,n,i){const s=this,a=new si(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);Vh.getContext().decodeAudioData(c,function(u){t(u)},o)}catch(c){o(c)}},n,i);function o(l){i?i(l):console.error(l),s.manager.itemError(e)}}}class YS extends Go{constructor(e,t,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;const i=new ye().set(e),s=new ye().set(t),a=new R(i.r,i.g,i.b),o=new R(s.r,s.g,s.b),l=Math.sqrt(Math.PI),c=l*Math.sqrt(.75);this.sh.coefficients[0].copy(a).add(o).multiplyScalar(l),this.sh.coefficients[1].copy(a).sub(o).multiplyScalar(c)}}class ZS extends Go{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const n=new ye().set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const um=new Be,fm=new Be,Qi=new Be;class JS{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Ut,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Ut,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Qi.copy(e.projectionMatrix);const i=t.eyeSep/2,s=i*t.near/t.focus,a=t.near*Math.tan(Bi*t.fov*.5)/t.zoom;let o,l;fm.elements[12]=-i,um.elements[12]=i,o=-a*t.aspect+s,l=a*t.aspect+s,Qi.elements[0]=2*t.near/(l-o),Qi.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(Qi),o=-a*t.aspect-s,l=a*t.aspect-s,Qi.elements[0]=2*t.near/(l-o),Qi.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(Qi)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(fm),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(um)}}class dm{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=pm(),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=pm();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function pm(){return(typeof performance=="undefined"?Date:performance).now()}const er=new R,mm=new Kt,KS=new R,tr=new R;class jS extends tt{constructor(){super(),this.type="AudioListener",this.context=Vh.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new dm}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(er,mm,KS),tr.set(0,0,-1).applyQuaternion(mm),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(er.x,i),t.positionY.linearRampToValueAtTime(er.y,i),t.positionZ.linearRampToValueAtTime(er.z,i),t.forwardX.linearRampToValueAtTime(tr.x,i),t.forwardY.linearRampToValueAtTime(tr.y,i),t.forwardZ.linearRampToValueAtTime(tr.z,i),t.upX.linearRampToValueAtTime(n.x,i),t.upY.linearRampToValueAtTime(n.y,i),t.upZ.linearRampToValueAtTime(n.z,i)}else t.setPosition(er.x,er.y,er.z),t.setOrientation(tr.x,tr.y,tr.z,n.x,n.y,n.z)}}class gm extends tt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const nr=new R,_m=new Kt,QS=new R,ir=new R;class eb extends gm{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(nr,_m,QS),ir.set(0,0,1).applyQuaternion(_m);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(nr.x,n),t.positionY.linearRampToValueAtTime(nr.y,n),t.positionZ.linearRampToValueAtTime(nr.z,n),t.orientationX.linearRampToValueAtTime(ir.x,n),t.orientationY.linearRampToValueAtTime(ir.y,n),t.orientationZ.linearRampToValueAtTime(ir.z,n)}else t.setPosition(nr.x,nr.y,nr.z),t.setOrientation(ir.x,ir.y,ir.z)}}class tb{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class xm{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,s,a;switch(t){case"quaternion":i=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,s=e*i+i;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==i;++o)n[s+o]=n[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(n,s,0,o,i)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(n,i,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,a=i;s!==a;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,s){if(i>=.5)for(let a=0;a!==s;++a)e[t+a]=e[n+a]}_slerp(e,t,n,i){Kt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){const a=this._workIndex*s;Kt.multiplyQuaternionsFlat(e,a,e,t,e,n),Kt.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,s){const a=1-i;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[n+o]*i}}_lerpAdditive(e,t,n,i,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[n+a]*i}}}const Wh="\\[\\]\\.:\\/",nb=new RegExp("["+Wh+"]","g"),Xh="[^"+Wh+"]",ib="[^"+Wh.replace("\\.","")+"]",rb=/((?:WC+[\/:])*)/.source.replace("WC",Xh),sb=/(WCOD+)?/.source.replace("WCOD",ib),ab=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Xh),ob=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Xh),lb=new RegExp("^"+rb+sb+ab+ob+"$"),cb=["material","materials","bones","map"];class hb{constructor(e,t,n){const i=n||et.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class et{constructor(e,t,n){this.path=t,this.parsedPath=n||et.parseTrackName(t),this.node=et.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new et.Composite(e,t,n):new et(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(nb,"")}static parseTrackName(e){const t=lb.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);cb.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let s=t.propertyIndex;if(e||(e=et.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[i];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}et.Composite=hb,et.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},et.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},et.prototype.GetterByBindingType=[et.prototype._getValue_direct,et.prototype._getValue_array,et.prototype._getValue_arrayElement,et.prototype._getValue_toArray],et.prototype.SetterByBindingTypeAndVersioning=[[et.prototype._setValue_direct,et.prototype._setValue_direct_setNeedsUpdate,et.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[et.prototype._setValue_array,et.prototype._setValue_array_setNeedsUpdate,et.prototype._setValue_array_setMatrixWorldNeedsUpdate],[et.prototype._setValue_arrayElement,et.prototype._setValue_arrayElement_setNeedsUpdate,et.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[et.prototype._setValue_fromArray,et.prototype._setValue_fromArray_setNeedsUpdate,et.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ub{constructor(){this.isAnimationObjectGroup=!0,this.uuid=on(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,i=arguments.length;n!==i;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,s=this._bindings,a=s.length;let o,l=e.length,c=this.nCachedObjects_;for(let h=0,u=arguments.length;h!==u;++h){const f=arguments[h],d=f.uuid;let p=t[d];if(p===void 0){p=l++,t[d]=p,e.push(f);for(let _=0,g=a;_!==g;++_)s[_].push(new et(f,n[_],i[_]))}else if(p<c){o=e[p];const _=--c,g=e[_];t[g.uuid]=p,e[p]=g,t[d]=_,e[_]=f;for(let m=0,y=a;m!==y;++m){const x=s[m],v=x[_];let M=x[p];x[p]=v,M===void 0&&(M=new et(f,n[m],i[m])),x[_]=M}}else e[p]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,h=t[c];if(h!==void 0&&h>=s){const u=s++,f=e[u];t[f.uuid]=h,e[h]=f,t[c]=u,e[u]=l;for(let d=0,p=i;d!==p;++d){const _=n[d],g=_[u],m=_[h];_[h]=g,_[u]=m}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],h=c.uuid,u=t[h];if(u!==void 0)if(delete t[h],u<s){const f=--s,d=e[f],p=--a,_=e[p];t[d.uuid]=u,e[u]=d,t[_.uuid]=f,e[f]=_,e.pop();for(let g=0,m=i;g!==m;++g){const y=n[g],x=y[f],v=y[p];y[u]=x,y[f]=v,y.pop()}}else{const f=--a,d=e[f];f>0&&(t[d.uuid]=u),e[u]=d,e.pop();for(let p=0,_=i;p!==_;++p){const g=n[p];g[u]=g[f],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const s=this._bindings;if(i!==void 0)return s[i];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,u=new Array(c);i=s.length,n[e]=i,a.push(e),o.push(t),s.push(u);for(let f=h,d=l.length;f!==d;++f){const p=l[f];u[f]=new et(p,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=n,a[n]=l,a.pop(),s[n]=s[o],s.pop(),i[n]=i[o],i.pop()}}}class ym{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:Fi,endingEnd:Fi};for(let c=0;c!==a;++c){const h=s[c].createInterpolant(null);o[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Df,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,s=e._clip.duration,a=s/i,o=i/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,s=i.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+n,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Cc:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case La:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,s=this._loopCount;const a=n===Nf;if(e===0)return s===-1?i:a&&(s&1)===1?t-i:i;if(n===Uf){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),i>=t||i<0){const o=Math.floor(i/t);i-=t*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(a&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=Oi,i.endingEnd=Oi):(e?i.endingStart=this.zeroSlopeAtStart?Oi:Fi:i.endingStart=Ss,t?i.endingEnd=this.zeroSlopeAtEnd?Oi:Fi:i.endingEnd=Ss)}_scheduleFading(e,t,n){const i=this._mixer,s=i.time;let a=this._weightInterpolant;a===null&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=n,this}}const fb=new Float32Array(1);class db extends Zn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,a=e._propertyBindings,o=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==s;++u){const f=i[u],d=f.name;let p=h[d];if(p!==void 0)++p.referenceCount,a[u]=p;else{if(p=a[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,d));continue}const _=t&&t._propertyBindings[u].binding.parsedPath;p=new xm(et.create(n,d,_),f.ValueTypeName,f.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,d),a[u]=p}o[u].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],h=e._byClipCacheIndex;c._byClipCacheIndex=h,l[h]=c,l.pop(),e._byClipCacheIndex=null;const u=o.actionByRoot,f=(e._localRoot||this._root).uuid;delete u[f],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,s=this._bindings;let a=i[t];a===void 0&&(a={},i[t]=a),a[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,s=n.path,a=this._bindingsByRootAndName,o=a[i],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new Fh(new Float32Array(2),new Float32Array(2),1,fb),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,s=t[i];e.__cacheIndex=i,t[i]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){const i=t||this._root,s=i.uuid;let a=typeof e=="string"?ea.findByName(i,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let c=null;if(n===void 0&&(a!==null?n=a.blendMode:n=La),l!==void 0){const u=l.actionByRoot[s];if(u!==void 0&&u.blendMode===n)return u;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const h=new ym(this,a,t,n);return this._bindAction(h,c),this._addInactiveAction(h,o,s),h}existingAction(e,t){const n=t||this._root,i=n.uuid,s=typeof e=="string"?ea.findByName(n,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[i]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,s=i[n];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const h=c._cacheIndex,u=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const a in n){const o=n[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const i=this._bindingsByRootAndName,s=i[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class qh{constructor(e){this.value=e}clone(){return new qh(this.value.clone===void 0?this.value:this.value.clone())}}let pb=0;class mb extends Zn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:pb++}),this.name="",this.usage=bs,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,i=t.length;n<i;n++)this.uniforms.push(t[n].clone());return this}clone(){return new this.constructor().copy(this)}}class gb extends ho{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class _b{constructor(e,t,n,i,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}class xb{constructor(e,t,n=0,i=1/0){this.ray=new Er(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Ga,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return $h(e,this,n,t),n.sort(vm),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)$h(e[i],this,n,t);return n.sort(vm),n}}function vm(r,e){return r.distance-e.distance}function $h(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){const i=r.children;for(let s=0,a=i.length;s<a;s++)$h(i[s],e,t,!0)}}class yb{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(ft(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class vb{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}const Mm=new q;class Mb{constructor(e=new q(1/0,1/0),t=new q(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Mm.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}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}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))}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)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Mm).distanceTo(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}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)}}const Sm=new R,Wo=new R;class Sb{constructor(e=new R,t=new R){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Sm.subVectors(e,this.start),Wo.subVectors(this.end,this.start);const n=Wo.dot(Wo);let s=Wo.dot(Sm)/n;return t&&(s=ft(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const bm=new R;class bb extends tt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Fe,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a<l;a++,o++){const c=a/l*Math.PI*2,h=o/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(h),Math.sin(h),1)}n.setAttribute("position",new ve(i,3));const s=new Vt({fog:!1,toneMapped:!1});this.cone=new kn(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),bm.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(bm),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Li=new R,Xo=new Be,Yh=new Be;class wb extends kn{constructor(e){const t=wm(e),n=new Fe,i=[],s=[],a=new ye(0,0,1),o=new ye(0,1,0);for(let c=0;c<t.length;c++){const h=t[c];h.parent&&h.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}n.setAttribute("position",new ve(i,3)),n.setAttribute("color",new ve(s,3));const l=new Vt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");Yh.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(Xo.multiplyMatrices(Yh,o.matrixWorld),Li.setFromMatrixPosition(Xo),i.setXYZ(a,Li.x,Li.y,Li.z),Xo.multiplyMatrices(Yh,o.parent.matrixWorld),Li.setFromMatrixPosition(Xo),i.setXYZ(a+1,Li.x,Li.y,Li.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function wm(r){const e=[];r.isBone===!0&&e.push(r);for(let t=0;t<r.children.length;t++)e.push.apply(e,wm(r.children[t]));return e}class Eb extends It{constructor(e,t,n){const i=new Js(t,4,2),s=new Ai({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const Ab=new R,Em=new ye,Am=new ye;class Tb extends tt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new Zs(t);i.rotateY(Math.PI*.5),this.material=new Ai({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=i.getAttribute("position"),a=new Float32Array(s.count*3);i.setAttribute("color",new Ze(a,3)),this.add(new It(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Em.copy(this.light.color),Am.copy(this.light.groundColor);for(let n=0,i=t.count;n<i;n++){const s=n<i/2?Em:Am;t.setXYZ(n,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(Ab.setFromMatrixPosition(this.light.matrixWorld).negate())}}class Rb extends kn{constructor(e=10,t=10,n=4473924,i=8947848){n=new ye(n),i=new ye(i);const s=t/2,a=e/t,o=e/2,l=[],c=[];for(let f=0,d=0,p=-o;f<=t;f++,p+=a){l.push(-o,0,p,o,0,p),l.push(p,0,-o,p,0,o);const _=f===s?n:i;_.toArray(c,d),d+=3,_.toArray(c,d),d+=3,_.toArray(c,d),d+=3,_.toArray(c,d),d+=3}const h=new Fe;h.setAttribute("position",new ve(l,3)),h.setAttribute("color",new ve(c,3));const u=new Vt({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Cb extends kn{constructor(e=10,t=16,n=8,i=64,s=4473924,a=8947848){s=new ye(s),a=new ye(a);const o=[],l=[];if(t>1)for(let u=0;u<t;u++){const f=u/t*(Math.PI*2),d=Math.sin(f)*e,p=Math.cos(f)*e;o.push(0,0,0),o.push(d,0,p);const _=u&1?s:a;l.push(_.r,_.g,_.b),l.push(_.r,_.g,_.b)}for(let u=0;u<n;u++){const f=u&1?s:a,d=e-e/n*u;for(let p=0;p<i;p++){let _=p/i*(Math.PI*2),g=Math.sin(_)*d,m=Math.cos(_)*d;o.push(g,0,m),l.push(f.r,f.g,f.b),_=(p+1)/i*(Math.PI*2),g=Math.sin(_)*d,m=Math.cos(_)*d,o.push(g,0,m),l.push(f.r,f.g,f.b)}}const c=new Fe;c.setAttribute("position",new ve(o,3)),c.setAttribute("color",new ve(l,3));const h=new Vt({vertexColors:!0,toneMapped:!1});super(c,h),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Tm=new R,qo=new R,Rm=new R;class Pb extends tt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let i=new Fe;i.setAttribute("position",new ve([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Vt({fog:!1,toneMapped:!1});this.lightPlane=new Ri(i,s),this.add(this.lightPlane),i=new Fe,i.setAttribute("position",new ve([0,0,0,0,0,1],3)),this.targetLine=new Ri(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Tm.setFromMatrixPosition(this.light.matrixWorld),qo.setFromMatrixPosition(this.light.target.matrixWorld),Rm.subVectors(qo,Tm),this.lightPlane.lookAt(qo),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(qo),this.targetLine.scale.z=Rm.length()}}const $o=new R,dt=new eo;class Lb extends kn{constructor(e){const t=new Fe,n=new Vt({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(p,_){l(p),l(_)}function l(p){i.push(0,0,0),s.push(0,0,0),a[p]===void 0&&(a[p]=[]),a[p].push(i.length/3-1)}t.setAttribute("position",new ve(i,3)),t.setAttribute("color",new ve(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const c=new ye(16755200),h=new ye(16711680),u=new ye(43775),f=new ye(16777215),d=new ye(3355443);this.setColors(c,h,u,f,d)}setColors(e,t,n,i,s){const o=this.geometry.getAttribute("color");o.setXYZ(0,e.r,e.g,e.b),o.setXYZ(1,e.r,e.g,e.b),o.setXYZ(2,e.r,e.g,e.b),o.setXYZ(3,e.r,e.g,e.b),o.setXYZ(4,e.r,e.g,e.b),o.setXYZ(5,e.r,e.g,e.b),o.setXYZ(6,e.r,e.g,e.b),o.setXYZ(7,e.r,e.g,e.b),o.setXYZ(8,e.r,e.g,e.b),o.setXYZ(9,e.r,e.g,e.b),o.setXYZ(10,e.r,e.g,e.b),o.setXYZ(11,e.r,e.g,e.b),o.setXYZ(12,e.r,e.g,e.b),o.setXYZ(13,e.r,e.g,e.b),o.setXYZ(14,e.r,e.g,e.b),o.setXYZ(15,e.r,e.g,e.b),o.setXYZ(16,e.r,e.g,e.b),o.setXYZ(17,e.r,e.g,e.b),o.setXYZ(18,e.r,e.g,e.b),o.setXYZ(19,e.r,e.g,e.b),o.setXYZ(20,e.r,e.g,e.b),o.setXYZ(21,e.r,e.g,e.b),o.setXYZ(22,e.r,e.g,e.b),o.setXYZ(23,e.r,e.g,e.b),o.setXYZ(24,t.r,t.g,t.b),o.setXYZ(25,t.r,t.g,t.b),o.setXYZ(26,t.r,t.g,t.b),o.setXYZ(27,t.r,t.g,t.b),o.setXYZ(28,t.r,t.g,t.b),o.setXYZ(29,t.r,t.g,t.b),o.setXYZ(30,t.r,t.g,t.b),o.setXYZ(31,t.r,t.g,t.b),o.setXYZ(32,n.r,n.g,n.b),o.setXYZ(33,n.r,n.g,n.b),o.setXYZ(34,n.r,n.g,n.b),o.setXYZ(35,n.r,n.g,n.b),o.setXYZ(36,n.r,n.g,n.b),o.setXYZ(37,n.r,n.g,n.b),o.setXYZ(38,i.r,i.g,i.b),o.setXYZ(39,i.r,i.g,i.b),o.setXYZ(40,s.r,s.g,s.b),o.setXYZ(41,s.r,s.g,s.b),o.setXYZ(42,s.r,s.g,s.b),o.setXYZ(43,s.r,s.g,s.b),o.setXYZ(44,s.r,s.g,s.b),o.setXYZ(45,s.r,s.g,s.b),o.setXYZ(46,s.r,s.g,s.b),o.setXYZ(47,s.r,s.g,s.b),o.setXYZ(48,s.r,s.g,s.b),o.setXYZ(49,s.r,s.g,s.b),o.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,i=1;dt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),St("c",t,e,dt,0,0,-1),St("t",t,e,dt,0,0,1),St("n1",t,e,dt,-n,-i,-1),St("n2",t,e,dt,n,-i,-1),St("n3",t,e,dt,-n,i,-1),St("n4",t,e,dt,n,i,-1),St("f1",t,e,dt,-n,-i,1),St("f2",t,e,dt,n,-i,1),St("f3",t,e,dt,-n,i,1),St("f4",t,e,dt,n,i,1),St("u1",t,e,dt,n*.7,i*1.1,-1),St("u2",t,e,dt,-n*.7,i*1.1,-1),St("u3",t,e,dt,0,i*2,-1),St("cf1",t,e,dt,-n,0,1),St("cf2",t,e,dt,n,0,1),St("cf3",t,e,dt,0,-i,1),St("cf4",t,e,dt,0,i,1),St("cn1",t,e,dt,-n,0,-1),St("cn2",t,e,dt,n,0,-1),St("cn3",t,e,dt,0,-i,-1),St("cn4",t,e,dt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function St(r,e,t,n,i,s,a){$o.set(i,s,a).unproject(n);const o=e[r];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,h=o.length;c<h;c++)l.setXYZ(o[c],$o.x,$o.y,$o.z)}}const Yo=new _n;class Ib extends kn{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(8*3),s=new Fe;s.setIndex(new Ze(n,1)),s.setAttribute("position",new Ze(i,3)),super(s,new Vt({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Yo.setFromObject(this.object),Yo.isEmpty())return;const t=Yo.min,n=Yo.max,i=this.geometry.attributes.position,s=i.array;s[0]=n.x,s[1]=n.y,s[2]=n.z,s[3]=t.x,s[4]=n.y,s[5]=n.z,s[6]=t.x,s[7]=t.y,s[8]=n.z,s[9]=n.x,s[10]=t.y,s[11]=n.z,s[12]=n.x,s[13]=n.y,s[14]=t.z,s[15]=t.x,s[16]=n.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=n.x,s[22]=t.y,s[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ub extends kn{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Fe;s.setIndex(new Ze(n,1)),s.setAttribute("position",new ve(i,3)),super(s,new Vt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class Db extends Ri{constructor(e,t=1,n=16776960){const i=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new Fe;a.setAttribute("position",new ve(s,3)),a.computeBoundingSphere(),super(a,new Vt({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new Fe;l.setAttribute("position",new ve(o,3)),l.computeBoundingSphere(),this.add(new It(l,new Ai({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Cm=new R;let Zo,Zh;class Nb extends tt{constructor(e=new R(0,0,1),t=new R(0,0,0),n=1,i=16776960,s=n*.2,a=s*.2){super(),this.type="ArrowHelper",Zo===void 0&&(Zo=new Fe,Zo.setAttribute("position",new ve([0,0,0,0,1,0],3)),Zh=new Zr(0,.5,1,5,1),Zh.translate(0,-.5,0)),this.position.copy(t),this.line=new Ri(Zo,new Vt({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new It(Zh,new Ai({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Cm.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Cm,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Fb extends kn{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Fe;i.setAttribute("position",new ve(t,3)),i.setAttribute("color",new ve(n,3));const s=new Vt({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){const i=new ye,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ob{constructor(){this.type="ShapePath",this.color=new ye,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Ws,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,a){return this.currentPath.bezierCurveTo(e,t,n,i,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(m){const y=[];for(let x=0,v=m.length;x<v;x++){const M=m[x],w=new ii;w.curves=M.curves,y.push(w)}return y}function n(m,y){const x=y.length;let v=!1;for(let M=x-1,w=0;w<x;M=w++){let A=y[M],C=y[w],S=C.x-A.x,b=C.y-A.y;if(Math.abs(b)>Number.EPSILON){if(b<0&&(A=y[w],S=-S,C=y[M],b=-b),m.y<A.y||m.y>C.y)continue;if(m.y===A.y){if(m.x===A.x)return!0}else{const L=b*(m.x-A.x)-S*(m.y-A.y);if(L===0)return!0;if(L<0)continue;v=!v}}else{if(m.y!==A.y)continue;if(C.x<=m.x&&m.x<=A.x||A.x<=m.x&&m.x<=C.x)return!0}}return v}const i=un.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new ii,l.curves=o.curves,c.push(l),c;let h=!i(s[0].getPoints());h=e?!h:h;const u=[],f=[];let d=[],p=0,_;f[p]=void 0,d[p]=[];for(let m=0,y=s.length;m<y;m++)o=s[m],_=o.getPoints(),a=i(_),a=e?!a:a,a?(!h&&f[p]&&p++,f[p]={s:new ii,p:_},f[p].s.curves=o.curves,h&&p++,d[p]=[]):d[p].push({h:o,p:_[0]});if(!f[0])return t(s);if(f.length>1){let m=!1,y=0;for(let x=0,v=f.length;x<v;x++)u[x]=[];for(let x=0,v=f.length;x<v;x++){const M=d[x];for(let w=0;w<M.length;w++){const A=M[w];let C=!0;for(let S=0;S<f.length;S++)n(A.p,f[S].p)&&(x!==S&&y++,C?(C=!1,u[S].push(A)):m=!0);C&&u[x].push(A)}}y>0&&m===!1&&(d=u)}let g;for(let m=0,y=f.length;m<y;m++){l=f[m].s,c.push(l),g=d[m];for(let x=0,v=g.length;x<v;x++)l.holes.push(g[x].h)}return c}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ot}})),typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ot);var Bb=Object.freeze({__proto__:null,ACESFilmicToneMapping:Sf,AddEquation:Di,AddOperation:xf,AdditiveAnimationBlendMode:Cc,AdditiveBlending:ql,AlphaFormat:Af,AlwaysCompare:$f,AlwaysDepth:uf,AlwaysStencilFunc:zf,AmbientLight:rm,AmbientLightProbe:ZS,AnimationAction:ym,AnimationClip:ea,AnimationLoader:FS,AnimationMixer:db,AnimationObjectGroup:ub,AnimationUtils:IS,ArcCurve:vp,ArrayCamera:Wd,ArrowHelper:Nb,Audio:gm,AudioAnalyser:tb,AudioContext:Vh,AudioListener:jS,AudioLoader:$S,AxesHelper:Fb,BackSide:kt,BasicDepthPacking:Ff,BasicShadowMap:ds,Bone:mh,BooleanKeyframeTrack:Ji,Box2:Mb,Box3:_n,Box3Helper:Ub,BoxGeometry:Vi,BoxHelper:Ib,BufferAttribute:Ze,BufferGeometry:Fe,BufferGeometryLoader:lm,ByteType:wf,Cache:ji,Camera:eo,CameraHelper:Lb,CanvasTexture:nS,CapsuleGeometry:wo,CatmullRomCurve3:Mp,CineonToneMapping:Mf,CircleGeometry:Eo,ClampToEdgeWrapping:Dt,Clock:dm,Color:ye,ColorKeyframeTrack:Oh,ColorManagement:gn,CompressedArrayTexture:tS,CompressedTexture:yh,CompressedTextureLoader:OS,ConeGeometry:Ao,CubeCamera:md,CubeReflectionMapping:pi,CubeRefractionMapping:mi,CubeTexture:Ds,CubeTextureLoader:BS,CubeUVReflectionMapping:mr,CubicBezierCurve:wh,CubicBezierCurve3:bp,CubicInterpolant:$p,CullFaceBack:dr,CullFaceFront:va,CullFaceFrontBack:Xl,CullFaceNone:Jt,Curve:Cn,CurvePath:Ep,CustomBlending:Ku,CustomToneMapping:bf,CylinderGeometry:Zr,Cylindrical:vb,Data3DTexture:zc,DataArrayTexture:Na,DataTexture:qr,DataTextureLoader:zS,DataUtils:H_,DecrementStencilOp:G0,DecrementWrapStencilOp:V0,DefaultLoadingManager:Jp,DepthFormat:xi,DepthStencilFormat:Ni,DepthTexture:Xd,DirectionalLight:im,DirectionalLightHelper:Pb,DiscreteInterpolant:Yp,DisplayP3ColorSpace:Lc,DodecahedronGeometry:To,DoubleSide:Nn,DstAlphaFactor:sf,DstColorFactor:of,DynamicCopyUsage:r_,DynamicDrawUsage:j0,DynamicReadUsage:t_,EdgesGeometry:Ap,EllipseCurve:Mo,EqualCompare:Hf,EqualDepth:df,EqualStencilFunc:$0,EquirectangularReflectionMapping:ms,EquirectangularRefractionMapping:gs,Euler:Ps,EventDispatcher:Zn,ExtrudeGeometry:Up,FileLoader:si,Float16BufferAttribute:Y_,Float32BufferAttribute:ve,Float64BufferAttribute:Z_,FloatType:On,Fog:co,FogExp2:lo,FramebufferTexture:eS,FrontSide:Xn,Frustum:no,GLBufferAttribute:_b,GLSL1:a_,GLSL3:Ic,GreaterCompare:Wf,GreaterDepth:mf,GreaterEqualCompare:qf,GreaterEqualDepth:pf,GreaterEqualStencilFunc:K0,GreaterStencilFunc:Z0,GridHelper:Rb,Group:kr,HalfFloatType:gr,HemisphereLight:Kp,HemisphereLightHelper:Tb,HemisphereLightProbe:YS,IcosahedronGeometry:Do,ImageBitmapLoader:qS,ImageLoader:ta,ImageUtils:Oc,IncrementStencilOp:k0,IncrementWrapStencilOp:H0,InstancedBufferAttribute:$r,InstancedBufferGeometry:om,InstancedInterleavedBuffer:gb,InstancedMesh:hp,Int16BufferAttribute:q_,Int32BufferAttribute:$_,Int8BufferAttribute:V_,IntType:ec,InterleavedBuffer:ho,InterleavedBufferAttribute:$i,Interpolant:Ks,InterpolateDiscrete:vs,InterpolateLinear:Ms,InterpolateSmooth:Pa,InvertStencilOp:W0,KeepStencilOp:Ia,KeyframeTrack:Pn,LOD:ep,LatheGeometry:Xs,Layers:Ga,LessCompare:Gf,LessDepth:ff,LessEqualCompare:Vf,LessEqualDepth:Ma,LessEqualStencilFunc:Y0,LessStencilFunc:q0,Light:Pi,LightProbe:Go,Line:Ri,Line3:Sb,LineBasicMaterial:Vt,LineCurve:bo,LineCurve3:wp,LineDashedMaterial:Xp,LineLoop:gp,LineSegments:kn,LinearEncoding:Pc,LinearFilter:vt,LinearInterpolant:Fh,LinearMipMapLinearFilter:D0,LinearMipMapNearestFilter:U0,LinearMipmapLinearFilter:gi,LinearMipmapNearestFilter:Ql,LinearSRGBColorSpace:Sn,LinearToneMapping:yf,Loader:en,LoaderUtils:Hh,LoadingManager:Bh,LoopOnce:Uf,LoopPingPong:Nf,LoopRepeat:Df,LuminanceAlphaFormat:Rf,LuminanceFormat:Tf,MOUSE:At,Material:Ft,MaterialLoader:Ho,MathUtils:v_,Matrix3:Xe,Matrix4:Be,MaxEquation:Jl,Mesh:It,MeshBasicMaterial:Ai,MeshDepthMaterial:lh,MeshDistanceMaterial:ch,MeshLambertMaterial:Vp,MeshMatcapMaterial:Wp,MeshNormalMaterial:Hp,MeshPhongMaterial:kp,MeshPhysicalMaterial:zp,MeshStandardMaterial:Ih,MeshToonMaterial:Gp,MinEquation:Zl,MirroredRepeatWrapping:xs,MixOperation:_f,MultiplyBlending:Yl,MultiplyOperation:ps,NearestFilter:yt,NearestMipMapLinearFilter:I0,NearestMipMapNearestFilter:L0,NearestMipmapLinearFilter:ys,NearestMipmapNearestFilter:ba,NeverCompare:kf,NeverDepth:hf,NeverStencilFunc:X0,NoBlending:qn,NoColorSpace:Mi,NoToneMapping:Fn,NormalAnimationBlendMode:La,NormalBlending:Ui,NotEqualCompare:Xf,NotEqualDepth:gf,NotEqualStencilFunc:J0,NumberKeyframeTrack:js,Object3D:tt,ObjectLoader:WS,ObjectSpaceNormalMap:Bf,OctahedronGeometry:Zs,OneFactor:tf,OneMinusDstAlphaFactor:af,OneMinusDstColorFactor:lf,OneMinusSrcAlphaFactor:jl,OneMinusSrcColorFactor:rf,OrthographicCamera:ro,PCFShadowMap:Mn,PCFSoftShadowMap:pr,PMREMGenerator:rh,Path:Ws,PerspectiveCamera:Ut,Plane:Ti,PlaneGeometry:Ns,PlaneHelper:Db,PointLight:nm,PointLightHelper:Eb,Points:xp,PointsMaterial:_h,PolarGridHelper:Cb,PolyhedronGeometry:Ci,PositionalAudio:eb,PropertyBinding:et,PropertyMixer:xm,QuadraticBezierCurve:Eh,QuadraticBezierCurve3:Ah,Quaternion:Kt,QuaternionKeyframeTrack:Kr,QuaternionLinearInterpolant:Zp,RED_GREEN_RGTC2_Format:Tc,RED_RGTC1_Format:If,REVISION:ot,RGBADepthPacking:Of,RGBAFormat:an,RGBAIntegerFormat:sc,RGBA_ASTC_10x10_Format:bc,RGBA_ASTC_10x5_Format:vc,RGBA_ASTC_10x6_Format:Mc,RGBA_ASTC_10x8_Format:Sc,RGBA_ASTC_12x10_Format:wc,RGBA_ASTC_12x12_Format:Ec,RGBA_ASTC_4x4_Format:fc,RGBA_ASTC_5x4_Format:dc,RGBA_ASTC_5x5_Format:pc,RGBA_ASTC_6x5_Format:mc,RGBA_ASTC_6x6_Format:gc,RGBA_ASTC_8x5_Format:_c,RGBA_ASTC_8x6_Format:xc,RGBA_ASTC_8x8_Format:yc,RGBA_BPTC_Format:Ca,RGBA_ETC2_EAC_Format:uc,RGBA_PVRTC_2BPPV1_Format:cc,RGBA_PVRTC_4BPPV1_Format:lc,RGBA_S3TC_DXT1_Format:Aa,RGBA_S3TC_DXT3_Format:Ta,RGBA_S3TC_DXT5_Format:Ra,RGB_ETC1_Format:Lf,RGB_ETC2_Format:hc,RGB_PVRTC_2BPPV1_Format:oc,RGB_PVRTC_4BPPV1_Format:ac,RGB_S3TC_DXT1_Format:Ea,RGFormat:Pf,RGIntegerFormat:rc,RawShaderMaterial:Bp,Ray:Er,Raycaster:xb,RectAreaLight:sm,RedFormat:Cf,RedIntegerFormat:ic,ReinhardToneMapping:vf,RepeatWrapping:_s,ReplaceStencilOp:z0,ReverseSubtractEquation:Qu,RingGeometry:No,SIGNED_RED_GREEN_RGTC2_Format:Rc,SIGNED_RED_RGTC1_Format:Ac,SRGBColorSpace:Ge,Scene:Yd,ShaderChunk:Ve,ShaderLib:Rn,ShaderMaterial:zn,ShadowMaterial:Op,Shape:ii,ShapeGeometry:Fo,ShapePath:Ob,ShapeUtils:un,ShortType:Ef,Skeleton:go,SkeletonHelper:wb,SkinnedMesh:ap,Source:zi,Sphere:wn,SphereGeometry:Js,Spherical:yb,SphericalHarmonics3:am,SplineCurve:Th,SpotLight:em,SpotLightHelper:bb,Sprite:jd,SpriteMaterial:uh,SrcAlphaFactor:Kl,SrcAlphaSaturateFactor:cf,SrcColorFactor:nf,StaticCopyUsage:i_,StaticDrawUsage:bs,StaticReadUsage:e_,StereoCamera:JS,StreamCopyUsage:s_,StreamDrawUsage:Q0,StreamReadUsage:n_,StringKeyframeTrack:Ki,SubtractEquation:ju,SubtractiveBlending:$l,TOUCH:xt,TangentSpaceNormalMap:vi,TetrahedronGeometry:Oo,Texture:Mt,TextureLoader:kS,TorusGeometry:Bo,TorusKnotGeometry:zo,Triangle:jt,TriangleFanDrawMode:O0,TriangleStripDrawMode:F0,TrianglesDrawMode:N0,TubeGeometry:ko,TwoPassDoubleSide:P0,UVMapping:Sa,Uint16BufferAttribute:Kc,Uint32BufferAttribute:jc,Uint8BufferAttribute:W_,Uint8ClampedBufferAttribute:X_,Uniform:qh,UniformsGroup:mb,UniformsLib:ge,UniformsUtils:pd,UnsignedByteType:$n,UnsignedInt248Type:_i,UnsignedIntType:Yn,UnsignedShort4444Type:tc,UnsignedShort5551Type:nc,UnsignedShortType:wa,VSMShadowMap:Dn,Vector2:q,Vector3:R,Vector4:rt,VectorKeyframeTrack:Qs,VideoTexture:QM,WebGL1Renderer:$d,WebGL3DRenderTarget:L_,WebGLArrayRenderTarget:P_,WebGLCoordinateSystem:Bn,WebGLCubeRenderTarget:gd,WebGLMultipleRenderTargets:I_,WebGLRenderTarget:bn,WebGLRenderer:qd,WebGLUtils:Vd,WebGPUCoordinateSystem:ws,WireframeGeometry:Dp,WrapAroundEnding:Ss,ZeroCurvatureEnding:Fi,ZeroFactor:ef,ZeroSlopeEnding:Oi,ZeroStencilOp:B0,_SRGBAFormat:Ua,sRGBEncoding:yi});const rr=new Map,zb=(r={})=>({generateTopUV(e,t,n,i,s){const a=t[n*3],o=t[n*3+1],l=t[i*3],c=t[i*3+1],h=t[s*3],u=t[s*3+1];let f;if(rr.has(e))f=rr.get(e);else{let g=r.box3;if(!g)if(g=new _n,r.box3Set){const{min:y,max:x}=r.box3Set;g.set(new R(y.x,y.y,0),new R(x.x,x.y,0))}else{const x=e.parameters.shapes.getPoints().map(v=>[v.x,v.y,0]).flat();g.setFromArray(x)}const m=g.getSize(new R);r.split&&(m.y/=r.split),f={box:g,size:m},rr.set(e,f)}const{box:d,size:p}=f,_=r.split?1-r.split:0;return[new q((a-d.min.x)/p.x,(o-d.min.y)/p.y+_),new q((l-d.min.x)/p.x,(c-d.min.y)/p.y+_),new q((h-d.min.x)/p.x,(u-d.min.y)/p.y+_)]},generateSideWallUV(e,t,n,i,s,a){const o=t[n*3],l=t[n*3+1],c=t[n*3+2],h=t[i*3],u=t[i*3+1],f=t[i*3+2],d=t[s*3],p=t[s*3+1],_=t[s*3+2],g=t[a*3],m=t[a*3+1],y=t[a*3+2];let x;if(rr.has(t))x=rr.get(t);else{const w=new _n;w.setFromArray(t);const A=w.getSize(new R);r.split&&(A.z/=1-r.split),x={box:w,size:A},rr.set(t,x)}const{box:v,size:M}=x;return Math.abs(l-u)<Math.abs(o-h)?[new q((o-v.min.x)/M.x,(c-v.min.z)/M.z),new q((h-v.min.x)/M.x,(f-v.min.z)/M.z),new q((d-v.min.x)/M.x,(_-v.min.z)/M.z),new q((g-v.min.x)/M.x,(y-v.min.z)/M.z)]:[new q((l-v.min.y)/M.y,(c-v.min.z)/M.z),new q((u-v.min.y)/M.y,(f-v.min.z)/M.z),new q((p-v.min.y)/M.y,(_-v.min.z)/M.z),new q((m-v.min.y)/M.y,(y-v.min.z)/M.z)]}}),kb=()=>{rr.clear()};class Jh extends Fe{constructor(e=new ii([new q(.5,.5),new q(-.5,.5),new q(-.5,-.5),new q(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new ve(i,3)),this.setAttribute("uv",new ve(s,2)),this.computeVertexNormals();function a(o){var oe,re,Ee;const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1,u=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:d-.1,_=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const m=t.extrudePath,y=t.UVGenerator!==void 0?t.UVGenerator:Gb,x=(oe=t.hasTop)!=null?oe:!0,v=(re=t.hasBottom)!=null?re:!0,M=(Ee=t.hasSide)!=null?Ee:!0;let w,A=!1,C,S,b,L;m&&(w=m.getSpacedPoints(h),A=!0,f=!1,C=m.computeFrenetFrames(h,!1),S=new R,b=new R,L=new R),f||(g=0,d=0,p=0,_=0);const k=o.extractPoints(c);let U=k.shape;const N=k.holes;if(!un.isClockWise(U)){U=U.reverse();for(let $=0,J=N.length;$<J;$++){const ne=N[$];un.isClockWise(ne)&&(N[$]=ne.reverse())}}const B=un.triangulateShape(U,N),O=U;for(let $=0,J=N.length;$<J;$++){const ne=N[$];U=U.concat(ne)}function H($,J,ne){return J||console.error("THREE.ExtrudeGeometry: vec does not exist"),$.clone().addScaledVector(J,ne)}const X=U.length,ee=B.length;function z($,J,ne){let de,pe,T;const E=$.x-J.x,W=$.y-J.y,se=ne.x-$.x,ie=ne.y-$.y,me=E*E+W*W,we=E*ie-W*se;if(Math.abs(we)>Number.EPSILON){const he=Math.sqrt(me),K=Math.sqrt(se*se+ie*ie),Re=J.x-W/he,Ce=J.y+E/he,Ie=ne.x-ie/K,be=ne.y+se/K,Me=((Ie-Re)*ie-(be-Ce)*se)/(E*ie-W*se);de=Re+E*Me-$.x,pe=Ce+W*Me-$.y;const qe=de*de+pe*pe;if(qe<=2)return new q(de,pe);T=Math.sqrt(qe/2)}else{let he=!1;E>Number.EPSILON?se>Number.EPSILON&&(he=!0):E<-Number.EPSILON?se<-Number.EPSILON&&(he=!0):Math.sign(W)===Math.sign(ie)&&(he=!0),he?(de=-W,pe=E,T=Math.sqrt(me)):(de=E,pe=W,T=Math.sqrt(me/2))}return new q(de/T,pe/T)}const Z=[];for(let $=0,J=O.length,ne=J-1,de=$+1;$<J;$++,ne++,de++)ne===J&&(ne=0),de===J&&(de=0),Z[$]=z(O[$],O[ne],O[de]);const le=[];let ce,fe=Z.concat();for(let $=0,J=N.length;$<J;$++){const ne=N[$];ce=[];for(let de=0,pe=ne.length,T=pe-1,E=de+1;de<pe;de++,T++,E++)T===pe&&(T=0),E===pe&&(E=0),ce[de]=z(ne[de],ne[T],ne[E]);le.push(ce),fe=fe.concat(ce)}for(let $=0;$<g;$++){const J=$/g,ne=d*Math.cos(J*Math.PI/2),de=p*Math.sin(J*Math.PI/2)+_;for(let pe=0,T=O.length;pe<T;pe++){const E=H(O[pe],Z[pe],de);je(E.x,E.y,-ne)}for(let pe=0,T=N.length;pe<T;pe++){const E=N[pe];ce=le[pe];for(let W=0,se=E.length;W<se;W++){const ie=H(E[W],ce[W],de);je(ie.x,ie.y,-ne)}}}const Ae=p+_;for(let $=0;$<X;$++){const J=f?H(U[$],fe[$],Ae):U[$];A?(b.copy(C.normals[0]).multiplyScalar(J.x),S.copy(C.binormals[0]).multiplyScalar(J.y),L.copy(w[0]).add(b).add(S),je(L.x,L.y,L.z)):je(J.x,J.y,0)}for(let $=1;$<=h;$++)for(let J=0;J<X;J++){const ne=f?H(U[J],fe[J],Ae):U[J];A?(b.copy(C.normals[$]).multiplyScalar(ne.x),S.copy(C.binormals[$]).multiplyScalar(ne.y),L.copy(w[$]).add(b).add(S),je(L.x,L.y,L.z)):je(ne.x,ne.y,u/h*$)}for(let $=g-1;$>=0;$--){const J=$/g,ne=d*Math.cos(J*Math.PI/2),de=p*Math.sin(J*Math.PI/2)+_;for(let pe=0,T=O.length;pe<T;pe++){const E=H(O[pe],Z[pe],de);je(E.x,E.y,u+ne)}for(let pe=0,T=N.length;pe<T;pe++){const E=N[pe];ce=le[pe];for(let W=0,se=E.length;W<se;W++){const ie=H(E[W],ce[W],de);A?je(ie.x,ie.y+w[h-1].y,w[h-1].x+ne):je(ie.x,ie.y,u+ne)}}}Pe(),M&&Te();function Pe(){const $=i.length/3;if(f){let J=0,ne=X*J;if(v)for(let de=0;de<ee;de++){const pe=B[de];Le(pe[2]+ne,pe[1]+ne,pe[0]+ne)}if(J=h+g*2,ne=X*J,x)for(let de=0;de<ee;de++){const pe=B[de];Le(pe[0]+ne,pe[1]+ne,pe[2]+ne)}}else{if(v)for(let J=0;J<ee;J++){const ne=B[J];Le(ne[2],ne[1],ne[0])}if(x)for(let J=0;J<ee;J++){const ne=B[J];Le(ne[0]+X*h,ne[1]+X*h,ne[2]+X*h)}}n.addGroup($,i.length/3-$,0)}function Te(){const $=i.length/3;let J=0;Ke(O,J),J+=O.length;for(let ne=0,de=N.length;ne<de;ne++){const pe=N[ne];Ke(pe,J),J+=pe.length}n.addGroup($,i.length/3-$,1)}function Ke($,J){let ne=$.length;for(;--ne>=0;){const de=ne;let pe=ne-1;pe<0&&(pe=$.length-1);for(let T=0,E=h+g*2;T<E;T++){const W=X*T,se=X*(T+1),ie=J+de+W,me=J+pe+W,we=J+pe+se,he=J+de+se;D(ie,me,we,he)}}}function je($,J,ne){l.push($),l.push(J),l.push(ne)}function Le($,J,ne){ae($),ae(J),ae(ne);const de=i.length/3,pe=y.generateTopUV(n,i,de-3,de-2,de-1);Q(pe[0]),Q(pe[1]),Q(pe[2])}function D($,J,ne,de){ae($),ae(J),ae(de),ae(J),ae(ne),ae(de);const pe=i.length/3,T=y.generateSideWallUV(n,i,pe-6,pe-3,pe-2,pe-1);Q(T[0]),Q(T[1]),Q(T[3]),Q(T[1]),Q(T[2]),Q(T[3])}function ae($){i.push(l[$*3+0]),i.push(l[$*3+1]),i.push(l[$*3+2])}function Q($){s.push($.x),s.push($.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return Hb(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];n.push(o)}const i=e.options.extrudePath;return console.log(i.type),i!==void 0&&(e.options.extrudePath=new Bb[`${i.type}Curve`]().fromJSON(i)),new Jh(n,e.options)}}const Gb={generateTopUV:function(r,e,t,n,i){const s=e[t*3],a=e[t*3+1],o=e[n*3],l=e[n*3+1],c=e[i*3],h=e[i*3+1];return[new q(s,a),new q(o,l),new q(c,h)]},generateSideWallUV:function(r,e,t,n,i,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[n*3],h=e[n*3+1],u=e[n*3+2],f=e[i*3],d=e[i*3+1],p=e[i*3+2],_=e[s*3],g=e[s*3+1],m=e[s*3+2];return Math.abs(o-h)<Math.abs(a-c)?[new q(a,1-l),new q(c,1-u),new q(f,1-p),new q(_,1-m)]:[new q(o,1-l),new q(h,1-u),new q(d,1-p),new q(g,1-m)]}};function Hb(r,e,t){if(t.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){const s=r[n];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}var Vb=r=>{const{split:e,depth:t,points:n,box3:i,hasTop:s,hasBottom:a,hasSide:o,box3Set:l}=r,c=new Jh(new ii(n),{depth:t,bevelEnabled:!1,UVGenerator:zb({split:e,box3:i,box3Set:l}),hasTop:s,hasBottom:a,hasSide:o});return kb(),c};function Jo(r,e){return r==null||e==null?NaN:r<e?-1:r>e?1:r>=e?0:NaN}function Wb(r,e){return r==null||e==null?NaN:e<r?-1:e>r?1:e>=r?0:NaN}function Pm(r){let e,t,n;r.length!==2?(e=Jo,t=(o,l)=>Jo(r(o),l),n=(o,l)=>r(o)-l):(e=r===Jo||r===Wb?r:Xb,t=r,n=r);function i(o,l,c=0,h=o.length){if(c<h){if(e(l,l)!==0)return h;do{const u=c+h>>>1;t(o[u],l)<0?c=u+1:h=u}while(c<h)}return c}function s(o,l,c=0,h=o.length){if(c<h){if(e(l,l)!==0)return h;do{const u=c+h>>>1;t(o[u],l)<=0?c=u+1:h=u}while(c<h)}return c}function a(o,l,c=0,h=o.length){const u=i(o,l,c,h-1);return u>c&&n(o[u-1],l)>-n(o[u],l)?u-1:u}return{left:i,center:a,right:s}}function Xb(){return 0}function qb(r){return r===null?NaN:+r}const $b=Pm(Jo).right;Pm(qb).center;var Yb=$b;function Ko(r,e){let t,n;if(e===void 0)for(const i of r)i!=null&&(t===void 0?i>=i&&(t=n=i):(t>i&&(t=i),n<i&&(n=i)));else{let i=-1;for(let s of r)(s=e(s,++i,r))!=null&&(t===void 0?s>=s&&(t=n=s):(t>s&&(t=s),n<s&&(n=s)))}return[t,n]}class ai{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){const t=this._partials;let n=0;for(let i=0;i<this._n&&i<32;i++){const s=t[i],a=e+s,o=Math.abs(e)<Math.abs(s)?e-(a-s):s-(a-e);o&&(t[n++]=o),e=a}return t[n]=e,this._n=n+1,this}valueOf(){const e=this._partials;let t=this._n,n,i,s,a=0;if(t>0){for(a=e[--t];t>0&&(n=a,i=e[--t],a=n+i,s=i-(a-n),!s););t>0&&(s<0&&e[t-1]<0||s>0&&e[t-1]>0)&&(i=s*2,n=a+i,i==n-a&&(a=n))}return a}}const Zb=Math.sqrt(50),Jb=Math.sqrt(10),Kb=Math.sqrt(2);function jo(r,e,t){const n=(e-r)/Math.max(0,t),i=Math.floor(Math.log10(n)),s=n/Math.pow(10,i),a=s>=Zb?10:s>=Jb?5:s>=Kb?2:1;let o,l,c;return i<0?(c=Math.pow(10,-i)/a,o=Math.round(r*c),l=Math.round(e*c),o/c<r&&++o,l/c>e&&--l,c=-c):(c=Math.pow(10,i)*a,o=Math.round(r/c),l=Math.round(e/c),o*c<r&&++o,l*c>e&&--l),l<o&&.5<=t&&t<2?jo(r,e,t*2):[o,l,c]}function jb(r,e,t){if(e=+e,r=+r,t=+t,!(t>0))return[];if(r===e)return[r];const n=e<r,[i,s,a]=n?jo(e,r,t):jo(r,e,t);if(!(s>=i))return[];const o=s-i+1,l=new Array(o);if(n)if(a<0)for(let c=0;c<o;++c)l[c]=(s-c)/-a;else for(let c=0;c<o;++c)l[c]=(s-c)*a;else if(a<0)for(let c=0;c<o;++c)l[c]=(i+c)/-a;else for(let c=0;c<o;++c)l[c]=(i+c)*a;return l}function Kh(r,e,t){return e=+e,r=+r,t=+t,jo(r,e,t)[2]}function Qb(r,e,t){e=+e,r=+r,t=+t;const n=e<r,i=n?Kh(e,r,t):Kh(r,e,t);return(n?-1:1)*(i<0?1/-i:i)}function e1(r,e){let t=0,n=0;if(e===void 0)for(let i of r)i!=null&&(i=+i)>=i&&(++t,n+=i);else{let i=-1;for(let s of r)(s=e(s,++i,r))!=null&&(s=+s)>=s&&(++t,n+=s)}if(t)return n/t}function*t1(r){for(const e of r)yield*e}function ia(r){return Array.from(t1(r))}var it=1e-6,Qo=1e-12,Je=Math.PI,tn=Je/2,el=Je/4,nn=Je*2,pt=180/Je,Ne=Je/180,st=Math.abs,jh=Math.atan,vn=Math.atan2,ze=Math.cos,n1=Math.exp,Qh=Math.hypot,i1=Math.log,De=Math.sin,r1=Math.sign||function(r){return r>0?1:r<0?-1:0},oi=Math.sqrt,s1=Math.tan;function a1(r){return r>1?0:r<-1?Je:Math.acos(r)}function li(r){return r>1?tn:r<-1?-tn:Math.asin(r)}function Lm(r){return(r=De(r/2))*r}function Bt(){}function tl(r,e){r&&Um.hasOwnProperty(r.type)&&Um[r.type](r,e)}var Im={Feature:function(r,e){tl(r.geometry,e)},FeatureCollection:function(r,e){for(var t=r.features,n=-1,i=t.length;++n<i;)tl(t[n].geometry,e)}},Um={Sphere:function(r,e){e.sphere()},Point:function(r,e){r=r.coordinates,e.point(r[0],r[1],r[2])},MultiPoint:function(r,e){for(var t=r.coordinates,n=-1,i=t.length;++n<i;)r=t[n],e.point(r[0],r[1],r[2])},LineString:function(r,e){eu(r.coordinates,e,0)},MultiLineString:function(r,e){for(var t=r.coordinates,n=-1,i=t.length;++n<i;)eu(t[n],e,0)},Polygon:function(r,e){Dm(r.coordinates,e)},MultiPolygon:function(r,e){for(var t=r.coordinates,n=-1,i=t.length;++n<i;)Dm(t[n],e)},GeometryCollection:function(r,e){for(var t=r.geometries,n=-1,i=t.length;++n<i;)tl(t[n],e)}};function eu(r,e,t){var n=-1,i=r.length-t,s;for(e.lineStart();++n<i;)s=r[n],e.point(s[0],s[1],s[2]);e.lineEnd()}function Dm(r,e){var t=-1,n=r.length;for(e.polygonStart();++t<n;)eu(r[t],e,1);e.polygonEnd()}function nl(r,e){r&&Im.hasOwnProperty(r.type)?Im[r.type](r,e):tl(r,e)}var il=new ai,Nm=new ai,Fm,Om,tu,nu,iu,ci={point:Bt,lineStart:Bt,lineEnd:Bt,polygonStart:function(){il=new ai,ci.lineStart=o1,ci.lineEnd=l1},polygonEnd:function(){var r=+il;Nm.add(r<0?nn+r:r),this.lineStart=this.lineEnd=this.point=Bt},sphere:function(){Nm.add(nn)}};function o1(){ci.point=c1}function l1(){Bm(Fm,Om)}function c1(r,e){ci.point=Bm,Fm=r,Om=e,r*=Ne,e*=Ne,tu=r,nu=ze(e=e/2+el),iu=De(e)}function Bm(r,e){r*=Ne,e*=Ne,e=e/2+el;var t=r-tu,n=t>=0?1:-1,i=n*t,s=ze(e),a=De(e),o=iu*a,l=nu*s+o*ze(i),c=o*n*De(i);il.add(vn(c,l)),tu=r,nu=s,iu=a}function rl(r){return[vn(r[1],r[0]),li(r[2])]}function sr(r){var e=r[0],t=r[1],n=ze(t);return[n*ze(e),n*De(e),De(t)]}function sl(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]}function jr(r,e){return[r[1]*e[2]-r[2]*e[1],r[2]*e[0]-r[0]*e[2],r[0]*e[1]-r[1]*e[0]]}function ru(r,e){r[0]+=e[0],r[1]+=e[1],r[2]+=e[2]}function al(r,e){return[r[0]*e,r[1]*e,r[2]*e]}function ol(r){var e=oi(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);r[0]/=e,r[1]/=e,r[2]/=e}var ct,rn,mt,fn,ar,zm,km,Qr,ra,Ii,hi,ui={point:su,lineStart:Hm,lineEnd:Vm,polygonStart:function(){ui.point=Wm,ui.lineStart=h1,ui.lineEnd=u1,ra=new ai,ci.polygonStart()},polygonEnd:function(){ci.polygonEnd(),ui.point=su,ui.lineStart=Hm,ui.lineEnd=Vm,il<0?(ct=-(mt=180),rn=-(fn=90)):ra>it?fn=90:ra<-it&&(rn=-90),hi[0]=ct,hi[1]=mt},sphere:function(){ct=-(mt=180),rn=-(fn=90)}};function su(r,e){Ii.push(hi=[ct=r,mt=r]),e<rn&&(rn=e),e>fn&&(fn=e)}function Gm(r,e){var t=sr([r*Ne,e*Ne]);if(Qr){var n=jr(Qr,t),i=[n[1],-n[0],0],s=jr(i,n);ol(s),s=rl(s);var a=r-ar,o=a>0?1:-1,l=s[0]*pt*o,c,h=st(a)>180;h^(o*ar<l&&l<o*r)?(c=s[1]*pt,c>fn&&(fn=c)):(l=(l+360)%360-180,h^(o*ar<l&&l<o*r)?(c=-s[1]*pt,c<rn&&(rn=c)):(e<rn&&(rn=e),e>fn&&(fn=e))),h?r<ar?dn(ct,r)>dn(ct,mt)&&(mt=r):dn(r,mt)>dn(ct,mt)&&(ct=r):mt>=ct?(r<ct&&(ct=r),r>mt&&(mt=r)):r>ar?dn(ct,r)>dn(ct,mt)&&(mt=r):dn(r,mt)>dn(ct,mt)&&(ct=r)}else Ii.push(hi=[ct=r,mt=r]);e<rn&&(rn=e),e>fn&&(fn=e),Qr=t,ar=r}function Hm(){ui.point=Gm}function Vm(){hi[0]=ct,hi[1]=mt,ui.point=su,Qr=null}function Wm(r,e){if(Qr){var t=r-ar;ra.add(st(t)>180?t+(t>0?360:-360):t)}else zm=r,km=e;ci.point(r,e),Gm(r,e)}function h1(){ci.lineStart()}function u1(){Wm(zm,km),ci.lineEnd(),st(ra)>it&&(ct=-(mt=180)),hi[0]=ct,hi[1]=mt,Qr=null}function dn(r,e){return(e-=r)<0?e+360:e}function f1(r,e){return r[0]-e[0]}function Xm(r,e){return r[0]<=r[1]?r[0]<=e&&e<=r[1]:e<r[0]||r[1]<e}function qm(r){var e,t,n,i,s,a,o;if(fn=mt=-(ct=rn=1/0),Ii=[],nl(r,ui),t=Ii.length){for(Ii.sort(f1),e=1,n=Ii[0],s=[n];e<t;++e)i=Ii[e],Xm(n,i[0])||Xm(n,i[1])?(dn(n[0],i[1])>dn(n[0],n[1])&&(n[1]=i[1]),dn(i[0],n[1])>dn(n[0],n[1])&&(n[0]=i[0])):s.push(n=i);for(a=-1/0,t=s.length-1,e=0,n=s[t];e<=t;n=i,++e)i=s[e],(o=dn(n[1],i[0]))>a&&(a=o,ct=i[0],mt=n[1])}return Ii=hi=null,ct===1/0||rn===1/0?[[NaN,NaN],[NaN,NaN]]:[[ct,rn],[mt,fn]]}var sa,ll,cl,hl,ul,fl,dl,pl,au,ou,lu,$m,Ym,Wt,Xt,qt,Ln={sphere:Bt,point:cu,lineStart:Zm,lineEnd:Jm,polygonStart:function(){Ln.lineStart=m1,Ln.lineEnd=g1},polygonEnd:function(){Ln.lineStart=Zm,Ln.lineEnd=Jm}};function cu(r,e){r*=Ne,e*=Ne;var t=ze(e);aa(t*ze(r),t*De(r),De(e))}function aa(r,e,t){++sa,cl+=(r-cl)/sa,hl+=(e-hl)/sa,ul+=(t-ul)/sa}function Zm(){Ln.point=d1}function d1(r,e){r*=Ne,e*=Ne;var t=ze(e);Wt=t*ze(r),Xt=t*De(r),qt=De(e),Ln.point=p1,aa(Wt,Xt,qt)}function p1(r,e){r*=Ne,e*=Ne;var t=ze(e),n=t*ze(r),i=t*De(r),s=De(e),a=vn(oi((a=Xt*s-qt*i)*a+(a=qt*n-Wt*s)*a+(a=Wt*i-Xt*n)*a),Wt*n+Xt*i+qt*s);ll+=a,fl+=a*(Wt+(Wt=n)),dl+=a*(Xt+(Xt=i)),pl+=a*(qt+(qt=s)),aa(Wt,Xt,qt)}function Jm(){Ln.point=cu}function m1(){Ln.point=_1}function g1(){Km($m,Ym),Ln.point=cu}function _1(r,e){$m=r,Ym=e,r*=Ne,e*=Ne,Ln.point=Km;var t=ze(e);Wt=t*ze(r),Xt=t*De(r),qt=De(e),aa(Wt,Xt,qt)}function Km(r,e){r*=Ne,e*=Ne;var t=ze(e),n=t*ze(r),i=t*De(r),s=De(e),a=Xt*s-qt*i,o=qt*n-Wt*s,l=Wt*i-Xt*n,c=Qh(a,o,l),h=li(c),u=c&&-h/c;au.add(u*a),ou.add(u*o),lu.add(u*l),ll+=h,fl+=h*(Wt+(Wt=n)),dl+=h*(Xt+(Xt=i)),pl+=h*(qt+(qt=s)),aa(Wt,Xt,qt)}function jm(r){sa=ll=cl=hl=ul=fl=dl=pl=0,au=new ai,ou=new ai,lu=new ai,nl(r,Ln);var e=+au,t=+ou,n=+lu,i=Qh(e,t,n);return i<Qo&&(e=fl,t=dl,n=pl,ll<it&&(e=cl,t=hl,n=ul),i=Qh(e,t,n),i<Qo)?[NaN,NaN]:[vn(t,e)*pt,li(n/i)*pt]}function hu(r,e){function t(n,i){return n=r(n,i),e(n[0],n[1])}return r.invert&&e.invert&&(t.invert=function(n,i){return n=e.invert(n,i),n&&r.invert(n[0],n[1])}),t}function uu(r,e){return st(r)>Je&&(r-=Math.round(r/nn)*nn),[r,e]}uu.invert=uu;function Qm(r,e,t){return(r%=nn)?e||t?hu(tg(r),ng(e,t)):tg(r):e||t?ng(e,t):uu}function eg(r){return function(e,t){return e+=r,st(e)>Je&&(e-=Math.round(e/nn)*nn),[e,t]}}function tg(r){var e=eg(r);return e.invert=eg(-r),e}function ng(r,e){var t=ze(r),n=De(r),i=ze(e),s=De(e);function a(o,l){var c=ze(l),h=ze(o)*c,u=De(o)*c,f=De(l),d=f*t+h*n;return[vn(u*i-d*s,h*t-f*n),li(d*i+u*s)]}return a.invert=function(o,l){var c=ze(l),h=ze(o)*c,u=De(o)*c,f=De(l),d=f*i-u*s;return[vn(u*i+f*s,h*t+d*n),li(d*t-h*n)]},a}function ig(r){r=Qm(r[0]*Ne,r[1]*Ne,r.length>2?r[2]*Ne:0);function e(t){return t=r(t[0]*Ne,t[1]*Ne),t[0]*=pt,t[1]*=pt,t}return e.invert=function(t){return t=r.invert(t[0]*Ne,t[1]*Ne),t[0]*=pt,t[1]*=pt,t},e}function x1(r,e,t,n,i,s){if(t){var a=ze(e),o=De(e),l=n*t;i==null?(i=e+n*nn,s=e-l/2):(i=rg(a,i),s=rg(a,s),(n>0?i<s:i>s)&&(i+=n*nn));for(var c,h=i;n>0?h>s:h<s;h-=l)c=rl([a,-o*ze(h),-o*De(h)]),r.point(c[0],c[1])}}function rg(r,e){e=sr(e),e[0]-=r,ol(e);var t=a1(-e[1]);return((-e[2]<0?-t:t)+nn-it)%nn}function sg(){var r=[],e;return{point:function(t,n,i){e.push([t,n,i])},lineStart:function(){r.push(e=[])},lineEnd:Bt,rejoin:function(){r.length>1&&r.push(r.pop().concat(r.shift()))},result:function(){var t=r;return r=[],e=null,t}}}function ml(r,e){return st(r[0]-e[0])<it&&st(r[1]-e[1])<it}function gl(r,e,t,n){this.x=r,this.z=e,this.o=t,this.e=n,this.v=!1,this.n=this.p=null}function ag(r,e,t,n,i){var s=[],a=[],o,l;if(r.forEach(function(p){if(!((_=p.length-1)<=0)){var _,g=p[0],m=p[_],y;if(ml(g,m)){if(!g[2]&&!m[2]){for(i.lineStart(),o=0;o<_;++o)i.point((g=p[o])[0],g[1]);i.lineEnd();return}m[0]+=2*it}s.push(y=new gl(g,p,null,!0)),a.push(y.o=new gl(g,null,y,!1)),s.push(y=new gl(m,p,null,!1)),a.push(y.o=new gl(m,null,y,!0))}}),!!s.length){for(a.sort(e),og(s),og(a),o=0,l=a.length;o<l;++o)a[o].e=t=!t;for(var c=s[0],h,u;;){for(var f=c,d=!0;f.v;)if((f=f.n)===c)return;h=f.z,i.lineStart();do{if(f.v=f.o.v=!0,f.e){if(d)for(o=0,l=h.length;o<l;++o)i.point((u=h[o])[0],u[1]);else n(f.x,f.n.x,1,i);f=f.n}else{if(d)for(h=f.p.z,o=h.length-1;o>=0;--o)i.point((u=h[o])[0],u[1]);else n(f.x,f.p.x,-1,i);f=f.p}f=f.o,h=f.z,d=!d}while(!f.v);i.lineEnd()}}}function og(r){if(e=r.length){for(var e,t=0,n=r[0],i;++t<e;)n.n=i=r[t],i.p=n,n=i;n.n=i=r[0],i.p=n}}function fu(r){return st(r[0])<=Je?r[0]:r1(r[0])*((st(r[0])+Je)%nn-Je)}function lg(r,e){var t=fu(e),n=e[1],i=De(n),s=[De(t),-ze(t),0],a=0,o=0,l=new ai;i===1?n=tn+it:i===-1&&(n=-tn-it);for(var c=0,h=r.length;c<h;++c)if(f=(u=r[c]).length)for(var u,f,d=u[f-1],p=fu(d),_=d[1]/2+el,g=De(_),m=ze(_),y=0;y<f;++y,p=v,g=w,m=A,d=x){var x=u[y],v=fu(x),M=x[1]/2+el,w=De(M),A=ze(M),C=v-p,S=C>=0?1:-1,b=S*C,L=b>Je,k=g*w;if(l.add(vn(k*S*De(b),m*A+k*ze(b))),a+=L?C+S*nn:C,L^p>=t^v>=t){var U=jr(sr(d),sr(x));ol(U);var N=jr(s,U);ol(N);var I=(L^C>=0?-1:1)*li(N[2]);(n>I||n===I&&(U[0]||U[1]))&&(o+=L^C>=0?1:-1)}}return(a<-it||a<it&&l<-Qo)^o&1}function cg(r,e,t,n){return function(i){var s=e(i),a=sg(),o=e(a),l=!1,c,h,u,f={point:d,lineStart:_,lineEnd:g,polygonStart:function(){f.point=m,f.lineStart=y,f.lineEnd=x,h=[],c=[]},polygonEnd:function(){f.point=d,f.lineStart=_,f.lineEnd=g,h=ia(h);var v=lg(c,n);h.length?(l||(i.polygonStart(),l=!0),ag(h,v1,v,t,i)):v&&(l||(i.polygonStart(),l=!0),i.lineStart(),t(null,null,1,i),i.lineEnd()),l&&(i.polygonEnd(),l=!1),h=c=null},sphere:function(){i.polygonStart(),i.lineStart(),t(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function d(v,M){r(v,M)&&i.point(v,M)}function p(v,M){s.point(v,M)}function _(){f.point=p,s.lineStart()}function g(){f.point=d,s.lineEnd()}function m(v,M){u.push([v,M]),o.point(v,M)}function y(){o.lineStart(),u=[]}function x(){m(u[0][0],u[0][1]),o.lineEnd();var v=o.clean(),M=a.result(),w,A=M.length,C,S,b;if(u.pop(),c.push(u),u=null,!!A){if(v&1){if(S=M[0],(C=S.length-1)>0){for(l||(i.polygonStart(),l=!0),i.lineStart(),w=0;w<C;++w)i.point((b=S[w])[0],b[1]);i.lineEnd()}return}A>1&&v&2&&M.push(M.pop().concat(M.shift())),h.push(M.filter(y1))}}return f}}function y1(r){return r.length>1}function v1(r,e){return((r=r.x)[0]<0?r[1]-tn-it:tn-r[1])-((e=e.x)[0]<0?e[1]-tn-it:tn-e[1])}var hg=cg(function(){return!0},M1,b1,[-Je,-tn]);function M1(r){var e=NaN,t=NaN,n=NaN,i;return{lineStart:function(){r.lineStart(),i=1},point:function(s,a){var o=s>0?Je:-Je,l=st(s-e);st(l-Je)<it?(r.point(e,t=(t+a)/2>0?tn:-tn),r.point(n,t),r.lineEnd(),r.lineStart(),r.point(o,t),r.point(s,t),i=0):n!==o&&l>=Je&&(st(e-n)<it&&(e-=n*it),st(s-o)<it&&(s-=o*it),t=S1(e,t,s,a),r.point(n,t),r.lineEnd(),r.lineStart(),r.point(o,t),i=0),r.point(e=s,t=a),n=o},lineEnd:function(){r.lineEnd(),e=t=NaN},clean:function(){return 2-i}}}function S1(r,e,t,n){var i,s,a=De(r-t);return st(a)>it?jh((De(e)*(s=ze(n))*De(t)-De(n)*(i=ze(e))*De(r))/(i*s*a)):(e+n)/2}function b1(r,e,t,n){var i;if(r==null)i=t*tn,n.point(-Je,i),n.point(0,i),n.point(Je,i),n.point(Je,0),n.point(Je,-i),n.point(0,-i),n.point(-Je,-i),n.point(-Je,0),n.point(-Je,i);else if(st(r[0]-e[0])>it){var s=r[0]<e[0]?Je:-Je;i=t*s/2,n.point(-s,i),n.point(0,i),n.point(s,i)}else n.point(e[0],e[1])}function w1(r){var e=ze(r),t=6*Ne,n=e>0,i=st(e)>it;function s(h,u,f,d){x1(d,r,t,f,h,u)}function a(h,u){return ze(h)*ze(u)>e}function o(h){var u,f,d,p,_;return{lineStart:function(){p=d=!1,_=1},point:function(g,m){var y=[g,m],x,v=a(g,m),M=n?v?0:c(g,m):v?c(g+(g<0?Je:-Je),m):0;if(!u&&(p=d=v)&&h.lineStart(),v!==d&&(x=l(u,y),(!x||ml(u,x)||ml(y,x))&&(y[2]=1)),v!==d)_=0,v?(h.lineStart(),x=l(y,u),h.point(x[0],x[1])):(x=l(u,y),h.point(x[0],x[1],2),h.lineEnd()),u=x;else if(i&&u&&n^v){var w;!(M&f)&&(w=l(y,u,!0))&&(_=0,n?(h.lineStart(),h.point(w[0][0],w[0][1]),h.point(w[1][0],w[1][1]),h.lineEnd()):(h.point(w[1][0],w[1][1]),h.lineEnd(),h.lineStart(),h.point(w[0][0],w[0][1],3)))}v&&(!u||!ml(u,y))&&h.point(y[0],y[1]),u=y,d=v,f=M},lineEnd:function(){d&&h.lineEnd(),u=null},clean:function(){return _|(p&&d)<<1}}}function l(h,u,f){var d=sr(h),p=sr(u),_=[1,0,0],g=jr(d,p),m=sl(g,g),y=g[0],x=m-y*y;if(!x)return!f&&h;var v=e*m/x,M=-e*y/x,w=jr(_,g),A=al(_,v),C=al(g,M);ru(A,C);var S=w,b=sl(A,S),L=sl(S,S),k=b*b-L*(sl(A,A)-1);if(!(k<0)){var U=oi(k),N=al(S,(-b-U)/L);if(ru(N,A),N=rl(N),!f)return N;var I=h[0],B=u[0],O=h[1],H=u[1],X;B<I&&(X=I,I=B,B=X);var ee=B-I,z=st(ee-Je)<it,Z=z||ee<it;if(!z&&H<O&&(X=O,O=H,H=X),Z?z?O+H>0^N[1]<(st(N[0]-I)<it?O:H):O<=N[1]&&N[1]<=H:ee>Je^(I<=N[0]&&N[0]<=B)){var le=al(S,(-b+U)/L);return ru(le,A),[N,rl(le)]}}}function c(h,u){var f=n?r:Je-r,d=0;return h<-f?d|=1:h>f&&(d|=2),u<-f?d|=4:u>f&&(d|=8),d}return cg(a,o,s,n?[0,-r]:[-Je,r-Je])}function E1(r,e,t,n,i,s){var a=r[0],o=r[1],l=e[0],c=e[1],h=0,u=1,f=l-a,d=c-o,p;if(p=t-a,!(!f&&p>0)){if(p/=f,f<0){if(p<h)return;p<u&&(u=p)}else if(f>0){if(p>u)return;p>h&&(h=p)}if(p=i-a,!(!f&&p<0)){if(p/=f,f<0){if(p>u)return;p>h&&(h=p)}else if(f>0){if(p<h)return;p<u&&(u=p)}if(p=n-o,!(!d&&p>0)){if(p/=d,d<0){if(p<h)return;p<u&&(u=p)}else if(d>0){if(p>u)return;p>h&&(h=p)}if(p=s-o,!(!d&&p<0)){if(p/=d,d<0){if(p>u)return;p>h&&(h=p)}else if(d>0){if(p<h)return;p<u&&(u=p)}return h>0&&(r[0]=a+h*f,r[1]=o+h*d),u<1&&(e[0]=a+u*f,e[1]=o+u*d),!0}}}}}var oa=1e9,_l=-oa;function A1(r,e,t,n){function i(c,h){return r<=c&&c<=t&&e<=h&&h<=n}function s(c,h,u,f){var d=0,p=0;if(c==null||(d=a(c,u))!==(p=a(h,u))||l(c,h)<0^u>0)do f.point(d===0||d===3?r:t,d>1?n:e);while((d=(d+u+4)%4)!==p);else f.point(h[0],h[1])}function a(c,h){return st(c[0]-r)<it?h>0?0:3:st(c[0]-t)<it?h>0?2:1:st(c[1]-e)<it?h>0?1:0:h>0?3:2}function o(c,h){return l(c.x,h.x)}function l(c,h){var u=a(c,1),f=a(h,1);return u!==f?u-f:u===0?h[1]-c[1]:u===1?c[0]-h[0]:u===2?c[1]-h[1]:h[0]-c[0]}return function(c){var h=c,u=sg(),f,d,p,_,g,m,y,x,v,M,w,A={point:C,lineStart:k,lineEnd:U,polygonStart:b,polygonEnd:L};function C(I,B){i(I,B)&&h.point(I,B)}function S(){for(var I=0,B=0,O=d.length;B<O;++B)for(var H=d[B],X=1,ee=H.length,z=H[0],Z,le,ce=z[0],fe=z[1];X<ee;++X)Z=ce,le=fe,z=H[X],ce=z[0],fe=z[1],le<=n?fe>n&&(ce-Z)*(n-le)>(fe-le)*(r-Z)&&++I:fe<=n&&(ce-Z)*(n-le)<(fe-le)*(r-Z)&&--I;return I}function b(){h=u,f=[],d=[],w=!0}function L(){var I=S(),B=w&&I,O=(f=ia(f)).length;(B||O)&&(c.polygonStart(),B&&(c.lineStart(),s(null,null,1,c),c.lineEnd()),O&&ag(f,o,I,s,c),c.polygonEnd()),h=c,f=d=p=null}function k(){A.point=N,d&&d.push(p=[]),M=!0,v=!1,y=x=NaN}function U(){f&&(N(_,g),m&&v&&u.rejoin(),f.push(u.result())),A.point=C,v&&h.lineEnd()}function N(I,B){var O=i(I,B);if(d&&p.push([I,B]),M)_=I,g=B,m=O,M=!1,O&&(h.lineStart(),h.point(I,B));else if(O&&v)h.point(I,B);else{var H=[y=Math.max(_l,Math.min(oa,y)),x=Math.max(_l,Math.min(oa,x))],X=[I=Math.max(_l,Math.min(oa,I)),B=Math.max(_l,Math.min(oa,B))];E1(H,X,r,e,t,n)?(v||(h.lineStart(),h.point(H[0],H[1])),h.point(X[0],X[1]),O||h.lineEnd(),w=!1):O&&(h.lineStart(),h.point(I,B),w=!1)}y=I,x=B,v=O}return A}}var du,pu,xl,yl,es={sphere:Bt,point:Bt,lineStart:T1,lineEnd:Bt,polygonStart:Bt,polygonEnd:Bt};function T1(){es.point=C1,es.lineEnd=R1}function R1(){es.point=es.lineEnd=Bt}function C1(r,e){r*=Ne,e*=Ne,pu=r,xl=De(e),yl=ze(e),es.point=P1}function P1(r,e){r*=Ne,e*=Ne;var t=De(e),n=ze(e),i=st(r-pu),s=ze(i),a=De(i),o=n*a,l=yl*t-xl*n*s,c=xl*t+yl*n*s;du.add(vn(oi(o*o+l*l),c)),pu=r,xl=t,yl=n}function L1(r){return du=new ai,nl(r,es),+du}var mu=[null,null],I1={type:"LineString",coordinates:mu};function ts(r,e){return mu[0]=r,mu[1]=e,L1(I1)}var ug={Feature:function(r,e){return vl(r.geometry,e)},FeatureCollection:function(r,e){for(var t=r.features,n=-1,i=t.length;++n<i;)if(vl(t[n].geometry,e))return!0;return!1}},fg={Sphere:function(){return!0},Point:function(r,e){return dg(r.coordinates,e)},MultiPoint:function(r,e){for(var t=r.coordinates,n=-1,i=t.length;++n<i;)if(dg(t[n],e))return!0;return!1},LineString:function(r,e){return pg(r.coordinates,e)},MultiLineString:function(r,e){for(var t=r.coordinates,n=-1,i=t.length;++n<i;)if(pg(t[n],e))return!0;return!1},Polygon:function(r,e){return mg(r.coordinates,e)},MultiPolygon:function(r,e){for(var t=r.coordinates,n=-1,i=t.length;++n<i;)if(mg(t[n],e))return!0;return!1},GeometryCollection:function(r,e){for(var t=r.geometries,n=-1,i=t.length;++n<i;)if(vl(t[n],e))return!0;return!1}};function vl(r,e){return r&&fg.hasOwnProperty(r.type)?fg[r.type](r,e):!1}function dg(r,e){return ts(r,e)===0}function pg(r,e){for(var t,n,i,s=0,a=r.length;s<a;s++){if(n=ts(r[s],e),n===0||s>0&&(i=ts(r[s],r[s-1]),i>0&&t<=i&&n<=i&&(t+n-i)*(1-Math.pow((t-n)/i,2))<Qo*i))return!0;t=n}return!1}function mg(r,e){return!!lg(r.map(U1),gg(e))}function U1(r){return r=r.map(gg),r.pop(),r}function gg(r){return[r[0]*Ne,r[1]*Ne]}function D1(r,e){return(r&&ug.hasOwnProperty(r.type)?ug[r.type]:vl)(r,e)}function N1(r,e){var t=r[0]*Ne,n=r[1]*Ne,i=e[0]*Ne,s=e[1]*Ne,a=ze(n),o=De(n),l=ze(s),c=De(s),h=a*ze(t),u=a*De(t),f=l*ze(i),d=l*De(i),p=2*li(oi(Lm(s-n)+a*l*Lm(i-t))),_=De(p),g=p?function(m){var y=De(m*=p)/_,x=De(p-m)/_,v=x*h+y*f,M=x*u+y*d,w=x*o+y*c;return[vn(M,v)*pt,vn(w,oi(v*v+M*M))*pt]}:function(){return[t*pt,n*pt]};return g.distance=p,g}var _g=r=>r,ns=1/0,Ml=ns,la=-ns,Sl=la,F1={point:O1,lineStart:Bt,lineEnd:Bt,polygonStart:Bt,polygonEnd:Bt,result:function(){var r=[[ns,Ml],[la,Sl]];return la=Sl=-(Ml=ns=1/0),r}};function O1(r,e){r<ns&&(ns=r),r>la&&(la=r),e<Ml&&(Ml=e),e>Sl&&(Sl=e)}var xg=F1;function gu(r){return function(e){var t=new _u;for(var n in r)t[n]=r[n];return t.stream=e,t}}function _u(){}_u.prototype={constructor:_u,point:function(r,e){this.stream.point(r,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function xu(r,e,t){var n=r.clipExtent&&r.clipExtent();return r.scale(150).translate([0,0]),n!=null&&r.clipExtent(null),nl(t,r.stream(xg)),e(xg.result()),n!=null&&r.clipExtent(n),r}function yg(r,e,t){return xu(r,function(n){var i=e[1][0]-e[0][0],s=e[1][1]-e[0][1],a=Math.min(i/(n[1][0]-n[0][0]),s/(n[1][1]-n[0][1])),o=+e[0][0]+(i-a*(n[1][0]+n[0][0]))/2,l=+e[0][1]+(s-a*(n[1][1]+n[0][1]))/2;r.scale(150*a).translate([o,l])},t)}function B1(r,e,t){return yg(r,[[0,0],e],t)}function z1(r,e,t){return xu(r,function(n){var i=+e,s=i/(n[1][0]-n[0][0]),a=(i-s*(n[1][0]+n[0][0]))/2,o=-s*n[0][1];r.scale(150*s).translate([a,o])},t)}function k1(r,e,t){return xu(r,function(n){var i=+e,s=i/(n[1][1]-n[0][1]),a=-s*n[0][0],o=(i-s*(n[1][1]+n[0][1]))/2;r.scale(150*s).translate([a,o])},t)}var vg=16,G1=ze(30*Ne);function Mg(r,e){return+e?V1(r,e):H1(r)}function H1(r){return gu({point:function(e,t){e=r(e,t),this.stream.point(e[0],e[1])}})}function V1(r,e){function t(n,i,s,a,o,l,c,h,u,f,d,p,_,g){var m=c-n,y=h-i,x=m*m+y*y;if(x>4*e&&_--){var v=a+f,M=o+d,w=l+p,A=oi(v*v+M*M+w*w),C=li(w/=A),S=st(st(w)-1)<it||st(s-u)<it?(s+u)/2:vn(M,v),b=r(S,C),L=b[0],k=b[1],U=L-n,N=k-i,I=y*U-m*N;(I*I/x>e||st((m*U+y*N)/x-.5)>.3||a*f+o*d+l*p<G1)&&(t(n,i,s,a,o,l,L,k,S,v/=A,M/=A,w,_,g),g.point(L,k),t(L,k,S,v,M,w,c,h,u,f,d,p,_,g))}}return function(n){var i,s,a,o,l,c,h,u,f,d,p,_,g={point:m,lineStart:y,lineEnd:v,polygonStart:function(){n.polygonStart(),g.lineStart=M},polygonEnd:function(){n.polygonEnd(),g.lineStart=y}};function m(C,S){C=r(C,S),n.point(C[0],C[1])}function y(){u=NaN,g.point=x,n.lineStart()}function x(C,S){var b=sr([C,S]),L=r(C,S);t(u,f,h,d,p,_,u=L[0],f=L[1],h=C,d=b[0],p=b[1],_=b[2],vg,n),n.point(u,f)}function v(){g.point=m,n.lineEnd()}function M(){y(),g.point=w,g.lineEnd=A}function w(C,S){x(i=C,S),s=u,a=f,o=d,l=p,c=_,g.point=x}function A(){t(u,f,h,d,p,_,s,a,i,o,l,c,vg,n),g.lineEnd=v,v()}return g}}var W1=gu({point:function(r,e){this.stream.point(r*Ne,e*Ne)}});function X1(r){return gu({point:function(e,t){var n=r(e,t);return this.stream.point(n[0],n[1])}})}function q1(r,e,t,n,i){function s(a,o){return a*=n,o*=i,[e+r*a,t-r*o]}return s.invert=function(a,o){return[(a-e)/r*n,(t-o)/r*i]},s}function Sg(r,e,t,n,i,s){if(!s)return q1(r,e,t,n,i);var a=ze(s),o=De(s),l=a*r,c=o*r,h=a/r,u=o/r,f=(o*t-a*e)/r,d=(o*e+a*t)/r;function p(_,g){return _*=n,g*=i,[l*_-c*g+e,t-c*_-l*g]}return p.invert=function(_,g){return[n*(h*_-u*g+f),i*(d-u*_-h*g)]},p}function bg(r){return $1(function(){return r})()}function $1(r){var e,t=150,n=480,i=250,s=0,a=0,o=0,l=0,c=0,h,u=0,f=1,d=1,p=null,_=hg,g=null,m,y,x,v=_g,M=.5,w,A,C,S,b;function L(I){return C(I[0]*Ne,I[1]*Ne)}function k(I){return I=C.invert(I[0],I[1]),I&&[I[0]*pt,I[1]*pt]}L.stream=function(I){return S&&b===I?S:S=W1(X1(h)(_(w(v(b=I)))))},L.preclip=function(I){return arguments.length?(_=I,p=void 0,N()):_},L.postclip=function(I){return arguments.length?(v=I,g=m=y=x=null,N()):v},L.clipAngle=function(I){return arguments.length?(_=+I?w1(p=I*Ne):(p=null,hg),N()):p*pt},L.clipExtent=function(I){return arguments.length?(v=I==null?(g=m=y=x=null,_g):A1(g=+I[0][0],m=+I[0][1],y=+I[1][0],x=+I[1][1]),N()):g==null?null:[[g,m],[y,x]]},L.scale=function(I){return arguments.length?(t=+I,U()):t},L.translate=function(I){return arguments.length?(n=+I[0],i=+I[1],U()):[n,i]},L.center=function(I){return arguments.length?(s=I[0]%360*Ne,a=I[1]%360*Ne,U()):[s*pt,a*pt]},L.rotate=function(I){return arguments.length?(o=I[0]%360*Ne,l=I[1]%360*Ne,c=I.length>2?I[2]%360*Ne:0,U()):[o*pt,l*pt,c*pt]},L.angle=function(I){return arguments.length?(u=I%360*Ne,U()):u*pt},L.reflectX=function(I){return arguments.length?(f=I?-1:1,U()):f<0},L.reflectY=function(I){return arguments.length?(d=I?-1:1,U()):d<0},L.precision=function(I){return arguments.length?(w=Mg(A,M=I*I),N()):oi(M)},L.fitExtent=function(I,B){return yg(L,I,B)},L.fitSize=function(I,B){return B1(L,I,B)},L.fitWidth=function(I,B){return z1(L,I,B)},L.fitHeight=function(I,B){return k1(L,I,B)};function U(){var I=Sg(t,0,0,f,d,u).apply(null,e(s,a)),B=Sg(t,n-I[0],i-I[1],f,d,u);return h=Qm(o,l,c),A=hu(e,B),C=hu(h,A),w=Mg(A,M),N()}function N(){return S=b=null,L}return function(){return e=r.apply(this,arguments),L.invert=e.invert&&k,U()}}function Y1(r){return function(e,t){var n=oi(e*e+t*t),i=r(n),s=De(i),a=ze(i);return[vn(e*s,n*a),li(n&&t*s/n)]}}function yu(r,e){return[r,i1(s1((tn+e)/2))]}yu.invert=function(r,e){return[r,2*jh(n1(e))-tn]};function Z1(){return J1(yu).scale(961/nn)}function J1(r){var e=bg(r),t=e.center,n=e.scale,i=e.translate,s=e.clipExtent,a=null,o,l,c;e.scale=function(u){return arguments.length?(n(u),h()):n()},e.translate=function(u){return arguments.length?(i(u),h()):i()},e.center=function(u){return arguments.length?(t(u),h()):t()},e.clipExtent=function(u){return arguments.length?(u==null?a=o=l=c=null:(a=+u[0][0],o=+u[0][1],l=+u[1][0],c=+u[1][1]),h()):a==null?null:[[a,o],[l,c]]};function h(){var u=Je*n(),f=e(ig(e.rotate()).invert([0,0]));return s(a==null?[[f[0]-u,f[1]-u],[f[0]+u,f[1]+u]]:r===yu?[[Math.max(f[0]-u,a),o],[Math.min(f[0]+u,l),c]]:[[a,Math.max(f[1]-u,o)],[l,Math.min(f[1]+u,c)]])}return h()}function wg(r,e){var t=ze(e),n=1+ze(r)*t;return[t*De(r)/n,De(e)/n]}wg.invert=Y1(function(r){return 2*jh(r)});function K1(){return bg(wg).scale(250).clipAngle(142)}const vu={},Eg=r=>{const e=JSON.stringify(r);if(vu[e])return vu[e];const t=Z1().center(r.center).scale(r.scale).translate([0,0]).precision(.1);return vu[e]=t,t},Ag=(r,e)=>r.map(([t,n])=>{if(e){const[i,s]=e([t,n]);return new q(i,-s)}else return new q(t,n)});function j1(r,e=0){const t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},a={},o=r[0].morphTargetsRelative,l=new Fe;let c=0;for(let h=0;h<r.length;++h){const u=r[h];let f=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const d in u.attributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;s[d]===void 0&&(s[d]=[]),s[d].push(u.attributes[d]),f++}if(f!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(o!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const d in u.morphAttributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[d]===void 0&&(a[d]=[]),a[d].push(u.morphAttributes[d])}if(e){let d;if(t)d=u.index.count;else if(u.attributes.position!==void 0)d=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;if(e===1)l.addGroup(c,d,h);else if(e===2&&u.groups.length>0)for(let p of u.groups){let _=p.materialIndex;l.addGroup(c+p.start,Math.min(p.count,d),_)}c+=d}}if(t){let h=0;const u=[];for(let f=0;f<r.length;++f){const d=r[f].index;for(let p=0;p<d.count;++p)u.push(d.getX(p)+h);h+=r[f].attributes.position.count}l.setIndex(u)}for(const h in s){const u=Tg(s[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,u)}for(const h in a){const u=a[h][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let f=0;f<u;++f){const d=[];for(let _=0;_<a[h].length;++_)d.push(a[h][_][f]);const p=Tg(d);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(p)}}return e===2?Q1(l):l}function Tg(r){let e,t,n,i=-1,s=0;for(let c=0;c<r.length;++c){const h=r[c];if(h.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.array.length}const a=new e(s);let o=0;for(let c=0;c<r.length;++c)a.set(r[c].array,o),o+=r[c].array.length;const l=new Ze(a,t,n);return i!==void 0&&(l.gpuType=i),l}function Q1(r){if(r.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),r;let e=r.groups;if(e=e.sort((a,o)=>a.materialIndex!==o.materialIndex?a.materialIndex-o.materialIndex:a.start-o.start),r.getIndex()===null){const a=r.getAttribute("position"),o=[];for(let l=0;l<a.count;l+=3)o.push(l,l+1,l+2);r.setIndex(o)}const t=r.getIndex(),n=[];for(let a=0;a<e.length;a++){const o=e[a],l=o.start,c=l+o.count;for(let h=l;h<c;h++)n.push(t.getX(h))}r.dispose(),r.setIndex(n);let i=0;for(let a=0;a<e.length;a++){const o=e[a];o.start=i,i+=o.count}let s=e[0];r.groups=[s];for(let a=1;a<e.length;a++){const o=e[a];s.materialIndex===o.materialIndex?s.count+=o.count:(s=o,r.groups.push(s))}return r}var bl=(r,e)=>{const t=j1(r,e!=null?e:0),n={},i=[],s=Object.keys(t.attributes);return t.index&&s.push("index"),s.forEach(a=>{const o=a==="index"?t.index:t.attributes[a];n[a]={array:o.array,itemSize:o.itemSize},i.push(o.array.buffer)}),e&&(n.groups=t.groups),t.dispose(),r.forEach(a=>{a.dispose()}),{message:n,transfer:i}};const ew=({coordinatesArr:r,split:e,box3Set:t,depth:n,projection:i,useGroups:s,hasTop:a,hasBottom:o,hasSide:l})=>{const c=i&&Eg({center:i.center,scale:i.scale}),u=r.map(f=>Ag(f,c)).map((f,d)=>{var p;return Vb({points:f,split:e,depth:(p=n[d])!=null?p:n[0],hasTop:a,hasBottom:o,hasSide:l,box3Set:t})});return bl(u,s)};function Mu(r,e,t,n,i){let s;if(r=r.subarray||r.slice?r:r.buffer,t=t.subarray||t.slice?t:t.buffer,r=e?r.subarray?r.subarray(e,i&&e+i):r.slice(e,i&&e+i):r,t.set)t.set(r,n);else for(s=0;s<r.length;s++)t[s+n]=r[s];return t}function tw(r){return r instanceof Float32Array?r:r instanceof Fe?r.getAttribute("position").array:r.map(e=>{const t=Array.isArray(e);return e instanceof R?[e.x,e.y,e.z]:e instanceof q?[e.x,e.y,0]:t&&e.length===3?[e[0],e[1],e[2]]:t&&e.length===2?[e[0],e[1],0]:e}).flat()}class nw extends Fe{constructor(){super(),this.type="MeshLine",this.isMeshLine=!0,this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this.widthCallback=null,this._points=[],this.matrixWorld=new Be,Object.defineProperties(this,{points:{enumerable:!0,get(){return this._points},set(e){this.setPoints(e,this.widthCallback)}}})}setMatrixWorld(e){this.matrixWorld=e}setPoints(e,t){if(e=tw(e),this._points=e,this.widthCallback=t!=null?t:null,this.positions=[],this.counters=[],e.length&&e[0]instanceof R)for(let n=0;n<e.length;n++){const i=e[n],s=n/(e.length-1);this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(s),this.counters.push(s)}else for(let n=0;n<e.length;n+=3){const i=n/(e.length-1);this.positions.push(e[n],e[n+1],e[n+2]),this.positions.push(e[n],e[n+1],e[n+2]),this.counters.push(i),this.counters.push(i)}this.process()}compareV3(e,t){const n=e*6,i=t*6;return this.positions[n]===this.positions[i]&&this.positions[n+1]===this.positions[i+1]&&this.positions[n+2]===this.positions[i+2]}copyV3(e){const t=e*6;return[this.positions[t],this.positions[t+1],this.positions[t+2]]}process(){const e=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];let t,n;this.compareV3(0,e-1)?n=this.copyV3(e-2):n=this.copyV3(0),this.previous.push(n[0],n[1],n[2]),this.previous.push(n[0],n[1],n[2]);for(let i=0;i<e;i++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(i/(e-1)):t=1,this.width.push(t),this.width.push(t),this.uvs.push(i/(e-1),0),this.uvs.push(i/(e-1),1),i<e-1){n=this.copyV3(i),this.previous.push(n[0],n[1],n[2]),this.previous.push(n[0],n[1],n[2]);const s=i*2;this.indices_array.push(s,s+1,s+2),this.indices_array.push(s+2,s+1,s+3)}i>0&&(n=this.copyV3(i),this.next.push(n[0],n[1],n[2]),this.next.push(n[0],n[1],n[2]))}this.compareV3(e-1,0)?n=this.copyV3(1):n=this.copyV3(e-1),this.next.push(n[0],n[1],n[2]),this.next.push(n[0],n[1],n[2]),!this._attributes||this._attributes.position.count!==this.positions.length?this._attributes={position:new Ze(new Float32Array(this.positions),3),previous:new Ze(new Float32Array(this.previous),3),next:new Ze(new Float32Array(this.next),3),side:new Ze(new Float32Array(this.side),1),width:new Ze(new Float32Array(this.width),1),uv:new Ze(new Float32Array(this.uvs),2),index:new Ze(new Uint16Array(this.indices_array),1),counters:new Ze(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()}advance({x:e,y:t,z:n}){const i=this._attributes.position.array,s=this._attributes.previous.array,a=this._attributes.next.array,o=i.length;Mu(i,0,s,0,o),Mu(i,6,i,0,o-6),i[o-6]=e,i[o-5]=t,i[o-4]=n,i[o-3]=e,i[o-2]=t,i[o-1]=n,Mu(i,6,a,0,o-6),a[o-6]=e,a[o-5]=t,a[o-4]=n,a[o-3]=e,a[o-2]=t,a[o-1]=n,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0}}var Rg=r=>{const{setPointWidth:e,nodes:t}=r,n=new nw;return n.setPoints(t,e),n};const iw=({coordinatesArr:r,projection:e,lineWidth:t,useGroups:n})=>{const i=e&&Eg({center:e.center,scale:e.scale}),a=r.map(o=>Ag(o,i)).map((o,l)=>{var h;const c=(h=t[l])!=null?h:t[0];return Rg({nodes:o,setPointWidth:()=>c})});return bl(a,n)};var is={},rw={get exports(){return is},set exports(r){is=r}};rw.exports=wl,is.default=wl;function wl(r,e,t){t=t||2;var n=e&&e.length,i=n?e[0]*t:r.length,s=Cg(r,0,i,t,!0),a=[];if(!s||s.next===s.prev)return a;var o,l,c,h,u,f,d;if(n&&(s=cw(r,e,s,t)),r.length>80*t){o=c=r[0],l=h=r[1];for(var p=t;p<i;p+=t)u=r[p],f=r[p+1],u<o&&(o=u),f<l&&(l=f),u>c&&(c=u),f>h&&(h=f);d=Math.max(c-o,h-l),d=d!==0?32767/d:0}return ca(s,a,t,o,l,d,0),a}function Cg(r,e,t,n,i){var s,a;if(i===wu(r,e,t,n)>0)for(s=e;s<t;s+=n)a=Ig(s,r[s],r[s+1],a);else for(s=t-n;s>=e;s-=n)a=Ig(s,r[s],r[s+1],a);return a&&El(a,a.next)&&(ua(a),a=a.next),a}function or(r,e){if(!r)return r;e||(e=r);var t=r,n;do if(n=!1,!t.steiner&&(El(t,t.next)||ht(t.prev,t,t.next)===0)){if(ua(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function ca(r,e,t,n,i,s,a){if(r){!a&&s&&pw(r,n,i,s);for(var o=r,l,c;r.prev!==r.next;){if(l=r.prev,c=r.next,s?aw(r,n,i,s):sw(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(c.i/t|0),ua(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=ow(or(r),e,t),ca(r,e,t,n,i,s,2)):a===2&&lw(r,e,t,n,i,s):ca(or(r),e,t,n,i,s,1);break}}}}function sw(r){var e=r.prev,t=r,n=r.next;if(ht(e,t,n)>=0)return!1;for(var i=e.x,s=t.x,a=n.x,o=e.y,l=t.y,c=n.y,h=i<s?i<a?i:a:s<a?s:a,u=o<l?o<c?o:c:l<c?l:c,f=i>s?i>a?i:a:s>a?s:a,d=o>l?o>c?o:c:l>c?l:c,p=n.next;p!==e;){if(p.x>=h&&p.x<=f&&p.y>=u&&p.y<=d&&rs(i,o,s,l,a,c,p.x,p.y)&&ht(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function aw(r,e,t,n){var i=r.prev,s=r,a=r.next;if(ht(i,s,a)>=0)return!1;for(var o=i.x,l=s.x,c=a.x,h=i.y,u=s.y,f=a.y,d=o<l?o<c?o:c:l<c?l:c,p=h<u?h<f?h:f:u<f?u:f,_=o>l?o>c?o:c:l>c?l:c,g=h>u?h>f?h:f:u>f?u:f,m=Su(d,p,e,t,n),y=Su(_,g,e,t,n),x=r.prevZ,v=r.nextZ;x&&x.z>=m&&v&&v.z<=y;){if(x.x>=d&&x.x<=_&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&rs(o,h,l,u,c,f,x.x,x.y)&&ht(x.prev,x,x.next)>=0||(x=x.prevZ,v.x>=d&&v.x<=_&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&rs(o,h,l,u,c,f,v.x,v.y)&&ht(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;x&&x.z>=m;){if(x.x>=d&&x.x<=_&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&rs(o,h,l,u,c,f,x.x,x.y)&&ht(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=d&&v.x<=_&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&rs(o,h,l,u,c,f,v.x,v.y)&&ht(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function ow(r,e,t){var n=r;do{var i=n.prev,s=n.next.next;!El(i,s)&&Pg(i,n,n.next,s)&&ha(i,s)&&ha(s,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),ua(n),ua(n.next),n=r=s),n=n.next}while(n!==r);return or(n)}function lw(r,e,t,n,i,s){var a=r;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&_w(a,o)){var l=Lg(a,o);a=or(a,a.next),l=or(l,l.next),ca(a,e,t,n,i,s,0),ca(l,e,t,n,i,s,0);return}o=o.next}a=a.next}while(a!==r)}function cw(r,e,t,n){var i=[],s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*n,l=s<a-1?e[s+1]*n:r.length,c=Cg(r,o,l,n,!1),c===c.next&&(c.steiner=!0),i.push(gw(c));for(i.sort(hw),s=0;s<i.length;s++)t=uw(i[s],t);return t}function hw(r,e){return r.x-e.x}function uw(r,e){var t=fw(r,e);if(!t)return e;var n=Lg(t,r);return or(n,n.next),or(t,t.next)}function fw(r,e){var t=e,n=r.x,i=r.y,s=-1/0,a;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){var o=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(o<=n&&o>s&&(s=o,a=t.x<t.next.x?t:t.next,o===n))return a}t=t.next}while(t!==e);if(!a)return null;var l=a,c=a.x,h=a.y,u=1/0,f;t=a;do n>=t.x&&t.x>=c&&n!==t.x&&rs(i<h?n:s,i,c,h,i<h?s:n,i,t.x,t.y)&&(f=Math.abs(i-t.y)/(n-t.x),ha(t,r)&&(f<u||f===u&&(t.x>a.x||t.x===a.x&&dw(a,t)))&&(a=t,u=f)),t=t.next;while(t!==l);return a}function dw(r,e){return ht(r.prev,r,e.prev)<0&&ht(e.next,r,r.next)<0}function pw(r,e,t,n){var i=r;do i.z===0&&(i.z=Su(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,mw(i)}function mw(r){var e,t,n,i,s,a,o,l,c=1;do{for(t=r,r=null,s=null,a=0;t;){for(a++,n=t,o=0,e=0;e<c&&(o++,n=n.nextZ,!!n);e++);for(l=c;o>0||l>0&&n;)o!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,o--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(a>1);return r}function Su(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function gw(r){var e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function rs(r,e,t,n,i,s,a,o){return(i-a)*(e-o)>=(r-a)*(s-o)&&(r-a)*(n-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(i-a)*(n-o)}function _w(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!xw(r,e)&&(ha(r,e)&&ha(e,r)&&yw(r,e)&&(ht(r.prev,r,e.prev)||ht(r,e.prev,e))||El(r,e)&&ht(r.prev,r,r.next)>0&&ht(e.prev,e,e.next)>0)}function ht(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function El(r,e){return r.x===e.x&&r.y===e.y}function Pg(r,e,t,n){var i=Tl(ht(r,e,t)),s=Tl(ht(r,e,n)),a=Tl(ht(t,n,r)),o=Tl(ht(t,n,e));return!!(i!==s&&a!==o||i===0&&Al(r,t,e)||s===0&&Al(r,n,e)||a===0&&Al(t,r,n)||o===0&&Al(t,e,n))}function Al(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Tl(r){return r>0?1:r<0?-1:0}function xw(r,e){var t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Pg(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function ha(r,e){return ht(r.prev,r,r.next)<0?ht(r,e,r.next)>=0&&ht(r,r.prev,e)>=0:ht(r,e,r.prev)<0||ht(r,r.next,e)<0}function yw(r,e){var t=r,n=!1,i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function Lg(r,e){var t=new bu(r.i,r.x,r.y),n=new bu(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Ig(r,e,t,n){var i=new bu(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function ua(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function bu(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}wl.deviation=function(r,e,t,n){var i=e&&e.length,s=i?e[0]*t:r.length,a=Math.abs(wu(r,0,s,t));if(i)for(var o=0,l=e.length;o<l;o++){var c=e[o]*t,h=o<l-1?e[o+1]*t:r.length;a-=Math.abs(wu(r,c,h,t))}var u=0;for(o=0;o<n.length;o+=3){var f=n[o]*t,d=n[o+1]*t,p=n[o+2]*t;u+=Math.abs((r[f]-r[p])*(r[d+1]-r[f+1])-(r[f]-r[d])*(r[p+1]-r[f+1]))}return a===0&&u===0?0:Math.abs((u-a)/a)};function wu(r,e,t,n){for(var i=0,s=e,a=t-n;s<t;s+=n)i+=(r[a]-r[s])*(r[s+1]+r[a+1]),a=s;return i}wl.flatten=function(r){for(var e=r[0][0].length,t={vertices:[],holes:[],dimensions:e},n=0,i=0;i<r.length;i++){for(var s=0;s<r[i].length;s++)for(var a=0;a<e;a++)t.vertices.push(r[i][s][a]);i>0&&(n+=r[i-1].length,t.holes.push(n))}return t};function vw(r){if(!r)throw new Error("coord is required");if(!Array.isArray(r)){if(r.type==="Feature"&&r.geometry!==null&&r.geometry.type==="Point")return r.geometry.coordinates;if(r.type==="Point")return r.coordinates}if(Array.isArray(r)&&r.length>=2&&!Array.isArray(r[0])&&!Array.isArray(r[1]))return r;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Mw(r){if(Array.isArray(r))return r;if(r.type==="Feature"){if(r.geometry!==null)return r.geometry.coordinates}else if(r.coordinates)return r.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Sw(r){return r.type==="Feature"?r.geometry:r}function bw(r){for(var e=Mw(r),t=0,n=1,i,s;n<e.length;)i=s||e[0],s=e[n],t+=(s[0]-i[0])*(s[1]+i[1]),n++;return t>0}function ww(r,e,t=0){const n=(90-e)*Math.PI/180,i=(90-r)*Math.PI/180;return[t*Math.sin(n)*Math.cos(i),t*Math.cos(n),t*Math.sin(n)*Math.sin(i)]}const fi=11102230246251565e-32,zt=134217729,Ew=(3+8*fi)*fi;function Eu(r,e,t,n,i){let s,a,o,l,c=e[0],h=n[0],u=0,f=0;h>c==h>-c?(s=c,c=e[++u]):(s=h,h=n[++f]);let d=0;if(u<r&&f<t)for(h>c==h>-c?(a=c+s,o=s-(a-c),c=e[++u]):(a=h+s,o=s-(a-h),h=n[++f]),s=a,o!==0&&(i[d++]=o);u<r&&f<t;)h>c==h>-c?(a=s+c,l=a-s,o=s-(a-l)+(c-l),c=e[++u]):(a=s+h,l=a-s,o=s-(a-l)+(h-l),h=n[++f]),s=a,o!==0&&(i[d++]=o);for(;u<r;)a=s+c,l=a-s,o=s-(a-l)+(c-l),c=e[++u],s=a,o!==0&&(i[d++]=o);for(;f<t;)a=s+h,l=a-s,o=s-(a-l)+(h-l),h=n[++f],s=a,o!==0&&(i[d++]=o);return(s!==0||d===0)&&(i[d++]=s),d}function Aw(r,e){let t=e[0];for(let n=1;n<r;n++)t+=e[n];return t}function fa(r){return new Float64Array(r)}const Tw=(3+16*fi)*fi,Rw=(2+12*fi)*fi,Cw=(9+64*fi)*fi*fi,ss=fa(4),Ug=fa(8),Dg=fa(12),Ng=fa(16),$t=fa(4);function Pw(r,e,t,n,i,s,a){let o,l,c,h,u,f,d,p,_,g,m,y,x,v,M,w,A,C;const S=r-i,b=t-i,L=e-s,k=n-s;v=S*k,f=zt*S,d=f-(f-S),p=S-d,f=zt*k,_=f-(f-k),g=k-_,M=p*g-(v-d*_-p*_-d*g),w=L*b,f=zt*L,d=f-(f-L),p=L-d,f=zt*b,_=f-(f-b),g=b-_,A=p*g-(w-d*_-p*_-d*g),m=M-A,u=M-m,ss[0]=M-(m+u)+(u-A),y=v+m,u=y-v,x=v-(y-u)+(m-u),m=x-w,u=x-m,ss[1]=x-(m+u)+(u-w),C=y+m,u=C-y,ss[2]=y-(C-u)+(m-u),ss[3]=C;let U=Aw(4,ss),N=Rw*a;if(U>=N||-U>=N||(u=r-S,o=r-(S+u)+(u-i),u=t-b,c=t-(b+u)+(u-i),u=e-L,l=e-(L+u)+(u-s),u=n-k,h=n-(k+u)+(u-s),o===0&&l===0&&c===0&&h===0)||(N=Cw*a+Ew*Math.abs(U),U+=S*h+k*o-(L*c+b*l),U>=N||-U>=N))return U;v=o*k,f=zt*o,d=f-(f-o),p=o-d,f=zt*k,_=f-(f-k),g=k-_,M=p*g-(v-d*_-p*_-d*g),w=l*b,f=zt*l,d=f-(f-l),p=l-d,f=zt*b,_=f-(f-b),g=b-_,A=p*g-(w-d*_-p*_-d*g),m=M-A,u=M-m,$t[0]=M-(m+u)+(u-A),y=v+m,u=y-v,x=v-(y-u)+(m-u),m=x-w,u=x-m,$t[1]=x-(m+u)+(u-w),C=y+m,u=C-y,$t[2]=y-(C-u)+(m-u),$t[3]=C;const I=Eu(4,ss,4,$t,Ug);v=S*h,f=zt*S,d=f-(f-S),p=S-d,f=zt*h,_=f-(f-h),g=h-_,M=p*g-(v-d*_-p*_-d*g),w=L*c,f=zt*L,d=f-(f-L),p=L-d,f=zt*c,_=f-(f-c),g=c-_,A=p*g-(w-d*_-p*_-d*g),m=M-A,u=M-m,$t[0]=M-(m+u)+(u-A),y=v+m,u=y-v,x=v-(y-u)+(m-u),m=x-w,u=x-m,$t[1]=x-(m+u)+(u-w),C=y+m,u=C-y,$t[2]=y-(C-u)+(m-u),$t[3]=C;const B=Eu(I,Ug,4,$t,Dg);v=o*h,f=zt*o,d=f-(f-o),p=o-d,f=zt*h,_=f-(f-h),g=h-_,M=p*g-(v-d*_-p*_-d*g),w=l*c,f=zt*l,d=f-(f-l),p=l-d,f=zt*c,_=f-(f-c),g=c-_,A=p*g-(w-d*_-p*_-d*g),m=M-A,u=M-m,$t[0]=M-(m+u)+(u-A),y=v+m,u=y-v,x=v-(y-u)+(m-u),m=x-w,u=x-m,$t[1]=x-(m+u)+(u-w),C=y+m,u=C-y,$t[2]=y-(C-u)+(m-u),$t[3]=C;const O=Eu(B,Dg,4,$t,Ng);return Ng[O-1]}function Rl(r,e,t,n,i,s){const a=(e-s)*(t-i),o=(r-i)*(n-s),l=a-o;if(a===0||o===0||a>0!=o>0)return l;const c=Math.abs(a+o);return Math.abs(l)>=Tw*c?l:-Pw(r,e,t,n,i,s,c)}const Fg=Math.pow(2,-52),Cl=new Uint32Array(512);class da{static from(e,t=Nw,n=Fw){const i=e.length,s=new Float64Array(i*2);for(let a=0;a<i;a++){const o=e[a];s[2*a]=t(o),s[2*a+1]=n(o)}return new da(s)}constructor(e){const t=e.length>>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:n,_hullTri:i,_hullHash:s}=this,a=e.length>>1;let o=1/0,l=1/0,c=-1/0,h=-1/0;for(let b=0;b<a;b++){const L=e[2*b],k=e[2*b+1];L<o&&(o=L),k<l&&(l=k),L>c&&(c=L),k>h&&(h=k),this._ids[b]=b}const u=(o+c)/2,f=(l+h)/2;let d=1/0,p,_,g;for(let b=0;b<a;b++){const L=Au(u,f,e[2*b],e[2*b+1]);L<d&&(p=b,d=L)}const m=e[2*p],y=e[2*p+1];d=1/0;for(let b=0;b<a;b++){if(b===p)continue;const L=Au(m,y,e[2*b],e[2*b+1]);L<d&&L>0&&(_=b,d=L)}let x=e[2*_],v=e[2*_+1],M=1/0;for(let b=0;b<a;b++){if(b===p||b===_)continue;const L=Uw(m,y,x,v,e[2*b],e[2*b+1]);L<M&&(g=b,M=L)}let w=e[2*g],A=e[2*g+1];if(M===1/0){for(let k=0;k<a;k++)this._dists[k]=e[2*k]-e[0]||e[2*k+1]-e[1];as(this._ids,this._dists,0,a-1);const b=new Uint32Array(a);let L=0;for(let k=0,U=-1/0;k<a;k++){const N=this._ids[k];this._dists[N]>U&&(b[L++]=N,U=this._dists[N])}this.hull=b.subarray(0,L),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(Rl(m,y,x,v,w,A)<0){const b=_,L=x,k=v;_=g,x=w,v=A,g=b,w=L,A=k}const C=Dw(m,y,x,v,w,A);this._cx=C.x,this._cy=C.y;for(let b=0;b<a;b++)this._dists[b]=Au(e[2*b],e[2*b+1],C.x,C.y);as(this._ids,this._dists,0,a-1),this._hullStart=p;let S=3;n[p]=t[g]=_,n[_]=t[p]=g,n[g]=t[_]=p,i[p]=0,i[_]=1,i[g]=2,s.fill(-1),s[this._hashKey(m,y)]=p,s[this._hashKey(x,v)]=_,s[this._hashKey(w,A)]=g,this.trianglesLen=0,this._addTriangle(p,_,g,-1,-1,-1);for(let b=0,L,k;b<this._ids.length;b++){const U=this._ids[b],N=e[2*U],I=e[2*U+1];if(b>0&&Math.abs(N-L)<=Fg&&Math.abs(I-k)<=Fg||(L=N,k=I,U===p||U===_||U===g))continue;let B=0;for(let z=0,Z=this._hashKey(N,I);z<this._hashSize&&(B=s[(Z+z)%this._hashSize],!(B!==-1&&B!==n[B]));z++);B=t[B];let O=B,H;for(;H=n[O],Rl(N,I,e[2*O],e[2*O+1],e[2*H],e[2*H+1])>=0;)if(O=H,O===B){O=-1;break}if(O===-1)continue;let X=this._addTriangle(O,U,n[O],-1,-1,i[O]);i[U]=this._legalize(X+2),i[O]=X,S++;let ee=n[O];for(;H=n[ee],Rl(N,I,e[2*ee],e[2*ee+1],e[2*H],e[2*H+1])<0;)X=this._addTriangle(ee,U,H,i[U],-1,i[ee]),i[U]=this._legalize(X+2),n[ee]=ee,S--,ee=H;if(O===B)for(;H=t[O],Rl(N,I,e[2*H],e[2*H+1],e[2*O],e[2*O+1])<0;)X=this._addTriangle(H,U,O,-1,i[O],i[H]),this._legalize(X+2),i[H]=X,n[O]=O,S--,O=H;this._hullStart=t[U]=O,n[O]=t[ee]=U,n[U]=ee,s[this._hashKey(N,I)]=U,s[this._hashKey(e[2*O],e[2*O+1])]=O}this.hull=new Uint32Array(S);for(let b=0,L=this._hullStart;b<S;b++)this.hull[b]=L,L=n[L];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(e,t){return Math.floor(Lw(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){const{_triangles:t,_halfedges:n,coords:i}=this;let s=0,a=0;for(;;){const o=n[e],l=e-e%3;if(a=l+(e+2)%3,o===-1){if(s===0)break;e=Cl[--s];continue}const c=o-o%3,h=l+(e+1)%3,u=c+(o+2)%3,f=t[a],d=t[e],p=t[h],_=t[u];if(Iw(i[2*f],i[2*f+1],i[2*d],i[2*d+1],i[2*p],i[2*p+1],i[2*_],i[2*_+1])){t[e]=_,t[o]=f;const m=n[u];if(m===-1){let x=this._hullStart;do{if(this._hullTri[x]===u){this._hullTri[x]=e;break}x=this._hullPrev[x]}while(x!==this._hullStart)}this._link(e,m),this._link(o,n[a]),this._link(a,u);const y=c+(o+1)%3;s<Cl.length&&(Cl[s++]=y)}else{if(s===0)break;e=Cl[--s]}}return a}_link(e,t){this._halfedges[e]=t,t!==-1&&(this._halfedges[t]=e)}_addTriangle(e,t,n,i,s,a){const o=this.trianglesLen;return this._triangles[o]=e,this._triangles[o+1]=t,this._triangles[o+2]=n,this._link(o,i),this._link(o+1,s),this._link(o+2,a),this.trianglesLen+=3,o}}function Lw(r,e){const t=r/(Math.abs(r)+Math.abs(e));return(e>0?3-t:1+t)/4}function Au(r,e,t,n){const i=r-t,s=e-n;return i*i+s*s}function Iw(r,e,t,n,i,s,a,o){const l=r-a,c=e-o,h=t-a,u=n-o,f=i-a,d=s-o,p=l*l+c*c,_=h*h+u*u,g=f*f+d*d;return l*(u*g-_*d)-c*(h*g-_*f)+p*(h*d-u*f)<0}function Uw(r,e,t,n,i,s){const a=t-r,o=n-e,l=i-r,c=s-e,h=a*a+o*o,u=l*l+c*c,f=.5/(a*c-o*l),d=(c*h-o*u)*f,p=(a*u-l*h)*f;return d*d+p*p}function Dw(r,e,t,n,i,s){const a=t-r,o=n-e,l=i-r,c=s-e,h=a*a+o*o,u=l*l+c*c,f=.5/(a*c-o*l),d=r+(c*h-o*u)*f,p=e+(a*u-l*h)*f;return{x:d,y:p}}function as(r,e,t,n){if(n-t<=20)for(let i=t+1;i<=n;i++){const s=r[i],a=e[s];let o=i-1;for(;o>=t&&e[r[o]]>a;)r[o+1]=r[o--];r[o+1]=s}else{const i=t+n>>1;let s=t+1,a=n;pa(r,i,s),e[r[t]]>e[r[n]]&&pa(r,t,n),e[r[s]]>e[r[n]]&&pa(r,s,n),e[r[t]]>e[r[s]]&&pa(r,t,s);const o=r[s],l=e[o];for(;;){do s++;while(e[r[s]]<l);do a--;while(e[r[a]]>l);if(a<s)break;pa(r,s,a)}r[t+1]=r[a],r[a]=o,n-s+1>=a-t?(as(r,e,s,n),as(r,e,t,a-1)):(as(r,e,t,a-1),as(r,e,s,n))}}function pa(r,e,t){const n=r[e];r[e]=r[t],r[t]=n}function Nw(r){return r[0]}function Fw(r){return r[1]}function Ow(r,e,t){if(t===void 0&&(t={}),!r)throw new Error("point is required");if(!e)throw new Error("polygon is required");var n=vw(r),i=Sw(e),s=i.type,a=e.bbox,o=i.coordinates;if(a&&Bw(n,a)===!1)return!1;s==="Polygon"&&(o=[o]);for(var l=!1,c=0;c<o.length&&!l;c++)if(Og(n,o[c][0],t.ignoreBoundary)){for(var h=!1,u=1;u<o[c].length&&!h;)Og(n,o[c][u],!t.ignoreBoundary)&&(h=!0),u++;h||(l=!0)}return l}function Og(r,e,t){var n=!1;e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]&&(e=e.slice(0,e.length-1));for(var i=0,s=e.length-1;i<e.length;s=i++){var a=e[i][0],o=e[i][1],l=e[s][0],c=e[s][1],h=r[1]*(a-l)+o*(l-r[0])+c*(r[0]-a)===0&&(a-r[0])*(l-r[0])<=0&&(o-r[1])*(c-r[1])<=0;if(h)return!t;var u=o>r[1]!=c>r[1]&&r[0]<(l-a)*(r[1]-o)/(c-o)+a;u&&(n=!n)}return n}function Bw(r,e){return e[0]<=r[0]&&e[1]<=r[1]&&e[2]>=r[0]&&e[3]>=r[1]}const Bg=1e-6;class lr{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;const i=e+n,s=t;if(n<0)throw new Error("negative radius");this._x1===null?this._+=`M${i},${s}`:(Math.abs(this._x1-i)>Bg||Math.abs(this._y1-s)>Bg)&&(this._+="L"+i+","+s),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=i},${this._y1=s}`)}rect(e,t,n,i){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+i}h${-n}Z`}value(){return this._||null}}class Tu{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class zw{constructor(e,[t,n,i,s]=[0,0,960,500]){if(!((i=+i)>=(t=+t))||!((s=+s)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=i,this.xmin=t,this.ymax=s,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:i}=this,s=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let d=0,p=0,_=n.length,g,m;d<_;d+=3,p+=2){const y=n[d]*2,x=n[d+1]*2,v=n[d+2]*2,M=e[y],w=e[y+1],A=e[x],C=e[x+1],S=e[v],b=e[v+1],L=A-M,k=C-w,U=S-M,N=b-w,I=(L*N-k*U)*2;if(Math.abs(I)<1e-9){let B=1e9;const O=n[0]*2;B*=Math.sign((e[O]-M)*N-(e[O+1]-w)*U),g=(M+S)/2-B*N,m=(w+b)/2+B*U}else{const B=1/I,O=L*L+k*k,H=U*U+N*N;g=M+(N*O-k*H)*B,m=w+(L*H-U*O)*B}s[p]=g,s[p+1]=m}let a=t[t.length-1],o,l=a*4,c,h=e[2*a],u,f=e[2*a+1];i.fill(0);for(let d=0;d<t.length;++d)a=t[d],o=l,c=h,u=f,l=a*4,h=e[2*a],f=e[2*a+1],i[o+2]=i[l]=u-f,i[o+3]=i[l+1]=h-c}render(e){const t=e==null?e=new lr:void 0,{delaunay:{halfedges:n,inedges:i,hull:s},circumcenters:a,vectors:o}=this;if(s.length<=1)return null;for(let h=0,u=n.length;h<u;++h){const f=n[h];if(f<h)continue;const d=Math.floor(h/3)*2,p=Math.floor(f/3)*2,_=a[d],g=a[d+1],m=a[p],y=a[p+1];this._renderSegment(_,g,m,y,e)}let l,c=s[s.length-1];for(let h=0;h<s.length;++h){l=c,c=s[h];const u=Math.floor(i[c]/3)*2,f=a[u],d=a[u+1],p=l*4,_=this._project(f,d,o[p+2],o[p+3]);_&&this._renderSegment(f,d,_[0],_[1],e)}return t&&t.value()}renderBounds(e){const t=e==null?e=new lr:void 0;return e.rect(this.xmin,this.ymin,this.xmax-this.xmin,this.ymax-this.ymin),t&&t.value()}renderCell(e,t){const n=t==null?t=new lr:void 0,i=this._clip(e);if(i===null||!i.length)return;t.moveTo(i[0],i[1]);let s=i.length;for(;i[0]===i[s-2]&&i[1]===i[s-1]&&s>1;)s-=2;for(let a=2;a<s;a+=2)(i[a]!==i[a-2]||i[a+1]!==i[a-1])&&t.lineTo(i[a],i[a+1]);return t.closePath(),n&&n.value()}*cellPolygons(){const{delaunay:{points:e}}=this;for(let t=0,n=e.length/2;t<n;++t){const i=this.cellPolygon(t);i&&(i.index=t,yield i)}}cellPolygon(e){const t=new Tu;return this.renderCell(e,t),t.value()}_renderSegment(e,t,n,i,s){let a;const o=this._regioncode(e,t),l=this._regioncode(n,i);o===0&&l===0?(s.moveTo(e,t),s.lineTo(n,i)):(a=this._clipSegment(e,t,n,i,o,l))&&(s.moveTo(a[0],a[1]),s.lineTo(a[2],a[3]))}contains(e,t,n){return t=+t,t!==t||(n=+n,n!==n)?!1:this.delaunay._step(e,t,n)===e}*neighbors(e){const t=this._clip(e);if(t)for(const n of this.delaunay.neighbors(e)){const i=this._clip(n);if(i){e:for(let s=0,a=t.length;s<a;s+=2)for(let o=0,l=i.length;o<l;o+=2)if(t[s]==i[o]&&t[s+1]==i[o+1]&&t[(s+2)%a]==i[(o+l-2)%l]&&t[(s+3)%a]==i[(o+l-1)%l]){yield n;break e}}}}_cell(e){const{circumcenters:t,delaunay:{inedges:n,halfedges:i,triangles:s}}=this,a=n[e];if(a===-1)return null;const o=[];let l=a;do{const c=Math.floor(l/3);if(o.push(t[c*2],t[c*2+1]),l=l%3===2?l-2:l+1,s[l]!==e)break;l=i[l]}while(l!==a&&l!==-1);return o}_clip(e){if(e===0&&this.delaunay.hull.length===1)return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];const t=this._cell(e);if(t===null)return null;const{vectors:n}=this,i=e*4;return n[i]||n[i+1]?this._clipInfinite(e,t,n[i],n[i+1],n[i+2],n[i+3]):this._clipFinite(e,t)}_clipFinite(e,t){const n=t.length;let i=null,s,a,o=t[n-2],l=t[n-1],c,h=this._regioncode(o,l),u,f=0;for(let d=0;d<n;d+=2)if(s=o,a=l,o=t[d],l=t[d+1],c=h,h=this._regioncode(o,l),c===0&&h===0)u=f,f=0,i?i.push(o,l):i=[o,l];else{let p,_,g,m,y;if(c===0){if((p=this._clipSegment(s,a,o,l,c,h))===null)continue;[_,g,m,y]=p}else{if((p=this._clipSegment(o,l,s,a,h,c))===null)continue;[m,y,_,g]=p,u=f,f=this._edgecode(_,g),u&&f&&this._edge(e,u,f,i,i.length),i?i.push(_,g):i=[_,g]}u=f,f=this._edgecode(m,y),u&&f&&this._edge(e,u,f,i,i.length),i?i.push(m,y):i=[m,y]}if(i)u=f,f=this._edgecode(i[0],i[1]),u&&f&&this._edge(e,u,f,i,i.length);else if(this.contains(e,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2))return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];return i}_clipSegment(e,t,n,i,s,a){for(;;){if(s===0&&a===0)return[e,t,n,i];if(s&a)return null;let o,l,c=s||a;c&8?(o=e+(n-e)*(this.ymax-t)/(i-t),l=this.ymax):c&4?(o=e+(n-e)*(this.ymin-t)/(i-t),l=this.ymin):c&2?(l=t+(i-t)*(this.xmax-e)/(n-e),o=this.xmax):(l=t+(i-t)*(this.xmin-e)/(n-e),o=this.xmin),s?(e=o,t=l,s=this._regioncode(e,t)):(n=o,i=l,a=this._regioncode(n,i))}}_clipInfinite(e,t,n,i,s,a){let o=Array.from(t),l;if((l=this._project(o[0],o[1],n,i))&&o.unshift(l[0],l[1]),(l=this._project(o[o.length-2],o[o.length-1],s,a))&&o.push(l[0],l[1]),o=this._clipFinite(e,o))for(let c=0,h=o.length,u,f=this._edgecode(o[h-2],o[h-1]);c<h;c+=2)u=f,f=this._edgecode(o[c],o[c+1]),u&&f&&(c=this._edge(e,u,f,o,c),h=o.length);else this.contains(e,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2)&&(o=[this.xmin,this.ymin,this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax]);return o}_edge(e,t,n,i,s){for(;t!==n;){let a,o;switch(t){case 5:t=4;continue;case 4:t=6,a=this.xmax,o=this.ymin;break;case 6:t=2;continue;case 2:t=10,a=this.xmax,o=this.ymax;break;case 10:t=8;continue;case 8:t=9,a=this.xmin,o=this.ymax;break;case 9:t=1;continue;case 1:t=5,a=this.xmin,o=this.ymin;break}(i[s]!==a||i[s+1]!==o)&&this.contains(e,a,o)&&(i.splice(s,0,a,o),s+=2)}if(i.length>4)for(let a=0;a<i.length;a+=2){const o=(a+2)%i.length,l=(a+4)%i.length;(i[a]===i[o]&&i[o]===i[l]||i[a+1]===i[o+1]&&i[o+1]===i[l+1])&&(i.splice(o,2),a-=2)}return s}_project(e,t,n,i){let s=1/0,a,o,l;if(i<0){if(t<=this.ymin)return null;(a=(this.ymin-t)/i)<s&&(l=this.ymin,o=e+(s=a)*n)}else if(i>0){if(t>=this.ymax)return null;(a=(this.ymax-t)/i)<s&&(l=this.ymax,o=e+(s=a)*n)}if(n>0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)<s&&(o=this.xmax,l=t+(s=a)*i)}else if(n<0){if(e<=this.xmin)return null;(a=(this.xmin-e)/n)<s&&(o=this.xmin,l=t+(s=a)*i)}return[o,l]}_edgecode(e,t){return(e===this.xmin?1:e===this.xmax?2:0)|(t===this.ymin?4:t===this.ymax?8:0)}_regioncode(e,t){return(e<this.xmin?1:e>this.xmax?2:0)|(t<this.ymin?4:t>this.ymax?8:0)}}const kw=2*Math.PI,os=Math.pow;function Gw(r){return r[0]}function Hw(r){return r[1]}function Vw(r){const{triangles:e,coords:t}=r;for(let n=0;n<e.length;n+=3){const i=2*e[n],s=2*e[n+1],a=2*e[n+2];if((t[a]-t[i])*(t[s+1]-t[i+1])-(t[s]-t[i])*(t[a+1]-t[i+1])>1e-10)return!1}return!0}function Ww(r,e,t){return[r+Math.sin(r+e)*t,e+Math.cos(r-e)*t]}class Ru{static from(e,t=Gw,n=Hw,i){return new Ru("length"in e?Xw(e,t,n,i):Float64Array.from(qw(e,t,n,i)))}constructor(e){this._delaunator=new da(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&Vw(e)){this.collinear=Int32Array.from({length:t.length/2},(f,d)=>d).sort((f,d)=>t[2*f]-t[2*d]||t[2*f+1]-t[2*d+1]);const l=this.collinear[0],c=this.collinear[this.collinear.length-1],h=[t[2*l],t[2*l+1],t[2*c],t[2*c+1]],u=1e-8*Math.hypot(h[3]-h[1],h[2]-h[0]);for(let f=0,d=t.length/2;f<d;++f){const p=Ww(t[2*f],t[2*f+1],u);t[2*f]=p[0],t[2*f+1]=p[1]}this._delaunator=new da(t)}else delete this.collinear;const n=this.halfedges=this._delaunator.halfedges,i=this.hull=this._delaunator.hull,s=this.triangles=this._delaunator.triangles,a=this.inedges.fill(-1),o=this._hullIndex.fill(-1);for(let l=0,c=n.length;l<c;++l){const h=s[l%3===2?l-2:l+1];(n[l]===-1||a[h]===-1)&&(a[h]=l)}for(let l=0,c=i.length;l<c;++l)o[i[l]]=l;i.length<=2&&i.length>0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=i[0],a[i[0]]=1,i.length===2&&(a[i[1]]=0,this.triangles[1]=i[1],this.triangles[2]=i[1]))}voronoi(e){return new zw(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:i,halfedges:s,triangles:a,collinear:o}=this;if(o){const u=o.indexOf(e);u>0&&(yield o[u-1]),u<o.length-1&&(yield o[u+1]);return}const l=t[e];if(l===-1)return;let c=l,h=-1;do{if(yield h=a[c],c=c%3===2?c-2:c+1,a[c]!==e)return;if(c=s[c],c===-1){const u=n[(i[e]+1)%n.length];u!==h&&(yield u);return}}while(c!==l)}find(e,t,n=0){if(e=+e,e!==e||(t=+t,t!==t))return-1;const i=n;let s;for(;(s=this._step(n,e,t))>=0&&s!==n&&s!==i;)n=s;return s}_step(e,t,n){const{inedges:i,hull:s,_hullIndex:a,halfedges:o,triangles:l,points:c}=this;if(i[e]===-1||!c.length)return(e+1)%(c.length>>1);let h=e,u=os(t-c[e*2],2)+os(n-c[e*2+1],2);const f=i[e];let d=f;do{let p=l[d];const _=os(t-c[p*2],2)+os(n-c[p*2+1],2);if(_<u&&(u=_,h=p),d=d%3===2?d-2:d+1,l[d]!==e)break;if(d=o[d],d===-1){if(d=s[(a[e]+1)%s.length],d!==p&&os(t-c[d*2],2)+os(n-c[d*2+1],2)<u)return d;break}}while(d!==f);return h}render(e){const t=e==null?e=new lr:void 0,{points:n,halfedges:i,triangles:s}=this;for(let a=0,o=i.length;a<o;++a){const l=i[a];if(l<a)continue;const c=s[a]*2,h=s[l]*2;e.moveTo(n[c],n[c+1]),e.lineTo(n[h],n[h+1])}return this.renderHull(e),t&&t.value()}renderPoints(e,t){t===void 0&&(!e||typeof e.moveTo!="function")&&(t=e,e=null),t=t==null?2:+t;const n=e==null?e=new lr:void 0,{points:i}=this;for(let s=0,a=i.length;s<a;s+=2){const o=i[s],l=i[s+1];e.moveTo(o+t,l),e.arc(o,l,t,0,kw)}return n&&n.value()}renderHull(e){const t=e==null?e=new lr:void 0,{hull:n,points:i}=this,s=n[0]*2,a=n.length;e.moveTo(i[s],i[s+1]);for(let o=1;o<a;++o){const l=2*n[o];e.lineTo(i[l],i[l+1])}return e.closePath(),t&&t.value()}hullPolygon(){const e=new Tu;return this.renderHull(e),e.value()}renderTriangle(e,t){const n=t==null?t=new lr:void 0,{points:i,triangles:s}=this,a=s[e*=3]*2,o=s[e+1]*2,l=s[e+2]*2;return t.moveTo(i[a],i[a+1]),t.lineTo(i[o],i[o+1]),t.lineTo(i[l],i[l+1]),t.closePath(),n&&n.value()}*trianglePolygons(){const{triangles:e}=this;for(let t=0,n=e.length/3;t<n;++t)yield this.trianglePolygon(t)}trianglePolygon(e){const t=new Tu;return this.renderTriangle(e,t),t.value()}}function Xw(r,e,t,n){const i=r.length,s=new Float64Array(i*2);for(let a=0;a<i;++a){const o=r[a];s[a*2]=e.call(n,o,a,r),s[a*2+1]=t.call(n,o,a,r)}return s}function*qw(r,e,t,n){let i=0;for(const s of r)yield e.call(n,s,i,r),yield t.call(n,s,i,r),++i}const Cu=Math.PI,zg=Cu/2,kg=180/Cu,Gg=Cu/180,$w=Math.atan2,Hg=Math.cos,Yw=Math.max,Zw=Math.min,Vg=Math.sin,Jw=Math.sign||function(r){return r>0?1:r<0?-1:0},Wg=Math.sqrt;function Kw(r){return r>1?zg:r<-1?-zg:Math.asin(r)}function Xg(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]}function pn(r,e){return[r[1]*e[2]-r[2]*e[1],r[2]*e[0]-r[0]*e[2],r[0]*e[1]-r[1]*e[0]]}function Pl(r,e){return[r[0]+e[0],r[1]+e[1],r[2]+e[2]]}function Ll(r){var e=Wg(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);return[r[0]/e,r[1]/e,r[2]/e]}function Pu(r){return[$w(r[1],r[0])*kg,Kw(Yw(-1,Zw(1,r[2])))*kg]}function Gn(r){const e=r[0]*Gg,t=r[1]*Gg,n=Hg(t);return[n*Hg(e),n*Vg(e),Vg(t)]}function Lu(r){return r=r.map(e=>Gn(e)),Xg(r[0],pn(r[2],r[1]))}function jw(r){const e=eE(r),t=nE(e),n=tE(t,r),i=rE(t,r.length),s=Qw(i,r),a=iE(t,r),{polygons:o,centers:l}=sE(a,t,r),c=aE(o),h=lE(t,r),u=oE(n,t);return{delaunay:e,edges:n,triangles:t,centers:l,neighbors:i,polygons:o,mesh:c,hull:h,urquhart:u,find:s}}function Qw(r,e){function t(n,i){let s=n[0]-i[0],a=n[1]-i[1],o=n[2]-i[2];return s*s+a*a+o*o}return function(i,s,a){a===void 0&&(a=0);let o,l,c=a;const h=Gn([i,s]);do o=a,a=null,l=t(h,Gn(e[o])),r[o].forEach(u=>{let f=t(h,Gn(e[u]));if(f<l){l=f,a=u,c=u;return}});while(a!==null);return c}}function eE(r){if(r.length<2)return{};let e=0;for(;isNaN(r[e][0]+r[e][1])&&e++<r.length;);const t=ig(r[e]),n=K1().translate([0,0]).scale(1).rotate(t.invert([180,0]));r=r.map(n);const i=[];let s=1;for(let u=0,f=r.length;u<f;u++){let d=us(r[u][0],2)+us(r[u][1],2);!isFinite(d)||d>1e32?i.push(u):d>s&&(s=d)}const a=1e6*Wg(s);i.forEach(u=>r[u]=[a,0]),r.push([0,a]),r.push([-a,0]),r.push([0,-a]);const o=Ru.from(r);o.projection=n;const{triangles:l,halfedges:c,inedges:h}=o;for(let u=0,f=c.length;u<f;u++)if(c[u]<0){const d=u%3==2?u-2:u+1,p=u%3==0?u+2:u-1,_=c[d],g=c[p];c[_]=g,c[g]=_,c[d]=c[p]=-1,l[u]=l[d]=l[p]=e,h[l[_]]=_%3==0?_+2:_-1,h[l[g]]=g%3==0?g+2:g-1,u+=2-u%3}else l[u]>r.length-3-1&&(l[u]=e);return o}function tE(r,e){const t=new Set;return e.length===2?[[0,1]]:(r.forEach(n=>{if(n[0]!==n[1]&&!(Lu(n.map(i=>e[i]))<0))for(let i=0,s;i<3;i++)s=(i+1)%3,t.add(Ko([n[i],n[s]]).join("-"))}),Array.from(t,n=>n.split("-").map(Number)))}function nE(r){const{triangles:e}=r;if(!e)return[];const t=[];for(let n=0,i=e.length/3;n<i;n++){const s=e[3*n],a=e[3*n+1],o=e[3*n+2];s!==a&&a!==o&&t.push([s,o,a])}return t}function iE(r,e){return r.map(t=>{const n=t.map(s=>e[s]).map(Gn),i=Pl(Pl(pn(n[1],n[0]),pn(n[2],n[1])),pn(n[0],n[2]));return Pu(Ll(i))})}function rE(r,e){const t=[];return r.forEach(n=>{for(let i=0;i<3;i++){const s=n[i],a=n[(i+1)%3];t[s]=t[s]||[],t[s].push(a)}}),r.length===0&&(e===2?(t[0]=[1],t[1]=[0]):e===1&&(t[0]=[])),t}function sE(r,e,t){const n=[],i=r.slice();if(e.length===0){if(t.length<2)return{polygons:n,centers:i};if(t.length===2){const o=Gn(t[0]),l=Gn(t[1]),c=Ll(Pl(o,l)),h=Ll(pn(o,l)),u=pn(c,h),f=[c,pn(c,u),pn(pn(c,u),u),pn(pn(pn(c,u),u),u)].map(Pu).map(a);return n.push(f),n.push(f.slice().reverse()),{polygons:n,centers:i}}}e.forEach((o,l)=>{for(let c=0;c<3;c++){const h=o[c],u=o[(c+1)%3],f=o[(c+2)%3];n[h]=n[h]||[],n[h].push([u,f,l,[h,u,f]])}});const s=n.map(o=>{const l=[o[0][2]];let c=o[0][1];for(let h=1;h<o.length;h++)for(let u=0;u<o.length;u++)if(o[u][0]==c){c=o[u][1],l.push(o[u][2]);break}if(l.length>2)return l;if(l.length==2){const h=qg(t[o[0][3][0]],t[o[0][3][1]],i[l[0]]),u=qg(t[o[0][3][2]],t[o[0][3][0]],i[l[0]]),f=a(h),d=a(u);return[l[0],d,l[1],f]}});function a(o){let l=-1;return i.slice(e.length,1/0).forEach((c,h)=>{c[0]===o[0]&&c[1]===o[1]&&(l=h+e.length)}),l<0&&(l=i.length,i.push(o)),l}return{polygons:s,centers:i}}function qg(r,e,t){r=Gn(r),e=Gn(e),t=Gn(t);const n=Jw(Xg(pn(e,r),t));return Pu(Ll(Pl(r,e)).map(i=>n*i))}function aE(r){const e=[];return r.forEach(t=>{if(!t)return;let n=t[t.length-1];for(let i of t)i>n&&e.push([n,i]),n=i}),e}function oE(r,e){return function(t){const n=new Map,i=new Map;return r.forEach((s,a)=>{const o=s.join("-");n.set(o,t[a]),i.set(o,!0)}),e.forEach(s=>{let a=0,o=-1;for(let l=0;l<3;l++){let c=Ko([s[l],s[(l+1)%3]]).join("-");n.get(c)>a&&(a=n.get(c),o=c)}i.set(o,!1)}),r.map(s=>i.get(s.join("-")))}}function lE(r,e){const t=new Set,n=[];r.map(o=>{if(!(Lu(o.map(l=>e[l>e.length?0:l]))>1e-12))for(let l=0;l<3;l++){let c=[o[l],o[(l+1)%3]],h=`${c[0]}-${c[1]}`;t.has(h)?t.delete(h):t.add(`${c[1]}-${c[0]}`)}});const i=new Map;let s;if(t.forEach(o=>{o=o.split("-").map(Number),i.set(o[0],o[1]),s=o[0]}),s===void 0)return n;let a=s;do{n.push(a);let o=i.get(a);i.set(a,-1),a=o}while(a>-1&&a!==s);return n}function cE(r){const e=function(t){if(e.delaunay=null,e._data=t,typeof e._data=="object"&&e._data.type==="FeatureCollection"&&(e._data=e._data.features),typeof e._data=="object"){const n=e._data.map(i=>[e._vx(i),e._vy(i),i]).filter(i=>isFinite(i[0]+i[1]));e.points=n.map(i=>[i[0],i[1]]),e.valid=n.map(i=>i[2]),e.delaunay=jw(e.points)}return e};return e._vx=function(t){if(typeof t=="object"&&"type"in t)return jm(t)[0];if(0 in t)return t[0]},e._vy=function(t){if(typeof t=="object"&&"type"in t)return jm(t)[1];if(1 in t)return t[1]},e.x=function(t){return t?(e._vx=t,e):e._vx},e.y=function(t){return t?(e._vy=t,e):e._vy},e.polygons=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n={type:"FeatureCollection",features:[]};return e.valid.length===0||(e.delaunay.polygons.forEach((i,s)=>n.features.push({type:"Feature",geometry:i?{type:"Polygon",coordinates:[[...i,i[0]].map(a=>e.delaunay.centers[a])]}:null,properties:{site:e.valid[s],sitecoordinates:e.points[s],neighbours:e.delaunay.neighbors[s]}})),e.valid.length===1&&n.features.push({type:"Feature",geometry:{type:"Sphere"},properties:{site:e.valid[0],sitecoordinates:e.points[0],neighbours:[]}})),n},e.triangles=function(t){return t!==void 0&&e(t),e.delaunay?{type:"FeatureCollection",features:e.delaunay.triangles.map((n,i)=>(n=n.map(s=>e.points[s]),n.center=e.delaunay.centers[i],n)).filter(n=>Lu(n)>0).map(n=>({type:"Feature",properties:{circumcenter:n.center},geometry:{type:"Polygon",coordinates:[[...n,n[0]]]}}))}:!1},e.links=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n=e.delaunay.edges.map(s=>ts(e.points[s[0]],e.points[s[1]])),i=e.delaunay.urquhart(n);return{type:"FeatureCollection",features:e.delaunay.edges.map((s,a)=>({type:"Feature",properties:{source:e.valid[s[0]],target:e.valid[s[1]],length:n[a],urquhart:!!i[a]},geometry:{type:"LineString",coordinates:[e.points[s[0]],e.points[s[1]]]}}))}},e.mesh=function(t){return t!==void 0&&e(t),e.delaunay?{type:"MultiLineString",coordinates:e.delaunay.edges.map(n=>[e.points[n[0]],e.points[n[1]]])}:!1},e.cellMesh=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const{centers:n,polygons:i}=e.delaunay,s=[];for(const a of i)if(a)for(let o=a.length,l=a[o-1],c=a[0],h=0;h<o;l=c,c=a[++h])c>l&&s.push([n[l],n[c]]);return{type:"MultiLineString",coordinates:s}},e._found=void 0,e.find=function(t,n,i){if(e._found=e.delaunay.find(t,n,e._found),!i||ts([t,n],e.points[e._found])<i)return e._found},e.hull=function(t){t!==void 0&&e(t);const n=e.delaunay.hull,i=e.points;return n.length===0?null:{type:"Polygon",coordinates:[[...n.map(s=>i[s]),i[n[0]]]]}},r?e(r):e}function hE(r,e){switch(arguments.length){case 0:break;case 1:this.range(r);break;default:this.range(e).domain(r);break}return this}function Iu(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function $g(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function ma(){}var ga=.7,Il=1/ga,ls="\\s*([+-]?\\d+)\\s*",_a="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Hn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",uE=/^#([0-9a-f]{3,8})$/,fE=new RegExp(`^rgb\\(${ls},${ls},${ls}\\)$`),dE=new RegExp(`^rgb\\(${Hn},${Hn},${Hn}\\)$`),pE=new RegExp(`^rgba\\(${ls},${ls},${ls},${_a}\\)$`),mE=new RegExp(`^rgba\\(${Hn},${Hn},${Hn},${_a}\\)$`),gE=new RegExp(`^hsl\\(${_a},${Hn},${Hn}\\)$`),_E=new RegExp(`^hsla\\(${_a},${Hn},${Hn},${_a}\\)$`),Yg={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};Iu(ma,xa,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:Zg,formatHex:Zg,formatHex8:xE,formatHsl:yE,formatRgb:Jg,toString:Jg});function Zg(){return this.rgb().formatHex()}function xE(){return this.rgb().formatHex8()}function yE(){return t0(this).formatHsl()}function Jg(){return this.rgb().formatRgb()}function xa(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=uE.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Kg(e):t===3?new sn(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?Ul(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?Ul(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=fE.exec(r))?new sn(e[1],e[2],e[3],1):(e=dE.exec(r))?new sn(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=pE.exec(r))?Ul(e[1],e[2],e[3],e[4]):(e=mE.exec(r))?Ul(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=gE.exec(r))?e0(e[1],e[2]/100,e[3]/100,1):(e=_E.exec(r))?e0(e[1],e[2]/100,e[3]/100,e[4]):Yg.hasOwnProperty(r)?Kg(Yg[r]):r==="transparent"?new sn(NaN,NaN,NaN,0):null}function Kg(r){return new sn(r>>16&255,r>>8&255,r&255,1)}function Ul(r,e,t,n){return n<=0&&(r=e=t=NaN),new sn(r,e,t,n)}function vE(r){return r instanceof ma||(r=xa(r)),r?(r=r.rgb(),new sn(r.r,r.g,r.b,r.opacity)):new sn}function Uu(r,e,t,n){return arguments.length===1?vE(r):new sn(r,e,t,n==null?1:n)}function sn(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}Iu(sn,Uu,$g(ma,{brighter(r){return r=r==null?Il:Math.pow(Il,r),new sn(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?ga:Math.pow(ga,r),new sn(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new sn(cr(this.r),cr(this.g),cr(this.b),Dl(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:jg,formatHex:jg,formatHex8:ME,formatRgb:Qg,toString:Qg}));function jg(){return`#${hr(this.r)}${hr(this.g)}${hr(this.b)}`}function ME(){return`#${hr(this.r)}${hr(this.g)}${hr(this.b)}${hr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Qg(){const r=Dl(this.opacity);return`${r===1?"rgb(":"rgba("}${cr(this.r)}, ${cr(this.g)}, ${cr(this.b)}${r===1?")":`, ${r})`}`}function Dl(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function cr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function hr(r){return r=cr(r),(r<16?"0":"")+r.toString(16)}function e0(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new In(r,e,t,n)}function t0(r){if(r instanceof In)return new In(r.h,r.s,r.l,r.opacity);if(r instanceof ma||(r=xa(r)),!r)return new In;if(r instanceof In)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,i=Math.min(e,t,n),s=Math.max(e,t,n),a=NaN,o=s-i,l=(s+i)/2;return o?(e===s?a=(t-n)/o+(t<n)*6:t===s?a=(n-e)/o+2:a=(e-t)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new In(a,o,l,r.opacity)}function SE(r,e,t,n){return arguments.length===1?t0(r):new In(r,e,t,n==null?1:n)}function In(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}Iu(In,SE,$g(ma,{brighter(r){return r=r==null?Il:Math.pow(Il,r),new In(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?ga:Math.pow(ga,r),new In(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,i=2*t-n;return new sn(Du(r>=240?r-240:r+120,i,n),Du(r,i,n),Du(r<120?r+240:r-120,i,n),this.opacity)},clamp(){return new In(n0(this.h),Nl(this.s),Nl(this.l),Dl(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Dl(this.opacity);return`${r===1?"hsl(":"hsla("}${n0(this.h)}, ${Nl(this.s)*100}%, ${Nl(this.l)*100}%${r===1?")":`, ${r})`}`}}));function n0(r){return r=(r||0)%360,r<0?r+360:r}function Nl(r){return Math.max(0,Math.min(1,r||0))}function Du(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}var Nu=r=>()=>r;function bE(r,e){return function(t){return r+t*e}}function wE(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function EE(r){return(r=+r)==1?i0:function(e,t){return t-e?wE(e,t,r):Nu(isNaN(e)?t:e)}}function i0(r,e){var t=e-r;return t?bE(r,t):Nu(isNaN(r)?e:r)}var r0=function r(e){var t=EE(e);function n(i,s){var a=t((i=Uu(i)).r,(s=Uu(s)).r),o=t(i.g,s.g),l=t(i.b,s.b),c=i0(i.opacity,s.opacity);return function(h){return i.r=a(h),i.g=o(h),i.b=l(h),i.opacity=c(h),i+""}}return n.gamma=r,n}(1);function AE(r,e){e||(e=[]);var t=r?Math.min(e.length,r.length):0,n=e.slice(),i;return function(s){for(i=0;i<t;++i)n[i]=r[i]*(1-s)+e[i]*s;return n}}function TE(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function RE(r,e){var t=e?e.length:0,n=r?Math.min(t,r.length):0,i=new Array(n),s=new Array(t),a;for(a=0;a<n;++a)i[a]=Bu(r[a],e[a]);for(;a<t;++a)s[a]=e[a];return function(o){for(a=0;a<n;++a)s[a]=i[a](o);return s}}function CE(r,e){var t=new Date;return r=+r,e=+e,function(n){return t.setTime(r*(1-n)+e*n),t}}function Fl(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}function PE(r,e){var t={},n={},i;(r===null||typeof r!="object")&&(r={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in r?t[i]=Bu(r[i],e[i]):n[i]=e[i];return function(s){for(i in t)n[i]=t[i](s);return n}}var Fu=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ou=new RegExp(Fu.source,"g");function LE(r){return function(){return r}}function IE(r){return function(e){return r(e)+""}}function UE(r,e){var t=Fu.lastIndex=Ou.lastIndex=0,n,i,s,a=-1,o=[],l=[];for(r=r+"",e=e+"";(n=Fu.exec(r))&&(i=Ou.exec(e));)(s=i.index)>t&&(s=e.slice(t,s),o[a]?o[a]+=s:o[++a]=s),(n=n[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:Fl(n,i)})),t=Ou.lastIndex;return t<e.length&&(s=e.slice(t),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?IE(l[0].x):LE(e):(e=l.length,function(c){for(var h=0,u;h<e;++h)o[(u=l[h]).i]=u.x(c);return o.join("")})}function Bu(r,e){var t=typeof e,n;return e==null||t==="boolean"?Nu(e):(t==="number"?Fl:t==="string"?(n=xa(e))?(e=n,r0):UE:e instanceof xa?r0:e instanceof Date?CE:TE(e)?AE:Array.isArray(e)?RE:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?PE:Fl)(r,e)}function DE(r,e){return r=+r,e=+e,function(t){return Math.round(r*(1-t)+e*t)}}function NE(r){return function(){return r}}function FE(r){return+r}var s0=[0,1];function cs(r){return r}function zu(r,e){return(e-=r=+r)?function(t){return(t-r)/e}:NE(isNaN(e)?NaN:.5)}function OE(r,e){var t;return r>e&&(t=r,r=e,e=t),function(n){return Math.max(r,Math.min(e,n))}}function BE(r,e,t){var n=r[0],i=r[1],s=e[0],a=e[1];return i<n?(n=zu(i,n),s=t(a,s)):(n=zu(n,i),s=t(s,a)),function(o){return s(n(o))}}function zE(r,e,t){var n=Math.min(r.length,e.length)-1,i=new Array(n),s=new Array(n),a=-1;for(r[n]<r[0]&&(r=r.slice().reverse(),e=e.slice().reverse());++a<n;)i[a]=zu(r[a],r[a+1]),s[a]=t(e[a],e[a+1]);return function(o){var l=Yb(r,o,1,n)-1;return s[l](i[l](o))}}function kE(r,e){return e.domain(r.domain()).range(r.range()).interpolate(r.interpolate()).clamp(r.clamp()).unknown(r.unknown())}function GE(){var r=s0,e=s0,t=Bu,n,i,s,a=cs,o,l,c;function h(){var f=Math.min(r.length,e.length);return a!==cs&&(a=OE(r[0],r[f-1])),o=f>2?zE:BE,l=c=null,u}function u(f){return f==null||isNaN(f=+f)?s:(l||(l=o(r.map(n),e,t)))(n(a(f)))}return u.invert=function(f){return a(i((c||(c=o(e,r.map(n),Fl)))(f)))},u.domain=function(f){return arguments.length?(r=Array.from(f,FE),h()):r.slice()},u.range=function(f){return arguments.length?(e=Array.from(f),h()):e.slice()},u.rangeRound=function(f){return e=Array.from(f),t=DE,h()},u.clamp=function(f){return arguments.length?(a=f?!0:cs,h()):a!==cs},u.interpolate=function(f){return arguments.length?(t=f,h()):t},u.unknown=function(f){return arguments.length?(s=f,u):s},function(f,d){return n=f,i=d,h()}}function HE(){return GE()(cs,cs)}function VE(r){return Math.abs(r=Math.round(r))>=1e21?r.toLocaleString("en").replace(/,/g,""):r.toString(10)}function Ol(r,e){if((t=(r=e?r.toExponential(e-1):r.toExponential()).indexOf("e"))<0)return null;var t,n=r.slice(0,t);return[n.length>1?n[0]+n.slice(2):n,+r.slice(t+1)]}function hs(r){return r=Ol(Math.abs(r)),r?r[1]:NaN}function WE(r,e){return function(t,n){for(var i=t.length,s=[],a=0,o=r[0],l=0;i>0&&o>0&&(l+o+1>n&&(o=Math.max(1,n-l)),s.push(t.substring(i-=o,i+o)),!((l+=o+1)>n));)o=r[a=(a+1)%r.length];return s.reverse().join(e)}}function XE(r){return function(e){return e.replace(/[0-9]/g,function(t){return r[+t]})}}var qE=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Bl(r){if(!(e=qE.exec(r)))throw new Error("invalid format: "+r);var e;return new ku({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}Bl.prototype=ku.prototype;function ku(r){this.fill=r.fill===void 0?" ":r.fill+"",this.align=r.align===void 0?">":r.align+"",this.sign=r.sign===void 0?"-":r.sign+"",this.symbol=r.symbol===void 0?"":r.symbol+"",this.zero=!!r.zero,this.width=r.width===void 0?void 0:+r.width,this.comma=!!r.comma,this.precision=r.precision===void 0?void 0:+r.precision,this.trim=!!r.trim,this.type=r.type===void 0?"":r.type+""}ku.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function $E(r){e:for(var e=r.length,t=1,n=-1,i;t<e;++t)switch(r[t]){case".":n=i=t;break;case"0":n===0&&(n=t),i=t;break;default:if(!+r[t])break e;n>0&&(n=0);break}return n>0?r.slice(0,n)+r.slice(i+1):r}var a0;function YE(r,e){var t=Ol(r,e);if(!t)return r+"";var n=t[0],i=t[1],s=i-(a0=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,a=n.length;return s===a?n:s>a?n+new Array(s-a+1).join("0"):s>0?n.slice(0,s)+"."+n.slice(s):"0."+new Array(1-s).join("0")+Ol(r,Math.max(0,e+s-1))[0]}function o0(r,e){var t=Ol(r,e);if(!t)return r+"";var n=t[0],i=t[1];return i<0?"0."+new Array(-i).join("0")+n:n.length>i+1?n.slice(0,i+1)+"."+n.slice(i+1):n+new Array(i-n.length+2).join("0")}var l0={"%":(r,e)=>(r*100).toFixed(e),b:r=>Math.round(r).toString(2),c:r=>r+"",d:VE,e:(r,e)=>r.toExponential(e),f:(r,e)=>r.toFixed(e),g:(r,e)=>r.toPrecision(e),o:r=>Math.round(r).toString(8),p:(r,e)=>o0(r*100,e),r:o0,s:YE,X:r=>Math.round(r).toString(16).toUpperCase(),x:r=>Math.round(r).toString(16)};function c0(r){return r}var h0=Array.prototype.map,u0=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ZE(r){var e=r.grouping===void 0||r.thousands===void 0?c0:WE(h0.call(r.grouping,Number),r.thousands+""),t=r.currency===void 0?"":r.currency[0]+"",n=r.currency===void 0?"":r.currency[1]+"",i=r.decimal===void 0?".":r.decimal+"",s=r.numerals===void 0?c0:XE(h0.call(r.numerals,String)),a=r.percent===void 0?"%":r.percent+"",o=r.minus===void 0?"−":r.minus+"",l=r.nan===void 0?"NaN":r.nan+"";function c(u){u=Bl(u);var f=u.fill,d=u.align,p=u.sign,_=u.symbol,g=u.zero,m=u.width,y=u.comma,x=u.precision,v=u.trim,M=u.type;M==="n"?(y=!0,M="g"):l0[M]||(x===void 0&&(x=12),v=!0,M="g"),(g||f==="0"&&d==="=")&&(g=!0,f="0",d="=");var w=_==="$"?t:_==="#"&&/[boxX]/.test(M)?"0"+M.toLowerCase():"",A=_==="$"?n:/[%p]/.test(M)?a:"",C=l0[M],S=/[defgprs%]/.test(M);x=x===void 0?6:/[gprs]/.test(M)?Math.max(1,Math.min(21,x)):Math.max(0,Math.min(20,x));function b(L){var k=w,U=A,N,I,B;if(M==="c")U=C(L)+U,L="";else{L=+L;var O=L<0||1/L<0;if(L=isNaN(L)?l:C(Math.abs(L),x),v&&(L=$E(L)),O&&+L==0&&p!=="+"&&(O=!1),k=(O?p==="("?p:o:p==="-"||p==="("?"":p)+k,U=(M==="s"?u0[8+a0/3]:"")+U+(O&&p==="("?")":""),S){for(N=-1,I=L.length;++N<I;)if(B=L.charCodeAt(N),48>B||B>57){U=(B===46?i+L.slice(N+1):L.slice(N))+U,L=L.slice(0,N);break}}}y&&!g&&(L=e(L,1/0));var H=k.length+L.length+U.length,X=H<m?new Array(m-H+1).join(f):"";switch(y&&g&&(L=e(X+L,X.length?m-U.length:1/0),X=""),d){case"<":L=k+L+U+X;break;case"=":L=k+X+L+U;break;case"^":L=X.slice(0,H=X.length>>1)+k+L+U+X.slice(H);break;default:L=X+k+L+U;break}return s(L)}return b.toString=function(){return u+""},b}function h(u,f){var d=c((u=Bl(u),u.type="f",u)),p=Math.max(-8,Math.min(8,Math.floor(hs(f)/3)))*3,_=Math.pow(10,-p),g=u0[8+p/3];return function(m){return d(_*m)+g}}return{format:c,formatPrefix:h}}var zl,f0,d0;JE({thousands:",",grouping:[3],currency:["$",""]});function JE(r){return zl=ZE(r),f0=zl.format,d0=zl.formatPrefix,zl}function KE(r){return Math.max(0,-hs(Math.abs(r)))}function jE(r,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(hs(e)/3)))*3-hs(Math.abs(r)))}function QE(r,e){return r=Math.abs(r),e=Math.abs(e)-r,Math.max(0,hs(e)-hs(r))+1}function eA(r,e,t,n){var i=Qb(r,e,t),s;switch(n=Bl(n==null?",f":n),n.type){case"s":{var a=Math.max(Math.abs(r),Math.abs(e));return n.precision==null&&!isNaN(s=jE(i,a))&&(n.precision=s),d0(n,a)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(s=QE(i,Math.max(Math.abs(r),Math.abs(e))))&&(n.precision=s-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(s=KE(i))&&(n.precision=s-(n.type==="%")*2);break}}return f0(n)}function tA(r){var e=r.domain;return r.ticks=function(t){var n=e();return jb(n[0],n[n.length-1],t==null?10:t)},r.tickFormat=function(t,n){var i=e();return eA(i[0],i[i.length-1],t==null?10:t,n)},r.nice=function(t){t==null&&(t=10);var n=e(),i=0,s=n.length-1,a=n[i],o=n[s],l,c,h=10;for(o<a&&(c=a,a=o,o=c,c=i,i=s,s=c);h-- >0;){if(c=Kh(a,o,t),c===l)return n[i]=a,n[s]=o,e(n);if(c>0)a=Math.floor(a/c)*c,o=Math.ceil(o/c)*c;else if(c<0)a=Math.ceil(a*c)/c,o=Math.floor(o*c)/c;else break;l=c}return r},r}function Gu(){var r=HE();return r.copy=function(){return kE(r,Gu())},hE.apply(r,arguments),tA(r)}function nA(r,e){return r.map(t=>{const n=[];let i;return t.forEach(s=>{if(i){const a=ts(s,i)*180/Math.PI;if(a>e){const o=N1(i,s),l=1/Math.ceil(a/e);let c=l;for(;c<1;)n.push(o(c)),c+=l}}n.push(i=s)}),n})}function iA(r,{minLng:e,maxLng:t,minLat:n,maxLat:i}={}){const s=Math.round(us(360/r,2)/Math.PI),a=(1+Math.sqrt(5))/2,o=d=>d/a*360%360-180,l=d=>Math.acos(2*d/s-1)/Math.PI*180-90,c=d=>s*(Math.cos((d+90)*Math.PI/180)+1)/2,h=[i!==void 0?Math.ceil(c(i)):0,n!==void 0?Math.floor(c(n)):s-1],u=e===void 0&&t===void 0?()=>!0:e===void 0?d=>d<=t:t===void 0?d=>d>=e:t>=e?d=>d>=e&&d<=t:d=>d>=e||d<=t,f=[];for(let d=h[0];d<=h[1];d++){const p=o(d);u(p)&&f.push([p,l(d)])}return f}function Hu(r,e,t=!1){return t?D1(e,r):Ow(r,e)}function rA(r,e){const t={type:"Polygon",coordinates:r},[[n,i],[s,a]]=qm(t);if(Math.min(Math.abs(s-n),Math.abs(a-i))<e)return[];const o=n>s||a>=89||i<=-89;return iA(e,{minLng:n,maxLng:s,minLat:i,maxLat:a}).filter(l=>Hu(l,t,o))}function sA(r,{resolution:e=1/0}={}){const t=nA(r,e),n=ia(t),i=rA(r,e),s=[...n,...i],a={type:"Polygon",coordinates:r},[[o,l],[c,h]]=qm(a),u=o>c||h>=89||l<=-89;let f=[];if(u){const m=cE(s).triangles(),y=new Map(s.map(([x,v],M)=>[`${x}-${v}`,M]));m.features.forEach(x=>{const v=x.geometry.coordinates[0].slice(0,3).reverse(),M=[];if(v.forEach(([w,A])=>{const C=`${w}-${A}`;y.has(C)&&M.push(y.get(C))}),M.length===3){if(M.some(w=>w<n.length)){const w=x.properties.circumcenter;if(!Hu(w,a,u))return}f.push(...M)}})}else if(i.length){const m=da.from(s);for(let y=0,x=m.triangles.length;y<x;y+=3){const v=[2,1,0].map(w=>m.triangles[y+w]),M=v.map(w=>s[w]);if(v.some(w=>w<n.length)){const w=[0,1].map(A=>e1(M,C=>C[A]));if(!Hu(w,a,u))continue}f.push(...v)}}else{const{vertices:m,holes:y=[]}=is.flatten(t);f=is(m,y,2)}const d=Gu(Ko(s,m=>m[0]),[0,1]),p=Gu(Ko(s,m=>m[1]),[0,1]),_=s.map(([m,y])=>[d(m),p(y)]);return{contour:t,triangles:{points:s,indices:f,uvs:_}}}const p0=new Fe().setAttribute?"setAttribute":"addAttribute";function kl(r,e,t=!0){const n=r.map(i=>i.map(([s,a])=>t?ww(s,a,e):[s,a,e]));return is.flatten(n)}function aA(r,e,t,n=!0){const{vertices:i,holes:s}=kl(r,e,n),{vertices:a}=kl(r,t,n),o=ia([a,i]),l=Math.round(a.length/3),c=new Set(s);let h=0;const u=[];for(let d=0;d<l;d++){let p=d+1;if(p===l)p=h;else if(c.has(p)){const _=p;p=h,h=_}u.push(d,d+l,p+l),u.push(p+l,p,d)}const f=[];for(let d=1;d>=0;d--)for(let p=0;p<l;p+=1)f.push(p/(l-1),d);return{indices:u,vertices:o,uvs:f,topVerts:a}}function m0(r,e,t,n=!0,i=!0){return{indices:n?r.indices:r.indices.slice().reverse(),vertices:kl([r.points],e,i).vertices,uvs:t}}const g0=({polygonGeoJson:r,startHeight:e,endHeight:t,curvatureResolution:n=1,cartesian:i=!0,hasSide:s=!0,hasBottom:a=!1,hasTop:o=!1})=>{r.forEach(_=>{bw(_)||_.reverse()});const{contour:l,triangles:c}=sA(r,{resolution:n});let h={},u;s&&(h=aA(l,e!=null?e:t,t!=null?t:e,i),u=h.topVerts);let f=[];(a||o)&&(f=ia(c.uvs));let d={};a&&(d=m0(c,e,f,!1,i));let p={};return o&&(p=m0(c,t,f,!0,i)),{contour:l,triangles:c,sideTorso:h,bottomCap:d,topCap:p,topVerts:u}};class oA extends Fe{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=Wl({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:n,hasTop:i,hasBottom:s,hasSide:a,cartesian:o,userDataRsoOffset:l}=this.parameters,{contour:c,sideTorso:h,topVerts:u,bottomCap:f,topCap:d}=g0(Wl({},this.parameters));let p=[],_=[],g=[],m=0;const y=x=>{const v=Math.round(p.length/3),M=g.length;p=p.concat(x.vertices),_=_.concat(x.uvs),g=g.concat(v?x.indices.map(w=>w+v):x.indices),this.addGroup(M,g.length-M,m++)};a&&(y(h),this.userData.topVerts=l?kl(c,n+l,o).vertices:u),s&&y(f),i&&y(d),this.setIndex(g),this[p0]("position",new ve(p,3)),this[p0]("uv",new ve(_,2)),this.computeVertexNormals()}}var lA=r=>{const o=r,{coordinate:e,startHeight:t,height:n}=o,i=R0(o,["coordinate","startHeight","height"]);let s=t||0;return typeof t!="undefined"&&typeof n!="undefined"&&(s=t+n),new oA([e],T0(Wl({},i),{startHeight:t,endHeight:s}))};const cA=({coordinatesArr:r,start:e,height:t,useGroups:n,hasTop:i,hasBottom:s,hasSide:a})=>{const o=r.map((l,c)=>{var h,u;return lA({coordinate:l,startHeight:(h=e[c])!=null?h:e[0],height:(u=t[c])!=null?u:t[0],hasTop:i!=null?i:!0,hasBottom:s!=null?s:!0,hasSide:a!=null?a:!0})});return bl(o,n)},hA=({coordinatesArr:r,lineWidth:e,start:t,useGroups:n})=>{const s=r.map((a,o)=>{var l;return g0({polygonGeoJson:[a],startHeight:(l=t[o])!=null?l:t[0]}).topVerts}).map((a,o)=>{var c;const l=(c=e[o])!=null?c:e[0];return Rg({nodes:a,setPointWidth:()=>l})});return bl(s,n)};var uA=(r,e,t)=>new Promise((n,i)=>{var s=l=>{try{o(t.next(l))}catch(c){i(c)}},a=l=>{try{o(t.throw(l))}catch(c){i(c)}},o=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);o((t=t.apply(r,e)).next())});function Vu(r){this.message=r||"promise cancelled",this.stack=new Error().stack}Vu.prototype=new Error,Vu.prototype.constructor=Error,Vu.prototype.name="CancellationError";function Wu(r){this.message=r||"timeout exceeded",this.stack=new Error().stack}Wu.prototype=new Error,Wu.prototype.constructor=Error,Wu.prototype.name="TimeoutError";function _0(r){return Object.getOwnPropertyNames(r).reduce(function(e,t){return Object.defineProperty(e,t,{value:r[t],enumerable:!0})},{})}let Xu=null;const qu={run(r,e){const t=new Function("return ("+r+").apply(null, arguments);");return t.apply(t,e)},methods(){return Object.keys(qu)}};addEventListener("message",r=>uA(void 0,[r],function*({data:e}){try{const t=qu[e.method];if(t){Xu=e.id;try{const n=yield t.apply(t,e.params);n.transfer&&n.message?postMessage({id:e.id,result:n.message,error:null},n.transfer):postMessage({id:e.id,result:n,error:null}),Xu=null}catch(n){postMessage({id:e.id,result:null,error:_0(n)}),Xu=null}}else throw new Error('Unknown method "'+e.method+'"')}catch(t){postMessage({id:e.id,result:null,error:_0(t)})}})),(r=>{Object.keys(r).forEach(e=>{qu[e]=r[e]}),postMessage("ready")})({extrudePolygon:ew,line:iw,conicPolygon:cA,conicLine:hA})})();