morpheus-cli 0.9.23 → 0.9.24
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.
- package/dist/cli/commands/restart.js +15 -0
- package/dist/cli/commands/start.js +9 -9
- package/dist/http/webhooks-router.js +12 -6
- package/dist/runtime/webhooks/dispatcher.js +12 -4
- package/dist/runtime/webhooks/repository.js +17 -6
- package/dist/ui/assets/{AuditDashboard-ClqEr7jg.js → AuditDashboard-CfYKdOEt.js} +1 -1
- package/dist/ui/assets/{Chat-BwxZJphx.js → Chat-CYev7-CJ.js} +1 -1
- package/dist/ui/assets/{Chronos-BafOMteb.js → Chronos-5KR8aZud.js} +1 -1
- package/dist/ui/assets/{ConfirmationModal-DU0AwhXD.js → ConfirmationModal-NFwIYI7B.js} +1 -1
- package/dist/ui/assets/{Dashboard-DvJb72Xe.js → Dashboard-hsjB56la.js} +1 -1
- package/dist/ui/assets/{DeleteConfirmationModal-FSWLK6-I.js → DeleteConfirmationModal-BfV370Vv.js} +1 -1
- package/dist/ui/assets/{Documents-D73CeGkW.js → Documents-BNo2tMfG.js} +1 -1
- package/dist/ui/assets/{Logs-BrFWnLIL.js → Logs-1hBpMPZE.js} +1 -1
- package/dist/ui/assets/{MCPManager-_L2Yo-uY.js → MCPManager-CvPRHn4C.js} +1 -1
- package/dist/ui/assets/{ModelPricing-CyXMdxJD.js → ModelPricing-BbwJFdz4.js} +1 -1
- package/dist/ui/assets/{Notifications-BpHokTLS.js → Notifications-C_MA51Gf.js} +1 -1
- package/dist/ui/assets/{SatiMemories-CfSTgr9V.js → SatiMemories-Cd9xn98_.js} +1 -1
- package/dist/ui/assets/{SessionAudit-pOWRgJtc.js → SessionAudit-BTABenGk.js} +1 -1
- package/dist/ui/assets/{Settings-CPDXAk18.js → Settings-DRVx4ICA.js} +1 -1
- package/dist/ui/assets/{Skills-GIkCxMS3.js → Skills-DS9p1-S8.js} +1 -1
- package/dist/ui/assets/{Smiths-ZcHXcrMt.js → Smiths-CMCZaAF_.js} +1 -1
- package/dist/ui/assets/{Tasks-DJ6R3d4f.js → Tasks-Cvt4sTcs.js} +1 -1
- package/dist/ui/assets/{TrinityDatabases-CnRAkDuu.js → TrinityDatabases-qhSUMeCw.js} +1 -1
- package/dist/ui/assets/{UsageStats-Bl7bs4ay.js → UsageStats-Cy9HKYOp.js} +1 -1
- package/dist/ui/assets/WebhookManager-ByqkTyqs.js +4 -0
- package/dist/ui/assets/{agents-DO69pNM1.js → agents-svEaAPka.js} +1 -1
- package/dist/ui/assets/{audit-CP5fC4m8.js → audit-gxRPR5Jb.js} +1 -1
- package/dist/ui/assets/{chronos-DPhK718h.js → chronos-ZrBE4yA4.js} +1 -1
- package/dist/ui/assets/{config-OLGQFNJL.js → config-B1i6Xxwk.js} +1 -1
- package/dist/ui/assets/{index-B9ePr-vB.js → index-DyKlGDg1.js} +2 -2
- package/dist/ui/assets/index-gx__iEcl.css +1 -0
- package/dist/ui/assets/{mcp-BeBznKtK.js → mcp-DSddQR1h.js} +1 -1
- package/dist/ui/assets/{skills-wEUxSGB3.js → skills-DIuMjpPF.js} +1 -1
- package/dist/ui/assets/{stats-KMbKDMJ-.js → stats-CxlRAO2g.js} +1 -1
- package/dist/ui/assets/{useCurrency-Bgg-7MTE.js → useCurrency-BkHiWfcT.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/ui/sw.js +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/WebhookManager-CEjjk4tx.js +0 -4
- package/dist/ui/assets/index-D_0tPLCk.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as q,m as pa}from"./vendor-motion-C3CZ8ZlO.js";import{r as q1,c as Y1,h as Sm,u as $1,t as pv,f as Z1}from"./index-B9ePr-vB.js";import{r as K1,u as br,c as J1}from"./vendor-utils-BIYveU_1.js";import{s as Q1}from"./stats-KMbKDMJ-.js";import{m as eE}from"./mcp-BeBznKtK.js";import{s as tE}from"./skills-wEUxSGB3.js";import{a as nE,g as fy,R as dy,r as le,L as py}from"./vendor-react-DikRIOlj.js";import{l as iE,m as sE,L as rE,A as aE,g as Mm,n as oE,o as lE,p as cE,i as uE,W as hE,P as fE,H as dE,f as pE,q as my,r as mE,s as gE,t as xE}from"./vendor-icons-DE7PWdkN.js";const vE={hidden:{opacity:0,y:20},show:{opacity:1,y:0}},_p=({title:s,value:e,icon:t,subValue:n})=>q.jsxs(pa.div,{variants:vE,className:"border border-azure-border dark:border-matrix-primary bg-azure-surface/50 dark:bg-zinc-950/50 p-6 rounded relative overflow-hidden group hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",children:[q.jsxs("div",{className:"flex justify-between items-start mb-4",children:[q.jsx("h3",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm font-bold uppercase",children:s}),q.jsx(t,{className:"w-6 h-6 text-azure-primary dark:text-matrix-primary group-hover:text-azure-primary dark:group-hover:text-matrix-highlight transition-colors"})]}),q.jsx("div",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight mb-1 font-mono tracking-tighter truncate",children:e}),n&&q.jsx("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70 font-mono",children:n})]});const yc="183",ma={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ga={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},gy=0,Em=1,xy=2,_E=3,vy=0,Fo=1,Gl=2,_a=3,qs=0,si=1,pi=2,vs=0,Ma=1,yh=2,wm=3,Tm=4,_y=5,yE=6,Sr=100,yy=101,by=102,Sy=103,My=104,Ey=200,wy=201,Ty=202,Ay=203,bh=204,Sh=205,Cy=206,Ry=207,Iy=208,Py=209,Ly=210,Ny=211,Dy=212,Uy=213,Fy=214,Mh=0,Eh=1,wh=2,Ta=3,Th=4,Ah=5,Ch=6,Rh=7,bc=0,Oy=1,zy=2,Bi=0,$m=1,Zm=2,Km=3,_f=4,Jm=5,Qm=6,eg=7,Am="attached",By="detached",yf=300,_s=301,Ar=302,Wl=303,Xl=304,qo=306,nc=1e3,gi=1001,ic=1002,mn=1003,tg=1004,bE=1004,No=1005,SE=1005,en=1006,jl=1007,ME=1007,gs=1008,EE=1008,ti=1009,ng=1010,ig=1011,zo=1012,bf=1013,ki=1014,ii=1015,ys=1016,Sf=1017,Mf=1018,Bo=1020,sg=35902,rg=35899,ag=1021,og=1022,Yn=1023,bs=1026,Er=1027,Ef=1028,Sc=1029,Aa=1030,wf=1031,wE=1032,Tf=1033,ql=33776,Yl=33777,$l=33778,Zl=33779,Ih=35840,Ph=35841,Lh=35842,Nh=35843,Dh=36196,Uh=37492,Fh=37496,Oh=37488,zh=37489,Bh=37490,kh=37491,Vh=37808,Hh=37809,Gh=37810,Wh=37811,Xh=37812,jh=37813,qh=37814,Yh=37815,$h=37816,Zh=37817,Kh=37818,Jh=37819,Qh=37820,ef=37821,tf=36492,nf=36494,sf=36495,rf=36283,af=36284,of=36285,lf=36286,ky=2200,Vy=2201,Hy=2202,sc=2300,cf=2301,mh=2302,Cm=2303,ya=2400,ba=2401,rc=2402,Af=2500,lg=2501,TE=0,AE=1,CE=2,Gy=3200,RE=3201,IE=3202,PE=3203,Ir=0,Wy=1,Ws="",qn="srgb",Cr="srgb-linear",ac="linear",Xt="srgb",LE="",NE="rg",DE="ga",UE=0,xa=7680,FE=7681,OE=7682,zE=7683,BE=34055,kE=34056,VE=5386,HE=512,GE=513,WE=514,XE=515,jE=516,qE=517,YE=518,Rm=519,Xy=512,jy=513,qy=514,Cf=515,Yy=516,$y=517,Rf=518,Zy=519,oc=35044,$E=35048,ZE=35040,KE=35045,JE=35049,QE=35041,ew=35046,tw=35050,nw=35042,iw="100",Im="300 es",Ri=2e3,Ca=2001,sw={COMPUTE:"compute",RENDER:"render"},rw={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},aw={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},ow={TEXTURE_COMPARE:"depthTextureCompare"};function lw(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}const cw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Do(s,e){return new cw[s](e)}function Ky(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function lc(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Jy(){const s=lc("canvas");return s.style.display="block",s}const mv={};let Rr=null;function uw(s){Rr=s}function hw(){return Rr}function cc(...s){const e="THREE."+s.shift();Rr?Rr("log",e,...s):console.log(e,...s)}function Qy(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function He(...s){s=Qy(s);const e="THREE."+s.shift();if(Rr)Rr("warn",e,...s);else{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function ot(...s){s=Qy(s);const e="THREE."+s.shift();if(Rr)Rr("error",e,...s);else{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function uc(...s){const e=s.join(" ");e in mv||(mv[e]=!0,He(...s))}function fw(s,e,t){return new Promise(function(n,i){function o(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(o,t);break;default:n()}}setTimeout(o,t)})}const dw={[Mh]:Eh,[wh]:Ch,[Th]:Rh,[Ta]:Ah,[Eh]:Mh,[Ch]:wh,[Rh]:Th,[Ah]:Ta};let Ss=class{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){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let o=0,l=i.length;o<l;o++)i[o].call(this,e);e.target=null}}};const Wn=["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 gv=1234567;const Ea=Math.PI/180,ko=180/Math.PI;function Ii(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Wn[s&255]+Wn[s>>8&255]+Wn[s>>16&255]+Wn[s>>24&255]+"-"+Wn[e&255]+Wn[e>>8&255]+"-"+Wn[e>>16&15|64]+Wn[e>>24&255]+"-"+Wn[t&63|128]+Wn[t>>8&255]+"-"+Wn[t>>16&255]+Wn[t>>24&255]+Wn[n&255]+Wn[n>>8&255]+Wn[n>>16&255]+Wn[n>>24&255]).toLowerCase()}function pt(s,e,t){return Math.max(e,Math.min(t,s))}function cg(s,e){return(s%e+e)%e}function pw(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function mw(s,e,t){return s!==e?(t-s)/(e-s):0}function Kl(s,e,t){return(1-t)*s+t*e}function gw(s,e,t,n){return Kl(s,e,1-Math.exp(-t*n))}function xw(s,e=1){return e-Math.abs(cg(s,e*2)-e)}function vw(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function _w(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function yw(s,e){return s+Math.floor(Math.random()*(e-s+1))}function bw(s,e){return s+Math.random()*(e-s)}function Sw(s){return s*(.5-Math.random())}function Mw(s){s!==void 0&&(gv=s);let e=gv+=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 Ew(s){return s*Ea}function ww(s){return s*ko}function Tw(s){return(s&s-1)===0&&s!==0}function Aw(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function Cw(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function Rw(s,e,t,n,i){const o=Math.cos,l=Math.sin,c=o(t/2),h=l(t/2),f=o((e+n)/2),p=l((e+n)/2),g=o((e-n)/2),m=l((e-n)/2),x=o((n-e)/2),v=l((n-e)/2);switch(i){case"XYX":s.set(c*p,h*g,h*m,c*f);break;case"YZY":s.set(h*m,c*p,h*g,c*f);break;case"ZXZ":s.set(h*g,h*m,c*p,c*f);break;case"XZX":s.set(c*p,h*v,h*x,c*f);break;case"YXY":s.set(h*x,c*p,h*v,c*f);break;case"ZYZ":s.set(h*v,h*x,c*p,c*f);break;default:He("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function ni(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function wt(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const Iw={DEG2RAD:Ea,RAD2DEG:ko,generateUUID:Ii,clamp:pt,euclideanModulo:cg,mapLinear:pw,inverseLerp:mw,lerp:Kl,damp:gw,pingpong:xw,smoothstep:vw,smootherstep:_w,randInt:yw,randFloat:bw,randFloatSpread:Sw,seededRandom:Mw,degToRad:Ew,radToDeg:ww,isPowerOfTwo:Tw,ceilPowerOfTwo:Aw,floorPowerOfTwo:Cw,setQuaternionFromProperEuler:Rw,normalize:wt,denormalize:ni};class pe{constructor(e=0,t=0){pe.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=pt(this.x,e.x,t.x),this.y=pt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=pt(this.x,e,t),this.y=pt(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(pt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(pt(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),o=this.x-e.x,l=this.y-e.y;return this.x=o*n-l*i+e.x,this.y=o*i+l*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class zn{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,o,l,c){let h=n[i+0],f=n[i+1],p=n[i+2],g=n[i+3],m=o[l+0],x=o[l+1],v=o[l+2],E=o[l+3];if(g!==E||h!==m||f!==x||p!==v){let b=h*m+f*x+p*v+g*E;b<0&&(m=-m,x=-x,v=-v,E=-E,b=-b);let _=1-c;if(b<.9995){const M=Math.acos(b),w=Math.sin(M);_=Math.sin(_*M)/w,c=Math.sin(c*M)/w,h=h*_+m*c,f=f*_+x*c,p=p*_+v*c,g=g*_+E*c}else{h=h*_+m*c,f=f*_+x*c,p=p*_+v*c,g=g*_+E*c;const M=1/Math.sqrt(h*h+f*f+p*p+g*g);h*=M,f*=M,p*=M,g*=M}}e[t]=h,e[t+1]=f,e[t+2]=p,e[t+3]=g}static multiplyQuaternionsFlat(e,t,n,i,o,l){const c=n[i],h=n[i+1],f=n[i+2],p=n[i+3],g=o[l],m=o[l+1],x=o[l+2],v=o[l+3];return e[t]=c*v+p*g+h*x-f*m,e[t+1]=h*v+p*m+f*g-c*x,e[t+2]=f*v+p*x+c*m-h*g,e[t+3]=p*v-c*g-h*m-f*x,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=!0){const n=e._x,i=e._y,o=e._z,l=e._order,c=Math.cos,h=Math.sin,f=c(n/2),p=c(i/2),g=c(o/2),m=h(n/2),x=h(i/2),v=h(o/2);switch(l){case"XYZ":this._x=m*p*g+f*x*v,this._y=f*x*g-m*p*v,this._z=f*p*v+m*x*g,this._w=f*p*g-m*x*v;break;case"YXZ":this._x=m*p*g+f*x*v,this._y=f*x*g-m*p*v,this._z=f*p*v-m*x*g,this._w=f*p*g+m*x*v;break;case"ZXY":this._x=m*p*g-f*x*v,this._y=f*x*g+m*p*v,this._z=f*p*v+m*x*g,this._w=f*p*g-m*x*v;break;case"ZYX":this._x=m*p*g-f*x*v,this._y=f*x*g+m*p*v,this._z=f*p*v-m*x*g,this._w=f*p*g+m*x*v;break;case"YZX":this._x=m*p*g+f*x*v,this._y=f*x*g+m*p*v,this._z=f*p*v-m*x*g,this._w=f*p*g-m*x*v;break;case"XZY":this._x=m*p*g-f*x*v,this._y=f*x*g-m*p*v,this._z=f*p*v+m*x*g,this._w=f*p*g+m*x*v;break;default:He("Quaternion: .setFromEuler() encountered an unknown order: "+l)}return t===!0&&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],o=t[8],l=t[1],c=t[5],h=t[9],f=t[2],p=t[6],g=t[10],m=n+c+g;if(m>0){const x=.5/Math.sqrt(m+1);this._w=.25/x,this._x=(p-h)*x,this._y=(o-f)*x,this._z=(l-i)*x}else if(n>c&&n>g){const x=2*Math.sqrt(1+n-c-g);this._w=(p-h)/x,this._x=.25*x,this._y=(i+l)/x,this._z=(o+f)/x}else if(c>g){const x=2*Math.sqrt(1+c-n-g);this._w=(o-f)/x,this._x=(i+l)/x,this._y=.25*x,this._z=(h+p)/x}else{const x=2*Math.sqrt(1+g-n-c);this._w=(l-i)/x,this._x=(o+f)/x,this._y=(h+p)/x,this._z=.25*x}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(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(pt(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,o=e._z,l=e._w,c=t._x,h=t._y,f=t._z,p=t._w;return this._x=n*p+l*c+i*f-o*h,this._y=i*p+l*h+o*c-n*f,this._z=o*p+l*f+n*h-i*c,this._w=l*p-n*c-i*h-o*f,this._onChangeCallback(),this}slerp(e,t){let n=e._x,i=e._y,o=e._z,l=e._w,c=this.dot(e);c<0&&(n=-n,i=-i,o=-o,l=-l,c=-c);let h=1-t;if(c<.9995){const f=Math.acos(c),p=Math.sin(f);h=Math.sin(h*f)/p,t=Math.sin(t*f)/p,this._x=this._x*h+n*t,this._y=this._y*h+i*t,this._z=this._z*h+o*t,this._w=this._w*h+l*t,this._onChangeCallback()}else this._x=this._x*h+n*t,this._y=this._y*h+i*t,this._z=this._z*h+o*t,this._w=this._w*h+l*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),o=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),o*Math.sin(t),o*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class O{constructor(e=0,t=0,n=0){O.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(xv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(xv.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*i,this.y=o[1]*t+o[4]*n+o[7]*i,this.z=o[2]*t+o[5]*n+o[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,o=e.elements,l=1/(o[3]*t+o[7]*n+o[11]*i+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*i+o[12])*l,this.y=(o[1]*t+o[5]*n+o[9]*i+o[13])*l,this.z=(o[2]*t+o[6]*n+o[10]*i+o[14])*l,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,o=e.x,l=e.y,c=e.z,h=e.w,f=2*(l*i-c*n),p=2*(c*t-o*i),g=2*(o*n-l*t);return this.x=t+h*f+l*g-c*p,this.y=n+h*p+c*f-o*g,this.z=i+h*g+o*p-l*f,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,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i,this.y=o[1]*t+o[5]*n+o[9]*i,this.z=o[2]*t+o[6]*n+o[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=pt(this.x,e.x,t.x),this.y=pt(this.y,e.y,t.y),this.z=pt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=pt(this.x,e,t),this.y=pt(this.y,e,t),this.z=pt(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(pt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,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,o=e.z,l=t.x,c=t.y,h=t.z;return this.x=i*h-o*c,this.y=o*l-n*h,this.z=n*c-i*l,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 yp.copy(this).projectOnVector(e),this.sub(yp)}reflect(e){return this.sub(yp.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(pt(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()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const yp=new O,xv=new zn;class St{constructor(e,t,n,i,o,l,c,h,f){St.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,o,l,c,h,f)}set(e,t,n,i,o,l,c,h,f){const p=this.elements;return p[0]=e,p[1]=i,p[2]=c,p[3]=t,p[4]=o,p[5]=h,p[6]=n,p[7]=l,p[8]=f,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,o=this.elements,l=n[0],c=n[3],h=n[6],f=n[1],p=n[4],g=n[7],m=n[2],x=n[5],v=n[8],E=i[0],b=i[3],_=i[6],M=i[1],w=i[4],T=i[7],P=i[2],R=i[5],U=i[8];return o[0]=l*E+c*M+h*P,o[3]=l*b+c*w+h*R,o[6]=l*_+c*T+h*U,o[1]=f*E+p*M+g*P,o[4]=f*b+p*w+g*R,o[7]=f*_+p*T+g*U,o[2]=m*E+x*M+v*P,o[5]=m*b+x*w+v*R,o[8]=m*_+x*T+v*U,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],o=e[3],l=e[4],c=e[5],h=e[6],f=e[7],p=e[8];return t*l*p-t*c*f-n*o*p+n*c*h+i*o*f-i*l*h}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],o=e[3],l=e[4],c=e[5],h=e[6],f=e[7],p=e[8],g=p*l-c*f,m=c*h-p*o,x=f*o-l*h,v=t*g+n*m+i*x;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const E=1/v;return e[0]=g*E,e[1]=(i*f-p*n)*E,e[2]=(c*n-i*l)*E,e[3]=m*E,e[4]=(p*t-i*h)*E,e[5]=(i*o-c*t)*E,e[6]=x*E,e[7]=(n*h-f*t)*E,e[8]=(l*t-n*o)*E,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,o,l,c){const h=Math.cos(o),f=Math.sin(o);return this.set(n*h,n*f,-n*(h*l+f*c)+l+e,-i*f,i*h,-i*(-f*l+h*c)+c+t,0,0,1),this}scale(e,t){return this.premultiply(bp.makeScale(e,t)),this}rotate(e){return this.premultiply(bp.makeRotation(-e)),this}translate(e,t){return this.premultiply(bp.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 bp=new St,vv=new St().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),_v=new St().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Pw(){const s={enabled:!0,workingColorSpace:Cr,spaces:{},convert:function(i,o,l){return this.enabled===!1||o===l||!o||!l||(this.spaces[o].transfer===Xt&&(i.r=js(i.r),i.g=js(i.g),i.b=js(i.b)),this.spaces[o].primaries!==this.spaces[l].primaries&&(i.applyMatrix3(this.spaces[o].toXYZ),i.applyMatrix3(this.spaces[l].fromXYZ)),this.spaces[l].transfer===Xt&&(i.r=Oo(i.r),i.g=Oo(i.g),i.b=Oo(i.b))),i},workingToColorSpace:function(i,o){return this.convert(i,this.workingColorSpace,o)},colorSpaceToWorking:function(i,o){return this.convert(i,o,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Ws?ac:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,o=this.workingColorSpace){return i.fromArray(this.spaces[o].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,o,l){return i.copy(this.spaces[o].toXYZ).multiply(this.spaces[l].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,o){return uc("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,o)},toWorkingColorSpace:function(i,o){return uc("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,o)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[Cr]:{primaries:e,whitePoint:n,transfer:ac,toXYZ:vv,fromXYZ:_v,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:qn},outputColorSpaceConfig:{drawingBufferColorSpace:qn}},[qn]:{primaries:e,whitePoint:n,transfer:Xt,toXYZ:vv,fromXYZ:_v,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:qn}}}),s}const Dt=Pw();function js(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Oo(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let lo;class eb{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{lo===void 0&&(lo=lc("canvas")),lo.width=e.width,lo.height=e.height;const i=lo.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=lo}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=lc("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),o=i.data;for(let l=0;l<o.length;l++)o[l]=js(o[l]/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(js(t[n]/255)*255):t[n]=js(t[n]);return{data:t,width:e.width,height:e.height}}else return He("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Lw=0;class wr{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Lw++}),this.uuid=Ii(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}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 o;if(Array.isArray(i)){o=[];for(let l=0,c=i.length;l<c;l++)i[l].isDataTexture?o.push(Sp(i[l].image)):o.push(Sp(i[l]))}else o=Sp(i);n.url=o}return t||(e.images[this.uuid]=n),n}}function Sp(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?eb.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(He("Texture: Unable to serialize Texture."),{})}let Nw=0;const Mp=new O;class un extends Ss{constructor(e=un.DEFAULT_IMAGE,t=un.DEFAULT_MAPPING,n=gi,i=gi,o=en,l=gs,c=Yn,h=ti,f=un.DEFAULT_ANISOTROPY,p=Ws){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Nw++}),this.uuid=Ii(),this.name="",this.source=new wr(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=o,this.minFilter=l,this.anisotropy=f,this.format=c,this.internalFormat=null,this.type=h,this.offset=new pe(0,0),this.repeat=new pe(1,1),this.center=new pe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new St,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=p,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Mp).x}get height(){return this.source.getSize(Mp).y}get depth(){return this.source.getSize(Mp).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){He(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){He(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}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.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==yf)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case nc:e.x=e.x-Math.floor(e.x);break;case gi:e.x=e.x<0?0:1;break;case ic: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 nc:e.y=e.y-Math.floor(e.y);break;case gi:e.y=e.y<0?0:1;break;case ic:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}un.DEFAULT_IMAGE=null;un.DEFAULT_MAPPING=yf;un.DEFAULT_ANISOTROPY=1;class Zt{constructor(e=0,t=0,n=0,i=1){Zt.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,o=this.w,l=e.elements;return this.x=l[0]*t+l[4]*n+l[8]*i+l[12]*o,this.y=l[1]*t+l[5]*n+l[9]*i+l[13]*o,this.z=l[2]*t+l[6]*n+l[10]*i+l[14]*o,this.w=l[3]*t+l[7]*n+l[11]*i+l[15]*o,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,o;const h=e.elements,f=h[0],p=h[4],g=h[8],m=h[1],x=h[5],v=h[9],E=h[2],b=h[6],_=h[10];if(Math.abs(p-m)<.01&&Math.abs(g-E)<.01&&Math.abs(v-b)<.01){if(Math.abs(p+m)<.1&&Math.abs(g+E)<.1&&Math.abs(v+b)<.1&&Math.abs(f+x+_-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(f+1)/2,T=(x+1)/2,P=(_+1)/2,R=(p+m)/4,U=(g+E)/4,A=(v+b)/4;return w>T&&w>P?w<.01?(n=0,i=.707106781,o=.707106781):(n=Math.sqrt(w),i=R/n,o=U/n):T>P?T<.01?(n=.707106781,i=0,o=.707106781):(i=Math.sqrt(T),n=R/i,o=A/i):P<.01?(n=.707106781,i=.707106781,o=0):(o=Math.sqrt(P),n=U/o,i=A/o),this.set(n,i,o,t),this}let M=Math.sqrt((b-v)*(b-v)+(g-E)*(g-E)+(m-p)*(m-p));return Math.abs(M)<.001&&(M=1),this.x=(b-v)/M,this.y=(g-E)/M,this.z=(m-p)/M,this.w=Math.acos((f+x+_-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=pt(this.x,e.x,t.x),this.y=pt(this.y,e.y,t.y),this.z=pt(this.z,e.z,t.z),this.w=pt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=pt(this.x,e,t),this.y=pt(this.y,e,t),this.z=pt(this.z,e,t),this.w=pt(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(pt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,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 ug extends Ss{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:en,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Zt(0,0,e,t),this.scissorTest=!1,this.viewport=new Zt(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:n.depth},o=new un(i),l=n.count;for(let c=0;c<l;c++)this.textures[c]=o.clone(),this.textures[c].isRenderTargetTexture=!0,this.textures[c].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:en,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}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,o=this.textures.length;i<o;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new wr(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Pi extends ug{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class If extends un{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=mn,this.minFilter=mn,this.wrapR=gi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Dw extends Pi{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new If(null,e,t,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class Pf extends un{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=mn,this.minFilter=mn,this.wrapR=gi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Uw extends Pi{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Pf(null,e,t,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class gt{constructor(e,t,n,i,o,l,c,h,f,p,g,m,x,v,E,b){gt.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,o,l,c,h,f,p,g,m,x,v,E,b)}set(e,t,n,i,o,l,c,h,f,p,g,m,x,v,E,b){const _=this.elements;return _[0]=e,_[4]=t,_[8]=n,_[12]=i,_[1]=o,_[5]=l,_[9]=c,_[13]=h,_[2]=f,_[6]=p,_[10]=g,_[14]=m,_[3]=x,_[7]=v,_[11]=E,_[15]=b,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 gt().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 this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(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){if(e.determinant()===0)return this.identity();const t=this.elements,n=e.elements,i=1/co.setFromMatrixColumn(e,0).length(),o=1/co.setFromMatrixColumn(e,1).length(),l=1/co.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]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*l,t[9]=n[9]*l,t[10]=n[10]*l,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,o=e.z,l=Math.cos(n),c=Math.sin(n),h=Math.cos(i),f=Math.sin(i),p=Math.cos(o),g=Math.sin(o);if(e.order==="XYZ"){const m=l*p,x=l*g,v=c*p,E=c*g;t[0]=h*p,t[4]=-h*g,t[8]=f,t[1]=x+v*f,t[5]=m-E*f,t[9]=-c*h,t[2]=E-m*f,t[6]=v+x*f,t[10]=l*h}else if(e.order==="YXZ"){const m=h*p,x=h*g,v=f*p,E=f*g;t[0]=m+E*c,t[4]=v*c-x,t[8]=l*f,t[1]=l*g,t[5]=l*p,t[9]=-c,t[2]=x*c-v,t[6]=E+m*c,t[10]=l*h}else if(e.order==="ZXY"){const m=h*p,x=h*g,v=f*p,E=f*g;t[0]=m-E*c,t[4]=-l*g,t[8]=v+x*c,t[1]=x+v*c,t[5]=l*p,t[9]=E-m*c,t[2]=-l*f,t[6]=c,t[10]=l*h}else if(e.order==="ZYX"){const m=l*p,x=l*g,v=c*p,E=c*g;t[0]=h*p,t[4]=v*f-x,t[8]=m*f+E,t[1]=h*g,t[5]=E*f+m,t[9]=x*f-v,t[2]=-f,t[6]=c*h,t[10]=l*h}else if(e.order==="YZX"){const m=l*h,x=l*f,v=c*h,E=c*f;t[0]=h*p,t[4]=E-m*g,t[8]=v*g+x,t[1]=g,t[5]=l*p,t[9]=-c*p,t[2]=-f*p,t[6]=x*g+v,t[10]=m-E*g}else if(e.order==="XZY"){const m=l*h,x=l*f,v=c*h,E=c*f;t[0]=h*p,t[4]=-g,t[8]=f*p,t[1]=m*g+E,t[5]=l*p,t[9]=x*g-v,t[2]=v*g-x,t[6]=c*p,t[10]=E*g+m}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(Fw,e,Ow)}lookAt(e,t,n){const i=this.elements;return Ai.subVectors(e,t),Ai.lengthSq()===0&&(Ai.z=1),Ai.normalize(),dr.crossVectors(n,Ai),dr.lengthSq()===0&&(Math.abs(n.z)===1?Ai.x+=1e-4:Ai.z+=1e-4,Ai.normalize(),dr.crossVectors(n,Ai)),dr.normalize(),yu.crossVectors(Ai,dr),i[0]=dr.x,i[4]=yu.x,i[8]=Ai.x,i[1]=dr.y,i[5]=yu.y,i[9]=Ai.y,i[2]=dr.z,i[6]=yu.z,i[10]=Ai.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,o=this.elements,l=n[0],c=n[4],h=n[8],f=n[12],p=n[1],g=n[5],m=n[9],x=n[13],v=n[2],E=n[6],b=n[10],_=n[14],M=n[3],w=n[7],T=n[11],P=n[15],R=i[0],U=i[4],A=i[8],I=i[12],B=i[1],F=i[5],j=i[9],H=i[13],Z=i[2],W=i[6],$=i[10],Y=i[14],ge=i[3],he=i[7],Ee=i[11],xe=i[15];return o[0]=l*R+c*B+h*Z+f*ge,o[4]=l*U+c*F+h*W+f*he,o[8]=l*A+c*j+h*$+f*Ee,o[12]=l*I+c*H+h*Y+f*xe,o[1]=p*R+g*B+m*Z+x*ge,o[5]=p*U+g*F+m*W+x*he,o[9]=p*A+g*j+m*$+x*Ee,o[13]=p*I+g*H+m*Y+x*xe,o[2]=v*R+E*B+b*Z+_*ge,o[6]=v*U+E*F+b*W+_*he,o[10]=v*A+E*j+b*$+_*Ee,o[14]=v*I+E*H+b*Y+_*xe,o[3]=M*R+w*B+T*Z+P*ge,o[7]=M*U+w*F+T*W+P*he,o[11]=M*A+w*j+T*$+P*Ee,o[15]=M*I+w*H+T*Y+P*xe,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],o=e[12],l=e[1],c=e[5],h=e[9],f=e[13],p=e[2],g=e[6],m=e[10],x=e[14],v=e[3],E=e[7],b=e[11],_=e[15],M=h*x-f*m,w=c*x-f*g,T=c*m-h*g,P=l*x-f*p,R=l*m-h*p,U=l*g-c*p;return t*(E*M-b*w+_*T)-n*(v*M-b*P+_*R)+i*(v*w-E*P+_*U)-o*(v*T-E*R+b*U)}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],o=e[3],l=e[4],c=e[5],h=e[6],f=e[7],p=e[8],g=e[9],m=e[10],x=e[11],v=e[12],E=e[13],b=e[14],_=e[15],M=t*c-n*l,w=t*h-i*l,T=t*f-o*l,P=n*h-i*c,R=n*f-o*c,U=i*f-o*h,A=p*E-g*v,I=p*b-m*v,B=p*_-x*v,F=g*b-m*E,j=g*_-x*E,H=m*_-x*b,Z=M*H-w*j+T*F+P*B-R*I+U*A;if(Z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const W=1/Z;return e[0]=(c*H-h*j+f*F)*W,e[1]=(i*j-n*H-o*F)*W,e[2]=(E*U-b*R+_*P)*W,e[3]=(m*R-g*U-x*P)*W,e[4]=(h*B-l*H-f*I)*W,e[5]=(t*H-i*B+o*I)*W,e[6]=(b*T-v*U-_*w)*W,e[7]=(p*U-m*T+x*w)*W,e[8]=(l*j-c*B+f*A)*W,e[9]=(n*B-t*j-o*A)*W,e[10]=(v*R-E*T+_*M)*W,e[11]=(g*T-p*R-x*M)*W,e[12]=(c*I-l*F-h*A)*W,e[13]=(t*F-n*I+i*A)*W,e[14]=(E*w-v*P-b*M)*W,e[15]=(p*P-g*w+m*M)*W,this}scale(e){const t=this.elements,n=e.x,i=e.y,o=e.z;return t[0]*=n,t[4]*=i,t[8]*=o,t[1]*=n,t[5]*=i,t[9]*=o,t[2]*=n,t[6]*=i,t[10]*=o,t[3]*=n,t[7]*=i,t[11]*=o,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),o=1-n,l=e.x,c=e.y,h=e.z,f=o*l,p=o*c;return this.set(f*l+n,f*c-i*h,f*h+i*c,0,f*c+i*h,p*c+n,p*h-i*l,0,f*h-i*c,p*h+i*l,o*h*h+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,o,l){return this.set(1,n,o,0,e,1,l,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,o=t._x,l=t._y,c=t._z,h=t._w,f=o+o,p=l+l,g=c+c,m=o*f,x=o*p,v=o*g,E=l*p,b=l*g,_=c*g,M=h*f,w=h*p,T=h*g,P=n.x,R=n.y,U=n.z;return i[0]=(1-(E+_))*P,i[1]=(x+T)*P,i[2]=(v-w)*P,i[3]=0,i[4]=(x-T)*R,i[5]=(1-(m+_))*R,i[6]=(b+M)*R,i[7]=0,i[8]=(v+w)*U,i[9]=(b-M)*U,i[10]=(1-(m+E))*U,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;e.x=i[12],e.y=i[13],e.z=i[14];const o=this.determinant();if(o===0)return n.set(1,1,1),t.identity(),this;let l=co.set(i[0],i[1],i[2]).length();const c=co.set(i[4],i[5],i[6]).length(),h=co.set(i[8],i[9],i[10]).length();o<0&&(l=-l),es.copy(this);const f=1/l,p=1/c,g=1/h;return es.elements[0]*=f,es.elements[1]*=f,es.elements[2]*=f,es.elements[4]*=p,es.elements[5]*=p,es.elements[6]*=p,es.elements[8]*=g,es.elements[9]*=g,es.elements[10]*=g,t.setFromRotationMatrix(es),n.x=l,n.y=c,n.z=h,this}makePerspective(e,t,n,i,o,l,c=Ri,h=!1){const f=this.elements,p=2*o/(t-e),g=2*o/(n-i),m=(t+e)/(t-e),x=(n+i)/(n-i);let v,E;if(h)v=o/(l-o),E=l*o/(l-o);else if(c===Ri)v=-(l+o)/(l-o),E=-2*l*o/(l-o);else if(c===Ca)v=-l/(l-o),E=-l*o/(l-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+c);return f[0]=p,f[4]=0,f[8]=m,f[12]=0,f[1]=0,f[5]=g,f[9]=x,f[13]=0,f[2]=0,f[6]=0,f[10]=v,f[14]=E,f[3]=0,f[7]=0,f[11]=-1,f[15]=0,this}makeOrthographic(e,t,n,i,o,l,c=Ri,h=!1){const f=this.elements,p=2/(t-e),g=2/(n-i),m=-(t+e)/(t-e),x=-(n+i)/(n-i);let v,E;if(h)v=1/(l-o),E=l/(l-o);else if(c===Ri)v=-2/(l-o),E=-(l+o)/(l-o);else if(c===Ca)v=-1/(l-o),E=-o/(l-o);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+c);return f[0]=p,f[4]=0,f[8]=0,f[12]=m,f[1]=0,f[5]=g,f[9]=0,f[13]=x,f[2]=0,f[6]=0,f[10]=v,f[14]=E,f[3]=0,f[7]=0,f[11]=0,f[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 co=new O,es=new gt,Fw=new O(0,0,0),Ow=new O(1,1,1),dr=new O,yu=new O,Ai=new O,yv=new gt,bv=new zn;class Li{constructor(e=0,t=0,n=0,i=Li.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,o=i[0],l=i[4],c=i[8],h=i[1],f=i[5],p=i[9],g=i[2],m=i[6],x=i[10];switch(t){case"XYZ":this._y=Math.asin(pt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-p,x),this._z=Math.atan2(-l,o)):(this._x=Math.atan2(m,f),this._z=0);break;case"YXZ":this._x=Math.asin(-pt(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(c,x),this._z=Math.atan2(h,f)):(this._y=Math.atan2(-g,o),this._z=0);break;case"ZXY":this._x=Math.asin(pt(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-g,x),this._z=Math.atan2(-l,f)):(this._y=0,this._z=Math.atan2(h,o));break;case"ZYX":this._y=Math.asin(-pt(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(m,x),this._z=Math.atan2(h,o)):(this._x=0,this._z=Math.atan2(-l,f));break;case"YZX":this._z=Math.asin(pt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-p,f),this._y=Math.atan2(-g,o)):(this._x=0,this._y=Math.atan2(c,x));break;case"XZY":this._z=Math.asin(-pt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(m,f),this._y=Math.atan2(c,o)):(this._x=Math.atan2(-p,x),this._y=0);break;default:He("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return yv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(yv,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return bv.setFromEuler(this),this.setFromQuaternion(bv,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}}Li.DEFAULT_ORDER="XYZ";class Vo{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 zw=0;const Sv=new O,uo=new zn,Fs=new gt,bu=new O,wl=new O,Bw=new O,kw=new zn,Mv=new O(1,0,0),Ev=new O(0,1,0),wv=new O(0,0,1),Tv={type:"added"},Vw={type:"removed"},ho={type:"childadded",child:null},Ep={type:"childremoved",child:null};class Ot extends Ss{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:zw++}),this.uuid=Ii(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ot.DEFAULT_UP.clone();const e=new O,t=new Li,n=new zn,i=new O(1,1,1);function o(){n.setFromEuler(t,!1)}function l(){t.setFromQuaternion(n,void 0,!1)}t._onChange(o),n._onChange(l),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 gt},normalMatrix:{value:new St}}),this.matrix=new gt,this.matrixWorld=new gt,this.matrixAutoUpdate=Ot.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ot.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Vo,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return uo.setFromAxisAngle(e,t),this.quaternion.multiply(uo),this}rotateOnWorldAxis(e,t){return uo.setFromAxisAngle(e,t),this.quaternion.premultiply(uo),this}rotateX(e){return this.rotateOnAxis(Mv,e)}rotateY(e){return this.rotateOnAxis(Ev,e)}rotateZ(e){return this.rotateOnAxis(wv,e)}translateOnAxis(e,t){return Sv.copy(e).applyQuaternion(this.quaternion),this.position.add(Sv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Mv,e)}translateY(e){return this.translateOnAxis(Ev,e)}translateZ(e){return this.translateOnAxis(wv,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Fs.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?bu.copy(e):bu.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),wl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Fs.lookAt(wl,bu,this.up):Fs.lookAt(bu,wl,this.up),this.quaternion.setFromRotationMatrix(Fs),i&&(Fs.extractRotation(i.matrixWorld),uo.setFromRotationMatrix(Fs),this.quaternion.premultiply(uo.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ot("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Tv),ho.child=e,this.dispatchEvent(ho),ho.child=null):ot("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(Vw),Ep.child=e,this.dispatchEvent(Ep),Ep.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Fs.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Fs.multiply(e.parent.matrixWorld)),e.applyMatrix4(Fs),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Tv),ho.child=e,this.dispatchEvent(ho),ho.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const l=this.children[n].getObjectByProperty(e,t);if(l!==void 0)return l}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let o=0,l=i.length;o<l;o++)i[o].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wl,e,Bw),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wl,kw,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);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,i=e.z,o=this.matrix.elements;o[12]+=t-o[0]*t-o[4]*n-o[8]*i,o[13]+=n-o[1]*t-o[5]*n-o[9]*i,o[14]+=i-o[2]*t-o[6]*n-o[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(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++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let o=0,l=i.length;o<l;o++)i[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.7,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),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(c=>({...c,boundingBox:c.boundingBox?c.boundingBox.toJSON():void 0,boundingSphere:c.boundingSphere?c.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(c=>({...c})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function o(c,h){return c[h.uuid]===void 0&&(c[h.uuid]=h.toJSON(e)),h.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=o(e.geometries,this.geometry);const c=this.geometry.parameters;if(c!==void 0&&c.shapes!==void 0){const h=c.shapes;if(Array.isArray(h))for(let f=0,p=h.length;f<p;f++){const g=h[f];o(e.shapes,g)}else o(e.shapes,h)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(o(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const c=[];for(let h=0,f=this.material.length;h<f;h++)c.push(o(e.materials,this.material[h]));i.material=c}else i.material=o(e.materials,this.material);if(this.children.length>0){i.children=[];for(let c=0;c<this.children.length;c++)i.children.push(this.children[c].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let c=0;c<this.animations.length;c++){const h=this.animations[c];i.animations.push(o(e.animations,h))}}if(t){const c=l(e.geometries),h=l(e.materials),f=l(e.textures),p=l(e.images),g=l(e.shapes),m=l(e.skeletons),x=l(e.animations),v=l(e.nodes);c.length>0&&(n.geometries=c),h.length>0&&(n.materials=h),f.length>0&&(n.textures=f),p.length>0&&(n.images=p),g.length>0&&(n.shapes=g),m.length>0&&(n.skeletons=m),x.length>0&&(n.animations=x),v.length>0&&(n.nodes=v)}return n.object=i,n;function l(c){const h=[];for(const f in c){const p=c[f];delete p.metadata,h.push(p)}return h}}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),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}Ot.DEFAULT_UP=new O(0,1,0);Ot.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ot.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Uo extends Ot{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Hw={type:"move"};class gh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Uo,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 Uo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Uo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O),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,o=null,l=null;const c=this._targetRay,h=this._grip,f=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(f&&e.hand){l=!0;for(const E of e.hand.values()){const b=t.getJointPose(E,n),_=this._getHandJoint(f,E);b!==null&&(_.matrix.fromArray(b.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,_.jointRadius=b.radius),_.visible=b!==null}const p=f.joints["index-finger-tip"],g=f.joints["thumb-tip"],m=p.position.distanceTo(g.position),x=.02,v=.005;f.inputState.pinching&&m>x+v?(f.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!f.inputState.pinching&&m<=x-v&&(f.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else h!==null&&e.gripSpace&&(o=t.getPose(e.gripSpace,n),o!==null&&(h.matrix.fromArray(o.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,o.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(o.linearVelocity)):h.hasLinearVelocity=!1,o.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(o.angularVelocity)):h.hasAngularVelocity=!1));c!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&o!==null&&(i=o),i!==null&&(c.matrix.fromArray(i.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,i.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(i.linearVelocity)):c.hasLinearVelocity=!1,i.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(i.angularVelocity)):c.hasAngularVelocity=!1,this.dispatchEvent(Hw)))}return c!==null&&(c.visible=i!==null),h!==null&&(h.visible=o!==null),f!==null&&(f.visible=l!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Uo;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const tb={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},pr={h:0,s:0,l:0},Su={h:0,s:0,l:0};function wp(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class Ye{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=qn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Dt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=Dt.workingColorSpace){return this.r=e,this.g=t,this.b=n,Dt.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=Dt.workingColorSpace){if(e=cg(e,1),t=pt(t,0,1),n=pt(n,0,1),t===0)this.r=this.g=this.b=n;else{const o=n<=.5?n*(1+t):n+t-n*t,l=2*n-o;this.r=wp(l,o,e+1/3),this.g=wp(l,o,e),this.b=wp(l,o,e-1/3)}return Dt.colorSpaceToWorking(this,i),this}setStyle(e,t=qn){function n(o){o!==void 0&&parseFloat(o)<1&&He("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let o;const l=i[1],c=i[2];switch(l){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setRGB(Math.min(255,parseInt(o[1],10))/255,Math.min(255,parseInt(o[2],10))/255,Math.min(255,parseInt(o[3],10))/255,t);if(o=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setRGB(Math.min(100,parseInt(o[1],10))/100,Math.min(100,parseInt(o[2],10))/100,Math.min(100,parseInt(o[3],10))/100,t);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setHSL(parseFloat(o[1])/360,parseFloat(o[2])/100,parseFloat(o[3])/100,t);break;default:He("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const o=i[1],l=o.length;if(l===3)return this.setRGB(parseInt(o.charAt(0),16)/15,parseInt(o.charAt(1),16)/15,parseInt(o.charAt(2),16)/15,t);if(l===6)return this.setHex(parseInt(o,16),t);He("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=qn){const n=tb[e.toLowerCase()];return n!==void 0?this.setHex(n,t):He("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=js(e.r),this.g=js(e.g),this.b=js(e.b),this}copyLinearToSRGB(e){return this.r=Oo(e.r),this.g=Oo(e.g),this.b=Oo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=qn){return Dt.workingToColorSpace(Xn.copy(this),e),Math.round(pt(Xn.r*255,0,255))*65536+Math.round(pt(Xn.g*255,0,255))*256+Math.round(pt(Xn.b*255,0,255))}getHexString(e=qn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Dt.workingColorSpace){Dt.workingToColorSpace(Xn.copy(this),t);const n=Xn.r,i=Xn.g,o=Xn.b,l=Math.max(n,i,o),c=Math.min(n,i,o);let h,f;const p=(c+l)/2;if(c===l)h=0,f=0;else{const g=l-c;switch(f=p<=.5?g/(l+c):g/(2-l-c),l){case n:h=(i-o)/g+(i<o?6:0);break;case i:h=(o-n)/g+2;break;case o:h=(n-i)/g+4;break}h/=6}return e.h=h,e.s=f,e.l=p,e}getRGB(e,t=Dt.workingColorSpace){return Dt.workingToColorSpace(Xn.copy(this),t),e.r=Xn.r,e.g=Xn.g,e.b=Xn.b,e}getStyle(e=qn){Dt.workingToColorSpace(Xn.copy(this),e);const t=Xn.r,n=Xn.g,i=Xn.b;return e!==qn?`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(pr),this.setHSL(pr.h+e,pr.s+t,pr.l+n)}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(pr),e.getHSL(Su);const n=Kl(pr.h,Su.h,t),i=Kl(pr.s,Su.s,t),o=Kl(pr.l,Su.l,t);return this.setHSL(n,i,o),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,o=e.elements;return this.r=o[0]*t+o[3]*n+o[6]*i,this.g=o[1]*t+o[4]*n+o[7]*i,this.b=o[2]*t+o[5]*n+o[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 Xn=new Ye;Ye.NAMES=tb;class Lf{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ye(e),this.density=t}clone(){return new Lf(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Nf{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 Nf(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class hg extends Ot{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Li,this.environmentIntensity=1,this.environmentRotation=new Li,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const ts=new O,Os=new O,Tp=new O,zs=new O,fo=new O,po=new O,Av=new O,Ap=new O,Cp=new O,Rp=new O,Ip=new Zt,Pp=new Zt,Lp=new Zt;class mi{constructor(e=new O,t=new O,n=new O){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),ts.subVectors(e,t),i.cross(ts);const o=i.lengthSq();return o>0?i.multiplyScalar(1/Math.sqrt(o)):i.set(0,0,0)}static getBarycoord(e,t,n,i,o){ts.subVectors(i,t),Os.subVectors(n,t),Tp.subVectors(e,t);const l=ts.dot(ts),c=ts.dot(Os),h=ts.dot(Tp),f=Os.dot(Os),p=Os.dot(Tp),g=l*f-c*c;if(g===0)return o.set(0,0,0),null;const m=1/g,x=(f*h-c*p)*m,v=(l*p-c*h)*m;return o.set(1-x-v,v,x)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,zs)===null?!1:zs.x>=0&&zs.y>=0&&zs.x+zs.y<=1}static getInterpolation(e,t,n,i,o,l,c,h){return this.getBarycoord(e,t,n,i,zs)===null?(h.x=0,h.y=0,"z"in h&&(h.z=0),"w"in h&&(h.w=0),null):(h.setScalar(0),h.addScaledVector(o,zs.x),h.addScaledVector(l,zs.y),h.addScaledVector(c,zs.z),h)}static getInterpolatedAttribute(e,t,n,i,o,l){return Ip.setScalar(0),Pp.setScalar(0),Lp.setScalar(0),Ip.fromBufferAttribute(e,t),Pp.fromBufferAttribute(e,n),Lp.fromBufferAttribute(e,i),l.setScalar(0),l.addScaledVector(Ip,o.x),l.addScaledVector(Pp,o.y),l.addScaledVector(Lp,o.z),l}static isFrontFacing(e,t,n,i){return ts.subVectors(n,t),Os.subVectors(e,t),ts.cross(Os).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 ts.subVectors(this.c,this.b),Os.subVectors(this.a,this.b),ts.cross(Os).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return mi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return mi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,o){return mi.getInterpolation(e,this.a,this.b,this.c,t,n,i,o)}containsPoint(e){return mi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return mi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,o=this.c;let l,c;fo.subVectors(i,n),po.subVectors(o,n),Ap.subVectors(e,n);const h=fo.dot(Ap),f=po.dot(Ap);if(h<=0&&f<=0)return t.copy(n);Cp.subVectors(e,i);const p=fo.dot(Cp),g=po.dot(Cp);if(p>=0&&g<=p)return t.copy(i);const m=h*g-p*f;if(m<=0&&h>=0&&p<=0)return l=h/(h-p),t.copy(n).addScaledVector(fo,l);Rp.subVectors(e,o);const x=fo.dot(Rp),v=po.dot(Rp);if(v>=0&&x<=v)return t.copy(o);const E=x*f-h*v;if(E<=0&&f>=0&&v<=0)return c=f/(f-v),t.copy(n).addScaledVector(po,c);const b=p*v-x*g;if(b<=0&&g-p>=0&&x-v>=0)return Av.subVectors(o,i),c=(g-p)/(g-p+(x-v)),t.copy(i).addScaledVector(Av,c);const _=1/(b+E+m);return l=E*_,c=m*_,t.copy(n).addScaledVector(fo,l).addScaledVector(po,c)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class $n{constructor(e=new O(1/0,1/0,1/0),t=new O(-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(ns.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(ns.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=ns.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){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const o=n.getAttribute("position");if(t===!0&&o!==void 0&&e.isInstancedMesh!==!0)for(let l=0,c=o.count;l<c;l++)e.isMesh===!0?e.getVertexPosition(l,ns):ns.fromBufferAttribute(o,l),ns.applyMatrix4(e.matrixWorld),this.expandByPoint(ns);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Mu.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Mu.copy(n.boundingBox)),Mu.applyMatrix4(e.matrixWorld),this.union(Mu)}const i=e.children;for(let o=0,l=i.length;o<l;o++)this.expandByObject(i[o],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,ns),ns.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(Tl),Eu.subVectors(this.max,Tl),mo.subVectors(e.a,Tl),go.subVectors(e.b,Tl),xo.subVectors(e.c,Tl),mr.subVectors(go,mo),gr.subVectors(xo,go),ea.subVectors(mo,xo);let t=[0,-mr.z,mr.y,0,-gr.z,gr.y,0,-ea.z,ea.y,mr.z,0,-mr.x,gr.z,0,-gr.x,ea.z,0,-ea.x,-mr.y,mr.x,0,-gr.y,gr.x,0,-ea.y,ea.x,0];return!Np(t,mo,go,xo,Eu)||(t=[1,0,0,0,1,0,0,0,1],!Np(t,mo,go,xo,Eu))?!1:(wu.crossVectors(mr,gr),t=[wu.x,wu.y,wu.z],Np(t,mo,go,xo,Eu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ns).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ns).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:(Bs[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Bs[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Bs[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Bs[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Bs[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Bs[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Bs[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Bs[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Bs),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Bs=[new O,new O,new O,new O,new O,new O,new O,new O],ns=new O,Mu=new $n,mo=new O,go=new O,xo=new O,mr=new O,gr=new O,ea=new O,Tl=new O,Eu=new O,wu=new O,ta=new O;function Np(s,e,t,n,i){for(let o=0,l=s.length-3;o<=l;o+=3){ta.fromArray(s,o);const c=i.x*Math.abs(ta.x)+i.y*Math.abs(ta.y)+i.z*Math.abs(ta.z),h=e.dot(ta),f=t.dot(ta),p=n.dot(ta);if(Math.max(-Math.max(h,f,p),Math.min(h,f,p))>c)return!1}return!0}const Xs=Gw();function Gw(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let h=0;h<256;++h){const f=h-127;f<-27?(n[h]=0,n[h|256]=32768,i[h]=24,i[h|256]=24):f<-14?(n[h]=1024>>-f-14,n[h|256]=1024>>-f-14|32768,i[h]=-f-1,i[h|256]=-f-1):f<=15?(n[h]=f+15<<10,n[h|256]=f+15<<10|32768,i[h]=13,i[h|256]=13):f<128?(n[h]=31744,n[h|256]=64512,i[h]=24,i[h|256]=24):(n[h]=31744,n[h|256]=64512,i[h]=13,i[h|256]=13)}const o=new Uint32Array(2048),l=new Uint32Array(64),c=new Uint32Array(64);for(let h=1;h<1024;++h){let f=h<<13,p=0;for(;(f&8388608)===0;)f<<=1,p-=8388608;f&=-8388609,p+=947912704,o[h]=f|p}for(let h=1024;h<2048;++h)o[h]=939524096+(h-1024<<13);for(let h=1;h<31;++h)l[h]=h<<23;l[31]=1199570944,l[32]=2147483648;for(let h=33;h<63;++h)l[h]=2147483648+(h-32<<23);l[63]=3347054592;for(let h=1;h<64;++h)h!==32&&(c[h]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:o,exponentTable:l,offsetTable:c}}function fi(s){Math.abs(s)>65504&&He("DataUtils.toHalfFloat(): Value out of range."),s=pt(s,-65504,65504),Xs.floatView[0]=s;const e=Xs.uint32View[0],t=e>>23&511;return Xs.baseTable[t]+((e&8388607)>>Xs.shiftTable[t])}function kl(s){const e=s>>10;return Xs.uint32View[0]=Xs.mantissaTable[Xs.offsetTable[e]+(s&1023)]+Xs.exponentTable[e],Xs.floatView[0]}class Ww{static toHalfFloat(e){return fi(e)}static fromHalfFloat(e){return kl(e)}}const bn=new O,Tu=new pe;let Xw=0;class Yt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Xw++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=oc,this.updateRanges=[],this.gpuType=ii,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,o=this.itemSize;i<o;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++)Tu.fromBufferAttribute(this,t),Tu.applyMatrix3(e),this.setXY(t,Tu.x,Tu.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.applyMatrix3(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.applyMatrix4(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.applyNormalMatrix(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.transformDirection(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=ni(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=wt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ni(t,this.array)),t}setX(e,t){return this.normalized&&(t=wt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ni(t,this.array)),t}setY(e,t){return this.normalized&&(t=wt(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=ni(t,this.array)),t}setZ(e,t){return this.normalized&&(t=wt(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=ni(t,this.array)),t}setW(e,t){return this.normalized&&(t=wt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=wt(t,this.array),n=wt(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=wt(t,this.array),n=wt(n,this.array),i=wt(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,o){return e*=this.itemSize,this.normalized&&(t=wt(t,this.array),n=wt(n,this.array),i=wt(i,this.array),o=wt(o,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=o,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!==oc&&(e.usage=this.usage),e}}class jw extends Yt{constructor(e,t,n){super(new Int8Array(e),t,n)}}class qw extends Yt{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class Yw extends Yt{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class $w extends Yt{constructor(e,t,n){super(new Int16Array(e),t,n)}}class fg extends Yt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Zw extends Yt{constructor(e,t,n){super(new Int32Array(e),t,n)}}class dg extends Yt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Kw extends Yt{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=kl(this.array[e*this.itemSize]);return this.normalized&&(t=ni(t,this.array)),t}setX(e,t){return this.normalized&&(t=wt(t,this.array)),this.array[e*this.itemSize]=fi(t),this}getY(e){let t=kl(this.array[e*this.itemSize+1]);return this.normalized&&(t=ni(t,this.array)),t}setY(e,t){return this.normalized&&(t=wt(t,this.array)),this.array[e*this.itemSize+1]=fi(t),this}getZ(e){let t=kl(this.array[e*this.itemSize+2]);return this.normalized&&(t=ni(t,this.array)),t}setZ(e,t){return this.normalized&&(t=wt(t,this.array)),this.array[e*this.itemSize+2]=fi(t),this}getW(e){let t=kl(this.array[e*this.itemSize+3]);return this.normalized&&(t=ni(t,this.array)),t}setW(e,t){return this.normalized&&(t=wt(t,this.array)),this.array[e*this.itemSize+3]=fi(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=wt(t,this.array),n=wt(n,this.array)),this.array[e+0]=fi(t),this.array[e+1]=fi(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=wt(t,this.array),n=wt(n,this.array),i=wt(i,this.array)),this.array[e+0]=fi(t),this.array[e+1]=fi(n),this.array[e+2]=fi(i),this}setXYZW(e,t,n,i,o){return e*=this.itemSize,this.normalized&&(t=wt(t,this.array),n=wt(n,this.array),i=wt(i,this.array),o=wt(o,this.array)),this.array[e+0]=fi(t),this.array[e+1]=fi(n),this.array[e+2]=fi(i),this.array[e+3]=fi(o),this}}class et extends Yt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Jw=new $n,Al=new O,Dp=new O;let Bn=class{constructor(e=new O,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Jw.setFromPoints(e).getCenter(n);let i=0;for(let o=0,l=e.length;o<l;o++)i=Math.max(i,n.distanceToSquared(e[o]));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;Al.subVectors(e,this.center);const t=Al.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Al,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):(Dp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Al.copy(e.center).add(Dp)),this.expandByPoint(Al.copy(e.center).sub(Dp))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Qw=0;const zi=new gt,Up=new Ot,vo=new O,Ci=new $n,Cl=new $n,Nn=new O;class _t extends Ss{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Qw++}),this.uuid=Ii(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(lw(e)?dg:fg)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return 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 o=new St().getNormalMatrix(e);n.applyNormalMatrix(o),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 zi.makeRotationFromQuaternion(e),this.applyMatrix4(zi),this}rotateX(e){return zi.makeRotationX(e),this.applyMatrix4(zi),this}rotateY(e){return zi.makeRotationY(e),this.applyMatrix4(zi),this}rotateZ(e){return zi.makeRotationZ(e),this.applyMatrix4(zi),this}translate(e,t,n){return zi.makeTranslation(e,t,n),this.applyMatrix4(zi),this}scale(e,t,n){return zi.makeScale(e,t,n),this.applyMatrix4(zi),this}lookAt(e){return Up.lookAt(e),Up.updateMatrix(),this.applyMatrix4(Up.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vo).negate(),this.translate(vo.x,vo.y,vo.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,o=e.length;i<o;i++){const l=e[i];n.push(l.x,l.y,l.z||0)}this.setAttribute("position",new et(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const o=e[i];t.setXYZ(i,o.x,o.y,o.z||0)}e.length>t.count&&He("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new $n);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ot("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(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 o=t[n];Ci.setFromBufferAttribute(o),this.morphTargetsRelative?(Nn.addVectors(this.boundingBox.min,Ci.min),this.boundingBox.expandByPoint(Nn),Nn.addVectors(this.boundingBox.max,Ci.max),this.boundingBox.expandByPoint(Nn)):(this.boundingBox.expandByPoint(Ci.min),this.boundingBox.expandByPoint(Ci.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ot('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 Bn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ot("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(e){const n=this.boundingSphere.center;if(Ci.setFromBufferAttribute(e),t)for(let o=0,l=t.length;o<l;o++){const c=t[o];Cl.setFromBufferAttribute(c),this.morphTargetsRelative?(Nn.addVectors(Ci.min,Cl.min),Ci.expandByPoint(Nn),Nn.addVectors(Ci.max,Cl.max),Ci.expandByPoint(Nn)):(Ci.expandByPoint(Cl.min),Ci.expandByPoint(Cl.max))}Ci.getCenter(n);let i=0;for(let o=0,l=e.count;o<l;o++)Nn.fromBufferAttribute(e,o),i=Math.max(i,n.distanceToSquared(Nn));if(t)for(let o=0,l=t.length;o<l;o++){const c=t[o],h=this.morphTargetsRelative;for(let f=0,p=c.count;f<p;f++)Nn.fromBufferAttribute(c,f),h&&(vo.fromBufferAttribute(e,f),Nn.add(vo)),i=Math.max(i,n.distanceToSquared(Nn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ot('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){ot("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,o=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Yt(new Float32Array(4*n.count),4));const l=this.getAttribute("tangent"),c=[],h=[];for(let A=0;A<n.count;A++)c[A]=new O,h[A]=new O;const f=new O,p=new O,g=new O,m=new pe,x=new pe,v=new pe,E=new O,b=new O;function _(A,I,B){f.fromBufferAttribute(n,A),p.fromBufferAttribute(n,I),g.fromBufferAttribute(n,B),m.fromBufferAttribute(o,A),x.fromBufferAttribute(o,I),v.fromBufferAttribute(o,B),p.sub(f),g.sub(f),x.sub(m),v.sub(m);const F=1/(x.x*v.y-v.x*x.y);isFinite(F)&&(E.copy(p).multiplyScalar(v.y).addScaledVector(g,-x.y).multiplyScalar(F),b.copy(g).multiplyScalar(x.x).addScaledVector(p,-v.x).multiplyScalar(F),c[A].add(E),c[I].add(E),c[B].add(E),h[A].add(b),h[I].add(b),h[B].add(b))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let A=0,I=M.length;A<I;++A){const B=M[A],F=B.start,j=B.count;for(let H=F,Z=F+j;H<Z;H+=3)_(e.getX(H+0),e.getX(H+1),e.getX(H+2))}const w=new O,T=new O,P=new O,R=new O;function U(A){P.fromBufferAttribute(i,A),R.copy(P);const I=c[A];w.copy(I),w.sub(P.multiplyScalar(P.dot(I))).normalize(),T.crossVectors(R,I);const F=T.dot(h[A])<0?-1:1;l.setXYZW(A,w.x,w.y,w.z,F)}for(let A=0,I=M.length;A<I;++A){const B=M[A],F=B.start,j=B.count;for(let H=F,Z=F+j;H<Z;H+=3)U(e.getX(H+0)),U(e.getX(H+1)),U(e.getX(H+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 Yt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let m=0,x=n.count;m<x;m++)n.setXYZ(m,0,0,0);const i=new O,o=new O,l=new O,c=new O,h=new O,f=new O,p=new O,g=new O;if(e)for(let m=0,x=e.count;m<x;m+=3){const v=e.getX(m+0),E=e.getX(m+1),b=e.getX(m+2);i.fromBufferAttribute(t,v),o.fromBufferAttribute(t,E),l.fromBufferAttribute(t,b),p.subVectors(l,o),g.subVectors(i,o),p.cross(g),c.fromBufferAttribute(n,v),h.fromBufferAttribute(n,E),f.fromBufferAttribute(n,b),c.add(p),h.add(p),f.add(p),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(E,h.x,h.y,h.z),n.setXYZ(b,f.x,f.y,f.z)}else for(let m=0,x=t.count;m<x;m+=3)i.fromBufferAttribute(t,m+0),o.fromBufferAttribute(t,m+1),l.fromBufferAttribute(t,m+2),p.subVectors(l,o),g.subVectors(i,o),p.cross(g),n.setXYZ(m+0,p.x,p.y,p.z),n.setXYZ(m+1,p.x,p.y,p.z),n.setXYZ(m+2,p.x,p.y,p.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Nn.fromBufferAttribute(e,t),Nn.normalize(),e.setXYZ(t,Nn.x,Nn.y,Nn.z)}toNonIndexed(){function e(c,h){const f=c.array,p=c.itemSize,g=c.normalized,m=new f.constructor(h.length*p);let x=0,v=0;for(let E=0,b=h.length;E<b;E++){c.isInterleavedBufferAttribute?x=h[E]*c.data.stride+c.offset:x=h[E]*p;for(let _=0;_<p;_++)m[v++]=f[x++]}return new Yt(m,p,g)}if(this.index===null)return He("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new _t,n=this.index.array,i=this.attributes;for(const c in i){const h=i[c],f=e(h,n);t.setAttribute(c,f)}const o=this.morphAttributes;for(const c in o){const h=[],f=o[c];for(let p=0,g=f.length;p<g;p++){const m=f[p],x=e(m,n);h.push(x)}t.morphAttributes[c]=h}t.morphTargetsRelative=this.morphTargetsRelative;const l=this.groups;for(let c=0,h=l.length;c<h;c++){const f=l[c];t.addGroup(f.start,f.count,f.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,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 h=this.parameters;for(const f in h)h[f]!==void 0&&(e[f]=h[f]);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 h in n){const f=n[h];e.data.attributes[h]=f.toJSON(e.data)}const i={};let o=!1;for(const h in this.morphAttributes){const f=this.morphAttributes[h],p=[];for(let g=0,m=f.length;g<m;g++){const x=f[g];p.push(x.toJSON(e.data))}p.length>0&&(i[h]=p,o=!0)}o&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const l=this.groups;l.length>0&&(e.data.groups=JSON.parse(JSON.stringify(l)));const c=this.boundingSphere;return c!==null&&(e.data.boundingSphere=c.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const f in i){const p=i[f];this.setAttribute(f,p.clone(t))}const o=e.morphAttributes;for(const f in o){const p=[],g=o[f];for(let m=0,x=g.length;m<x;m++)p.push(g[m].clone(t));this.morphAttributes[f]=p}this.morphTargetsRelative=e.morphTargetsRelative;const l=e.groups;for(let f=0,p=l.length;f<p;f++){const g=l[f];this.addGroup(g.start,g.count,g.materialIndex)}const c=e.boundingBox;c!==null&&(this.boundingBox=c.clone());const h=e.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Df{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=oc,this.updateRanges=[],this.version=0,this.uuid=Ii()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,o=this.stride;i<o;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=Ii()),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=Ii()),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 Qn=new O;class Ra{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++)Qn.fromBufferAttribute(this,t),Qn.applyMatrix4(e),this.setXYZ(t,Qn.x,Qn.y,Qn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Qn.fromBufferAttribute(this,t),Qn.applyNormalMatrix(e),this.setXYZ(t,Qn.x,Qn.y,Qn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Qn.fromBufferAttribute(this,t),Qn.transformDirection(e),this.setXYZ(t,Qn.x,Qn.y,Qn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=ni(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=wt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=wt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=wt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=wt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=wt(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=ni(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ni(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ni(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ni(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=wt(t,this.array),n=wt(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=wt(t,this.array),n=wt(n,this.array),i=wt(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,o){return e=e*this.data.stride+this.offset,this.normalized&&(t=wt(t,this.array),n=wt(n,this.array),i=wt(i,this.array),o=wt(o,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]=o,this}clone(e){if(e===void 0){cc("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 o=0;o<this.itemSize;o++)t.push(this.data.array[i+o])}return new Yt(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 Ra(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){cc("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 o=0;o<this.itemSize;o++)t.push(this.data.array[i+o])}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}}}let eT=0;class Zn extends Ss{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:eT++}),this.uuid=Ii(),this.name="",this.type="Material",this.blending=Ma,this.side=qs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=bh,this.blendDst=Sh,this.blendEquation=Sr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ye(0,0,0),this.blendAlpha=0,this.depthFunc=Ta,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Rm,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=xa,this.stencilZFail=xa,this.stencilZPass=xa,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){He(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){He(`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.7,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!==void 0&&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.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),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.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),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!==Ma&&(n.blending=this.blending),this.side!==qs&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==bh&&(n.blendSrc=this.blendSrc),this.blendDst!==Sh&&(n.blendDst=this.blendDst),this.blendEquation!==Sr&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ta&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Rm&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==xa&&(n.stencilFail=this.stencilFail),this.stencilZFail!==xa&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==xa&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),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=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),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=!0),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(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}if(t){const o=i(e.textures),l=i(e.images);o.length>0&&(n.textures=o),l.length>0&&(n.images=l)}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.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let o=0;o!==i;++o)n[o]=t[o].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.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class pg extends Zn{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 _o;const Rl=new O,yo=new O,bo=new O,So=new pe,Il=new pe,nb=new gt,Au=new O,Pl=new O,Cu=new O,Cv=new pe,Fp=new pe,Rv=new pe;class ib extends Ot{constructor(e=new pg){if(super(),this.isSprite=!0,this.type="Sprite",_o===void 0){_o=new _t;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 Df(t,5);_o.setIndex([0,1,2,0,2,3]),_o.setAttribute("position",new Ra(n,3,0,!1)),_o.setAttribute("uv",new Ra(n,2,3,!1))}this.geometry=_o,this.material=e,this.center=new pe(.5,.5),this.count=1}raycast(e,t){e.camera===null&&ot('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),yo.setFromMatrixScale(this.matrixWorld),nb.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),bo.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&yo.multiplyScalar(-bo.z);const n=this.material.rotation;let i,o;n!==0&&(o=Math.cos(n),i=Math.sin(n));const l=this.center;Ru(Au.set(-.5,-.5,0),bo,l,yo,i,o),Ru(Pl.set(.5,-.5,0),bo,l,yo,i,o),Ru(Cu.set(.5,.5,0),bo,l,yo,i,o),Cv.set(0,0),Fp.set(1,0),Rv.set(1,1);let c=e.ray.intersectTriangle(Au,Pl,Cu,!1,Rl);if(c===null&&(Ru(Pl.set(-.5,.5,0),bo,l,yo,i,o),Fp.set(0,1),c=e.ray.intersectTriangle(Au,Cu,Pl,!1,Rl),c===null))return;const h=e.ray.origin.distanceTo(Rl);h<e.near||h>e.far||t.push({distance:h,point:Rl.clone(),uv:mi.getInterpolation(Rl,Au,Pl,Cu,Cv,Fp,Rv,new pe),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 Ru(s,e,t,n,i,o){So.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(Il.x=o*So.x-i*So.y,Il.y=i*So.x+o*So.y):Il.copy(So),s.copy(e),s.x+=Il.x,s.y+=Il.y,s.applyMatrix4(nb)}const Iu=new O,Iv=new O;class sb extends Ot{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n<i;n++){const o=t[n];this.addLevel(o.object.clone(),o.distance,o.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let o;for(o=0;o<i.length&&!(t<i[o].distance);o++);return i.splice(o,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const i=t.splice(n,1);return this.remove(i[0].object),!0}return!1}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 o=t[n].distance;if(t[n].object.visible&&(o-=o*t[n].hysteresis),e<o)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Iu.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Iu);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Iu.setFromMatrixPosition(e.matrixWorld),Iv.setFromMatrixPosition(this.matrixWorld);const n=Iu.distanceTo(Iv)/e.zoom;t[0].object.visible=!0;let i,o;for(i=1,o=t.length;i<o;i++){let l=t[i].distance;if(t[i].object.visible&&(l-=l*t[i].hysteresis),n>=l)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<o;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,o=n.length;i<o;i++){const l=n[i];t.object.levels.push({object:l.object.uuid,distance:l.distance,hysteresis:l.hysteresis})}return t}}const ks=new O,Op=new O,Pu=new O,xr=new O,zp=new O,Lu=new O,Bp=new O;class La{constructor(e=new O,t=new O(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,ks)),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=ks.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ks.copy(this.origin).addScaledVector(this.direction,t),ks.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Op.copy(e).add(t).multiplyScalar(.5),Pu.copy(t).sub(e).normalize(),xr.copy(this.origin).sub(Op);const o=e.distanceTo(t)*.5,l=-this.direction.dot(Pu),c=xr.dot(this.direction),h=-xr.dot(Pu),f=xr.lengthSq(),p=Math.abs(1-l*l);let g,m,x,v;if(p>0)if(g=l*h-c,m=l*c-h,v=o*p,g>=0)if(m>=-v)if(m<=v){const E=1/p;g*=E,m*=E,x=g*(g+l*m+2*c)+m*(l*g+m+2*h)+f}else m=o,g=Math.max(0,-(l*m+c)),x=-g*g+m*(m+2*h)+f;else m=-o,g=Math.max(0,-(l*m+c)),x=-g*g+m*(m+2*h)+f;else m<=-v?(g=Math.max(0,-(-l*o+c)),m=g>0?-o:Math.min(Math.max(-o,-h),o),x=-g*g+m*(m+2*h)+f):m<=v?(g=0,m=Math.min(Math.max(-o,-h),o),x=m*(m+2*h)+f):(g=Math.max(0,-(l*o+c)),m=g>0?o:Math.min(Math.max(-o,-h),o),x=-g*g+m*(m+2*h)+f);else m=l>0?-o:o,g=Math.max(0,-(l*m+c)),x=-g*g+m*(m+2*h)+f;return n&&n.copy(this.origin).addScaledVector(this.direction,g),i&&i.copy(Op).addScaledVector(Pu,m),x}intersectSphere(e,t){ks.subVectors(e.center,this.origin);const n=ks.dot(this.direction),i=ks.dot(ks)-n*n,o=e.radius*e.radius;if(i>o)return null;const l=Math.sqrt(o-i),c=n-l,h=n+l;return h<0?null:c<0?this.at(h,t):this.at(c,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const 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,o,l,c,h;const f=1/this.direction.x,p=1/this.direction.y,g=1/this.direction.z,m=this.origin;return f>=0?(n=(e.min.x-m.x)*f,i=(e.max.x-m.x)*f):(n=(e.max.x-m.x)*f,i=(e.min.x-m.x)*f),p>=0?(o=(e.min.y-m.y)*p,l=(e.max.y-m.y)*p):(o=(e.max.y-m.y)*p,l=(e.min.y-m.y)*p),n>l||o>i||((o>n||isNaN(n))&&(n=o),(l<i||isNaN(i))&&(i=l),g>=0?(c=(e.min.z-m.z)*g,h=(e.max.z-m.z)*g):(c=(e.max.z-m.z)*g,h=(e.min.z-m.z)*g),n>h||c>i)||((c>n||n!==n)&&(n=c),(h<i||i!==i)&&(i=h),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,ks)!==null}intersectTriangle(e,t,n,i,o){zp.subVectors(t,e),Lu.subVectors(n,e),Bp.crossVectors(zp,Lu);let l=this.direction.dot(Bp),c;if(l>0){if(i)return null;c=1}else if(l<0)c=-1,l=-l;else return null;xr.subVectors(this.origin,e);const h=c*this.direction.dot(Lu.crossVectors(xr,Lu));if(h<0)return null;const f=c*this.direction.dot(zp.cross(xr));if(f<0||h+f>l)return null;const p=-c*xr.dot(Bp);return p<0?null:this.at(p/l,o)}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 Pr extends Zn{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.envMapRotation=new Li,this.combine=bc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Pv=new gt,na=new La,Nu=new Bn,Lv=new O,Du=new O,Uu=new O,Fu=new O,kp=new O,Ou=new O,Nv=new O,zu=new O;class Sn extends Ot{constructor(e=new _t,t=new Pr){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():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 o=0,l=i.length;o<l;o++){const c=i[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,o=n.morphAttributes.position,l=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const c=this.morphTargetInfluences;if(o&&c){Ou.set(0,0,0);for(let h=0,f=o.length;h<f;h++){const p=c[h],g=o[h];p!==0&&(kp.fromBufferAttribute(g,e),l?Ou.addScaledVector(kp,p):Ou.addScaledVector(kp.sub(t),p))}t.add(Ou)}return t}raycast(e,t){const n=this.geometry,i=this.material,o=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Nu.copy(n.boundingSphere),Nu.applyMatrix4(o),na.copy(e.ray).recast(e.near),!(Nu.containsPoint(na.origin)===!1&&(na.intersectSphere(Nu,Lv)===null||na.origin.distanceToSquared(Lv)>(e.far-e.near)**2))&&(Pv.copy(o).invert(),na.copy(e.ray).applyMatrix4(Pv),!(n.boundingBox!==null&&na.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,na)))}_computeIntersections(e,t,n){let i;const o=this.geometry,l=this.material,c=o.index,h=o.attributes.position,f=o.attributes.uv,p=o.attributes.uv1,g=o.attributes.normal,m=o.groups,x=o.drawRange;if(c!==null)if(Array.isArray(l))for(let v=0,E=m.length;v<E;v++){const b=m[v],_=l[b.materialIndex],M=Math.max(b.start,x.start),w=Math.min(c.count,Math.min(b.start+b.count,x.start+x.count));for(let T=M,P=w;T<P;T+=3){const R=c.getX(T),U=c.getX(T+1),A=c.getX(T+2);i=Bu(this,_,e,n,f,p,g,R,U,A),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,t.push(i))}}else{const v=Math.max(0,x.start),E=Math.min(c.count,x.start+x.count);for(let b=v,_=E;b<_;b+=3){const M=c.getX(b),w=c.getX(b+1),T=c.getX(b+2);i=Bu(this,l,e,n,f,p,g,M,w,T),i&&(i.faceIndex=Math.floor(b/3),t.push(i))}}else if(h!==void 0)if(Array.isArray(l))for(let v=0,E=m.length;v<E;v++){const b=m[v],_=l[b.materialIndex],M=Math.max(b.start,x.start),w=Math.min(h.count,Math.min(b.start+b.count,x.start+x.count));for(let T=M,P=w;T<P;T+=3){const R=T,U=T+1,A=T+2;i=Bu(this,_,e,n,f,p,g,R,U,A),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,t.push(i))}}else{const v=Math.max(0,x.start),E=Math.min(h.count,x.start+x.count);for(let b=v,_=E;b<_;b+=3){const M=b,w=b+1,T=b+2;i=Bu(this,l,e,n,f,p,g,M,w,T),i&&(i.faceIndex=Math.floor(b/3),t.push(i))}}}}function tT(s,e,t,n,i,o,l,c){let h;if(e.side===si?h=n.intersectTriangle(l,o,i,!0,c):h=n.intersectTriangle(i,o,l,e.side===qs,c),h===null)return null;zu.copy(c),zu.applyMatrix4(s.matrixWorld);const f=t.ray.origin.distanceTo(zu);return f<t.near||f>t.far?null:{distance:f,point:zu.clone(),object:s}}function Bu(s,e,t,n,i,o,l,c,h,f){s.getVertexPosition(c,Du),s.getVertexPosition(h,Uu),s.getVertexPosition(f,Fu);const p=tT(s,e,t,n,Du,Uu,Fu,Nv);if(p){const g=new O;mi.getBarycoord(Nv,Du,Uu,Fu,g),i&&(p.uv=mi.getInterpolatedAttribute(i,c,h,f,g,new pe)),o&&(p.uv1=mi.getInterpolatedAttribute(o,c,h,f,g,new pe)),l&&(p.normal=mi.getInterpolatedAttribute(l,c,h,f,g,new O),p.normal.dot(n.direction)>0&&p.normal.multiplyScalar(-1));const m={a:c,b:h,c:f,normal:new O,materialIndex:0};mi.getNormal(Du,Uu,Fu,m.normal),p.face=m,p.barycoord=g}return p}const Dv=new O,Uv=new Zt,Fv=new Zt,nT=new O,Ov=new gt,ku=new O,Vp=new Bn,zv=new gt,Hp=new La;class rb extends Sn{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Am,this.bindMatrix=new gt,this.bindMatrixInverse=new gt,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++)this.getVertexPosition(n,ku),this.boundingBox.expandByPoint(ku)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Bn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ku),this.boundingSphere.expandByPoint(ku)}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(),Vp.copy(this.boundingSphere),Vp.applyMatrix4(i),e.ray.intersectsSphere(Vp)!==!1&&(zv.copy(i).invert(),Hp.copy(e.ray).applyMatrix4(zv),!(this.boundingBox!==null&&Hp.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Hp)))}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 Zt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const o=1/e.manhattanLength();o!==1/0?e.multiplyScalar(o):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Am?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===By?this.bindMatrixInverse.copy(this.bindMatrix).invert():He("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Uv.fromBufferAttribute(i.attributes.skinIndex,e),Fv.fromBufferAttribute(i.attributes.skinWeight,e),Dv.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let o=0;o<4;o++){const l=Fv.getComponent(o);if(l!==0){const c=Uv.getComponent(o);Ov.multiplyMatrices(n.bones[c].matrixWorld,n.boneInverses[c]),t.addScaledVector(nT.copy(Dv).applyMatrix4(Ov),l)}}return t.applyMatrix4(this.bindMatrixInverse)}}class mg extends Ot{constructor(){super(),this.isBone=!0,this.type="Bone"}}class rs extends un{constructor(e=null,t=1,n=1,i,o,l,c,h,f=mn,p=mn,g,m){super(null,l,c,h,f,p,i,o,g,m),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Bv=new gt,iT=new gt;class Uf{constructor(e=[],t=[]){this.uuid=Ii(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,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){He("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 gt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new gt;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 o=0,l=e.length;o<l;o++){const c=e[o]?e[o].matrixWorld:iT;Bv.multiplyMatrices(c,t[o]),Bv.toArray(n,o*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Uf(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new rs(t,e,e,Yn,ii);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,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 o=e.bones[n];let l=t[o];l===void 0&&(He("Skeleton: No bone found with UUID:",o),l=new mg),this.bones.push(l),this.boneInverses.push(new gt().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,o=t.length;i<o;i++){const l=t[i];e.bones.push(l.uuid);const c=n[i];e.boneInverses.push(c.toArray())}return e}}class Ho extends Yt{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 Mo=new gt,kv=new gt,Vu=[],Vv=new $n,sT=new gt,Ll=new Sn,Nl=new Bn;class ab extends Sn{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ho(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,sT)}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,Mo),Vv.copy(e.boundingBox).applyMatrix4(Mo),this.boundingBox.union(Vv)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Bn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Mo),Nl.copy(e.boundingSphere).applyMatrix4(Mo),this.boundingSphere.union(Nl)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),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)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,o=n.length+1,l=e*o+1;for(let c=0;c<n.length;c++)n[c]=i[l+c]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Ll.geometry=this.geometry,Ll.material=this.material,Ll.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Nl.copy(this.boundingSphere),Nl.applyMatrix4(n),e.ray.intersectsSphere(Nl)!==!1))for(let o=0;o<i;o++){this.getMatrixAt(o,Mo),kv.multiplyMatrices(n,Mo),Ll.matrixWorld=kv,Ll.raycast(e,Vu);for(let l=0,c=Vu.length;l<c;l++){const h=Vu[l];h.instanceId=o,h.object=this,t.push(h)}Vu.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Ho(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new rs(new Float32Array(i*this.count),i,this.count,Ef,ii));const o=this.morphTexture.source.data.data;let l=0;for(let f=0;f<n.length;f++)l+=n[f];const c=this.geometry.morphTargetsRelative?1:1-l,h=i*e;o[h]=c,o.set(n,h+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Gp=new O,rT=new O,aT=new St;class Gs{constructor(e=new O(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=Gp.subVectors(n,t).cross(rT.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(Gp),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const o=-(e.start.dot(this.normal)+this.constant)/i;return o<0||o>1?null:t.copy(e.start).addScaledVector(n,o)}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||aT.getNormalMatrix(e),i=this.coplanarPoint(Gp).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(o),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 ia=new Bn,oT=new pe(.5,.5),Hu=new O;class Yo{constructor(e=new Gs,t=new Gs,n=new Gs,i=new Gs,o=new Gs,l=new Gs){this.planes=[e,t,n,i,o,l]}set(e,t,n,i,o,l){const c=this.planes;return c[0].copy(e),c[1].copy(t),c[2].copy(n),c[3].copy(i),c[4].copy(o),c[5].copy(l),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=Ri,n=!1){const i=this.planes,o=e.elements,l=o[0],c=o[1],h=o[2],f=o[3],p=o[4],g=o[5],m=o[6],x=o[7],v=o[8],E=o[9],b=o[10],_=o[11],M=o[12],w=o[13],T=o[14],P=o[15];if(i[0].setComponents(f-l,x-p,_-v,P-M).normalize(),i[1].setComponents(f+l,x+p,_+v,P+M).normalize(),i[2].setComponents(f+c,x+g,_+E,P+w).normalize(),i[3].setComponents(f-c,x-g,_-E,P-w).normalize(),n)i[4].setComponents(h,m,b,T).normalize(),i[5].setComponents(f-h,x-m,_-b,P-T).normalize();else if(i[4].setComponents(f-h,x-m,_-b,P-T).normalize(),t===Ri)i[5].setComponents(f+h,x+m,_+b,P+T).normalize();else if(t===Ca)i[5].setComponents(h,m,b,T).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(),ia.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ia.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ia)}intersectsSprite(e){ia.center.set(0,0,0);const t=oT.distanceTo(e.center);return ia.radius=.7071067811865476+t,ia.applyMatrix4(e.matrixWorld),this.intersectsSphere(ia)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let o=0;o<6;o++)if(t[o].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(Hu.x=i.normal.x>0?e.max.x:e.min.x,Hu.y=i.normal.y>0?e.max.y:e.min.y,Hu.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Hu)<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)}}const fs=new gt,ds=new Yo;class Ff{constructor(){this.coordinateSystem=Ri}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(fs.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ds.setFromProjectionMatrix(fs,i.coordinateSystem,i.reversedDepth),ds.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(fs.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ds.setFromProjectionMatrix(fs,i.coordinateSystem,i.reversedDepth),ds.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(fs.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ds.setFromProjectionMatrix(fs,i.coordinateSystem,i.reversedDepth),ds.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(fs.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ds.setFromProjectionMatrix(fs,i.coordinateSystem,i.reversedDepth),ds.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(fs.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ds.setFromProjectionMatrix(fs,i.coordinateSystem,i.reversedDepth),ds.containsPoint(e))return!0}return!1}clone(){return new Ff}}function Wp(s,e){return s-e}function lT(s,e){return s.z-e.z}function cT(s,e){return e.z-s.z}class uT{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,i){const o=this.pool,l=this.list;this.index>=o.length&&o.push({start:-1,count:-1,z:-1,index:-1});const c=o[this.index];l.push(c),this.index++,c.start=e,c.count=t,c.z=n,c.index=i}reset(){this.list.length=0,this.index=0}}const ui=new gt,hT=new Ye(1,1,1),Hv=new Yo,fT=new Ff,Gu=new $n,sa=new Bn,Dl=new O,Gv=new O,dT=new O,Xp=new uT,jn=new Sn,Wu=[];function pT(s,e,t=0){const n=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const i=s.count;for(let o=0;o<i;o++)for(let l=0;l<n;l++)e.setComponent(o+t,l,s.getComponent(o,l))}else e.array.set(s.array,t*n);e.needsUpdate=!0}function ra(s,e){if(s.constructor!==e.constructor){const t=Math.min(s.length,e.length);for(let n=0;n<t;n++)e[n]=s[n]}else{const t=Math.min(s.length,e.length);e.set(new s.constructor(s.buffer,0,t))}}class ob extends Sn{constructor(e,t,n=t*2,i){super(new _t,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new rs(t,e,e,Yn,ii);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new rs(t,e,e,Sc,ki);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new rs(t,e,e,Yn,ii);n.colorSpace=Dt.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const l=e.getAttribute(o),{array:c,itemSize:h,normalized:f}=l,p=new c.constructor(n*h),g=new Yt(p,h,f);t.setAttribute(o,g)}if(e.getIndex()!==null){const o=n>65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new Yt(o,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=e.getAttribute(n),o=t.getAttribute(n);if(i.itemSize!==o.itemSize||i.normalized!==o.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new $n);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const o=t[n].geometryIndex;this.getMatrixAt(n,ui),this.getBoundingBoxAt(o,Gu).applyMatrix4(ui),e.union(Gu)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Bn);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const o=t[n].geometryIndex;this.getMatrixAt(n,ui),this.getBoundingSphereAt(o,sa).applyMatrix4(ui),e.union(sa)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Wp),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));const o=this._matricesTexture;ui.identity().toArray(o.image.data,i*16),o.needsUpdate=!0;const l=this._colorsTexture;return l&&(hT.toArray(l.image.data,i*4),l.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},o=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const l=e.getIndex();if(l!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?l.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let h;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Wp),h=this._availableGeometryIds.shift(),o[h]=i):(h=this._geometryCount,this._geometryCount++,o.push(i)),this.setGeometryAt(h,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,i=n.getIndex()!==null,o=n.getIndex(),l=t.getIndex(),c=this._geometryInfo[e];if(i&&l.count>c.reservedIndexCount||t.attributes.position.count>c.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const h=c.vertexStart,f=c.reservedVertexCount;c.vertexCount=t.getAttribute("position").count;for(const p in n.attributes){const g=t.getAttribute(p),m=n.getAttribute(p);pT(g,m,h);const x=g.itemSize;for(let v=g.count,E=f;v<E;v++){const b=h+v;for(let _=0;_<x;_++)m.setComponent(b,_,0)}m.needsUpdate=!0,m.addUpdateRange(h*x,f*x)}if(i){const p=c.indexStart,g=c.reservedIndexCount;c.indexCount=t.getIndex().count;for(let m=0;m<l.count;m++)o.setX(p+m,h+l.getX(m));for(let m=l.count,x=g;m<x;m++)o.setX(p+m,h);o.needsUpdate=!0,o.addUpdateRange(p,c.reservedIndexCount)}return c.start=i?c.indexStart:c.vertexStart,c.count=i?c.indexCount:c.vertexCount,c.boundingBox=null,t.boundingBox!==null&&(c.boundingBox=t.boundingBox.clone()),c.boundingSphere=null,t.boundingSphere!==null&&(c.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let i=0,o=n.length;i<o;i++)n[i].active&&n[i].geometryIndex===e&&this.deleteInstance(i);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const n=this._geometryInfo,i=n.map((l,c)=>c).sort((l,c)=>n[l].vertexStart-n[c].vertexStart),o=this.geometry;for(let l=0,c=n.length;l<c;l++){const h=i[l],f=n[h];if(f.active!==!1){if(o.index!==null){if(f.indexStart!==t){const{indexStart:p,vertexStart:g,reservedIndexCount:m}=f,x=o.index,v=x.array,E=e-g;for(let b=p;b<p+m;b++)v[b]=v[b]+E;x.array.copyWithin(t,p,p+m),x.addUpdateRange(t,m),x.needsUpdate=!0,f.indexStart=t}t+=f.reservedIndexCount}if(f.vertexStart!==e){const{vertexStart:p,reservedVertexCount:g}=f,m=o.attributes;for(const x in m){const v=m[x],{array:E,itemSize:b}=v;E.copyWithin(e*b,p*b,(p+g)*b),v.addUpdateRange(e*b,g*b),v.needsUpdate=!0}f.vertexStart=e}e+=f.reservedVertexCount,f.start=o.index?f.indexStart:f.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingBox===null){const o=new $n,l=n.index,c=n.attributes.position;for(let h=i.start,f=i.start+i.count;h<f;h++){let p=h;l&&(p=l.getX(p)),o.expandByPoint(Dl.fromBufferAttribute(c,p))}i.boundingBox=o}return t.copy(i.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingSphere===null){const o=new Bn;this.getBoundingBoxAt(e,Gu),Gu.getCenter(o.center);const l=n.index,c=n.attributes.position;let h=0;for(let f=i.start,p=i.start+i.count;f<p;f++){let g=f;l&&(g=l.getX(g)),Dl.fromBufferAttribute(c,g),h=Math.max(h,o.center.distanceToSquared(Dl))}o.radius=Math.sqrt(h),i.boundingSphere=o}return t.copy(i.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,i=this._matricesTexture.image.data;return t.toArray(i,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(Wp);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const i=new Int32Array(e),o=new Int32Array(e);ra(this._multiDrawCounts,i),ra(this._multiDrawStarts,o),this._multiDrawCounts=i,this._multiDrawStarts=o,this._maxInstanceCount=e;const l=this._indirectTexture,c=this._matricesTexture,h=this._colorsTexture;l.dispose(),this._initIndirectTexture(),ra(l.image.data,this._indirectTexture.image.data),c.dispose(),this._initMatricesTexture(),ra(c.image.data,this._matricesTexture.image.data),h&&(h.dispose(),this._initColorsTexture(),ra(h.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const n=[...this._geometryInfo].filter(c=>c.active);if(Math.max(...n.map(c=>c.vertexStart+c.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(h=>h.indexStart+h.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const o=this.geometry;o.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new _t,this._initializeGeometry(o));const l=this.geometry;o.index&&ra(o.index.array,l.index.array);for(const c in o.attributes)ra(o.attributes[c].array,l.attributes[c].array)}raycast(e,t){const n=this._instanceInfo,i=this._geometryInfo,o=this.matrixWorld,l=this.geometry;jn.material=this.material,jn.geometry.index=l.index,jn.geometry.attributes=l.attributes,jn.geometry.boundingBox===null&&(jn.geometry.boundingBox=new $n),jn.geometry.boundingSphere===null&&(jn.geometry.boundingSphere=new Bn);for(let c=0,h=n.length;c<h;c++){if(!n[c].visible||!n[c].active)continue;const f=n[c].geometryIndex,p=i[f];jn.geometry.setDrawRange(p.start,p.count),this.getMatrixAt(c,jn.matrixWorld).premultiply(o),this.getBoundingBoxAt(f,jn.geometry.boundingBox),this.getBoundingSphereAt(f,jn.geometry.boundingSphere),jn.raycast(e,Wu);for(let g=0,m=Wu.length;g<m;g++){const x=Wu[g];x.object=this,x.batchId=c,t.push(x)}Wu.length=0}jn.material=null,jn.geometry.index=null,jn.geometry.attributes={},jn.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,i,o){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const l=i.getIndex();let c=l===null?1:l.array.BYTES_PER_ELEMENT,h=1;o.wireframe&&(h=2,c=i.attributes.position.count>65535?4:2);const f=this._instanceInfo,p=this._multiDrawStarts,g=this._multiDrawCounts,m=this._geometryInfo,x=this.perObjectFrustumCulled,v=this._indirectTexture,E=v.image.data,b=n.isArrayCamera?fT:Hv;x&&!n.isArrayCamera&&(ui.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Hv.setFromProjectionMatrix(ui,n.coordinateSystem,n.reversedDepth));let _=0;if(this.sortObjects){ui.copy(this.matrixWorld).invert(),Dl.setFromMatrixPosition(n.matrixWorld).applyMatrix4(ui),Gv.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(ui);for(let T=0,P=f.length;T<P;T++)if(f[T].visible&&f[T].active){const R=f[T].geometryIndex;this.getMatrixAt(T,ui),this.getBoundingSphereAt(R,sa).applyMatrix4(ui);let U=!1;if(x&&(U=!b.intersectsSphere(sa,n)),!U){const A=m[R],I=dT.subVectors(sa.center,Dl).dot(Gv);Xp.push(A.start,A.count,I,T)}}const M=Xp.list,w=this.customSort;w===null?M.sort(o.transparent?cT:lT):w.call(this,M,n);for(let T=0,P=M.length;T<P;T++){const R=M[T];p[_]=R.start*c*h,g[_]=R.count*h,E[_]=R.index,_++}Xp.reset()}else for(let M=0,w=f.length;M<w;M++)if(f[M].visible&&f[M].active){const T=f[M].geometryIndex;let P=!1;if(x&&(this.getMatrixAt(M,ui),this.getBoundingSphereAt(T,sa).applyMatrix4(ui),P=!b.intersectsSphere(sa,n)),!P){const R=m[T];p[_]=R.start*c*h,g[_]=R.count*h,E[_]=M,_++}}v.needsUpdate=!0,this._multiDrawCount=_,this._visibilityChanged=!1}onBeforeShadow(e,t,n,i,o,l){this.onBeforeRender(e,null,i,o,l)}}class Kn extends Zn{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 uf=new O,hf=new O,Wv=new gt,Ul=new La,Xu=new Bn,jp=new O,Xv=new O;class Ys extends Ot{constructor(e=new _t,t=new Kn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,o=t.count;i<o;i++)uf.fromBufferAttribute(t,i-1),hf.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=uf.distanceTo(hf);e.setAttribute("lineDistance",new et(n,1))}else He("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,o=e.params.Line.threshold,l=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Xu.copy(n.boundingSphere),Xu.applyMatrix4(i),Xu.radius+=o,e.ray.intersectsSphere(Xu)===!1)return;Wv.copy(i).invert(),Ul.copy(e.ray).applyMatrix4(Wv);const c=o/((this.scale.x+this.scale.y+this.scale.z)/3),h=c*c,f=this.isLineSegments?2:1,p=n.index,m=n.attributes.position;if(p!==null){const x=Math.max(0,l.start),v=Math.min(p.count,l.start+l.count);for(let E=x,b=v-1;E<b;E+=f){const _=p.getX(E),M=p.getX(E+1),w=ju(this,e,Ul,h,_,M,E);w&&t.push(w)}if(this.isLineLoop){const E=p.getX(v-1),b=p.getX(x),_=ju(this,e,Ul,h,E,b,v-1);_&&t.push(_)}}else{const x=Math.max(0,l.start),v=Math.min(m.count,l.start+l.count);for(let E=x,b=v-1;E<b;E+=f){const _=ju(this,e,Ul,h,E,E+1,E);_&&t.push(_)}if(this.isLineLoop){const E=ju(this,e,Ul,h,v-1,x,v-1);E&&t.push(E)}}}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 o=0,l=i.length;o<l;o++){const c=i[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}}function ju(s,e,t,n,i,o,l){const c=s.geometry.attributes.position;if(uf.fromBufferAttribute(c,i),hf.fromBufferAttribute(c,o),t.distanceSqToSegment(uf,hf,jp,Xv)>n)return;jp.applyMatrix4(s.matrixWorld);const f=e.ray.origin.distanceTo(jp);if(!(f<e.near||f>e.far))return{distance:f,point:Xv.clone().applyMatrix4(s.matrixWorld),index:l,face:null,faceIndex:null,barycoord:null,object:s}}const jv=new O,qv=new O;class Ms extends Ys{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,o=t.count;i<o;i+=2)jv.fromBufferAttribute(t,i),qv.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+jv.distanceTo(qv);e.setAttribute("lineDistance",new et(n,1))}else He("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class lb extends Ys{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class gg extends Zn{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 Yv=new gt,Pm=new La,qu=new Bn,Yu=new O;class cb extends Ot{constructor(e=new _t,t=new gg){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,o=e.params.Points.threshold,l=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),qu.copy(n.boundingSphere),qu.applyMatrix4(i),qu.radius+=o,e.ray.intersectsSphere(qu)===!1)return;Yv.copy(i).invert(),Pm.copy(e.ray).applyMatrix4(Yv);const c=o/((this.scale.x+this.scale.y+this.scale.z)/3),h=c*c,f=n.index,g=n.attributes.position;if(f!==null){const m=Math.max(0,l.start),x=Math.min(f.count,l.start+l.count);for(let v=m,E=x;v<E;v++){const b=f.getX(v);Yu.fromBufferAttribute(g,b),$v(Yu,b,h,i,e,t,this)}}else{const m=Math.max(0,l.start),x=Math.min(g.count,l.start+l.count);for(let v=m,E=x;v<E;v++)Yu.fromBufferAttribute(g,v),$v(Yu,v,h,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 o=0,l=i.length;o<l;o++){const c=i[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}}function $v(s,e,t,n,i,o,l){const c=Pm.distanceSqToPoint(s);if(c<t){const h=new O;Pm.closestPointToPoint(s,h),h.applyMatrix4(n);const f=i.ray.origin.distanceTo(h);if(f<i.near||f>i.far)return;o.push({distance:f,distanceToRay:Math.sqrt(c),point:h,index:e,face:null,faceIndex:null,barycoord:null,object:l})}}class ub extends un{constructor(e,t,n,i,o=en,l=en,c,h,f){super(e,t,n,i,o,l,c,h,f),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const p=this;function g(){p.needsUpdate=!0,p._requestVideoFrameCallbackId=e.requestVideoFrameCallback(g)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(g))}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)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class mT extends ub{constructor(e,t,n,i,o,l,c,h){super({},e,t,n,i,o,l,c,h),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class gT extends un{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=mn,this.minFilter=mn,this.generateMipmaps=!1,this.needsUpdate=!0}}class Of extends un{constructor(e,t,n,i,o,l,c,h,f,p,g,m){super(null,l,c,h,f,p,i,o,g,m),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class xT extends Of{constructor(e,t,n,i,o,l){super(e,t,n,o,l),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=gi,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class vT extends Of{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,_s),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Mc extends un{constructor(e=[],t=_s,n,i,o,l,c,h,f,p){super(e,t,n,i,o,l,c,h,f,p),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class _T extends un{constructor(e,t,n,i,o,l,c,h,f){super(e,t,n,i,o,l,c,h,f),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Go extends un{constructor(e,t,n=ki,i,o,l,c=mn,h=mn,f,p=bs,g=1){if(p!==bs&&p!==Er)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:t,depth:g};super(m,i,o,l,c,h,p,n,f),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new wr(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class hb extends Go{constructor(e,t=ki,n=_s,i,o,l=mn,c=mn,h,f=bs){const p={width:e,height:e,depth:1},g=[p,p,p,p,p,p];super(e,e,t,n,i,o,l,c,h,f),this.image=g,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class xg extends un{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Na extends _t{constructor(e=1,t=1,n=1,i=1,o=1,l=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:o,depthSegments:l};const c=this;i=Math.floor(i),o=Math.floor(o),l=Math.floor(l);const h=[],f=[],p=[],g=[];let m=0,x=0;v("z","y","x",-1,-1,n,t,e,l,o,0),v("z","y","x",1,-1,n,t,-e,l,o,1),v("x","z","y",1,1,e,n,t,i,l,2),v("x","z","y",1,-1,e,n,-t,i,l,3),v("x","y","z",1,-1,e,t,n,i,o,4),v("x","y","z",-1,-1,e,t,-n,i,o,5),this.setIndex(h),this.setAttribute("position",new et(f,3)),this.setAttribute("normal",new et(p,3)),this.setAttribute("uv",new et(g,2));function v(E,b,_,M,w,T,P,R,U,A,I){const B=T/U,F=P/A,j=T/2,H=P/2,Z=R/2,W=U+1,$=A+1;let Y=0,ge=0;const he=new O;for(let Ee=0;Ee<$;Ee++){const xe=Ee*F-H;for(let ve=0;ve<W;ve++){const Xe=ve*B-j;he[E]=Xe*M,he[b]=xe*w,he[_]=Z,f.push(he.x,he.y,he.z),he[E]=0,he[b]=0,he[_]=R>0?1:-1,p.push(he.x,he.y,he.z),g.push(ve/U),g.push(1-Ee/A),Y+=1}}for(let Ee=0;Ee<A;Ee++)for(let xe=0;xe<U;xe++){const ve=m+xe+W*Ee,Xe=m+xe+W*(Ee+1),lt=m+(xe+1)+W*(Ee+1),yt=m+(xe+1)+W*Ee;h.push(ve,Xe,yt),h.push(Xe,lt,yt),ge+=6}c.addGroup(x,ge,I),x+=ge,m+=Y}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Na(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class zf extends _t{constructor(e=1,t=1,n=4,i=8,o=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i,heightSegments:o},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),o=Math.max(1,Math.floor(o));const l=[],c=[],h=[],f=[],p=t/2,g=Math.PI/2*e,m=t,x=2*g+m,v=n*2+o,E=i+1,b=new O,_=new O;for(let M=0;M<=v;M++){let w=0,T=0,P=0,R=0;if(M<=n){const I=M/n,B=I*Math.PI/2;T=-p-e*Math.cos(B),P=e*Math.sin(B),R=-e*Math.cos(B),w=I*g}else if(M<=n+o){const I=(M-n)/o;T=-p+I*t,P=e,R=0,w=g+I*m}else{const I=(M-n-o)/n,B=I*Math.PI/2;T=p+e*Math.sin(B),P=e*Math.cos(B),R=e*Math.sin(B),w=g+m+I*g}const U=Math.max(0,Math.min(1,w/x));let A=0;M===0?A=.5/i:M===v&&(A=-.5/i);for(let I=0;I<=i;I++){const B=I/i,F=B*Math.PI*2,j=Math.sin(F),H=Math.cos(F);_.x=-P*H,_.y=T,_.z=P*j,c.push(_.x,_.y,_.z),b.set(-P*H,R,P*j),b.normalize(),h.push(b.x,b.y,b.z),f.push(B+A,U)}if(M>0){const I=(M-1)*E;for(let B=0;B<i;B++){const F=I+B,j=I+B+1,H=M*E+B,Z=M*E+B+1;l.push(F,j,H),l.push(j,Z,H)}}}this.setIndex(l),this.setAttribute("position",new et(c,3)),this.setAttribute("normal",new et(h,3)),this.setAttribute("uv",new et(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new zf(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class Bf extends _t{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 o=[],l=[],c=[],h=[],f=new O,p=new pe;l.push(0,0,0),c.push(0,0,1),h.push(.5,.5);for(let g=0,m=3;g<=t;g++,m+=3){const x=n+g/t*i;f.x=e*Math.cos(x),f.y=e*Math.sin(x),l.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(l[m]/e+1)/2,p.y=(l[m+1]/e+1)/2,h.push(p.x,p.y)}for(let g=1;g<=t;g++)o.push(g,g+1,0);this.setIndex(o),this.setAttribute("position",new et(l,3)),this.setAttribute("normal",new et(c,3)),this.setAttribute("uv",new et(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Bf(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Ec extends _t{constructor(e=1,t=1,n=1,i=32,o=1,l=!1,c=0,h=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:o,openEnded:l,thetaStart:c,thetaLength:h};const f=this;i=Math.floor(i),o=Math.floor(o);const p=[],g=[],m=[],x=[];let v=0;const E=[],b=n/2;let _=0;M(),l===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(p),this.setAttribute("position",new et(g,3)),this.setAttribute("normal",new et(m,3)),this.setAttribute("uv",new et(x,2));function M(){const T=new O,P=new O;let R=0;const U=(t-e)/n;for(let A=0;A<=o;A++){const I=[],B=A/o,F=B*(t-e)+e;for(let j=0;j<=i;j++){const H=j/i,Z=H*h+c,W=Math.sin(Z),$=Math.cos(Z);P.x=F*W,P.y=-B*n+b,P.z=F*$,g.push(P.x,P.y,P.z),T.set(W,U,$).normalize(),m.push(T.x,T.y,T.z),x.push(H,1-B),I.push(v++)}E.push(I)}for(let A=0;A<i;A++)for(let I=0;I<o;I++){const B=E[I][A],F=E[I+1][A],j=E[I+1][A+1],H=E[I][A+1];(e>0||I!==0)&&(p.push(B,F,H),R+=3),(t>0||I!==o-1)&&(p.push(F,j,H),R+=3)}f.addGroup(_,R,0),_+=R}function w(T){const P=v,R=new pe,U=new O;let A=0;const I=T===!0?e:t,B=T===!0?1:-1;for(let j=1;j<=i;j++)g.push(0,b*B,0),m.push(0,B,0),x.push(.5,.5),v++;const F=v;for(let j=0;j<=i;j++){const Z=j/i*h+c,W=Math.cos(Z),$=Math.sin(Z);U.x=I*$,U.y=b*B,U.z=I*W,g.push(U.x,U.y,U.z),m.push(0,B,0),R.x=W*.5+.5,R.y=$*.5*B+.5,x.push(R.x,R.y),v++}for(let j=0;j<i;j++){const H=P+j,Z=F+j;T===!0?p.push(Z,Z+1,H):p.push(Z+1,Z,H),A+=3}f.addGroup(_,A,T===!0?1:2),_+=A}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ec(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class wc extends Ec{constructor(e=1,t=1,n=32,i=1,o=!1,l=0,c=Math.PI*2){super(0,e,t,n,i,o,l,c),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:o,thetaStart:l,thetaLength:c}}static fromJSON(e){return new wc(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Lr extends _t{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const o=[],l=[];c(i),f(n),p(),this.setAttribute("position",new et(o,3)),this.setAttribute("normal",new et(o.slice(),3)),this.setAttribute("uv",new et(l,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function c(M){const w=new O,T=new O,P=new O;for(let R=0;R<t.length;R+=3)x(t[R+0],w),x(t[R+1],T),x(t[R+2],P),h(w,T,P,M)}function h(M,w,T,P){const R=P+1,U=[];for(let A=0;A<=R;A++){U[A]=[];const I=M.clone().lerp(T,A/R),B=w.clone().lerp(T,A/R),F=R-A;for(let j=0;j<=F;j++)j===0&&A===R?U[A][j]=I:U[A][j]=I.clone().lerp(B,j/F)}for(let A=0;A<R;A++)for(let I=0;I<2*(R-A)-1;I++){const B=Math.floor(I/2);I%2===0?(m(U[A][B+1]),m(U[A+1][B]),m(U[A][B])):(m(U[A][B+1]),m(U[A+1][B+1]),m(U[A+1][B]))}}function f(M){const w=new O;for(let T=0;T<o.length;T+=3)w.x=o[T+0],w.y=o[T+1],w.z=o[T+2],w.normalize().multiplyScalar(M),o[T+0]=w.x,o[T+1]=w.y,o[T+2]=w.z}function p(){const M=new O;for(let w=0;w<o.length;w+=3){M.x=o[w+0],M.y=o[w+1],M.z=o[w+2];const T=b(M)/2/Math.PI+.5,P=_(M)/Math.PI+.5;l.push(T,1-P)}v(),g()}function g(){for(let M=0;M<l.length;M+=6){const w=l[M+0],T=l[M+2],P=l[M+4],R=Math.max(w,T,P),U=Math.min(w,T,P);R>.9&&U<.1&&(w<.2&&(l[M+0]+=1),T<.2&&(l[M+2]+=1),P<.2&&(l[M+4]+=1))}}function m(M){o.push(M.x,M.y,M.z)}function x(M,w){const T=M*3;w.x=e[T+0],w.y=e[T+1],w.z=e[T+2]}function v(){const M=new O,w=new O,T=new O,P=new O,R=new pe,U=new pe,A=new pe;for(let I=0,B=0;I<o.length;I+=9,B+=6){M.set(o[I+0],o[I+1],o[I+2]),w.set(o[I+3],o[I+4],o[I+5]),T.set(o[I+6],o[I+7],o[I+8]),R.set(l[B+0],l[B+1]),U.set(l[B+2],l[B+3]),A.set(l[B+4],l[B+5]),P.copy(M).add(w).add(T).divideScalar(3);const F=b(P);E(R,B+0,M,F),E(U,B+2,w,F),E(A,B+4,T,F)}}function E(M,w,T,P){P<0&&M.x===1&&(l[w]=M.x-1),T.x===0&&T.z===0&&(l[w]=P/2/Math.PI+.5)}function b(M){return Math.atan2(M.z,-M.x)}function _(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Lr(e.vertices,e.indices,e.radius,e.detail)}}class kf extends Lr{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n,o=[-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],l=[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(o,l,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new kf(e.radius,e.detail)}}const $u=new O,Zu=new O,qp=new O,Ku=new mi;class fb extends _t{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),o=Math.cos(Ea*t),l=e.getIndex(),c=e.getAttribute("position"),h=l?l.count:c.count,f=[0,0,0],p=["a","b","c"],g=new Array(3),m={},x=[];for(let v=0;v<h;v+=3){l?(f[0]=l.getX(v),f[1]=l.getX(v+1),f[2]=l.getX(v+2)):(f[0]=v,f[1]=v+1,f[2]=v+2);const{a:E,b,c:_}=Ku;if(E.fromBufferAttribute(c,f[0]),b.fromBufferAttribute(c,f[1]),_.fromBufferAttribute(c,f[2]),Ku.getNormal(qp),g[0]=`${Math.round(E.x*i)},${Math.round(E.y*i)},${Math.round(E.z*i)}`,g[1]=`${Math.round(b.x*i)},${Math.round(b.y*i)},${Math.round(b.z*i)}`,g[2]=`${Math.round(_.x*i)},${Math.round(_.y*i)},${Math.round(_.z*i)}`,!(g[0]===g[1]||g[1]===g[2]||g[2]===g[0]))for(let M=0;M<3;M++){const w=(M+1)%3,T=g[M],P=g[w],R=Ku[p[M]],U=Ku[p[w]],A=`${T}_${P}`,I=`${P}_${T}`;I in m&&m[I]?(qp.dot(m[I].normal)<=o&&(x.push(R.x,R.y,R.z),x.push(U.x,U.y,U.z)),m[I]=null):A in m||(m[A]={index0:f[M],index1:f[w],normal:qp.clone()})}}for(const v in m)if(m[v]){const{index0:E,index1:b}=m[v];$u.fromBufferAttribute(c,E),Zu.fromBufferAttribute(c,b),x.push($u.x,$u.y,$u.z),x.push(Zu.x,Zu.y,Zu.z)}this.setAttribute("position",new et(x,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class os{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){He("Curve: .getPoint() not implemented.")}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),o=0;t.push(0);for(let l=1;l<=e;l++)n=this.getPoint(l/e),o+=n.distanceTo(i),t.push(o),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let i=0;const o=n.length;let l;t?l=t:l=e*n[o-1];let c=0,h=o-1,f;for(;c<=h;)if(i=Math.floor(c+(h-c)/2),f=n[i]-l,f<0)c=i+1;else if(f>0)h=i-1;else{h=i;break}if(i=h,n[i]===l)return i/(o-1);const p=n[i],m=n[i+1]-p,x=(l-p)/m;return(i+x)/(o-1)}getTangent(e,t){let i=e-1e-4,o=e+1e-4;i<0&&(i=0),o>1&&(o=1);const l=this.getPoint(i),c=this.getPoint(o),h=t||(l.isVector2?new pe:new O);return h.copy(c).sub(l).normalize(),h}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new O,i=[],o=[],l=[],c=new O,h=new gt;for(let x=0;x<=e;x++){const v=x/e;i[x]=this.getTangentAt(v,new O)}o[0]=new O,l[0]=new O;let f=Number.MAX_VALUE;const p=Math.abs(i[0].x),g=Math.abs(i[0].y),m=Math.abs(i[0].z);p<=f&&(f=p,n.set(1,0,0)),g<=f&&(f=g,n.set(0,1,0)),m<=f&&n.set(0,0,1),c.crossVectors(i[0],n).normalize(),o[0].crossVectors(i[0],c),l[0].crossVectors(i[0],o[0]);for(let x=1;x<=e;x++){if(o[x]=o[x-1].clone(),l[x]=l[x-1].clone(),c.crossVectors(i[x-1],i[x]),c.length()>Number.EPSILON){c.normalize();const v=Math.acos(pt(i[x-1].dot(i[x]),-1,1));o[x].applyMatrix4(h.makeRotationAxis(c,v))}l[x].crossVectors(i[x],o[x])}if(t===!0){let x=Math.acos(pt(o[0].dot(o[e]),-1,1));x/=e,i[0].dot(c.crossVectors(o[0],o[e]))>0&&(x=-x);for(let v=1;v<=e;v++)o[v].applyMatrix4(h.makeRotationAxis(i[v],x*v)),l[v].crossVectors(i[v],o[v])}return{tangents:i,normals:o,binormals:l}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Vf extends os{constructor(e=0,t=0,n=1,i=1,o=0,l=Math.PI*2,c=!1,h=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=o,this.aEndAngle=l,this.aClockwise=c,this.aRotation=h}getPoint(e,t=new pe){const n=t,i=Math.PI*2;let o=this.aEndAngle-this.aStartAngle;const l=Math.abs(o)<Number.EPSILON;for(;o<0;)o+=i;for(;o>i;)o-=i;o<Number.EPSILON&&(l?o=0:o=i),this.aClockwise===!0&&!l&&(o===i?o=-i:o=o-i);const c=this.aStartAngle+e*o;let h=this.aX+this.xRadius*Math.cos(c),f=this.aY+this.yRadius*Math.sin(c);if(this.aRotation!==0){const p=Math.cos(this.aRotation),g=Math.sin(this.aRotation),m=h-this.aX,x=f-this.aY;h=m*p-x*g+this.aX,f=m*g+x*p+this.aY}return n.set(h,f)}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 db extends Vf{constructor(e,t,n,i,o,l){super(e,t,n,n,i,o,l),this.isArcCurve=!0,this.type="ArcCurve"}}function vg(){let s=0,e=0,t=0,n=0;function i(o,l,c,h){s=o,e=c,t=-3*o+3*l-2*c-h,n=2*o-2*l+c+h}return{initCatmullRom:function(o,l,c,h,f){i(l,c,f*(c-o),f*(h-l))},initNonuniformCatmullRom:function(o,l,c,h,f,p,g){let m=(l-o)/f-(c-o)/(f+p)+(c-l)/p,x=(c-l)/p-(h-l)/(p+g)+(h-c)/g;m*=p,x*=p,i(l,c,m,x)},calc:function(o){const l=o*o,c=l*o;return s+e*o+t*l+n*c}}}const Ju=new O,Yp=new vg,$p=new vg,Zp=new vg;class pb extends os{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 O){const n=t,i=this.points,o=i.length,l=(o-(this.closed?0:1))*e;let c=Math.floor(l),h=l-c;this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/o)+1)*o:h===0&&c===o-1&&(c=o-2,h=1);let f,p;this.closed||c>0?f=i[(c-1)%o]:(Ju.subVectors(i[0],i[1]).add(i[0]),f=Ju);const g=i[c%o],m=i[(c+1)%o];if(this.closed||c+2<o?p=i[(c+2)%o]:(Ju.subVectors(i[o-1],i[o-2]).add(i[o-1]),p=Ju),this.curveType==="centripetal"||this.curveType==="chordal"){const x=this.curveType==="chordal"?.5:.25;let v=Math.pow(f.distanceToSquared(g),x),E=Math.pow(g.distanceToSquared(m),x),b=Math.pow(m.distanceToSquared(p),x);E<1e-4&&(E=1),v<1e-4&&(v=E),b<1e-4&&(b=E),Yp.initNonuniformCatmullRom(f.x,g.x,m.x,p.x,v,E,b),$p.initNonuniformCatmullRom(f.y,g.y,m.y,p.y,v,E,b),Zp.initNonuniformCatmullRom(f.z,g.z,m.z,p.z,v,E,b)}else this.curveType==="catmullrom"&&(Yp.initCatmullRom(f.x,g.x,m.x,p.x,this.tension),$p.initCatmullRom(f.y,g.y,m.y,p.y,this.tension),Zp.initCatmullRom(f.z,g.z,m.z,p.z,this.tension));return n.set(Yp.calc(h),$p.calc(h),Zp.calc(h)),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 O().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Zv(s,e,t,n,i){const o=(n-e)*.5,l=(i-t)*.5,c=s*s,h=s*c;return(2*t-2*n+o+l)*h+(-3*t+3*n-2*o-l)*c+o*s+t}function yT(s,e){const t=1-s;return t*t*e}function bT(s,e){return 2*(1-s)*s*e}function ST(s,e){return s*s*e}function Jl(s,e,t,n){return yT(s,e)+bT(s,t)+ST(s,n)}function MT(s,e){const t=1-s;return t*t*t*e}function ET(s,e){const t=1-s;return 3*t*t*s*e}function wT(s,e){return 3*(1-s)*s*s*e}function TT(s,e){return s*s*s*e}function Ql(s,e,t,n,i){return MT(s,e)+ET(s,t)+wT(s,n)+TT(s,i)}class _g extends os{constructor(e=new pe,t=new pe,n=new pe,i=new pe){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new pe){const n=t,i=this.v0,o=this.v1,l=this.v2,c=this.v3;return n.set(Ql(e,i.x,o.x,l.x,c.x),Ql(e,i.y,o.y,l.y,c.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 mb extends os{constructor(e=new O,t=new O,n=new O,i=new O){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new O){const n=t,i=this.v0,o=this.v1,l=this.v2,c=this.v3;return n.set(Ql(e,i.x,o.x,l.x,c.x),Ql(e,i.y,o.y,l.y,c.y),Ql(e,i.z,o.z,l.z,c.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 yg extends os{constructor(e=new pe,t=new pe){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new pe){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 pe){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 gb extends os{constructor(e=new O,t=new O){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new O){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 O){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 bg extends os{constructor(e=new pe,t=new pe,n=new pe){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new pe){const n=t,i=this.v0,o=this.v1,l=this.v2;return n.set(Jl(e,i.x,o.x,l.x),Jl(e,i.y,o.y,l.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 Sg extends os{constructor(e=new O,t=new O,n=new O){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new O){const n=t,i=this.v0,o=this.v1,l=this.v2;return n.set(Jl(e,i.x,o.x,l.x),Jl(e,i.y,o.y,l.y),Jl(e,i.z,o.z,l.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 Mg extends os{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new pe){const n=t,i=this.points,o=(i.length-1)*e,l=Math.floor(o),c=o-l,h=i[l===0?l:l-1],f=i[l],p=i[l>i.length-2?i.length-1:l+1],g=i[l>i.length-3?i.length-1:l+2];return n.set(Zv(c,h.x,f.x,p.x,g.x),Zv(c,h.y,f.y,p.y,g.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 pe().fromArray(i))}return this}}var ff=Object.freeze({__proto__:null,ArcCurve:db,CatmullRomCurve3:pb,CubicBezierCurve:_g,CubicBezierCurve3:mb,EllipseCurve:Vf,LineCurve:yg,LineCurve3:gb,QuadraticBezierCurve:bg,QuadraticBezierCurve3:Sg,SplineCurve:Mg});class xb extends os{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);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new ff[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let o=0;for(;o<i.length;){if(i[o]>=n){const l=i[o]-n,c=this.curves[o],h=c.getLength(),f=h===0?0:1-l/h;return c.getPointAt(f,t)}o++}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,o=this.curves;i<o.length;i++){const l=o[i],c=l.isEllipseCurve?e*2:l.isLineCurve||l.isLineCurve3?1:l.isSplineCurve?e*l.points.length:e,h=l.getPoints(c);for(let f=0;f<h.length;f++){const p=h[f];n&&n.equals(p)||(t.push(p),n=p)}}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 ff[i.type]().fromJSON(i))}return this}}class df extends xb{constructor(e){super(),this.type="Path",this.currentPoint=new pe,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 yg(this.currentPoint.clone(),new pe(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const o=new bg(this.currentPoint.clone(),new pe(e,t),new pe(n,i));return this.curves.push(o),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,o,l){const c=new _g(this.currentPoint.clone(),new pe(e,t),new pe(n,i),new pe(o,l));return this.curves.push(c),this.currentPoint.set(o,l),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Mg(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absarc(e+c,t+h,n,i,o,l),this}absarc(e,t,n,i,o,l){return this.absellipse(e,t,n,n,i,o,l),this}ellipse(e,t,n,i,o,l,c,h){const f=this.currentPoint.x,p=this.currentPoint.y;return this.absellipse(e+f,t+p,n,i,o,l,c,h),this}absellipse(e,t,n,i,o,l,c,h){const f=new Vf(e,t,n,i,o,l,c,h);if(this.curves.length>0){const g=f.getPoint(0);g.equals(this.currentPoint)||this.lineTo(g.x,g.y)}this.curves.push(f);const p=f.getPoint(1);return this.currentPoint.copy(p),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 wa extends df{constructor(e){super(e),this.uuid=Ii(),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 df().fromJSON(i))}return this}}function AT(s,e,t=2){const n=e&&e.length,i=n?e[0]*t:s.length;let o=vb(s,0,i,t,!0);const l=[];if(!o||o.next===o.prev)return l;let c,h,f;if(n&&(o=LT(s,e,o,t)),s.length>80*t){c=s[0],h=s[1];let p=c,g=h;for(let m=t;m<i;m+=t){const x=s[m],v=s[m+1];x<c&&(c=x),v<h&&(h=v),x>p&&(p=x),v>g&&(g=v)}f=Math.max(p-c,g-h),f=f!==0?32767/f:0}return hc(o,l,t,c,h,f,0),l}function vb(s,e,t,n,i){let o;if(i===GT(s,e,t,n)>0)for(let l=e;l<t;l+=n)o=Kv(l/n|0,s[l],s[l+1],o);else for(let l=t-n;l>=e;l-=n)o=Kv(l/n|0,s[l],s[l+1],o);return o&&Wo(o,o.next)&&(dc(o),o=o.next),o}function Ia(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(Wo(t,t.next)||on(t.prev,t,t.next)===0)){if(dc(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function hc(s,e,t,n,i,o,l){if(!s)return;!l&&o&&OT(s,n,i,o);let c=s;for(;s.prev!==s.next;){const h=s.prev,f=s.next;if(o?RT(s,n,i,o):CT(s)){e.push(h.i,s.i,f.i),dc(s),s=f.next,c=f.next;continue}if(s=f,s===c){l?l===1?(s=IT(Ia(s),e),hc(s,e,t,n,i,o,2)):l===2&&PT(s,e,t,n,i,o):hc(Ia(s),e,t,n,i,o,1);break}}}function CT(s){const e=s.prev,t=s,n=s.next;if(on(e,t,n)>=0)return!1;const i=e.x,o=t.x,l=n.x,c=e.y,h=t.y,f=n.y,p=Math.min(i,o,l),g=Math.min(c,h,f),m=Math.max(i,o,l),x=Math.max(c,h,f);let v=n.next;for(;v!==e;){if(v.x>=p&&v.x<=m&&v.y>=g&&v.y<=x&&Vl(i,c,o,h,l,f,v.x,v.y)&&on(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function RT(s,e,t,n){const i=s.prev,o=s,l=s.next;if(on(i,o,l)>=0)return!1;const c=i.x,h=o.x,f=l.x,p=i.y,g=o.y,m=l.y,x=Math.min(c,h,f),v=Math.min(p,g,m),E=Math.max(c,h,f),b=Math.max(p,g,m),_=Lm(x,v,e,t,n),M=Lm(E,b,e,t,n);let w=s.prevZ,T=s.nextZ;for(;w&&w.z>=_&&T&&T.z<=M;){if(w.x>=x&&w.x<=E&&w.y>=v&&w.y<=b&&w!==i&&w!==l&&Vl(c,p,h,g,f,m,w.x,w.y)&&on(w.prev,w,w.next)>=0||(w=w.prevZ,T.x>=x&&T.x<=E&&T.y>=v&&T.y<=b&&T!==i&&T!==l&&Vl(c,p,h,g,f,m,T.x,T.y)&&on(T.prev,T,T.next)>=0))return!1;T=T.nextZ}for(;w&&w.z>=_;){if(w.x>=x&&w.x<=E&&w.y>=v&&w.y<=b&&w!==i&&w!==l&&Vl(c,p,h,g,f,m,w.x,w.y)&&on(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;T&&T.z<=M;){if(T.x>=x&&T.x<=E&&T.y>=v&&T.y<=b&&T!==i&&T!==l&&Vl(c,p,h,g,f,m,T.x,T.y)&&on(T.prev,T,T.next)>=0)return!1;T=T.nextZ}return!0}function IT(s,e){let t=s;do{const n=t.prev,i=t.next.next;!Wo(n,i)&&yb(n,t,t.next,i)&&fc(n,i)&&fc(i,n)&&(e.push(n.i,t.i,i.i),dc(t),dc(t.next),t=s=i),t=t.next}while(t!==s);return Ia(t)}function PT(s,e,t,n,i,o){let l=s;do{let c=l.next.next;for(;c!==l.prev;){if(l.i!==c.i&&kT(l,c)){let h=bb(l,c);l=Ia(l,l.next),h=Ia(h,h.next),hc(l,e,t,n,i,o,0),hc(h,e,t,n,i,o,0);return}c=c.next}l=l.next}while(l!==s)}function LT(s,e,t,n){const i=[];for(let o=0,l=e.length;o<l;o++){const c=e[o]*n,h=o<l-1?e[o+1]*n:s.length,f=vb(s,c,h,n,!1);f===f.next&&(f.steiner=!0),i.push(BT(f))}i.sort(NT);for(let o=0;o<i.length;o++)t=DT(i[o],t);return t}function NT(s,e){let t=s.x-e.x;if(t===0&&(t=s.y-e.y,t===0)){const n=(s.next.y-s.y)/(s.next.x-s.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=n-i}return t}function DT(s,e){const t=UT(s,e);if(!t)return e;const n=bb(t,s);return Ia(n,n.next),Ia(t,t.next)}function UT(s,e){let t=e;const n=s.x,i=s.y;let o=-1/0,l;if(Wo(s,t))return t;do{if(Wo(s,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const g=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(g<=n&&g>o&&(o=g,l=t.x<t.next.x?t:t.next,g===n))return l}t=t.next}while(t!==e);if(!l)return null;const c=l,h=l.x,f=l.y;let p=1/0;t=l;do{if(n>=t.x&&t.x>=h&&n!==t.x&&_b(i<f?n:o,i,h,f,i<f?o:n,i,t.x,t.y)){const g=Math.abs(i-t.y)/(n-t.x);fc(t,s)&&(g<p||g===p&&(t.x>l.x||t.x===l.x&&FT(l,t)))&&(l=t,p=g)}t=t.next}while(t!==c);return l}function FT(s,e){return on(s.prev,s,e.prev)<0&&on(e.next,s,s.next)<0}function OT(s,e,t,n){let i=s;do i.z===0&&(i.z=Lm(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,zT(i)}function zT(s){let e,t=1;do{let n=s,i;s=null;let o=null;for(e=0;n;){e++;let l=n,c=0;for(let f=0;f<t&&(c++,l=l.nextZ,!!l);f++);let h=t;for(;c>0||h>0&&l;)c!==0&&(h===0||!l||n.z<=l.z)?(i=n,n=n.nextZ,c--):(i=l,l=l.nextZ,h--),o?o.nextZ=i:s=i,i.prevZ=o,o=i;n=l}o.nextZ=null,t*=2}while(e>1);return s}function Lm(s,e,t,n,i){return s=(s-t)*i|0,e=(e-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function BT(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function _b(s,e,t,n,i,o,l,c){return(i-l)*(e-c)>=(s-l)*(o-c)&&(s-l)*(n-c)>=(t-l)*(e-c)&&(t-l)*(o-c)>=(i-l)*(n-c)}function Vl(s,e,t,n,i,o,l,c){return!(s===l&&e===c)&&_b(s,e,t,n,i,o,l,c)}function kT(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!VT(s,e)&&(fc(s,e)&&fc(e,s)&&HT(s,e)&&(on(s.prev,s,e.prev)||on(s,e.prev,e))||Wo(s,e)&&on(s.prev,s,s.next)>0&&on(e.prev,e,e.next)>0)}function on(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function Wo(s,e){return s.x===e.x&&s.y===e.y}function yb(s,e,t,n){const i=eh(on(s,e,t)),o=eh(on(s,e,n)),l=eh(on(t,n,s)),c=eh(on(t,n,e));return!!(i!==o&&l!==c||i===0&&Qu(s,t,e)||o===0&&Qu(s,n,e)||l===0&&Qu(t,s,n)||c===0&&Qu(t,e,n))}function Qu(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function eh(s){return s>0?1:s<0?-1:0}function VT(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&yb(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function fc(s,e){return on(s.prev,s,s.next)<0?on(s,e,s.next)>=0&&on(s,s.prev,e)>=0:on(s,e,s.prev)<0||on(s,s.next,e)<0}function HT(s,e){let t=s,n=!1;const i=(s.x+e.x)/2,o=(s.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&i<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function bb(s,e){const t=Nm(s.i,s.x,s.y),n=Nm(e.i,e.x,e.y),i=s.next,o=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function Kv(s,e,t,n){const i=Nm(s,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 dc(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Nm(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function GT(s,e,t,n){let i=0;for(let o=e,l=t-n;o<t;o+=n)i+=(s[l]-s[o])*(s[o+1]+s[l+1]),l=o;return i}class WT{static triangulate(e,t,n=2){return AT(e,t,n)}}class ss{static area(e){const t=e.length;let n=0;for(let i=t-1,o=0;o<t;i=o++)n+=e[i].x*e[o].y-e[o].x*e[i].y;return n*.5}static isClockWise(e){return ss.area(e)<0}static triangulateShape(e,t){const n=[],i=[],o=[];Jv(e),Qv(n,e);let l=e.length;t.forEach(Jv);for(let h=0;h<t.length;h++)i.push(l),l+=t[h].length,Qv(n,t[h]);const c=WT.triangulate(n,i);for(let h=0;h<c.length;h+=3)o.push(c.slice(h,h+3));return o}}function Jv(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function Qv(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class Hf extends _t{constructor(e=new wa([new pe(.5,.5),new pe(-.5,.5),new pe(-.5,-.5),new pe(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],o=[];for(let c=0,h=e.length;c<h;c++){const f=e[c];l(f)}this.setAttribute("position",new et(i,3)),this.setAttribute("uv",new et(o,2)),this.computeVertexNormals();function l(c){const h=[],f=t.curveSegments!==void 0?t.curveSegments:12,p=t.steps!==void 0?t.steps:1,g=t.depth!==void 0?t.depth:1;let m=t.bevelEnabled!==void 0?t.bevelEnabled:!0,x=t.bevelThickness!==void 0?t.bevelThickness:.2,v=t.bevelSize!==void 0?t.bevelSize:x-.1,E=t.bevelOffset!==void 0?t.bevelOffset:0,b=t.bevelSegments!==void 0?t.bevelSegments:3;const _=t.extrudePath,M=t.UVGenerator!==void 0?t.UVGenerator:XT;let w,T=!1,P,R,U,A;if(_){w=_.getSpacedPoints(p),T=!0,m=!1;const de=_.isCatmullRomCurve3?_.closed:!1;P=_.computeFrenetFrames(p,de),R=new O,U=new O,A=new O}m||(b=0,x=0,v=0,E=0);const I=c.extractPoints(f);let B=I.shape;const F=I.holes;if(!ss.isClockWise(B)){B=B.reverse();for(let de=0,_e=F.length;de<_e;de++){const me=F[de];ss.isClockWise(me)&&(F[de]=me.reverse())}}function H(de){const me=10000000000000001e-36;let Te=de[0];for(let z=1;z<=de.length;z++){const nt=z%de.length,Fe=de[nt],rt=Fe.x-Te.x,Ae=Fe.y-Te.y,D=rt*rt+Ae*Ae,C=Math.max(Math.abs(Fe.x),Math.abs(Fe.y),Math.abs(Te.x),Math.abs(Te.y)),X=me*C*C;if(D<=X){de.splice(nt,1),z--;continue}Te=Fe}}H(B),F.forEach(H);const Z=F.length,W=B;for(let de=0;de<Z;de++){const _e=F[de];B=B.concat(_e)}function $(de,_e,me){return _e||ot("ExtrudeGeometry: vec does not exist"),de.clone().addScaledVector(_e,me)}const Y=B.length;function ge(de,_e,me){let Te,z,nt;const Fe=de.x-_e.x,rt=de.y-_e.y,Ae=me.x-de.x,D=me.y-de.y,C=Fe*Fe+rt*rt,X=Fe*D-rt*Ae;if(Math.abs(X)>Number.EPSILON){const se=Math.sqrt(C),fe=Math.sqrt(Ae*Ae+D*D),ae=_e.x-rt/se,je=_e.y+Fe/se,Ie=me.x-D/fe,it=me.y+Ae/fe,ut=((Ie-ae)*D-(it-je)*Ae)/(Fe*D-rt*Ae);Te=ae+Fe*ut-de.x,z=je+rt*ut-de.y;const Se=Te*Te+z*z;if(Se<=2)return new pe(Te,z);nt=Math.sqrt(Se/2)}else{let se=!1;Fe>Number.EPSILON?Ae>Number.EPSILON&&(se=!0):Fe<-Number.EPSILON?Ae<-Number.EPSILON&&(se=!0):Math.sign(rt)===Math.sign(D)&&(se=!0),se?(Te=-rt,z=Fe,nt=Math.sqrt(C)):(Te=Fe,z=rt,nt=Math.sqrt(C/2))}return new pe(Te/nt,z/nt)}const he=[];for(let de=0,_e=W.length,me=_e-1,Te=de+1;de<_e;de++,me++,Te++)me===_e&&(me=0),Te===_e&&(Te=0),he[de]=ge(W[de],W[me],W[Te]);const Ee=[];let xe,ve=he.concat();for(let de=0,_e=Z;de<_e;de++){const me=F[de];xe=[];for(let Te=0,z=me.length,nt=z-1,Fe=Te+1;Te<z;Te++,nt++,Fe++)nt===z&&(nt=0),Fe===z&&(Fe=0),xe[Te]=ge(me[Te],me[nt],me[Fe]);Ee.push(xe),ve=ve.concat(xe)}let Xe;if(b===0)Xe=ss.triangulateShape(W,F);else{const de=[],_e=[];for(let me=0;me<b;me++){const Te=me/b,z=x*Math.cos(Te*Math.PI/2),nt=v*Math.sin(Te*Math.PI/2)+E;for(let Fe=0,rt=W.length;Fe<rt;Fe++){const Ae=$(W[Fe],he[Fe],nt);Qe(Ae.x,Ae.y,-z),Te===0&&de.push(Ae)}for(let Fe=0,rt=Z;Fe<rt;Fe++){const Ae=F[Fe];xe=Ee[Fe];const D=[];for(let C=0,X=Ae.length;C<X;C++){const se=$(Ae[C],xe[C],nt);Qe(se.x,se.y,-z),Te===0&&D.push(se)}Te===0&&_e.push(D)}}Xe=ss.triangulateShape(de,_e)}const lt=Xe.length,yt=v+E;for(let de=0;de<Y;de++){const _e=m?$(B[de],ve[de],yt):B[de];T?(U.copy(P.normals[0]).multiplyScalar(_e.x),R.copy(P.binormals[0]).multiplyScalar(_e.y),A.copy(w[0]).add(U).add(R),Qe(A.x,A.y,A.z)):Qe(_e.x,_e.y,0)}for(let de=1;de<=p;de++)for(let _e=0;_e<Y;_e++){const me=m?$(B[_e],ve[_e],yt):B[_e];T?(U.copy(P.normals[de]).multiplyScalar(me.x),R.copy(P.binormals[de]).multiplyScalar(me.y),A.copy(w[de]).add(U).add(R),Qe(A.x,A.y,A.z)):Qe(me.x,me.y,g/p*de)}for(let de=b-1;de>=0;de--){const _e=de/b,me=x*Math.cos(_e*Math.PI/2),Te=v*Math.sin(_e*Math.PI/2)+E;for(let z=0,nt=W.length;z<nt;z++){const Fe=$(W[z],he[z],Te);Qe(Fe.x,Fe.y,g+me)}for(let z=0,nt=F.length;z<nt;z++){const Fe=F[z];xe=Ee[z];for(let rt=0,Ae=Fe.length;rt<Ae;rt++){const D=$(Fe[rt],xe[rt],Te);T?Qe(D.x,D.y+w[p-1].y,w[p-1].x+me):Qe(D.x,D.y,g+me)}}}ue(),Re();function ue(){const de=i.length/3;if(m){let _e=0,me=Y*_e;for(let Te=0;Te<lt;Te++){const z=Xe[Te];Ze(z[2]+me,z[1]+me,z[0]+me)}_e=p+b*2,me=Y*_e;for(let Te=0;Te<lt;Te++){const z=Xe[Te];Ze(z[0]+me,z[1]+me,z[2]+me)}}else{for(let _e=0;_e<lt;_e++){const me=Xe[_e];Ze(me[2],me[1],me[0])}for(let _e=0;_e<lt;_e++){const me=Xe[_e];Ze(me[0]+Y*p,me[1]+Y*p,me[2]+Y*p)}}n.addGroup(de,i.length/3-de,0)}function Re(){const de=i.length/3;let _e=0;we(W,_e),_e+=W.length;for(let me=0,Te=F.length;me<Te;me++){const z=F[me];we(z,_e),_e+=z.length}n.addGroup(de,i.length/3-de,1)}function we(de,_e){let me=de.length;for(;--me>=0;){const Te=me;let z=me-1;z<0&&(z=de.length-1);for(let nt=0,Fe=p+b*2;nt<Fe;nt++){const rt=Y*nt,Ae=Y*(nt+1),D=_e+Te+rt,C=_e+z+rt,X=_e+z+Ae,se=_e+Te+Ae;Ge(D,C,X,se)}}}function Qe(de,_e,me){h.push(de),h.push(_e),h.push(me)}function Ze(de,_e,me){xt(de),xt(_e),xt(me);const Te=i.length/3,z=M.generateTopUV(n,i,Te-3,Te-2,Te-1);tt(z[0]),tt(z[1]),tt(z[2])}function Ge(de,_e,me,Te){xt(de),xt(_e),xt(Te),xt(_e),xt(me),xt(Te);const z=i.length/3,nt=M.generateSideWallUV(n,i,z-6,z-3,z-2,z-1);tt(nt[0]),tt(nt[1]),tt(nt[3]),tt(nt[1]),tt(nt[2]),tt(nt[3])}function xt(de){i.push(h[de*3+0]),i.push(h[de*3+1]),i.push(h[de*3+2])}function tt(de){o.push(de.x),o.push(de.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 jT(t,n,e)}static fromJSON(e,t){const n=[];for(let o=0,l=e.shapes.length;o<l;o++){const c=t[e.shapes[o]];n.push(c)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new ff[i.type]().fromJSON(i)),new Hf(n,e.options)}}const XT={generateTopUV:function(s,e,t,n,i){const o=e[t*3],l=e[t*3+1],c=e[n*3],h=e[n*3+1],f=e[i*3],p=e[i*3+1];return[new pe(o,l),new pe(c,h),new pe(f,p)]},generateSideWallUV:function(s,e,t,n,i,o){const l=e[t*3],c=e[t*3+1],h=e[t*3+2],f=e[n*3],p=e[n*3+1],g=e[n*3+2],m=e[i*3],x=e[i*3+1],v=e[i*3+2],E=e[o*3],b=e[o*3+1],_=e[o*3+2];return Math.abs(c-p)<Math.abs(l-f)?[new pe(l,1-h),new pe(f,1-g),new pe(m,1-v),new pe(E,1-_)]:[new pe(c,1-h),new pe(p,1-g),new pe(x,1-v),new pe(b,1-_)]}};function jT(s,e,t){if(t.shapes=[],Array.isArray(s))for(let n=0,i=s.length;n<i;n++){const o=s[n];t.shapes.push(o.uuid)}else t.shapes.push(s.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Gf extends Lr{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],o=[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,o,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Gf(e.radius,e.detail)}}class Wf extends _t{constructor(e=[new pe(0,-.5),new pe(.5,0),new pe(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=pt(i,0,Math.PI*2);const o=[],l=[],c=[],h=[],f=[],p=1/t,g=new O,m=new pe,x=new O,v=new O,E=new O;let b=0,_=0;for(let M=0;M<=e.length-1;M++)switch(M){case 0:b=e[M+1].x-e[M].x,_=e[M+1].y-e[M].y,x.x=_*1,x.y=-b,x.z=_*0,E.copy(x),x.normalize(),h.push(x.x,x.y,x.z);break;case e.length-1:h.push(E.x,E.y,E.z);break;default:b=e[M+1].x-e[M].x,_=e[M+1].y-e[M].y,x.x=_*1,x.y=-b,x.z=_*0,v.copy(x),x.x+=E.x,x.y+=E.y,x.z+=E.z,x.normalize(),h.push(x.x,x.y,x.z),E.copy(v)}for(let M=0;M<=t;M++){const w=n+M*p*i,T=Math.sin(w),P=Math.cos(w);for(let R=0;R<=e.length-1;R++){g.x=e[R].x*T,g.y=e[R].y,g.z=e[R].x*P,l.push(g.x,g.y,g.z),m.x=M/t,m.y=R/(e.length-1),c.push(m.x,m.y);const U=h[3*R+0]*T,A=h[3*R+1],I=h[3*R+0]*P;f.push(U,A,I)}}for(let M=0;M<t;M++)for(let w=0;w<e.length-1;w++){const T=w+M*e.length,P=T,R=T+e.length,U=T+e.length+1,A=T+1;o.push(P,R,A),o.push(U,A,R)}this.setIndex(o),this.setAttribute("position",new et(l,3)),this.setAttribute("uv",new et(c,2)),this.setAttribute("normal",new et(f,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wf(e.points,e.segments,e.phiStart,e.phiLength)}}class Tc extends Lr{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 Tc(e.radius,e.detail)}}class $o extends _t{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const o=e/2,l=t/2,c=Math.floor(n),h=Math.floor(i),f=c+1,p=h+1,g=e/c,m=t/h,x=[],v=[],E=[],b=[];for(let _=0;_<p;_++){const M=_*m-l;for(let w=0;w<f;w++){const T=w*g-o;v.push(T,-M,0),E.push(0,0,1),b.push(w/c),b.push(1-_/h)}}for(let _=0;_<h;_++)for(let M=0;M<c;M++){const w=M+f*_,T=M+f*(_+1),P=M+1+f*(_+1),R=M+1+f*_;x.push(w,T,R),x.push(T,P,R)}this.setIndex(x),this.setAttribute("position",new et(v,3)),this.setAttribute("normal",new et(E,3)),this.setAttribute("uv",new et(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $o(e.width,e.height,e.widthSegments,e.heightSegments)}}class Xf extends _t{constructor(e=.5,t=1,n=32,i=1,o=0,l=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:o,thetaLength:l},n=Math.max(3,n),i=Math.max(1,i);const c=[],h=[],f=[],p=[];let g=e;const m=(t-e)/i,x=new O,v=new pe;for(let E=0;E<=i;E++){for(let b=0;b<=n;b++){const _=o+b/n*l;x.x=g*Math.cos(_),x.y=g*Math.sin(_),h.push(x.x,x.y,x.z),f.push(0,0,1),v.x=(x.x/t+1)/2,v.y=(x.y/t+1)/2,p.push(v.x,v.y)}g+=m}for(let E=0;E<i;E++){const b=E*(n+1);for(let _=0;_<n;_++){const M=_+b,w=M,T=M+n+1,P=M+n+2,R=M+1;c.push(w,T,R),c.push(T,P,R)}}this.setIndex(c),this.setAttribute("position",new et(h,3)),this.setAttribute("normal",new et(f,3)),this.setAttribute("uv",new et(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xf(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class jf extends _t{constructor(e=new wa([new pe(0,.5),new pe(-.5,-.5),new pe(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],o=[],l=[];let c=0,h=0;if(Array.isArray(e)===!1)f(e);else for(let p=0;p<e.length;p++)f(e[p]),this.addGroup(c,h,p),c+=h,h=0;this.setIndex(n),this.setAttribute("position",new et(i,3)),this.setAttribute("normal",new et(o,3)),this.setAttribute("uv",new et(l,2));function f(p){const g=i.length/3,m=p.extractPoints(t);let x=m.shape;const v=m.holes;ss.isClockWise(x)===!1&&(x=x.reverse());for(let b=0,_=v.length;b<_;b++){const M=v[b];ss.isClockWise(M)===!0&&(v[b]=M.reverse())}const E=ss.triangulateShape(x,v);for(let b=0,_=v.length;b<_;b++){const M=v[b];x=x.concat(M)}for(let b=0,_=x.length;b<_;b++){const M=x[b];i.push(M.x,M.y,0),o.push(0,0,1),l.push(M.x,M.y)}for(let b=0,_=E.length;b<_;b++){const M=E[b],w=M[0]+g,T=M[1]+g,P=M[2]+g;n.push(w,T,P),h+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return qT(t,e)}static fromJSON(e,t){const n=[];for(let i=0,o=e.shapes.length;i<o;i++){const l=t[e.shapes[i]];n.push(l)}return new jf(n,e.curveSegments)}}function qT(s,e){if(e.shapes=[],Array.isArray(s))for(let t=0,n=s.length;t<n;t++){const i=s[t];e.shapes.push(i.uuid)}else e.shapes.push(s.uuid);return e}class Ac extends _t{constructor(e=1,t=32,n=16,i=0,o=Math.PI*2,l=0,c=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:o,thetaStart:l,thetaLength:c},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const h=Math.min(l+c,Math.PI);let f=0;const p=[],g=new O,m=new O,x=[],v=[],E=[],b=[];for(let _=0;_<=n;_++){const M=[],w=_/n;let T=0;_===0&&l===0?T=.5/t:_===n&&h===Math.PI&&(T=-.5/t);for(let P=0;P<=t;P++){const R=P/t;g.x=-e*Math.cos(i+R*o)*Math.sin(l+w*c),g.y=e*Math.cos(l+w*c),g.z=e*Math.sin(i+R*o)*Math.sin(l+w*c),v.push(g.x,g.y,g.z),m.copy(g).normalize(),E.push(m.x,m.y,m.z),b.push(R+T,1-w),M.push(f++)}p.push(M)}for(let _=0;_<n;_++)for(let M=0;M<t;M++){const w=p[_][M+1],T=p[_][M],P=p[_+1][M],R=p[_+1][M+1];(_!==0||l>0)&&x.push(w,T,R),(_!==n-1||h<Math.PI)&&x.push(T,P,R)}this.setIndex(x),this.setAttribute("position",new et(v,3)),this.setAttribute("normal",new et(E,3)),this.setAttribute("uv",new et(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ac(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class qf extends Lr{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 qf(e.radius,e.detail)}}class Yf extends _t{constructor(e=1,t=.4,n=12,i=48,o=Math.PI*2,l=0,c=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:o,thetaStart:l,thetaLength:c},n=Math.floor(n),i=Math.floor(i);const h=[],f=[],p=[],g=[],m=new O,x=new O,v=new O;for(let E=0;E<=n;E++){const b=l+E/n*c;for(let _=0;_<=i;_++){const M=_/i*o;x.x=(e+t*Math.cos(b))*Math.cos(M),x.y=(e+t*Math.cos(b))*Math.sin(M),x.z=t*Math.sin(b),f.push(x.x,x.y,x.z),m.x=e*Math.cos(M),m.y=e*Math.sin(M),v.subVectors(x,m).normalize(),p.push(v.x,v.y,v.z),g.push(_/i),g.push(E/n)}}for(let E=1;E<=n;E++)for(let b=1;b<=i;b++){const _=(i+1)*E+b-1,M=(i+1)*(E-1)+b-1,w=(i+1)*(E-1)+b,T=(i+1)*E+b;h.push(_,M,T),h.push(M,w,T)}this.setIndex(h),this.setAttribute("position",new et(f,3)),this.setAttribute("normal",new et(p,3)),this.setAttribute("uv",new et(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Yf(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class $f extends _t{constructor(e=1,t=.4,n=64,i=8,o=2,l=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:o,q:l},n=Math.floor(n),i=Math.floor(i);const c=[],h=[],f=[],p=[],g=new O,m=new O,x=new O,v=new O,E=new O,b=new O,_=new O;for(let w=0;w<=n;++w){const T=w/n*o*Math.PI*2;M(T,o,l,e,x),M(T+.01,o,l,e,v),b.subVectors(v,x),_.addVectors(v,x),E.crossVectors(b,_),_.crossVectors(E,b),E.normalize(),_.normalize();for(let P=0;P<=i;++P){const R=P/i*Math.PI*2,U=-t*Math.cos(R),A=t*Math.sin(R);g.x=x.x+(U*_.x+A*E.x),g.y=x.y+(U*_.y+A*E.y),g.z=x.z+(U*_.z+A*E.z),h.push(g.x,g.y,g.z),m.subVectors(g,x).normalize(),f.push(m.x,m.y,m.z),p.push(w/n),p.push(P/i)}}for(let w=1;w<=n;w++)for(let T=1;T<=i;T++){const P=(i+1)*(w-1)+(T-1),R=(i+1)*w+(T-1),U=(i+1)*w+T,A=(i+1)*(w-1)+T;c.push(P,R,A),c.push(R,U,A)}this.setIndex(c),this.setAttribute("position",new et(h,3)),this.setAttribute("normal",new et(f,3)),this.setAttribute("uv",new et(p,2));function M(w,T,P,R,U){const A=Math.cos(w),I=Math.sin(w),B=P/T*w,F=Math.cos(B);U.x=R*(2+F)*.5*A,U.y=R*(2+F)*I*.5,U.z=R*Math.sin(B)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $f(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Zf extends _t{constructor(e=new Sg(new O(-1,-1,0),new O(-1,1,0),new O(1,1,0)),t=64,n=1,i=8,o=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:o};const l=e.computeFrenetFrames(t,o);this.tangents=l.tangents,this.normals=l.normals,this.binormals=l.binormals;const c=new O,h=new O,f=new pe;let p=new O;const g=[],m=[],x=[],v=[];E(),this.setIndex(v),this.setAttribute("position",new et(g,3)),this.setAttribute("normal",new et(m,3)),this.setAttribute("uv",new et(x,2));function E(){for(let w=0;w<t;w++)b(w);b(o===!1?t:0),M(),_()}function b(w){p=e.getPointAt(w/t,p);const T=l.normals[w],P=l.binormals[w];for(let R=0;R<=i;R++){const U=R/i*Math.PI*2,A=Math.sin(U),I=-Math.cos(U);h.x=I*T.x+A*P.x,h.y=I*T.y+A*P.y,h.z=I*T.z+A*P.z,h.normalize(),m.push(h.x,h.y,h.z),c.x=p.x+n*h.x,c.y=p.y+n*h.y,c.z=p.z+n*h.z,g.push(c.x,c.y,c.z)}}function _(){for(let w=1;w<=t;w++)for(let T=1;T<=i;T++){const P=(i+1)*(w-1)+(T-1),R=(i+1)*w+(T-1),U=(i+1)*w+T,A=(i+1)*(w-1)+T;v.push(P,R,A),v.push(R,U,A)}}function M(){for(let w=0;w<=t;w++)for(let T=0;T<=i;T++)f.x=w/t,f.y=T/i,x.push(f.x,f.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 Zf(new ff[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Sb extends _t{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new O,o=new O;if(e.index!==null){const l=e.attributes.position,c=e.index;let h=e.groups;h.length===0&&(h=[{start:0,count:c.count,materialIndex:0}]);for(let f=0,p=h.length;f<p;++f){const g=h[f],m=g.start,x=g.count;for(let v=m,E=m+x;v<E;v+=3)for(let b=0;b<3;b++){const _=c.getX(v+b),M=c.getX(v+(b+1)%3);i.fromBufferAttribute(l,_),o.fromBufferAttribute(l,M),e_(i,o,n)===!0&&(t.push(i.x,i.y,i.z),t.push(o.x,o.y,o.z))}}}else{const l=e.attributes.position;for(let c=0,h=l.count/3;c<h;c++)for(let f=0;f<3;f++){const p=3*c+f,g=3*c+(f+1)%3;i.fromBufferAttribute(l,p),o.fromBufferAttribute(l,g),e_(i,o,n)===!0&&(t.push(i.x,i.y,i.z),t.push(o.x,o.y,o.z))}}this.setAttribute("position",new et(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function e_(s,e,t){const n=`${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}var t_=Object.freeze({__proto__:null,BoxGeometry:Na,CapsuleGeometry:zf,CircleGeometry:Bf,ConeGeometry:wc,CylinderGeometry:Ec,DodecahedronGeometry:kf,EdgesGeometry:fb,ExtrudeGeometry:Hf,IcosahedronGeometry:Gf,LatheGeometry:Wf,OctahedronGeometry:Tc,PlaneGeometry:$o,PolyhedronGeometry:Lr,RingGeometry:Xf,ShapeGeometry:jf,SphereGeometry:Ac,TetrahedronGeometry:qf,TorusGeometry:Yf,TorusKnotGeometry:$f,TubeGeometry:Zf,WireframeGeometry:Sb});class Mb extends Zn{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}}function Xo(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(He("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 ei(s){const e={};for(let t=0;t<s.length;t++){const n=Xo(s[t]);for(const i in n)e[i]=n[i]}return e}function YT(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function Eb(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Dt.workingColorSpace}const wb={clone:Xo,merge:ei};var $T=`void main() {
|
|
1
|
+
import{j as q,m as pa}from"./vendor-motion-C3CZ8ZlO.js";import{r as q1,c as Y1,h as Sm,u as $1,t as pv,f as Z1}from"./index-DyKlGDg1.js";import{r as K1,u as br,c as J1}from"./vendor-utils-BIYveU_1.js";import{s as Q1}from"./stats-CxlRAO2g.js";import{m as eE}from"./mcp-DSddQR1h.js";import{s as tE}from"./skills-DIuMjpPF.js";import{a as nE,g as fy,R as dy,r as le,L as py}from"./vendor-react-DikRIOlj.js";import{l as iE,m as sE,L as rE,A as aE,g as Mm,n as oE,o as lE,p as cE,i as uE,W as hE,P as fE,H as dE,f as pE,q as my,r as mE,s as gE,t as xE}from"./vendor-icons-DE7PWdkN.js";const vE={hidden:{opacity:0,y:20},show:{opacity:1,y:0}},_p=({title:s,value:e,icon:t,subValue:n})=>q.jsxs(pa.div,{variants:vE,className:"border border-azure-border dark:border-matrix-primary bg-azure-surface/50 dark:bg-zinc-950/50 p-6 rounded relative overflow-hidden group hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",children:[q.jsxs("div",{className:"flex justify-between items-start mb-4",children:[q.jsx("h3",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm font-bold uppercase",children:s}),q.jsx(t,{className:"w-6 h-6 text-azure-primary dark:text-matrix-primary group-hover:text-azure-primary dark:group-hover:text-matrix-highlight transition-colors"})]}),q.jsx("div",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight mb-1 font-mono tracking-tighter truncate",children:e}),n&&q.jsx("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70 font-mono",children:n})]});const yc="183",ma={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ga={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},gy=0,Em=1,xy=2,_E=3,vy=0,Fo=1,Gl=2,_a=3,qs=0,si=1,pi=2,vs=0,Ma=1,yh=2,wm=3,Tm=4,_y=5,yE=6,Sr=100,yy=101,by=102,Sy=103,My=104,Ey=200,wy=201,Ty=202,Ay=203,bh=204,Sh=205,Cy=206,Ry=207,Iy=208,Py=209,Ly=210,Ny=211,Dy=212,Uy=213,Fy=214,Mh=0,Eh=1,wh=2,Ta=3,Th=4,Ah=5,Ch=6,Rh=7,bc=0,Oy=1,zy=2,Bi=0,$m=1,Zm=2,Km=3,_f=4,Jm=5,Qm=6,eg=7,Am="attached",By="detached",yf=300,_s=301,Ar=302,Wl=303,Xl=304,qo=306,nc=1e3,gi=1001,ic=1002,mn=1003,tg=1004,bE=1004,No=1005,SE=1005,en=1006,jl=1007,ME=1007,gs=1008,EE=1008,ti=1009,ng=1010,ig=1011,zo=1012,bf=1013,ki=1014,ii=1015,ys=1016,Sf=1017,Mf=1018,Bo=1020,sg=35902,rg=35899,ag=1021,og=1022,Yn=1023,bs=1026,Er=1027,Ef=1028,Sc=1029,Aa=1030,wf=1031,wE=1032,Tf=1033,ql=33776,Yl=33777,$l=33778,Zl=33779,Ih=35840,Ph=35841,Lh=35842,Nh=35843,Dh=36196,Uh=37492,Fh=37496,Oh=37488,zh=37489,Bh=37490,kh=37491,Vh=37808,Hh=37809,Gh=37810,Wh=37811,Xh=37812,jh=37813,qh=37814,Yh=37815,$h=37816,Zh=37817,Kh=37818,Jh=37819,Qh=37820,ef=37821,tf=36492,nf=36494,sf=36495,rf=36283,af=36284,of=36285,lf=36286,ky=2200,Vy=2201,Hy=2202,sc=2300,cf=2301,mh=2302,Cm=2303,ya=2400,ba=2401,rc=2402,Af=2500,lg=2501,TE=0,AE=1,CE=2,Gy=3200,RE=3201,IE=3202,PE=3203,Ir=0,Wy=1,Ws="",qn="srgb",Cr="srgb-linear",ac="linear",Xt="srgb",LE="",NE="rg",DE="ga",UE=0,xa=7680,FE=7681,OE=7682,zE=7683,BE=34055,kE=34056,VE=5386,HE=512,GE=513,WE=514,XE=515,jE=516,qE=517,YE=518,Rm=519,Xy=512,jy=513,qy=514,Cf=515,Yy=516,$y=517,Rf=518,Zy=519,oc=35044,$E=35048,ZE=35040,KE=35045,JE=35049,QE=35041,ew=35046,tw=35050,nw=35042,iw="100",Im="300 es",Ri=2e3,Ca=2001,sw={COMPUTE:"compute",RENDER:"render"},rw={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},aw={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},ow={TEXTURE_COMPARE:"depthTextureCompare"};function lw(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}const cw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Do(s,e){return new cw[s](e)}function Ky(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function lc(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Jy(){const s=lc("canvas");return s.style.display="block",s}const mv={};let Rr=null;function uw(s){Rr=s}function hw(){return Rr}function cc(...s){const e="THREE."+s.shift();Rr?Rr("log",e,...s):console.log(e,...s)}function Qy(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function He(...s){s=Qy(s);const e="THREE."+s.shift();if(Rr)Rr("warn",e,...s);else{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function ot(...s){s=Qy(s);const e="THREE."+s.shift();if(Rr)Rr("error",e,...s);else{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function uc(...s){const e=s.join(" ");e in mv||(mv[e]=!0,He(...s))}function fw(s,e,t){return new Promise(function(n,i){function o(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(o,t);break;default:n()}}setTimeout(o,t)})}const dw={[Mh]:Eh,[wh]:Ch,[Th]:Rh,[Ta]:Ah,[Eh]:Mh,[Ch]:wh,[Rh]:Th,[Ah]:Ta};let Ss=class{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){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let o=0,l=i.length;o<l;o++)i[o].call(this,e);e.target=null}}};const Wn=["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 gv=1234567;const Ea=Math.PI/180,ko=180/Math.PI;function Ii(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Wn[s&255]+Wn[s>>8&255]+Wn[s>>16&255]+Wn[s>>24&255]+"-"+Wn[e&255]+Wn[e>>8&255]+"-"+Wn[e>>16&15|64]+Wn[e>>24&255]+"-"+Wn[t&63|128]+Wn[t>>8&255]+"-"+Wn[t>>16&255]+Wn[t>>24&255]+Wn[n&255]+Wn[n>>8&255]+Wn[n>>16&255]+Wn[n>>24&255]).toLowerCase()}function pt(s,e,t){return Math.max(e,Math.min(t,s))}function cg(s,e){return(s%e+e)%e}function pw(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function mw(s,e,t){return s!==e?(t-s)/(e-s):0}function Kl(s,e,t){return(1-t)*s+t*e}function gw(s,e,t,n){return Kl(s,e,1-Math.exp(-t*n))}function xw(s,e=1){return e-Math.abs(cg(s,e*2)-e)}function vw(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function _w(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function yw(s,e){return s+Math.floor(Math.random()*(e-s+1))}function bw(s,e){return s+Math.random()*(e-s)}function Sw(s){return s*(.5-Math.random())}function Mw(s){s!==void 0&&(gv=s);let e=gv+=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 Ew(s){return s*Ea}function ww(s){return s*ko}function Tw(s){return(s&s-1)===0&&s!==0}function Aw(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function Cw(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function Rw(s,e,t,n,i){const o=Math.cos,l=Math.sin,c=o(t/2),h=l(t/2),f=o((e+n)/2),p=l((e+n)/2),g=o((e-n)/2),m=l((e-n)/2),x=o((n-e)/2),v=l((n-e)/2);switch(i){case"XYX":s.set(c*p,h*g,h*m,c*f);break;case"YZY":s.set(h*m,c*p,h*g,c*f);break;case"ZXZ":s.set(h*g,h*m,c*p,c*f);break;case"XZX":s.set(c*p,h*v,h*x,c*f);break;case"YXY":s.set(h*x,c*p,h*v,c*f);break;case"ZYZ":s.set(h*v,h*x,c*p,c*f);break;default:He("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function ni(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function wt(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const Iw={DEG2RAD:Ea,RAD2DEG:ko,generateUUID:Ii,clamp:pt,euclideanModulo:cg,mapLinear:pw,inverseLerp:mw,lerp:Kl,damp:gw,pingpong:xw,smoothstep:vw,smootherstep:_w,randInt:yw,randFloat:bw,randFloatSpread:Sw,seededRandom:Mw,degToRad:Ew,radToDeg:ww,isPowerOfTwo:Tw,ceilPowerOfTwo:Aw,floorPowerOfTwo:Cw,setQuaternionFromProperEuler:Rw,normalize:wt,denormalize:ni};class pe{constructor(e=0,t=0){pe.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=pt(this.x,e.x,t.x),this.y=pt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=pt(this.x,e,t),this.y=pt(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(pt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(pt(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),o=this.x-e.x,l=this.y-e.y;return this.x=o*n-l*i+e.x,this.y=o*i+l*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class zn{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,o,l,c){let h=n[i+0],f=n[i+1],p=n[i+2],g=n[i+3],m=o[l+0],x=o[l+1],v=o[l+2],E=o[l+3];if(g!==E||h!==m||f!==x||p!==v){let b=h*m+f*x+p*v+g*E;b<0&&(m=-m,x=-x,v=-v,E=-E,b=-b);let _=1-c;if(b<.9995){const M=Math.acos(b),w=Math.sin(M);_=Math.sin(_*M)/w,c=Math.sin(c*M)/w,h=h*_+m*c,f=f*_+x*c,p=p*_+v*c,g=g*_+E*c}else{h=h*_+m*c,f=f*_+x*c,p=p*_+v*c,g=g*_+E*c;const M=1/Math.sqrt(h*h+f*f+p*p+g*g);h*=M,f*=M,p*=M,g*=M}}e[t]=h,e[t+1]=f,e[t+2]=p,e[t+3]=g}static multiplyQuaternionsFlat(e,t,n,i,o,l){const c=n[i],h=n[i+1],f=n[i+2],p=n[i+3],g=o[l],m=o[l+1],x=o[l+2],v=o[l+3];return e[t]=c*v+p*g+h*x-f*m,e[t+1]=h*v+p*m+f*g-c*x,e[t+2]=f*v+p*x+c*m-h*g,e[t+3]=p*v-c*g-h*m-f*x,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=!0){const n=e._x,i=e._y,o=e._z,l=e._order,c=Math.cos,h=Math.sin,f=c(n/2),p=c(i/2),g=c(o/2),m=h(n/2),x=h(i/2),v=h(o/2);switch(l){case"XYZ":this._x=m*p*g+f*x*v,this._y=f*x*g-m*p*v,this._z=f*p*v+m*x*g,this._w=f*p*g-m*x*v;break;case"YXZ":this._x=m*p*g+f*x*v,this._y=f*x*g-m*p*v,this._z=f*p*v-m*x*g,this._w=f*p*g+m*x*v;break;case"ZXY":this._x=m*p*g-f*x*v,this._y=f*x*g+m*p*v,this._z=f*p*v+m*x*g,this._w=f*p*g-m*x*v;break;case"ZYX":this._x=m*p*g-f*x*v,this._y=f*x*g+m*p*v,this._z=f*p*v-m*x*g,this._w=f*p*g+m*x*v;break;case"YZX":this._x=m*p*g+f*x*v,this._y=f*x*g+m*p*v,this._z=f*p*v-m*x*g,this._w=f*p*g-m*x*v;break;case"XZY":this._x=m*p*g-f*x*v,this._y=f*x*g-m*p*v,this._z=f*p*v+m*x*g,this._w=f*p*g+m*x*v;break;default:He("Quaternion: .setFromEuler() encountered an unknown order: "+l)}return t===!0&&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],o=t[8],l=t[1],c=t[5],h=t[9],f=t[2],p=t[6],g=t[10],m=n+c+g;if(m>0){const x=.5/Math.sqrt(m+1);this._w=.25/x,this._x=(p-h)*x,this._y=(o-f)*x,this._z=(l-i)*x}else if(n>c&&n>g){const x=2*Math.sqrt(1+n-c-g);this._w=(p-h)/x,this._x=.25*x,this._y=(i+l)/x,this._z=(o+f)/x}else if(c>g){const x=2*Math.sqrt(1+c-n-g);this._w=(o-f)/x,this._x=(i+l)/x,this._y=.25*x,this._z=(h+p)/x}else{const x=2*Math.sqrt(1+g-n-c);this._w=(l-i)/x,this._x=(o+f)/x,this._y=(h+p)/x,this._z=.25*x}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(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(pt(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,o=e._z,l=e._w,c=t._x,h=t._y,f=t._z,p=t._w;return this._x=n*p+l*c+i*f-o*h,this._y=i*p+l*h+o*c-n*f,this._z=o*p+l*f+n*h-i*c,this._w=l*p-n*c-i*h-o*f,this._onChangeCallback(),this}slerp(e,t){let n=e._x,i=e._y,o=e._z,l=e._w,c=this.dot(e);c<0&&(n=-n,i=-i,o=-o,l=-l,c=-c);let h=1-t;if(c<.9995){const f=Math.acos(c),p=Math.sin(f);h=Math.sin(h*f)/p,t=Math.sin(t*f)/p,this._x=this._x*h+n*t,this._y=this._y*h+i*t,this._z=this._z*h+o*t,this._w=this._w*h+l*t,this._onChangeCallback()}else this._x=this._x*h+n*t,this._y=this._y*h+i*t,this._z=this._z*h+o*t,this._w=this._w*h+l*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),o=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),o*Math.sin(t),o*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class O{constructor(e=0,t=0,n=0){O.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(xv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(xv.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*i,this.y=o[1]*t+o[4]*n+o[7]*i,this.z=o[2]*t+o[5]*n+o[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,o=e.elements,l=1/(o[3]*t+o[7]*n+o[11]*i+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*i+o[12])*l,this.y=(o[1]*t+o[5]*n+o[9]*i+o[13])*l,this.z=(o[2]*t+o[6]*n+o[10]*i+o[14])*l,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,o=e.x,l=e.y,c=e.z,h=e.w,f=2*(l*i-c*n),p=2*(c*t-o*i),g=2*(o*n-l*t);return this.x=t+h*f+l*g-c*p,this.y=n+h*p+c*f-o*g,this.z=i+h*g+o*p-l*f,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,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i,this.y=o[1]*t+o[5]*n+o[9]*i,this.z=o[2]*t+o[6]*n+o[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=pt(this.x,e.x,t.x),this.y=pt(this.y,e.y,t.y),this.z=pt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=pt(this.x,e,t),this.y=pt(this.y,e,t),this.z=pt(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(pt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,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,o=e.z,l=t.x,c=t.y,h=t.z;return this.x=i*h-o*c,this.y=o*l-n*h,this.z=n*c-i*l,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 yp.copy(this).projectOnVector(e),this.sub(yp)}reflect(e){return this.sub(yp.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(pt(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()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const yp=new O,xv=new zn;class St{constructor(e,t,n,i,o,l,c,h,f){St.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,o,l,c,h,f)}set(e,t,n,i,o,l,c,h,f){const p=this.elements;return p[0]=e,p[1]=i,p[2]=c,p[3]=t,p[4]=o,p[5]=h,p[6]=n,p[7]=l,p[8]=f,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,o=this.elements,l=n[0],c=n[3],h=n[6],f=n[1],p=n[4],g=n[7],m=n[2],x=n[5],v=n[8],E=i[0],b=i[3],_=i[6],M=i[1],w=i[4],T=i[7],P=i[2],R=i[5],U=i[8];return o[0]=l*E+c*M+h*P,o[3]=l*b+c*w+h*R,o[6]=l*_+c*T+h*U,o[1]=f*E+p*M+g*P,o[4]=f*b+p*w+g*R,o[7]=f*_+p*T+g*U,o[2]=m*E+x*M+v*P,o[5]=m*b+x*w+v*R,o[8]=m*_+x*T+v*U,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],o=e[3],l=e[4],c=e[5],h=e[6],f=e[7],p=e[8];return t*l*p-t*c*f-n*o*p+n*c*h+i*o*f-i*l*h}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],o=e[3],l=e[4],c=e[5],h=e[6],f=e[7],p=e[8],g=p*l-c*f,m=c*h-p*o,x=f*o-l*h,v=t*g+n*m+i*x;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const E=1/v;return e[0]=g*E,e[1]=(i*f-p*n)*E,e[2]=(c*n-i*l)*E,e[3]=m*E,e[4]=(p*t-i*h)*E,e[5]=(i*o-c*t)*E,e[6]=x*E,e[7]=(n*h-f*t)*E,e[8]=(l*t-n*o)*E,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,o,l,c){const h=Math.cos(o),f=Math.sin(o);return this.set(n*h,n*f,-n*(h*l+f*c)+l+e,-i*f,i*h,-i*(-f*l+h*c)+c+t,0,0,1),this}scale(e,t){return this.premultiply(bp.makeScale(e,t)),this}rotate(e){return this.premultiply(bp.makeRotation(-e)),this}translate(e,t){return this.premultiply(bp.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 bp=new St,vv=new St().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),_v=new St().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Pw(){const s={enabled:!0,workingColorSpace:Cr,spaces:{},convert:function(i,o,l){return this.enabled===!1||o===l||!o||!l||(this.spaces[o].transfer===Xt&&(i.r=js(i.r),i.g=js(i.g),i.b=js(i.b)),this.spaces[o].primaries!==this.spaces[l].primaries&&(i.applyMatrix3(this.spaces[o].toXYZ),i.applyMatrix3(this.spaces[l].fromXYZ)),this.spaces[l].transfer===Xt&&(i.r=Oo(i.r),i.g=Oo(i.g),i.b=Oo(i.b))),i},workingToColorSpace:function(i,o){return this.convert(i,this.workingColorSpace,o)},colorSpaceToWorking:function(i,o){return this.convert(i,o,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Ws?ac:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,o=this.workingColorSpace){return i.fromArray(this.spaces[o].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,o,l){return i.copy(this.spaces[o].toXYZ).multiply(this.spaces[l].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,o){return uc("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,o)},toWorkingColorSpace:function(i,o){return uc("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,o)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[Cr]:{primaries:e,whitePoint:n,transfer:ac,toXYZ:vv,fromXYZ:_v,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:qn},outputColorSpaceConfig:{drawingBufferColorSpace:qn}},[qn]:{primaries:e,whitePoint:n,transfer:Xt,toXYZ:vv,fromXYZ:_v,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:qn}}}),s}const Dt=Pw();function js(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Oo(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let lo;class eb{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{lo===void 0&&(lo=lc("canvas")),lo.width=e.width,lo.height=e.height;const i=lo.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=lo}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=lc("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),o=i.data;for(let l=0;l<o.length;l++)o[l]=js(o[l]/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(js(t[n]/255)*255):t[n]=js(t[n]);return{data:t,width:e.width,height:e.height}}else return He("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Lw=0;class wr{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Lw++}),this.uuid=Ii(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}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 o;if(Array.isArray(i)){o=[];for(let l=0,c=i.length;l<c;l++)i[l].isDataTexture?o.push(Sp(i[l].image)):o.push(Sp(i[l]))}else o=Sp(i);n.url=o}return t||(e.images[this.uuid]=n),n}}function Sp(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?eb.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(He("Texture: Unable to serialize Texture."),{})}let Nw=0;const Mp=new O;class un extends Ss{constructor(e=un.DEFAULT_IMAGE,t=un.DEFAULT_MAPPING,n=gi,i=gi,o=en,l=gs,c=Yn,h=ti,f=un.DEFAULT_ANISOTROPY,p=Ws){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Nw++}),this.uuid=Ii(),this.name="",this.source=new wr(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=o,this.minFilter=l,this.anisotropy=f,this.format=c,this.internalFormat=null,this.type=h,this.offset=new pe(0,0),this.repeat=new pe(1,1),this.center=new pe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new St,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=p,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Mp).x}get height(){return this.source.getSize(Mp).y}get depth(){return this.source.getSize(Mp).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){He(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){He(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}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.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==yf)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case nc:e.x=e.x-Math.floor(e.x);break;case gi:e.x=e.x<0?0:1;break;case ic: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 nc:e.y=e.y-Math.floor(e.y);break;case gi:e.y=e.y<0?0:1;break;case ic:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}un.DEFAULT_IMAGE=null;un.DEFAULT_MAPPING=yf;un.DEFAULT_ANISOTROPY=1;class Zt{constructor(e=0,t=0,n=0,i=1){Zt.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,o=this.w,l=e.elements;return this.x=l[0]*t+l[4]*n+l[8]*i+l[12]*o,this.y=l[1]*t+l[5]*n+l[9]*i+l[13]*o,this.z=l[2]*t+l[6]*n+l[10]*i+l[14]*o,this.w=l[3]*t+l[7]*n+l[11]*i+l[15]*o,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,o;const h=e.elements,f=h[0],p=h[4],g=h[8],m=h[1],x=h[5],v=h[9],E=h[2],b=h[6],_=h[10];if(Math.abs(p-m)<.01&&Math.abs(g-E)<.01&&Math.abs(v-b)<.01){if(Math.abs(p+m)<.1&&Math.abs(g+E)<.1&&Math.abs(v+b)<.1&&Math.abs(f+x+_-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(f+1)/2,T=(x+1)/2,P=(_+1)/2,R=(p+m)/4,U=(g+E)/4,A=(v+b)/4;return w>T&&w>P?w<.01?(n=0,i=.707106781,o=.707106781):(n=Math.sqrt(w),i=R/n,o=U/n):T>P?T<.01?(n=.707106781,i=0,o=.707106781):(i=Math.sqrt(T),n=R/i,o=A/i):P<.01?(n=.707106781,i=.707106781,o=0):(o=Math.sqrt(P),n=U/o,i=A/o),this.set(n,i,o,t),this}let M=Math.sqrt((b-v)*(b-v)+(g-E)*(g-E)+(m-p)*(m-p));return Math.abs(M)<.001&&(M=1),this.x=(b-v)/M,this.y=(g-E)/M,this.z=(m-p)/M,this.w=Math.acos((f+x+_-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=pt(this.x,e.x,t.x),this.y=pt(this.y,e.y,t.y),this.z=pt(this.z,e.z,t.z),this.w=pt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=pt(this.x,e,t),this.y=pt(this.y,e,t),this.z=pt(this.z,e,t),this.w=pt(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(pt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,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 ug extends Ss{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:en,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Zt(0,0,e,t),this.scissorTest=!1,this.viewport=new Zt(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:n.depth},o=new un(i),l=n.count;for(let c=0;c<l;c++)this.textures[c]=o.clone(),this.textures[c].isRenderTargetTexture=!0,this.textures[c].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:en,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}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,o=this.textures.length;i<o;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new wr(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Pi extends ug{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class If extends un{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=mn,this.minFilter=mn,this.wrapR=gi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Dw extends Pi{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new If(null,e,t,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class Pf extends un{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=mn,this.minFilter=mn,this.wrapR=gi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Uw extends Pi{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Pf(null,e,t,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class gt{constructor(e,t,n,i,o,l,c,h,f,p,g,m,x,v,E,b){gt.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,o,l,c,h,f,p,g,m,x,v,E,b)}set(e,t,n,i,o,l,c,h,f,p,g,m,x,v,E,b){const _=this.elements;return _[0]=e,_[4]=t,_[8]=n,_[12]=i,_[1]=o,_[5]=l,_[9]=c,_[13]=h,_[2]=f,_[6]=p,_[10]=g,_[14]=m,_[3]=x,_[7]=v,_[11]=E,_[15]=b,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 gt().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 this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(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){if(e.determinant()===0)return this.identity();const t=this.elements,n=e.elements,i=1/co.setFromMatrixColumn(e,0).length(),o=1/co.setFromMatrixColumn(e,1).length(),l=1/co.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]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*l,t[9]=n[9]*l,t[10]=n[10]*l,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,o=e.z,l=Math.cos(n),c=Math.sin(n),h=Math.cos(i),f=Math.sin(i),p=Math.cos(o),g=Math.sin(o);if(e.order==="XYZ"){const m=l*p,x=l*g,v=c*p,E=c*g;t[0]=h*p,t[4]=-h*g,t[8]=f,t[1]=x+v*f,t[5]=m-E*f,t[9]=-c*h,t[2]=E-m*f,t[6]=v+x*f,t[10]=l*h}else if(e.order==="YXZ"){const m=h*p,x=h*g,v=f*p,E=f*g;t[0]=m+E*c,t[4]=v*c-x,t[8]=l*f,t[1]=l*g,t[5]=l*p,t[9]=-c,t[2]=x*c-v,t[6]=E+m*c,t[10]=l*h}else if(e.order==="ZXY"){const m=h*p,x=h*g,v=f*p,E=f*g;t[0]=m-E*c,t[4]=-l*g,t[8]=v+x*c,t[1]=x+v*c,t[5]=l*p,t[9]=E-m*c,t[2]=-l*f,t[6]=c,t[10]=l*h}else if(e.order==="ZYX"){const m=l*p,x=l*g,v=c*p,E=c*g;t[0]=h*p,t[4]=v*f-x,t[8]=m*f+E,t[1]=h*g,t[5]=E*f+m,t[9]=x*f-v,t[2]=-f,t[6]=c*h,t[10]=l*h}else if(e.order==="YZX"){const m=l*h,x=l*f,v=c*h,E=c*f;t[0]=h*p,t[4]=E-m*g,t[8]=v*g+x,t[1]=g,t[5]=l*p,t[9]=-c*p,t[2]=-f*p,t[6]=x*g+v,t[10]=m-E*g}else if(e.order==="XZY"){const m=l*h,x=l*f,v=c*h,E=c*f;t[0]=h*p,t[4]=-g,t[8]=f*p,t[1]=m*g+E,t[5]=l*p,t[9]=x*g-v,t[2]=v*g-x,t[6]=c*p,t[10]=E*g+m}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(Fw,e,Ow)}lookAt(e,t,n){const i=this.elements;return Ai.subVectors(e,t),Ai.lengthSq()===0&&(Ai.z=1),Ai.normalize(),dr.crossVectors(n,Ai),dr.lengthSq()===0&&(Math.abs(n.z)===1?Ai.x+=1e-4:Ai.z+=1e-4,Ai.normalize(),dr.crossVectors(n,Ai)),dr.normalize(),yu.crossVectors(Ai,dr),i[0]=dr.x,i[4]=yu.x,i[8]=Ai.x,i[1]=dr.y,i[5]=yu.y,i[9]=Ai.y,i[2]=dr.z,i[6]=yu.z,i[10]=Ai.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,o=this.elements,l=n[0],c=n[4],h=n[8],f=n[12],p=n[1],g=n[5],m=n[9],x=n[13],v=n[2],E=n[6],b=n[10],_=n[14],M=n[3],w=n[7],T=n[11],P=n[15],R=i[0],U=i[4],A=i[8],I=i[12],B=i[1],F=i[5],j=i[9],H=i[13],Z=i[2],W=i[6],$=i[10],Y=i[14],ge=i[3],he=i[7],Ee=i[11],xe=i[15];return o[0]=l*R+c*B+h*Z+f*ge,o[4]=l*U+c*F+h*W+f*he,o[8]=l*A+c*j+h*$+f*Ee,o[12]=l*I+c*H+h*Y+f*xe,o[1]=p*R+g*B+m*Z+x*ge,o[5]=p*U+g*F+m*W+x*he,o[9]=p*A+g*j+m*$+x*Ee,o[13]=p*I+g*H+m*Y+x*xe,o[2]=v*R+E*B+b*Z+_*ge,o[6]=v*U+E*F+b*W+_*he,o[10]=v*A+E*j+b*$+_*Ee,o[14]=v*I+E*H+b*Y+_*xe,o[3]=M*R+w*B+T*Z+P*ge,o[7]=M*U+w*F+T*W+P*he,o[11]=M*A+w*j+T*$+P*Ee,o[15]=M*I+w*H+T*Y+P*xe,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],o=e[12],l=e[1],c=e[5],h=e[9],f=e[13],p=e[2],g=e[6],m=e[10],x=e[14],v=e[3],E=e[7],b=e[11],_=e[15],M=h*x-f*m,w=c*x-f*g,T=c*m-h*g,P=l*x-f*p,R=l*m-h*p,U=l*g-c*p;return t*(E*M-b*w+_*T)-n*(v*M-b*P+_*R)+i*(v*w-E*P+_*U)-o*(v*T-E*R+b*U)}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],o=e[3],l=e[4],c=e[5],h=e[6],f=e[7],p=e[8],g=e[9],m=e[10],x=e[11],v=e[12],E=e[13],b=e[14],_=e[15],M=t*c-n*l,w=t*h-i*l,T=t*f-o*l,P=n*h-i*c,R=n*f-o*c,U=i*f-o*h,A=p*E-g*v,I=p*b-m*v,B=p*_-x*v,F=g*b-m*E,j=g*_-x*E,H=m*_-x*b,Z=M*H-w*j+T*F+P*B-R*I+U*A;if(Z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const W=1/Z;return e[0]=(c*H-h*j+f*F)*W,e[1]=(i*j-n*H-o*F)*W,e[2]=(E*U-b*R+_*P)*W,e[3]=(m*R-g*U-x*P)*W,e[4]=(h*B-l*H-f*I)*W,e[5]=(t*H-i*B+o*I)*W,e[6]=(b*T-v*U-_*w)*W,e[7]=(p*U-m*T+x*w)*W,e[8]=(l*j-c*B+f*A)*W,e[9]=(n*B-t*j-o*A)*W,e[10]=(v*R-E*T+_*M)*W,e[11]=(g*T-p*R-x*M)*W,e[12]=(c*I-l*F-h*A)*W,e[13]=(t*F-n*I+i*A)*W,e[14]=(E*w-v*P-b*M)*W,e[15]=(p*P-g*w+m*M)*W,this}scale(e){const t=this.elements,n=e.x,i=e.y,o=e.z;return t[0]*=n,t[4]*=i,t[8]*=o,t[1]*=n,t[5]*=i,t[9]*=o,t[2]*=n,t[6]*=i,t[10]*=o,t[3]*=n,t[7]*=i,t[11]*=o,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),o=1-n,l=e.x,c=e.y,h=e.z,f=o*l,p=o*c;return this.set(f*l+n,f*c-i*h,f*h+i*c,0,f*c+i*h,p*c+n,p*h-i*l,0,f*h-i*c,p*h+i*l,o*h*h+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,o,l){return this.set(1,n,o,0,e,1,l,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,o=t._x,l=t._y,c=t._z,h=t._w,f=o+o,p=l+l,g=c+c,m=o*f,x=o*p,v=o*g,E=l*p,b=l*g,_=c*g,M=h*f,w=h*p,T=h*g,P=n.x,R=n.y,U=n.z;return i[0]=(1-(E+_))*P,i[1]=(x+T)*P,i[2]=(v-w)*P,i[3]=0,i[4]=(x-T)*R,i[5]=(1-(m+_))*R,i[6]=(b+M)*R,i[7]=0,i[8]=(v+w)*U,i[9]=(b-M)*U,i[10]=(1-(m+E))*U,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;e.x=i[12],e.y=i[13],e.z=i[14];const o=this.determinant();if(o===0)return n.set(1,1,1),t.identity(),this;let l=co.set(i[0],i[1],i[2]).length();const c=co.set(i[4],i[5],i[6]).length(),h=co.set(i[8],i[9],i[10]).length();o<0&&(l=-l),es.copy(this);const f=1/l,p=1/c,g=1/h;return es.elements[0]*=f,es.elements[1]*=f,es.elements[2]*=f,es.elements[4]*=p,es.elements[5]*=p,es.elements[6]*=p,es.elements[8]*=g,es.elements[9]*=g,es.elements[10]*=g,t.setFromRotationMatrix(es),n.x=l,n.y=c,n.z=h,this}makePerspective(e,t,n,i,o,l,c=Ri,h=!1){const f=this.elements,p=2*o/(t-e),g=2*o/(n-i),m=(t+e)/(t-e),x=(n+i)/(n-i);let v,E;if(h)v=o/(l-o),E=l*o/(l-o);else if(c===Ri)v=-(l+o)/(l-o),E=-2*l*o/(l-o);else if(c===Ca)v=-l/(l-o),E=-l*o/(l-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+c);return f[0]=p,f[4]=0,f[8]=m,f[12]=0,f[1]=0,f[5]=g,f[9]=x,f[13]=0,f[2]=0,f[6]=0,f[10]=v,f[14]=E,f[3]=0,f[7]=0,f[11]=-1,f[15]=0,this}makeOrthographic(e,t,n,i,o,l,c=Ri,h=!1){const f=this.elements,p=2/(t-e),g=2/(n-i),m=-(t+e)/(t-e),x=-(n+i)/(n-i);let v,E;if(h)v=1/(l-o),E=l/(l-o);else if(c===Ri)v=-2/(l-o),E=-(l+o)/(l-o);else if(c===Ca)v=-1/(l-o),E=-o/(l-o);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+c);return f[0]=p,f[4]=0,f[8]=0,f[12]=m,f[1]=0,f[5]=g,f[9]=0,f[13]=x,f[2]=0,f[6]=0,f[10]=v,f[14]=E,f[3]=0,f[7]=0,f[11]=0,f[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 co=new O,es=new gt,Fw=new O(0,0,0),Ow=new O(1,1,1),dr=new O,yu=new O,Ai=new O,yv=new gt,bv=new zn;class Li{constructor(e=0,t=0,n=0,i=Li.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,o=i[0],l=i[4],c=i[8],h=i[1],f=i[5],p=i[9],g=i[2],m=i[6],x=i[10];switch(t){case"XYZ":this._y=Math.asin(pt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-p,x),this._z=Math.atan2(-l,o)):(this._x=Math.atan2(m,f),this._z=0);break;case"YXZ":this._x=Math.asin(-pt(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(c,x),this._z=Math.atan2(h,f)):(this._y=Math.atan2(-g,o),this._z=0);break;case"ZXY":this._x=Math.asin(pt(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-g,x),this._z=Math.atan2(-l,f)):(this._y=0,this._z=Math.atan2(h,o));break;case"ZYX":this._y=Math.asin(-pt(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(m,x),this._z=Math.atan2(h,o)):(this._x=0,this._z=Math.atan2(-l,f));break;case"YZX":this._z=Math.asin(pt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-p,f),this._y=Math.atan2(-g,o)):(this._x=0,this._y=Math.atan2(c,x));break;case"XZY":this._z=Math.asin(-pt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(m,f),this._y=Math.atan2(c,o)):(this._x=Math.atan2(-p,x),this._y=0);break;default:He("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return yv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(yv,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return bv.setFromEuler(this),this.setFromQuaternion(bv,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}}Li.DEFAULT_ORDER="XYZ";class Vo{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 zw=0;const Sv=new O,uo=new zn,Fs=new gt,bu=new O,wl=new O,Bw=new O,kw=new zn,Mv=new O(1,0,0),Ev=new O(0,1,0),wv=new O(0,0,1),Tv={type:"added"},Vw={type:"removed"},ho={type:"childadded",child:null},Ep={type:"childremoved",child:null};class Ot extends Ss{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:zw++}),this.uuid=Ii(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ot.DEFAULT_UP.clone();const e=new O,t=new Li,n=new zn,i=new O(1,1,1);function o(){n.setFromEuler(t,!1)}function l(){t.setFromQuaternion(n,void 0,!1)}t._onChange(o),n._onChange(l),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 gt},normalMatrix:{value:new St}}),this.matrix=new gt,this.matrixWorld=new gt,this.matrixAutoUpdate=Ot.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ot.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Vo,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return uo.setFromAxisAngle(e,t),this.quaternion.multiply(uo),this}rotateOnWorldAxis(e,t){return uo.setFromAxisAngle(e,t),this.quaternion.premultiply(uo),this}rotateX(e){return this.rotateOnAxis(Mv,e)}rotateY(e){return this.rotateOnAxis(Ev,e)}rotateZ(e){return this.rotateOnAxis(wv,e)}translateOnAxis(e,t){return Sv.copy(e).applyQuaternion(this.quaternion),this.position.add(Sv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Mv,e)}translateY(e){return this.translateOnAxis(Ev,e)}translateZ(e){return this.translateOnAxis(wv,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Fs.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?bu.copy(e):bu.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),wl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Fs.lookAt(wl,bu,this.up):Fs.lookAt(bu,wl,this.up),this.quaternion.setFromRotationMatrix(Fs),i&&(Fs.extractRotation(i.matrixWorld),uo.setFromRotationMatrix(Fs),this.quaternion.premultiply(uo.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ot("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Tv),ho.child=e,this.dispatchEvent(ho),ho.child=null):ot("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(Vw),Ep.child=e,this.dispatchEvent(Ep),Ep.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Fs.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Fs.multiply(e.parent.matrixWorld)),e.applyMatrix4(Fs),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Tv),ho.child=e,this.dispatchEvent(ho),ho.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const l=this.children[n].getObjectByProperty(e,t);if(l!==void 0)return l}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let o=0,l=i.length;o<l;o++)i[o].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wl,e,Bw),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wl,kw,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);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,i=e.z,o=this.matrix.elements;o[12]+=t-o[0]*t-o[4]*n-o[8]*i,o[13]+=n-o[1]*t-o[5]*n-o[9]*i,o[14]+=i-o[2]*t-o[6]*n-o[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(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++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let o=0,l=i.length;o<l;o++)i[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.7,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),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(c=>({...c,boundingBox:c.boundingBox?c.boundingBox.toJSON():void 0,boundingSphere:c.boundingSphere?c.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(c=>({...c})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function o(c,h){return c[h.uuid]===void 0&&(c[h.uuid]=h.toJSON(e)),h.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=o(e.geometries,this.geometry);const c=this.geometry.parameters;if(c!==void 0&&c.shapes!==void 0){const h=c.shapes;if(Array.isArray(h))for(let f=0,p=h.length;f<p;f++){const g=h[f];o(e.shapes,g)}else o(e.shapes,h)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(o(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const c=[];for(let h=0,f=this.material.length;h<f;h++)c.push(o(e.materials,this.material[h]));i.material=c}else i.material=o(e.materials,this.material);if(this.children.length>0){i.children=[];for(let c=0;c<this.children.length;c++)i.children.push(this.children[c].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let c=0;c<this.animations.length;c++){const h=this.animations[c];i.animations.push(o(e.animations,h))}}if(t){const c=l(e.geometries),h=l(e.materials),f=l(e.textures),p=l(e.images),g=l(e.shapes),m=l(e.skeletons),x=l(e.animations),v=l(e.nodes);c.length>0&&(n.geometries=c),h.length>0&&(n.materials=h),f.length>0&&(n.textures=f),p.length>0&&(n.images=p),g.length>0&&(n.shapes=g),m.length>0&&(n.skeletons=m),x.length>0&&(n.animations=x),v.length>0&&(n.nodes=v)}return n.object=i,n;function l(c){const h=[];for(const f in c){const p=c[f];delete p.metadata,h.push(p)}return h}}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),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}Ot.DEFAULT_UP=new O(0,1,0);Ot.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ot.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Uo extends Ot{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Hw={type:"move"};class gh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Uo,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 Uo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Uo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O),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,o=null,l=null;const c=this._targetRay,h=this._grip,f=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(f&&e.hand){l=!0;for(const E of e.hand.values()){const b=t.getJointPose(E,n),_=this._getHandJoint(f,E);b!==null&&(_.matrix.fromArray(b.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,_.jointRadius=b.radius),_.visible=b!==null}const p=f.joints["index-finger-tip"],g=f.joints["thumb-tip"],m=p.position.distanceTo(g.position),x=.02,v=.005;f.inputState.pinching&&m>x+v?(f.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!f.inputState.pinching&&m<=x-v&&(f.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else h!==null&&e.gripSpace&&(o=t.getPose(e.gripSpace,n),o!==null&&(h.matrix.fromArray(o.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,o.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(o.linearVelocity)):h.hasLinearVelocity=!1,o.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(o.angularVelocity)):h.hasAngularVelocity=!1));c!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&o!==null&&(i=o),i!==null&&(c.matrix.fromArray(i.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,i.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(i.linearVelocity)):c.hasLinearVelocity=!1,i.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(i.angularVelocity)):c.hasAngularVelocity=!1,this.dispatchEvent(Hw)))}return c!==null&&(c.visible=i!==null),h!==null&&(h.visible=o!==null),f!==null&&(f.visible=l!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Uo;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const tb={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},pr={h:0,s:0,l:0},Su={h:0,s:0,l:0};function wp(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class Ye{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=qn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Dt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=Dt.workingColorSpace){return this.r=e,this.g=t,this.b=n,Dt.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=Dt.workingColorSpace){if(e=cg(e,1),t=pt(t,0,1),n=pt(n,0,1),t===0)this.r=this.g=this.b=n;else{const o=n<=.5?n*(1+t):n+t-n*t,l=2*n-o;this.r=wp(l,o,e+1/3),this.g=wp(l,o,e),this.b=wp(l,o,e-1/3)}return Dt.colorSpaceToWorking(this,i),this}setStyle(e,t=qn){function n(o){o!==void 0&&parseFloat(o)<1&&He("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let o;const l=i[1],c=i[2];switch(l){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setRGB(Math.min(255,parseInt(o[1],10))/255,Math.min(255,parseInt(o[2],10))/255,Math.min(255,parseInt(o[3],10))/255,t);if(o=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setRGB(Math.min(100,parseInt(o[1],10))/100,Math.min(100,parseInt(o[2],10))/100,Math.min(100,parseInt(o[3],10))/100,t);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setHSL(parseFloat(o[1])/360,parseFloat(o[2])/100,parseFloat(o[3])/100,t);break;default:He("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const o=i[1],l=o.length;if(l===3)return this.setRGB(parseInt(o.charAt(0),16)/15,parseInt(o.charAt(1),16)/15,parseInt(o.charAt(2),16)/15,t);if(l===6)return this.setHex(parseInt(o,16),t);He("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=qn){const n=tb[e.toLowerCase()];return n!==void 0?this.setHex(n,t):He("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=js(e.r),this.g=js(e.g),this.b=js(e.b),this}copyLinearToSRGB(e){return this.r=Oo(e.r),this.g=Oo(e.g),this.b=Oo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=qn){return Dt.workingToColorSpace(Xn.copy(this),e),Math.round(pt(Xn.r*255,0,255))*65536+Math.round(pt(Xn.g*255,0,255))*256+Math.round(pt(Xn.b*255,0,255))}getHexString(e=qn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Dt.workingColorSpace){Dt.workingToColorSpace(Xn.copy(this),t);const n=Xn.r,i=Xn.g,o=Xn.b,l=Math.max(n,i,o),c=Math.min(n,i,o);let h,f;const p=(c+l)/2;if(c===l)h=0,f=0;else{const g=l-c;switch(f=p<=.5?g/(l+c):g/(2-l-c),l){case n:h=(i-o)/g+(i<o?6:0);break;case i:h=(o-n)/g+2;break;case o:h=(n-i)/g+4;break}h/=6}return e.h=h,e.s=f,e.l=p,e}getRGB(e,t=Dt.workingColorSpace){return Dt.workingToColorSpace(Xn.copy(this),t),e.r=Xn.r,e.g=Xn.g,e.b=Xn.b,e}getStyle(e=qn){Dt.workingToColorSpace(Xn.copy(this),e);const t=Xn.r,n=Xn.g,i=Xn.b;return e!==qn?`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(pr),this.setHSL(pr.h+e,pr.s+t,pr.l+n)}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(pr),e.getHSL(Su);const n=Kl(pr.h,Su.h,t),i=Kl(pr.s,Su.s,t),o=Kl(pr.l,Su.l,t);return this.setHSL(n,i,o),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,o=e.elements;return this.r=o[0]*t+o[3]*n+o[6]*i,this.g=o[1]*t+o[4]*n+o[7]*i,this.b=o[2]*t+o[5]*n+o[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 Xn=new Ye;Ye.NAMES=tb;class Lf{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ye(e),this.density=t}clone(){return new Lf(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Nf{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 Nf(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class hg extends Ot{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Li,this.environmentIntensity=1,this.environmentRotation=new Li,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const ts=new O,Os=new O,Tp=new O,zs=new O,fo=new O,po=new O,Av=new O,Ap=new O,Cp=new O,Rp=new O,Ip=new Zt,Pp=new Zt,Lp=new Zt;class mi{constructor(e=new O,t=new O,n=new O){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),ts.subVectors(e,t),i.cross(ts);const o=i.lengthSq();return o>0?i.multiplyScalar(1/Math.sqrt(o)):i.set(0,0,0)}static getBarycoord(e,t,n,i,o){ts.subVectors(i,t),Os.subVectors(n,t),Tp.subVectors(e,t);const l=ts.dot(ts),c=ts.dot(Os),h=ts.dot(Tp),f=Os.dot(Os),p=Os.dot(Tp),g=l*f-c*c;if(g===0)return o.set(0,0,0),null;const m=1/g,x=(f*h-c*p)*m,v=(l*p-c*h)*m;return o.set(1-x-v,v,x)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,zs)===null?!1:zs.x>=0&&zs.y>=0&&zs.x+zs.y<=1}static getInterpolation(e,t,n,i,o,l,c,h){return this.getBarycoord(e,t,n,i,zs)===null?(h.x=0,h.y=0,"z"in h&&(h.z=0),"w"in h&&(h.w=0),null):(h.setScalar(0),h.addScaledVector(o,zs.x),h.addScaledVector(l,zs.y),h.addScaledVector(c,zs.z),h)}static getInterpolatedAttribute(e,t,n,i,o,l){return Ip.setScalar(0),Pp.setScalar(0),Lp.setScalar(0),Ip.fromBufferAttribute(e,t),Pp.fromBufferAttribute(e,n),Lp.fromBufferAttribute(e,i),l.setScalar(0),l.addScaledVector(Ip,o.x),l.addScaledVector(Pp,o.y),l.addScaledVector(Lp,o.z),l}static isFrontFacing(e,t,n,i){return ts.subVectors(n,t),Os.subVectors(e,t),ts.cross(Os).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 ts.subVectors(this.c,this.b),Os.subVectors(this.a,this.b),ts.cross(Os).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return mi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return mi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,o){return mi.getInterpolation(e,this.a,this.b,this.c,t,n,i,o)}containsPoint(e){return mi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return mi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,o=this.c;let l,c;fo.subVectors(i,n),po.subVectors(o,n),Ap.subVectors(e,n);const h=fo.dot(Ap),f=po.dot(Ap);if(h<=0&&f<=0)return t.copy(n);Cp.subVectors(e,i);const p=fo.dot(Cp),g=po.dot(Cp);if(p>=0&&g<=p)return t.copy(i);const m=h*g-p*f;if(m<=0&&h>=0&&p<=0)return l=h/(h-p),t.copy(n).addScaledVector(fo,l);Rp.subVectors(e,o);const x=fo.dot(Rp),v=po.dot(Rp);if(v>=0&&x<=v)return t.copy(o);const E=x*f-h*v;if(E<=0&&f>=0&&v<=0)return c=f/(f-v),t.copy(n).addScaledVector(po,c);const b=p*v-x*g;if(b<=0&&g-p>=0&&x-v>=0)return Av.subVectors(o,i),c=(g-p)/(g-p+(x-v)),t.copy(i).addScaledVector(Av,c);const _=1/(b+E+m);return l=E*_,c=m*_,t.copy(n).addScaledVector(fo,l).addScaledVector(po,c)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class $n{constructor(e=new O(1/0,1/0,1/0),t=new O(-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(ns.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(ns.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=ns.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){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const o=n.getAttribute("position");if(t===!0&&o!==void 0&&e.isInstancedMesh!==!0)for(let l=0,c=o.count;l<c;l++)e.isMesh===!0?e.getVertexPosition(l,ns):ns.fromBufferAttribute(o,l),ns.applyMatrix4(e.matrixWorld),this.expandByPoint(ns);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Mu.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Mu.copy(n.boundingBox)),Mu.applyMatrix4(e.matrixWorld),this.union(Mu)}const i=e.children;for(let o=0,l=i.length;o<l;o++)this.expandByObject(i[o],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,ns),ns.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(Tl),Eu.subVectors(this.max,Tl),mo.subVectors(e.a,Tl),go.subVectors(e.b,Tl),xo.subVectors(e.c,Tl),mr.subVectors(go,mo),gr.subVectors(xo,go),ea.subVectors(mo,xo);let t=[0,-mr.z,mr.y,0,-gr.z,gr.y,0,-ea.z,ea.y,mr.z,0,-mr.x,gr.z,0,-gr.x,ea.z,0,-ea.x,-mr.y,mr.x,0,-gr.y,gr.x,0,-ea.y,ea.x,0];return!Np(t,mo,go,xo,Eu)||(t=[1,0,0,0,1,0,0,0,1],!Np(t,mo,go,xo,Eu))?!1:(wu.crossVectors(mr,gr),t=[wu.x,wu.y,wu.z],Np(t,mo,go,xo,Eu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ns).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ns).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:(Bs[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Bs[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Bs[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Bs[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Bs[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Bs[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Bs[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Bs[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Bs),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Bs=[new O,new O,new O,new O,new O,new O,new O,new O],ns=new O,Mu=new $n,mo=new O,go=new O,xo=new O,mr=new O,gr=new O,ea=new O,Tl=new O,Eu=new O,wu=new O,ta=new O;function Np(s,e,t,n,i){for(let o=0,l=s.length-3;o<=l;o+=3){ta.fromArray(s,o);const c=i.x*Math.abs(ta.x)+i.y*Math.abs(ta.y)+i.z*Math.abs(ta.z),h=e.dot(ta),f=t.dot(ta),p=n.dot(ta);if(Math.max(-Math.max(h,f,p),Math.min(h,f,p))>c)return!1}return!0}const Xs=Gw();function Gw(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let h=0;h<256;++h){const f=h-127;f<-27?(n[h]=0,n[h|256]=32768,i[h]=24,i[h|256]=24):f<-14?(n[h]=1024>>-f-14,n[h|256]=1024>>-f-14|32768,i[h]=-f-1,i[h|256]=-f-1):f<=15?(n[h]=f+15<<10,n[h|256]=f+15<<10|32768,i[h]=13,i[h|256]=13):f<128?(n[h]=31744,n[h|256]=64512,i[h]=24,i[h|256]=24):(n[h]=31744,n[h|256]=64512,i[h]=13,i[h|256]=13)}const o=new Uint32Array(2048),l=new Uint32Array(64),c=new Uint32Array(64);for(let h=1;h<1024;++h){let f=h<<13,p=0;for(;(f&8388608)===0;)f<<=1,p-=8388608;f&=-8388609,p+=947912704,o[h]=f|p}for(let h=1024;h<2048;++h)o[h]=939524096+(h-1024<<13);for(let h=1;h<31;++h)l[h]=h<<23;l[31]=1199570944,l[32]=2147483648;for(let h=33;h<63;++h)l[h]=2147483648+(h-32<<23);l[63]=3347054592;for(let h=1;h<64;++h)h!==32&&(c[h]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:o,exponentTable:l,offsetTable:c}}function fi(s){Math.abs(s)>65504&&He("DataUtils.toHalfFloat(): Value out of range."),s=pt(s,-65504,65504),Xs.floatView[0]=s;const e=Xs.uint32View[0],t=e>>23&511;return Xs.baseTable[t]+((e&8388607)>>Xs.shiftTable[t])}function kl(s){const e=s>>10;return Xs.uint32View[0]=Xs.mantissaTable[Xs.offsetTable[e]+(s&1023)]+Xs.exponentTable[e],Xs.floatView[0]}class Ww{static toHalfFloat(e){return fi(e)}static fromHalfFloat(e){return kl(e)}}const bn=new O,Tu=new pe;let Xw=0;class Yt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Xw++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=oc,this.updateRanges=[],this.gpuType=ii,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,o=this.itemSize;i<o;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++)Tu.fromBufferAttribute(this,t),Tu.applyMatrix3(e),this.setXY(t,Tu.x,Tu.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.applyMatrix3(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.applyMatrix4(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.applyNormalMatrix(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)bn.fromBufferAttribute(this,t),bn.transformDirection(e),this.setXYZ(t,bn.x,bn.y,bn.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=ni(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=wt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ni(t,this.array)),t}setX(e,t){return this.normalized&&(t=wt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ni(t,this.array)),t}setY(e,t){return this.normalized&&(t=wt(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=ni(t,this.array)),t}setZ(e,t){return this.normalized&&(t=wt(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=ni(t,this.array)),t}setW(e,t){return this.normalized&&(t=wt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=wt(t,this.array),n=wt(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=wt(t,this.array),n=wt(n,this.array),i=wt(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,o){return e*=this.itemSize,this.normalized&&(t=wt(t,this.array),n=wt(n,this.array),i=wt(i,this.array),o=wt(o,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=o,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!==oc&&(e.usage=this.usage),e}}class jw extends Yt{constructor(e,t,n){super(new Int8Array(e),t,n)}}class qw extends Yt{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class Yw extends Yt{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class $w extends Yt{constructor(e,t,n){super(new Int16Array(e),t,n)}}class fg extends Yt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Zw extends Yt{constructor(e,t,n){super(new Int32Array(e),t,n)}}class dg extends Yt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Kw extends Yt{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=kl(this.array[e*this.itemSize]);return this.normalized&&(t=ni(t,this.array)),t}setX(e,t){return this.normalized&&(t=wt(t,this.array)),this.array[e*this.itemSize]=fi(t),this}getY(e){let t=kl(this.array[e*this.itemSize+1]);return this.normalized&&(t=ni(t,this.array)),t}setY(e,t){return this.normalized&&(t=wt(t,this.array)),this.array[e*this.itemSize+1]=fi(t),this}getZ(e){let t=kl(this.array[e*this.itemSize+2]);return this.normalized&&(t=ni(t,this.array)),t}setZ(e,t){return this.normalized&&(t=wt(t,this.array)),this.array[e*this.itemSize+2]=fi(t),this}getW(e){let t=kl(this.array[e*this.itemSize+3]);return this.normalized&&(t=ni(t,this.array)),t}setW(e,t){return this.normalized&&(t=wt(t,this.array)),this.array[e*this.itemSize+3]=fi(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=wt(t,this.array),n=wt(n,this.array)),this.array[e+0]=fi(t),this.array[e+1]=fi(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=wt(t,this.array),n=wt(n,this.array),i=wt(i,this.array)),this.array[e+0]=fi(t),this.array[e+1]=fi(n),this.array[e+2]=fi(i),this}setXYZW(e,t,n,i,o){return e*=this.itemSize,this.normalized&&(t=wt(t,this.array),n=wt(n,this.array),i=wt(i,this.array),o=wt(o,this.array)),this.array[e+0]=fi(t),this.array[e+1]=fi(n),this.array[e+2]=fi(i),this.array[e+3]=fi(o),this}}class et extends Yt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Jw=new $n,Al=new O,Dp=new O;let Bn=class{constructor(e=new O,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Jw.setFromPoints(e).getCenter(n);let i=0;for(let o=0,l=e.length;o<l;o++)i=Math.max(i,n.distanceToSquared(e[o]));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;Al.subVectors(e,this.center);const t=Al.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Al,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):(Dp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Al.copy(e.center).add(Dp)),this.expandByPoint(Al.copy(e.center).sub(Dp))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Qw=0;const zi=new gt,Up=new Ot,vo=new O,Ci=new $n,Cl=new $n,Nn=new O;class _t extends Ss{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Qw++}),this.uuid=Ii(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(lw(e)?dg:fg)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return 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 o=new St().getNormalMatrix(e);n.applyNormalMatrix(o),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 zi.makeRotationFromQuaternion(e),this.applyMatrix4(zi),this}rotateX(e){return zi.makeRotationX(e),this.applyMatrix4(zi),this}rotateY(e){return zi.makeRotationY(e),this.applyMatrix4(zi),this}rotateZ(e){return zi.makeRotationZ(e),this.applyMatrix4(zi),this}translate(e,t,n){return zi.makeTranslation(e,t,n),this.applyMatrix4(zi),this}scale(e,t,n){return zi.makeScale(e,t,n),this.applyMatrix4(zi),this}lookAt(e){return Up.lookAt(e),Up.updateMatrix(),this.applyMatrix4(Up.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vo).negate(),this.translate(vo.x,vo.y,vo.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,o=e.length;i<o;i++){const l=e[i];n.push(l.x,l.y,l.z||0)}this.setAttribute("position",new et(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const o=e[i];t.setXYZ(i,o.x,o.y,o.z||0)}e.length>t.count&&He("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new $n);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ot("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new O(-1/0,-1/0,-1/0),new O(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 o=t[n];Ci.setFromBufferAttribute(o),this.morphTargetsRelative?(Nn.addVectors(this.boundingBox.min,Ci.min),this.boundingBox.expandByPoint(Nn),Nn.addVectors(this.boundingBox.max,Ci.max),this.boundingBox.expandByPoint(Nn)):(this.boundingBox.expandByPoint(Ci.min),this.boundingBox.expandByPoint(Ci.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ot('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 Bn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ot("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new O,1/0);return}if(e){const n=this.boundingSphere.center;if(Ci.setFromBufferAttribute(e),t)for(let o=0,l=t.length;o<l;o++){const c=t[o];Cl.setFromBufferAttribute(c),this.morphTargetsRelative?(Nn.addVectors(Ci.min,Cl.min),Ci.expandByPoint(Nn),Nn.addVectors(Ci.max,Cl.max),Ci.expandByPoint(Nn)):(Ci.expandByPoint(Cl.min),Ci.expandByPoint(Cl.max))}Ci.getCenter(n);let i=0;for(let o=0,l=e.count;o<l;o++)Nn.fromBufferAttribute(e,o),i=Math.max(i,n.distanceToSquared(Nn));if(t)for(let o=0,l=t.length;o<l;o++){const c=t[o],h=this.morphTargetsRelative;for(let f=0,p=c.count;f<p;f++)Nn.fromBufferAttribute(c,f),h&&(vo.fromBufferAttribute(e,f),Nn.add(vo)),i=Math.max(i,n.distanceToSquared(Nn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ot('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){ot("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,o=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Yt(new Float32Array(4*n.count),4));const l=this.getAttribute("tangent"),c=[],h=[];for(let A=0;A<n.count;A++)c[A]=new O,h[A]=new O;const f=new O,p=new O,g=new O,m=new pe,x=new pe,v=new pe,E=new O,b=new O;function _(A,I,B){f.fromBufferAttribute(n,A),p.fromBufferAttribute(n,I),g.fromBufferAttribute(n,B),m.fromBufferAttribute(o,A),x.fromBufferAttribute(o,I),v.fromBufferAttribute(o,B),p.sub(f),g.sub(f),x.sub(m),v.sub(m);const F=1/(x.x*v.y-v.x*x.y);isFinite(F)&&(E.copy(p).multiplyScalar(v.y).addScaledVector(g,-x.y).multiplyScalar(F),b.copy(g).multiplyScalar(x.x).addScaledVector(p,-v.x).multiplyScalar(F),c[A].add(E),c[I].add(E),c[B].add(E),h[A].add(b),h[I].add(b),h[B].add(b))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let A=0,I=M.length;A<I;++A){const B=M[A],F=B.start,j=B.count;for(let H=F,Z=F+j;H<Z;H+=3)_(e.getX(H+0),e.getX(H+1),e.getX(H+2))}const w=new O,T=new O,P=new O,R=new O;function U(A){P.fromBufferAttribute(i,A),R.copy(P);const I=c[A];w.copy(I),w.sub(P.multiplyScalar(P.dot(I))).normalize(),T.crossVectors(R,I);const F=T.dot(h[A])<0?-1:1;l.setXYZW(A,w.x,w.y,w.z,F)}for(let A=0,I=M.length;A<I;++A){const B=M[A],F=B.start,j=B.count;for(let H=F,Z=F+j;H<Z;H+=3)U(e.getX(H+0)),U(e.getX(H+1)),U(e.getX(H+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 Yt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let m=0,x=n.count;m<x;m++)n.setXYZ(m,0,0,0);const i=new O,o=new O,l=new O,c=new O,h=new O,f=new O,p=new O,g=new O;if(e)for(let m=0,x=e.count;m<x;m+=3){const v=e.getX(m+0),E=e.getX(m+1),b=e.getX(m+2);i.fromBufferAttribute(t,v),o.fromBufferAttribute(t,E),l.fromBufferAttribute(t,b),p.subVectors(l,o),g.subVectors(i,o),p.cross(g),c.fromBufferAttribute(n,v),h.fromBufferAttribute(n,E),f.fromBufferAttribute(n,b),c.add(p),h.add(p),f.add(p),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(E,h.x,h.y,h.z),n.setXYZ(b,f.x,f.y,f.z)}else for(let m=0,x=t.count;m<x;m+=3)i.fromBufferAttribute(t,m+0),o.fromBufferAttribute(t,m+1),l.fromBufferAttribute(t,m+2),p.subVectors(l,o),g.subVectors(i,o),p.cross(g),n.setXYZ(m+0,p.x,p.y,p.z),n.setXYZ(m+1,p.x,p.y,p.z),n.setXYZ(m+2,p.x,p.y,p.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Nn.fromBufferAttribute(e,t),Nn.normalize(),e.setXYZ(t,Nn.x,Nn.y,Nn.z)}toNonIndexed(){function e(c,h){const f=c.array,p=c.itemSize,g=c.normalized,m=new f.constructor(h.length*p);let x=0,v=0;for(let E=0,b=h.length;E<b;E++){c.isInterleavedBufferAttribute?x=h[E]*c.data.stride+c.offset:x=h[E]*p;for(let _=0;_<p;_++)m[v++]=f[x++]}return new Yt(m,p,g)}if(this.index===null)return He("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new _t,n=this.index.array,i=this.attributes;for(const c in i){const h=i[c],f=e(h,n);t.setAttribute(c,f)}const o=this.morphAttributes;for(const c in o){const h=[],f=o[c];for(let p=0,g=f.length;p<g;p++){const m=f[p],x=e(m,n);h.push(x)}t.morphAttributes[c]=h}t.morphTargetsRelative=this.morphTargetsRelative;const l=this.groups;for(let c=0,h=l.length;c<h;c++){const f=l[c];t.addGroup(f.start,f.count,f.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,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 h=this.parameters;for(const f in h)h[f]!==void 0&&(e[f]=h[f]);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 h in n){const f=n[h];e.data.attributes[h]=f.toJSON(e.data)}const i={};let o=!1;for(const h in this.morphAttributes){const f=this.morphAttributes[h],p=[];for(let g=0,m=f.length;g<m;g++){const x=f[g];p.push(x.toJSON(e.data))}p.length>0&&(i[h]=p,o=!0)}o&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const l=this.groups;l.length>0&&(e.data.groups=JSON.parse(JSON.stringify(l)));const c=this.boundingSphere;return c!==null&&(e.data.boundingSphere=c.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const f in i){const p=i[f];this.setAttribute(f,p.clone(t))}const o=e.morphAttributes;for(const f in o){const p=[],g=o[f];for(let m=0,x=g.length;m<x;m++)p.push(g[m].clone(t));this.morphAttributes[f]=p}this.morphTargetsRelative=e.morphTargetsRelative;const l=e.groups;for(let f=0,p=l.length;f<p;f++){const g=l[f];this.addGroup(g.start,g.count,g.materialIndex)}const c=e.boundingBox;c!==null&&(this.boundingBox=c.clone());const h=e.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Df{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=oc,this.updateRanges=[],this.version=0,this.uuid=Ii()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,o=this.stride;i<o;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=Ii()),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=Ii()),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 Qn=new O;class Ra{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++)Qn.fromBufferAttribute(this,t),Qn.applyMatrix4(e),this.setXYZ(t,Qn.x,Qn.y,Qn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Qn.fromBufferAttribute(this,t),Qn.applyNormalMatrix(e),this.setXYZ(t,Qn.x,Qn.y,Qn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Qn.fromBufferAttribute(this,t),Qn.transformDirection(e),this.setXYZ(t,Qn.x,Qn.y,Qn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=ni(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=wt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=wt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=wt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=wt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=wt(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=ni(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ni(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ni(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ni(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=wt(t,this.array),n=wt(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=wt(t,this.array),n=wt(n,this.array),i=wt(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,o){return e=e*this.data.stride+this.offset,this.normalized&&(t=wt(t,this.array),n=wt(n,this.array),i=wt(i,this.array),o=wt(o,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]=o,this}clone(e){if(e===void 0){cc("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 o=0;o<this.itemSize;o++)t.push(this.data.array[i+o])}return new Yt(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 Ra(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){cc("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 o=0;o<this.itemSize;o++)t.push(this.data.array[i+o])}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}}}let eT=0;class Zn extends Ss{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:eT++}),this.uuid=Ii(),this.name="",this.type="Material",this.blending=Ma,this.side=qs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=bh,this.blendDst=Sh,this.blendEquation=Sr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ye(0,0,0),this.blendAlpha=0,this.depthFunc=Ta,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Rm,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=xa,this.stencilZFail=xa,this.stencilZPass=xa,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){He(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){He(`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.7,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!==void 0&&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.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),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.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),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!==Ma&&(n.blending=this.blending),this.side!==qs&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==bh&&(n.blendSrc=this.blendSrc),this.blendDst!==Sh&&(n.blendDst=this.blendDst),this.blendEquation!==Sr&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ta&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Rm&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==xa&&(n.stencilFail=this.stencilFail),this.stencilZFail!==xa&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==xa&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),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=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),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=!0),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(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}if(t){const o=i(e.textures),l=i(e.images);o.length>0&&(n.textures=o),l.length>0&&(n.images=l)}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.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let o=0;o!==i;++o)n[o]=t[o].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.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class pg extends Zn{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 _o;const Rl=new O,yo=new O,bo=new O,So=new pe,Il=new pe,nb=new gt,Au=new O,Pl=new O,Cu=new O,Cv=new pe,Fp=new pe,Rv=new pe;class ib extends Ot{constructor(e=new pg){if(super(),this.isSprite=!0,this.type="Sprite",_o===void 0){_o=new _t;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 Df(t,5);_o.setIndex([0,1,2,0,2,3]),_o.setAttribute("position",new Ra(n,3,0,!1)),_o.setAttribute("uv",new Ra(n,2,3,!1))}this.geometry=_o,this.material=e,this.center=new pe(.5,.5),this.count=1}raycast(e,t){e.camera===null&&ot('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),yo.setFromMatrixScale(this.matrixWorld),nb.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),bo.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&yo.multiplyScalar(-bo.z);const n=this.material.rotation;let i,o;n!==0&&(o=Math.cos(n),i=Math.sin(n));const l=this.center;Ru(Au.set(-.5,-.5,0),bo,l,yo,i,o),Ru(Pl.set(.5,-.5,0),bo,l,yo,i,o),Ru(Cu.set(.5,.5,0),bo,l,yo,i,o),Cv.set(0,0),Fp.set(1,0),Rv.set(1,1);let c=e.ray.intersectTriangle(Au,Pl,Cu,!1,Rl);if(c===null&&(Ru(Pl.set(-.5,.5,0),bo,l,yo,i,o),Fp.set(0,1),c=e.ray.intersectTriangle(Au,Cu,Pl,!1,Rl),c===null))return;const h=e.ray.origin.distanceTo(Rl);h<e.near||h>e.far||t.push({distance:h,point:Rl.clone(),uv:mi.getInterpolation(Rl,Au,Pl,Cu,Cv,Fp,Rv,new pe),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 Ru(s,e,t,n,i,o){So.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(Il.x=o*So.x-i*So.y,Il.y=i*So.x+o*So.y):Il.copy(So),s.copy(e),s.x+=Il.x,s.y+=Il.y,s.applyMatrix4(nb)}const Iu=new O,Iv=new O;class sb extends Ot{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n<i;n++){const o=t[n];this.addLevel(o.object.clone(),o.distance,o.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let o;for(o=0;o<i.length&&!(t<i[o].distance);o++);return i.splice(o,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const i=t.splice(n,1);return this.remove(i[0].object),!0}return!1}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 o=t[n].distance;if(t[n].object.visible&&(o-=o*t[n].hysteresis),e<o)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Iu.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Iu);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Iu.setFromMatrixPosition(e.matrixWorld),Iv.setFromMatrixPosition(this.matrixWorld);const n=Iu.distanceTo(Iv)/e.zoom;t[0].object.visible=!0;let i,o;for(i=1,o=t.length;i<o;i++){let l=t[i].distance;if(t[i].object.visible&&(l-=l*t[i].hysteresis),n>=l)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<o;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,o=n.length;i<o;i++){const l=n[i];t.object.levels.push({object:l.object.uuid,distance:l.distance,hysteresis:l.hysteresis})}return t}}const ks=new O,Op=new O,Pu=new O,xr=new O,zp=new O,Lu=new O,Bp=new O;class La{constructor(e=new O,t=new O(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,ks)),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=ks.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ks.copy(this.origin).addScaledVector(this.direction,t),ks.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Op.copy(e).add(t).multiplyScalar(.5),Pu.copy(t).sub(e).normalize(),xr.copy(this.origin).sub(Op);const o=e.distanceTo(t)*.5,l=-this.direction.dot(Pu),c=xr.dot(this.direction),h=-xr.dot(Pu),f=xr.lengthSq(),p=Math.abs(1-l*l);let g,m,x,v;if(p>0)if(g=l*h-c,m=l*c-h,v=o*p,g>=0)if(m>=-v)if(m<=v){const E=1/p;g*=E,m*=E,x=g*(g+l*m+2*c)+m*(l*g+m+2*h)+f}else m=o,g=Math.max(0,-(l*m+c)),x=-g*g+m*(m+2*h)+f;else m=-o,g=Math.max(0,-(l*m+c)),x=-g*g+m*(m+2*h)+f;else m<=-v?(g=Math.max(0,-(-l*o+c)),m=g>0?-o:Math.min(Math.max(-o,-h),o),x=-g*g+m*(m+2*h)+f):m<=v?(g=0,m=Math.min(Math.max(-o,-h),o),x=m*(m+2*h)+f):(g=Math.max(0,-(l*o+c)),m=g>0?o:Math.min(Math.max(-o,-h),o),x=-g*g+m*(m+2*h)+f);else m=l>0?-o:o,g=Math.max(0,-(l*m+c)),x=-g*g+m*(m+2*h)+f;return n&&n.copy(this.origin).addScaledVector(this.direction,g),i&&i.copy(Op).addScaledVector(Pu,m),x}intersectSphere(e,t){ks.subVectors(e.center,this.origin);const n=ks.dot(this.direction),i=ks.dot(ks)-n*n,o=e.radius*e.radius;if(i>o)return null;const l=Math.sqrt(o-i),c=n-l,h=n+l;return h<0?null:c<0?this.at(h,t):this.at(c,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const 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,o,l,c,h;const f=1/this.direction.x,p=1/this.direction.y,g=1/this.direction.z,m=this.origin;return f>=0?(n=(e.min.x-m.x)*f,i=(e.max.x-m.x)*f):(n=(e.max.x-m.x)*f,i=(e.min.x-m.x)*f),p>=0?(o=(e.min.y-m.y)*p,l=(e.max.y-m.y)*p):(o=(e.max.y-m.y)*p,l=(e.min.y-m.y)*p),n>l||o>i||((o>n||isNaN(n))&&(n=o),(l<i||isNaN(i))&&(i=l),g>=0?(c=(e.min.z-m.z)*g,h=(e.max.z-m.z)*g):(c=(e.max.z-m.z)*g,h=(e.min.z-m.z)*g),n>h||c>i)||((c>n||n!==n)&&(n=c),(h<i||i!==i)&&(i=h),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,ks)!==null}intersectTriangle(e,t,n,i,o){zp.subVectors(t,e),Lu.subVectors(n,e),Bp.crossVectors(zp,Lu);let l=this.direction.dot(Bp),c;if(l>0){if(i)return null;c=1}else if(l<0)c=-1,l=-l;else return null;xr.subVectors(this.origin,e);const h=c*this.direction.dot(Lu.crossVectors(xr,Lu));if(h<0)return null;const f=c*this.direction.dot(zp.cross(xr));if(f<0||h+f>l)return null;const p=-c*xr.dot(Bp);return p<0?null:this.at(p/l,o)}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 Pr extends Zn{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.envMapRotation=new Li,this.combine=bc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Pv=new gt,na=new La,Nu=new Bn,Lv=new O,Du=new O,Uu=new O,Fu=new O,kp=new O,Ou=new O,Nv=new O,zu=new O;class Sn extends Ot{constructor(e=new _t,t=new Pr){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():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 o=0,l=i.length;o<l;o++){const c=i[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,o=n.morphAttributes.position,l=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const c=this.morphTargetInfluences;if(o&&c){Ou.set(0,0,0);for(let h=0,f=o.length;h<f;h++){const p=c[h],g=o[h];p!==0&&(kp.fromBufferAttribute(g,e),l?Ou.addScaledVector(kp,p):Ou.addScaledVector(kp.sub(t),p))}t.add(Ou)}return t}raycast(e,t){const n=this.geometry,i=this.material,o=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Nu.copy(n.boundingSphere),Nu.applyMatrix4(o),na.copy(e.ray).recast(e.near),!(Nu.containsPoint(na.origin)===!1&&(na.intersectSphere(Nu,Lv)===null||na.origin.distanceToSquared(Lv)>(e.far-e.near)**2))&&(Pv.copy(o).invert(),na.copy(e.ray).applyMatrix4(Pv),!(n.boundingBox!==null&&na.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,na)))}_computeIntersections(e,t,n){let i;const o=this.geometry,l=this.material,c=o.index,h=o.attributes.position,f=o.attributes.uv,p=o.attributes.uv1,g=o.attributes.normal,m=o.groups,x=o.drawRange;if(c!==null)if(Array.isArray(l))for(let v=0,E=m.length;v<E;v++){const b=m[v],_=l[b.materialIndex],M=Math.max(b.start,x.start),w=Math.min(c.count,Math.min(b.start+b.count,x.start+x.count));for(let T=M,P=w;T<P;T+=3){const R=c.getX(T),U=c.getX(T+1),A=c.getX(T+2);i=Bu(this,_,e,n,f,p,g,R,U,A),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,t.push(i))}}else{const v=Math.max(0,x.start),E=Math.min(c.count,x.start+x.count);for(let b=v,_=E;b<_;b+=3){const M=c.getX(b),w=c.getX(b+1),T=c.getX(b+2);i=Bu(this,l,e,n,f,p,g,M,w,T),i&&(i.faceIndex=Math.floor(b/3),t.push(i))}}else if(h!==void 0)if(Array.isArray(l))for(let v=0,E=m.length;v<E;v++){const b=m[v],_=l[b.materialIndex],M=Math.max(b.start,x.start),w=Math.min(h.count,Math.min(b.start+b.count,x.start+x.count));for(let T=M,P=w;T<P;T+=3){const R=T,U=T+1,A=T+2;i=Bu(this,_,e,n,f,p,g,R,U,A),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,t.push(i))}}else{const v=Math.max(0,x.start),E=Math.min(h.count,x.start+x.count);for(let b=v,_=E;b<_;b+=3){const M=b,w=b+1,T=b+2;i=Bu(this,l,e,n,f,p,g,M,w,T),i&&(i.faceIndex=Math.floor(b/3),t.push(i))}}}}function tT(s,e,t,n,i,o,l,c){let h;if(e.side===si?h=n.intersectTriangle(l,o,i,!0,c):h=n.intersectTriangle(i,o,l,e.side===qs,c),h===null)return null;zu.copy(c),zu.applyMatrix4(s.matrixWorld);const f=t.ray.origin.distanceTo(zu);return f<t.near||f>t.far?null:{distance:f,point:zu.clone(),object:s}}function Bu(s,e,t,n,i,o,l,c,h,f){s.getVertexPosition(c,Du),s.getVertexPosition(h,Uu),s.getVertexPosition(f,Fu);const p=tT(s,e,t,n,Du,Uu,Fu,Nv);if(p){const g=new O;mi.getBarycoord(Nv,Du,Uu,Fu,g),i&&(p.uv=mi.getInterpolatedAttribute(i,c,h,f,g,new pe)),o&&(p.uv1=mi.getInterpolatedAttribute(o,c,h,f,g,new pe)),l&&(p.normal=mi.getInterpolatedAttribute(l,c,h,f,g,new O),p.normal.dot(n.direction)>0&&p.normal.multiplyScalar(-1));const m={a:c,b:h,c:f,normal:new O,materialIndex:0};mi.getNormal(Du,Uu,Fu,m.normal),p.face=m,p.barycoord=g}return p}const Dv=new O,Uv=new Zt,Fv=new Zt,nT=new O,Ov=new gt,ku=new O,Vp=new Bn,zv=new gt,Hp=new La;class rb extends Sn{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Am,this.bindMatrix=new gt,this.bindMatrixInverse=new gt,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++)this.getVertexPosition(n,ku),this.boundingBox.expandByPoint(ku)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Bn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ku),this.boundingSphere.expandByPoint(ku)}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(),Vp.copy(this.boundingSphere),Vp.applyMatrix4(i),e.ray.intersectsSphere(Vp)!==!1&&(zv.copy(i).invert(),Hp.copy(e.ray).applyMatrix4(zv),!(this.boundingBox!==null&&Hp.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Hp)))}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 Zt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const o=1/e.manhattanLength();o!==1/0?e.multiplyScalar(o):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Am?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===By?this.bindMatrixInverse.copy(this.bindMatrix).invert():He("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Uv.fromBufferAttribute(i.attributes.skinIndex,e),Fv.fromBufferAttribute(i.attributes.skinWeight,e),Dv.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let o=0;o<4;o++){const l=Fv.getComponent(o);if(l!==0){const c=Uv.getComponent(o);Ov.multiplyMatrices(n.bones[c].matrixWorld,n.boneInverses[c]),t.addScaledVector(nT.copy(Dv).applyMatrix4(Ov),l)}}return t.applyMatrix4(this.bindMatrixInverse)}}class mg extends Ot{constructor(){super(),this.isBone=!0,this.type="Bone"}}class rs extends un{constructor(e=null,t=1,n=1,i,o,l,c,h,f=mn,p=mn,g,m){super(null,l,c,h,f,p,i,o,g,m),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Bv=new gt,iT=new gt;class Uf{constructor(e=[],t=[]){this.uuid=Ii(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,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){He("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 gt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new gt;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 o=0,l=e.length;o<l;o++){const c=e[o]?e[o].matrixWorld:iT;Bv.multiplyMatrices(c,t[o]),Bv.toArray(n,o*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Uf(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new rs(t,e,e,Yn,ii);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,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 o=e.bones[n];let l=t[o];l===void 0&&(He("Skeleton: No bone found with UUID:",o),l=new mg),this.bones.push(l),this.boneInverses.push(new gt().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,o=t.length;i<o;i++){const l=t[i];e.bones.push(l.uuid);const c=n[i];e.boneInverses.push(c.toArray())}return e}}class Ho extends Yt{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 Mo=new gt,kv=new gt,Vu=[],Vv=new $n,sT=new gt,Ll=new Sn,Nl=new Bn;class ab extends Sn{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ho(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,sT)}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,Mo),Vv.copy(e.boundingBox).applyMatrix4(Mo),this.boundingBox.union(Vv)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Bn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Mo),Nl.copy(e.boundingSphere).applyMatrix4(Mo),this.boundingSphere.union(Nl)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.previousInstanceMatrix!==null&&(this.previousInstanceMatrix=e.previousInstanceMatrix.clone()),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),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)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,o=n.length+1,l=e*o+1;for(let c=0;c<n.length;c++)n[c]=i[l+c]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Ll.geometry=this.geometry,Ll.material=this.material,Ll.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Nl.copy(this.boundingSphere),Nl.applyMatrix4(n),e.ray.intersectsSphere(Nl)!==!1))for(let o=0;o<i;o++){this.getMatrixAt(o,Mo),kv.multiplyMatrices(n,Mo),Ll.matrixWorld=kv,Ll.raycast(e,Vu);for(let l=0,c=Vu.length;l<c;l++){const h=Vu[l];h.instanceId=o,h.object=this,t.push(h)}Vu.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Ho(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new rs(new Float32Array(i*this.count),i,this.count,Ef,ii));const o=this.morphTexture.source.data.data;let l=0;for(let f=0;f<n.length;f++)l+=n[f];const c=this.geometry.morphTargetsRelative?1:1-l,h=i*e;o[h]=c,o.set(n,h+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Gp=new O,rT=new O,aT=new St;class Gs{constructor(e=new O(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=Gp.subVectors(n,t).cross(rT.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(Gp),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const o=-(e.start.dot(this.normal)+this.constant)/i;return o<0||o>1?null:t.copy(e.start).addScaledVector(n,o)}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||aT.getNormalMatrix(e),i=this.coplanarPoint(Gp).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(o),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 ia=new Bn,oT=new pe(.5,.5),Hu=new O;class Yo{constructor(e=new Gs,t=new Gs,n=new Gs,i=new Gs,o=new Gs,l=new Gs){this.planes=[e,t,n,i,o,l]}set(e,t,n,i,o,l){const c=this.planes;return c[0].copy(e),c[1].copy(t),c[2].copy(n),c[3].copy(i),c[4].copy(o),c[5].copy(l),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=Ri,n=!1){const i=this.planes,o=e.elements,l=o[0],c=o[1],h=o[2],f=o[3],p=o[4],g=o[5],m=o[6],x=o[7],v=o[8],E=o[9],b=o[10],_=o[11],M=o[12],w=o[13],T=o[14],P=o[15];if(i[0].setComponents(f-l,x-p,_-v,P-M).normalize(),i[1].setComponents(f+l,x+p,_+v,P+M).normalize(),i[2].setComponents(f+c,x+g,_+E,P+w).normalize(),i[3].setComponents(f-c,x-g,_-E,P-w).normalize(),n)i[4].setComponents(h,m,b,T).normalize(),i[5].setComponents(f-h,x-m,_-b,P-T).normalize();else if(i[4].setComponents(f-h,x-m,_-b,P-T).normalize(),t===Ri)i[5].setComponents(f+h,x+m,_+b,P+T).normalize();else if(t===Ca)i[5].setComponents(h,m,b,T).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(),ia.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ia.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ia)}intersectsSprite(e){ia.center.set(0,0,0);const t=oT.distanceTo(e.center);return ia.radius=.7071067811865476+t,ia.applyMatrix4(e.matrixWorld),this.intersectsSphere(ia)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let o=0;o<6;o++)if(t[o].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(Hu.x=i.normal.x>0?e.max.x:e.min.x,Hu.y=i.normal.y>0?e.max.y:e.min.y,Hu.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Hu)<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)}}const fs=new gt,ds=new Yo;class Ff{constructor(){this.coordinateSystem=Ri}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(fs.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ds.setFromProjectionMatrix(fs,i.coordinateSystem,i.reversedDepth),ds.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(fs.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ds.setFromProjectionMatrix(fs,i.coordinateSystem,i.reversedDepth),ds.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(fs.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ds.setFromProjectionMatrix(fs,i.coordinateSystem,i.reversedDepth),ds.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(fs.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ds.setFromProjectionMatrix(fs,i.coordinateSystem,i.reversedDepth),ds.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const i=t.cameras[n];if(fs.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),ds.setFromProjectionMatrix(fs,i.coordinateSystem,i.reversedDepth),ds.containsPoint(e))return!0}return!1}clone(){return new Ff}}function Wp(s,e){return s-e}function lT(s,e){return s.z-e.z}function cT(s,e){return e.z-s.z}class uT{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,i){const o=this.pool,l=this.list;this.index>=o.length&&o.push({start:-1,count:-1,z:-1,index:-1});const c=o[this.index];l.push(c),this.index++,c.start=e,c.count=t,c.z=n,c.index=i}reset(){this.list.length=0,this.index=0}}const ui=new gt,hT=new Ye(1,1,1),Hv=new Yo,fT=new Ff,Gu=new $n,sa=new Bn,Dl=new O,Gv=new O,dT=new O,Xp=new uT,jn=new Sn,Wu=[];function pT(s,e,t=0){const n=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const i=s.count;for(let o=0;o<i;o++)for(let l=0;l<n;l++)e.setComponent(o+t,l,s.getComponent(o,l))}else e.array.set(s.array,t*n);e.needsUpdate=!0}function ra(s,e){if(s.constructor!==e.constructor){const t=Math.min(s.length,e.length);for(let n=0;n<t;n++)e[n]=s[n]}else{const t=Math.min(s.length,e.length);e.set(new s.constructor(s.buffer,0,t))}}class ob extends Sn{constructor(e,t,n=t*2,i){super(new _t,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new rs(t,e,e,Yn,ii);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new rs(t,e,e,Sc,ki);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new rs(t,e,e,Yn,ii);n.colorSpace=Dt.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const l=e.getAttribute(o),{array:c,itemSize:h,normalized:f}=l,p=new c.constructor(n*h),g=new Yt(p,h,f);t.setAttribute(o,g)}if(e.getIndex()!==null){const o=n>65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new Yt(o,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=e.getAttribute(n),o=t.getAttribute(n);if(i.itemSize!==o.itemSize||i.normalized!==o.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new $n);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const o=t[n].geometryIndex;this.getMatrixAt(n,ui),this.getBoundingBoxAt(o,Gu).applyMatrix4(ui),e.union(Gu)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Bn);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const o=t[n].geometryIndex;this.getMatrixAt(n,ui),this.getBoundingSphereAt(o,sa).applyMatrix4(ui),e.union(sa)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Wp),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));const o=this._matricesTexture;ui.identity().toArray(o.image.data,i*16),o.needsUpdate=!0;const l=this._colorsTexture;return l&&(hT.toArray(l.image.data,i*4),l.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},o=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const l=e.getIndex();if(l!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?l.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let h;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Wp),h=this._availableGeometryIds.shift(),o[h]=i):(h=this._geometryCount,this._geometryCount++,o.push(i)),this.setGeometryAt(h,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,i=n.getIndex()!==null,o=n.getIndex(),l=t.getIndex(),c=this._geometryInfo[e];if(i&&l.count>c.reservedIndexCount||t.attributes.position.count>c.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const h=c.vertexStart,f=c.reservedVertexCount;c.vertexCount=t.getAttribute("position").count;for(const p in n.attributes){const g=t.getAttribute(p),m=n.getAttribute(p);pT(g,m,h);const x=g.itemSize;for(let v=g.count,E=f;v<E;v++){const b=h+v;for(let _=0;_<x;_++)m.setComponent(b,_,0)}m.needsUpdate=!0,m.addUpdateRange(h*x,f*x)}if(i){const p=c.indexStart,g=c.reservedIndexCount;c.indexCount=t.getIndex().count;for(let m=0;m<l.count;m++)o.setX(p+m,h+l.getX(m));for(let m=l.count,x=g;m<x;m++)o.setX(p+m,h);o.needsUpdate=!0,o.addUpdateRange(p,c.reservedIndexCount)}return c.start=i?c.indexStart:c.vertexStart,c.count=i?c.indexCount:c.vertexCount,c.boundingBox=null,t.boundingBox!==null&&(c.boundingBox=t.boundingBox.clone()),c.boundingSphere=null,t.boundingSphere!==null&&(c.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let i=0,o=n.length;i<o;i++)n[i].active&&n[i].geometryIndex===e&&this.deleteInstance(i);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const n=this._geometryInfo,i=n.map((l,c)=>c).sort((l,c)=>n[l].vertexStart-n[c].vertexStart),o=this.geometry;for(let l=0,c=n.length;l<c;l++){const h=i[l],f=n[h];if(f.active!==!1){if(o.index!==null){if(f.indexStart!==t){const{indexStart:p,vertexStart:g,reservedIndexCount:m}=f,x=o.index,v=x.array,E=e-g;for(let b=p;b<p+m;b++)v[b]=v[b]+E;x.array.copyWithin(t,p,p+m),x.addUpdateRange(t,m),x.needsUpdate=!0,f.indexStart=t}t+=f.reservedIndexCount}if(f.vertexStart!==e){const{vertexStart:p,reservedVertexCount:g}=f,m=o.attributes;for(const x in m){const v=m[x],{array:E,itemSize:b}=v;E.copyWithin(e*b,p*b,(p+g)*b),v.addUpdateRange(e*b,g*b),v.needsUpdate=!0}f.vertexStart=e}e+=f.reservedVertexCount,f.start=o.index?f.indexStart:f.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingBox===null){const o=new $n,l=n.index,c=n.attributes.position;for(let h=i.start,f=i.start+i.count;h<f;h++){let p=h;l&&(p=l.getX(p)),o.expandByPoint(Dl.fromBufferAttribute(c,p))}i.boundingBox=o}return t.copy(i.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingSphere===null){const o=new Bn;this.getBoundingBoxAt(e,Gu),Gu.getCenter(o.center);const l=n.index,c=n.attributes.position;let h=0;for(let f=i.start,p=i.start+i.count;f<p;f++){let g=f;l&&(g=l.getX(g)),Dl.fromBufferAttribute(c,g),h=Math.max(h,o.center.distanceToSquared(Dl))}o.radius=Math.sqrt(h),i.boundingSphere=o}return t.copy(i.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,i=this._matricesTexture.image.data;return t.toArray(i,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(Wp);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const i=new Int32Array(e),o=new Int32Array(e);ra(this._multiDrawCounts,i),ra(this._multiDrawStarts,o),this._multiDrawCounts=i,this._multiDrawStarts=o,this._maxInstanceCount=e;const l=this._indirectTexture,c=this._matricesTexture,h=this._colorsTexture;l.dispose(),this._initIndirectTexture(),ra(l.image.data,this._indirectTexture.image.data),c.dispose(),this._initMatricesTexture(),ra(c.image.data,this._matricesTexture.image.data),h&&(h.dispose(),this._initColorsTexture(),ra(h.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const n=[...this._geometryInfo].filter(c=>c.active);if(Math.max(...n.map(c=>c.vertexStart+c.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(h=>h.indexStart+h.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const o=this.geometry;o.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new _t,this._initializeGeometry(o));const l=this.geometry;o.index&&ra(o.index.array,l.index.array);for(const c in o.attributes)ra(o.attributes[c].array,l.attributes[c].array)}raycast(e,t){const n=this._instanceInfo,i=this._geometryInfo,o=this.matrixWorld,l=this.geometry;jn.material=this.material,jn.geometry.index=l.index,jn.geometry.attributes=l.attributes,jn.geometry.boundingBox===null&&(jn.geometry.boundingBox=new $n),jn.geometry.boundingSphere===null&&(jn.geometry.boundingSphere=new Bn);for(let c=0,h=n.length;c<h;c++){if(!n[c].visible||!n[c].active)continue;const f=n[c].geometryIndex,p=i[f];jn.geometry.setDrawRange(p.start,p.count),this.getMatrixAt(c,jn.matrixWorld).premultiply(o),this.getBoundingBoxAt(f,jn.geometry.boundingBox),this.getBoundingSphereAt(f,jn.geometry.boundingSphere),jn.raycast(e,Wu);for(let g=0,m=Wu.length;g<m;g++){const x=Wu[g];x.object=this,x.batchId=c,t.push(x)}Wu.length=0}jn.material=null,jn.geometry.index=null,jn.geometry.attributes={},jn.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,i,o){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const l=i.getIndex();let c=l===null?1:l.array.BYTES_PER_ELEMENT,h=1;o.wireframe&&(h=2,c=i.attributes.position.count>65535?4:2);const f=this._instanceInfo,p=this._multiDrawStarts,g=this._multiDrawCounts,m=this._geometryInfo,x=this.perObjectFrustumCulled,v=this._indirectTexture,E=v.image.data,b=n.isArrayCamera?fT:Hv;x&&!n.isArrayCamera&&(ui.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Hv.setFromProjectionMatrix(ui,n.coordinateSystem,n.reversedDepth));let _=0;if(this.sortObjects){ui.copy(this.matrixWorld).invert(),Dl.setFromMatrixPosition(n.matrixWorld).applyMatrix4(ui),Gv.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(ui);for(let T=0,P=f.length;T<P;T++)if(f[T].visible&&f[T].active){const R=f[T].geometryIndex;this.getMatrixAt(T,ui),this.getBoundingSphereAt(R,sa).applyMatrix4(ui);let U=!1;if(x&&(U=!b.intersectsSphere(sa,n)),!U){const A=m[R],I=dT.subVectors(sa.center,Dl).dot(Gv);Xp.push(A.start,A.count,I,T)}}const M=Xp.list,w=this.customSort;w===null?M.sort(o.transparent?cT:lT):w.call(this,M,n);for(let T=0,P=M.length;T<P;T++){const R=M[T];p[_]=R.start*c*h,g[_]=R.count*h,E[_]=R.index,_++}Xp.reset()}else for(let M=0,w=f.length;M<w;M++)if(f[M].visible&&f[M].active){const T=f[M].geometryIndex;let P=!1;if(x&&(this.getMatrixAt(M,ui),this.getBoundingSphereAt(T,sa).applyMatrix4(ui),P=!b.intersectsSphere(sa,n)),!P){const R=m[T];p[_]=R.start*c*h,g[_]=R.count*h,E[_]=M,_++}}v.needsUpdate=!0,this._multiDrawCount=_,this._visibilityChanged=!1}onBeforeShadow(e,t,n,i,o,l){this.onBeforeRender(e,null,i,o,l)}}class Kn extends Zn{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 uf=new O,hf=new O,Wv=new gt,Ul=new La,Xu=new Bn,jp=new O,Xv=new O;class Ys extends Ot{constructor(e=new _t,t=new Kn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,o=t.count;i<o;i++)uf.fromBufferAttribute(t,i-1),hf.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=uf.distanceTo(hf);e.setAttribute("lineDistance",new et(n,1))}else He("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,o=e.params.Line.threshold,l=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Xu.copy(n.boundingSphere),Xu.applyMatrix4(i),Xu.radius+=o,e.ray.intersectsSphere(Xu)===!1)return;Wv.copy(i).invert(),Ul.copy(e.ray).applyMatrix4(Wv);const c=o/((this.scale.x+this.scale.y+this.scale.z)/3),h=c*c,f=this.isLineSegments?2:1,p=n.index,m=n.attributes.position;if(p!==null){const x=Math.max(0,l.start),v=Math.min(p.count,l.start+l.count);for(let E=x,b=v-1;E<b;E+=f){const _=p.getX(E),M=p.getX(E+1),w=ju(this,e,Ul,h,_,M,E);w&&t.push(w)}if(this.isLineLoop){const E=p.getX(v-1),b=p.getX(x),_=ju(this,e,Ul,h,E,b,v-1);_&&t.push(_)}}else{const x=Math.max(0,l.start),v=Math.min(m.count,l.start+l.count);for(let E=x,b=v-1;E<b;E+=f){const _=ju(this,e,Ul,h,E,E+1,E);_&&t.push(_)}if(this.isLineLoop){const E=ju(this,e,Ul,h,v-1,x,v-1);E&&t.push(E)}}}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 o=0,l=i.length;o<l;o++){const c=i[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}}function ju(s,e,t,n,i,o,l){const c=s.geometry.attributes.position;if(uf.fromBufferAttribute(c,i),hf.fromBufferAttribute(c,o),t.distanceSqToSegment(uf,hf,jp,Xv)>n)return;jp.applyMatrix4(s.matrixWorld);const f=e.ray.origin.distanceTo(jp);if(!(f<e.near||f>e.far))return{distance:f,point:Xv.clone().applyMatrix4(s.matrixWorld),index:l,face:null,faceIndex:null,barycoord:null,object:s}}const jv=new O,qv=new O;class Ms extends Ys{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,o=t.count;i<o;i+=2)jv.fromBufferAttribute(t,i),qv.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+jv.distanceTo(qv);e.setAttribute("lineDistance",new et(n,1))}else He("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class lb extends Ys{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class gg extends Zn{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 Yv=new gt,Pm=new La,qu=new Bn,Yu=new O;class cb extends Ot{constructor(e=new _t,t=new gg){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,o=e.params.Points.threshold,l=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),qu.copy(n.boundingSphere),qu.applyMatrix4(i),qu.radius+=o,e.ray.intersectsSphere(qu)===!1)return;Yv.copy(i).invert(),Pm.copy(e.ray).applyMatrix4(Yv);const c=o/((this.scale.x+this.scale.y+this.scale.z)/3),h=c*c,f=n.index,g=n.attributes.position;if(f!==null){const m=Math.max(0,l.start),x=Math.min(f.count,l.start+l.count);for(let v=m,E=x;v<E;v++){const b=f.getX(v);Yu.fromBufferAttribute(g,b),$v(Yu,b,h,i,e,t,this)}}else{const m=Math.max(0,l.start),x=Math.min(g.count,l.start+l.count);for(let v=m,E=x;v<E;v++)Yu.fromBufferAttribute(g,v),$v(Yu,v,h,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 o=0,l=i.length;o<l;o++){const c=i[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}}function $v(s,e,t,n,i,o,l){const c=Pm.distanceSqToPoint(s);if(c<t){const h=new O;Pm.closestPointToPoint(s,h),h.applyMatrix4(n);const f=i.ray.origin.distanceTo(h);if(f<i.near||f>i.far)return;o.push({distance:f,distanceToRay:Math.sqrt(c),point:h,index:e,face:null,faceIndex:null,barycoord:null,object:l})}}class ub extends un{constructor(e,t,n,i,o=en,l=en,c,h,f){super(e,t,n,i,o,l,c,h,f),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const p=this;function g(){p.needsUpdate=!0,p._requestVideoFrameCallbackId=e.requestVideoFrameCallback(g)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(g))}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)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class mT extends ub{constructor(e,t,n,i,o,l,c,h){super({},e,t,n,i,o,l,c,h),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class gT extends un{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=mn,this.minFilter=mn,this.generateMipmaps=!1,this.needsUpdate=!0}}class Of extends un{constructor(e,t,n,i,o,l,c,h,f,p,g,m){super(null,l,c,h,f,p,i,o,g,m),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class xT extends Of{constructor(e,t,n,i,o,l){super(e,t,n,o,l),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=gi,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class vT extends Of{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,_s),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Mc extends un{constructor(e=[],t=_s,n,i,o,l,c,h,f,p){super(e,t,n,i,o,l,c,h,f,p),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class _T extends un{constructor(e,t,n,i,o,l,c,h,f){super(e,t,n,i,o,l,c,h,f),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Go extends un{constructor(e,t,n=ki,i,o,l,c=mn,h=mn,f,p=bs,g=1){if(p!==bs&&p!==Er)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:t,depth:g};super(m,i,o,l,c,h,p,n,f),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new wr(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class hb extends Go{constructor(e,t=ki,n=_s,i,o,l=mn,c=mn,h,f=bs){const p={width:e,height:e,depth:1},g=[p,p,p,p,p,p];super(e,e,t,n,i,o,l,c,h,f),this.image=g,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class xg extends un{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Na extends _t{constructor(e=1,t=1,n=1,i=1,o=1,l=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:o,depthSegments:l};const c=this;i=Math.floor(i),o=Math.floor(o),l=Math.floor(l);const h=[],f=[],p=[],g=[];let m=0,x=0;v("z","y","x",-1,-1,n,t,e,l,o,0),v("z","y","x",1,-1,n,t,-e,l,o,1),v("x","z","y",1,1,e,n,t,i,l,2),v("x","z","y",1,-1,e,n,-t,i,l,3),v("x","y","z",1,-1,e,t,n,i,o,4),v("x","y","z",-1,-1,e,t,-n,i,o,5),this.setIndex(h),this.setAttribute("position",new et(f,3)),this.setAttribute("normal",new et(p,3)),this.setAttribute("uv",new et(g,2));function v(E,b,_,M,w,T,P,R,U,A,I){const B=T/U,F=P/A,j=T/2,H=P/2,Z=R/2,W=U+1,$=A+1;let Y=0,ge=0;const he=new O;for(let Ee=0;Ee<$;Ee++){const xe=Ee*F-H;for(let ve=0;ve<W;ve++){const Xe=ve*B-j;he[E]=Xe*M,he[b]=xe*w,he[_]=Z,f.push(he.x,he.y,he.z),he[E]=0,he[b]=0,he[_]=R>0?1:-1,p.push(he.x,he.y,he.z),g.push(ve/U),g.push(1-Ee/A),Y+=1}}for(let Ee=0;Ee<A;Ee++)for(let xe=0;xe<U;xe++){const ve=m+xe+W*Ee,Xe=m+xe+W*(Ee+1),lt=m+(xe+1)+W*(Ee+1),yt=m+(xe+1)+W*Ee;h.push(ve,Xe,yt),h.push(Xe,lt,yt),ge+=6}c.addGroup(x,ge,I),x+=ge,m+=Y}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Na(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class zf extends _t{constructor(e=1,t=1,n=4,i=8,o=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i,heightSegments:o},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),o=Math.max(1,Math.floor(o));const l=[],c=[],h=[],f=[],p=t/2,g=Math.PI/2*e,m=t,x=2*g+m,v=n*2+o,E=i+1,b=new O,_=new O;for(let M=0;M<=v;M++){let w=0,T=0,P=0,R=0;if(M<=n){const I=M/n,B=I*Math.PI/2;T=-p-e*Math.cos(B),P=e*Math.sin(B),R=-e*Math.cos(B),w=I*g}else if(M<=n+o){const I=(M-n)/o;T=-p+I*t,P=e,R=0,w=g+I*m}else{const I=(M-n-o)/n,B=I*Math.PI/2;T=p+e*Math.sin(B),P=e*Math.cos(B),R=e*Math.sin(B),w=g+m+I*g}const U=Math.max(0,Math.min(1,w/x));let A=0;M===0?A=.5/i:M===v&&(A=-.5/i);for(let I=0;I<=i;I++){const B=I/i,F=B*Math.PI*2,j=Math.sin(F),H=Math.cos(F);_.x=-P*H,_.y=T,_.z=P*j,c.push(_.x,_.y,_.z),b.set(-P*H,R,P*j),b.normalize(),h.push(b.x,b.y,b.z),f.push(B+A,U)}if(M>0){const I=(M-1)*E;for(let B=0;B<i;B++){const F=I+B,j=I+B+1,H=M*E+B,Z=M*E+B+1;l.push(F,j,H),l.push(j,Z,H)}}}this.setIndex(l),this.setAttribute("position",new et(c,3)),this.setAttribute("normal",new et(h,3)),this.setAttribute("uv",new et(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new zf(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class Bf extends _t{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 o=[],l=[],c=[],h=[],f=new O,p=new pe;l.push(0,0,0),c.push(0,0,1),h.push(.5,.5);for(let g=0,m=3;g<=t;g++,m+=3){const x=n+g/t*i;f.x=e*Math.cos(x),f.y=e*Math.sin(x),l.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(l[m]/e+1)/2,p.y=(l[m+1]/e+1)/2,h.push(p.x,p.y)}for(let g=1;g<=t;g++)o.push(g,g+1,0);this.setIndex(o),this.setAttribute("position",new et(l,3)),this.setAttribute("normal",new et(c,3)),this.setAttribute("uv",new et(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Bf(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Ec extends _t{constructor(e=1,t=1,n=1,i=32,o=1,l=!1,c=0,h=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:o,openEnded:l,thetaStart:c,thetaLength:h};const f=this;i=Math.floor(i),o=Math.floor(o);const p=[],g=[],m=[],x=[];let v=0;const E=[],b=n/2;let _=0;M(),l===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(p),this.setAttribute("position",new et(g,3)),this.setAttribute("normal",new et(m,3)),this.setAttribute("uv",new et(x,2));function M(){const T=new O,P=new O;let R=0;const U=(t-e)/n;for(let A=0;A<=o;A++){const I=[],B=A/o,F=B*(t-e)+e;for(let j=0;j<=i;j++){const H=j/i,Z=H*h+c,W=Math.sin(Z),$=Math.cos(Z);P.x=F*W,P.y=-B*n+b,P.z=F*$,g.push(P.x,P.y,P.z),T.set(W,U,$).normalize(),m.push(T.x,T.y,T.z),x.push(H,1-B),I.push(v++)}E.push(I)}for(let A=0;A<i;A++)for(let I=0;I<o;I++){const B=E[I][A],F=E[I+1][A],j=E[I+1][A+1],H=E[I][A+1];(e>0||I!==0)&&(p.push(B,F,H),R+=3),(t>0||I!==o-1)&&(p.push(F,j,H),R+=3)}f.addGroup(_,R,0),_+=R}function w(T){const P=v,R=new pe,U=new O;let A=0;const I=T===!0?e:t,B=T===!0?1:-1;for(let j=1;j<=i;j++)g.push(0,b*B,0),m.push(0,B,0),x.push(.5,.5),v++;const F=v;for(let j=0;j<=i;j++){const Z=j/i*h+c,W=Math.cos(Z),$=Math.sin(Z);U.x=I*$,U.y=b*B,U.z=I*W,g.push(U.x,U.y,U.z),m.push(0,B,0),R.x=W*.5+.5,R.y=$*.5*B+.5,x.push(R.x,R.y),v++}for(let j=0;j<i;j++){const H=P+j,Z=F+j;T===!0?p.push(Z,Z+1,H):p.push(Z+1,Z,H),A+=3}f.addGroup(_,A,T===!0?1:2),_+=A}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ec(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class wc extends Ec{constructor(e=1,t=1,n=32,i=1,o=!1,l=0,c=Math.PI*2){super(0,e,t,n,i,o,l,c),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:o,thetaStart:l,thetaLength:c}}static fromJSON(e){return new wc(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Lr extends _t{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const o=[],l=[];c(i),f(n),p(),this.setAttribute("position",new et(o,3)),this.setAttribute("normal",new et(o.slice(),3)),this.setAttribute("uv",new et(l,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function c(M){const w=new O,T=new O,P=new O;for(let R=0;R<t.length;R+=3)x(t[R+0],w),x(t[R+1],T),x(t[R+2],P),h(w,T,P,M)}function h(M,w,T,P){const R=P+1,U=[];for(let A=0;A<=R;A++){U[A]=[];const I=M.clone().lerp(T,A/R),B=w.clone().lerp(T,A/R),F=R-A;for(let j=0;j<=F;j++)j===0&&A===R?U[A][j]=I:U[A][j]=I.clone().lerp(B,j/F)}for(let A=0;A<R;A++)for(let I=0;I<2*(R-A)-1;I++){const B=Math.floor(I/2);I%2===0?(m(U[A][B+1]),m(U[A+1][B]),m(U[A][B])):(m(U[A][B+1]),m(U[A+1][B+1]),m(U[A+1][B]))}}function f(M){const w=new O;for(let T=0;T<o.length;T+=3)w.x=o[T+0],w.y=o[T+1],w.z=o[T+2],w.normalize().multiplyScalar(M),o[T+0]=w.x,o[T+1]=w.y,o[T+2]=w.z}function p(){const M=new O;for(let w=0;w<o.length;w+=3){M.x=o[w+0],M.y=o[w+1],M.z=o[w+2];const T=b(M)/2/Math.PI+.5,P=_(M)/Math.PI+.5;l.push(T,1-P)}v(),g()}function g(){for(let M=0;M<l.length;M+=6){const w=l[M+0],T=l[M+2],P=l[M+4],R=Math.max(w,T,P),U=Math.min(w,T,P);R>.9&&U<.1&&(w<.2&&(l[M+0]+=1),T<.2&&(l[M+2]+=1),P<.2&&(l[M+4]+=1))}}function m(M){o.push(M.x,M.y,M.z)}function x(M,w){const T=M*3;w.x=e[T+0],w.y=e[T+1],w.z=e[T+2]}function v(){const M=new O,w=new O,T=new O,P=new O,R=new pe,U=new pe,A=new pe;for(let I=0,B=0;I<o.length;I+=9,B+=6){M.set(o[I+0],o[I+1],o[I+2]),w.set(o[I+3],o[I+4],o[I+5]),T.set(o[I+6],o[I+7],o[I+8]),R.set(l[B+0],l[B+1]),U.set(l[B+2],l[B+3]),A.set(l[B+4],l[B+5]),P.copy(M).add(w).add(T).divideScalar(3);const F=b(P);E(R,B+0,M,F),E(U,B+2,w,F),E(A,B+4,T,F)}}function E(M,w,T,P){P<0&&M.x===1&&(l[w]=M.x-1),T.x===0&&T.z===0&&(l[w]=P/2/Math.PI+.5)}function b(M){return Math.atan2(M.z,-M.x)}function _(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Lr(e.vertices,e.indices,e.radius,e.detail)}}class kf extends Lr{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n,o=[-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],l=[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(o,l,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new kf(e.radius,e.detail)}}const $u=new O,Zu=new O,qp=new O,Ku=new mi;class fb extends _t{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),o=Math.cos(Ea*t),l=e.getIndex(),c=e.getAttribute("position"),h=l?l.count:c.count,f=[0,0,0],p=["a","b","c"],g=new Array(3),m={},x=[];for(let v=0;v<h;v+=3){l?(f[0]=l.getX(v),f[1]=l.getX(v+1),f[2]=l.getX(v+2)):(f[0]=v,f[1]=v+1,f[2]=v+2);const{a:E,b,c:_}=Ku;if(E.fromBufferAttribute(c,f[0]),b.fromBufferAttribute(c,f[1]),_.fromBufferAttribute(c,f[2]),Ku.getNormal(qp),g[0]=`${Math.round(E.x*i)},${Math.round(E.y*i)},${Math.round(E.z*i)}`,g[1]=`${Math.round(b.x*i)},${Math.round(b.y*i)},${Math.round(b.z*i)}`,g[2]=`${Math.round(_.x*i)},${Math.round(_.y*i)},${Math.round(_.z*i)}`,!(g[0]===g[1]||g[1]===g[2]||g[2]===g[0]))for(let M=0;M<3;M++){const w=(M+1)%3,T=g[M],P=g[w],R=Ku[p[M]],U=Ku[p[w]],A=`${T}_${P}`,I=`${P}_${T}`;I in m&&m[I]?(qp.dot(m[I].normal)<=o&&(x.push(R.x,R.y,R.z),x.push(U.x,U.y,U.z)),m[I]=null):A in m||(m[A]={index0:f[M],index1:f[w],normal:qp.clone()})}}for(const v in m)if(m[v]){const{index0:E,index1:b}=m[v];$u.fromBufferAttribute(c,E),Zu.fromBufferAttribute(c,b),x.push($u.x,$u.y,$u.z),x.push(Zu.x,Zu.y,Zu.z)}this.setAttribute("position",new et(x,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class os{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){He("Curve: .getPoint() not implemented.")}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),o=0;t.push(0);for(let l=1;l<=e;l++)n=this.getPoint(l/e),o+=n.distanceTo(i),t.push(o),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let i=0;const o=n.length;let l;t?l=t:l=e*n[o-1];let c=0,h=o-1,f;for(;c<=h;)if(i=Math.floor(c+(h-c)/2),f=n[i]-l,f<0)c=i+1;else if(f>0)h=i-1;else{h=i;break}if(i=h,n[i]===l)return i/(o-1);const p=n[i],m=n[i+1]-p,x=(l-p)/m;return(i+x)/(o-1)}getTangent(e,t){let i=e-1e-4,o=e+1e-4;i<0&&(i=0),o>1&&(o=1);const l=this.getPoint(i),c=this.getPoint(o),h=t||(l.isVector2?new pe:new O);return h.copy(c).sub(l).normalize(),h}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new O,i=[],o=[],l=[],c=new O,h=new gt;for(let x=0;x<=e;x++){const v=x/e;i[x]=this.getTangentAt(v,new O)}o[0]=new O,l[0]=new O;let f=Number.MAX_VALUE;const p=Math.abs(i[0].x),g=Math.abs(i[0].y),m=Math.abs(i[0].z);p<=f&&(f=p,n.set(1,0,0)),g<=f&&(f=g,n.set(0,1,0)),m<=f&&n.set(0,0,1),c.crossVectors(i[0],n).normalize(),o[0].crossVectors(i[0],c),l[0].crossVectors(i[0],o[0]);for(let x=1;x<=e;x++){if(o[x]=o[x-1].clone(),l[x]=l[x-1].clone(),c.crossVectors(i[x-1],i[x]),c.length()>Number.EPSILON){c.normalize();const v=Math.acos(pt(i[x-1].dot(i[x]),-1,1));o[x].applyMatrix4(h.makeRotationAxis(c,v))}l[x].crossVectors(i[x],o[x])}if(t===!0){let x=Math.acos(pt(o[0].dot(o[e]),-1,1));x/=e,i[0].dot(c.crossVectors(o[0],o[e]))>0&&(x=-x);for(let v=1;v<=e;v++)o[v].applyMatrix4(h.makeRotationAxis(i[v],x*v)),l[v].crossVectors(i[v],o[v])}return{tangents:i,normals:o,binormals:l}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Vf extends os{constructor(e=0,t=0,n=1,i=1,o=0,l=Math.PI*2,c=!1,h=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=o,this.aEndAngle=l,this.aClockwise=c,this.aRotation=h}getPoint(e,t=new pe){const n=t,i=Math.PI*2;let o=this.aEndAngle-this.aStartAngle;const l=Math.abs(o)<Number.EPSILON;for(;o<0;)o+=i;for(;o>i;)o-=i;o<Number.EPSILON&&(l?o=0:o=i),this.aClockwise===!0&&!l&&(o===i?o=-i:o=o-i);const c=this.aStartAngle+e*o;let h=this.aX+this.xRadius*Math.cos(c),f=this.aY+this.yRadius*Math.sin(c);if(this.aRotation!==0){const p=Math.cos(this.aRotation),g=Math.sin(this.aRotation),m=h-this.aX,x=f-this.aY;h=m*p-x*g+this.aX,f=m*g+x*p+this.aY}return n.set(h,f)}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 db extends Vf{constructor(e,t,n,i,o,l){super(e,t,n,n,i,o,l),this.isArcCurve=!0,this.type="ArcCurve"}}function vg(){let s=0,e=0,t=0,n=0;function i(o,l,c,h){s=o,e=c,t=-3*o+3*l-2*c-h,n=2*o-2*l+c+h}return{initCatmullRom:function(o,l,c,h,f){i(l,c,f*(c-o),f*(h-l))},initNonuniformCatmullRom:function(o,l,c,h,f,p,g){let m=(l-o)/f-(c-o)/(f+p)+(c-l)/p,x=(c-l)/p-(h-l)/(p+g)+(h-c)/g;m*=p,x*=p,i(l,c,m,x)},calc:function(o){const l=o*o,c=l*o;return s+e*o+t*l+n*c}}}const Ju=new O,Yp=new vg,$p=new vg,Zp=new vg;class pb extends os{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 O){const n=t,i=this.points,o=i.length,l=(o-(this.closed?0:1))*e;let c=Math.floor(l),h=l-c;this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/o)+1)*o:h===0&&c===o-1&&(c=o-2,h=1);let f,p;this.closed||c>0?f=i[(c-1)%o]:(Ju.subVectors(i[0],i[1]).add(i[0]),f=Ju);const g=i[c%o],m=i[(c+1)%o];if(this.closed||c+2<o?p=i[(c+2)%o]:(Ju.subVectors(i[o-1],i[o-2]).add(i[o-1]),p=Ju),this.curveType==="centripetal"||this.curveType==="chordal"){const x=this.curveType==="chordal"?.5:.25;let v=Math.pow(f.distanceToSquared(g),x),E=Math.pow(g.distanceToSquared(m),x),b=Math.pow(m.distanceToSquared(p),x);E<1e-4&&(E=1),v<1e-4&&(v=E),b<1e-4&&(b=E),Yp.initNonuniformCatmullRom(f.x,g.x,m.x,p.x,v,E,b),$p.initNonuniformCatmullRom(f.y,g.y,m.y,p.y,v,E,b),Zp.initNonuniformCatmullRom(f.z,g.z,m.z,p.z,v,E,b)}else this.curveType==="catmullrom"&&(Yp.initCatmullRom(f.x,g.x,m.x,p.x,this.tension),$p.initCatmullRom(f.y,g.y,m.y,p.y,this.tension),Zp.initCatmullRom(f.z,g.z,m.z,p.z,this.tension));return n.set(Yp.calc(h),$p.calc(h),Zp.calc(h)),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 O().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Zv(s,e,t,n,i){const o=(n-e)*.5,l=(i-t)*.5,c=s*s,h=s*c;return(2*t-2*n+o+l)*h+(-3*t+3*n-2*o-l)*c+o*s+t}function yT(s,e){const t=1-s;return t*t*e}function bT(s,e){return 2*(1-s)*s*e}function ST(s,e){return s*s*e}function Jl(s,e,t,n){return yT(s,e)+bT(s,t)+ST(s,n)}function MT(s,e){const t=1-s;return t*t*t*e}function ET(s,e){const t=1-s;return 3*t*t*s*e}function wT(s,e){return 3*(1-s)*s*s*e}function TT(s,e){return s*s*s*e}function Ql(s,e,t,n,i){return MT(s,e)+ET(s,t)+wT(s,n)+TT(s,i)}class _g extends os{constructor(e=new pe,t=new pe,n=new pe,i=new pe){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new pe){const n=t,i=this.v0,o=this.v1,l=this.v2,c=this.v3;return n.set(Ql(e,i.x,o.x,l.x,c.x),Ql(e,i.y,o.y,l.y,c.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 mb extends os{constructor(e=new O,t=new O,n=new O,i=new O){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new O){const n=t,i=this.v0,o=this.v1,l=this.v2,c=this.v3;return n.set(Ql(e,i.x,o.x,l.x,c.x),Ql(e,i.y,o.y,l.y,c.y),Ql(e,i.z,o.z,l.z,c.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 yg extends os{constructor(e=new pe,t=new pe){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new pe){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 pe){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 gb extends os{constructor(e=new O,t=new O){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new O){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 O){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 bg extends os{constructor(e=new pe,t=new pe,n=new pe){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new pe){const n=t,i=this.v0,o=this.v1,l=this.v2;return n.set(Jl(e,i.x,o.x,l.x),Jl(e,i.y,o.y,l.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 Sg extends os{constructor(e=new O,t=new O,n=new O){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new O){const n=t,i=this.v0,o=this.v1,l=this.v2;return n.set(Jl(e,i.x,o.x,l.x),Jl(e,i.y,o.y,l.y),Jl(e,i.z,o.z,l.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 Mg extends os{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new pe){const n=t,i=this.points,o=(i.length-1)*e,l=Math.floor(o),c=o-l,h=i[l===0?l:l-1],f=i[l],p=i[l>i.length-2?i.length-1:l+1],g=i[l>i.length-3?i.length-1:l+2];return n.set(Zv(c,h.x,f.x,p.x,g.x),Zv(c,h.y,f.y,p.y,g.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 pe().fromArray(i))}return this}}var ff=Object.freeze({__proto__:null,ArcCurve:db,CatmullRomCurve3:pb,CubicBezierCurve:_g,CubicBezierCurve3:mb,EllipseCurve:Vf,LineCurve:yg,LineCurve3:gb,QuadraticBezierCurve:bg,QuadraticBezierCurve3:Sg,SplineCurve:Mg});class xb extends os{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);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new ff[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let o=0;for(;o<i.length;){if(i[o]>=n){const l=i[o]-n,c=this.curves[o],h=c.getLength(),f=h===0?0:1-l/h;return c.getPointAt(f,t)}o++}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,o=this.curves;i<o.length;i++){const l=o[i],c=l.isEllipseCurve?e*2:l.isLineCurve||l.isLineCurve3?1:l.isSplineCurve?e*l.points.length:e,h=l.getPoints(c);for(let f=0;f<h.length;f++){const p=h[f];n&&n.equals(p)||(t.push(p),n=p)}}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 ff[i.type]().fromJSON(i))}return this}}class df extends xb{constructor(e){super(),this.type="Path",this.currentPoint=new pe,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 yg(this.currentPoint.clone(),new pe(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const o=new bg(this.currentPoint.clone(),new pe(e,t),new pe(n,i));return this.curves.push(o),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,o,l){const c=new _g(this.currentPoint.clone(),new pe(e,t),new pe(n,i),new pe(o,l));return this.curves.push(c),this.currentPoint.set(o,l),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Mg(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absarc(e+c,t+h,n,i,o,l),this}absarc(e,t,n,i,o,l){return this.absellipse(e,t,n,n,i,o,l),this}ellipse(e,t,n,i,o,l,c,h){const f=this.currentPoint.x,p=this.currentPoint.y;return this.absellipse(e+f,t+p,n,i,o,l,c,h),this}absellipse(e,t,n,i,o,l,c,h){const f=new Vf(e,t,n,i,o,l,c,h);if(this.curves.length>0){const g=f.getPoint(0);g.equals(this.currentPoint)||this.lineTo(g.x,g.y)}this.curves.push(f);const p=f.getPoint(1);return this.currentPoint.copy(p),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 wa extends df{constructor(e){super(e),this.uuid=Ii(),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 df().fromJSON(i))}return this}}function AT(s,e,t=2){const n=e&&e.length,i=n?e[0]*t:s.length;let o=vb(s,0,i,t,!0);const l=[];if(!o||o.next===o.prev)return l;let c,h,f;if(n&&(o=LT(s,e,o,t)),s.length>80*t){c=s[0],h=s[1];let p=c,g=h;for(let m=t;m<i;m+=t){const x=s[m],v=s[m+1];x<c&&(c=x),v<h&&(h=v),x>p&&(p=x),v>g&&(g=v)}f=Math.max(p-c,g-h),f=f!==0?32767/f:0}return hc(o,l,t,c,h,f,0),l}function vb(s,e,t,n,i){let o;if(i===GT(s,e,t,n)>0)for(let l=e;l<t;l+=n)o=Kv(l/n|0,s[l],s[l+1],o);else for(let l=t-n;l>=e;l-=n)o=Kv(l/n|0,s[l],s[l+1],o);return o&&Wo(o,o.next)&&(dc(o),o=o.next),o}function Ia(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(Wo(t,t.next)||on(t.prev,t,t.next)===0)){if(dc(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function hc(s,e,t,n,i,o,l){if(!s)return;!l&&o&&OT(s,n,i,o);let c=s;for(;s.prev!==s.next;){const h=s.prev,f=s.next;if(o?RT(s,n,i,o):CT(s)){e.push(h.i,s.i,f.i),dc(s),s=f.next,c=f.next;continue}if(s=f,s===c){l?l===1?(s=IT(Ia(s),e),hc(s,e,t,n,i,o,2)):l===2&&PT(s,e,t,n,i,o):hc(Ia(s),e,t,n,i,o,1);break}}}function CT(s){const e=s.prev,t=s,n=s.next;if(on(e,t,n)>=0)return!1;const i=e.x,o=t.x,l=n.x,c=e.y,h=t.y,f=n.y,p=Math.min(i,o,l),g=Math.min(c,h,f),m=Math.max(i,o,l),x=Math.max(c,h,f);let v=n.next;for(;v!==e;){if(v.x>=p&&v.x<=m&&v.y>=g&&v.y<=x&&Vl(i,c,o,h,l,f,v.x,v.y)&&on(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function RT(s,e,t,n){const i=s.prev,o=s,l=s.next;if(on(i,o,l)>=0)return!1;const c=i.x,h=o.x,f=l.x,p=i.y,g=o.y,m=l.y,x=Math.min(c,h,f),v=Math.min(p,g,m),E=Math.max(c,h,f),b=Math.max(p,g,m),_=Lm(x,v,e,t,n),M=Lm(E,b,e,t,n);let w=s.prevZ,T=s.nextZ;for(;w&&w.z>=_&&T&&T.z<=M;){if(w.x>=x&&w.x<=E&&w.y>=v&&w.y<=b&&w!==i&&w!==l&&Vl(c,p,h,g,f,m,w.x,w.y)&&on(w.prev,w,w.next)>=0||(w=w.prevZ,T.x>=x&&T.x<=E&&T.y>=v&&T.y<=b&&T!==i&&T!==l&&Vl(c,p,h,g,f,m,T.x,T.y)&&on(T.prev,T,T.next)>=0))return!1;T=T.nextZ}for(;w&&w.z>=_;){if(w.x>=x&&w.x<=E&&w.y>=v&&w.y<=b&&w!==i&&w!==l&&Vl(c,p,h,g,f,m,w.x,w.y)&&on(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;T&&T.z<=M;){if(T.x>=x&&T.x<=E&&T.y>=v&&T.y<=b&&T!==i&&T!==l&&Vl(c,p,h,g,f,m,T.x,T.y)&&on(T.prev,T,T.next)>=0)return!1;T=T.nextZ}return!0}function IT(s,e){let t=s;do{const n=t.prev,i=t.next.next;!Wo(n,i)&&yb(n,t,t.next,i)&&fc(n,i)&&fc(i,n)&&(e.push(n.i,t.i,i.i),dc(t),dc(t.next),t=s=i),t=t.next}while(t!==s);return Ia(t)}function PT(s,e,t,n,i,o){let l=s;do{let c=l.next.next;for(;c!==l.prev;){if(l.i!==c.i&&kT(l,c)){let h=bb(l,c);l=Ia(l,l.next),h=Ia(h,h.next),hc(l,e,t,n,i,o,0),hc(h,e,t,n,i,o,0);return}c=c.next}l=l.next}while(l!==s)}function LT(s,e,t,n){const i=[];for(let o=0,l=e.length;o<l;o++){const c=e[o]*n,h=o<l-1?e[o+1]*n:s.length,f=vb(s,c,h,n,!1);f===f.next&&(f.steiner=!0),i.push(BT(f))}i.sort(NT);for(let o=0;o<i.length;o++)t=DT(i[o],t);return t}function NT(s,e){let t=s.x-e.x;if(t===0&&(t=s.y-e.y,t===0)){const n=(s.next.y-s.y)/(s.next.x-s.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=n-i}return t}function DT(s,e){const t=UT(s,e);if(!t)return e;const n=bb(t,s);return Ia(n,n.next),Ia(t,t.next)}function UT(s,e){let t=e;const n=s.x,i=s.y;let o=-1/0,l;if(Wo(s,t))return t;do{if(Wo(s,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const g=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(g<=n&&g>o&&(o=g,l=t.x<t.next.x?t:t.next,g===n))return l}t=t.next}while(t!==e);if(!l)return null;const c=l,h=l.x,f=l.y;let p=1/0;t=l;do{if(n>=t.x&&t.x>=h&&n!==t.x&&_b(i<f?n:o,i,h,f,i<f?o:n,i,t.x,t.y)){const g=Math.abs(i-t.y)/(n-t.x);fc(t,s)&&(g<p||g===p&&(t.x>l.x||t.x===l.x&&FT(l,t)))&&(l=t,p=g)}t=t.next}while(t!==c);return l}function FT(s,e){return on(s.prev,s,e.prev)<0&&on(e.next,s,s.next)<0}function OT(s,e,t,n){let i=s;do i.z===0&&(i.z=Lm(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,zT(i)}function zT(s){let e,t=1;do{let n=s,i;s=null;let o=null;for(e=0;n;){e++;let l=n,c=0;for(let f=0;f<t&&(c++,l=l.nextZ,!!l);f++);let h=t;for(;c>0||h>0&&l;)c!==0&&(h===0||!l||n.z<=l.z)?(i=n,n=n.nextZ,c--):(i=l,l=l.nextZ,h--),o?o.nextZ=i:s=i,i.prevZ=o,o=i;n=l}o.nextZ=null,t*=2}while(e>1);return s}function Lm(s,e,t,n,i){return s=(s-t)*i|0,e=(e-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function BT(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function _b(s,e,t,n,i,o,l,c){return(i-l)*(e-c)>=(s-l)*(o-c)&&(s-l)*(n-c)>=(t-l)*(e-c)&&(t-l)*(o-c)>=(i-l)*(n-c)}function Vl(s,e,t,n,i,o,l,c){return!(s===l&&e===c)&&_b(s,e,t,n,i,o,l,c)}function kT(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!VT(s,e)&&(fc(s,e)&&fc(e,s)&&HT(s,e)&&(on(s.prev,s,e.prev)||on(s,e.prev,e))||Wo(s,e)&&on(s.prev,s,s.next)>0&&on(e.prev,e,e.next)>0)}function on(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function Wo(s,e){return s.x===e.x&&s.y===e.y}function yb(s,e,t,n){const i=eh(on(s,e,t)),o=eh(on(s,e,n)),l=eh(on(t,n,s)),c=eh(on(t,n,e));return!!(i!==o&&l!==c||i===0&&Qu(s,t,e)||o===0&&Qu(s,n,e)||l===0&&Qu(t,s,n)||c===0&&Qu(t,e,n))}function Qu(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function eh(s){return s>0?1:s<0?-1:0}function VT(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&yb(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function fc(s,e){return on(s.prev,s,s.next)<0?on(s,e,s.next)>=0&&on(s,s.prev,e)>=0:on(s,e,s.prev)<0||on(s,s.next,e)<0}function HT(s,e){let t=s,n=!1;const i=(s.x+e.x)/2,o=(s.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&i<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function bb(s,e){const t=Nm(s.i,s.x,s.y),n=Nm(e.i,e.x,e.y),i=s.next,o=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function Kv(s,e,t,n){const i=Nm(s,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 dc(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Nm(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function GT(s,e,t,n){let i=0;for(let o=e,l=t-n;o<t;o+=n)i+=(s[l]-s[o])*(s[o+1]+s[l+1]),l=o;return i}class WT{static triangulate(e,t,n=2){return AT(e,t,n)}}class ss{static area(e){const t=e.length;let n=0;for(let i=t-1,o=0;o<t;i=o++)n+=e[i].x*e[o].y-e[o].x*e[i].y;return n*.5}static isClockWise(e){return ss.area(e)<0}static triangulateShape(e,t){const n=[],i=[],o=[];Jv(e),Qv(n,e);let l=e.length;t.forEach(Jv);for(let h=0;h<t.length;h++)i.push(l),l+=t[h].length,Qv(n,t[h]);const c=WT.triangulate(n,i);for(let h=0;h<c.length;h+=3)o.push(c.slice(h,h+3));return o}}function Jv(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function Qv(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class Hf extends _t{constructor(e=new wa([new pe(.5,.5),new pe(-.5,.5),new pe(-.5,-.5),new pe(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],o=[];for(let c=0,h=e.length;c<h;c++){const f=e[c];l(f)}this.setAttribute("position",new et(i,3)),this.setAttribute("uv",new et(o,2)),this.computeVertexNormals();function l(c){const h=[],f=t.curveSegments!==void 0?t.curveSegments:12,p=t.steps!==void 0?t.steps:1,g=t.depth!==void 0?t.depth:1;let m=t.bevelEnabled!==void 0?t.bevelEnabled:!0,x=t.bevelThickness!==void 0?t.bevelThickness:.2,v=t.bevelSize!==void 0?t.bevelSize:x-.1,E=t.bevelOffset!==void 0?t.bevelOffset:0,b=t.bevelSegments!==void 0?t.bevelSegments:3;const _=t.extrudePath,M=t.UVGenerator!==void 0?t.UVGenerator:XT;let w,T=!1,P,R,U,A;if(_){w=_.getSpacedPoints(p),T=!0,m=!1;const de=_.isCatmullRomCurve3?_.closed:!1;P=_.computeFrenetFrames(p,de),R=new O,U=new O,A=new O}m||(b=0,x=0,v=0,E=0);const I=c.extractPoints(f);let B=I.shape;const F=I.holes;if(!ss.isClockWise(B)){B=B.reverse();for(let de=0,_e=F.length;de<_e;de++){const me=F[de];ss.isClockWise(me)&&(F[de]=me.reverse())}}function H(de){const me=10000000000000001e-36;let Te=de[0];for(let z=1;z<=de.length;z++){const nt=z%de.length,Fe=de[nt],rt=Fe.x-Te.x,Ae=Fe.y-Te.y,D=rt*rt+Ae*Ae,C=Math.max(Math.abs(Fe.x),Math.abs(Fe.y),Math.abs(Te.x),Math.abs(Te.y)),X=me*C*C;if(D<=X){de.splice(nt,1),z--;continue}Te=Fe}}H(B),F.forEach(H);const Z=F.length,W=B;for(let de=0;de<Z;de++){const _e=F[de];B=B.concat(_e)}function $(de,_e,me){return _e||ot("ExtrudeGeometry: vec does not exist"),de.clone().addScaledVector(_e,me)}const Y=B.length;function ge(de,_e,me){let Te,z,nt;const Fe=de.x-_e.x,rt=de.y-_e.y,Ae=me.x-de.x,D=me.y-de.y,C=Fe*Fe+rt*rt,X=Fe*D-rt*Ae;if(Math.abs(X)>Number.EPSILON){const se=Math.sqrt(C),fe=Math.sqrt(Ae*Ae+D*D),ae=_e.x-rt/se,je=_e.y+Fe/se,Ie=me.x-D/fe,it=me.y+Ae/fe,ut=((Ie-ae)*D-(it-je)*Ae)/(Fe*D-rt*Ae);Te=ae+Fe*ut-de.x,z=je+rt*ut-de.y;const Se=Te*Te+z*z;if(Se<=2)return new pe(Te,z);nt=Math.sqrt(Se/2)}else{let se=!1;Fe>Number.EPSILON?Ae>Number.EPSILON&&(se=!0):Fe<-Number.EPSILON?Ae<-Number.EPSILON&&(se=!0):Math.sign(rt)===Math.sign(D)&&(se=!0),se?(Te=-rt,z=Fe,nt=Math.sqrt(C)):(Te=Fe,z=rt,nt=Math.sqrt(C/2))}return new pe(Te/nt,z/nt)}const he=[];for(let de=0,_e=W.length,me=_e-1,Te=de+1;de<_e;de++,me++,Te++)me===_e&&(me=0),Te===_e&&(Te=0),he[de]=ge(W[de],W[me],W[Te]);const Ee=[];let xe,ve=he.concat();for(let de=0,_e=Z;de<_e;de++){const me=F[de];xe=[];for(let Te=0,z=me.length,nt=z-1,Fe=Te+1;Te<z;Te++,nt++,Fe++)nt===z&&(nt=0),Fe===z&&(Fe=0),xe[Te]=ge(me[Te],me[nt],me[Fe]);Ee.push(xe),ve=ve.concat(xe)}let Xe;if(b===0)Xe=ss.triangulateShape(W,F);else{const de=[],_e=[];for(let me=0;me<b;me++){const Te=me/b,z=x*Math.cos(Te*Math.PI/2),nt=v*Math.sin(Te*Math.PI/2)+E;for(let Fe=0,rt=W.length;Fe<rt;Fe++){const Ae=$(W[Fe],he[Fe],nt);Qe(Ae.x,Ae.y,-z),Te===0&&de.push(Ae)}for(let Fe=0,rt=Z;Fe<rt;Fe++){const Ae=F[Fe];xe=Ee[Fe];const D=[];for(let C=0,X=Ae.length;C<X;C++){const se=$(Ae[C],xe[C],nt);Qe(se.x,se.y,-z),Te===0&&D.push(se)}Te===0&&_e.push(D)}}Xe=ss.triangulateShape(de,_e)}const lt=Xe.length,yt=v+E;for(let de=0;de<Y;de++){const _e=m?$(B[de],ve[de],yt):B[de];T?(U.copy(P.normals[0]).multiplyScalar(_e.x),R.copy(P.binormals[0]).multiplyScalar(_e.y),A.copy(w[0]).add(U).add(R),Qe(A.x,A.y,A.z)):Qe(_e.x,_e.y,0)}for(let de=1;de<=p;de++)for(let _e=0;_e<Y;_e++){const me=m?$(B[_e],ve[_e],yt):B[_e];T?(U.copy(P.normals[de]).multiplyScalar(me.x),R.copy(P.binormals[de]).multiplyScalar(me.y),A.copy(w[de]).add(U).add(R),Qe(A.x,A.y,A.z)):Qe(me.x,me.y,g/p*de)}for(let de=b-1;de>=0;de--){const _e=de/b,me=x*Math.cos(_e*Math.PI/2),Te=v*Math.sin(_e*Math.PI/2)+E;for(let z=0,nt=W.length;z<nt;z++){const Fe=$(W[z],he[z],Te);Qe(Fe.x,Fe.y,g+me)}for(let z=0,nt=F.length;z<nt;z++){const Fe=F[z];xe=Ee[z];for(let rt=0,Ae=Fe.length;rt<Ae;rt++){const D=$(Fe[rt],xe[rt],Te);T?Qe(D.x,D.y+w[p-1].y,w[p-1].x+me):Qe(D.x,D.y,g+me)}}}ue(),Re();function ue(){const de=i.length/3;if(m){let _e=0,me=Y*_e;for(let Te=0;Te<lt;Te++){const z=Xe[Te];Ze(z[2]+me,z[1]+me,z[0]+me)}_e=p+b*2,me=Y*_e;for(let Te=0;Te<lt;Te++){const z=Xe[Te];Ze(z[0]+me,z[1]+me,z[2]+me)}}else{for(let _e=0;_e<lt;_e++){const me=Xe[_e];Ze(me[2],me[1],me[0])}for(let _e=0;_e<lt;_e++){const me=Xe[_e];Ze(me[0]+Y*p,me[1]+Y*p,me[2]+Y*p)}}n.addGroup(de,i.length/3-de,0)}function Re(){const de=i.length/3;let _e=0;we(W,_e),_e+=W.length;for(let me=0,Te=F.length;me<Te;me++){const z=F[me];we(z,_e),_e+=z.length}n.addGroup(de,i.length/3-de,1)}function we(de,_e){let me=de.length;for(;--me>=0;){const Te=me;let z=me-1;z<0&&(z=de.length-1);for(let nt=0,Fe=p+b*2;nt<Fe;nt++){const rt=Y*nt,Ae=Y*(nt+1),D=_e+Te+rt,C=_e+z+rt,X=_e+z+Ae,se=_e+Te+Ae;Ge(D,C,X,se)}}}function Qe(de,_e,me){h.push(de),h.push(_e),h.push(me)}function Ze(de,_e,me){xt(de),xt(_e),xt(me);const Te=i.length/3,z=M.generateTopUV(n,i,Te-3,Te-2,Te-1);tt(z[0]),tt(z[1]),tt(z[2])}function Ge(de,_e,me,Te){xt(de),xt(_e),xt(Te),xt(_e),xt(me),xt(Te);const z=i.length/3,nt=M.generateSideWallUV(n,i,z-6,z-3,z-2,z-1);tt(nt[0]),tt(nt[1]),tt(nt[3]),tt(nt[1]),tt(nt[2]),tt(nt[3])}function xt(de){i.push(h[de*3+0]),i.push(h[de*3+1]),i.push(h[de*3+2])}function tt(de){o.push(de.x),o.push(de.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 jT(t,n,e)}static fromJSON(e,t){const n=[];for(let o=0,l=e.shapes.length;o<l;o++){const c=t[e.shapes[o]];n.push(c)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new ff[i.type]().fromJSON(i)),new Hf(n,e.options)}}const XT={generateTopUV:function(s,e,t,n,i){const o=e[t*3],l=e[t*3+1],c=e[n*3],h=e[n*3+1],f=e[i*3],p=e[i*3+1];return[new pe(o,l),new pe(c,h),new pe(f,p)]},generateSideWallUV:function(s,e,t,n,i,o){const l=e[t*3],c=e[t*3+1],h=e[t*3+2],f=e[n*3],p=e[n*3+1],g=e[n*3+2],m=e[i*3],x=e[i*3+1],v=e[i*3+2],E=e[o*3],b=e[o*3+1],_=e[o*3+2];return Math.abs(c-p)<Math.abs(l-f)?[new pe(l,1-h),new pe(f,1-g),new pe(m,1-v),new pe(E,1-_)]:[new pe(c,1-h),new pe(p,1-g),new pe(x,1-v),new pe(b,1-_)]}};function jT(s,e,t){if(t.shapes=[],Array.isArray(s))for(let n=0,i=s.length;n<i;n++){const o=s[n];t.shapes.push(o.uuid)}else t.shapes.push(s.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Gf extends Lr{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],o=[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,o,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Gf(e.radius,e.detail)}}class Wf extends _t{constructor(e=[new pe(0,-.5),new pe(.5,0),new pe(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=pt(i,0,Math.PI*2);const o=[],l=[],c=[],h=[],f=[],p=1/t,g=new O,m=new pe,x=new O,v=new O,E=new O;let b=0,_=0;for(let M=0;M<=e.length-1;M++)switch(M){case 0:b=e[M+1].x-e[M].x,_=e[M+1].y-e[M].y,x.x=_*1,x.y=-b,x.z=_*0,E.copy(x),x.normalize(),h.push(x.x,x.y,x.z);break;case e.length-1:h.push(E.x,E.y,E.z);break;default:b=e[M+1].x-e[M].x,_=e[M+1].y-e[M].y,x.x=_*1,x.y=-b,x.z=_*0,v.copy(x),x.x+=E.x,x.y+=E.y,x.z+=E.z,x.normalize(),h.push(x.x,x.y,x.z),E.copy(v)}for(let M=0;M<=t;M++){const w=n+M*p*i,T=Math.sin(w),P=Math.cos(w);for(let R=0;R<=e.length-1;R++){g.x=e[R].x*T,g.y=e[R].y,g.z=e[R].x*P,l.push(g.x,g.y,g.z),m.x=M/t,m.y=R/(e.length-1),c.push(m.x,m.y);const U=h[3*R+0]*T,A=h[3*R+1],I=h[3*R+0]*P;f.push(U,A,I)}}for(let M=0;M<t;M++)for(let w=0;w<e.length-1;w++){const T=w+M*e.length,P=T,R=T+e.length,U=T+e.length+1,A=T+1;o.push(P,R,A),o.push(U,A,R)}this.setIndex(o),this.setAttribute("position",new et(l,3)),this.setAttribute("uv",new et(c,2)),this.setAttribute("normal",new et(f,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wf(e.points,e.segments,e.phiStart,e.phiLength)}}class Tc extends Lr{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 Tc(e.radius,e.detail)}}class $o extends _t{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const o=e/2,l=t/2,c=Math.floor(n),h=Math.floor(i),f=c+1,p=h+1,g=e/c,m=t/h,x=[],v=[],E=[],b=[];for(let _=0;_<p;_++){const M=_*m-l;for(let w=0;w<f;w++){const T=w*g-o;v.push(T,-M,0),E.push(0,0,1),b.push(w/c),b.push(1-_/h)}}for(let _=0;_<h;_++)for(let M=0;M<c;M++){const w=M+f*_,T=M+f*(_+1),P=M+1+f*(_+1),R=M+1+f*_;x.push(w,T,R),x.push(T,P,R)}this.setIndex(x),this.setAttribute("position",new et(v,3)),this.setAttribute("normal",new et(E,3)),this.setAttribute("uv",new et(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $o(e.width,e.height,e.widthSegments,e.heightSegments)}}class Xf extends _t{constructor(e=.5,t=1,n=32,i=1,o=0,l=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:o,thetaLength:l},n=Math.max(3,n),i=Math.max(1,i);const c=[],h=[],f=[],p=[];let g=e;const m=(t-e)/i,x=new O,v=new pe;for(let E=0;E<=i;E++){for(let b=0;b<=n;b++){const _=o+b/n*l;x.x=g*Math.cos(_),x.y=g*Math.sin(_),h.push(x.x,x.y,x.z),f.push(0,0,1),v.x=(x.x/t+1)/2,v.y=(x.y/t+1)/2,p.push(v.x,v.y)}g+=m}for(let E=0;E<i;E++){const b=E*(n+1);for(let _=0;_<n;_++){const M=_+b,w=M,T=M+n+1,P=M+n+2,R=M+1;c.push(w,T,R),c.push(T,P,R)}}this.setIndex(c),this.setAttribute("position",new et(h,3)),this.setAttribute("normal",new et(f,3)),this.setAttribute("uv",new et(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xf(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class jf extends _t{constructor(e=new wa([new pe(0,.5),new pe(-.5,-.5),new pe(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],o=[],l=[];let c=0,h=0;if(Array.isArray(e)===!1)f(e);else for(let p=0;p<e.length;p++)f(e[p]),this.addGroup(c,h,p),c+=h,h=0;this.setIndex(n),this.setAttribute("position",new et(i,3)),this.setAttribute("normal",new et(o,3)),this.setAttribute("uv",new et(l,2));function f(p){const g=i.length/3,m=p.extractPoints(t);let x=m.shape;const v=m.holes;ss.isClockWise(x)===!1&&(x=x.reverse());for(let b=0,_=v.length;b<_;b++){const M=v[b];ss.isClockWise(M)===!0&&(v[b]=M.reverse())}const E=ss.triangulateShape(x,v);for(let b=0,_=v.length;b<_;b++){const M=v[b];x=x.concat(M)}for(let b=0,_=x.length;b<_;b++){const M=x[b];i.push(M.x,M.y,0),o.push(0,0,1),l.push(M.x,M.y)}for(let b=0,_=E.length;b<_;b++){const M=E[b],w=M[0]+g,T=M[1]+g,P=M[2]+g;n.push(w,T,P),h+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return qT(t,e)}static fromJSON(e,t){const n=[];for(let i=0,o=e.shapes.length;i<o;i++){const l=t[e.shapes[i]];n.push(l)}return new jf(n,e.curveSegments)}}function qT(s,e){if(e.shapes=[],Array.isArray(s))for(let t=0,n=s.length;t<n;t++){const i=s[t];e.shapes.push(i.uuid)}else e.shapes.push(s.uuid);return e}class Ac extends _t{constructor(e=1,t=32,n=16,i=0,o=Math.PI*2,l=0,c=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:o,thetaStart:l,thetaLength:c},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const h=Math.min(l+c,Math.PI);let f=0;const p=[],g=new O,m=new O,x=[],v=[],E=[],b=[];for(let _=0;_<=n;_++){const M=[],w=_/n;let T=0;_===0&&l===0?T=.5/t:_===n&&h===Math.PI&&(T=-.5/t);for(let P=0;P<=t;P++){const R=P/t;g.x=-e*Math.cos(i+R*o)*Math.sin(l+w*c),g.y=e*Math.cos(l+w*c),g.z=e*Math.sin(i+R*o)*Math.sin(l+w*c),v.push(g.x,g.y,g.z),m.copy(g).normalize(),E.push(m.x,m.y,m.z),b.push(R+T,1-w),M.push(f++)}p.push(M)}for(let _=0;_<n;_++)for(let M=0;M<t;M++){const w=p[_][M+1],T=p[_][M],P=p[_+1][M],R=p[_+1][M+1];(_!==0||l>0)&&x.push(w,T,R),(_!==n-1||h<Math.PI)&&x.push(T,P,R)}this.setIndex(x),this.setAttribute("position",new et(v,3)),this.setAttribute("normal",new et(E,3)),this.setAttribute("uv",new et(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ac(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class qf extends Lr{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 qf(e.radius,e.detail)}}class Yf extends _t{constructor(e=1,t=.4,n=12,i=48,o=Math.PI*2,l=0,c=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:o,thetaStart:l,thetaLength:c},n=Math.floor(n),i=Math.floor(i);const h=[],f=[],p=[],g=[],m=new O,x=new O,v=new O;for(let E=0;E<=n;E++){const b=l+E/n*c;for(let _=0;_<=i;_++){const M=_/i*o;x.x=(e+t*Math.cos(b))*Math.cos(M),x.y=(e+t*Math.cos(b))*Math.sin(M),x.z=t*Math.sin(b),f.push(x.x,x.y,x.z),m.x=e*Math.cos(M),m.y=e*Math.sin(M),v.subVectors(x,m).normalize(),p.push(v.x,v.y,v.z),g.push(_/i),g.push(E/n)}}for(let E=1;E<=n;E++)for(let b=1;b<=i;b++){const _=(i+1)*E+b-1,M=(i+1)*(E-1)+b-1,w=(i+1)*(E-1)+b,T=(i+1)*E+b;h.push(_,M,T),h.push(M,w,T)}this.setIndex(h),this.setAttribute("position",new et(f,3)),this.setAttribute("normal",new et(p,3)),this.setAttribute("uv",new et(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Yf(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class $f extends _t{constructor(e=1,t=.4,n=64,i=8,o=2,l=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:o,q:l},n=Math.floor(n),i=Math.floor(i);const c=[],h=[],f=[],p=[],g=new O,m=new O,x=new O,v=new O,E=new O,b=new O,_=new O;for(let w=0;w<=n;++w){const T=w/n*o*Math.PI*2;M(T,o,l,e,x),M(T+.01,o,l,e,v),b.subVectors(v,x),_.addVectors(v,x),E.crossVectors(b,_),_.crossVectors(E,b),E.normalize(),_.normalize();for(let P=0;P<=i;++P){const R=P/i*Math.PI*2,U=-t*Math.cos(R),A=t*Math.sin(R);g.x=x.x+(U*_.x+A*E.x),g.y=x.y+(U*_.y+A*E.y),g.z=x.z+(U*_.z+A*E.z),h.push(g.x,g.y,g.z),m.subVectors(g,x).normalize(),f.push(m.x,m.y,m.z),p.push(w/n),p.push(P/i)}}for(let w=1;w<=n;w++)for(let T=1;T<=i;T++){const P=(i+1)*(w-1)+(T-1),R=(i+1)*w+(T-1),U=(i+1)*w+T,A=(i+1)*(w-1)+T;c.push(P,R,A),c.push(R,U,A)}this.setIndex(c),this.setAttribute("position",new et(h,3)),this.setAttribute("normal",new et(f,3)),this.setAttribute("uv",new et(p,2));function M(w,T,P,R,U){const A=Math.cos(w),I=Math.sin(w),B=P/T*w,F=Math.cos(B);U.x=R*(2+F)*.5*A,U.y=R*(2+F)*I*.5,U.z=R*Math.sin(B)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $f(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Zf extends _t{constructor(e=new Sg(new O(-1,-1,0),new O(-1,1,0),new O(1,1,0)),t=64,n=1,i=8,o=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:o};const l=e.computeFrenetFrames(t,o);this.tangents=l.tangents,this.normals=l.normals,this.binormals=l.binormals;const c=new O,h=new O,f=new pe;let p=new O;const g=[],m=[],x=[],v=[];E(),this.setIndex(v),this.setAttribute("position",new et(g,3)),this.setAttribute("normal",new et(m,3)),this.setAttribute("uv",new et(x,2));function E(){for(let w=0;w<t;w++)b(w);b(o===!1?t:0),M(),_()}function b(w){p=e.getPointAt(w/t,p);const T=l.normals[w],P=l.binormals[w];for(let R=0;R<=i;R++){const U=R/i*Math.PI*2,A=Math.sin(U),I=-Math.cos(U);h.x=I*T.x+A*P.x,h.y=I*T.y+A*P.y,h.z=I*T.z+A*P.z,h.normalize(),m.push(h.x,h.y,h.z),c.x=p.x+n*h.x,c.y=p.y+n*h.y,c.z=p.z+n*h.z,g.push(c.x,c.y,c.z)}}function _(){for(let w=1;w<=t;w++)for(let T=1;T<=i;T++){const P=(i+1)*(w-1)+(T-1),R=(i+1)*w+(T-1),U=(i+1)*w+T,A=(i+1)*(w-1)+T;v.push(P,R,A),v.push(R,U,A)}}function M(){for(let w=0;w<=t;w++)for(let T=0;T<=i;T++)f.x=w/t,f.y=T/i,x.push(f.x,f.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 Zf(new ff[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Sb extends _t{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new O,o=new O;if(e.index!==null){const l=e.attributes.position,c=e.index;let h=e.groups;h.length===0&&(h=[{start:0,count:c.count,materialIndex:0}]);for(let f=0,p=h.length;f<p;++f){const g=h[f],m=g.start,x=g.count;for(let v=m,E=m+x;v<E;v+=3)for(let b=0;b<3;b++){const _=c.getX(v+b),M=c.getX(v+(b+1)%3);i.fromBufferAttribute(l,_),o.fromBufferAttribute(l,M),e_(i,o,n)===!0&&(t.push(i.x,i.y,i.z),t.push(o.x,o.y,o.z))}}}else{const l=e.attributes.position;for(let c=0,h=l.count/3;c<h;c++)for(let f=0;f<3;f++){const p=3*c+f,g=3*c+(f+1)%3;i.fromBufferAttribute(l,p),o.fromBufferAttribute(l,g),e_(i,o,n)===!0&&(t.push(i.x,i.y,i.z),t.push(o.x,o.y,o.z))}}this.setAttribute("position",new et(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function e_(s,e,t){const n=`${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}var t_=Object.freeze({__proto__:null,BoxGeometry:Na,CapsuleGeometry:zf,CircleGeometry:Bf,ConeGeometry:wc,CylinderGeometry:Ec,DodecahedronGeometry:kf,EdgesGeometry:fb,ExtrudeGeometry:Hf,IcosahedronGeometry:Gf,LatheGeometry:Wf,OctahedronGeometry:Tc,PlaneGeometry:$o,PolyhedronGeometry:Lr,RingGeometry:Xf,ShapeGeometry:jf,SphereGeometry:Ac,TetrahedronGeometry:qf,TorusGeometry:Yf,TorusKnotGeometry:$f,TubeGeometry:Zf,WireframeGeometry:Sb});class Mb extends Zn{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}}function Xo(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(He("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 ei(s){const e={};for(let t=0;t<s.length;t++){const n=Xo(s[t]);for(const i in n)e[i]=n[i]}return e}function YT(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function Eb(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Dt.workingColorSpace}const wb={clone:Xo,merge:ei};var $T=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
3
|
}`,ZT=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|