OrbitControls.B-WH-rzu.js 482 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840
  1. /**
  2. * @license
  3. * Copyright 2010-2025 Three.js Authors
  4. * SPDX-License-Identifier: MIT
  5. */const Qn={ROTATE:0,DOLLY:1,PAN:2},$n={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Fo=0,Ks=1,Oo=2,Ka=1,Bo=2,tn=3,_n=0,Te=1,en=2,pn=0,ti=1,Zs=2,js=3,$s=4,zo=5,wn=100,Ho=101,Vo=102,Go=103,ko=104,Wo=200,Xo=201,Yo=202,qo=203,Gr=204,kr=205,Ko=206,Zo=207,jo=208,$o=209,Jo=210,Qo=211,tl=212,el=213,nl=214,Wr=0,Xr=1,Yr=2,ni=3,qr=4,Kr=5,Zr=6,jr=7,Za=0,il=1,rl=2,mn=0,sl=1,al=2,ol=3,ll=4,cl=5,hl=6,ul=7,ja=300,ii=301,ri=302,$r=303,Jr=304,sr=306,Qr=1e3,Pn=1001,ts=1002,ze=1003,dl=1004,Ri=1005,Ge=1006,hr=1007,Dn=1008,Ye=1009,$a=1010,Ja=1011,mi=1012,Ds=1013,Ln=1014,nn=1015,Mi=1016,Ls=1017,Us=1018,_i=1020,Qa=35902,to=35899,eo=1021,no=1022,Be=1023,gi=1026,vi=1027,io=1028,Is=1029,ro=1030,Ns=1031,Fs=1033,ji=33776,$i=33777,Ji=33778,Qi=33779,es=35840,ns=35841,is=35842,rs=35843,ss=36196,as=37492,os=37496,ls=37808,cs=37809,hs=37810,us=37811,ds=37812,fs=37813,ps=37814,ms=37815,_s=37816,gs=37817,vs=37818,xs=37819,Ms=37820,Ss=37821,Es=36492,ys=36494,Ts=36495,bs=36283,As=36284,Rs=36285,ws=36286,fl=3200,pl=3201,so=0,ml=1,fn="",Le="srgb",si="srgb-linear",nr="linear",qt="srgb",On=7680,Js=519,_l=512,gl=513,vl=514,ao=515,xl=516,Ml=517,Sl=518,El=519,Qs=35044,ta="300 es",ke=2e3,ir=2001;class Nn{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const r=n[t];if(r!==void 0){const s=r.indexOf(e);s!==-1&&r.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,t);t.target=null}}}const me=["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"],tr=Math.PI/180,Cs=180/Math.PI;function Si(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(me[i&255]+me[i>>8&255]+me[i>>16&255]+me[i>>24&255]+"-"+me[t&255]+me[t>>8&255]+"-"+me[t>>16&15|64]+me[t>>24&255]+"-"+me[e&63|128]+me[e>>8&255]+"-"+me[e>>16&255]+me[e>>24&255]+me[n&255]+me[n>>8&255]+me[n>>16&255]+me[n>>24&255]).toLowerCase()}function Bt(i,t,e){return Math.max(t,Math.min(e,i))}function yl(i,t){return(i%t+t)%t}function ur(i,t,e){return(1-e)*i+e*t}function ci(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Ee(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const Tl={DEG2RAD:tr};class Lt{constructor(t=0,e=0){Lt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Bt(this.x,t.x,e.x),this.y=Bt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Bt(this.x,t,e),this.y=Bt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Bt(n,t,e))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Bt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),r=Math.sin(e),s=this.x-t.x,a=this.y-t.y;return this.x=s*n-a*r+t.x,this.y=s*r+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Un{constructor(t=0,e=0,n=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=r}static slerpFlat(t,e,n,r,s,a,o){let c=n[r+0],l=n[r+1],u=n[r+2],d=n[r+3];const f=s[a+0],m=s[a+1],v=s[a+2],M=s[a+3];if(o===0){t[e+0]=c,t[e+1]=l,t[e+2]=u,t[e+3]=d;return}if(o===1){t[e+0]=f,t[e+1]=m,t[e+2]=v,t[e+3]=M;return}if(d!==M||c!==f||l!==m||u!==v){let p=1-o;const h=c*f+l*m+u*v+d*M,A=h>=0?1:-1,T=1-h*h;if(T>Number.EPSILON){const C=Math.sqrt(T),R=Math.atan2(C,h*A);p=Math.sin(p*R)/C,o=Math.sin(o*R)/C}const E=o*A;if(c=c*p+f*E,l=l*p+m*E,u=u*p+v*E,d=d*p+M*E,p===1-o){const C=1/Math.sqrt(c*c+l*l+u*u+d*d);c*=C,l*=C,u*=C,d*=C}}t[e]=c,t[e+1]=l,t[e+2]=u,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,r,s,a){const o=n[r],c=n[r+1],l=n[r+2],u=n[r+3],d=s[a],f=s[a+1],m=s[a+2],v=s[a+3];return t[e]=o*v+u*d+c*m-l*f,t[e+1]=c*v+u*f+l*d-o*m,t[e+2]=l*v+u*m+o*f-c*d,t[e+3]=u*v-o*d-c*f-l*m,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,r=t._y,s=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(r/2),d=o(s/2),f=c(n/2),m=c(r/2),v=c(s/2);switch(a){case"XYZ":this._x=f*u*d+l*m*v,this._y=l*m*d-f*u*v,this._z=l*u*v+f*m*d,this._w=l*u*d-f*m*v;break;case"YXZ":this._x=f*u*d+l*m*v,this._y=l*m*d-f*u*v,this._z=l*u*v-f*m*d,this._w=l*u*d+f*m*v;break;case"ZXY":this._x=f*u*d-l*m*v,this._y=l*m*d+f*u*v,this._z=l*u*v+f*m*d,this._w=l*u*d-f*m*v;break;case"ZYX":this._x=f*u*d-l*m*v,this._y=l*m*d+f*u*v,this._z=l*u*v-f*m*d,this._w=l*u*d+f*m*v;break;case"YZX":this._x=f*u*d+l*m*v,this._y=l*m*d+f*u*v,this._z=l*u*v-f*m*d,this._w=l*u*d-f*m*v;break;case"XZY":this._x=f*u*d-l*m*v,this._y=l*m*d-f*u*v,this._z=l*u*v+f*m*d,this._w=l*u*d+f*m*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],s=e[8],a=e[1],o=e[5],c=e[9],l=e[2],u=e[6],d=e[10],f=n+o+d;if(f>0){const m=.5/Math.sqrt(f+1);this._w=.25/m,this._x=(u-c)*m,this._y=(s-l)*m,this._z=(a-r)*m}else if(n>o&&n>d){const m=2*Math.sqrt(1+n-o-d);this._w=(u-c)/m,this._x=.25*m,this._y=(r+a)/m,this._z=(s+l)/m}else if(o>d){const m=2*Math.sqrt(1+o-n-d);this._w=(s-l)/m,this._x=(r+a)/m,this._y=.25*m,this._z=(c+u)/m}else{const m=2*Math.sqrt(1+d-n-o);this._w=(a-r)/m,this._x=(s+l)/m,this._y=(c+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Bt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const r=Math.min(1,e/n);return this.slerp(t,r),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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,s=t._z,a=t._w,o=e._x,c=e._y,l=e._z,u=e._w;return this._x=n*u+a*o+r*l-s*c,this._y=r*u+a*c+s*o-n*l,this._z=s*u+a*l+n*c-r*o,this._w=a*u-n*o-r*c-s*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,r=this._y,s=this._z,a=this._w;let o=a*t._w+n*t._x+r*t._y+s*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const m=1-e;return this._w=m*a+e*this._w,this._x=m*n+e*this._x,this._y=m*r+e*this._y,this._z=m*s+e*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,o),d=Math.sin((1-e)*u)/l,f=Math.sin(e*u)/l;return this._w=a*d+this._w*f,this._x=n*d+this._x*f,this._y=r*d+this._y*f,this._z=s*d+this._z*f,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(t),r*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class N{constructor(t=0,e=0,n=0){N.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(ea.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ea.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*r,this.y=s[1]*e+s[4]*n+s[7]*r,this.z=s[2]*e+s[5]*n+s[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=t.elements,a=1/(s[3]*e+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*e+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*e+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,s=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*r-o*n),u=2*(o*e-s*r),d=2*(s*n-a*e);return this.x=e+c*l+a*d-o*u,this.y=n+c*u+o*l-s*d,this.z=r+c*d+s*u-a*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*r,this.y=s[1]*e+s[5]*n+s[9]*r,this.z=s[2]*e+s[6]*n+s[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Bt(this.x,t.x,e.x),this.y=Bt(this.y,t.y,e.y),this.z=Bt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Bt(this.x,t,e),this.y=Bt(this.y,t,e),this.z=Bt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Bt(n,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,r=t.y,s=t.z,a=e.x,o=e.y,c=e.z;return this.x=r*c-s*o,this.y=s*a-n*c,this.z=n*o-r*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return dr.copy(this).projectOnVector(t),this.sub(dr)}reflect(t){return this.sub(dr.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Bt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const dr=new N,ea=new Un;class It{constructor(t,e,n,r,s,a,o,c,l){It.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,a,o,c,l)}set(t,e,n,r,s,a,o,c,l){const u=this.elements;return u[0]=t,u[1]=r,u[2]=o,u[3]=e,u[4]=s,u[5]=c,u[6]=n,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,s=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],u=n[4],d=n[7],f=n[2],m=n[5],v=n[8],M=r[0],p=r[3],h=r[6],A=r[1],T=r[4],E=r[7],C=r[2],R=r[5],D=r[8];return s[0]=a*M+o*A+c*C,s[3]=a*p+o*T+c*R,s[6]=a*h+o*E+c*D,s[1]=l*M+u*A+d*C,s[4]=l*p+u*T+d*R,s[7]=l*h+u*E+d*D,s[2]=f*M+m*A+v*C,s[5]=f*p+m*T+v*R,s[8]=f*h+m*E+v*D,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8];return e*a*u-e*o*l-n*s*u+n*o*c+r*s*l-r*a*c}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=u*a-o*l,f=o*c-u*s,m=l*s-a*c,v=e*d+n*f+r*m;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const M=1/v;return t[0]=d*M,t[1]=(r*l-u*n)*M,t[2]=(o*n-r*a)*M,t[3]=f*M,t[4]=(u*e-r*c)*M,t[5]=(r*s-o*e)*M,t[6]=m*M,t[7]=(n*c-l*e)*M,t[8]=(a*e-n*s)*M,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,r,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*a+l*o)+a+t,-r*l,r*c,-r*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(fr.makeScale(t,e)),this}rotate(t){return this.premultiply(fr.makeRotation(-t)),this}translate(t,e){return this.premultiply(fr.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let r=0;r<9;r++)if(e[r]!==n[r])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const fr=new It;function oo(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function rr(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function bl(){const i=rr("canvas");return i.style.display="block",i}const na={};function xi(i){i in na||(na[i]=!0,console.warn(i))}function Al(i,t,e){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:n()}}setTimeout(s,e)})}const ia=new It().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ra=new It().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Rl(){const i={enabled:!0,workingColorSpace:si,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===qt&&(r.r=sn(r.r),r.g=sn(r.g),r.b=sn(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===qt&&(r.r=ei(r.r),r.g=ei(r.g),r.b=ei(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===fn?nr:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return xi("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return xi("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[si]:{primaries:t,whitePoint:n,transfer:nr,toXYZ:ia,fromXYZ:ra,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Le},outputColorSpaceConfig:{drawingBufferColorSpace:Le}},[Le]:{primaries:t,whitePoint:n,transfer:qt,toXYZ:ia,fromXYZ:ra,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Le}}}),i}const Gt=Rl();function sn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ei(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Bn;class wl{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{Bn===void 0&&(Bn=rr("canvas")),Bn.width=t.width,Bn.height=t.height;const r=Bn.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height),n=Bn}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=rr("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const r=n.getImageData(0,0,t.width,t.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=sn(s[a]/255)*255;return n.putImageData(r,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(sn(e[n]/255)*255):e[n]=sn(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Cl=0;class Os{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Cl++}),this.uuid=Si(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(pr(r[a].image)):s.push(pr(r[a]))}else s=pr(r);n.url=s}return e||(t.images[this.uuid]=n),n}}function pr(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?wl.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Pl=0;const mr=new N;class Me extends Nn{constructor(t=Me.DEFAULT_IMAGE,e=Me.DEFAULT_MAPPING,n=Pn,r=Pn,s=Ge,a=Dn,o=Be,c=Ye,l=Me.DEFAULT_ANISOTROPY,u=fn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Pl++}),this.uuid=Si(),this.name="",this.source=new Os(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Lt(0,0),this.repeat=new Lt(1,1),this.center=new Lt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new It,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(mr).x}get height(){return this.source.getSize(mr).y}get depth(){return this.source.getSize(mr).z}get image(){return this.source.data}set image(t=null){this.source.data=t}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(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const r=this[e];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==ja)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Qr:t.x=t.x-Math.floor(t.x);break;case Pn:t.x=t.x<0?0:1;break;case ts:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Qr:t.y=t.y-Math.floor(t.y);break;case Pn:t.y=t.y<0?0:1;break;case ts:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Me.DEFAULT_IMAGE=null;Me.DEFAULT_MAPPING=ja;Me.DEFAULT_ANISOTROPY=1;class se{constructor(t=0,e=0,n=0,r=1){se.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*e+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*e+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*e+a[7]*n+a[11]*r+a[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,r,s;const c=t.elements,l=c[0],u=c[4],d=c[8],f=c[1],m=c[5],v=c[9],M=c[2],p=c[6],h=c[10];if(Math.abs(u-f)<.01&&Math.abs(d-M)<.01&&Math.abs(v-p)<.01){if(Math.abs(u+f)<.1&&Math.abs(d+M)<.1&&Math.abs(v+p)<.1&&Math.abs(l+m+h-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const T=(l+1)/2,E=(m+1)/2,C=(h+1)/2,R=(u+f)/4,D=(d+M)/4,F=(v+p)/4;return T>E&&T>C?T<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(T),r=R/n,s=D/n):E>C?E<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(E),n=R/r,s=F/r):C<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(C),n=D/s,r=F/s),this.set(n,r,s,e),this}let A=Math.sqrt((p-v)*(p-v)+(d-M)*(d-M)+(f-u)*(f-u));return Math.abs(A)<.001&&(A=1),this.x=(p-v)/A,this.y=(d-M)/A,this.z=(f-u)/A,this.w=Math.acos((l+m+h-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Bt(this.x,t.x,e.x),this.y=Bt(this.y,t.y,e.y),this.z=Bt(this.z,t.z,e.z),this.w=Bt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Bt(this.x,t,e),this.y=Bt(this.y,t,e),this.z=Bt(this.z,t,e),this.w=Bt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Bt(n,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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 Dl extends Nn{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ge,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new se(0,0,t,e),this.scissorTest=!1,this.viewport=new se(0,0,t,e);const r={width:t,height:e,depth:n.depth},s=new Me(r);this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].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(t={}){const e={minFilter:Ge,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=t,this.textures[r].image.height=e,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const r=Object.assign({},t.textures[e].image);this.textures[e].source=new Os(r)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class In extends Dl{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class lo extends Me{constructor(t=null,e=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=ze,this.minFilter=ze,this.wrapR=Pn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ll extends Me{constructor(t=null,e=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=ze,this.minFilter=ze,this.wrapR=Pn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ei{constructor(t=new N(1/0,1/0,1/0),e=new N(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Ue.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Ue.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Ue.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Ue):Ue.fromBufferAttribute(s,a),Ue.applyMatrix4(t.matrixWorld),this.expandByPoint(Ue);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),wi.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),wi.copy(n.boundingBox)),wi.applyMatrix4(t.matrixWorld),this.union(wi)}const r=t.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Ue),Ue.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(hi),Ci.subVectors(this.max,hi),zn.subVectors(t.a,hi),Hn.subVectors(t.b,hi),Vn.subVectors(t.c,hi),an.subVectors(Hn,zn),on.subVectors(Vn,Hn),Sn.subVectors(zn,Vn);let e=[0,-an.z,an.y,0,-on.z,on.y,0,-Sn.z,Sn.y,an.z,0,-an.x,on.z,0,-on.x,Sn.z,0,-Sn.x,-an.y,an.x,0,-on.y,on.x,0,-Sn.y,Sn.x,0];return!_r(e,zn,Hn,Vn,Ci)||(e=[1,0,0,0,1,0,0,0,1],!_r(e,zn,Hn,Vn,Ci))?!1:(Pi.crossVectors(an,on),e=[Pi.x,Pi.y,Pi.z],_r(e,zn,Hn,Vn,Ci))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ue).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Ue).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ze[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ze[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ze[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ze[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ze[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ze[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ze[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ze[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ze),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Ze=[new N,new N,new N,new N,new N,new N,new N,new N],Ue=new N,wi=new Ei,zn=new N,Hn=new N,Vn=new N,an=new N,on=new N,Sn=new N,hi=new N,Ci=new N,Pi=new N,En=new N;function _r(i,t,e,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){En.fromArray(i,s);const o=r.x*Math.abs(En.x)+r.y*Math.abs(En.y)+r.z*Math.abs(En.z),c=t.dot(En),l=e.dot(En),u=n.dot(En);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}const Ul=new Ei,ui=new N,gr=new N;class Bs{constructor(t=new N,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):Ul.setFromPoints(t).getCenter(n);let r=0;for(let s=0,a=t.length;s<a;s++)r=Math.max(r,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(r),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;ui.subVectors(t,this.center);const e=ui.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),r=(n-this.radius)*.5;this.center.addScaledVector(ui,r/n),this.radius+=r}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(gr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ui.copy(t.center).add(gr)),this.expandByPoint(ui.copy(t.center).sub(gr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const je=new N,vr=new N,Di=new N,ln=new N,xr=new N,Li=new N,Mr=new N;class co{constructor(t=new N,e=new N(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,je)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=je.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(je.copy(this.origin).addScaledVector(this.direction,e),je.distanceToSquared(t))}distanceSqToSegment(t,e,n,r){vr.copy(t).add(e).multiplyScalar(.5),Di.copy(e).sub(t).normalize(),ln.copy(this.origin).sub(vr);const s=t.distanceTo(e)*.5,a=-this.direction.dot(Di),o=ln.dot(this.direction),c=-ln.dot(Di),l=ln.lengthSq(),u=Math.abs(1-a*a);let d,f,m,v;if(u>0)if(d=a*c-o,f=a*o-c,v=s*u,d>=0)if(f>=-v)if(f<=v){const M=1/u;d*=M,f*=M,m=d*(d+a*f+2*o)+f*(a*d+f+2*c)+l}else f=s,d=Math.max(0,-(a*f+o)),m=-d*d+f*(f+2*c)+l;else f=-s,d=Math.max(0,-(a*f+o)),m=-d*d+f*(f+2*c)+l;else f<=-v?(d=Math.max(0,-(-a*s+o)),f=d>0?-s:Math.min(Math.max(-s,-c),s),m=-d*d+f*(f+2*c)+l):f<=v?(d=0,f=Math.min(Math.max(-s,-c),s),m=f*(f+2*c)+l):(d=Math.max(0,-(a*s+o)),f=d>0?s:Math.min(Math.max(-s,-c),s),m=-d*d+f*(f+2*c)+l);else f=a>0?-s:s,d=Math.max(0,-(a*f+o)),m=-d*d+f*(f+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(vr).addScaledVector(Di,f),m}intersectSphere(t,e){je.subVectors(t.center,this.origin);const n=je.dot(this.direction),r=je.dot(je)-n*n,s=t.radius*t.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,r,s,a,o,c;const l=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,f=this.origin;return l>=0?(n=(t.min.x-f.x)*l,r=(t.max.x-f.x)*l):(n=(t.max.x-f.x)*l,r=(t.min.x-f.x)*l),u>=0?(s=(t.min.y-f.y)*u,a=(t.max.y-f.y)*u):(s=(t.max.y-f.y)*u,a=(t.min.y-f.y)*u),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),d>=0?(o=(t.min.z-f.z)*d,c=(t.max.z-f.z)*d):(o=(t.max.z-f.z)*d,c=(t.min.z-f.z)*d),n>c||o>r)||((o>n||n!==n)&&(n=o),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,e)}intersectsBox(t){return this.intersectBox(t,je)!==null}intersectTriangle(t,e,n,r,s){xr.subVectors(e,t),Li.subVectors(n,t),Mr.crossVectors(xr,Li);let a=this.direction.dot(Mr),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ln.subVectors(this.origin,t);const c=o*this.direction.dot(Li.crossVectors(ln,Li));if(c<0)return null;const l=o*this.direction.dot(xr.cross(ln));if(l<0||c+l>a)return null;const u=-o*ln.dot(Mr);return u<0?null:this.at(u/a,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class oe{constructor(t,e,n,r,s,a,o,c,l,u,d,f,m,v,M,p){oe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,a,o,c,l,u,d,f,m,v,M,p)}set(t,e,n,r,s,a,o,c,l,u,d,f,m,v,M,p){const h=this.elements;return h[0]=t,h[4]=e,h[8]=n,h[12]=r,h[1]=s,h[5]=a,h[9]=o,h[13]=c,h[2]=l,h[6]=u,h[10]=d,h[14]=f,h[3]=m,h[7]=v,h[11]=M,h[15]=p,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 oe().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,r=1/Gn.setFromMatrixColumn(t,0).length(),s=1/Gn.setFromMatrixColumn(t,1).length(),a=1/Gn.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,r=t.y,s=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),d=Math.sin(s);if(t.order==="XYZ"){const f=a*u,m=a*d,v=o*u,M=o*d;e[0]=c*u,e[4]=-c*d,e[8]=l,e[1]=m+v*l,e[5]=f-M*l,e[9]=-o*c,e[2]=M-f*l,e[6]=v+m*l,e[10]=a*c}else if(t.order==="YXZ"){const f=c*u,m=c*d,v=l*u,M=l*d;e[0]=f+M*o,e[4]=v*o-m,e[8]=a*l,e[1]=a*d,e[5]=a*u,e[9]=-o,e[2]=m*o-v,e[6]=M+f*o,e[10]=a*c}else if(t.order==="ZXY"){const f=c*u,m=c*d,v=l*u,M=l*d;e[0]=f-M*o,e[4]=-a*d,e[8]=v+m*o,e[1]=m+v*o,e[5]=a*u,e[9]=M-f*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){const f=a*u,m=a*d,v=o*u,M=o*d;e[0]=c*u,e[4]=v*l-m,e[8]=f*l+M,e[1]=c*d,e[5]=M*l+f,e[9]=m*l-v,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){const f=a*c,m=a*l,v=o*c,M=o*l;e[0]=c*u,e[4]=M-f*d,e[8]=v*d+m,e[1]=d,e[5]=a*u,e[9]=-o*u,e[2]=-l*u,e[6]=m*d+v,e[10]=f-M*d}else if(t.order==="XZY"){const f=a*c,m=a*l,v=o*c,M=o*l;e[0]=c*u,e[4]=-d,e[8]=l*u,e[1]=f*d+M,e[5]=a*u,e[9]=m*d-v,e[2]=v*d-m,e[6]=o*u,e[10]=M*d+f}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Il,t,Nl)}lookAt(t,e,n){const r=this.elements;return Re.subVectors(t,e),Re.lengthSq()===0&&(Re.z=1),Re.normalize(),cn.crossVectors(n,Re),cn.lengthSq()===0&&(Math.abs(n.z)===1?Re.x+=1e-4:Re.z+=1e-4,Re.normalize(),cn.crossVectors(n,Re)),cn.normalize(),Ui.crossVectors(Re,cn),r[0]=cn.x,r[4]=Ui.x,r[8]=Re.x,r[1]=cn.y,r[5]=Ui.y,r[9]=Re.y,r[2]=cn.z,r[6]=Ui.z,r[10]=Re.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,s=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],u=n[1],d=n[5],f=n[9],m=n[13],v=n[2],M=n[6],p=n[10],h=n[14],A=n[3],T=n[7],E=n[11],C=n[15],R=r[0],D=r[4],F=r[8],S=r[12],x=r[1],P=r[5],z=r[9],G=r[13],X=r[2],K=r[6],W=r[10],et=r[14],H=r[3],st=r[7],ct=r[11],Et=r[15];return s[0]=a*R+o*x+c*X+l*H,s[4]=a*D+o*P+c*K+l*st,s[8]=a*F+o*z+c*W+l*ct,s[12]=a*S+o*G+c*et+l*Et,s[1]=u*R+d*x+f*X+m*H,s[5]=u*D+d*P+f*K+m*st,s[9]=u*F+d*z+f*W+m*ct,s[13]=u*S+d*G+f*et+m*Et,s[2]=v*R+M*x+p*X+h*H,s[6]=v*D+M*P+p*K+h*st,s[10]=v*F+M*z+p*W+h*ct,s[14]=v*S+M*G+p*et+h*Et,s[3]=A*R+T*x+E*X+C*H,s[7]=A*D+T*P+E*K+C*st,s[11]=A*F+T*z+E*W+C*ct,s[15]=A*S+T*G+E*et+C*Et,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],r=t[8],s=t[12],a=t[1],o=t[5],c=t[9],l=t[13],u=t[2],d=t[6],f=t[10],m=t[14],v=t[3],M=t[7],p=t[11],h=t[15];return v*(+s*c*d-r*l*d-s*o*f+n*l*f+r*o*m-n*c*m)+M*(+e*c*m-e*l*f+s*a*f-r*a*m+r*l*u-s*c*u)+p*(+e*l*d-e*o*m-s*a*d+n*a*m+s*o*u-n*l*u)+h*(-r*o*u-e*c*d+e*o*f+r*a*d-n*a*f+n*c*u)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],m=t[11],v=t[12],M=t[13],p=t[14],h=t[15],A=d*p*l-M*f*l+M*c*m-o*p*m-d*c*h+o*f*h,T=v*f*l-u*p*l-v*c*m+a*p*m+u*c*h-a*f*h,E=u*M*l-v*d*l+v*o*m-a*M*m-u*o*h+a*d*h,C=v*d*c-u*M*c-v*o*f+a*M*f+u*o*p-a*d*p,R=e*A+n*T+r*E+s*C;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const D=1/R;return t[0]=A*D,t[1]=(M*f*s-d*p*s-M*r*m+n*p*m+d*r*h-n*f*h)*D,t[2]=(o*p*s-M*c*s+M*r*l-n*p*l-o*r*h+n*c*h)*D,t[3]=(d*c*s-o*f*s-d*r*l+n*f*l+o*r*m-n*c*m)*D,t[4]=T*D,t[5]=(u*p*s-v*f*s+v*r*m-e*p*m-u*r*h+e*f*h)*D,t[6]=(v*c*s-a*p*s-v*r*l+e*p*l+a*r*h-e*c*h)*D,t[7]=(a*f*s-u*c*s+u*r*l-e*f*l-a*r*m+e*c*m)*D,t[8]=E*D,t[9]=(v*d*s-u*M*s-v*n*m+e*M*m+u*n*h-e*d*h)*D,t[10]=(a*M*s-v*o*s+v*n*l-e*M*l-a*n*h+e*o*h)*D,t[11]=(u*o*s-a*d*s-u*n*l+e*d*l+a*n*m-e*o*m)*D,t[12]=C*D,t[13]=(u*M*r-v*d*r+v*n*f-e*M*f-u*n*p+e*d*p)*D,t[14]=(v*o*r-a*M*r-v*n*c+e*M*c+a*n*p-e*o*p)*D,t[15]=(a*d*r-u*o*r+u*n*c-e*d*c-a*n*f+e*o*f)*D,this}scale(t){const e=this.elements,n=t.x,r=t.y,s=t.z;return e[0]*=n,e[4]*=r,e[8]*=s,e[1]*=n,e[5]*=r,e[9]*=s,e[2]*=n,e[6]*=r,e[10]*=s,e[3]*=n,e[7]*=r,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),r=Math.sin(e),s=1-n,a=t.x,o=t.y,c=t.z,l=s*a,u=s*o;return this.set(l*a+n,l*o-r*c,l*c+r*o,0,l*o+r*c,u*o+n,u*c-r*a,0,l*c-r*o,u*c+r*a,s*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,r,s,a){return this.set(1,n,s,0,t,1,a,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,s=e._x,a=e._y,o=e._z,c=e._w,l=s+s,u=a+a,d=o+o,f=s*l,m=s*u,v=s*d,M=a*u,p=a*d,h=o*d,A=c*l,T=c*u,E=c*d,C=n.x,R=n.y,D=n.z;return r[0]=(1-(M+h))*C,r[1]=(m+E)*C,r[2]=(v-T)*C,r[3]=0,r[4]=(m-E)*R,r[5]=(1-(f+h))*R,r[6]=(p+A)*R,r[7]=0,r[8]=(v+T)*D,r[9]=(p-A)*D,r[10]=(1-(f+M))*D,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;let s=Gn.set(r[0],r[1],r[2]).length();const a=Gn.set(r[4],r[5],r[6]).length(),o=Gn.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],Ie.copy(this);const l=1/s,u=1/a,d=1/o;return Ie.elements[0]*=l,Ie.elements[1]*=l,Ie.elements[2]*=l,Ie.elements[4]*=u,Ie.elements[5]*=u,Ie.elements[6]*=u,Ie.elements[8]*=d,Ie.elements[9]*=d,Ie.elements[10]*=d,e.setFromRotationMatrix(Ie),n.x=s,n.y=a,n.z=o,this}makePerspective(t,e,n,r,s,a,o=ke,c=!1){const l=this.elements,u=2*s/(e-t),d=2*s/(n-r),f=(e+t)/(e-t),m=(n+r)/(n-r);let v,M;if(c)v=s/(a-s),M=a*s/(a-s);else if(o===ke)v=-(a+s)/(a-s),M=-2*a*s/(a-s);else if(o===ir)v=-a/(a-s),M=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=d,l[9]=m,l[13]=0,l[2]=0,l[6]=0,l[10]=v,l[14]=M,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,r,s,a,o=ke,c=!1){const l=this.elements,u=2/(e-t),d=2/(n-r),f=-(e+t)/(e-t),m=-(n+r)/(n-r);let v,M;if(c)v=1/(a-s),M=a/(a-s);else if(o===ke)v=-2/(a-s),M=-(a+s)/(a-s);else if(o===ir)v=-1/(a-s),M=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=0,l[12]=f,l[1]=0,l[5]=d,l[9]=0,l[13]=m,l[2]=0,l[6]=0,l[10]=v,l[14]=M,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let r=0;r<16;r++)if(e[r]!==n[r])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Gn=new N,Ie=new oe,Il=new N(0,0,0),Nl=new N(1,1,1),cn=new N,Ui=new N,Re=new N,sa=new oe,aa=new Un;class qe{constructor(t=0,e=0,n=0,r=qe.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const r=t.elements,s=r[0],a=r[4],o=r[8],c=r[1],l=r[5],u=r[9],d=r[2],f=r[6],m=r[10];switch(e){case"XYZ":this._y=Math.asin(Bt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Bt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(Bt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-d,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Bt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(f,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Bt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Bt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return sa.makeRotationFromQuaternion(t),this.setFromRotationMatrix(sa,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return aa.setFromEuler(this),this.setFromQuaternion(aa,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}qe.DEFAULT_ORDER="XYZ";class ho{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Fl=0;const oa=new N,kn=new Un,$e=new oe,Ii=new N,di=new N,Ol=new N,Bl=new Un,la=new N(1,0,0),ca=new N(0,1,0),ha=new N(0,0,1),ua={type:"added"},zl={type:"removed"},Wn={type:"childadded",child:null},Sr={type:"childremoved",child:null};class ge extends Nn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Fl++}),this.uuid=Si(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ge.DEFAULT_UP.clone();const t=new N,e=new qe,n=new Un,r=new N(1,1,1);function s(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new oe},normalMatrix:{value:new It}}),this.matrix=new oe,this.matrixWorld=new oe,this.matrixAutoUpdate=ge.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ge.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ho,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.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return kn.setFromAxisAngle(t,e),this.quaternion.multiply(kn),this}rotateOnWorldAxis(t,e){return kn.setFromAxisAngle(t,e),this.quaternion.premultiply(kn),this}rotateX(t){return this.rotateOnAxis(la,t)}rotateY(t){return this.rotateOnAxis(ca,t)}rotateZ(t){return this.rotateOnAxis(ha,t)}translateOnAxis(t,e){return oa.copy(t).applyQuaternion(this.quaternion),this.position.add(oa.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(la,t)}translateY(t){return this.translateOnAxis(ca,t)}translateZ(t){return this.translateOnAxis(ha,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4($e.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Ii.copy(t):Ii.set(t,e,n);const r=this.parent;this.updateWorldMatrix(!0,!1),di.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?$e.lookAt(di,Ii,this.up):$e.lookAt(Ii,di,this.up),this.quaternion.setFromRotationMatrix($e),r&&($e.extractRotation(r.matrixWorld),kn.setFromRotationMatrix($e),this.quaternion.premultiply(kn.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(ua),Wn.child=t,this.dispatchEvent(Wn),Wn.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(zl),Sr.child=t,this.dispatchEvent(Sr),Sr.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),$e.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),$e.multiply(t.parent.matrixWorld)),t.applyMatrix4($e),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(ua),Wn.child=t,this.dispatchEvent(Wn),Wn.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(di,t,Ol),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(di,Bl,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!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)),e===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(t),r.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){const d=c[l];s(t.shapes,d)}else s(t.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(t.materials,this.material[c]));r.material=o}else r.material=s(t.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];r.animations.push(s(t.animations,c))}}if(e){const o=a(t.geometries),c=a(t.materials),l=a(t.textures),u=a(t.images),d=a(t.shapes),f=a(t.skeletons),m=a(t.animations),v=a(t.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),d.length>0&&(n.shapes=d),f.length>0&&(n.skeletons=f),m.length>0&&(n.animations=m),v.length>0&&(n.nodes=v)}return n.object=r,n;function a(o){const c=[];for(const l in o){const u=o[l];delete u.metadata,c.push(u)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const r=t.children[n];this.add(r.clone())}return this}}ge.DEFAULT_UP=new N(0,1,0);ge.DEFAULT_MATRIX_AUTO_UPDATE=!0;ge.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ne=new N,Je=new N,Er=new N,Qe=new N,Xn=new N,Yn=new N,da=new N,yr=new N,Tr=new N,br=new N,Ar=new se,Rr=new se,wr=new se;class Oe{constructor(t=new N,e=new N,n=new N){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,r){r.subVectors(n,e),Ne.subVectors(t,e),r.cross(Ne);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(t,e,n,r,s){Ne.subVectors(r,e),Je.subVectors(n,e),Er.subVectors(t,e);const a=Ne.dot(Ne),o=Ne.dot(Je),c=Ne.dot(Er),l=Je.dot(Je),u=Je.dot(Er),d=a*l-o*o;if(d===0)return s.set(0,0,0),null;const f=1/d,m=(l*c-o*u)*f,v=(a*u-o*c)*f;return s.set(1-m-v,v,m)}static containsPoint(t,e,n,r){return this.getBarycoord(t,e,n,r,Qe)===null?!1:Qe.x>=0&&Qe.y>=0&&Qe.x+Qe.y<=1}static getInterpolation(t,e,n,r,s,a,o,c){return this.getBarycoord(t,e,n,r,Qe)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,Qe.x),c.addScaledVector(a,Qe.y),c.addScaledVector(o,Qe.z),c)}static getInterpolatedAttribute(t,e,n,r,s,a){return Ar.setScalar(0),Rr.setScalar(0),wr.setScalar(0),Ar.fromBufferAttribute(t,e),Rr.fromBufferAttribute(t,n),wr.fromBufferAttribute(t,r),a.setScalar(0),a.addScaledVector(Ar,s.x),a.addScaledVector(Rr,s.y),a.addScaledVector(wr,s.z),a}static isFrontFacing(t,e,n,r){return Ne.subVectors(n,e),Je.subVectors(t,e),Ne.cross(Je).dot(r)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this}setFromAttributeAndIndices(t,e,n,r){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Ne.subVectors(this.c,this.b),Je.subVectors(this.a,this.b),Ne.cross(Je).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Oe.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Oe.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,r,s){return Oe.getInterpolation(t,this.a,this.b,this.c,e,n,r,s)}containsPoint(t){return Oe.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Oe.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,r=this.b,s=this.c;let a,o;Xn.subVectors(r,n),Yn.subVectors(s,n),yr.subVectors(t,n);const c=Xn.dot(yr),l=Yn.dot(yr);if(c<=0&&l<=0)return e.copy(n);Tr.subVectors(t,r);const u=Xn.dot(Tr),d=Yn.dot(Tr);if(u>=0&&d<=u)return e.copy(r);const f=c*d-u*l;if(f<=0&&c>=0&&u<=0)return a=c/(c-u),e.copy(n).addScaledVector(Xn,a);br.subVectors(t,s);const m=Xn.dot(br),v=Yn.dot(br);if(v>=0&&m<=v)return e.copy(s);const M=m*l-c*v;if(M<=0&&l>=0&&v<=0)return o=l/(l-v),e.copy(n).addScaledVector(Yn,o);const p=u*v-m*d;if(p<=0&&d-u>=0&&m-v>=0)return da.subVectors(s,r),o=(d-u)/(d-u+(m-v)),e.copy(r).addScaledVector(da,o);const h=1/(p+M+f);return a=M*h,o=f*h,e.copy(n).addScaledVector(Xn,a).addScaledVector(Yn,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const uo={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},hn={h:0,s:0,l:0},Ni={h:0,s:0,l:0};function Cr(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class kt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const r=t;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Le){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Gt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,r=Gt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Gt.colorSpaceToWorking(this,r),this}setHSL(t,e,n,r=Gt.workingColorSpace){if(t=yl(t,1),e=Bt(e,0,1),n=Bt(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,a=2*n-s;this.r=Cr(a,s,t+1/3),this.g=Cr(a,s,t),this.b=Cr(a,s,t-1/3)}return Gt.colorSpaceToWorking(this,r),this}setStyle(t,e=Le){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Le){const n=uo[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=sn(t.r),this.g=sn(t.g),this.b=sn(t.b),this}copyLinearToSRGB(t){return this.r=ei(t.r),this.g=ei(t.g),this.b=ei(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Le){return Gt.workingToColorSpace(_e.copy(this),t),Math.round(Bt(_e.r*255,0,255))*65536+Math.round(Bt(_e.g*255,0,255))*256+Math.round(Bt(_e.b*255,0,255))}getHexString(t=Le){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Gt.workingColorSpace){Gt.workingToColorSpace(_e.copy(this),e);const n=_e.r,r=_e.g,s=_e.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let c,l;const u=(o+a)/2;if(o===a)c=0,l=0;else{const d=a-o;switch(l=u<=.5?d/(a+o):d/(2-a-o),a){case n:c=(r-s)/d+(r<s?6:0);break;case r:c=(s-n)/d+2;break;case s:c=(n-r)/d+4;break}c/=6}return t.h=c,t.s=l,t.l=u,t}getRGB(t,e=Gt.workingColorSpace){return Gt.workingToColorSpace(_e.copy(this),e),t.r=_e.r,t.g=_e.g,t.b=_e.b,t}getStyle(t=Le){Gt.workingToColorSpace(_e.copy(this),t);const e=_e.r,n=_e.g,r=_e.b;return t!==Le?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(t,e,n){return this.getHSL(hn),this.setHSL(hn.h+t,hn.s+e,hn.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(hn),t.getHSL(Ni);const n=ur(hn.h,Ni.h,e),r=ur(hn.s,Ni.s,e),s=ur(hn.l,Ni.l,e);return this.setHSL(n,r,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,r=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*r,this.g=s[1]*e+s[4]*n+s[7]*r,this.b=s[2]*e+s[5]*n+s[8]*r,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const _e=new kt;kt.NAMES=uo;let Hl=0;class yi extends Nn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Hl++}),this.uuid=Si(),this.name="",this.type="Material",this.blending=ti,this.side=_n,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Gr,this.blendDst=kr,this.blendEquation=wn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new kt(0,0,0),this.blendAlpha=0,this.depthFunc=ni,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Js,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=On,this.stencilZFail=On,this.stencilZPass=On,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(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const r=this[e];if(r===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={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(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).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(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).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(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).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(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).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!==ti&&(n.blending=this.blending),this.side!==_n&&(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!==Gr&&(n.blendSrc=this.blendSrc),this.blendDst!==kr&&(n.blendDst=this.blendDst),this.blendEquation!==wn&&(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!==ni&&(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!==Js&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==On&&(n.stencilFail=this.stencilFail),this.stencilZFail!==On&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==On&&(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.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 r(s){const a=[];for(const o in s){const c=s[o];delete c.metadata,a.push(c)}return a}if(e){const s=r(t.textures),a=r(t.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const r=e.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class fo extends yi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new kt(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 qe,this.combine=Za,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const le=new N,Fi=new Lt;let Vl=0;class We{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Vl++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Qs,this.updateRanges=[],this.gpuType=nn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[t+r]=e.array[n+r];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Fi.fromBufferAttribute(this,e),Fi.applyMatrix3(t),this.setXY(e,Fi.x,Fi.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)le.fromBufferAttribute(this,e),le.applyMatrix3(t),this.setXYZ(e,le.x,le.y,le.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)le.fromBufferAttribute(this,e),le.applyMatrix4(t),this.setXYZ(e,le.x,le.y,le.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)le.fromBufferAttribute(this,e),le.applyNormalMatrix(t),this.setXYZ(e,le.x,le.y,le.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)le.fromBufferAttribute(this,e),le.transformDirection(t),this.setXYZ(e,le.x,le.y,le.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=ci(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Ee(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=ci(e,this.array)),e}setX(t,e){return this.normalized&&(e=Ee(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=ci(e,this.array)),e}setY(t,e){return this.normalized&&(e=Ee(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=ci(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Ee(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=ci(e,this.array)),e}setW(t,e){return this.normalized&&(e=Ee(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Ee(e,this.array),n=Ee(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,r){return t*=this.itemSize,this.normalized&&(e=Ee(e,this.array),n=Ee(n,this.array),r=Ee(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t*=this.itemSize,this.normalized&&(e=Ee(e,this.array),n=Ee(n,this.array),r=Ee(r,this.array),s=Ee(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Qs&&(t.usage=this.usage),t}}class po extends We{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class mo extends We{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Xe extends We{constructor(t,e,n){super(new Float32Array(t),e,n)}}let Gl=0;const De=new oe,Pr=new ge,qn=new N,we=new Ei,fi=new Ei,fe=new N;class vn extends Nn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Gl++}),this.uuid=Si(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(oo(t)?mo:po)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new It().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(t),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return De.makeRotationFromQuaternion(t),this.applyMatrix4(De),this}rotateX(t){return De.makeRotationX(t),this.applyMatrix4(De),this}rotateY(t){return De.makeRotationY(t),this.applyMatrix4(De),this}rotateZ(t){return De.makeRotationZ(t),this.applyMatrix4(De),this}translate(t,e,n){return De.makeTranslation(t,e,n),this.applyMatrix4(De),this}scale(t,e,n){return De.makeScale(t,e,n),this.applyMatrix4(De),this}lookAt(t){return Pr.lookAt(t),Pr.updateMatrix(),this.applyMatrix4(Pr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(qn).negate(),this.translate(qn.x,qn.y,qn.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let r=0,s=t.length;r<s;r++){const a=t[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Xe(n,3))}else{const n=Math.min(t.length,e.count);for(let r=0;r<n;r++){const s=t[r];e.setXYZ(r,s.x,s.y,s.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ei);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){const s=e[n];we.setFromBufferAttribute(s),this.morphTargetsRelative?(fe.addVectors(this.boundingBox.min,we.min),this.boundingBox.expandByPoint(fe),fe.addVectors(this.boundingBox.max,we.max),this.boundingBox.expandByPoint(fe)):(this.boundingBox.expandByPoint(we.min),this.boundingBox.expandByPoint(we.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Bs);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new N,1/0);return}if(t){const n=this.boundingSphere.center;if(we.setFromBufferAttribute(t),e)for(let s=0,a=e.length;s<a;s++){const o=e[s];fi.setFromBufferAttribute(o),this.morphTargetsRelative?(fe.addVectors(we.min,fi.min),we.expandByPoint(fe),fe.addVectors(we.max,fi.max),we.expandByPoint(fe)):(we.expandByPoint(fi.min),we.expandByPoint(fi.max))}we.getCenter(n);let r=0;for(let s=0,a=t.count;s<a;s++)fe.fromBufferAttribute(t,s),r=Math.max(r,n.distanceToSquared(fe));if(e)for(let s=0,a=e.length;s<a;s++){const o=e[s],c=this.morphTargetsRelative;for(let l=0,u=o.count;l<u;l++)fe.fromBufferAttribute(o,l),c&&(qn.fromBufferAttribute(t,l),fe.add(qn)),r=Math.max(r,n.distanceToSquared(fe))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,r=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new We(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],c=[];for(let F=0;F<n.count;F++)o[F]=new N,c[F]=new N;const l=new N,u=new N,d=new N,f=new Lt,m=new Lt,v=new Lt,M=new N,p=new N;function h(F,S,x){l.fromBufferAttribute(n,F),u.fromBufferAttribute(n,S),d.fromBufferAttribute(n,x),f.fromBufferAttribute(s,F),m.fromBufferAttribute(s,S),v.fromBufferAttribute(s,x),u.sub(l),d.sub(l),m.sub(f),v.sub(f);const P=1/(m.x*v.y-v.x*m.y);isFinite(P)&&(M.copy(u).multiplyScalar(v.y).addScaledVector(d,-m.y).multiplyScalar(P),p.copy(d).multiplyScalar(m.x).addScaledVector(u,-v.x).multiplyScalar(P),o[F].add(M),o[S].add(M),o[x].add(M),c[F].add(p),c[S].add(p),c[x].add(p))}let A=this.groups;A.length===0&&(A=[{start:0,count:t.count}]);for(let F=0,S=A.length;F<S;++F){const x=A[F],P=x.start,z=x.count;for(let G=P,X=P+z;G<X;G+=3)h(t.getX(G+0),t.getX(G+1),t.getX(G+2))}const T=new N,E=new N,C=new N,R=new N;function D(F){C.fromBufferAttribute(r,F),R.copy(C);const S=o[F];T.copy(S),T.sub(C.multiplyScalar(C.dot(S))).normalize(),E.crossVectors(R,S);const P=E.dot(c[F])<0?-1:1;a.setXYZW(F,T.x,T.y,T.z,P)}for(let F=0,S=A.length;F<S;++F){const x=A[F],P=x.start,z=x.count;for(let G=P,X=P+z;G<X;G+=3)D(t.getX(G+0)),D(t.getX(G+1)),D(t.getX(G+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new We(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let f=0,m=n.count;f<m;f++)n.setXYZ(f,0,0,0);const r=new N,s=new N,a=new N,o=new N,c=new N,l=new N,u=new N,d=new N;if(t)for(let f=0,m=t.count;f<m;f+=3){const v=t.getX(f+0),M=t.getX(f+1),p=t.getX(f+2);r.fromBufferAttribute(e,v),s.fromBufferAttribute(e,M),a.fromBufferAttribute(e,p),u.subVectors(a,s),d.subVectors(r,s),u.cross(d),o.fromBufferAttribute(n,v),c.fromBufferAttribute(n,M),l.fromBufferAttribute(n,p),o.add(u),c.add(u),l.add(u),n.setXYZ(v,o.x,o.y,o.z),n.setXYZ(M,c.x,c.y,c.z),n.setXYZ(p,l.x,l.y,l.z)}else for(let f=0,m=e.count;f<m;f+=3)r.fromBufferAttribute(e,f+0),s.fromBufferAttribute(e,f+1),a.fromBufferAttribute(e,f+2),u.subVectors(a,s),d.subVectors(r,s),u.cross(d),n.setXYZ(f+0,u.x,u.y,u.z),n.setXYZ(f+1,u.x,u.y,u.z),n.setXYZ(f+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)fe.fromBufferAttribute(t,e),fe.normalize(),t.setXYZ(e,fe.x,fe.y,fe.z)}toNonIndexed(){function t(o,c){const l=o.array,u=o.itemSize,d=o.normalized,f=new l.constructor(c.length*u);let m=0,v=0;for(let M=0,p=c.length;M<p;M++){o.isInterleavedBufferAttribute?m=c[M]*o.data.stride+o.offset:m=c[M]*u;for(let h=0;h<u;h++)f[v++]=l[m++]}return new We(f,u,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new vn,n=this.index.array,r=this.attributes;for(const o in r){const c=r[o],l=t(c,n);e.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let u=0,d=l.length;u<d;u++){const f=l[u],m=t(f,n);c.push(m)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const c in n){const l=n[c];t.data.attributes[c]=l.toJSON(t.data)}const r={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let d=0,f=l.length;d<f;d++){const m=l[d];u.push(m.toJSON(t.data))}u.length>0&&(r[c]=u,s=!0)}s&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone());const r=t.attributes;for(const l in r){const u=r[l];this.setAttribute(l,u.clone(e))}const s=t.morphAttributes;for(const l in s){const u=[],d=s[l];for(let f=0,m=d.length;f<m;f++)u.push(d[f].clone(e));this.morphAttributes[l]=u}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,u=a.length;l<u;l++){const d=a[l];this.addGroup(d.start,d.count,d.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const fa=new oe,yn=new co,Oi=new Bs,pa=new N,Bi=new N,zi=new N,Hi=new N,Dr=new N,Vi=new N,ma=new N,Gi=new N;class rn extends ge{constructor(t=new vn,e=new fo){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(t,e){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(r,t);const o=this.morphTargetInfluences;if(s&&o){Vi.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const u=o[c],d=s[c];u!==0&&(Dr.fromBufferAttribute(d,t),a?Vi.addScaledVector(Dr,u):Vi.addScaledVector(Dr.sub(e),u))}e.add(Vi)}return e}raycast(t,e){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Oi.copy(n.boundingSphere),Oi.applyMatrix4(s),yn.copy(t.ray).recast(t.near),!(Oi.containsPoint(yn.origin)===!1&&(yn.intersectSphere(Oi,pa)===null||yn.origin.distanceToSquared(pa)>(t.far-t.near)**2))&&(fa.copy(s).invert(),yn.copy(t.ray).applyMatrix4(fa),!(n.boundingBox!==null&&yn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,yn)))}_computeIntersections(t,e,n){let r;const s=this.geometry,a=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,d=s.attributes.normal,f=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,M=f.length;v<M;v++){const p=f[v],h=a[p.materialIndex],A=Math.max(p.start,m.start),T=Math.min(o.count,Math.min(p.start+p.count,m.start+m.count));for(let E=A,C=T;E<C;E+=3){const R=o.getX(E),D=o.getX(E+1),F=o.getX(E+2);r=ki(this,h,t,n,l,u,d,R,D,F),r&&(r.faceIndex=Math.floor(E/3),r.face.materialIndex=p.materialIndex,e.push(r))}}else{const v=Math.max(0,m.start),M=Math.min(o.count,m.start+m.count);for(let p=v,h=M;p<h;p+=3){const A=o.getX(p),T=o.getX(p+1),E=o.getX(p+2);r=ki(this,a,t,n,l,u,d,A,T,E),r&&(r.faceIndex=Math.floor(p/3),e.push(r))}}else if(c!==void 0)if(Array.isArray(a))for(let v=0,M=f.length;v<M;v++){const p=f[v],h=a[p.materialIndex],A=Math.max(p.start,m.start),T=Math.min(c.count,Math.min(p.start+p.count,m.start+m.count));for(let E=A,C=T;E<C;E+=3){const R=E,D=E+1,F=E+2;r=ki(this,h,t,n,l,u,d,R,D,F),r&&(r.faceIndex=Math.floor(E/3),r.face.materialIndex=p.materialIndex,e.push(r))}}else{const v=Math.max(0,m.start),M=Math.min(c.count,m.start+m.count);for(let p=v,h=M;p<h;p+=3){const A=p,T=p+1,E=p+2;r=ki(this,a,t,n,l,u,d,A,T,E),r&&(r.faceIndex=Math.floor(p/3),e.push(r))}}}}function kl(i,t,e,n,r,s,a,o){let c;if(t.side===Te?c=n.intersectTriangle(a,s,r,!0,o):c=n.intersectTriangle(r,s,a,t.side===_n,o),c===null)return null;Gi.copy(o),Gi.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Gi);return l<e.near||l>e.far?null:{distance:l,point:Gi.clone(),object:i}}function ki(i,t,e,n,r,s,a,o,c,l){i.getVertexPosition(o,Bi),i.getVertexPosition(c,zi),i.getVertexPosition(l,Hi);const u=kl(i,t,e,n,Bi,zi,Hi,ma);if(u){const d=new N;Oe.getBarycoord(ma,Bi,zi,Hi,d),r&&(u.uv=Oe.getInterpolatedAttribute(r,o,c,l,d,new Lt)),s&&(u.uv1=Oe.getInterpolatedAttribute(s,o,c,l,d,new Lt)),a&&(u.normal=Oe.getInterpolatedAttribute(a,o,c,l,d,new N),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const f={a:o,b:c,c:l,normal:new N,materialIndex:0};Oe.getNormal(Bi,zi,Hi,f.normal),u.face=f,u.barycoord=d}return u}class Ti extends vn{constructor(t=1,e=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const c=[],l=[],u=[],d=[];let f=0,m=0;v("z","y","x",-1,-1,n,e,t,a,s,0),v("z","y","x",1,-1,n,e,-t,a,s,1),v("x","z","y",1,1,t,n,e,r,a,2),v("x","z","y",1,-1,t,n,-e,r,a,3),v("x","y","z",1,-1,t,e,n,r,s,4),v("x","y","z",-1,-1,t,e,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new Xe(l,3)),this.setAttribute("normal",new Xe(u,3)),this.setAttribute("uv",new Xe(d,2));function v(M,p,h,A,T,E,C,R,D,F,S){const x=E/D,P=C/F,z=E/2,G=C/2,X=R/2,K=D+1,W=F+1;let et=0,H=0;const st=new N;for(let ct=0;ct<W;ct++){const Et=ct*P-G;for(let Ot=0;Ot<K;Ot++){const jt=Ot*x-z;st[M]=jt*A,st[p]=Et*T,st[h]=X,l.push(st.x,st.y,st.z),st[M]=0,st[p]=0,st[h]=R>0?1:-1,u.push(st.x,st.y,st.z),d.push(Ot/D),d.push(1-ct/F),et+=1}}for(let ct=0;ct<F;ct++)for(let Et=0;Et<D;Et++){const Ot=f+Et+K*ct,jt=f+Et+K*(ct+1),Qt=f+(Et+1)+K*(ct+1),Wt=f+(Et+1)+K*ct;c.push(Ot,jt,Wt),c.push(jt,Qt,Wt),H+=6}o.addGroup(m,H,S),m+=H,f+=et}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ti(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function ai(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const r=i[e][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=r.clone():Array.isArray(r)?t[e][n]=r.slice():t[e][n]=r}}return t}function xe(i){const t={};for(let e=0;e<i.length;e++){const n=ai(i[e]);for(const r in n)t[r]=n[r]}return t}function Wl(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function _o(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Gt.workingColorSpace}const Xl={clone:ai,merge:xe};var Yl=`void main() {
  6. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  7. }`,ql=`void main() {
  8. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  9. }`;class gn extends yi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Yl,this.fragmentShader=ql,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=ai(t.uniforms),this.uniformsGroups=Wl(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?e.uniforms[r]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[r]={type:"m4",value:a.toArray()}:e.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class go extends ge{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new oe,this.projectionMatrix=new oe,this.projectionMatrixInverse=new oe,this.coordinateSystem=ke,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const un=new N,_a=new Lt,ga=new Lt;class Fe extends go{constructor(t=50,e=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=Cs*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(tr*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Cs*2*Math.atan(Math.tan(tr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){un.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(un.x,un.y).multiplyScalar(-t/un.z),un.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(un.x,un.y).multiplyScalar(-t/un.z)}getViewSize(t,e){return this.getViewBounds(t,_a,ga),e.subVectors(ga,_a)}setViewOffset(t,e,n,r,s,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(tr*.5*this.fov)/this.zoom,n=2*e,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;s+=a.offsetX*r/c,e-=a.offsetY*n/l,r*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(s+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const Kn=-90,Zn=1;class Kl extends ge{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Fe(Kn,Zn,t,e);r.layers=this.layers,this.add(r);const s=new Fe(Kn,Zn,t,e);s.layers=this.layers,this.add(s);const a=new Fe(Kn,Zn,t,e);a.layers=this.layers,this.add(a);const o=new Fe(Kn,Zn,t,e);o.layers=this.layers,this.add(o);const c=new Fe(Kn,Zn,t,e);c.layers=this.layers,this.add(c);const l=new Fe(Kn,Zn,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,r,s,a,o,c]=e;for(const l of e)this.remove(l);if(t===ke)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===ir)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,c,l,u]=this.children,d=t.getRenderTarget(),f=t.getActiveCubeFace(),m=t.getActiveMipmapLevel(),v=t.xr.enabled;t.xr.enabled=!1;const M=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,r),t.render(e,s),t.setRenderTarget(n,1,r),t.render(e,a),t.setRenderTarget(n,2,r),t.render(e,o),t.setRenderTarget(n,3,r),t.render(e,c),t.setRenderTarget(n,4,r),t.render(e,l),n.texture.generateMipmaps=M,t.setRenderTarget(n,5,r),t.render(e,u),t.setRenderTarget(d,f,m),t.xr.enabled=v,n.texture.needsPMREMUpdate=!0}}class vo extends Me{constructor(t=[],e=ii,n,r,s,a,o,c,l,u){super(t,e,n,r,s,a,o,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Zl extends In{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},r=[n,n,n,n,n,n];this.texture=new vo(r),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
  10. varying vec3 vWorldDirection;
  11. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  12. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  13. }
  14. void main() {
  15. vWorldDirection = transformDirection( position, modelMatrix );
  16. #include <begin_vertex>
  17. #include <project_vertex>
  18. }
  19. `,fragmentShader:`
  20. uniform sampler2D tEquirect;
  21. varying vec3 vWorldDirection;
  22. #include <common>
  23. void main() {
  24. vec3 direction = normalize( vWorldDirection );
  25. vec2 sampleUV = equirectUv( direction );
  26. gl_FragColor = texture2D( tEquirect, sampleUV );
  27. }
  28. `},r=new Ti(5,5,5),s=new gn({name:"CubemapFromEquirect",uniforms:ai(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Te,blending:pn});s.uniforms.tEquirect.value=e;const a=new rn(r,s),o=e.minFilter;return e.minFilter===Dn&&(e.minFilter=Ge),new Kl(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,r=!0){const s=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,r);t.setRenderTarget(s)}}class Wi extends ge{constructor(){super(),this.isGroup=!0,this.type="Group"}}const jl={type:"move"};class Lr{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Wi,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 Wi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Wi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let r=null,s=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(const M of t.hand.values()){const p=e.getJointPose(M,n),h=this._getHandJoint(l,M);p!==null&&(h.matrix.fromArray(p.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,h.jointRadius=p.radius),h.visible=p!==null}const u=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],f=u.position.distanceTo(d.position),m=.02,v=.005;l.inputState.pinching&&f>m+v?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&f<=m-v&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(r=e.getPose(t.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(jl)))}return o!==null&&(o.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new Wi;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}class np extends ge{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 qe,this.environmentIntensity=1,this.environmentRotation=new qe,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const Ur=new N,$l=new N,Jl=new It;class dn{constructor(t=new N(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const r=Ur.subVectors(n,e).cross($l.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(Ur),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Jl.getNormalMatrix(t),r=this.coplanarPoint(Ur).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Tn=new Bs,Ql=new Lt(.5,.5),Xi=new N;class zs{constructor(t=new dn,e=new dn,n=new dn,r=new dn,s=new dn,a=new dn){this.planes=[t,e,n,r,s,a]}set(t,e,n,r,s,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=ke,n=!1){const r=this.planes,s=t.elements,a=s[0],o=s[1],c=s[2],l=s[3],u=s[4],d=s[5],f=s[6],m=s[7],v=s[8],M=s[9],p=s[10],h=s[11],A=s[12],T=s[13],E=s[14],C=s[15];if(r[0].setComponents(l-a,m-u,h-v,C-A).normalize(),r[1].setComponents(l+a,m+u,h+v,C+A).normalize(),r[2].setComponents(l+o,m+d,h+M,C+T).normalize(),r[3].setComponents(l-o,m-d,h-M,C-T).normalize(),n)r[4].setComponents(c,f,p,E).normalize(),r[5].setComponents(l-c,m-f,h-p,C-E).normalize();else if(r[4].setComponents(l-c,m-f,h-p,C-E).normalize(),e===ke)r[5].setComponents(l+c,m+f,h+p,C+E).normalize();else if(e===ir)r[5].setComponents(c,f,p,E).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Tn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Tn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Tn)}intersectsSprite(t){Tn.center.set(0,0,0);const e=Ql.distanceTo(t.center);return Tn.radius=.7071067811865476+e,Tn.applyMatrix4(t.matrixWorld),this.intersectsSphere(Tn)}intersectsSphere(t){const e=this.planes,n=t.center,r=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const r=e[n];if(Xi.x=r.normal.x>0?t.max.x:t.min.x,Xi.y=r.normal.y>0?t.max.y:t.min.y,Xi.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(Xi)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class ip extends Me{constructor(t,e,n,r,s,a,o,c,l){super(t,e,n,r,s,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class xo extends Me{constructor(t,e,n=Ln,r,s,a,o=ze,c=ze,l,u=gi,d=1){if(u!==gi&&u!==vi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const f={width:t,height:e,depth:d};super(f,r,s,a,o,c,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Os(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class Mo extends Me{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class ar extends vn{constructor(t=1,e=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:r};const s=t/2,a=e/2,o=Math.floor(n),c=Math.floor(r),l=o+1,u=c+1,d=t/o,f=e/c,m=[],v=[],M=[],p=[];for(let h=0;h<u;h++){const A=h*f-a;for(let T=0;T<l;T++){const E=T*d-s;v.push(E,-A,0),M.push(0,0,1),p.push(T/o),p.push(1-h/c)}}for(let h=0;h<c;h++)for(let A=0;A<o;A++){const T=A+l*h,E=A+l*(h+1),C=A+1+l*(h+1),R=A+1+l*h;m.push(T,E,R),m.push(E,C,R)}this.setIndex(m),this.setAttribute("position",new Xe(v,3)),this.setAttribute("normal",new Xe(M,3)),this.setAttribute("uv",new Xe(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ar(t.width,t.height,t.widthSegments,t.heightSegments)}}class So extends vn{constructor(t=1,e=32,n=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:s,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const u=[],d=new N,f=new N,m=[],v=[],M=[],p=[];for(let h=0;h<=n;h++){const A=[],T=h/n;let E=0;h===0&&a===0?E=.5/e:h===n&&c===Math.PI&&(E=-.5/e);for(let C=0;C<=e;C++){const R=C/e;d.x=-t*Math.cos(r+R*s)*Math.sin(a+T*o),d.y=t*Math.cos(a+T*o),d.z=t*Math.sin(r+R*s)*Math.sin(a+T*o),v.push(d.x,d.y,d.z),f.copy(d).normalize(),M.push(f.x,f.y,f.z),p.push(R+E,1-T),A.push(l++)}u.push(A)}for(let h=0;h<n;h++)for(let A=0;A<e;A++){const T=u[h][A+1],E=u[h][A],C=u[h+1][A],R=u[h+1][A+1];(h!==0||a>0)&&m.push(T,E,R),(h!==n-1||c<Math.PI)&&m.push(E,C,R)}this.setIndex(m),this.setAttribute("position",new Xe(v,3)),this.setAttribute("normal",new Xe(M,3)),this.setAttribute("uv",new Xe(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new So(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class rp extends yi{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new kt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new kt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=so,this.normalScale=new Lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new qe,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class tc extends yi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=fl,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class ec extends yi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class Eo extends ge{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new kt(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}const Ir=new oe,va=new N,xa=new N;class nc{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Lt(512,512),this.mapType=Ye,this.map=null,this.mapPass=null,this.matrix=new oe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new zs,this._frameExtents=new Lt(1,1),this._viewportCount=1,this._viewports=[new se(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;va.setFromMatrixPosition(t.matrixWorld),e.position.copy(va),xa.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(xa),e.updateMatrixWorld(),Ir.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ir,e.coordinateSystem,e.reversedDepth),e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ir)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class yo extends go{constructor(t=-1,e=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-t,a=n+t,o=r+e,c=r-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,a=s+l*this.view.width,o-=u*this.view.offsetY,c=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class ic extends nc{constructor(){super(new yo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class sp extends Eo{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ge.DEFAULT_UP),this.updateMatrix(),this.target=new ge,this.shadow=new ic}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class ap extends Eo{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class rc extends Fe{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class Ma{constructor(t=1,e=0,n=0){this.radius=t,this.phi=e,this.theta=n}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Bt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Bt(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class sc extends Nn{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){if(t===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=t}disconnect(){}dispose(){}update(){}}function Sa(i,t,e,n){const r=ac(n);switch(e){case eo:return i*t;case io:return i*t/r.components*r.byteLength;case Is:return i*t/r.components*r.byteLength;case ro:return i*t*2/r.components*r.byteLength;case Ns:return i*t*2/r.components*r.byteLength;case no:return i*t*3/r.components*r.byteLength;case Be:return i*t*4/r.components*r.byteLength;case Fs:return i*t*4/r.components*r.byteLength;case ji:case $i:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Ji:case Qi:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case ns:case rs:return Math.max(i,16)*Math.max(t,8)/4;case es:case is:return Math.max(i,8)*Math.max(t,8)/2;case ss:case as:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case os:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case ls:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case cs:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case hs:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case us:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case ds:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case fs:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case ps:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case ms:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case _s:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case gs:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case vs:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case xs:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Ms:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case Ss:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case Es:case ys:case Ts:return Math.ceil(i/4)*Math.ceil(t/4)*16;case bs:case As:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Rs:case ws:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function ac(i){switch(i){case Ye:case $a:return{byteLength:1,components:1};case mi:case Ja:case Mi:return{byteLength:2,components:1};case Ls:case Us:return{byteLength:2,components:4};case Ln:case Ds:case nn:return{byteLength:4,components:1};case Qa:case to:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"180"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="180");/**
  29. * @license
  30. * Copyright 2010-2025 Three.js Authors
  31. * SPDX-License-Identifier: MIT
  32. */function To(){let i=null,t=!1,e=null,n=null;function r(s,a){e(s,a),n=i.requestAnimationFrame(r)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(r),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){i=s}}}function oc(i){const t=new WeakMap;function e(o,c){const l=o.array,u=o.usage,d=l.byteLength,f=i.createBuffer();i.bindBuffer(c,f),i.bufferData(c,l,u),o.onUploadCallback();let m;if(l instanceof Float32Array)m=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)m=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?m=i.HALF_FLOAT:m=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)m=i.SHORT;else if(l instanceof Uint32Array)m=i.UNSIGNED_INT;else if(l instanceof Int32Array)m=i.INT;else if(l instanceof Int8Array)m=i.BYTE;else if(l instanceof Uint8Array)m=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)m=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:f,type:m,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:d}}function n(o,c,l){const u=c.array,d=c.updateRanges;if(i.bindBuffer(l,o),d.length===0)i.bufferSubData(l,0,u);else{d.sort((m,v)=>m.start-v.start);let f=0;for(let m=1;m<d.length;m++){const v=d[f],M=d[m];M.start<=v.start+v.count+1?v.count=Math.max(v.count,M.start+M.count-v.start):(++f,d[f]=M)}d.length=f+1;for(let m=0,v=d.length;m<v;m++){const M=d[m];i.bufferSubData(l,M.start*u.BYTES_PER_ELEMENT,u,M.start,M.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=t.get(o);c&&(i.deleteBuffer(c.buffer),t.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=t.get(o);(!u||u.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const l=t.get(o);if(l===void 0)t.set(o,e(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,o,c),l.version=o.version}}return{get:r,remove:s,update:a}}var lc=`#ifdef USE_ALPHAHASH
  33. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  34. #endif`,cc=`#ifdef USE_ALPHAHASH
  35. const float ALPHA_HASH_SCALE = 0.05;
  36. float hash2D( vec2 value ) {
  37. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  38. }
  39. float hash3D( vec3 value ) {
  40. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  41. }
  42. float getAlphaHashThreshold( vec3 position ) {
  43. float maxDeriv = max(
  44. length( dFdx( position.xyz ) ),
  45. length( dFdy( position.xyz ) )
  46. );
  47. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  48. vec2 pixScales = vec2(
  49. exp2( floor( log2( pixScale ) ) ),
  50. exp2( ceil( log2( pixScale ) ) )
  51. );
  52. vec2 alpha = vec2(
  53. hash3D( floor( pixScales.x * position.xyz ) ),
  54. hash3D( floor( pixScales.y * position.xyz ) )
  55. );
  56. float lerpFactor = fract( log2( pixScale ) );
  57. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  58. float a = min( lerpFactor, 1.0 - lerpFactor );
  59. vec3 cases = vec3(
  60. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  61. ( x - 0.5 * a ) / ( 1.0 - a ),
  62. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  63. );
  64. float threshold = ( x < ( 1.0 - a ) )
  65. ? ( ( x < a ) ? cases.x : cases.y )
  66. : cases.z;
  67. return clamp( threshold , 1.0e-6, 1.0 );
  68. }
  69. #endif`,hc=`#ifdef USE_ALPHAMAP
  70. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  71. #endif`,uc=`#ifdef USE_ALPHAMAP
  72. uniform sampler2D alphaMap;
  73. #endif`,dc=`#ifdef USE_ALPHATEST
  74. #ifdef ALPHA_TO_COVERAGE
  75. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  76. if ( diffuseColor.a == 0.0 ) discard;
  77. #else
  78. if ( diffuseColor.a < alphaTest ) discard;
  79. #endif
  80. #endif`,fc=`#ifdef USE_ALPHATEST
  81. uniform float alphaTest;
  82. #endif`,pc=`#ifdef USE_AOMAP
  83. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  84. reflectedLight.indirectDiffuse *= ambientOcclusion;
  85. #if defined( USE_CLEARCOAT )
  86. clearcoatSpecularIndirect *= ambientOcclusion;
  87. #endif
  88. #if defined( USE_SHEEN )
  89. sheenSpecularIndirect *= ambientOcclusion;
  90. #endif
  91. #if defined( USE_ENVMAP ) && defined( STANDARD )
  92. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  93. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  94. #endif
  95. #endif`,mc=`#ifdef USE_AOMAP
  96. uniform sampler2D aoMap;
  97. uniform float aoMapIntensity;
  98. #endif`,_c=`#ifdef USE_BATCHING
  99. #if ! defined( GL_ANGLE_multi_draw )
  100. #define gl_DrawID _gl_DrawID
  101. uniform int _gl_DrawID;
  102. #endif
  103. uniform highp sampler2D batchingTexture;
  104. uniform highp usampler2D batchingIdTexture;
  105. mat4 getBatchingMatrix( const in float i ) {
  106. int size = textureSize( batchingTexture, 0 ).x;
  107. int j = int( i ) * 4;
  108. int x = j % size;
  109. int y = j / size;
  110. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  111. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  112. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  113. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  114. return mat4( v1, v2, v3, v4 );
  115. }
  116. float getIndirectIndex( const in int i ) {
  117. int size = textureSize( batchingIdTexture, 0 ).x;
  118. int x = i % size;
  119. int y = i / size;
  120. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  121. }
  122. #endif
  123. #ifdef USE_BATCHING_COLOR
  124. uniform sampler2D batchingColorTexture;
  125. vec3 getBatchingColor( const in float i ) {
  126. int size = textureSize( batchingColorTexture, 0 ).x;
  127. int j = int( i );
  128. int x = j % size;
  129. int y = j / size;
  130. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  131. }
  132. #endif`,gc=`#ifdef USE_BATCHING
  133. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  134. #endif`,vc=`vec3 transformed = vec3( position );
  135. #ifdef USE_ALPHAHASH
  136. vPosition = vec3( position );
  137. #endif`,xc=`vec3 objectNormal = vec3( normal );
  138. #ifdef USE_TANGENT
  139. vec3 objectTangent = vec3( tangent.xyz );
  140. #endif`,Mc=`float G_BlinnPhong_Implicit( ) {
  141. return 0.25;
  142. }
  143. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  144. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  145. }
  146. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  147. vec3 halfDir = normalize( lightDir + viewDir );
  148. float dotNH = saturate( dot( normal, halfDir ) );
  149. float dotVH = saturate( dot( viewDir, halfDir ) );
  150. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  151. float G = G_BlinnPhong_Implicit( );
  152. float D = D_BlinnPhong( shininess, dotNH );
  153. return F * ( G * D );
  154. } // validated`,Sc=`#ifdef USE_IRIDESCENCE
  155. const mat3 XYZ_TO_REC709 = mat3(
  156. 3.2404542, -0.9692660, 0.0556434,
  157. -1.5371385, 1.8760108, -0.2040259,
  158. -0.4985314, 0.0415560, 1.0572252
  159. );
  160. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  161. vec3 sqrtF0 = sqrt( fresnel0 );
  162. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  163. }
  164. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  165. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  166. }
  167. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  168. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  169. }
  170. vec3 evalSensitivity( float OPD, vec3 shift ) {
  171. float phase = 2.0 * PI * OPD * 1.0e-9;
  172. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  173. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  174. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  175. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  176. xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
  177. xyz /= 1.0685e-7;
  178. vec3 rgb = XYZ_TO_REC709 * xyz;
  179. return rgb;
  180. }
  181. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  182. vec3 I;
  183. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  184. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  185. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  186. if ( cosTheta2Sq < 0.0 ) {
  187. return vec3( 1.0 );
  188. }
  189. float cosTheta2 = sqrt( cosTheta2Sq );
  190. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  191. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  192. float T121 = 1.0 - R12;
  193. float phi12 = 0.0;
  194. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  195. float phi21 = PI - phi12;
  196. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  197. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  198. vec3 phi23 = vec3( 0.0 );
  199. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  200. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  201. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  202. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  203. vec3 phi = vec3( phi21 ) + phi23;
  204. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  205. vec3 r123 = sqrt( R123 );
  206. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  207. vec3 C0 = R12 + Rs;
  208. I = C0;
  209. vec3 Cm = Rs - T121;
  210. for ( int m = 1; m <= 2; ++ m ) {
  211. Cm *= r123;
  212. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  213. I += Cm * Sm;
  214. }
  215. return max( I, vec3( 0.0 ) );
  216. }
  217. #endif`,Ec=`#ifdef USE_BUMPMAP
  218. uniform sampler2D bumpMap;
  219. uniform float bumpScale;
  220. vec2 dHdxy_fwd() {
  221. vec2 dSTdx = dFdx( vBumpMapUv );
  222. vec2 dSTdy = dFdy( vBumpMapUv );
  223. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  224. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  225. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  226. return vec2( dBx, dBy );
  227. }
  228. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  229. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  230. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  231. vec3 vN = surf_norm;
  232. vec3 R1 = cross( vSigmaY, vN );
  233. vec3 R2 = cross( vN, vSigmaX );
  234. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  235. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  236. return normalize( abs( fDet ) * surf_norm - vGrad );
  237. }
  238. #endif`,yc=`#if NUM_CLIPPING_PLANES > 0
  239. vec4 plane;
  240. #ifdef ALPHA_TO_COVERAGE
  241. float distanceToPlane, distanceGradient;
  242. float clipOpacity = 1.0;
  243. #pragma unroll_loop_start
  244. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  245. plane = clippingPlanes[ i ];
  246. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  247. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  248. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  249. if ( clipOpacity == 0.0 ) discard;
  250. }
  251. #pragma unroll_loop_end
  252. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  253. float unionClipOpacity = 1.0;
  254. #pragma unroll_loop_start
  255. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  256. plane = clippingPlanes[ i ];
  257. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  258. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  259. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  260. }
  261. #pragma unroll_loop_end
  262. clipOpacity *= 1.0 - unionClipOpacity;
  263. #endif
  264. diffuseColor.a *= clipOpacity;
  265. if ( diffuseColor.a == 0.0 ) discard;
  266. #else
  267. #pragma unroll_loop_start
  268. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  269. plane = clippingPlanes[ i ];
  270. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  271. }
  272. #pragma unroll_loop_end
  273. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  274. bool clipped = true;
  275. #pragma unroll_loop_start
  276. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  277. plane = clippingPlanes[ i ];
  278. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  279. }
  280. #pragma unroll_loop_end
  281. if ( clipped ) discard;
  282. #endif
  283. #endif
  284. #endif`,Tc=`#if NUM_CLIPPING_PLANES > 0
  285. varying vec3 vClipPosition;
  286. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  287. #endif`,bc=`#if NUM_CLIPPING_PLANES > 0
  288. varying vec3 vClipPosition;
  289. #endif`,Ac=`#if NUM_CLIPPING_PLANES > 0
  290. vClipPosition = - mvPosition.xyz;
  291. #endif`,Rc=`#if defined( USE_COLOR_ALPHA )
  292. diffuseColor *= vColor;
  293. #elif defined( USE_COLOR )
  294. diffuseColor.rgb *= vColor;
  295. #endif`,wc=`#if defined( USE_COLOR_ALPHA )
  296. varying vec4 vColor;
  297. #elif defined( USE_COLOR )
  298. varying vec3 vColor;
  299. #endif`,Cc=`#if defined( USE_COLOR_ALPHA )
  300. varying vec4 vColor;
  301. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  302. varying vec3 vColor;
  303. #endif`,Pc=`#if defined( USE_COLOR_ALPHA )
  304. vColor = vec4( 1.0 );
  305. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  306. vColor = vec3( 1.0 );
  307. #endif
  308. #ifdef USE_COLOR
  309. vColor *= color;
  310. #endif
  311. #ifdef USE_INSTANCING_COLOR
  312. vColor.xyz *= instanceColor.xyz;
  313. #endif
  314. #ifdef USE_BATCHING_COLOR
  315. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  316. vColor.xyz *= batchingColor.xyz;
  317. #endif`,Dc=`#define PI 3.141592653589793
  318. #define PI2 6.283185307179586
  319. #define PI_HALF 1.5707963267948966
  320. #define RECIPROCAL_PI 0.3183098861837907
  321. #define RECIPROCAL_PI2 0.15915494309189535
  322. #define EPSILON 1e-6
  323. #ifndef saturate
  324. #define saturate( a ) clamp( a, 0.0, 1.0 )
  325. #endif
  326. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  327. float pow2( const in float x ) { return x*x; }
  328. vec3 pow2( const in vec3 x ) { return x*x; }
  329. float pow3( const in float x ) { return x*x*x; }
  330. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  331. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  332. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  333. highp float rand( const in vec2 uv ) {
  334. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  335. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  336. return fract( sin( sn ) * c );
  337. }
  338. #ifdef HIGH_PRECISION
  339. float precisionSafeLength( vec3 v ) { return length( v ); }
  340. #else
  341. float precisionSafeLength( vec3 v ) {
  342. float maxComponent = max3( abs( v ) );
  343. return length( v / maxComponent ) * maxComponent;
  344. }
  345. #endif
  346. struct IncidentLight {
  347. vec3 color;
  348. vec3 direction;
  349. bool visible;
  350. };
  351. struct ReflectedLight {
  352. vec3 directDiffuse;
  353. vec3 directSpecular;
  354. vec3 indirectDiffuse;
  355. vec3 indirectSpecular;
  356. };
  357. #ifdef USE_ALPHAHASH
  358. varying vec3 vPosition;
  359. #endif
  360. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  361. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  362. }
  363. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  364. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  365. }
  366. mat3 transposeMat3( const in mat3 m ) {
  367. mat3 tmp;
  368. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  369. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  370. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  371. return tmp;
  372. }
  373. bool isPerspectiveMatrix( mat4 m ) {
  374. return m[ 2 ][ 3 ] == - 1.0;
  375. }
  376. vec2 equirectUv( in vec3 dir ) {
  377. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  378. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  379. return vec2( u, v );
  380. }
  381. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  382. return RECIPROCAL_PI * diffuseColor;
  383. }
  384. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  385. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  386. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  387. }
  388. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  389. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  390. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  391. } // validated`,Lc=`#ifdef ENVMAP_TYPE_CUBE_UV
  392. #define cubeUV_minMipLevel 4.0
  393. #define cubeUV_minTileSize 16.0
  394. float getFace( vec3 direction ) {
  395. vec3 absDirection = abs( direction );
  396. float face = - 1.0;
  397. if ( absDirection.x > absDirection.z ) {
  398. if ( absDirection.x > absDirection.y )
  399. face = direction.x > 0.0 ? 0.0 : 3.0;
  400. else
  401. face = direction.y > 0.0 ? 1.0 : 4.0;
  402. } else {
  403. if ( absDirection.z > absDirection.y )
  404. face = direction.z > 0.0 ? 2.0 : 5.0;
  405. else
  406. face = direction.y > 0.0 ? 1.0 : 4.0;
  407. }
  408. return face;
  409. }
  410. vec2 getUV( vec3 direction, float face ) {
  411. vec2 uv;
  412. if ( face == 0.0 ) {
  413. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  414. } else if ( face == 1.0 ) {
  415. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  416. } else if ( face == 2.0 ) {
  417. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  418. } else if ( face == 3.0 ) {
  419. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  420. } else if ( face == 4.0 ) {
  421. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  422. } else {
  423. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  424. }
  425. return 0.5 * ( uv + 1.0 );
  426. }
  427. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  428. float face = getFace( direction );
  429. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  430. mipInt = max( mipInt, cubeUV_minMipLevel );
  431. float faceSize = exp2( mipInt );
  432. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  433. if ( face > 2.0 ) {
  434. uv.y += faceSize;
  435. face -= 3.0;
  436. }
  437. uv.x += face * faceSize;
  438. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  439. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  440. uv.x *= CUBEUV_TEXEL_WIDTH;
  441. uv.y *= CUBEUV_TEXEL_HEIGHT;
  442. #ifdef texture2DGradEXT
  443. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  444. #else
  445. return texture2D( envMap, uv ).rgb;
  446. #endif
  447. }
  448. #define cubeUV_r0 1.0
  449. #define cubeUV_m0 - 2.0
  450. #define cubeUV_r1 0.8
  451. #define cubeUV_m1 - 1.0
  452. #define cubeUV_r4 0.4
  453. #define cubeUV_m4 2.0
  454. #define cubeUV_r5 0.305
  455. #define cubeUV_m5 3.0
  456. #define cubeUV_r6 0.21
  457. #define cubeUV_m6 4.0
  458. float roughnessToMip( float roughness ) {
  459. float mip = 0.0;
  460. if ( roughness >= cubeUV_r1 ) {
  461. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  462. } else if ( roughness >= cubeUV_r4 ) {
  463. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  464. } else if ( roughness >= cubeUV_r5 ) {
  465. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  466. } else if ( roughness >= cubeUV_r6 ) {
  467. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  468. } else {
  469. mip = - 2.0 * log2( 1.16 * roughness ); }
  470. return mip;
  471. }
  472. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  473. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  474. float mipF = fract( mip );
  475. float mipInt = floor( mip );
  476. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  477. if ( mipF == 0.0 ) {
  478. return vec4( color0, 1.0 );
  479. } else {
  480. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  481. return vec4( mix( color0, color1, mipF ), 1.0 );
  482. }
  483. }
  484. #endif`,Uc=`vec3 transformedNormal = objectNormal;
  485. #ifdef USE_TANGENT
  486. vec3 transformedTangent = objectTangent;
  487. #endif
  488. #ifdef USE_BATCHING
  489. mat3 bm = mat3( batchingMatrix );
  490. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  491. transformedNormal = bm * transformedNormal;
  492. #ifdef USE_TANGENT
  493. transformedTangent = bm * transformedTangent;
  494. #endif
  495. #endif
  496. #ifdef USE_INSTANCING
  497. mat3 im = mat3( instanceMatrix );
  498. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  499. transformedNormal = im * transformedNormal;
  500. #ifdef USE_TANGENT
  501. transformedTangent = im * transformedTangent;
  502. #endif
  503. #endif
  504. transformedNormal = normalMatrix * transformedNormal;
  505. #ifdef FLIP_SIDED
  506. transformedNormal = - transformedNormal;
  507. #endif
  508. #ifdef USE_TANGENT
  509. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  510. #ifdef FLIP_SIDED
  511. transformedTangent = - transformedTangent;
  512. #endif
  513. #endif`,Ic=`#ifdef USE_DISPLACEMENTMAP
  514. uniform sampler2D displacementMap;
  515. uniform float displacementScale;
  516. uniform float displacementBias;
  517. #endif`,Nc=`#ifdef USE_DISPLACEMENTMAP
  518. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  519. #endif`,Fc=`#ifdef USE_EMISSIVEMAP
  520. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  521. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  522. emissiveColor = sRGBTransferEOTF( emissiveColor );
  523. #endif
  524. totalEmissiveRadiance *= emissiveColor.rgb;
  525. #endif`,Oc=`#ifdef USE_EMISSIVEMAP
  526. uniform sampler2D emissiveMap;
  527. #endif`,Bc="gl_FragColor = linearToOutputTexel( gl_FragColor );",zc=`vec4 LinearTransferOETF( in vec4 value ) {
  528. return value;
  529. }
  530. vec4 sRGBTransferEOTF( in vec4 value ) {
  531. return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
  532. }
  533. vec4 sRGBTransferOETF( in vec4 value ) {
  534. return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
  535. }`,Hc=`#ifdef USE_ENVMAP
  536. #ifdef ENV_WORLDPOS
  537. vec3 cameraToFrag;
  538. if ( isOrthographic ) {
  539. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  540. } else {
  541. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  542. }
  543. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  544. #ifdef ENVMAP_MODE_REFLECTION
  545. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  546. #else
  547. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  548. #endif
  549. #else
  550. vec3 reflectVec = vReflect;
  551. #endif
  552. #ifdef ENVMAP_TYPE_CUBE
  553. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  554. #else
  555. vec4 envColor = vec4( 0.0 );
  556. #endif
  557. #ifdef ENVMAP_BLENDING_MULTIPLY
  558. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  559. #elif defined( ENVMAP_BLENDING_MIX )
  560. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  561. #elif defined( ENVMAP_BLENDING_ADD )
  562. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  563. #endif
  564. #endif`,Vc=`#ifdef USE_ENVMAP
  565. uniform float envMapIntensity;
  566. uniform float flipEnvMap;
  567. uniform mat3 envMapRotation;
  568. #ifdef ENVMAP_TYPE_CUBE
  569. uniform samplerCube envMap;
  570. #else
  571. uniform sampler2D envMap;
  572. #endif
  573. #endif`,Gc=`#ifdef USE_ENVMAP
  574. uniform float reflectivity;
  575. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  576. #define ENV_WORLDPOS
  577. #endif
  578. #ifdef ENV_WORLDPOS
  579. varying vec3 vWorldPosition;
  580. uniform float refractionRatio;
  581. #else
  582. varying vec3 vReflect;
  583. #endif
  584. #endif`,kc=`#ifdef USE_ENVMAP
  585. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  586. #define ENV_WORLDPOS
  587. #endif
  588. #ifdef ENV_WORLDPOS
  589. varying vec3 vWorldPosition;
  590. #else
  591. varying vec3 vReflect;
  592. uniform float refractionRatio;
  593. #endif
  594. #endif`,Wc=`#ifdef USE_ENVMAP
  595. #ifdef ENV_WORLDPOS
  596. vWorldPosition = worldPosition.xyz;
  597. #else
  598. vec3 cameraToVertex;
  599. if ( isOrthographic ) {
  600. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  601. } else {
  602. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  603. }
  604. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  605. #ifdef ENVMAP_MODE_REFLECTION
  606. vReflect = reflect( cameraToVertex, worldNormal );
  607. #else
  608. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  609. #endif
  610. #endif
  611. #endif`,Xc=`#ifdef USE_FOG
  612. vFogDepth = - mvPosition.z;
  613. #endif`,Yc=`#ifdef USE_FOG
  614. varying float vFogDepth;
  615. #endif`,qc=`#ifdef USE_FOG
  616. #ifdef FOG_EXP2
  617. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  618. #else
  619. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  620. #endif
  621. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  622. #endif`,Kc=`#ifdef USE_FOG
  623. uniform vec3 fogColor;
  624. varying float vFogDepth;
  625. #ifdef FOG_EXP2
  626. uniform float fogDensity;
  627. #else
  628. uniform float fogNear;
  629. uniform float fogFar;
  630. #endif
  631. #endif`,Zc=`#ifdef USE_GRADIENTMAP
  632. uniform sampler2D gradientMap;
  633. #endif
  634. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  635. float dotNL = dot( normal, lightDirection );
  636. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  637. #ifdef USE_GRADIENTMAP
  638. return vec3( texture2D( gradientMap, coord ).r );
  639. #else
  640. vec2 fw = fwidth( coord ) * 0.5;
  641. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  642. #endif
  643. }`,jc=`#ifdef USE_LIGHTMAP
  644. uniform sampler2D lightMap;
  645. uniform float lightMapIntensity;
  646. #endif`,$c=`LambertMaterial material;
  647. material.diffuseColor = diffuseColor.rgb;
  648. material.specularStrength = specularStrength;`,Jc=`varying vec3 vViewPosition;
  649. struct LambertMaterial {
  650. vec3 diffuseColor;
  651. float specularStrength;
  652. };
  653. void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  654. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  655. vec3 irradiance = dotNL * directLight.color;
  656. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  657. }
  658. void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  659. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  660. }
  661. #define RE_Direct RE_Direct_Lambert
  662. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Qc=`uniform bool receiveShadow;
  663. uniform vec3 ambientLightColor;
  664. #if defined( USE_LIGHT_PROBES )
  665. uniform vec3 lightProbe[ 9 ];
  666. #endif
  667. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  668. float x = normal.x, y = normal.y, z = normal.z;
  669. vec3 result = shCoefficients[ 0 ] * 0.886227;
  670. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  671. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  672. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  673. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  674. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  675. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  676. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  677. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  678. return result;
  679. }
  680. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  681. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  682. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  683. return irradiance;
  684. }
  685. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  686. vec3 irradiance = ambientLightColor;
  687. return irradiance;
  688. }
  689. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  690. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  691. if ( cutoffDistance > 0.0 ) {
  692. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  693. }
  694. return distanceFalloff;
  695. }
  696. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  697. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  698. }
  699. #if NUM_DIR_LIGHTS > 0
  700. struct DirectionalLight {
  701. vec3 direction;
  702. vec3 color;
  703. };
  704. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  705. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  706. light.color = directionalLight.color;
  707. light.direction = directionalLight.direction;
  708. light.visible = true;
  709. }
  710. #endif
  711. #if NUM_POINT_LIGHTS > 0
  712. struct PointLight {
  713. vec3 position;
  714. vec3 color;
  715. float distance;
  716. float decay;
  717. };
  718. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  719. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  720. vec3 lVector = pointLight.position - geometryPosition;
  721. light.direction = normalize( lVector );
  722. float lightDistance = length( lVector );
  723. light.color = pointLight.color;
  724. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  725. light.visible = ( light.color != vec3( 0.0 ) );
  726. }
  727. #endif
  728. #if NUM_SPOT_LIGHTS > 0
  729. struct SpotLight {
  730. vec3 position;
  731. vec3 direction;
  732. vec3 color;
  733. float distance;
  734. float decay;
  735. float coneCos;
  736. float penumbraCos;
  737. };
  738. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  739. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  740. vec3 lVector = spotLight.position - geometryPosition;
  741. light.direction = normalize( lVector );
  742. float angleCos = dot( light.direction, spotLight.direction );
  743. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  744. if ( spotAttenuation > 0.0 ) {
  745. float lightDistance = length( lVector );
  746. light.color = spotLight.color * spotAttenuation;
  747. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  748. light.visible = ( light.color != vec3( 0.0 ) );
  749. } else {
  750. light.color = vec3( 0.0 );
  751. light.visible = false;
  752. }
  753. }
  754. #endif
  755. #if NUM_RECT_AREA_LIGHTS > 0
  756. struct RectAreaLight {
  757. vec3 color;
  758. vec3 position;
  759. vec3 halfWidth;
  760. vec3 halfHeight;
  761. };
  762. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  763. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  764. #endif
  765. #if NUM_HEMI_LIGHTS > 0
  766. struct HemisphereLight {
  767. vec3 direction;
  768. vec3 skyColor;
  769. vec3 groundColor;
  770. };
  771. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  772. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  773. float dotNL = dot( normal, hemiLight.direction );
  774. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  775. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  776. return irradiance;
  777. }
  778. #endif`,th=`#ifdef USE_ENVMAP
  779. vec3 getIBLIrradiance( const in vec3 normal ) {
  780. #ifdef ENVMAP_TYPE_CUBE_UV
  781. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  782. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  783. return PI * envMapColor.rgb * envMapIntensity;
  784. #else
  785. return vec3( 0.0 );
  786. #endif
  787. }
  788. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  789. #ifdef ENVMAP_TYPE_CUBE_UV
  790. vec3 reflectVec = reflect( - viewDir, normal );
  791. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  792. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  793. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  794. return envMapColor.rgb * envMapIntensity;
  795. #else
  796. return vec3( 0.0 );
  797. #endif
  798. }
  799. #ifdef USE_ANISOTROPY
  800. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  801. #ifdef ENVMAP_TYPE_CUBE_UV
  802. vec3 bentNormal = cross( bitangent, viewDir );
  803. bentNormal = normalize( cross( bentNormal, bitangent ) );
  804. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  805. return getIBLRadiance( viewDir, bentNormal, roughness );
  806. #else
  807. return vec3( 0.0 );
  808. #endif
  809. }
  810. #endif
  811. #endif`,eh=`ToonMaterial material;
  812. material.diffuseColor = diffuseColor.rgb;`,nh=`varying vec3 vViewPosition;
  813. struct ToonMaterial {
  814. vec3 diffuseColor;
  815. };
  816. void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  817. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  818. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  819. }
  820. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  821. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  822. }
  823. #define RE_Direct RE_Direct_Toon
  824. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,ih=`BlinnPhongMaterial material;
  825. material.diffuseColor = diffuseColor.rgb;
  826. material.specularColor = specular;
  827. material.specularShininess = shininess;
  828. material.specularStrength = specularStrength;`,rh=`varying vec3 vViewPosition;
  829. struct BlinnPhongMaterial {
  830. vec3 diffuseColor;
  831. vec3 specularColor;
  832. float specularShininess;
  833. float specularStrength;
  834. };
  835. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  836. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  837. vec3 irradiance = dotNL * directLight.color;
  838. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  839. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  840. }
  841. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  842. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  843. }
  844. #define RE_Direct RE_Direct_BlinnPhong
  845. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,sh=`PhysicalMaterial material;
  846. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  847. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  848. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  849. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  850. material.roughness = min( material.roughness, 1.0 );
  851. #ifdef IOR
  852. material.ior = ior;
  853. #ifdef USE_SPECULAR
  854. float specularIntensityFactor = specularIntensity;
  855. vec3 specularColorFactor = specularColor;
  856. #ifdef USE_SPECULAR_COLORMAP
  857. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  858. #endif
  859. #ifdef USE_SPECULAR_INTENSITYMAP
  860. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  861. #endif
  862. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  863. #else
  864. float specularIntensityFactor = 1.0;
  865. vec3 specularColorFactor = vec3( 1.0 );
  866. material.specularF90 = 1.0;
  867. #endif
  868. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  869. #else
  870. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  871. material.specularF90 = 1.0;
  872. #endif
  873. #ifdef USE_CLEARCOAT
  874. material.clearcoat = clearcoat;
  875. material.clearcoatRoughness = clearcoatRoughness;
  876. material.clearcoatF0 = vec3( 0.04 );
  877. material.clearcoatF90 = 1.0;
  878. #ifdef USE_CLEARCOATMAP
  879. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  880. #endif
  881. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  882. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  883. #endif
  884. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  885. material.clearcoatRoughness += geometryRoughness;
  886. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  887. #endif
  888. #ifdef USE_DISPERSION
  889. material.dispersion = dispersion;
  890. #endif
  891. #ifdef USE_IRIDESCENCE
  892. material.iridescence = iridescence;
  893. material.iridescenceIOR = iridescenceIOR;
  894. #ifdef USE_IRIDESCENCEMAP
  895. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  896. #endif
  897. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  898. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  899. #else
  900. material.iridescenceThickness = iridescenceThicknessMaximum;
  901. #endif
  902. #endif
  903. #ifdef USE_SHEEN
  904. material.sheenColor = sheenColor;
  905. #ifdef USE_SHEEN_COLORMAP
  906. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  907. #endif
  908. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  909. #ifdef USE_SHEEN_ROUGHNESSMAP
  910. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  911. #endif
  912. #endif
  913. #ifdef USE_ANISOTROPY
  914. #ifdef USE_ANISOTROPYMAP
  915. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  916. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  917. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  918. #else
  919. vec2 anisotropyV = anisotropyVector;
  920. #endif
  921. material.anisotropy = length( anisotropyV );
  922. if( material.anisotropy == 0.0 ) {
  923. anisotropyV = vec2( 1.0, 0.0 );
  924. } else {
  925. anisotropyV /= material.anisotropy;
  926. material.anisotropy = saturate( material.anisotropy );
  927. }
  928. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  929. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  930. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  931. #endif`,ah=`struct PhysicalMaterial {
  932. vec3 diffuseColor;
  933. float roughness;
  934. vec3 specularColor;
  935. float specularF90;
  936. float dispersion;
  937. #ifdef USE_CLEARCOAT
  938. float clearcoat;
  939. float clearcoatRoughness;
  940. vec3 clearcoatF0;
  941. float clearcoatF90;
  942. #endif
  943. #ifdef USE_IRIDESCENCE
  944. float iridescence;
  945. float iridescenceIOR;
  946. float iridescenceThickness;
  947. vec3 iridescenceFresnel;
  948. vec3 iridescenceF0;
  949. #endif
  950. #ifdef USE_SHEEN
  951. vec3 sheenColor;
  952. float sheenRoughness;
  953. #endif
  954. #ifdef IOR
  955. float ior;
  956. #endif
  957. #ifdef USE_TRANSMISSION
  958. float transmission;
  959. float transmissionAlpha;
  960. float thickness;
  961. float attenuationDistance;
  962. vec3 attenuationColor;
  963. #endif
  964. #ifdef USE_ANISOTROPY
  965. float anisotropy;
  966. float alphaT;
  967. vec3 anisotropyT;
  968. vec3 anisotropyB;
  969. #endif
  970. };
  971. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  972. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  973. vec3 sheenSpecularDirect = vec3( 0.0 );
  974. vec3 sheenSpecularIndirect = vec3(0.0 );
  975. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  976. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  977. float x2 = x * x;
  978. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  979. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  980. }
  981. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  982. float a2 = pow2( alpha );
  983. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  984. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  985. return 0.5 / max( gv + gl, EPSILON );
  986. }
  987. float D_GGX( const in float alpha, const in float dotNH ) {
  988. float a2 = pow2( alpha );
  989. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  990. return RECIPROCAL_PI * a2 / pow2( denom );
  991. }
  992. #ifdef USE_ANISOTROPY
  993. float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
  994. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  995. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  996. float v = 0.5 / ( gv + gl );
  997. return saturate(v);
  998. }
  999. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  1000. float a2 = alphaT * alphaB;
  1001. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  1002. highp float v2 = dot( v, v );
  1003. float w2 = a2 / v2;
  1004. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1005. }
  1006. #endif
  1007. #ifdef USE_CLEARCOAT
  1008. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1009. vec3 f0 = material.clearcoatF0;
  1010. float f90 = material.clearcoatF90;
  1011. float roughness = material.clearcoatRoughness;
  1012. float alpha = pow2( roughness );
  1013. vec3 halfDir = normalize( lightDir + viewDir );
  1014. float dotNL = saturate( dot( normal, lightDir ) );
  1015. float dotNV = saturate( dot( normal, viewDir ) );
  1016. float dotNH = saturate( dot( normal, halfDir ) );
  1017. float dotVH = saturate( dot( viewDir, halfDir ) );
  1018. vec3 F = F_Schlick( f0, f90, dotVH );
  1019. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1020. float D = D_GGX( alpha, dotNH );
  1021. return F * ( V * D );
  1022. }
  1023. #endif
  1024. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1025. vec3 f0 = material.specularColor;
  1026. float f90 = material.specularF90;
  1027. float roughness = material.roughness;
  1028. float alpha = pow2( roughness );
  1029. vec3 halfDir = normalize( lightDir + viewDir );
  1030. float dotNL = saturate( dot( normal, lightDir ) );
  1031. float dotNV = saturate( dot( normal, viewDir ) );
  1032. float dotNH = saturate( dot( normal, halfDir ) );
  1033. float dotVH = saturate( dot( viewDir, halfDir ) );
  1034. vec3 F = F_Schlick( f0, f90, dotVH );
  1035. #ifdef USE_IRIDESCENCE
  1036. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1037. #endif
  1038. #ifdef USE_ANISOTROPY
  1039. float dotTL = dot( material.anisotropyT, lightDir );
  1040. float dotTV = dot( material.anisotropyT, viewDir );
  1041. float dotTH = dot( material.anisotropyT, halfDir );
  1042. float dotBL = dot( material.anisotropyB, lightDir );
  1043. float dotBV = dot( material.anisotropyB, viewDir );
  1044. float dotBH = dot( material.anisotropyB, halfDir );
  1045. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1046. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1047. #else
  1048. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1049. float D = D_GGX( alpha, dotNH );
  1050. #endif
  1051. return F * ( V * D );
  1052. }
  1053. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1054. const float LUT_SIZE = 64.0;
  1055. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1056. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1057. float dotNV = saturate( dot( N, V ) );
  1058. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1059. uv = uv * LUT_SCALE + LUT_BIAS;
  1060. return uv;
  1061. }
  1062. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1063. float l = length( f );
  1064. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1065. }
  1066. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1067. float x = dot( v1, v2 );
  1068. float y = abs( x );
  1069. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1070. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1071. float v = a / b;
  1072. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1073. return cross( v1, v2 ) * theta_sintheta;
  1074. }
  1075. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1076. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1077. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1078. vec3 lightNormal = cross( v1, v2 );
  1079. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1080. vec3 T1, T2;
  1081. T1 = normalize( V - N * dot( V, N ) );
  1082. T2 = - cross( N, T1 );
  1083. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  1084. vec3 coords[ 4 ];
  1085. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1086. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1087. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1088. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1089. coords[ 0 ] = normalize( coords[ 0 ] );
  1090. coords[ 1 ] = normalize( coords[ 1 ] );
  1091. coords[ 2 ] = normalize( coords[ 2 ] );
  1092. coords[ 3 ] = normalize( coords[ 3 ] );
  1093. vec3 vectorFormFactor = vec3( 0.0 );
  1094. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1095. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1096. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1097. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1098. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1099. return vec3( result );
  1100. }
  1101. #if defined( USE_SHEEN )
  1102. float D_Charlie( float roughness, float dotNH ) {
  1103. float alpha = pow2( roughness );
  1104. float invAlpha = 1.0 / alpha;
  1105. float cos2h = dotNH * dotNH;
  1106. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1107. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1108. }
  1109. float V_Neubelt( float dotNV, float dotNL ) {
  1110. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1111. }
  1112. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1113. vec3 halfDir = normalize( lightDir + viewDir );
  1114. float dotNL = saturate( dot( normal, lightDir ) );
  1115. float dotNV = saturate( dot( normal, viewDir ) );
  1116. float dotNH = saturate( dot( normal, halfDir ) );
  1117. float D = D_Charlie( sheenRoughness, dotNH );
  1118. float V = V_Neubelt( dotNV, dotNL );
  1119. return sheenColor * ( D * V );
  1120. }
  1121. #endif
  1122. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1123. float dotNV = saturate( dot( normal, viewDir ) );
  1124. float r2 = roughness * roughness;
  1125. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1126. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1127. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1128. return saturate( DG * RECIPROCAL_PI );
  1129. }
  1130. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1131. float dotNV = saturate( dot( normal, viewDir ) );
  1132. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  1133. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  1134. vec4 r = roughness * c0 + c1;
  1135. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  1136. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  1137. return fab;
  1138. }
  1139. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1140. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1141. return specularColor * fab.x + specularF90 * fab.y;
  1142. }
  1143. #ifdef USE_IRIDESCENCE
  1144. void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  1145. #else
  1146. void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  1147. #endif
  1148. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1149. #ifdef USE_IRIDESCENCE
  1150. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1151. #else
  1152. vec3 Fr = specularColor;
  1153. #endif
  1154. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1155. float Ess = fab.x + fab.y;
  1156. float Ems = 1.0 - Ess;
  1157. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1158. singleScatter += FssEss;
  1159. multiScatter += Fms * Ems;
  1160. }
  1161. #if NUM_RECT_AREA_LIGHTS > 0
  1162. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1163. vec3 normal = geometryNormal;
  1164. vec3 viewDir = geometryViewDir;
  1165. vec3 position = geometryPosition;
  1166. vec3 lightPos = rectAreaLight.position;
  1167. vec3 halfWidth = rectAreaLight.halfWidth;
  1168. vec3 halfHeight = rectAreaLight.halfHeight;
  1169. vec3 lightColor = rectAreaLight.color;
  1170. float roughness = material.roughness;
  1171. vec3 rectCoords[ 4 ];
  1172. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1173. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1174. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1175. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1176. vec4 t1 = texture2D( ltc_1, uv );
  1177. vec4 t2 = texture2D( ltc_2, uv );
  1178. mat3 mInv = mat3(
  1179. vec3( t1.x, 0, t1.y ),
  1180. vec3( 0, 1, 0 ),
  1181. vec3( t1.z, 0, t1.w )
  1182. );
  1183. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1184. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1185. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1186. }
  1187. #endif
  1188. void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1189. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1190. vec3 irradiance = dotNL * directLight.color;
  1191. #ifdef USE_CLEARCOAT
  1192. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1193. vec3 ccIrradiance = dotNLcc * directLight.color;
  1194. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1195. #endif
  1196. #ifdef USE_SHEEN
  1197. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1198. #endif
  1199. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  1200. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1201. }
  1202. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1203. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1204. }
  1205. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  1206. #ifdef USE_CLEARCOAT
  1207. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1208. #endif
  1209. #ifdef USE_SHEEN
  1210. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1211. #endif
  1212. vec3 singleScattering = vec3( 0.0 );
  1213. vec3 multiScattering = vec3( 0.0 );
  1214. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1215. #ifdef USE_IRIDESCENCE
  1216. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1217. #else
  1218. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1219. #endif
  1220. vec3 totalScattering = singleScattering + multiScattering;
  1221. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1222. reflectedLight.indirectSpecular += radiance * singleScattering;
  1223. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1224. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1225. }
  1226. #define RE_Direct RE_Direct_Physical
  1227. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1228. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1229. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1230. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1231. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1232. }`,oh=`
  1233. vec3 geometryPosition = - vViewPosition;
  1234. vec3 geometryNormal = normal;
  1235. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1236. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1237. #ifdef USE_CLEARCOAT
  1238. geometryClearcoatNormal = clearcoatNormal;
  1239. #endif
  1240. #ifdef USE_IRIDESCENCE
  1241. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1242. if ( material.iridescenceThickness == 0.0 ) {
  1243. material.iridescence = 0.0;
  1244. } else {
  1245. material.iridescence = saturate( material.iridescence );
  1246. }
  1247. if ( material.iridescence > 0.0 ) {
  1248. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1249. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1250. }
  1251. #endif
  1252. IncidentLight directLight;
  1253. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1254. PointLight pointLight;
  1255. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1256. PointLightShadow pointLightShadow;
  1257. #endif
  1258. #pragma unroll_loop_start
  1259. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1260. pointLight = pointLights[ i ];
  1261. getPointLightInfo( pointLight, geometryPosition, directLight );
  1262. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1263. pointLightShadow = pointLightShadows[ i ];
  1264. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1265. #endif
  1266. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1267. }
  1268. #pragma unroll_loop_end
  1269. #endif
  1270. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1271. SpotLight spotLight;
  1272. vec4 spotColor;
  1273. vec3 spotLightCoord;
  1274. bool inSpotLightMap;
  1275. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1276. SpotLightShadow spotLightShadow;
  1277. #endif
  1278. #pragma unroll_loop_start
  1279. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1280. spotLight = spotLights[ i ];
  1281. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1282. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1283. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1284. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1285. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1286. #else
  1287. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1288. #endif
  1289. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1290. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1291. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1292. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1293. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1294. #endif
  1295. #undef SPOT_LIGHT_MAP_INDEX
  1296. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1297. spotLightShadow = spotLightShadows[ i ];
  1298. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1299. #endif
  1300. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1301. }
  1302. #pragma unroll_loop_end
  1303. #endif
  1304. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1305. DirectionalLight directionalLight;
  1306. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1307. DirectionalLightShadow directionalLightShadow;
  1308. #endif
  1309. #pragma unroll_loop_start
  1310. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1311. directionalLight = directionalLights[ i ];
  1312. getDirectionalLightInfo( directionalLight, directLight );
  1313. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1314. directionalLightShadow = directionalLightShadows[ i ];
  1315. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1316. #endif
  1317. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1318. }
  1319. #pragma unroll_loop_end
  1320. #endif
  1321. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1322. RectAreaLight rectAreaLight;
  1323. #pragma unroll_loop_start
  1324. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1325. rectAreaLight = rectAreaLights[ i ];
  1326. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1327. }
  1328. #pragma unroll_loop_end
  1329. #endif
  1330. #if defined( RE_IndirectDiffuse )
  1331. vec3 iblIrradiance = vec3( 0.0 );
  1332. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1333. #if defined( USE_LIGHT_PROBES )
  1334. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1335. #endif
  1336. #if ( NUM_HEMI_LIGHTS > 0 )
  1337. #pragma unroll_loop_start
  1338. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1339. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1340. }
  1341. #pragma unroll_loop_end
  1342. #endif
  1343. #endif
  1344. #if defined( RE_IndirectSpecular )
  1345. vec3 radiance = vec3( 0.0 );
  1346. vec3 clearcoatRadiance = vec3( 0.0 );
  1347. #endif`,lh=`#if defined( RE_IndirectDiffuse )
  1348. #ifdef USE_LIGHTMAP
  1349. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1350. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1351. irradiance += lightMapIrradiance;
  1352. #endif
  1353. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1354. iblIrradiance += getIBLIrradiance( geometryNormal );
  1355. #endif
  1356. #endif
  1357. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1358. #ifdef USE_ANISOTROPY
  1359. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1360. #else
  1361. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1362. #endif
  1363. #ifdef USE_CLEARCOAT
  1364. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1365. #endif
  1366. #endif`,ch=`#if defined( RE_IndirectDiffuse )
  1367. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1368. #endif
  1369. #if defined( RE_IndirectSpecular )
  1370. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1371. #endif`,hh=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1372. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1373. #endif`,uh=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1374. uniform float logDepthBufFC;
  1375. varying float vFragDepth;
  1376. varying float vIsPerspective;
  1377. #endif`,dh=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1378. varying float vFragDepth;
  1379. varying float vIsPerspective;
  1380. #endif`,fh=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1381. vFragDepth = 1.0 + gl_Position.w;
  1382. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1383. #endif`,ph=`#ifdef USE_MAP
  1384. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1385. #ifdef DECODE_VIDEO_TEXTURE
  1386. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1387. #endif
  1388. diffuseColor *= sampledDiffuseColor;
  1389. #endif`,mh=`#ifdef USE_MAP
  1390. uniform sampler2D map;
  1391. #endif`,_h=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1392. #if defined( USE_POINTS_UV )
  1393. vec2 uv = vUv;
  1394. #else
  1395. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1396. #endif
  1397. #endif
  1398. #ifdef USE_MAP
  1399. diffuseColor *= texture2D( map, uv );
  1400. #endif
  1401. #ifdef USE_ALPHAMAP
  1402. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1403. #endif`,gh=`#if defined( USE_POINTS_UV )
  1404. varying vec2 vUv;
  1405. #else
  1406. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1407. uniform mat3 uvTransform;
  1408. #endif
  1409. #endif
  1410. #ifdef USE_MAP
  1411. uniform sampler2D map;
  1412. #endif
  1413. #ifdef USE_ALPHAMAP
  1414. uniform sampler2D alphaMap;
  1415. #endif`,vh=`float metalnessFactor = metalness;
  1416. #ifdef USE_METALNESSMAP
  1417. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1418. metalnessFactor *= texelMetalness.b;
  1419. #endif`,xh=`#ifdef USE_METALNESSMAP
  1420. uniform sampler2D metalnessMap;
  1421. #endif`,Mh=`#ifdef USE_INSTANCING_MORPH
  1422. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1423. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1424. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1425. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1426. }
  1427. #endif`,Sh=`#if defined( USE_MORPHCOLORS )
  1428. vColor *= morphTargetBaseInfluence;
  1429. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1430. #if defined( USE_COLOR_ALPHA )
  1431. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1432. #elif defined( USE_COLOR )
  1433. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1434. #endif
  1435. }
  1436. #endif`,Eh=`#ifdef USE_MORPHNORMALS
  1437. objectNormal *= morphTargetBaseInfluence;
  1438. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1439. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1440. }
  1441. #endif`,yh=`#ifdef USE_MORPHTARGETS
  1442. #ifndef USE_INSTANCING_MORPH
  1443. uniform float morphTargetBaseInfluence;
  1444. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1445. #endif
  1446. uniform sampler2DArray morphTargetsTexture;
  1447. uniform ivec2 morphTargetsTextureSize;
  1448. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1449. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1450. int y = texelIndex / morphTargetsTextureSize.x;
  1451. int x = texelIndex - y * morphTargetsTextureSize.x;
  1452. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1453. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1454. }
  1455. #endif`,Th=`#ifdef USE_MORPHTARGETS
  1456. transformed *= morphTargetBaseInfluence;
  1457. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1458. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1459. }
  1460. #endif`,bh=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1461. #ifdef FLAT_SHADED
  1462. vec3 fdx = dFdx( vViewPosition );
  1463. vec3 fdy = dFdy( vViewPosition );
  1464. vec3 normal = normalize( cross( fdx, fdy ) );
  1465. #else
  1466. vec3 normal = normalize( vNormal );
  1467. #ifdef DOUBLE_SIDED
  1468. normal *= faceDirection;
  1469. #endif
  1470. #endif
  1471. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1472. #ifdef USE_TANGENT
  1473. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1474. #else
  1475. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1476. #if defined( USE_NORMALMAP )
  1477. vNormalMapUv
  1478. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1479. vClearcoatNormalMapUv
  1480. #else
  1481. vUv
  1482. #endif
  1483. );
  1484. #endif
  1485. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1486. tbn[0] *= faceDirection;
  1487. tbn[1] *= faceDirection;
  1488. #endif
  1489. #endif
  1490. #ifdef USE_CLEARCOAT_NORMALMAP
  1491. #ifdef USE_TANGENT
  1492. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1493. #else
  1494. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1495. #endif
  1496. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1497. tbn2[0] *= faceDirection;
  1498. tbn2[1] *= faceDirection;
  1499. #endif
  1500. #endif
  1501. vec3 nonPerturbedNormal = normal;`,Ah=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1502. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1503. #ifdef FLIP_SIDED
  1504. normal = - normal;
  1505. #endif
  1506. #ifdef DOUBLE_SIDED
  1507. normal = normal * faceDirection;
  1508. #endif
  1509. normal = normalize( normalMatrix * normal );
  1510. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1511. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1512. mapN.xy *= normalScale;
  1513. normal = normalize( tbn * mapN );
  1514. #elif defined( USE_BUMPMAP )
  1515. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1516. #endif`,Rh=`#ifndef FLAT_SHADED
  1517. varying vec3 vNormal;
  1518. #ifdef USE_TANGENT
  1519. varying vec3 vTangent;
  1520. varying vec3 vBitangent;
  1521. #endif
  1522. #endif`,wh=`#ifndef FLAT_SHADED
  1523. varying vec3 vNormal;
  1524. #ifdef USE_TANGENT
  1525. varying vec3 vTangent;
  1526. varying vec3 vBitangent;
  1527. #endif
  1528. #endif`,Ch=`#ifndef FLAT_SHADED
  1529. vNormal = normalize( transformedNormal );
  1530. #ifdef USE_TANGENT
  1531. vTangent = normalize( transformedTangent );
  1532. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1533. #endif
  1534. #endif`,Ph=`#ifdef USE_NORMALMAP
  1535. uniform sampler2D normalMap;
  1536. uniform vec2 normalScale;
  1537. #endif
  1538. #ifdef USE_NORMALMAP_OBJECTSPACE
  1539. uniform mat3 normalMatrix;
  1540. #endif
  1541. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1542. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1543. vec3 q0 = dFdx( eye_pos.xyz );
  1544. vec3 q1 = dFdy( eye_pos.xyz );
  1545. vec2 st0 = dFdx( uv.st );
  1546. vec2 st1 = dFdy( uv.st );
  1547. vec3 N = surf_norm;
  1548. vec3 q1perp = cross( q1, N );
  1549. vec3 q0perp = cross( N, q0 );
  1550. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1551. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1552. float det = max( dot( T, T ), dot( B, B ) );
  1553. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1554. return mat3( T * scale, B * scale, N );
  1555. }
  1556. #endif`,Dh=`#ifdef USE_CLEARCOAT
  1557. vec3 clearcoatNormal = nonPerturbedNormal;
  1558. #endif`,Lh=`#ifdef USE_CLEARCOAT_NORMALMAP
  1559. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1560. clearcoatMapN.xy *= clearcoatNormalScale;
  1561. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1562. #endif`,Uh=`#ifdef USE_CLEARCOATMAP
  1563. uniform sampler2D clearcoatMap;
  1564. #endif
  1565. #ifdef USE_CLEARCOAT_NORMALMAP
  1566. uniform sampler2D clearcoatNormalMap;
  1567. uniform vec2 clearcoatNormalScale;
  1568. #endif
  1569. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1570. uniform sampler2D clearcoatRoughnessMap;
  1571. #endif`,Ih=`#ifdef USE_IRIDESCENCEMAP
  1572. uniform sampler2D iridescenceMap;
  1573. #endif
  1574. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1575. uniform sampler2D iridescenceThicknessMap;
  1576. #endif`,Nh=`#ifdef OPAQUE
  1577. diffuseColor.a = 1.0;
  1578. #endif
  1579. #ifdef USE_TRANSMISSION
  1580. diffuseColor.a *= material.transmissionAlpha;
  1581. #endif
  1582. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Fh=`vec3 packNormalToRGB( const in vec3 normal ) {
  1583. return normalize( normal ) * 0.5 + 0.5;
  1584. }
  1585. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1586. return 2.0 * rgb.xyz - 1.0;
  1587. }
  1588. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1589. const float Inv255 = 1. / 255.;
  1590. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1591. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1592. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1593. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1594. vec4 packDepthToRGBA( const in float v ) {
  1595. if( v <= 0.0 )
  1596. return vec4( 0., 0., 0., 0. );
  1597. if( v >= 1.0 )
  1598. return vec4( 1., 1., 1., 1. );
  1599. float vuf;
  1600. float af = modf( v * PackFactors.a, vuf );
  1601. float bf = modf( vuf * ShiftRight8, vuf );
  1602. float gf = modf( vuf * ShiftRight8, vuf );
  1603. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1604. }
  1605. vec3 packDepthToRGB( const in float v ) {
  1606. if( v <= 0.0 )
  1607. return vec3( 0., 0., 0. );
  1608. if( v >= 1.0 )
  1609. return vec3( 1., 1., 1. );
  1610. float vuf;
  1611. float bf = modf( v * PackFactors.b, vuf );
  1612. float gf = modf( vuf * ShiftRight8, vuf );
  1613. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1614. }
  1615. vec2 packDepthToRG( const in float v ) {
  1616. if( v <= 0.0 )
  1617. return vec2( 0., 0. );
  1618. if( v >= 1.0 )
  1619. return vec2( 1., 1. );
  1620. float vuf;
  1621. float gf = modf( v * 256., vuf );
  1622. return vec2( vuf * Inv255, gf );
  1623. }
  1624. float unpackRGBAToDepth( const in vec4 v ) {
  1625. return dot( v, UnpackFactors4 );
  1626. }
  1627. float unpackRGBToDepth( const in vec3 v ) {
  1628. return dot( v, UnpackFactors3 );
  1629. }
  1630. float unpackRGToDepth( const in vec2 v ) {
  1631. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1632. }
  1633. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1634. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1635. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1636. }
  1637. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1638. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1639. }
  1640. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1641. return ( viewZ + near ) / ( near - far );
  1642. }
  1643. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1644. return depth * ( near - far ) - near;
  1645. }
  1646. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1647. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1648. }
  1649. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1650. return ( near * far ) / ( ( far - near ) * depth - far );
  1651. }`,Oh=`#ifdef PREMULTIPLIED_ALPHA
  1652. gl_FragColor.rgb *= gl_FragColor.a;
  1653. #endif`,Bh=`vec4 mvPosition = vec4( transformed, 1.0 );
  1654. #ifdef USE_BATCHING
  1655. mvPosition = batchingMatrix * mvPosition;
  1656. #endif
  1657. #ifdef USE_INSTANCING
  1658. mvPosition = instanceMatrix * mvPosition;
  1659. #endif
  1660. mvPosition = modelViewMatrix * mvPosition;
  1661. gl_Position = projectionMatrix * mvPosition;`,zh=`#ifdef DITHERING
  1662. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1663. #endif`,Hh=`#ifdef DITHERING
  1664. vec3 dithering( vec3 color ) {
  1665. float grid_position = rand( gl_FragCoord.xy );
  1666. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1667. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1668. return color + dither_shift_RGB;
  1669. }
  1670. #endif`,Vh=`float roughnessFactor = roughness;
  1671. #ifdef USE_ROUGHNESSMAP
  1672. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1673. roughnessFactor *= texelRoughness.g;
  1674. #endif`,Gh=`#ifdef USE_ROUGHNESSMAP
  1675. uniform sampler2D roughnessMap;
  1676. #endif`,kh=`#if NUM_SPOT_LIGHT_COORDS > 0
  1677. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1678. #endif
  1679. #if NUM_SPOT_LIGHT_MAPS > 0
  1680. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1681. #endif
  1682. #ifdef USE_SHADOWMAP
  1683. #if NUM_DIR_LIGHT_SHADOWS > 0
  1684. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1685. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1686. struct DirectionalLightShadow {
  1687. float shadowIntensity;
  1688. float shadowBias;
  1689. float shadowNormalBias;
  1690. float shadowRadius;
  1691. vec2 shadowMapSize;
  1692. };
  1693. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1694. #endif
  1695. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1696. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1697. struct SpotLightShadow {
  1698. float shadowIntensity;
  1699. float shadowBias;
  1700. float shadowNormalBias;
  1701. float shadowRadius;
  1702. vec2 shadowMapSize;
  1703. };
  1704. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1705. #endif
  1706. #if NUM_POINT_LIGHT_SHADOWS > 0
  1707. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1708. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1709. struct PointLightShadow {
  1710. float shadowIntensity;
  1711. float shadowBias;
  1712. float shadowNormalBias;
  1713. float shadowRadius;
  1714. vec2 shadowMapSize;
  1715. float shadowCameraNear;
  1716. float shadowCameraFar;
  1717. };
  1718. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1719. #endif
  1720. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1721. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1722. #ifdef USE_REVERSED_DEPTH_BUFFER
  1723. return step( depth, compare );
  1724. #else
  1725. return step( compare, depth );
  1726. #endif
  1727. }
  1728. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1729. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1730. }
  1731. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1732. float occlusion = 1.0;
  1733. vec2 distribution = texture2DDistribution( shadow, uv );
  1734. #ifdef USE_REVERSED_DEPTH_BUFFER
  1735. float hard_shadow = step( distribution.x, compare );
  1736. #else
  1737. float hard_shadow = step( compare, distribution.x );
  1738. #endif
  1739. if ( hard_shadow != 1.0 ) {
  1740. float distance = compare - distribution.x;
  1741. float variance = max( 0.00000, distribution.y * distribution.y );
  1742. float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
  1743. }
  1744. return occlusion;
  1745. }
  1746. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1747. float shadow = 1.0;
  1748. shadowCoord.xyz /= shadowCoord.w;
  1749. shadowCoord.z += shadowBias;
  1750. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1751. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1752. if ( frustumTest ) {
  1753. #if defined( SHADOWMAP_TYPE_PCF )
  1754. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1755. float dx0 = - texelSize.x * shadowRadius;
  1756. float dy0 = - texelSize.y * shadowRadius;
  1757. float dx1 = + texelSize.x * shadowRadius;
  1758. float dy1 = + texelSize.y * shadowRadius;
  1759. float dx2 = dx0 / 2.0;
  1760. float dy2 = dy0 / 2.0;
  1761. float dx3 = dx1 / 2.0;
  1762. float dy3 = dy1 / 2.0;
  1763. shadow = (
  1764. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1765. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1766. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1767. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1768. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1769. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1770. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1771. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1772. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1773. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1774. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1775. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1776. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1777. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1778. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1779. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1780. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1781. ) * ( 1.0 / 17.0 );
  1782. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1783. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1784. float dx = texelSize.x;
  1785. float dy = texelSize.y;
  1786. vec2 uv = shadowCoord.xy;
  1787. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1788. uv -= f * texelSize;
  1789. shadow = (
  1790. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1791. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1792. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1793. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1794. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1795. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1796. f.x ) +
  1797. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1798. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1799. f.x ) +
  1800. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1801. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1802. f.y ) +
  1803. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1804. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1805. f.y ) +
  1806. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1807. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1808. f.x ),
  1809. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1810. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1811. f.x ),
  1812. f.y )
  1813. ) * ( 1.0 / 9.0 );
  1814. #elif defined( SHADOWMAP_TYPE_VSM )
  1815. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1816. #else
  1817. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1818. #endif
  1819. }
  1820. return mix( 1.0, shadow, shadowIntensity );
  1821. }
  1822. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1823. vec3 absV = abs( v );
  1824. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1825. absV *= scaleToCube;
  1826. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1827. vec2 planar = v.xy;
  1828. float almostATexel = 1.5 * texelSizeY;
  1829. float almostOne = 1.0 - almostATexel;
  1830. if ( absV.z >= almostOne ) {
  1831. if ( v.z > 0.0 )
  1832. planar.x = 4.0 - v.x;
  1833. } else if ( absV.x >= almostOne ) {
  1834. float signX = sign( v.x );
  1835. planar.x = v.z * signX + 2.0 * signX;
  1836. } else if ( absV.y >= almostOne ) {
  1837. float signY = sign( v.y );
  1838. planar.x = v.x + 2.0 * signY + 2.0;
  1839. planar.y = v.z * signY - 2.0;
  1840. }
  1841. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1842. }
  1843. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1844. float shadow = 1.0;
  1845. vec3 lightToPosition = shadowCoord.xyz;
  1846. float lightToPositionLength = length( lightToPosition );
  1847. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1848. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1849. vec3 bd3D = normalize( lightToPosition );
  1850. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1851. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1852. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1853. shadow = (
  1854. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1855. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1856. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1857. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1858. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1859. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1860. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1861. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1862. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1863. ) * ( 1.0 / 9.0 );
  1864. #else
  1865. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1866. #endif
  1867. }
  1868. return mix( 1.0, shadow, shadowIntensity );
  1869. }
  1870. #endif`,Wh=`#if NUM_SPOT_LIGHT_COORDS > 0
  1871. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1872. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1873. #endif
  1874. #ifdef USE_SHADOWMAP
  1875. #if NUM_DIR_LIGHT_SHADOWS > 0
  1876. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1877. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1878. struct DirectionalLightShadow {
  1879. float shadowIntensity;
  1880. float shadowBias;
  1881. float shadowNormalBias;
  1882. float shadowRadius;
  1883. vec2 shadowMapSize;
  1884. };
  1885. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1886. #endif
  1887. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1888. struct SpotLightShadow {
  1889. float shadowIntensity;
  1890. float shadowBias;
  1891. float shadowNormalBias;
  1892. float shadowRadius;
  1893. vec2 shadowMapSize;
  1894. };
  1895. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1896. #endif
  1897. #if NUM_POINT_LIGHT_SHADOWS > 0
  1898. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1899. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1900. struct PointLightShadow {
  1901. float shadowIntensity;
  1902. float shadowBias;
  1903. float shadowNormalBias;
  1904. float shadowRadius;
  1905. vec2 shadowMapSize;
  1906. float shadowCameraNear;
  1907. float shadowCameraFar;
  1908. };
  1909. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1910. #endif
  1911. #endif`,Xh=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  1912. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1913. vec4 shadowWorldPosition;
  1914. #endif
  1915. #if defined( USE_SHADOWMAP )
  1916. #if NUM_DIR_LIGHT_SHADOWS > 0
  1917. #pragma unroll_loop_start
  1918. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1919. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1920. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1921. }
  1922. #pragma unroll_loop_end
  1923. #endif
  1924. #if NUM_POINT_LIGHT_SHADOWS > 0
  1925. #pragma unroll_loop_start
  1926. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1927. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1928. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1929. }
  1930. #pragma unroll_loop_end
  1931. #endif
  1932. #endif
  1933. #if NUM_SPOT_LIGHT_COORDS > 0
  1934. #pragma unroll_loop_start
  1935. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  1936. shadowWorldPosition = worldPosition;
  1937. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1938. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  1939. #endif
  1940. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  1941. }
  1942. #pragma unroll_loop_end
  1943. #endif`,Yh=`float getShadowMask() {
  1944. float shadow = 1.0;
  1945. #ifdef USE_SHADOWMAP
  1946. #if NUM_DIR_LIGHT_SHADOWS > 0
  1947. DirectionalLightShadow directionalLight;
  1948. #pragma unroll_loop_start
  1949. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1950. directionalLight = directionalLightShadows[ i ];
  1951. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1952. }
  1953. #pragma unroll_loop_end
  1954. #endif
  1955. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1956. SpotLightShadow spotLight;
  1957. #pragma unroll_loop_start
  1958. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1959. spotLight = spotLightShadows[ i ];
  1960. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1961. }
  1962. #pragma unroll_loop_end
  1963. #endif
  1964. #if NUM_POINT_LIGHT_SHADOWS > 0
  1965. PointLightShadow pointLight;
  1966. #pragma unroll_loop_start
  1967. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1968. pointLight = pointLightShadows[ i ];
  1969. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1970. }
  1971. #pragma unroll_loop_end
  1972. #endif
  1973. #endif
  1974. return shadow;
  1975. }`,qh=`#ifdef USE_SKINNING
  1976. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1977. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1978. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1979. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1980. #endif`,Kh=`#ifdef USE_SKINNING
  1981. uniform mat4 bindMatrix;
  1982. uniform mat4 bindMatrixInverse;
  1983. uniform highp sampler2D boneTexture;
  1984. mat4 getBoneMatrix( const in float i ) {
  1985. int size = textureSize( boneTexture, 0 ).x;
  1986. int j = int( i ) * 4;
  1987. int x = j % size;
  1988. int y = j / size;
  1989. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  1990. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  1991. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  1992. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  1993. return mat4( v1, v2, v3, v4 );
  1994. }
  1995. #endif`,Zh=`#ifdef USE_SKINNING
  1996. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  1997. vec4 skinned = vec4( 0.0 );
  1998. skinned += boneMatX * skinVertex * skinWeight.x;
  1999. skinned += boneMatY * skinVertex * skinWeight.y;
  2000. skinned += boneMatZ * skinVertex * skinWeight.z;
  2001. skinned += boneMatW * skinVertex * skinWeight.w;
  2002. transformed = ( bindMatrixInverse * skinned ).xyz;
  2003. #endif`,jh=`#ifdef USE_SKINNING
  2004. mat4 skinMatrix = mat4( 0.0 );
  2005. skinMatrix += skinWeight.x * boneMatX;
  2006. skinMatrix += skinWeight.y * boneMatY;
  2007. skinMatrix += skinWeight.z * boneMatZ;
  2008. skinMatrix += skinWeight.w * boneMatW;
  2009. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2010. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2011. #ifdef USE_TANGENT
  2012. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2013. #endif
  2014. #endif`,$h=`float specularStrength;
  2015. #ifdef USE_SPECULARMAP
  2016. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2017. specularStrength = texelSpecular.r;
  2018. #else
  2019. specularStrength = 1.0;
  2020. #endif`,Jh=`#ifdef USE_SPECULARMAP
  2021. uniform sampler2D specularMap;
  2022. #endif`,Qh=`#if defined( TONE_MAPPING )
  2023. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2024. #endif`,tu=`#ifndef saturate
  2025. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2026. #endif
  2027. uniform float toneMappingExposure;
  2028. vec3 LinearToneMapping( vec3 color ) {
  2029. return saturate( toneMappingExposure * color );
  2030. }
  2031. vec3 ReinhardToneMapping( vec3 color ) {
  2032. color *= toneMappingExposure;
  2033. return saturate( color / ( vec3( 1.0 ) + color ) );
  2034. }
  2035. vec3 CineonToneMapping( vec3 color ) {
  2036. color *= toneMappingExposure;
  2037. color = max( vec3( 0.0 ), color - 0.004 );
  2038. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2039. }
  2040. vec3 RRTAndODTFit( vec3 v ) {
  2041. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2042. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2043. return a / b;
  2044. }
  2045. vec3 ACESFilmicToneMapping( vec3 color ) {
  2046. const mat3 ACESInputMat = mat3(
  2047. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2048. vec3( 0.04823, 0.01566, 0.83777 )
  2049. );
  2050. const mat3 ACESOutputMat = mat3(
  2051. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2052. vec3( -0.07367, -0.00605, 1.07602 )
  2053. );
  2054. color *= toneMappingExposure / 0.6;
  2055. color = ACESInputMat * color;
  2056. color = RRTAndODTFit( color );
  2057. color = ACESOutputMat * color;
  2058. return saturate( color );
  2059. }
  2060. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2061. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2062. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2063. vec3( - 0.0728, - 0.0083, 1.1187 )
  2064. );
  2065. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2066. vec3( 0.6274, 0.0691, 0.0164 ),
  2067. vec3( 0.3293, 0.9195, 0.0880 ),
  2068. vec3( 0.0433, 0.0113, 0.8956 )
  2069. );
  2070. vec3 agxDefaultContrastApprox( vec3 x ) {
  2071. vec3 x2 = x * x;
  2072. vec3 x4 = x2 * x2;
  2073. return + 15.5 * x4 * x2
  2074. - 40.14 * x4 * x
  2075. + 31.96 * x4
  2076. - 6.868 * x2 * x
  2077. + 0.4298 * x2
  2078. + 0.1191 * x
  2079. - 0.00232;
  2080. }
  2081. vec3 AgXToneMapping( vec3 color ) {
  2082. const mat3 AgXInsetMatrix = mat3(
  2083. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2084. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2085. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2086. );
  2087. const mat3 AgXOutsetMatrix = mat3(
  2088. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2089. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2090. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2091. );
  2092. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2093. color *= toneMappingExposure;
  2094. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2095. color = AgXInsetMatrix * color;
  2096. color = max( color, 1e-10 ); color = log2( color );
  2097. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2098. color = clamp( color, 0.0, 1.0 );
  2099. color = agxDefaultContrastApprox( color );
  2100. color = AgXOutsetMatrix * color;
  2101. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2102. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2103. color = clamp( color, 0.0, 1.0 );
  2104. return color;
  2105. }
  2106. vec3 NeutralToneMapping( vec3 color ) {
  2107. const float StartCompression = 0.8 - 0.04;
  2108. const float Desaturation = 0.15;
  2109. color *= toneMappingExposure;
  2110. float x = min( color.r, min( color.g, color.b ) );
  2111. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2112. color -= offset;
  2113. float peak = max( color.r, max( color.g, color.b ) );
  2114. if ( peak < StartCompression ) return color;
  2115. float d = 1. - StartCompression;
  2116. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2117. color *= newPeak / peak;
  2118. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2119. return mix( color, vec3( newPeak ), g );
  2120. }
  2121. vec3 CustomToneMapping( vec3 color ) { return color; }`,eu=`#ifdef USE_TRANSMISSION
  2122. material.transmission = transmission;
  2123. material.transmissionAlpha = 1.0;
  2124. material.thickness = thickness;
  2125. material.attenuationDistance = attenuationDistance;
  2126. material.attenuationColor = attenuationColor;
  2127. #ifdef USE_TRANSMISSIONMAP
  2128. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2129. #endif
  2130. #ifdef USE_THICKNESSMAP
  2131. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2132. #endif
  2133. vec3 pos = vWorldPosition;
  2134. vec3 v = normalize( cameraPosition - pos );
  2135. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2136. vec4 transmitted = getIBLVolumeRefraction(
  2137. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2138. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2139. material.attenuationColor, material.attenuationDistance );
  2140. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2141. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2142. #endif`,nu=`#ifdef USE_TRANSMISSION
  2143. uniform float transmission;
  2144. uniform float thickness;
  2145. uniform float attenuationDistance;
  2146. uniform vec3 attenuationColor;
  2147. #ifdef USE_TRANSMISSIONMAP
  2148. uniform sampler2D transmissionMap;
  2149. #endif
  2150. #ifdef USE_THICKNESSMAP
  2151. uniform sampler2D thicknessMap;
  2152. #endif
  2153. uniform vec2 transmissionSamplerSize;
  2154. uniform sampler2D transmissionSamplerMap;
  2155. uniform mat4 modelMatrix;
  2156. uniform mat4 projectionMatrix;
  2157. varying vec3 vWorldPosition;
  2158. float w0( float a ) {
  2159. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2160. }
  2161. float w1( float a ) {
  2162. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2163. }
  2164. float w2( float a ){
  2165. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2166. }
  2167. float w3( float a ) {
  2168. return ( 1.0 / 6.0 ) * ( a * a * a );
  2169. }
  2170. float g0( float a ) {
  2171. return w0( a ) + w1( a );
  2172. }
  2173. float g1( float a ) {
  2174. return w2( a ) + w3( a );
  2175. }
  2176. float h0( float a ) {
  2177. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2178. }
  2179. float h1( float a ) {
  2180. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2181. }
  2182. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2183. uv = uv * texelSize.zw + 0.5;
  2184. vec2 iuv = floor( uv );
  2185. vec2 fuv = fract( uv );
  2186. float g0x = g0( fuv.x );
  2187. float g1x = g1( fuv.x );
  2188. float h0x = h0( fuv.x );
  2189. float h1x = h1( fuv.x );
  2190. float h0y = h0( fuv.y );
  2191. float h1y = h1( fuv.y );
  2192. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2193. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2194. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2195. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2196. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2197. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2198. }
  2199. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2200. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2201. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2202. vec2 fLodSizeInv = 1.0 / fLodSize;
  2203. vec2 cLodSizeInv = 1.0 / cLodSize;
  2204. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2205. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2206. return mix( fSample, cSample, fract( lod ) );
  2207. }
  2208. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2209. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2210. vec3 modelScale;
  2211. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2212. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2213. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2214. return normalize( refractionVector ) * thickness * modelScale;
  2215. }
  2216. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2217. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2218. }
  2219. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2220. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2221. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2222. }
  2223. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2224. if ( isinf( attenuationDistance ) ) {
  2225. return vec3( 1.0 );
  2226. } else {
  2227. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2228. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2229. }
  2230. }
  2231. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2232. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2233. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2234. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2235. vec4 transmittedLight;
  2236. vec3 transmittance;
  2237. #ifdef USE_DISPERSION
  2238. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2239. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2240. for ( int i = 0; i < 3; i ++ ) {
  2241. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2242. vec3 refractedRayExit = position + transmissionRay;
  2243. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2244. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2245. refractionCoords += 1.0;
  2246. refractionCoords /= 2.0;
  2247. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2248. transmittedLight[ i ] = transmissionSample[ i ];
  2249. transmittedLight.a += transmissionSample.a;
  2250. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2251. }
  2252. transmittedLight.a /= 3.0;
  2253. #else
  2254. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2255. vec3 refractedRayExit = position + transmissionRay;
  2256. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2257. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2258. refractionCoords += 1.0;
  2259. refractionCoords /= 2.0;
  2260. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2261. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2262. #endif
  2263. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2264. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2265. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2266. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2267. }
  2268. #endif`,iu=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2269. varying vec2 vUv;
  2270. #endif
  2271. #ifdef USE_MAP
  2272. varying vec2 vMapUv;
  2273. #endif
  2274. #ifdef USE_ALPHAMAP
  2275. varying vec2 vAlphaMapUv;
  2276. #endif
  2277. #ifdef USE_LIGHTMAP
  2278. varying vec2 vLightMapUv;
  2279. #endif
  2280. #ifdef USE_AOMAP
  2281. varying vec2 vAoMapUv;
  2282. #endif
  2283. #ifdef USE_BUMPMAP
  2284. varying vec2 vBumpMapUv;
  2285. #endif
  2286. #ifdef USE_NORMALMAP
  2287. varying vec2 vNormalMapUv;
  2288. #endif
  2289. #ifdef USE_EMISSIVEMAP
  2290. varying vec2 vEmissiveMapUv;
  2291. #endif
  2292. #ifdef USE_METALNESSMAP
  2293. varying vec2 vMetalnessMapUv;
  2294. #endif
  2295. #ifdef USE_ROUGHNESSMAP
  2296. varying vec2 vRoughnessMapUv;
  2297. #endif
  2298. #ifdef USE_ANISOTROPYMAP
  2299. varying vec2 vAnisotropyMapUv;
  2300. #endif
  2301. #ifdef USE_CLEARCOATMAP
  2302. varying vec2 vClearcoatMapUv;
  2303. #endif
  2304. #ifdef USE_CLEARCOAT_NORMALMAP
  2305. varying vec2 vClearcoatNormalMapUv;
  2306. #endif
  2307. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2308. varying vec2 vClearcoatRoughnessMapUv;
  2309. #endif
  2310. #ifdef USE_IRIDESCENCEMAP
  2311. varying vec2 vIridescenceMapUv;
  2312. #endif
  2313. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2314. varying vec2 vIridescenceThicknessMapUv;
  2315. #endif
  2316. #ifdef USE_SHEEN_COLORMAP
  2317. varying vec2 vSheenColorMapUv;
  2318. #endif
  2319. #ifdef USE_SHEEN_ROUGHNESSMAP
  2320. varying vec2 vSheenRoughnessMapUv;
  2321. #endif
  2322. #ifdef USE_SPECULARMAP
  2323. varying vec2 vSpecularMapUv;
  2324. #endif
  2325. #ifdef USE_SPECULAR_COLORMAP
  2326. varying vec2 vSpecularColorMapUv;
  2327. #endif
  2328. #ifdef USE_SPECULAR_INTENSITYMAP
  2329. varying vec2 vSpecularIntensityMapUv;
  2330. #endif
  2331. #ifdef USE_TRANSMISSIONMAP
  2332. uniform mat3 transmissionMapTransform;
  2333. varying vec2 vTransmissionMapUv;
  2334. #endif
  2335. #ifdef USE_THICKNESSMAP
  2336. uniform mat3 thicknessMapTransform;
  2337. varying vec2 vThicknessMapUv;
  2338. #endif`,ru=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2339. varying vec2 vUv;
  2340. #endif
  2341. #ifdef USE_MAP
  2342. uniform mat3 mapTransform;
  2343. varying vec2 vMapUv;
  2344. #endif
  2345. #ifdef USE_ALPHAMAP
  2346. uniform mat3 alphaMapTransform;
  2347. varying vec2 vAlphaMapUv;
  2348. #endif
  2349. #ifdef USE_LIGHTMAP
  2350. uniform mat3 lightMapTransform;
  2351. varying vec2 vLightMapUv;
  2352. #endif
  2353. #ifdef USE_AOMAP
  2354. uniform mat3 aoMapTransform;
  2355. varying vec2 vAoMapUv;
  2356. #endif
  2357. #ifdef USE_BUMPMAP
  2358. uniform mat3 bumpMapTransform;
  2359. varying vec2 vBumpMapUv;
  2360. #endif
  2361. #ifdef USE_NORMALMAP
  2362. uniform mat3 normalMapTransform;
  2363. varying vec2 vNormalMapUv;
  2364. #endif
  2365. #ifdef USE_DISPLACEMENTMAP
  2366. uniform mat3 displacementMapTransform;
  2367. varying vec2 vDisplacementMapUv;
  2368. #endif
  2369. #ifdef USE_EMISSIVEMAP
  2370. uniform mat3 emissiveMapTransform;
  2371. varying vec2 vEmissiveMapUv;
  2372. #endif
  2373. #ifdef USE_METALNESSMAP
  2374. uniform mat3 metalnessMapTransform;
  2375. varying vec2 vMetalnessMapUv;
  2376. #endif
  2377. #ifdef USE_ROUGHNESSMAP
  2378. uniform mat3 roughnessMapTransform;
  2379. varying vec2 vRoughnessMapUv;
  2380. #endif
  2381. #ifdef USE_ANISOTROPYMAP
  2382. uniform mat3 anisotropyMapTransform;
  2383. varying vec2 vAnisotropyMapUv;
  2384. #endif
  2385. #ifdef USE_CLEARCOATMAP
  2386. uniform mat3 clearcoatMapTransform;
  2387. varying vec2 vClearcoatMapUv;
  2388. #endif
  2389. #ifdef USE_CLEARCOAT_NORMALMAP
  2390. uniform mat3 clearcoatNormalMapTransform;
  2391. varying vec2 vClearcoatNormalMapUv;
  2392. #endif
  2393. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2394. uniform mat3 clearcoatRoughnessMapTransform;
  2395. varying vec2 vClearcoatRoughnessMapUv;
  2396. #endif
  2397. #ifdef USE_SHEEN_COLORMAP
  2398. uniform mat3 sheenColorMapTransform;
  2399. varying vec2 vSheenColorMapUv;
  2400. #endif
  2401. #ifdef USE_SHEEN_ROUGHNESSMAP
  2402. uniform mat3 sheenRoughnessMapTransform;
  2403. varying vec2 vSheenRoughnessMapUv;
  2404. #endif
  2405. #ifdef USE_IRIDESCENCEMAP
  2406. uniform mat3 iridescenceMapTransform;
  2407. varying vec2 vIridescenceMapUv;
  2408. #endif
  2409. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2410. uniform mat3 iridescenceThicknessMapTransform;
  2411. varying vec2 vIridescenceThicknessMapUv;
  2412. #endif
  2413. #ifdef USE_SPECULARMAP
  2414. uniform mat3 specularMapTransform;
  2415. varying vec2 vSpecularMapUv;
  2416. #endif
  2417. #ifdef USE_SPECULAR_COLORMAP
  2418. uniform mat3 specularColorMapTransform;
  2419. varying vec2 vSpecularColorMapUv;
  2420. #endif
  2421. #ifdef USE_SPECULAR_INTENSITYMAP
  2422. uniform mat3 specularIntensityMapTransform;
  2423. varying vec2 vSpecularIntensityMapUv;
  2424. #endif
  2425. #ifdef USE_TRANSMISSIONMAP
  2426. uniform mat3 transmissionMapTransform;
  2427. varying vec2 vTransmissionMapUv;
  2428. #endif
  2429. #ifdef USE_THICKNESSMAP
  2430. uniform mat3 thicknessMapTransform;
  2431. varying vec2 vThicknessMapUv;
  2432. #endif`,su=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2433. vUv = vec3( uv, 1 ).xy;
  2434. #endif
  2435. #ifdef USE_MAP
  2436. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2437. #endif
  2438. #ifdef USE_ALPHAMAP
  2439. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2440. #endif
  2441. #ifdef USE_LIGHTMAP
  2442. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2443. #endif
  2444. #ifdef USE_AOMAP
  2445. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2446. #endif
  2447. #ifdef USE_BUMPMAP
  2448. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2449. #endif
  2450. #ifdef USE_NORMALMAP
  2451. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2452. #endif
  2453. #ifdef USE_DISPLACEMENTMAP
  2454. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2455. #endif
  2456. #ifdef USE_EMISSIVEMAP
  2457. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2458. #endif
  2459. #ifdef USE_METALNESSMAP
  2460. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2461. #endif
  2462. #ifdef USE_ROUGHNESSMAP
  2463. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2464. #endif
  2465. #ifdef USE_ANISOTROPYMAP
  2466. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2467. #endif
  2468. #ifdef USE_CLEARCOATMAP
  2469. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2470. #endif
  2471. #ifdef USE_CLEARCOAT_NORMALMAP
  2472. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2473. #endif
  2474. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2475. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2476. #endif
  2477. #ifdef USE_IRIDESCENCEMAP
  2478. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2479. #endif
  2480. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2481. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2482. #endif
  2483. #ifdef USE_SHEEN_COLORMAP
  2484. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2485. #endif
  2486. #ifdef USE_SHEEN_ROUGHNESSMAP
  2487. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2488. #endif
  2489. #ifdef USE_SPECULARMAP
  2490. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2491. #endif
  2492. #ifdef USE_SPECULAR_COLORMAP
  2493. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2494. #endif
  2495. #ifdef USE_SPECULAR_INTENSITYMAP
  2496. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2497. #endif
  2498. #ifdef USE_TRANSMISSIONMAP
  2499. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2500. #endif
  2501. #ifdef USE_THICKNESSMAP
  2502. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2503. #endif`,au=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2504. vec4 worldPosition = vec4( transformed, 1.0 );
  2505. #ifdef USE_BATCHING
  2506. worldPosition = batchingMatrix * worldPosition;
  2507. #endif
  2508. #ifdef USE_INSTANCING
  2509. worldPosition = instanceMatrix * worldPosition;
  2510. #endif
  2511. worldPosition = modelMatrix * worldPosition;
  2512. #endif`;const ou=`varying vec2 vUv;
  2513. uniform mat3 uvTransform;
  2514. void main() {
  2515. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2516. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2517. }`,lu=`uniform sampler2D t2D;
  2518. uniform float backgroundIntensity;
  2519. varying vec2 vUv;
  2520. void main() {
  2521. vec4 texColor = texture2D( t2D, vUv );
  2522. #ifdef DECODE_VIDEO_TEXTURE
  2523. texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
  2524. #endif
  2525. texColor.rgb *= backgroundIntensity;
  2526. gl_FragColor = texColor;
  2527. #include <tonemapping_fragment>
  2528. #include <colorspace_fragment>
  2529. }`,cu=`varying vec3 vWorldDirection;
  2530. #include <common>
  2531. void main() {
  2532. vWorldDirection = transformDirection( position, modelMatrix );
  2533. #include <begin_vertex>
  2534. #include <project_vertex>
  2535. gl_Position.z = gl_Position.w;
  2536. }`,hu=`#ifdef ENVMAP_TYPE_CUBE
  2537. uniform samplerCube envMap;
  2538. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2539. uniform sampler2D envMap;
  2540. #endif
  2541. uniform float flipEnvMap;
  2542. uniform float backgroundBlurriness;
  2543. uniform float backgroundIntensity;
  2544. uniform mat3 backgroundRotation;
  2545. varying vec3 vWorldDirection;
  2546. #include <cube_uv_reflection_fragment>
  2547. void main() {
  2548. #ifdef ENVMAP_TYPE_CUBE
  2549. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2550. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2551. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2552. #else
  2553. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2554. #endif
  2555. texColor.rgb *= backgroundIntensity;
  2556. gl_FragColor = texColor;
  2557. #include <tonemapping_fragment>
  2558. #include <colorspace_fragment>
  2559. }`,uu=`varying vec3 vWorldDirection;
  2560. #include <common>
  2561. void main() {
  2562. vWorldDirection = transformDirection( position, modelMatrix );
  2563. #include <begin_vertex>
  2564. #include <project_vertex>
  2565. gl_Position.z = gl_Position.w;
  2566. }`,du=`uniform samplerCube tCube;
  2567. uniform float tFlip;
  2568. uniform float opacity;
  2569. varying vec3 vWorldDirection;
  2570. void main() {
  2571. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2572. gl_FragColor = texColor;
  2573. gl_FragColor.a *= opacity;
  2574. #include <tonemapping_fragment>
  2575. #include <colorspace_fragment>
  2576. }`,fu=`#include <common>
  2577. #include <batching_pars_vertex>
  2578. #include <uv_pars_vertex>
  2579. #include <displacementmap_pars_vertex>
  2580. #include <morphtarget_pars_vertex>
  2581. #include <skinning_pars_vertex>
  2582. #include <logdepthbuf_pars_vertex>
  2583. #include <clipping_planes_pars_vertex>
  2584. varying vec2 vHighPrecisionZW;
  2585. void main() {
  2586. #include <uv_vertex>
  2587. #include <batching_vertex>
  2588. #include <skinbase_vertex>
  2589. #include <morphinstance_vertex>
  2590. #ifdef USE_DISPLACEMENTMAP
  2591. #include <beginnormal_vertex>
  2592. #include <morphnormal_vertex>
  2593. #include <skinnormal_vertex>
  2594. #endif
  2595. #include <begin_vertex>
  2596. #include <morphtarget_vertex>
  2597. #include <skinning_vertex>
  2598. #include <displacementmap_vertex>
  2599. #include <project_vertex>
  2600. #include <logdepthbuf_vertex>
  2601. #include <clipping_planes_vertex>
  2602. vHighPrecisionZW = gl_Position.zw;
  2603. }`,pu=`#if DEPTH_PACKING == 3200
  2604. uniform float opacity;
  2605. #endif
  2606. #include <common>
  2607. #include <packing>
  2608. #include <uv_pars_fragment>
  2609. #include <map_pars_fragment>
  2610. #include <alphamap_pars_fragment>
  2611. #include <alphatest_pars_fragment>
  2612. #include <alphahash_pars_fragment>
  2613. #include <logdepthbuf_pars_fragment>
  2614. #include <clipping_planes_pars_fragment>
  2615. varying vec2 vHighPrecisionZW;
  2616. void main() {
  2617. vec4 diffuseColor = vec4( 1.0 );
  2618. #include <clipping_planes_fragment>
  2619. #if DEPTH_PACKING == 3200
  2620. diffuseColor.a = opacity;
  2621. #endif
  2622. #include <map_fragment>
  2623. #include <alphamap_fragment>
  2624. #include <alphatest_fragment>
  2625. #include <alphahash_fragment>
  2626. #include <logdepthbuf_fragment>
  2627. #ifdef USE_REVERSED_DEPTH_BUFFER
  2628. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2629. #else
  2630. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2631. #endif
  2632. #if DEPTH_PACKING == 3200
  2633. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2634. #elif DEPTH_PACKING == 3201
  2635. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2636. #elif DEPTH_PACKING == 3202
  2637. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2638. #elif DEPTH_PACKING == 3203
  2639. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2640. #endif
  2641. }`,mu=`#define DISTANCE
  2642. varying vec3 vWorldPosition;
  2643. #include <common>
  2644. #include <batching_pars_vertex>
  2645. #include <uv_pars_vertex>
  2646. #include <displacementmap_pars_vertex>
  2647. #include <morphtarget_pars_vertex>
  2648. #include <skinning_pars_vertex>
  2649. #include <clipping_planes_pars_vertex>
  2650. void main() {
  2651. #include <uv_vertex>
  2652. #include <batching_vertex>
  2653. #include <skinbase_vertex>
  2654. #include <morphinstance_vertex>
  2655. #ifdef USE_DISPLACEMENTMAP
  2656. #include <beginnormal_vertex>
  2657. #include <morphnormal_vertex>
  2658. #include <skinnormal_vertex>
  2659. #endif
  2660. #include <begin_vertex>
  2661. #include <morphtarget_vertex>
  2662. #include <skinning_vertex>
  2663. #include <displacementmap_vertex>
  2664. #include <project_vertex>
  2665. #include <worldpos_vertex>
  2666. #include <clipping_planes_vertex>
  2667. vWorldPosition = worldPosition.xyz;
  2668. }`,_u=`#define DISTANCE
  2669. uniform vec3 referencePosition;
  2670. uniform float nearDistance;
  2671. uniform float farDistance;
  2672. varying vec3 vWorldPosition;
  2673. #include <common>
  2674. #include <packing>
  2675. #include <uv_pars_fragment>
  2676. #include <map_pars_fragment>
  2677. #include <alphamap_pars_fragment>
  2678. #include <alphatest_pars_fragment>
  2679. #include <alphahash_pars_fragment>
  2680. #include <clipping_planes_pars_fragment>
  2681. void main () {
  2682. vec4 diffuseColor = vec4( 1.0 );
  2683. #include <clipping_planes_fragment>
  2684. #include <map_fragment>
  2685. #include <alphamap_fragment>
  2686. #include <alphatest_fragment>
  2687. #include <alphahash_fragment>
  2688. float dist = length( vWorldPosition - referencePosition );
  2689. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2690. dist = saturate( dist );
  2691. gl_FragColor = packDepthToRGBA( dist );
  2692. }`,gu=`varying vec3 vWorldDirection;
  2693. #include <common>
  2694. void main() {
  2695. vWorldDirection = transformDirection( position, modelMatrix );
  2696. #include <begin_vertex>
  2697. #include <project_vertex>
  2698. }`,vu=`uniform sampler2D tEquirect;
  2699. varying vec3 vWorldDirection;
  2700. #include <common>
  2701. void main() {
  2702. vec3 direction = normalize( vWorldDirection );
  2703. vec2 sampleUV = equirectUv( direction );
  2704. gl_FragColor = texture2D( tEquirect, sampleUV );
  2705. #include <tonemapping_fragment>
  2706. #include <colorspace_fragment>
  2707. }`,xu=`uniform float scale;
  2708. attribute float lineDistance;
  2709. varying float vLineDistance;
  2710. #include <common>
  2711. #include <uv_pars_vertex>
  2712. #include <color_pars_vertex>
  2713. #include <fog_pars_vertex>
  2714. #include <morphtarget_pars_vertex>
  2715. #include <logdepthbuf_pars_vertex>
  2716. #include <clipping_planes_pars_vertex>
  2717. void main() {
  2718. vLineDistance = scale * lineDistance;
  2719. #include <uv_vertex>
  2720. #include <color_vertex>
  2721. #include <morphinstance_vertex>
  2722. #include <morphcolor_vertex>
  2723. #include <begin_vertex>
  2724. #include <morphtarget_vertex>
  2725. #include <project_vertex>
  2726. #include <logdepthbuf_vertex>
  2727. #include <clipping_planes_vertex>
  2728. #include <fog_vertex>
  2729. }`,Mu=`uniform vec3 diffuse;
  2730. uniform float opacity;
  2731. uniform float dashSize;
  2732. uniform float totalSize;
  2733. varying float vLineDistance;
  2734. #include <common>
  2735. #include <color_pars_fragment>
  2736. #include <uv_pars_fragment>
  2737. #include <map_pars_fragment>
  2738. #include <fog_pars_fragment>
  2739. #include <logdepthbuf_pars_fragment>
  2740. #include <clipping_planes_pars_fragment>
  2741. void main() {
  2742. vec4 diffuseColor = vec4( diffuse, opacity );
  2743. #include <clipping_planes_fragment>
  2744. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2745. discard;
  2746. }
  2747. vec3 outgoingLight = vec3( 0.0 );
  2748. #include <logdepthbuf_fragment>
  2749. #include <map_fragment>
  2750. #include <color_fragment>
  2751. outgoingLight = diffuseColor.rgb;
  2752. #include <opaque_fragment>
  2753. #include <tonemapping_fragment>
  2754. #include <colorspace_fragment>
  2755. #include <fog_fragment>
  2756. #include <premultiplied_alpha_fragment>
  2757. }`,Su=`#include <common>
  2758. #include <batching_pars_vertex>
  2759. #include <uv_pars_vertex>
  2760. #include <envmap_pars_vertex>
  2761. #include <color_pars_vertex>
  2762. #include <fog_pars_vertex>
  2763. #include <morphtarget_pars_vertex>
  2764. #include <skinning_pars_vertex>
  2765. #include <logdepthbuf_pars_vertex>
  2766. #include <clipping_planes_pars_vertex>
  2767. void main() {
  2768. #include <uv_vertex>
  2769. #include <color_vertex>
  2770. #include <morphinstance_vertex>
  2771. #include <morphcolor_vertex>
  2772. #include <batching_vertex>
  2773. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2774. #include <beginnormal_vertex>
  2775. #include <morphnormal_vertex>
  2776. #include <skinbase_vertex>
  2777. #include <skinnormal_vertex>
  2778. #include <defaultnormal_vertex>
  2779. #endif
  2780. #include <begin_vertex>
  2781. #include <morphtarget_vertex>
  2782. #include <skinning_vertex>
  2783. #include <project_vertex>
  2784. #include <logdepthbuf_vertex>
  2785. #include <clipping_planes_vertex>
  2786. #include <worldpos_vertex>
  2787. #include <envmap_vertex>
  2788. #include <fog_vertex>
  2789. }`,Eu=`uniform vec3 diffuse;
  2790. uniform float opacity;
  2791. #ifndef FLAT_SHADED
  2792. varying vec3 vNormal;
  2793. #endif
  2794. #include <common>
  2795. #include <dithering_pars_fragment>
  2796. #include <color_pars_fragment>
  2797. #include <uv_pars_fragment>
  2798. #include <map_pars_fragment>
  2799. #include <alphamap_pars_fragment>
  2800. #include <alphatest_pars_fragment>
  2801. #include <alphahash_pars_fragment>
  2802. #include <aomap_pars_fragment>
  2803. #include <lightmap_pars_fragment>
  2804. #include <envmap_common_pars_fragment>
  2805. #include <envmap_pars_fragment>
  2806. #include <fog_pars_fragment>
  2807. #include <specularmap_pars_fragment>
  2808. #include <logdepthbuf_pars_fragment>
  2809. #include <clipping_planes_pars_fragment>
  2810. void main() {
  2811. vec4 diffuseColor = vec4( diffuse, opacity );
  2812. #include <clipping_planes_fragment>
  2813. #include <logdepthbuf_fragment>
  2814. #include <map_fragment>
  2815. #include <color_fragment>
  2816. #include <alphamap_fragment>
  2817. #include <alphatest_fragment>
  2818. #include <alphahash_fragment>
  2819. #include <specularmap_fragment>
  2820. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2821. #ifdef USE_LIGHTMAP
  2822. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2823. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2824. #else
  2825. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2826. #endif
  2827. #include <aomap_fragment>
  2828. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2829. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2830. #include <envmap_fragment>
  2831. #include <opaque_fragment>
  2832. #include <tonemapping_fragment>
  2833. #include <colorspace_fragment>
  2834. #include <fog_fragment>
  2835. #include <premultiplied_alpha_fragment>
  2836. #include <dithering_fragment>
  2837. }`,yu=`#define LAMBERT
  2838. varying vec3 vViewPosition;
  2839. #include <common>
  2840. #include <batching_pars_vertex>
  2841. #include <uv_pars_vertex>
  2842. #include <displacementmap_pars_vertex>
  2843. #include <envmap_pars_vertex>
  2844. #include <color_pars_vertex>
  2845. #include <fog_pars_vertex>
  2846. #include <normal_pars_vertex>
  2847. #include <morphtarget_pars_vertex>
  2848. #include <skinning_pars_vertex>
  2849. #include <shadowmap_pars_vertex>
  2850. #include <logdepthbuf_pars_vertex>
  2851. #include <clipping_planes_pars_vertex>
  2852. void main() {
  2853. #include <uv_vertex>
  2854. #include <color_vertex>
  2855. #include <morphinstance_vertex>
  2856. #include <morphcolor_vertex>
  2857. #include <batching_vertex>
  2858. #include <beginnormal_vertex>
  2859. #include <morphnormal_vertex>
  2860. #include <skinbase_vertex>
  2861. #include <skinnormal_vertex>
  2862. #include <defaultnormal_vertex>
  2863. #include <normal_vertex>
  2864. #include <begin_vertex>
  2865. #include <morphtarget_vertex>
  2866. #include <skinning_vertex>
  2867. #include <displacementmap_vertex>
  2868. #include <project_vertex>
  2869. #include <logdepthbuf_vertex>
  2870. #include <clipping_planes_vertex>
  2871. vViewPosition = - mvPosition.xyz;
  2872. #include <worldpos_vertex>
  2873. #include <envmap_vertex>
  2874. #include <shadowmap_vertex>
  2875. #include <fog_vertex>
  2876. }`,Tu=`#define LAMBERT
  2877. uniform vec3 diffuse;
  2878. uniform vec3 emissive;
  2879. uniform float opacity;
  2880. #include <common>
  2881. #include <packing>
  2882. #include <dithering_pars_fragment>
  2883. #include <color_pars_fragment>
  2884. #include <uv_pars_fragment>
  2885. #include <map_pars_fragment>
  2886. #include <alphamap_pars_fragment>
  2887. #include <alphatest_pars_fragment>
  2888. #include <alphahash_pars_fragment>
  2889. #include <aomap_pars_fragment>
  2890. #include <lightmap_pars_fragment>
  2891. #include <emissivemap_pars_fragment>
  2892. #include <envmap_common_pars_fragment>
  2893. #include <envmap_pars_fragment>
  2894. #include <fog_pars_fragment>
  2895. #include <bsdfs>
  2896. #include <lights_pars_begin>
  2897. #include <normal_pars_fragment>
  2898. #include <lights_lambert_pars_fragment>
  2899. #include <shadowmap_pars_fragment>
  2900. #include <bumpmap_pars_fragment>
  2901. #include <normalmap_pars_fragment>
  2902. #include <specularmap_pars_fragment>
  2903. #include <logdepthbuf_pars_fragment>
  2904. #include <clipping_planes_pars_fragment>
  2905. void main() {
  2906. vec4 diffuseColor = vec4( diffuse, opacity );
  2907. #include <clipping_planes_fragment>
  2908. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2909. vec3 totalEmissiveRadiance = emissive;
  2910. #include <logdepthbuf_fragment>
  2911. #include <map_fragment>
  2912. #include <color_fragment>
  2913. #include <alphamap_fragment>
  2914. #include <alphatest_fragment>
  2915. #include <alphahash_fragment>
  2916. #include <specularmap_fragment>
  2917. #include <normal_fragment_begin>
  2918. #include <normal_fragment_maps>
  2919. #include <emissivemap_fragment>
  2920. #include <lights_lambert_fragment>
  2921. #include <lights_fragment_begin>
  2922. #include <lights_fragment_maps>
  2923. #include <lights_fragment_end>
  2924. #include <aomap_fragment>
  2925. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2926. #include <envmap_fragment>
  2927. #include <opaque_fragment>
  2928. #include <tonemapping_fragment>
  2929. #include <colorspace_fragment>
  2930. #include <fog_fragment>
  2931. #include <premultiplied_alpha_fragment>
  2932. #include <dithering_fragment>
  2933. }`,bu=`#define MATCAP
  2934. varying vec3 vViewPosition;
  2935. #include <common>
  2936. #include <batching_pars_vertex>
  2937. #include <uv_pars_vertex>
  2938. #include <color_pars_vertex>
  2939. #include <displacementmap_pars_vertex>
  2940. #include <fog_pars_vertex>
  2941. #include <normal_pars_vertex>
  2942. #include <morphtarget_pars_vertex>
  2943. #include <skinning_pars_vertex>
  2944. #include <logdepthbuf_pars_vertex>
  2945. #include <clipping_planes_pars_vertex>
  2946. void main() {
  2947. #include <uv_vertex>
  2948. #include <color_vertex>
  2949. #include <morphinstance_vertex>
  2950. #include <morphcolor_vertex>
  2951. #include <batching_vertex>
  2952. #include <beginnormal_vertex>
  2953. #include <morphnormal_vertex>
  2954. #include <skinbase_vertex>
  2955. #include <skinnormal_vertex>
  2956. #include <defaultnormal_vertex>
  2957. #include <normal_vertex>
  2958. #include <begin_vertex>
  2959. #include <morphtarget_vertex>
  2960. #include <skinning_vertex>
  2961. #include <displacementmap_vertex>
  2962. #include <project_vertex>
  2963. #include <logdepthbuf_vertex>
  2964. #include <clipping_planes_vertex>
  2965. #include <fog_vertex>
  2966. vViewPosition = - mvPosition.xyz;
  2967. }`,Au=`#define MATCAP
  2968. uniform vec3 diffuse;
  2969. uniform float opacity;
  2970. uniform sampler2D matcap;
  2971. varying vec3 vViewPosition;
  2972. #include <common>
  2973. #include <dithering_pars_fragment>
  2974. #include <color_pars_fragment>
  2975. #include <uv_pars_fragment>
  2976. #include <map_pars_fragment>
  2977. #include <alphamap_pars_fragment>
  2978. #include <alphatest_pars_fragment>
  2979. #include <alphahash_pars_fragment>
  2980. #include <fog_pars_fragment>
  2981. #include <normal_pars_fragment>
  2982. #include <bumpmap_pars_fragment>
  2983. #include <normalmap_pars_fragment>
  2984. #include <logdepthbuf_pars_fragment>
  2985. #include <clipping_planes_pars_fragment>
  2986. void main() {
  2987. vec4 diffuseColor = vec4( diffuse, opacity );
  2988. #include <clipping_planes_fragment>
  2989. #include <logdepthbuf_fragment>
  2990. #include <map_fragment>
  2991. #include <color_fragment>
  2992. #include <alphamap_fragment>
  2993. #include <alphatest_fragment>
  2994. #include <alphahash_fragment>
  2995. #include <normal_fragment_begin>
  2996. #include <normal_fragment_maps>
  2997. vec3 viewDir = normalize( vViewPosition );
  2998. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  2999. vec3 y = cross( viewDir, x );
  3000. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3001. #ifdef USE_MATCAP
  3002. vec4 matcapColor = texture2D( matcap, uv );
  3003. #else
  3004. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3005. #endif
  3006. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3007. #include <opaque_fragment>
  3008. #include <tonemapping_fragment>
  3009. #include <colorspace_fragment>
  3010. #include <fog_fragment>
  3011. #include <premultiplied_alpha_fragment>
  3012. #include <dithering_fragment>
  3013. }`,Ru=`#define NORMAL
  3014. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3015. varying vec3 vViewPosition;
  3016. #endif
  3017. #include <common>
  3018. #include <batching_pars_vertex>
  3019. #include <uv_pars_vertex>
  3020. #include <displacementmap_pars_vertex>
  3021. #include <normal_pars_vertex>
  3022. #include <morphtarget_pars_vertex>
  3023. #include <skinning_pars_vertex>
  3024. #include <logdepthbuf_pars_vertex>
  3025. #include <clipping_planes_pars_vertex>
  3026. void main() {
  3027. #include <uv_vertex>
  3028. #include <batching_vertex>
  3029. #include <beginnormal_vertex>
  3030. #include <morphinstance_vertex>
  3031. #include <morphnormal_vertex>
  3032. #include <skinbase_vertex>
  3033. #include <skinnormal_vertex>
  3034. #include <defaultnormal_vertex>
  3035. #include <normal_vertex>
  3036. #include <begin_vertex>
  3037. #include <morphtarget_vertex>
  3038. #include <skinning_vertex>
  3039. #include <displacementmap_vertex>
  3040. #include <project_vertex>
  3041. #include <logdepthbuf_vertex>
  3042. #include <clipping_planes_vertex>
  3043. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3044. vViewPosition = - mvPosition.xyz;
  3045. #endif
  3046. }`,wu=`#define NORMAL
  3047. uniform float opacity;
  3048. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3049. varying vec3 vViewPosition;
  3050. #endif
  3051. #include <packing>
  3052. #include <uv_pars_fragment>
  3053. #include <normal_pars_fragment>
  3054. #include <bumpmap_pars_fragment>
  3055. #include <normalmap_pars_fragment>
  3056. #include <logdepthbuf_pars_fragment>
  3057. #include <clipping_planes_pars_fragment>
  3058. void main() {
  3059. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3060. #include <clipping_planes_fragment>
  3061. #include <logdepthbuf_fragment>
  3062. #include <normal_fragment_begin>
  3063. #include <normal_fragment_maps>
  3064. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3065. #ifdef OPAQUE
  3066. gl_FragColor.a = 1.0;
  3067. #endif
  3068. }`,Cu=`#define PHONG
  3069. varying vec3 vViewPosition;
  3070. #include <common>
  3071. #include <batching_pars_vertex>
  3072. #include <uv_pars_vertex>
  3073. #include <displacementmap_pars_vertex>
  3074. #include <envmap_pars_vertex>
  3075. #include <color_pars_vertex>
  3076. #include <fog_pars_vertex>
  3077. #include <normal_pars_vertex>
  3078. #include <morphtarget_pars_vertex>
  3079. #include <skinning_pars_vertex>
  3080. #include <shadowmap_pars_vertex>
  3081. #include <logdepthbuf_pars_vertex>
  3082. #include <clipping_planes_pars_vertex>
  3083. void main() {
  3084. #include <uv_vertex>
  3085. #include <color_vertex>
  3086. #include <morphcolor_vertex>
  3087. #include <batching_vertex>
  3088. #include <beginnormal_vertex>
  3089. #include <morphinstance_vertex>
  3090. #include <morphnormal_vertex>
  3091. #include <skinbase_vertex>
  3092. #include <skinnormal_vertex>
  3093. #include <defaultnormal_vertex>
  3094. #include <normal_vertex>
  3095. #include <begin_vertex>
  3096. #include <morphtarget_vertex>
  3097. #include <skinning_vertex>
  3098. #include <displacementmap_vertex>
  3099. #include <project_vertex>
  3100. #include <logdepthbuf_vertex>
  3101. #include <clipping_planes_vertex>
  3102. vViewPosition = - mvPosition.xyz;
  3103. #include <worldpos_vertex>
  3104. #include <envmap_vertex>
  3105. #include <shadowmap_vertex>
  3106. #include <fog_vertex>
  3107. }`,Pu=`#define PHONG
  3108. uniform vec3 diffuse;
  3109. uniform vec3 emissive;
  3110. uniform vec3 specular;
  3111. uniform float shininess;
  3112. uniform float opacity;
  3113. #include <common>
  3114. #include <packing>
  3115. #include <dithering_pars_fragment>
  3116. #include <color_pars_fragment>
  3117. #include <uv_pars_fragment>
  3118. #include <map_pars_fragment>
  3119. #include <alphamap_pars_fragment>
  3120. #include <alphatest_pars_fragment>
  3121. #include <alphahash_pars_fragment>
  3122. #include <aomap_pars_fragment>
  3123. #include <lightmap_pars_fragment>
  3124. #include <emissivemap_pars_fragment>
  3125. #include <envmap_common_pars_fragment>
  3126. #include <envmap_pars_fragment>
  3127. #include <fog_pars_fragment>
  3128. #include <bsdfs>
  3129. #include <lights_pars_begin>
  3130. #include <normal_pars_fragment>
  3131. #include <lights_phong_pars_fragment>
  3132. #include <shadowmap_pars_fragment>
  3133. #include <bumpmap_pars_fragment>
  3134. #include <normalmap_pars_fragment>
  3135. #include <specularmap_pars_fragment>
  3136. #include <logdepthbuf_pars_fragment>
  3137. #include <clipping_planes_pars_fragment>
  3138. void main() {
  3139. vec4 diffuseColor = vec4( diffuse, opacity );
  3140. #include <clipping_planes_fragment>
  3141. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3142. vec3 totalEmissiveRadiance = emissive;
  3143. #include <logdepthbuf_fragment>
  3144. #include <map_fragment>
  3145. #include <color_fragment>
  3146. #include <alphamap_fragment>
  3147. #include <alphatest_fragment>
  3148. #include <alphahash_fragment>
  3149. #include <specularmap_fragment>
  3150. #include <normal_fragment_begin>
  3151. #include <normal_fragment_maps>
  3152. #include <emissivemap_fragment>
  3153. #include <lights_phong_fragment>
  3154. #include <lights_fragment_begin>
  3155. #include <lights_fragment_maps>
  3156. #include <lights_fragment_end>
  3157. #include <aomap_fragment>
  3158. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3159. #include <envmap_fragment>
  3160. #include <opaque_fragment>
  3161. #include <tonemapping_fragment>
  3162. #include <colorspace_fragment>
  3163. #include <fog_fragment>
  3164. #include <premultiplied_alpha_fragment>
  3165. #include <dithering_fragment>
  3166. }`,Du=`#define STANDARD
  3167. varying vec3 vViewPosition;
  3168. #ifdef USE_TRANSMISSION
  3169. varying vec3 vWorldPosition;
  3170. #endif
  3171. #include <common>
  3172. #include <batching_pars_vertex>
  3173. #include <uv_pars_vertex>
  3174. #include <displacementmap_pars_vertex>
  3175. #include <color_pars_vertex>
  3176. #include <fog_pars_vertex>
  3177. #include <normal_pars_vertex>
  3178. #include <morphtarget_pars_vertex>
  3179. #include <skinning_pars_vertex>
  3180. #include <shadowmap_pars_vertex>
  3181. #include <logdepthbuf_pars_vertex>
  3182. #include <clipping_planes_pars_vertex>
  3183. void main() {
  3184. #include <uv_vertex>
  3185. #include <color_vertex>
  3186. #include <morphinstance_vertex>
  3187. #include <morphcolor_vertex>
  3188. #include <batching_vertex>
  3189. #include <beginnormal_vertex>
  3190. #include <morphnormal_vertex>
  3191. #include <skinbase_vertex>
  3192. #include <skinnormal_vertex>
  3193. #include <defaultnormal_vertex>
  3194. #include <normal_vertex>
  3195. #include <begin_vertex>
  3196. #include <morphtarget_vertex>
  3197. #include <skinning_vertex>
  3198. #include <displacementmap_vertex>
  3199. #include <project_vertex>
  3200. #include <logdepthbuf_vertex>
  3201. #include <clipping_planes_vertex>
  3202. vViewPosition = - mvPosition.xyz;
  3203. #include <worldpos_vertex>
  3204. #include <shadowmap_vertex>
  3205. #include <fog_vertex>
  3206. #ifdef USE_TRANSMISSION
  3207. vWorldPosition = worldPosition.xyz;
  3208. #endif
  3209. }`,Lu=`#define STANDARD
  3210. #ifdef PHYSICAL
  3211. #define IOR
  3212. #define USE_SPECULAR
  3213. #endif
  3214. uniform vec3 diffuse;
  3215. uniform vec3 emissive;
  3216. uniform float roughness;
  3217. uniform float metalness;
  3218. uniform float opacity;
  3219. #ifdef IOR
  3220. uniform float ior;
  3221. #endif
  3222. #ifdef USE_SPECULAR
  3223. uniform float specularIntensity;
  3224. uniform vec3 specularColor;
  3225. #ifdef USE_SPECULAR_COLORMAP
  3226. uniform sampler2D specularColorMap;
  3227. #endif
  3228. #ifdef USE_SPECULAR_INTENSITYMAP
  3229. uniform sampler2D specularIntensityMap;
  3230. #endif
  3231. #endif
  3232. #ifdef USE_CLEARCOAT
  3233. uniform float clearcoat;
  3234. uniform float clearcoatRoughness;
  3235. #endif
  3236. #ifdef USE_DISPERSION
  3237. uniform float dispersion;
  3238. #endif
  3239. #ifdef USE_IRIDESCENCE
  3240. uniform float iridescence;
  3241. uniform float iridescenceIOR;
  3242. uniform float iridescenceThicknessMinimum;
  3243. uniform float iridescenceThicknessMaximum;
  3244. #endif
  3245. #ifdef USE_SHEEN
  3246. uniform vec3 sheenColor;
  3247. uniform float sheenRoughness;
  3248. #ifdef USE_SHEEN_COLORMAP
  3249. uniform sampler2D sheenColorMap;
  3250. #endif
  3251. #ifdef USE_SHEEN_ROUGHNESSMAP
  3252. uniform sampler2D sheenRoughnessMap;
  3253. #endif
  3254. #endif
  3255. #ifdef USE_ANISOTROPY
  3256. uniform vec2 anisotropyVector;
  3257. #ifdef USE_ANISOTROPYMAP
  3258. uniform sampler2D anisotropyMap;
  3259. #endif
  3260. #endif
  3261. varying vec3 vViewPosition;
  3262. #include <common>
  3263. #include <packing>
  3264. #include <dithering_pars_fragment>
  3265. #include <color_pars_fragment>
  3266. #include <uv_pars_fragment>
  3267. #include <map_pars_fragment>
  3268. #include <alphamap_pars_fragment>
  3269. #include <alphatest_pars_fragment>
  3270. #include <alphahash_pars_fragment>
  3271. #include <aomap_pars_fragment>
  3272. #include <lightmap_pars_fragment>
  3273. #include <emissivemap_pars_fragment>
  3274. #include <iridescence_fragment>
  3275. #include <cube_uv_reflection_fragment>
  3276. #include <envmap_common_pars_fragment>
  3277. #include <envmap_physical_pars_fragment>
  3278. #include <fog_pars_fragment>
  3279. #include <lights_pars_begin>
  3280. #include <normal_pars_fragment>
  3281. #include <lights_physical_pars_fragment>
  3282. #include <transmission_pars_fragment>
  3283. #include <shadowmap_pars_fragment>
  3284. #include <bumpmap_pars_fragment>
  3285. #include <normalmap_pars_fragment>
  3286. #include <clearcoat_pars_fragment>
  3287. #include <iridescence_pars_fragment>
  3288. #include <roughnessmap_pars_fragment>
  3289. #include <metalnessmap_pars_fragment>
  3290. #include <logdepthbuf_pars_fragment>
  3291. #include <clipping_planes_pars_fragment>
  3292. void main() {
  3293. vec4 diffuseColor = vec4( diffuse, opacity );
  3294. #include <clipping_planes_fragment>
  3295. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3296. vec3 totalEmissiveRadiance = emissive;
  3297. #include <logdepthbuf_fragment>
  3298. #include <map_fragment>
  3299. #include <color_fragment>
  3300. #include <alphamap_fragment>
  3301. #include <alphatest_fragment>
  3302. #include <alphahash_fragment>
  3303. #include <roughnessmap_fragment>
  3304. #include <metalnessmap_fragment>
  3305. #include <normal_fragment_begin>
  3306. #include <normal_fragment_maps>
  3307. #include <clearcoat_normal_fragment_begin>
  3308. #include <clearcoat_normal_fragment_maps>
  3309. #include <emissivemap_fragment>
  3310. #include <lights_physical_fragment>
  3311. #include <lights_fragment_begin>
  3312. #include <lights_fragment_maps>
  3313. #include <lights_fragment_end>
  3314. #include <aomap_fragment>
  3315. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3316. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3317. #include <transmission_fragment>
  3318. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3319. #ifdef USE_SHEEN
  3320. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3321. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3322. #endif
  3323. #ifdef USE_CLEARCOAT
  3324. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3325. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3326. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3327. #endif
  3328. #include <opaque_fragment>
  3329. #include <tonemapping_fragment>
  3330. #include <colorspace_fragment>
  3331. #include <fog_fragment>
  3332. #include <premultiplied_alpha_fragment>
  3333. #include <dithering_fragment>
  3334. }`,Uu=`#define TOON
  3335. varying vec3 vViewPosition;
  3336. #include <common>
  3337. #include <batching_pars_vertex>
  3338. #include <uv_pars_vertex>
  3339. #include <displacementmap_pars_vertex>
  3340. #include <color_pars_vertex>
  3341. #include <fog_pars_vertex>
  3342. #include <normal_pars_vertex>
  3343. #include <morphtarget_pars_vertex>
  3344. #include <skinning_pars_vertex>
  3345. #include <shadowmap_pars_vertex>
  3346. #include <logdepthbuf_pars_vertex>
  3347. #include <clipping_planes_pars_vertex>
  3348. void main() {
  3349. #include <uv_vertex>
  3350. #include <color_vertex>
  3351. #include <morphinstance_vertex>
  3352. #include <morphcolor_vertex>
  3353. #include <batching_vertex>
  3354. #include <beginnormal_vertex>
  3355. #include <morphnormal_vertex>
  3356. #include <skinbase_vertex>
  3357. #include <skinnormal_vertex>
  3358. #include <defaultnormal_vertex>
  3359. #include <normal_vertex>
  3360. #include <begin_vertex>
  3361. #include <morphtarget_vertex>
  3362. #include <skinning_vertex>
  3363. #include <displacementmap_vertex>
  3364. #include <project_vertex>
  3365. #include <logdepthbuf_vertex>
  3366. #include <clipping_planes_vertex>
  3367. vViewPosition = - mvPosition.xyz;
  3368. #include <worldpos_vertex>
  3369. #include <shadowmap_vertex>
  3370. #include <fog_vertex>
  3371. }`,Iu=`#define TOON
  3372. uniform vec3 diffuse;
  3373. uniform vec3 emissive;
  3374. uniform float opacity;
  3375. #include <common>
  3376. #include <packing>
  3377. #include <dithering_pars_fragment>
  3378. #include <color_pars_fragment>
  3379. #include <uv_pars_fragment>
  3380. #include <map_pars_fragment>
  3381. #include <alphamap_pars_fragment>
  3382. #include <alphatest_pars_fragment>
  3383. #include <alphahash_pars_fragment>
  3384. #include <aomap_pars_fragment>
  3385. #include <lightmap_pars_fragment>
  3386. #include <emissivemap_pars_fragment>
  3387. #include <gradientmap_pars_fragment>
  3388. #include <fog_pars_fragment>
  3389. #include <bsdfs>
  3390. #include <lights_pars_begin>
  3391. #include <normal_pars_fragment>
  3392. #include <lights_toon_pars_fragment>
  3393. #include <shadowmap_pars_fragment>
  3394. #include <bumpmap_pars_fragment>
  3395. #include <normalmap_pars_fragment>
  3396. #include <logdepthbuf_pars_fragment>
  3397. #include <clipping_planes_pars_fragment>
  3398. void main() {
  3399. vec4 diffuseColor = vec4( diffuse, opacity );
  3400. #include <clipping_planes_fragment>
  3401. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3402. vec3 totalEmissiveRadiance = emissive;
  3403. #include <logdepthbuf_fragment>
  3404. #include <map_fragment>
  3405. #include <color_fragment>
  3406. #include <alphamap_fragment>
  3407. #include <alphatest_fragment>
  3408. #include <alphahash_fragment>
  3409. #include <normal_fragment_begin>
  3410. #include <normal_fragment_maps>
  3411. #include <emissivemap_fragment>
  3412. #include <lights_toon_fragment>
  3413. #include <lights_fragment_begin>
  3414. #include <lights_fragment_maps>
  3415. #include <lights_fragment_end>
  3416. #include <aomap_fragment>
  3417. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3418. #include <opaque_fragment>
  3419. #include <tonemapping_fragment>
  3420. #include <colorspace_fragment>
  3421. #include <fog_fragment>
  3422. #include <premultiplied_alpha_fragment>
  3423. #include <dithering_fragment>
  3424. }`,Nu=`uniform float size;
  3425. uniform float scale;
  3426. #include <common>
  3427. #include <color_pars_vertex>
  3428. #include <fog_pars_vertex>
  3429. #include <morphtarget_pars_vertex>
  3430. #include <logdepthbuf_pars_vertex>
  3431. #include <clipping_planes_pars_vertex>
  3432. #ifdef USE_POINTS_UV
  3433. varying vec2 vUv;
  3434. uniform mat3 uvTransform;
  3435. #endif
  3436. void main() {
  3437. #ifdef USE_POINTS_UV
  3438. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3439. #endif
  3440. #include <color_vertex>
  3441. #include <morphinstance_vertex>
  3442. #include <morphcolor_vertex>
  3443. #include <begin_vertex>
  3444. #include <morphtarget_vertex>
  3445. #include <project_vertex>
  3446. gl_PointSize = size;
  3447. #ifdef USE_SIZEATTENUATION
  3448. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3449. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3450. #endif
  3451. #include <logdepthbuf_vertex>
  3452. #include <clipping_planes_vertex>
  3453. #include <worldpos_vertex>
  3454. #include <fog_vertex>
  3455. }`,Fu=`uniform vec3 diffuse;
  3456. uniform float opacity;
  3457. #include <common>
  3458. #include <color_pars_fragment>
  3459. #include <map_particle_pars_fragment>
  3460. #include <alphatest_pars_fragment>
  3461. #include <alphahash_pars_fragment>
  3462. #include <fog_pars_fragment>
  3463. #include <logdepthbuf_pars_fragment>
  3464. #include <clipping_planes_pars_fragment>
  3465. void main() {
  3466. vec4 diffuseColor = vec4( diffuse, opacity );
  3467. #include <clipping_planes_fragment>
  3468. vec3 outgoingLight = vec3( 0.0 );
  3469. #include <logdepthbuf_fragment>
  3470. #include <map_particle_fragment>
  3471. #include <color_fragment>
  3472. #include <alphatest_fragment>
  3473. #include <alphahash_fragment>
  3474. outgoingLight = diffuseColor.rgb;
  3475. #include <opaque_fragment>
  3476. #include <tonemapping_fragment>
  3477. #include <colorspace_fragment>
  3478. #include <fog_fragment>
  3479. #include <premultiplied_alpha_fragment>
  3480. }`,Ou=`#include <common>
  3481. #include <batching_pars_vertex>
  3482. #include <fog_pars_vertex>
  3483. #include <morphtarget_pars_vertex>
  3484. #include <skinning_pars_vertex>
  3485. #include <logdepthbuf_pars_vertex>
  3486. #include <shadowmap_pars_vertex>
  3487. void main() {
  3488. #include <batching_vertex>
  3489. #include <beginnormal_vertex>
  3490. #include <morphinstance_vertex>
  3491. #include <morphnormal_vertex>
  3492. #include <skinbase_vertex>
  3493. #include <skinnormal_vertex>
  3494. #include <defaultnormal_vertex>
  3495. #include <begin_vertex>
  3496. #include <morphtarget_vertex>
  3497. #include <skinning_vertex>
  3498. #include <project_vertex>
  3499. #include <logdepthbuf_vertex>
  3500. #include <worldpos_vertex>
  3501. #include <shadowmap_vertex>
  3502. #include <fog_vertex>
  3503. }`,Bu=`uniform vec3 color;
  3504. uniform float opacity;
  3505. #include <common>
  3506. #include <packing>
  3507. #include <fog_pars_fragment>
  3508. #include <bsdfs>
  3509. #include <lights_pars_begin>
  3510. #include <logdepthbuf_pars_fragment>
  3511. #include <shadowmap_pars_fragment>
  3512. #include <shadowmask_pars_fragment>
  3513. void main() {
  3514. #include <logdepthbuf_fragment>
  3515. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3516. #include <tonemapping_fragment>
  3517. #include <colorspace_fragment>
  3518. #include <fog_fragment>
  3519. }`,zu=`uniform float rotation;
  3520. uniform vec2 center;
  3521. #include <common>
  3522. #include <uv_pars_vertex>
  3523. #include <fog_pars_vertex>
  3524. #include <logdepthbuf_pars_vertex>
  3525. #include <clipping_planes_pars_vertex>
  3526. void main() {
  3527. #include <uv_vertex>
  3528. vec4 mvPosition = modelViewMatrix[ 3 ];
  3529. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3530. #ifndef USE_SIZEATTENUATION
  3531. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3532. if ( isPerspective ) scale *= - mvPosition.z;
  3533. #endif
  3534. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3535. vec2 rotatedPosition;
  3536. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3537. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3538. mvPosition.xy += rotatedPosition;
  3539. gl_Position = projectionMatrix * mvPosition;
  3540. #include <logdepthbuf_vertex>
  3541. #include <clipping_planes_vertex>
  3542. #include <fog_vertex>
  3543. }`,Hu=`uniform vec3 diffuse;
  3544. uniform float opacity;
  3545. #include <common>
  3546. #include <uv_pars_fragment>
  3547. #include <map_pars_fragment>
  3548. #include <alphamap_pars_fragment>
  3549. #include <alphatest_pars_fragment>
  3550. #include <alphahash_pars_fragment>
  3551. #include <fog_pars_fragment>
  3552. #include <logdepthbuf_pars_fragment>
  3553. #include <clipping_planes_pars_fragment>
  3554. void main() {
  3555. vec4 diffuseColor = vec4( diffuse, opacity );
  3556. #include <clipping_planes_fragment>
  3557. vec3 outgoingLight = vec3( 0.0 );
  3558. #include <logdepthbuf_fragment>
  3559. #include <map_fragment>
  3560. #include <alphamap_fragment>
  3561. #include <alphatest_fragment>
  3562. #include <alphahash_fragment>
  3563. outgoingLight = diffuseColor.rgb;
  3564. #include <opaque_fragment>
  3565. #include <tonemapping_fragment>
  3566. #include <colorspace_fragment>
  3567. #include <fog_fragment>
  3568. }`,Ft={alphahash_fragment:lc,alphahash_pars_fragment:cc,alphamap_fragment:hc,alphamap_pars_fragment:uc,alphatest_fragment:dc,alphatest_pars_fragment:fc,aomap_fragment:pc,aomap_pars_fragment:mc,batching_pars_vertex:_c,batching_vertex:gc,begin_vertex:vc,beginnormal_vertex:xc,bsdfs:Mc,iridescence_fragment:Sc,bumpmap_pars_fragment:Ec,clipping_planes_fragment:yc,clipping_planes_pars_fragment:Tc,clipping_planes_pars_vertex:bc,clipping_planes_vertex:Ac,color_fragment:Rc,color_pars_fragment:wc,color_pars_vertex:Cc,color_vertex:Pc,common:Dc,cube_uv_reflection_fragment:Lc,defaultnormal_vertex:Uc,displacementmap_pars_vertex:Ic,displacementmap_vertex:Nc,emissivemap_fragment:Fc,emissivemap_pars_fragment:Oc,colorspace_fragment:Bc,colorspace_pars_fragment:zc,envmap_fragment:Hc,envmap_common_pars_fragment:Vc,envmap_pars_fragment:Gc,envmap_pars_vertex:kc,envmap_physical_pars_fragment:th,envmap_vertex:Wc,fog_vertex:Xc,fog_pars_vertex:Yc,fog_fragment:qc,fog_pars_fragment:Kc,gradientmap_pars_fragment:Zc,lightmap_pars_fragment:jc,lights_lambert_fragment:$c,lights_lambert_pars_fragment:Jc,lights_pars_begin:Qc,lights_toon_fragment:eh,lights_toon_pars_fragment:nh,lights_phong_fragment:ih,lights_phong_pars_fragment:rh,lights_physical_fragment:sh,lights_physical_pars_fragment:ah,lights_fragment_begin:oh,lights_fragment_maps:lh,lights_fragment_end:ch,logdepthbuf_fragment:hh,logdepthbuf_pars_fragment:uh,logdepthbuf_pars_vertex:dh,logdepthbuf_vertex:fh,map_fragment:ph,map_pars_fragment:mh,map_particle_fragment:_h,map_particle_pars_fragment:gh,metalnessmap_fragment:vh,metalnessmap_pars_fragment:xh,morphinstance_vertex:Mh,morphcolor_vertex:Sh,morphnormal_vertex:Eh,morphtarget_pars_vertex:yh,morphtarget_vertex:Th,normal_fragment_begin:bh,normal_fragment_maps:Ah,normal_pars_fragment:Rh,normal_pars_vertex:wh,normal_vertex:Ch,normalmap_pars_fragment:Ph,clearcoat_normal_fragment_begin:Dh,clearcoat_normal_fragment_maps:Lh,clearcoat_pars_fragment:Uh,iridescence_pars_fragment:Ih,opaque_fragment:Nh,packing:Fh,premultiplied_alpha_fragment:Oh,project_vertex:Bh,dithering_fragment:zh,dithering_pars_fragment:Hh,roughnessmap_fragment:Vh,roughnessmap_pars_fragment:Gh,shadowmap_pars_fragment:kh,shadowmap_pars_vertex:Wh,shadowmap_vertex:Xh,shadowmask_pars_fragment:Yh,skinbase_vertex:qh,skinning_pars_vertex:Kh,skinning_vertex:Zh,skinnormal_vertex:jh,specularmap_fragment:$h,specularmap_pars_fragment:Jh,tonemapping_fragment:Qh,tonemapping_pars_fragment:tu,transmission_fragment:eu,transmission_pars_fragment:nu,uv_pars_fragment:iu,uv_pars_vertex:ru,uv_vertex:su,worldpos_vertex:au,background_vert:ou,background_frag:lu,backgroundCube_vert:cu,backgroundCube_frag:hu,cube_vert:uu,cube_frag:du,depth_vert:fu,depth_frag:pu,distanceRGBA_vert:mu,distanceRGBA_frag:_u,equirect_vert:gu,equirect_frag:vu,linedashed_vert:xu,linedashed_frag:Mu,meshbasic_vert:Su,meshbasic_frag:Eu,meshlambert_vert:yu,meshlambert_frag:Tu,meshmatcap_vert:bu,meshmatcap_frag:Au,meshnormal_vert:Ru,meshnormal_frag:wu,meshphong_vert:Cu,meshphong_frag:Pu,meshphysical_vert:Du,meshphysical_frag:Lu,meshtoon_vert:Uu,meshtoon_frag:Iu,points_vert:Nu,points_frag:Fu,shadow_vert:Ou,shadow_frag:Bu,sprite_vert:zu,sprite_frag:Hu},rt={common:{diffuse:{value:new kt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new It},alphaMap:{value:null},alphaMapTransform:{value:new It},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new It}},envmap:{envMap:{value:null},envMapRotation:{value:new It},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new It}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new It}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new It},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new It},normalScale:{value:new Lt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new It},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new It}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new It}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new It}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new kt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new kt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new It},alphaTest:{value:0},uvTransform:{value:new It}},sprite:{diffuse:{value:new kt(16777215)},opacity:{value:1},center:{value:new Lt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new It},alphaMap:{value:null},alphaMapTransform:{value:new It},alphaTest:{value:0}}},Ve={basic:{uniforms:xe([rt.common,rt.specularmap,rt.envmap,rt.aomap,rt.lightmap,rt.fog]),vertexShader:Ft.meshbasic_vert,fragmentShader:Ft.meshbasic_frag},lambert:{uniforms:xe([rt.common,rt.specularmap,rt.envmap,rt.aomap,rt.lightmap,rt.emissivemap,rt.bumpmap,rt.normalmap,rt.displacementmap,rt.fog,rt.lights,{emissive:{value:new kt(0)}}]),vertexShader:Ft.meshlambert_vert,fragmentShader:Ft.meshlambert_frag},phong:{uniforms:xe([rt.common,rt.specularmap,rt.envmap,rt.aomap,rt.lightmap,rt.emissivemap,rt.bumpmap,rt.normalmap,rt.displacementmap,rt.fog,rt.lights,{emissive:{value:new kt(0)},specular:{value:new kt(1118481)},shininess:{value:30}}]),vertexShader:Ft.meshphong_vert,fragmentShader:Ft.meshphong_frag},standard:{uniforms:xe([rt.common,rt.envmap,rt.aomap,rt.lightmap,rt.emissivemap,rt.bumpmap,rt.normalmap,rt.displacementmap,rt.roughnessmap,rt.metalnessmap,rt.fog,rt.lights,{emissive:{value:new kt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ft.meshphysical_vert,fragmentShader:Ft.meshphysical_frag},toon:{uniforms:xe([rt.common,rt.aomap,rt.lightmap,rt.emissivemap,rt.bumpmap,rt.normalmap,rt.displacementmap,rt.gradientmap,rt.fog,rt.lights,{emissive:{value:new kt(0)}}]),vertexShader:Ft.meshtoon_vert,fragmentShader:Ft.meshtoon_frag},matcap:{uniforms:xe([rt.common,rt.bumpmap,rt.normalmap,rt.displacementmap,rt.fog,{matcap:{value:null}}]),vertexShader:Ft.meshmatcap_vert,fragmentShader:Ft.meshmatcap_frag},points:{uniforms:xe([rt.points,rt.fog]),vertexShader:Ft.points_vert,fragmentShader:Ft.points_frag},dashed:{uniforms:xe([rt.common,rt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ft.linedashed_vert,fragmentShader:Ft.linedashed_frag},depth:{uniforms:xe([rt.common,rt.displacementmap]),vertexShader:Ft.depth_vert,fragmentShader:Ft.depth_frag},normal:{uniforms:xe([rt.common,rt.bumpmap,rt.normalmap,rt.displacementmap,{opacity:{value:1}}]),vertexShader:Ft.meshnormal_vert,fragmentShader:Ft.meshnormal_frag},sprite:{uniforms:xe([rt.sprite,rt.fog]),vertexShader:Ft.sprite_vert,fragmentShader:Ft.sprite_frag},background:{uniforms:{uvTransform:{value:new It},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ft.background_vert,fragmentShader:Ft.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new It}},vertexShader:Ft.backgroundCube_vert,fragmentShader:Ft.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ft.cube_vert,fragmentShader:Ft.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ft.equirect_vert,fragmentShader:Ft.equirect_frag},distanceRGBA:{uniforms:xe([rt.common,rt.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ft.distanceRGBA_vert,fragmentShader:Ft.distanceRGBA_frag},shadow:{uniforms:xe([rt.lights,rt.fog,{color:{value:new kt(0)},opacity:{value:1}}]),vertexShader:Ft.shadow_vert,fragmentShader:Ft.shadow_frag}};Ve.physical={uniforms:xe([Ve.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new It},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new It},clearcoatNormalScale:{value:new Lt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new It},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new It},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new It},sheen:{value:0},sheenColor:{value:new kt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new It},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new It},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new It},transmissionSamplerSize:{value:new Lt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new It},attenuationDistance:{value:0},attenuationColor:{value:new kt(0)},specularColor:{value:new kt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new It},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new It},anisotropyVector:{value:new Lt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new It}}]),vertexShader:Ft.meshphysical_vert,fragmentShader:Ft.meshphysical_frag};const Yi={r:0,b:0,g:0},bn=new qe,Vu=new oe;function Gu(i,t,e,n,r,s,a){const o=new kt(0);let c=s===!0?0:1,l,u,d=null,f=0,m=null;function v(T){let E=T.isScene===!0?T.background:null;return E&&E.isTexture&&(E=(T.backgroundBlurriness>0?e:t).get(E)),E}function M(T){let E=!1;const C=v(T);C===null?h(o,c):C&&C.isColor&&(h(C,1),E=!0);const R=i.xr.getEnvironmentBlendMode();R==="additive"?n.buffers.color.setClear(0,0,0,1,a):R==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||E)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function p(T,E){const C=v(E);C&&(C.isCubeTexture||C.mapping===sr)?(u===void 0&&(u=new rn(new Ti(1,1,1),new gn({name:"BackgroundCubeMaterial",uniforms:ai(Ve.backgroundCube.uniforms),vertexShader:Ve.backgroundCube.vertexShader,fragmentShader:Ve.backgroundCube.fragmentShader,side:Te,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(R,D,F){this.matrixWorld.copyPosition(F.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),bn.copy(E.backgroundRotation),bn.x*=-1,bn.y*=-1,bn.z*=-1,C.isCubeTexture&&C.isRenderTargetTexture===!1&&(bn.y*=-1,bn.z*=-1),u.material.uniforms.envMap.value=C,u.material.uniforms.flipEnvMap.value=C.isCubeTexture&&C.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(Vu.makeRotationFromEuler(bn)),u.material.toneMapped=Gt.getTransfer(C.colorSpace)!==qt,(d!==C||f!==C.version||m!==i.toneMapping)&&(u.material.needsUpdate=!0,d=C,f=C.version,m=i.toneMapping),u.layers.enableAll(),T.unshift(u,u.geometry,u.material,0,0,null)):C&&C.isTexture&&(l===void 0&&(l=new rn(new ar(2,2),new gn({name:"BackgroundMaterial",uniforms:ai(Ve.background.uniforms),vertexShader:Ve.background.vertexShader,fragmentShader:Ve.background.fragmentShader,side:_n,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=C,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.toneMapped=Gt.getTransfer(C.colorSpace)!==qt,C.matrixAutoUpdate===!0&&C.updateMatrix(),l.material.uniforms.uvTransform.value.copy(C.matrix),(d!==C||f!==C.version||m!==i.toneMapping)&&(l.material.needsUpdate=!0,d=C,f=C.version,m=i.toneMapping),l.layers.enableAll(),T.unshift(l,l.geometry,l.material,0,0,null))}function h(T,E){T.getRGB(Yi,_o(i)),n.buffers.color.setClear(Yi.r,Yi.g,Yi.b,E,a)}function A(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(T,E=1){o.set(T),c=E,h(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(T){c=T,h(o,c)},render:M,addToRenderList:p,dispose:A}}function ku(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=f(null);let s=r,a=!1;function o(x,P,z,G,X){let K=!1;const W=d(G,z,P);s!==W&&(s=W,l(s.object)),K=m(x,G,z,X),K&&v(x,G,z,X),X!==null&&t.update(X,i.ELEMENT_ARRAY_BUFFER),(K||a)&&(a=!1,E(x,P,z,G),X!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(X).buffer))}function c(){return i.createVertexArray()}function l(x){return i.bindVertexArray(x)}function u(x){return i.deleteVertexArray(x)}function d(x,P,z){const G=z.wireframe===!0;let X=n[x.id];X===void 0&&(X={},n[x.id]=X);let K=X[P.id];K===void 0&&(K={},X[P.id]=K);let W=K[G];return W===void 0&&(W=f(c()),K[G]=W),W}function f(x){const P=[],z=[],G=[];for(let X=0;X<e;X++)P[X]=0,z[X]=0,G[X]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:z,attributeDivisors:G,object:x,attributes:{},index:null}}function m(x,P,z,G){const X=s.attributes,K=P.attributes;let W=0;const et=z.getAttributes();for(const H in et)if(et[H].location>=0){const ct=X[H];let Et=K[H];if(Et===void 0&&(H==="instanceMatrix"&&x.instanceMatrix&&(Et=x.instanceMatrix),H==="instanceColor"&&x.instanceColor&&(Et=x.instanceColor)),ct===void 0||ct.attribute!==Et||Et&&ct.data!==Et.data)return!0;W++}return s.attributesNum!==W||s.index!==G}function v(x,P,z,G){const X={},K=P.attributes;let W=0;const et=z.getAttributes();for(const H in et)if(et[H].location>=0){let ct=K[H];ct===void 0&&(H==="instanceMatrix"&&x.instanceMatrix&&(ct=x.instanceMatrix),H==="instanceColor"&&x.instanceColor&&(ct=x.instanceColor));const Et={};Et.attribute=ct,ct&&ct.data&&(Et.data=ct.data),X[H]=Et,W++}s.attributes=X,s.attributesNum=W,s.index=G}function M(){const x=s.newAttributes;for(let P=0,z=x.length;P<z;P++)x[P]=0}function p(x){h(x,0)}function h(x,P){const z=s.newAttributes,G=s.enabledAttributes,X=s.attributeDivisors;z[x]=1,G[x]===0&&(i.enableVertexAttribArray(x),G[x]=1),X[x]!==P&&(i.vertexAttribDivisor(x,P),X[x]=P)}function A(){const x=s.newAttributes,P=s.enabledAttributes;for(let z=0,G=P.length;z<G;z++)P[z]!==x[z]&&(i.disableVertexAttribArray(z),P[z]=0)}function T(x,P,z,G,X,K,W){W===!0?i.vertexAttribIPointer(x,P,z,X,K):i.vertexAttribPointer(x,P,z,G,X,K)}function E(x,P,z,G){M();const X=G.attributes,K=z.getAttributes(),W=P.defaultAttributeValues;for(const et in K){const H=K[et];if(H.location>=0){let st=X[et];if(st===void 0&&(et==="instanceMatrix"&&x.instanceMatrix&&(st=x.instanceMatrix),et==="instanceColor"&&x.instanceColor&&(st=x.instanceColor)),st!==void 0){const ct=st.normalized,Et=st.itemSize,Ot=t.get(st);if(Ot===void 0)continue;const jt=Ot.buffer,Qt=Ot.type,Wt=Ot.bytesPerElement,Y=Qt===i.INT||Qt===i.UNSIGNED_INT||st.gpuType===Ds;if(st.isInterleavedBufferAttribute){const j=st.data,dt=j.stride,Ct=st.offset;if(j.isInstancedInterleavedBuffer){for(let St=0;St<H.locationSize;St++)h(H.location+St,j.meshPerAttribute);x.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let St=0;St<H.locationSize;St++)p(H.location+St);i.bindBuffer(i.ARRAY_BUFFER,jt);for(let St=0;St<H.locationSize;St++)T(H.location+St,Et/H.locationSize,Qt,ct,dt*Wt,(Ct+Et/H.locationSize*St)*Wt,Y)}else{if(st.isInstancedBufferAttribute){for(let j=0;j<H.locationSize;j++)h(H.location+j,st.meshPerAttribute);x.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=st.meshPerAttribute*st.count)}else for(let j=0;j<H.locationSize;j++)p(H.location+j);i.bindBuffer(i.ARRAY_BUFFER,jt);for(let j=0;j<H.locationSize;j++)T(H.location+j,Et/H.locationSize,Qt,ct,Et*Wt,Et/H.locationSize*j*Wt,Y)}}else if(W!==void 0){const ct=W[et];if(ct!==void 0)switch(ct.length){case 2:i.vertexAttrib2fv(H.location,ct);break;case 3:i.vertexAttrib3fv(H.location,ct);break;case 4:i.vertexAttrib4fv(H.location,ct);break;default:i.vertexAttrib1fv(H.location,ct)}}}}A()}function C(){F();for(const x in n){const P=n[x];for(const z in P){const G=P[z];for(const X in G)u(G[X].object),delete G[X];delete P[z]}delete n[x]}}function R(x){if(n[x.id]===void 0)return;const P=n[x.id];for(const z in P){const G=P[z];for(const X in G)u(G[X].object),delete G[X];delete P[z]}delete n[x.id]}function D(x){for(const P in n){const z=n[P];if(z[x.id]===void 0)continue;const G=z[x.id];for(const X in G)u(G[X].object),delete G[X];delete z[x.id]}}function F(){S(),a=!0,s!==r&&(s=r,l(s.object))}function S(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:F,resetDefaultState:S,dispose:C,releaseStatesOfGeometry:R,releaseStatesOfProgram:D,initAttributes:M,enableAttribute:p,disableUnusedAttributes:A}}function Wu(i,t,e){let n;function r(l){n=l}function s(l,u){i.drawArrays(n,l,u),e.update(u,n,1)}function a(l,u,d){d!==0&&(i.drawArraysInstanced(n,l,u,d),e.update(u,n,d))}function o(l,u,d){if(d===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,u,0,d);let m=0;for(let v=0;v<d;v++)m+=u[v];e.update(m,n,1)}function c(l,u,d,f){if(d===0)return;const m=t.get("WEBGL_multi_draw");if(m===null)for(let v=0;v<l.length;v++)a(l[v],u[v],f[v]);else{m.multiDrawArraysInstancedWEBGL(n,l,0,u,0,f,0,d);let v=0;for(let M=0;M<d;M++)v+=u[M]*f[M];e.update(v,n,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function Xu(i,t,e,n){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){const D=t.get("EXT_texture_filter_anisotropic");r=i.getParameter(D.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(D){return!(D!==Be&&n.convert(D)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(D){const F=D===Mi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(D!==Ye&&n.convert(D)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&D!==nn&&!F)}function c(D){if(D==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";D="mediump"}return D==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);const d=e.logarithmicDepthBuffer===!0,f=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control"),m=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),M=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),h=i.getParameter(i.MAX_VERTEX_ATTRIBS),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),E=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),C=v>0,R=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:m,maxVertexTextures:v,maxTextureSize:M,maxCubemapSize:p,maxAttributes:h,maxVertexUniforms:A,maxVaryings:T,maxFragmentUniforms:E,vertexTextures:C,maxSamples:R}}function Yu(i){const t=this;let e=null,n=0,r=!1,s=!1;const a=new dn,o=new It,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){const m=d.length!==0||f||n!==0||r;return r=f,n=d.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,f){e=u(d,f,0)},this.setState=function(d,f,m){const v=d.clippingPlanes,M=d.clipIntersection,p=d.clipShadows,h=i.get(d);if(!r||v===null||v.length===0||s&&!p)s?u(null):l();else{const A=s?0:n,T=A*4;let E=h.clippingState||null;c.value=E,E=u(v,f,T,m);for(let C=0;C!==T;++C)E[C]=e[C];h.clippingState=E,this.numIntersection=M?this.numPlanes:0,this.numPlanes+=A}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function u(d,f,m,v){const M=d!==null?d.length:0;let p=null;if(M!==0){if(p=c.value,v!==!0||p===null){const h=m+M*4,A=f.matrixWorldInverse;o.getNormalMatrix(A),(p===null||p.length<h)&&(p=new Float32Array(h));for(let T=0,E=m;T!==M;++T,E+=4)a.copy(d[T]).applyMatrix4(A,o),a.normal.toArray(p,E),p[E+3]=a.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=M,t.numIntersection=0,p}}function qu(i){let t=new WeakMap;function e(a,o){return o===$r?a.mapping=ii:o===Jr&&(a.mapping=ri),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===$r||o===Jr)if(t.has(a)){const c=t.get(a).texture;return e(c,a.mapping)}else{const c=a.image;if(c&&c.height>0){const l=new Zl(c.height);return l.fromEquirectangularTexture(i,a),t.set(a,l),a.addEventListener("dispose",r),e(l.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const c=t.get(o);c!==void 0&&(t.delete(o),c.dispose())}function s(){t=new WeakMap}return{get:n,dispose:s}}const Jn=4,Ea=[.125,.215,.35,.446,.526,.582],Cn=20,Nr=new yo,ya=new kt;let Fr=null,Or=0,Br=0,zr=!1;const Rn=(1+Math.sqrt(5))/2,jn=1/Rn,Ta=[new N(-Rn,jn,0),new N(Rn,jn,0),new N(-jn,0,Rn),new N(jn,0,Rn),new N(0,Rn,-jn),new N(0,Rn,jn),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)],Ku=new N;class ba{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,r=100,s={}){const{size:a=256,position:o=Ku}=s;Fr=this._renderer.getRenderTarget(),Or=this._renderer.getActiveCubeFace(),Br=this._renderer.getActiveMipmapLevel(),zr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,n,r,c,o),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=wa(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ra(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Fr,Or,Br),this._renderer.xr.enabled=zr,t.scissorTest=!1,qi(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===ii||t.mapping===ri?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Fr=this._renderer.getRenderTarget(),Or=this._renderer.getActiveCubeFace(),Br=this._renderer.getActiveMipmapLevel(),zr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Ge,minFilter:Ge,generateMipmaps:!1,type:Mi,format:Be,colorSpace:si,depthBuffer:!1},r=Aa(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Aa(t,e,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Zu(s)),this._blurMaterial=ju(s,t,e)}return r}_compileMaterial(t){const e=new rn(this._lodPlanes[0],t);this._renderer.compile(e,Nr)}_sceneToCubeUV(t,e,n,r,s){const c=new Fe(90,1,e,n),l=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,m=d.toneMapping;d.getClearColor(ya),d.toneMapping=mn,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(r),d.clearDepth(),d.setRenderTarget(null));const M=new fo({name:"PMREM.Background",side:Te,depthWrite:!1,depthTest:!1}),p=new rn(new Ti,M);let h=!1;const A=t.background;A?A.isColor&&(M.color.copy(A),t.background=null,h=!0):(M.color.copy(ya),h=!0);for(let T=0;T<6;T++){const E=T%3;E===0?(c.up.set(0,l[T],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+u[T],s.y,s.z)):E===1?(c.up.set(0,0,l[T]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+u[T],s.z)):(c.up.set(0,l[T],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+u[T]));const C=this._cubeSize;qi(r,E*C,T>2?C:0,C,C),d.setRenderTarget(r),h&&d.render(p,c),d.render(t,c)}p.geometry.dispose(),p.material.dispose(),d.toneMapping=m,d.autoClear=f,t.background=A}_textureToCubeUV(t,e){const n=this._renderer,r=t.mapping===ii||t.mapping===ri;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=wa()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ra());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new rn(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=t;const c=this._cubeSize;qi(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,Nr)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=Ta[(r-s-1)%Ta.length];this._blur(t,s-1,s,a,o)}e.autoClear=n}_blur(t,e,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,r,"latitudinal",s),this._halfBlur(a,t,n,n,r,"longitudinal",s)}_halfBlur(t,e,n,r,s,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,d=new rn(this._lodPlanes[r],l),f=l.uniforms,m=this._sizeLods[n]-1,v=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Cn-1),M=s/v,p=isFinite(s)?1+Math.floor(u*M):Cn;p>Cn&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Cn}`);const h=[];let A=0;for(let D=0;D<Cn;++D){const F=D/M,S=Math.exp(-F*F/2);h.push(S),D===0?A+=S:D<p&&(A+=2*S)}for(let D=0;D<h.length;D++)h[D]=h[D]/A;f.envMap.value=t.texture,f.samples.value=p,f.weights.value=h,f.latitudinal.value=a==="latitudinal",o&&(f.poleAxis.value=o);const{_lodMax:T}=this;f.dTheta.value=v,f.mipInt.value=T-n;const E=this._sizeLods[r],C=3*E*(r>T-Jn?r-T+Jn:0),R=4*(this._cubeSize-E);qi(e,C,R,3*E,2*E),c.setRenderTarget(e),c.render(d,Nr)}}function Zu(i){const t=[],e=[],n=[];let r=i;const s=i-Jn+1+Ea.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);e.push(o);let c=1/o;a>i-Jn?c=Ea[a-i+Jn-1]:a===0&&(c=0),n.push(c);const l=1/(o-2),u=-l,d=1+l,f=[u,u,d,u,d,d,u,u,d,d,u,d],m=6,v=6,M=3,p=2,h=1,A=new Float32Array(M*v*m),T=new Float32Array(p*v*m),E=new Float32Array(h*v*m);for(let R=0;R<m;R++){const D=R%3*2/3-1,F=R>2?0:-1,S=[D,F,0,D+2/3,F,0,D+2/3,F+1,0,D,F,0,D+2/3,F+1,0,D,F+1,0];A.set(S,M*v*R),T.set(f,p*v*R);const x=[R,R,R,R,R,R];E.set(x,h*v*R)}const C=new vn;C.setAttribute("position",new We(A,M)),C.setAttribute("uv",new We(T,p)),C.setAttribute("faceIndex",new We(E,h)),t.push(C),r>Jn&&r--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Aa(i,t,e){const n=new In(i,t,e);return n.texture.mapping=sr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function qi(i,t,e,n,r){i.viewport.set(t,e,n,r),i.scissor.set(t,e,n,r)}function ju(i,t,e){const n=new Float32Array(Cn),r=new N(0,1,0);return new gn({name:"SphericalGaussianBlur",defines:{n:Cn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Hs(),fragmentShader:`
  3569. precision mediump float;
  3570. precision mediump int;
  3571. varying vec3 vOutputDirection;
  3572. uniform sampler2D envMap;
  3573. uniform int samples;
  3574. uniform float weights[ n ];
  3575. uniform bool latitudinal;
  3576. uniform float dTheta;
  3577. uniform float mipInt;
  3578. uniform vec3 poleAxis;
  3579. #define ENVMAP_TYPE_CUBE_UV
  3580. #include <cube_uv_reflection_fragment>
  3581. vec3 getSample( float theta, vec3 axis ) {
  3582. float cosTheta = cos( theta );
  3583. // Rodrigues' axis-angle rotation
  3584. vec3 sampleDirection = vOutputDirection * cosTheta
  3585. + cross( axis, vOutputDirection ) * sin( theta )
  3586. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3587. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3588. }
  3589. void main() {
  3590. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3591. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3592. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3593. }
  3594. axis = normalize( axis );
  3595. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3596. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3597. for ( int i = 1; i < n; i++ ) {
  3598. if ( i >= samples ) {
  3599. break;
  3600. }
  3601. float theta = dTheta * float( i );
  3602. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3603. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3604. }
  3605. }
  3606. `,blending:pn,depthTest:!1,depthWrite:!1})}function Ra(){return new gn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Hs(),fragmentShader:`
  3607. precision mediump float;
  3608. precision mediump int;
  3609. varying vec3 vOutputDirection;
  3610. uniform sampler2D envMap;
  3611. #include <common>
  3612. void main() {
  3613. vec3 outputDirection = normalize( vOutputDirection );
  3614. vec2 uv = equirectUv( outputDirection );
  3615. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3616. }
  3617. `,blending:pn,depthTest:!1,depthWrite:!1})}function wa(){return new gn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Hs(),fragmentShader:`
  3618. precision mediump float;
  3619. precision mediump int;
  3620. uniform float flipEnvMap;
  3621. varying vec3 vOutputDirection;
  3622. uniform samplerCube envMap;
  3623. void main() {
  3624. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3625. }
  3626. `,blending:pn,depthTest:!1,depthWrite:!1})}function Hs(){return`
  3627. precision mediump float;
  3628. precision mediump int;
  3629. attribute float faceIndex;
  3630. varying vec3 vOutputDirection;
  3631. // RH coordinate system; PMREM face-indexing convention
  3632. vec3 getDirection( vec2 uv, float face ) {
  3633. uv = 2.0 * uv - 1.0;
  3634. vec3 direction = vec3( uv, 1.0 );
  3635. if ( face == 0.0 ) {
  3636. direction = direction.zyx; // ( 1, v, u ) pos x
  3637. } else if ( face == 1.0 ) {
  3638. direction = direction.xzy;
  3639. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3640. } else if ( face == 2.0 ) {
  3641. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3642. } else if ( face == 3.0 ) {
  3643. direction = direction.zyx;
  3644. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3645. } else if ( face == 4.0 ) {
  3646. direction = direction.xzy;
  3647. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3648. } else if ( face == 5.0 ) {
  3649. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3650. }
  3651. return direction;
  3652. }
  3653. void main() {
  3654. vOutputDirection = getDirection( uv, faceIndex );
  3655. gl_Position = vec4( position, 1.0 );
  3656. }
  3657. `}function $u(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){const c=o.mapping,l=c===$r||c===Jr,u=c===ii||c===ri;if(l||u){let d=t.get(o);const f=d!==void 0?d.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==f)return e===null&&(e=new ba(i)),d=l?e.fromEquirectangular(o,d):e.fromCubemap(o,d),d.texture.pmremVersion=o.pmremVersion,t.set(o,d),d.texture;if(d!==void 0)return d.texture;{const m=o.image;return l&&m&&m.height>0||u&&m&&r(m)?(e===null&&(e=new ba(i)),d=l?e.fromEquirectangular(o):e.fromCubemap(o),d.texture.pmremVersion=o.pmremVersion,t.set(o,d),o.addEventListener("dispose",s),d.texture):null}}}return o}function r(o){let c=0;const l=6;for(let u=0;u<l;u++)o[u]!==void 0&&c++;return c===l}function s(o){const c=o.target;c.removeEventListener("dispose",s);const l=t.get(c);l!==void 0&&(t.delete(c),l.dispose())}function a(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:a}}function Ju(i){const t={};function e(n){if(t[n]!==void 0)return t[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return t[n]=r,r}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const r=e(n);return r===null&&xi("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function Qu(i,t,e,n){const r={},s=new WeakMap;function a(d){const f=d.target;f.index!==null&&t.remove(f.index);for(const v in f.attributes)t.remove(f.attributes[v]);f.removeEventListener("dispose",a),delete r[f.id];const m=s.get(f);m&&(t.remove(m),s.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,e.memory.geometries--}function o(d,f){return r[f.id]===!0||(f.addEventListener("dispose",a),r[f.id]=!0,e.memory.geometries++),f}function c(d){const f=d.attributes;for(const m in f)t.update(f[m],i.ARRAY_BUFFER)}function l(d){const f=[],m=d.index,v=d.attributes.position;let M=0;if(m!==null){const A=m.array;M=m.version;for(let T=0,E=A.length;T<E;T+=3){const C=A[T+0],R=A[T+1],D=A[T+2];f.push(C,R,R,D,D,C)}}else if(v!==void 0){const A=v.array;M=v.version;for(let T=0,E=A.length/3-1;T<E;T+=3){const C=T+0,R=T+1,D=T+2;f.push(C,R,R,D,D,C)}}else return;const p=new(oo(f)?mo:po)(f,1);p.version=M;const h=s.get(d);h&&t.remove(h),s.set(d,p)}function u(d){const f=s.get(d);if(f){const m=d.index;m!==null&&f.version<m.version&&l(d)}else l(d);return s.get(d)}return{get:o,update:c,getWireframeAttribute:u}}function td(i,t,e){let n;function r(f){n=f}let s,a;function o(f){s=f.type,a=f.bytesPerElement}function c(f,m){i.drawElements(n,m,s,f*a),e.update(m,n,1)}function l(f,m,v){v!==0&&(i.drawElementsInstanced(n,m,s,f*a,v),e.update(m,n,v))}function u(f,m,v){if(v===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,m,0,s,f,0,v);let p=0;for(let h=0;h<v;h++)p+=m[h];e.update(p,n,1)}function d(f,m,v,M){if(v===0)return;const p=t.get("WEBGL_multi_draw");if(p===null)for(let h=0;h<f.length;h++)l(f[h]/a,m[h],M[h]);else{p.multiDrawElementsInstancedWEBGL(n,m,0,s,f,0,M,0,v);let h=0;for(let A=0;A<v;A++)h+=m[A]*M[A];e.update(h,n,1)}}this.setMode=r,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=d}function ed(i){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(e.calls++,a){case i.TRIANGLES:e.triangles+=o*(s/3);break;case i.LINES:e.lines+=o*(s/2);break;case i.LINE_STRIP:e.lines+=o*(s-1);break;case i.LINE_LOOP:e.lines+=o*s;break;case i.POINTS:e.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function r(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:r,update:n}}function nd(i,t,e){const n=new WeakMap,r=new se;function s(a,o,c){const l=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=u!==void 0?u.length:0;let f=n.get(o);if(f===void 0||f.count!==d){let S=function(){D.dispose(),n.delete(o),o.removeEventListener("dispose",S)};f!==void 0&&f.texture.dispose();const m=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,M=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],h=o.morphAttributes.normal||[],A=o.morphAttributes.color||[];let T=0;m===!0&&(T=1),v===!0&&(T=2),M===!0&&(T=3);let E=o.attributes.position.count*T,C=1;E>t.maxTextureSize&&(C=Math.ceil(E/t.maxTextureSize),E=t.maxTextureSize);const R=new Float32Array(E*C*4*d),D=new lo(R,E,C,d);D.type=nn,D.needsUpdate=!0;const F=T*4;for(let x=0;x<d;x++){const P=p[x],z=h[x],G=A[x],X=E*C*4*x;for(let K=0;K<P.count;K++){const W=K*F;m===!0&&(r.fromBufferAttribute(P,K),R[X+W+0]=r.x,R[X+W+1]=r.y,R[X+W+2]=r.z,R[X+W+3]=0),v===!0&&(r.fromBufferAttribute(z,K),R[X+W+4]=r.x,R[X+W+5]=r.y,R[X+W+6]=r.z,R[X+W+7]=0),M===!0&&(r.fromBufferAttribute(G,K),R[X+W+8]=r.x,R[X+W+9]=r.y,R[X+W+10]=r.z,R[X+W+11]=G.itemSize===4?r.w:1)}}f={count:d,texture:D,size:new Lt(E,C)},n.set(o,f),o.addEventListener("dispose",S)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,e);else{let m=0;for(let M=0;M<l.length;M++)m+=l[M];const v=o.morphTargetsRelative?1:1-m;c.getUniforms().setValue(i,"morphTargetBaseInfluence",v),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",f.texture,e),c.getUniforms().setValue(i,"morphTargetsTextureSize",f.size)}return{update:s}}function id(i,t,e,n){let r=new WeakMap;function s(c){const l=n.render.frame,u=c.geometry,d=t.get(c,u);if(r.get(d)!==l&&(t.update(d),r.set(d,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),r.get(c)!==l&&(e.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){const f=c.skeleton;r.get(f)!==l&&(f.update(),r.set(f,l))}return d}function a(){r=new WeakMap}function o(c){const l=c.target;l.removeEventListener("dispose",o),e.remove(l.instanceMatrix),l.instanceColor!==null&&e.remove(l.instanceColor)}return{update:s,dispose:a}}const bo=new Me,Ca=new xo(1,1),Ao=new lo,Ro=new Ll,wo=new vo,Pa=[],Da=[],La=new Float32Array(16),Ua=new Float32Array(9),Ia=new Float32Array(4);function oi(i,t,e){const n=i[0];if(n<=0||n>0)return i;const r=t*e;let s=Pa[r];if(s===void 0&&(s=new Float32Array(r),Pa[r]=s),t!==0){n.toArray(s,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(s,o)}return s}function he(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function ue(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function or(i,t){let e=Da[t];e===void 0&&(e=new Int32Array(t),Da[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function rd(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function sd(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(he(e,t))return;i.uniform2fv(this.addr,t),ue(e,t)}}function ad(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(he(e,t))return;i.uniform3fv(this.addr,t),ue(e,t)}}function od(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(he(e,t))return;i.uniform4fv(this.addr,t),ue(e,t)}}function ld(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(he(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),ue(e,t)}else{if(he(e,n))return;Ia.set(n),i.uniformMatrix2fv(this.addr,!1,Ia),ue(e,n)}}function cd(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(he(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),ue(e,t)}else{if(he(e,n))return;Ua.set(n),i.uniformMatrix3fv(this.addr,!1,Ua),ue(e,n)}}function hd(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(he(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),ue(e,t)}else{if(he(e,n))return;La.set(n),i.uniformMatrix4fv(this.addr,!1,La),ue(e,n)}}function ud(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function dd(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(he(e,t))return;i.uniform2iv(this.addr,t),ue(e,t)}}function fd(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(he(e,t))return;i.uniform3iv(this.addr,t),ue(e,t)}}function pd(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(he(e,t))return;i.uniform4iv(this.addr,t),ue(e,t)}}function md(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function _d(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(he(e,t))return;i.uniform2uiv(this.addr,t),ue(e,t)}}function gd(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(he(e,t))return;i.uniform3uiv(this.addr,t),ue(e,t)}}function vd(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(he(e,t))return;i.uniform4uiv(this.addr,t),ue(e,t)}}function xd(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(Ca.compareFunction=ao,s=Ca):s=bo,e.setTexture2D(t||s,r)}function Md(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture3D(t||Ro,r)}function Sd(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTextureCube(t||wo,r)}function Ed(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture2DArray(t||Ao,r)}function yd(i){switch(i){case 5126:return rd;case 35664:return sd;case 35665:return ad;case 35666:return od;case 35674:return ld;case 35675:return cd;case 35676:return hd;case 5124:case 35670:return ud;case 35667:case 35671:return dd;case 35668:case 35672:return fd;case 35669:case 35673:return pd;case 5125:return md;case 36294:return _d;case 36295:return gd;case 36296:return vd;case 35678:case 36198:case 36298:case 36306:case 35682:return xd;case 35679:case 36299:case 36307:return Md;case 35680:case 36300:case 36308:case 36293:return Sd;case 36289:case 36303:case 36311:case 36292:return Ed}}function Td(i,t){i.uniform1fv(this.addr,t)}function bd(i,t){const e=oi(t,this.size,2);i.uniform2fv(this.addr,e)}function Ad(i,t){const e=oi(t,this.size,3);i.uniform3fv(this.addr,e)}function Rd(i,t){const e=oi(t,this.size,4);i.uniform4fv(this.addr,e)}function wd(i,t){const e=oi(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function Cd(i,t){const e=oi(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function Pd(i,t){const e=oi(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function Dd(i,t){i.uniform1iv(this.addr,t)}function Ld(i,t){i.uniform2iv(this.addr,t)}function Ud(i,t){i.uniform3iv(this.addr,t)}function Id(i,t){i.uniform4iv(this.addr,t)}function Nd(i,t){i.uniform1uiv(this.addr,t)}function Fd(i,t){i.uniform2uiv(this.addr,t)}function Od(i,t){i.uniform3uiv(this.addr,t)}function Bd(i,t){i.uniform4uiv(this.addr,t)}function zd(i,t,e){const n=this.cache,r=t.length,s=or(e,r);he(n,s)||(i.uniform1iv(this.addr,s),ue(n,s));for(let a=0;a!==r;++a)e.setTexture2D(t[a]||bo,s[a])}function Hd(i,t,e){const n=this.cache,r=t.length,s=or(e,r);he(n,s)||(i.uniform1iv(this.addr,s),ue(n,s));for(let a=0;a!==r;++a)e.setTexture3D(t[a]||Ro,s[a])}function Vd(i,t,e){const n=this.cache,r=t.length,s=or(e,r);he(n,s)||(i.uniform1iv(this.addr,s),ue(n,s));for(let a=0;a!==r;++a)e.setTextureCube(t[a]||wo,s[a])}function Gd(i,t,e){const n=this.cache,r=t.length,s=or(e,r);he(n,s)||(i.uniform1iv(this.addr,s),ue(n,s));for(let a=0;a!==r;++a)e.setTexture2DArray(t[a]||Ao,s[a])}function kd(i){switch(i){case 5126:return Td;case 35664:return bd;case 35665:return Ad;case 35666:return Rd;case 35674:return wd;case 35675:return Cd;case 35676:return Pd;case 5124:case 35670:return Dd;case 35667:case 35671:return Ld;case 35668:case 35672:return Ud;case 35669:case 35673:return Id;case 5125:return Nd;case 36294:return Fd;case 36295:return Od;case 36296:return Bd;case 35678:case 36198:case 36298:case 36306:case 35682:return zd;case 35679:case 36299:case 36307:return Hd;case 35680:case 36300:case 36308:case 36293:return Vd;case 36289:case 36303:case 36311:case 36292:return Gd}}class Wd{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=yd(e.type)}}class Xd{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=kd(e.type)}}class Yd{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(t,e[o.id],n)}}}const Hr=/(\w+)(\])?(\[|\.)?/g;function Na(i,t){i.seq.push(t),i.map[t.id]=t}function qd(i,t,e){const n=i.name,r=n.length;for(Hr.lastIndex=0;;){const s=Hr.exec(n),a=Hr.lastIndex;let o=s[1];const c=s[2]==="]",l=s[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===r){Na(e,l===void 0?new Wd(o,i,t):new Xd(o,i,t));break}else{let d=e.map[o];d===void 0&&(d=new Yd(o),Na(e,d)),e=d}}}class er{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=t.getActiveUniform(e,r),a=t.getUniformLocation(e,s.name);qd(s,a,this)}}setValue(t,e,n,r){const s=this.map[e];s!==void 0&&s.setValue(t,n,r)}setOptional(t,e,n){const r=e[n];r!==void 0&&this.setValue(t,n,r)}static upload(t,e,n,r){for(let s=0,a=e.length;s!==a;++s){const o=e[s],c=n[o.id];c.needsUpdate!==!1&&o.setValue(t,c.value,r)}}static seqWithValue(t,e){const n=[];for(let r=0,s=t.length;r!==s;++r){const a=t[r];a.id in e&&n.push(a)}return n}}function Fa(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const Kd=37297;let Zd=0;function jd(i,t){const e=i.split(`
  3658. `),n=[],r=Math.max(t-6,0),s=Math.min(t+6,e.length);for(let a=r;a<s;a++){const o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
  3659. `)}const Oa=new It;function $d(i){Gt._getMatrix(Oa,Gt.workingColorSpace,i);const t=`mat3( ${Oa.elements.map(e=>e.toFixed(4))} )`;switch(Gt.getTransfer(i)){case nr:return[t,"LinearTransferOETF"];case qt:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Ba(i,t,e){const n=i.getShaderParameter(t,i.COMPILE_STATUS),s=(i.getShaderInfoLog(t)||"").trim();if(n&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return e.toUpperCase()+`
  3660. `+s+`
  3661. `+jd(i.getShaderSource(t),o)}else return s}function Jd(i,t){const e=$d(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
  3662. `)}function Qd(i,t){let e;switch(t){case sl:e="Linear";break;case al:e="Reinhard";break;case ol:e="Cineon";break;case ll:e="ACESFilmic";break;case hl:e="AgX";break;case ul:e="Neutral";break;case cl:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const Ki=new N;function tf(){Gt.getLuminanceCoefficients(Ki);const i=Ki.x.toFixed(4),t=Ki.y.toFixed(4),e=Ki.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
  3663. `)}function ef(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(pi).join(`
  3664. `)}function nf(i){const t=[];for(const e in i){const n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
  3665. `)}function rf(i,t){const e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(t,r),a=s.name;let o=1;s.type===i.FLOAT_MAT2&&(o=2),s.type===i.FLOAT_MAT3&&(o=3),s.type===i.FLOAT_MAT4&&(o=4),e[a]={type:s.type,location:i.getAttribLocation(t,a),locationSize:o}}return e}function pi(i){return i!==""}function za(i,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Ha(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const sf=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ps(i){return i.replace(sf,of)}const af=new Map;function of(i,t){let e=Ft[t];if(e===void 0){const n=af.get(t);if(n!==void 0)e=Ft[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Ps(e)}const lf=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Va(i){return i.replace(lf,cf)}function cf(i,t,e,n){let r="";for(let s=parseInt(t);s<parseInt(e);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Ga(i){let t=`precision ${i.precision} float;
  3666. precision ${i.precision} int;
  3667. precision ${i.precision} sampler2D;
  3668. precision ${i.precision} samplerCube;
  3669. precision ${i.precision} sampler3D;
  3670. precision ${i.precision} sampler2DArray;
  3671. precision ${i.precision} sampler2DShadow;
  3672. precision ${i.precision} samplerCubeShadow;
  3673. precision ${i.precision} sampler2DArrayShadow;
  3674. precision ${i.precision} isampler2D;
  3675. precision ${i.precision} isampler3D;
  3676. precision ${i.precision} isamplerCube;
  3677. precision ${i.precision} isampler2DArray;
  3678. precision ${i.precision} usampler2D;
  3679. precision ${i.precision} usampler3D;
  3680. precision ${i.precision} usamplerCube;
  3681. precision ${i.precision} usampler2DArray;
  3682. `;return i.precision==="highp"?t+=`
  3683. #define HIGH_PRECISION`:i.precision==="mediump"?t+=`
  3684. #define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
  3685. #define LOW_PRECISION`),t}function hf(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Ka?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===Bo?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===tn&&(t="SHADOWMAP_TYPE_VSM"),t}function uf(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case ii:case ri:t="ENVMAP_TYPE_CUBE";break;case sr:t="ENVMAP_TYPE_CUBE_UV";break}return t}function df(i){let t="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case ri:t="ENVMAP_MODE_REFRACTION";break}return t}function ff(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case Za:t="ENVMAP_BLENDING_MULTIPLY";break;case il:t="ENVMAP_BLENDING_MIX";break;case rl:t="ENVMAP_BLENDING_ADD";break}return t}function pf(i){const t=i.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function mf(i,t,e,n){const r=i.getContext(),s=e.defines;let a=e.vertexShader,o=e.fragmentShader;const c=hf(e),l=uf(e),u=df(e),d=ff(e),f=pf(e),m=ef(e),v=nf(s),M=r.createProgram();let p,h,A=e.glslVersion?"#version "+e.glslVersion+`
  3686. `:"";e.isRawShaderMaterial?(p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,v].filter(pi).join(`
  3687. `),p.length>0&&(p+=`
  3688. `),h=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,v].filter(pi).join(`
  3689. `),h.length>0&&(h+=`
  3690. `)):(p=[Ga(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,v,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+u:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3691. `].filter(pi).join(`
  3692. `),h=[Ga(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,v,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+u:"",e.envMap?"#define "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==mn?"#define TONE_MAPPING":"",e.toneMapping!==mn?Ft.tonemapping_pars_fragment:"",e.toneMapping!==mn?Qd("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Ft.colorspace_pars_fragment,Jd("linearToOutputTexel",e.outputColorSpace),tf(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
  3693. `].filter(pi).join(`
  3694. `)),a=Ps(a),a=za(a,e),a=Ha(a,e),o=Ps(o),o=za(o,e),o=Ha(o,e),a=Va(a),o=Va(o),e.isRawShaderMaterial!==!0&&(A=`#version 300 es
  3695. `,p=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3696. `)+`
  3697. `+p,h=["#define varying in",e.glslVersion===ta?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===ta?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
  3698. `)+`
  3699. `+h);const T=A+p+a,E=A+h+o,C=Fa(r,r.VERTEX_SHADER,T),R=Fa(r,r.FRAGMENT_SHADER,E);r.attachShader(M,C),r.attachShader(M,R),e.index0AttributeName!==void 0?r.bindAttribLocation(M,0,e.index0AttributeName):e.morphTargets===!0&&r.bindAttribLocation(M,0,"position"),r.linkProgram(M);function D(P){if(i.debug.checkShaderErrors){const z=r.getProgramInfoLog(M)||"",G=r.getShaderInfoLog(C)||"",X=r.getShaderInfoLog(R)||"",K=z.trim(),W=G.trim(),et=X.trim();let H=!0,st=!0;if(r.getProgramParameter(M,r.LINK_STATUS)===!1)if(H=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,M,C,R);else{const ct=Ba(r,C,"vertex"),Et=Ba(r,R,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(M,r.VALIDATE_STATUS)+`
  3700. Material Name: `+P.name+`
  3701. Material Type: `+P.type+`
  3702. Program Info Log: `+K+`
  3703. `+ct+`
  3704. `+Et)}else K!==""?console.warn("THREE.WebGLProgram: Program Info Log:",K):(W===""||et==="")&&(st=!1);st&&(P.diagnostics={runnable:H,programLog:K,vertexShader:{log:W,prefix:p},fragmentShader:{log:et,prefix:h}})}r.deleteShader(C),r.deleteShader(R),F=new er(r,M),S=rf(r,M)}let F;this.getUniforms=function(){return F===void 0&&D(this),F};let S;this.getAttributes=function(){return S===void 0&&D(this),S};let x=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return x===!1&&(x=r.getProgramParameter(M,Kd)),x},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(M),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=Zd++,this.cacheKey=t,this.usedTimes=1,this.program=M,this.vertexShader=C,this.fragmentShader=R,this}let _f=0;class gf{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,r=this._getShaderStage(e),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new vf(t),e.set(t,n)),n}}class vf{constructor(t){this.id=_f++,this.code=t,this.usedTimes=0}}function xf(i,t,e,n,r,s,a){const o=new ho,c=new gf,l=new Set,u=[],d=r.logarithmicDepthBuffer,f=r.vertexTextures;let m=r.precision;const v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function M(S){return l.add(S),S===0?"uv":`uv${S}`}function p(S,x,P,z,G){const X=z.fog,K=G.geometry,W=S.isMeshStandardMaterial?z.environment:null,et=(S.isMeshStandardMaterial?e:t).get(S.envMap||W),H=et&&et.mapping===sr?et.image.height:null,st=v[S.type];S.precision!==null&&(m=r.getMaxPrecision(S.precision),m!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",m,"instead."));const ct=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,Et=ct!==void 0?ct.length:0;let Ot=0;K.morphAttributes.position!==void 0&&(Ot=1),K.morphAttributes.normal!==void 0&&(Ot=2),K.morphAttributes.color!==void 0&&(Ot=3);let jt,Qt,Wt,Y;if(st){const Xt=Ve[st];jt=Xt.vertexShader,Qt=Xt.fragmentShader}else jt=S.vertexShader,Qt=S.fragmentShader,c.update(S),Wt=c.getVertexShaderID(S),Y=c.getFragmentShaderID(S);const j=i.getRenderTarget(),dt=i.state.buffers.depth.getReversed(),Ct=G.isInstancedMesh===!0,St=G.isBatchedMesh===!0,Ht=!!S.map,pe=!!S.matcap,b=!!et,te=!!S.aoMap,Dt=!!S.lightMap,Rt=!!S.bumpMap,mt=!!S.normalMap,ee=!!S.displacementMap,_t=!!S.emissiveMap,Nt=!!S.metalnessMap,de=!!S.roughnessMap,ae=S.anisotropy>0,y=S.clearcoat>0,_=S.dispersion>0,I=S.iridescence>0,k=S.sheen>0,Z=S.transmission>0,V=ae&&!!S.anisotropyMap,Mt=y&&!!S.clearcoatMap,nt=y&&!!S.clearcoatNormalMap,gt=y&&!!S.clearcoatRoughnessMap,vt=I&&!!S.iridescenceMap,Q=I&&!!S.iridescenceThicknessMap,lt=k&&!!S.sheenColorMap,At=k&&!!S.sheenRoughnessMap,xt=!!S.specularMap,at=!!S.specularColorMap,Ut=!!S.specularIntensityMap,w=Z&&!!S.transmissionMap,tt=Z&&!!S.thicknessMap,it=!!S.gradientMap,ut=!!S.alphaMap,$=S.alphaTest>0,q=!!S.alphaHash,pt=!!S.extensions;let Pt=mn;S.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(Pt=i.toneMapping);const $t={shaderID:st,shaderType:S.type,shaderName:S.name,vertexShader:jt,fragmentShader:Qt,defines:S.defines,customVertexShaderID:Wt,customFragmentShaderID:Y,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:m,batching:St,batchingColor:St&&G._colorsTexture!==null,instancing:Ct,instancingColor:Ct&&G.instanceColor!==null,instancingMorph:Ct&&G.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:j===null?i.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:si,alphaToCoverage:!!S.alphaToCoverage,map:Ht,matcap:pe,envMap:b,envMapMode:b&&et.mapping,envMapCubeUVHeight:H,aoMap:te,lightMap:Dt,bumpMap:Rt,normalMap:mt,displacementMap:f&&ee,emissiveMap:_t,normalMapObjectSpace:mt&&S.normalMapType===ml,normalMapTangentSpace:mt&&S.normalMapType===so,metalnessMap:Nt,roughnessMap:de,anisotropy:ae,anisotropyMap:V,clearcoat:y,clearcoatMap:Mt,clearcoatNormalMap:nt,clearcoatRoughnessMap:gt,dispersion:_,iridescence:I,iridescenceMap:vt,iridescenceThicknessMap:Q,sheen:k,sheenColorMap:lt,sheenRoughnessMap:At,specularMap:xt,specularColorMap:at,specularIntensityMap:Ut,transmission:Z,transmissionMap:w,thicknessMap:tt,gradientMap:it,opaque:S.transparent===!1&&S.blending===ti&&S.alphaToCoverage===!1,alphaMap:ut,alphaTest:$,alphaHash:q,combine:S.combine,mapUv:Ht&&M(S.map.channel),aoMapUv:te&&M(S.aoMap.channel),lightMapUv:Dt&&M(S.lightMap.channel),bumpMapUv:Rt&&M(S.bumpMap.channel),normalMapUv:mt&&M(S.normalMap.channel),displacementMapUv:ee&&M(S.displacementMap.channel),emissiveMapUv:_t&&M(S.emissiveMap.channel),metalnessMapUv:Nt&&M(S.metalnessMap.channel),roughnessMapUv:de&&M(S.roughnessMap.channel),anisotropyMapUv:V&&M(S.anisotropyMap.channel),clearcoatMapUv:Mt&&M(S.clearcoatMap.channel),clearcoatNormalMapUv:nt&&M(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:gt&&M(S.clearcoatRoughnessMap.channel),iridescenceMapUv:vt&&M(S.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&M(S.iridescenceThicknessMap.channel),sheenColorMapUv:lt&&M(S.sheenColorMap.channel),sheenRoughnessMapUv:At&&M(S.sheenRoughnessMap.channel),specularMapUv:xt&&M(S.specularMap.channel),specularColorMapUv:at&&M(S.specularColorMap.channel),specularIntensityMapUv:Ut&&M(S.specularIntensityMap.channel),transmissionMapUv:w&&M(S.transmissionMap.channel),thicknessMapUv:tt&&M(S.thicknessMap.channel),alphaMapUv:ut&&M(S.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(mt||ae),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,pointsUvs:G.isPoints===!0&&!!K.attributes.uv&&(Ht||ut),fog:!!X,useFog:S.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:S.flatShading===!0&&S.wireframe===!1,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:dt,skinning:G.isSkinnedMesh===!0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:Et,morphTextureStride:Ot,numDirLights:x.directional.length,numPointLights:x.point.length,numSpotLights:x.spot.length,numSpotLightMaps:x.spotLightMap.length,numRectAreaLights:x.rectArea.length,numHemiLights:x.hemi.length,numDirLightShadows:x.directionalShadowMap.length,numPointLightShadows:x.pointShadowMap.length,numSpotLightShadows:x.spotShadowMap.length,numSpotLightShadowsWithMaps:x.numSpotLightShadowsWithMaps,numLightProbes:x.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:Pt,decodeVideoTexture:Ht&&S.map.isVideoTexture===!0&&Gt.getTransfer(S.map.colorSpace)===qt,decodeVideoTextureEmissive:_t&&S.emissiveMap.isVideoTexture===!0&&Gt.getTransfer(S.emissiveMap.colorSpace)===qt,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===en,flipSided:S.side===Te,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionClipCullDistance:pt&&S.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(pt&&S.extensions.multiDraw===!0||St)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()};return $t.vertexUv1s=l.has(1),$t.vertexUv2s=l.has(2),$t.vertexUv3s=l.has(3),l.clear(),$t}function h(S){const x=[];if(S.shaderID?x.push(S.shaderID):(x.push(S.customVertexShaderID),x.push(S.customFragmentShaderID)),S.defines!==void 0)for(const P in S.defines)x.push(P),x.push(S.defines[P]);return S.isRawShaderMaterial===!1&&(A(x,S),T(x,S),x.push(i.outputColorSpace)),x.push(S.customProgramCacheKey),x.join()}function A(S,x){S.push(x.precision),S.push(x.outputColorSpace),S.push(x.envMapMode),S.push(x.envMapCubeUVHeight),S.push(x.mapUv),S.push(x.alphaMapUv),S.push(x.lightMapUv),S.push(x.aoMapUv),S.push(x.bumpMapUv),S.push(x.normalMapUv),S.push(x.displacementMapUv),S.push(x.emissiveMapUv),S.push(x.metalnessMapUv),S.push(x.roughnessMapUv),S.push(x.anisotropyMapUv),S.push(x.clearcoatMapUv),S.push(x.clearcoatNormalMapUv),S.push(x.clearcoatRoughnessMapUv),S.push(x.iridescenceMapUv),S.push(x.iridescenceThicknessMapUv),S.push(x.sheenColorMapUv),S.push(x.sheenRoughnessMapUv),S.push(x.specularMapUv),S.push(x.specularColorMapUv),S.push(x.specularIntensityMapUv),S.push(x.transmissionMapUv),S.push(x.thicknessMapUv),S.push(x.combine),S.push(x.fogExp2),S.push(x.sizeAttenuation),S.push(x.morphTargetsCount),S.push(x.morphAttributeCount),S.push(x.numDirLights),S.push(x.numPointLights),S.push(x.numSpotLights),S.push(x.numSpotLightMaps),S.push(x.numHemiLights),S.push(x.numRectAreaLights),S.push(x.numDirLightShadows),S.push(x.numPointLightShadows),S.push(x.numSpotLightShadows),S.push(x.numSpotLightShadowsWithMaps),S.push(x.numLightProbes),S.push(x.shadowMapType),S.push(x.toneMapping),S.push(x.numClippingPlanes),S.push(x.numClipIntersection),S.push(x.depthPacking)}function T(S,x){o.disableAll(),x.supportsVertexTextures&&o.enable(0),x.instancing&&o.enable(1),x.instancingColor&&o.enable(2),x.instancingMorph&&o.enable(3),x.matcap&&o.enable(4),x.envMap&&o.enable(5),x.normalMapObjectSpace&&o.enable(6),x.normalMapTangentSpace&&o.enable(7),x.clearcoat&&o.enable(8),x.iridescence&&o.enable(9),x.alphaTest&&o.enable(10),x.vertexColors&&o.enable(11),x.vertexAlphas&&o.enable(12),x.vertexUv1s&&o.enable(13),x.vertexUv2s&&o.enable(14),x.vertexUv3s&&o.enable(15),x.vertexTangents&&o.enable(16),x.anisotropy&&o.enable(17),x.alphaHash&&o.enable(18),x.batching&&o.enable(19),x.dispersion&&o.enable(20),x.batchingColor&&o.enable(21),x.gradientMap&&o.enable(22),S.push(o.mask),o.disableAll(),x.fog&&o.enable(0),x.useFog&&o.enable(1),x.flatShading&&o.enable(2),x.logarithmicDepthBuffer&&o.enable(3),x.reversedDepthBuffer&&o.enable(4),x.skinning&&o.enable(5),x.morphTargets&&o.enable(6),x.morphNormals&&o.enable(7),x.morphColors&&o.enable(8),x.premultipliedAlpha&&o.enable(9),x.shadowMapEnabled&&o.enable(10),x.doubleSided&&o.enable(11),x.flipSided&&o.enable(12),x.useDepthPacking&&o.enable(13),x.dithering&&o.enable(14),x.transmission&&o.enable(15),x.sheen&&o.enable(16),x.opaque&&o.enable(17),x.pointsUvs&&o.enable(18),x.decodeVideoTexture&&o.enable(19),x.decodeVideoTextureEmissive&&o.enable(20),x.alphaToCoverage&&o.enable(21),S.push(o.mask)}function E(S){const x=v[S.type];let P;if(x){const z=Ve[x];P=Xl.clone(z.uniforms)}else P=S.uniforms;return P}function C(S,x){let P;for(let z=0,G=u.length;z<G;z++){const X=u[z];if(X.cacheKey===x){P=X,++P.usedTimes;break}}return P===void 0&&(P=new mf(i,x,S,s),u.push(P)),P}function R(S){if(--S.usedTimes===0){const x=u.indexOf(S);u[x]=u[u.length-1],u.pop(),S.destroy()}}function D(S){c.remove(S)}function F(){c.dispose()}return{getParameters:p,getProgramCacheKey:h,getUniforms:E,acquireProgram:C,releaseProgram:R,releaseShaderCache:D,programs:u,dispose:F}}function Mf(){let i=new WeakMap;function t(a){return i.has(a)}function e(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function r(a,o,c){i.get(a)[o]=c}function s(){i=new WeakMap}return{has:t,get:e,remove:n,update:r,dispose:s}}function Sf(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function ka(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function Wa(){const i=[];let t=0;const e=[],n=[],r=[];function s(){t=0,e.length=0,n.length=0,r.length=0}function a(d,f,m,v,M,p){let h=i[t];return h===void 0?(h={id:d.id,object:d,geometry:f,material:m,groupOrder:v,renderOrder:d.renderOrder,z:M,group:p},i[t]=h):(h.id=d.id,h.object=d,h.geometry=f,h.material=m,h.groupOrder=v,h.renderOrder=d.renderOrder,h.z=M,h.group=p),t++,h}function o(d,f,m,v,M,p){const h=a(d,f,m,v,M,p);m.transmission>0?n.push(h):m.transparent===!0?r.push(h):e.push(h)}function c(d,f,m,v,M,p){const h=a(d,f,m,v,M,p);m.transmission>0?n.unshift(h):m.transparent===!0?r.unshift(h):e.unshift(h)}function l(d,f){e.length>1&&e.sort(d||Sf),n.length>1&&n.sort(f||ka),r.length>1&&r.sort(f||ka)}function u(){for(let d=t,f=i.length;d<f;d++){const m=i[d];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:e,transmissive:n,transparent:r,init:s,push:o,unshift:c,finish:u,sort:l}}function Ef(){let i=new WeakMap;function t(n,r){const s=i.get(n);let a;return s===void 0?(a=new Wa,i.set(n,[a])):r>=s.length?(a=new Wa,s.push(a)):a=s[r],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function yf(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new N,color:new kt};break;case"SpotLight":e={position:new N,direction:new N,color:new kt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new N,color:new kt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new N,skyColor:new kt,groundColor:new kt};break;case"RectAreaLight":e={color:new kt,position:new N,halfWidth:new N,halfHeight:new N};break}return i[t.id]=e,e}}}function Tf(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Lt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Lt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Lt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let bf=0;function Af(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Rf(i){const t=new yf,e=Tf(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new N);const r=new N,s=new oe,a=new oe;function o(l){let u=0,d=0,f=0;for(let S=0;S<9;S++)n.probe[S].set(0,0,0);let m=0,v=0,M=0,p=0,h=0,A=0,T=0,E=0,C=0,R=0,D=0;l.sort(Af);for(let S=0,x=l.length;S<x;S++){const P=l[S],z=P.color,G=P.intensity,X=P.distance,K=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)u+=z.r*G,d+=z.g*G,f+=z.b*G;else if(P.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(P.sh.coefficients[W],G);D++}else if(P.isDirectionalLight){const W=t.get(P);if(W.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){const et=P.shadow,H=e.get(P);H.shadowIntensity=et.intensity,H.shadowBias=et.bias,H.shadowNormalBias=et.normalBias,H.shadowRadius=et.radius,H.shadowMapSize=et.mapSize,n.directionalShadow[m]=H,n.directionalShadowMap[m]=K,n.directionalShadowMatrix[m]=P.shadow.matrix,A++}n.directional[m]=W,m++}else if(P.isSpotLight){const W=t.get(P);W.position.setFromMatrixPosition(P.matrixWorld),W.color.copy(z).multiplyScalar(G),W.distance=X,W.coneCos=Math.cos(P.angle),W.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),W.decay=P.decay,n.spot[M]=W;const et=P.shadow;if(P.map&&(n.spotLightMap[C]=P.map,C++,et.updateMatrices(P),P.castShadow&&R++),n.spotLightMatrix[M]=et.matrix,P.castShadow){const H=e.get(P);H.shadowIntensity=et.intensity,H.shadowBias=et.bias,H.shadowNormalBias=et.normalBias,H.shadowRadius=et.radius,H.shadowMapSize=et.mapSize,n.spotShadow[M]=H,n.spotShadowMap[M]=K,E++}M++}else if(P.isRectAreaLight){const W=t.get(P);W.color.copy(z).multiplyScalar(G),W.halfWidth.set(P.width*.5,0,0),W.halfHeight.set(0,P.height*.5,0),n.rectArea[p]=W,p++}else if(P.isPointLight){const W=t.get(P);if(W.color.copy(P.color).multiplyScalar(P.intensity),W.distance=P.distance,W.decay=P.decay,P.castShadow){const et=P.shadow,H=e.get(P);H.shadowIntensity=et.intensity,H.shadowBias=et.bias,H.shadowNormalBias=et.normalBias,H.shadowRadius=et.radius,H.shadowMapSize=et.mapSize,H.shadowCameraNear=et.camera.near,H.shadowCameraFar=et.camera.far,n.pointShadow[v]=H,n.pointShadowMap[v]=K,n.pointShadowMatrix[v]=P.shadow.matrix,T++}n.point[v]=W,v++}else if(P.isHemisphereLight){const W=t.get(P);W.skyColor.copy(P.color).multiplyScalar(G),W.groundColor.copy(P.groundColor).multiplyScalar(G),n.hemi[h]=W,h++}}p>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=rt.LTC_FLOAT_1,n.rectAreaLTC2=rt.LTC_FLOAT_2):(n.rectAreaLTC1=rt.LTC_HALF_1,n.rectAreaLTC2=rt.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=d,n.ambient[2]=f;const F=n.hash;(F.directionalLength!==m||F.pointLength!==v||F.spotLength!==M||F.rectAreaLength!==p||F.hemiLength!==h||F.numDirectionalShadows!==A||F.numPointShadows!==T||F.numSpotShadows!==E||F.numSpotMaps!==C||F.numLightProbes!==D)&&(n.directional.length=m,n.spot.length=M,n.rectArea.length=p,n.point.length=v,n.hemi.length=h,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=T,n.pointShadowMap.length=T,n.spotShadow.length=E,n.spotShadowMap.length=E,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=T,n.spotLightMatrix.length=E+C-R,n.spotLightMap.length=C,n.numSpotLightShadowsWithMaps=R,n.numLightProbes=D,F.directionalLength=m,F.pointLength=v,F.spotLength=M,F.rectAreaLength=p,F.hemiLength=h,F.numDirectionalShadows=A,F.numPointShadows=T,F.numSpotShadows=E,F.numSpotMaps=C,F.numLightProbes=D,n.version=bf++)}function c(l,u){let d=0,f=0,m=0,v=0,M=0;const p=u.matrixWorldInverse;for(let h=0,A=l.length;h<A;h++){const T=l[h];if(T.isDirectionalLight){const E=n.directional[d];E.direction.setFromMatrixPosition(T.matrixWorld),r.setFromMatrixPosition(T.target.matrixWorld),E.direction.sub(r),E.direction.transformDirection(p),d++}else if(T.isSpotLight){const E=n.spot[m];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(p),E.direction.setFromMatrixPosition(T.matrixWorld),r.setFromMatrixPosition(T.target.matrixWorld),E.direction.sub(r),E.direction.transformDirection(p),m++}else if(T.isRectAreaLight){const E=n.rectArea[v];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(p),a.identity(),s.copy(T.matrixWorld),s.premultiply(p),a.extractRotation(s),E.halfWidth.set(T.width*.5,0,0),E.halfHeight.set(0,T.height*.5,0),E.halfWidth.applyMatrix4(a),E.halfHeight.applyMatrix4(a),v++}else if(T.isPointLight){const E=n.point[f];E.position.setFromMatrixPosition(T.matrixWorld),E.position.applyMatrix4(p),f++}else if(T.isHemisphereLight){const E=n.hemi[M];E.direction.setFromMatrixPosition(T.matrixWorld),E.direction.transformDirection(p),M++}}}return{setup:o,setupView:c,state:n}}function Xa(i){const t=new Rf(i),e=[],n=[];function r(u){l.camera=u,e.length=0,n.length=0}function s(u){e.push(u)}function a(u){n.push(u)}function o(){t.setup(e)}function c(u){t.setupView(e,u)}const l={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:o,setupLightsView:c,pushLight:s,pushShadow:a}}function wf(i){let t=new WeakMap;function e(r,s=0){const a=t.get(r);let o;return a===void 0?(o=new Xa(i),t.set(r,[o])):s>=a.length?(o=new Xa(i),a.push(o)):o=a[s],o}function n(){t=new WeakMap}return{get:e,dispose:n}}const Cf=`void main() {
  3705. gl_Position = vec4( position, 1.0 );
  3706. }`,Pf=`uniform sampler2D shadow_pass;
  3707. uniform vec2 resolution;
  3708. uniform float radius;
  3709. #include <packing>
  3710. void main() {
  3711. const float samples = float( VSM_SAMPLES );
  3712. float mean = 0.0;
  3713. float squared_mean = 0.0;
  3714. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3715. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3716. for ( float i = 0.0; i < samples; i ++ ) {
  3717. float uvOffset = uvStart + i * uvStride;
  3718. #ifdef HORIZONTAL_PASS
  3719. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3720. mean += distribution.x;
  3721. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3722. #else
  3723. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3724. mean += depth;
  3725. squared_mean += depth * depth;
  3726. #endif
  3727. }
  3728. mean = mean / samples;
  3729. squared_mean = squared_mean / samples;
  3730. float std_dev = sqrt( squared_mean - mean * mean );
  3731. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3732. }`;function Df(i,t,e){let n=new zs;const r=new Lt,s=new Lt,a=new se,o=new tc({depthPacking:pl}),c=new ec,l={},u=e.maxTextureSize,d={[_n]:Te,[Te]:_n,[en]:en},f=new gn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Lt},radius:{value:4}},vertexShader:Cf,fragmentShader:Pf}),m=f.clone();m.defines.HORIZONTAL_PASS=1;const v=new vn;v.setAttribute("position",new We(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const M=new rn(v,f),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ka;let h=this.type;this.render=function(R,D,F){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||R.length===0)return;const S=i.getRenderTarget(),x=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),z=i.state;z.setBlending(pn),z.buffers.depth.getReversed()===!0?z.buffers.color.setClear(0,0,0,0):z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const G=h!==tn&&this.type===tn,X=h===tn&&this.type!==tn;for(let K=0,W=R.length;K<W;K++){const et=R[K],H=et.shadow;if(H===void 0){console.warn("THREE.WebGLShadowMap:",et,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;r.copy(H.mapSize);const st=H.getFrameExtents();if(r.multiply(st),s.copy(H.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/st.x),r.x=s.x*st.x,H.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/st.y),r.y=s.y*st.y,H.mapSize.y=s.y)),H.map===null||G===!0||X===!0){const Et=this.type!==tn?{minFilter:ze,magFilter:ze}:{};H.map!==null&&H.map.dispose(),H.map=new In(r.x,r.y,Et),H.map.texture.name=et.name+".shadowMap",H.camera.updateProjectionMatrix()}i.setRenderTarget(H.map),i.clear();const ct=H.getViewportCount();for(let Et=0;Et<ct;Et++){const Ot=H.getViewport(Et);a.set(s.x*Ot.x,s.y*Ot.y,s.x*Ot.z,s.y*Ot.w),z.viewport(a),H.updateMatrices(et,Et),n=H.getFrustum(),E(D,F,H.camera,et,this.type)}H.isPointLightShadow!==!0&&this.type===tn&&A(H,F),H.needsUpdate=!1}h=this.type,p.needsUpdate=!1,i.setRenderTarget(S,x,P)};function A(R,D){const F=t.update(M);f.defines.VSM_SAMPLES!==R.blurSamples&&(f.defines.VSM_SAMPLES=R.blurSamples,m.defines.VSM_SAMPLES=R.blurSamples,f.needsUpdate=!0,m.needsUpdate=!0),R.mapPass===null&&(R.mapPass=new In(r.x,r.y)),f.uniforms.shadow_pass.value=R.map.texture,f.uniforms.resolution.value=R.mapSize,f.uniforms.radius.value=R.radius,i.setRenderTarget(R.mapPass),i.clear(),i.renderBufferDirect(D,null,F,f,M,null),m.uniforms.shadow_pass.value=R.mapPass.texture,m.uniforms.resolution.value=R.mapSize,m.uniforms.radius.value=R.radius,i.setRenderTarget(R.map),i.clear(),i.renderBufferDirect(D,null,F,m,M,null)}function T(R,D,F,S){let x=null;const P=F.isPointLight===!0?R.customDistanceMaterial:R.customDepthMaterial;if(P!==void 0)x=P;else if(x=F.isPointLight===!0?c:o,i.localClippingEnabled&&D.clipShadows===!0&&Array.isArray(D.clippingPlanes)&&D.clippingPlanes.length!==0||D.displacementMap&&D.displacementScale!==0||D.alphaMap&&D.alphaTest>0||D.map&&D.alphaTest>0||D.alphaToCoverage===!0){const z=x.uuid,G=D.uuid;let X=l[z];X===void 0&&(X={},l[z]=X);let K=X[G];K===void 0&&(K=x.clone(),X[G]=K,D.addEventListener("dispose",C)),x=K}if(x.visible=D.visible,x.wireframe=D.wireframe,S===tn?x.side=D.shadowSide!==null?D.shadowSide:D.side:x.side=D.shadowSide!==null?D.shadowSide:d[D.side],x.alphaMap=D.alphaMap,x.alphaTest=D.alphaToCoverage===!0?.5:D.alphaTest,x.map=D.map,x.clipShadows=D.clipShadows,x.clippingPlanes=D.clippingPlanes,x.clipIntersection=D.clipIntersection,x.displacementMap=D.displacementMap,x.displacementScale=D.displacementScale,x.displacementBias=D.displacementBias,x.wireframeLinewidth=D.wireframeLinewidth,x.linewidth=D.linewidth,F.isPointLight===!0&&x.isMeshDistanceMaterial===!0){const z=i.properties.get(x);z.light=F}return x}function E(R,D,F,S,x){if(R.visible===!1)return;if(R.layers.test(D.layers)&&(R.isMesh||R.isLine||R.isPoints)&&(R.castShadow||R.receiveShadow&&x===tn)&&(!R.frustumCulled||n.intersectsObject(R))){R.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,R.matrixWorld);const G=t.update(R),X=R.material;if(Array.isArray(X)){const K=G.groups;for(let W=0,et=K.length;W<et;W++){const H=K[W],st=X[H.materialIndex];if(st&&st.visible){const ct=T(R,st,S,x);R.onBeforeShadow(i,R,D,F,G,ct,H),i.renderBufferDirect(F,null,G,ct,R,H),R.onAfterShadow(i,R,D,F,G,ct,H)}}}else if(X.visible){const K=T(R,X,S,x);R.onBeforeShadow(i,R,D,F,G,K,null),i.renderBufferDirect(F,null,G,K,R,null),R.onAfterShadow(i,R,D,F,G,K,null)}}const z=R.children;for(let G=0,X=z.length;G<X;G++)E(z[G],D,F,S,x)}function C(R){R.target.removeEventListener("dispose",C);for(const F in l){const S=l[F],x=R.target.uuid;x in S&&(S[x].dispose(),delete S[x])}}}const Lf={[Wr]:Xr,[Yr]:Zr,[qr]:jr,[ni]:Kr,[Xr]:Wr,[Zr]:Yr,[jr]:qr,[Kr]:ni};function Uf(i,t){function e(){let w=!1;const tt=new se;let it=null;const ut=new se(0,0,0,0);return{setMask:function($){it!==$&&!w&&(i.colorMask($,$,$,$),it=$)},setLocked:function($){w=$},setClear:function($,q,pt,Pt,$t){$t===!0&&($*=Pt,q*=Pt,pt*=Pt),tt.set($,q,pt,Pt),ut.equals(tt)===!1&&(i.clearColor($,q,pt,Pt),ut.copy(tt))},reset:function(){w=!1,it=null,ut.set(-1,0,0,0)}}}function n(){let w=!1,tt=!1,it=null,ut=null,$=null;return{setReversed:function(q){if(tt!==q){const pt=t.get("EXT_clip_control");q?pt.clipControlEXT(pt.LOWER_LEFT_EXT,pt.ZERO_TO_ONE_EXT):pt.clipControlEXT(pt.LOWER_LEFT_EXT,pt.NEGATIVE_ONE_TO_ONE_EXT),tt=q;const Pt=$;$=null,this.setClear(Pt)}},getReversed:function(){return tt},setTest:function(q){q?j(i.DEPTH_TEST):dt(i.DEPTH_TEST)},setMask:function(q){it!==q&&!w&&(i.depthMask(q),it=q)},setFunc:function(q){if(tt&&(q=Lf[q]),ut!==q){switch(q){case Wr:i.depthFunc(i.NEVER);break;case Xr:i.depthFunc(i.ALWAYS);break;case Yr:i.depthFunc(i.LESS);break;case ni:i.depthFunc(i.LEQUAL);break;case qr:i.depthFunc(i.EQUAL);break;case Kr:i.depthFunc(i.GEQUAL);break;case Zr:i.depthFunc(i.GREATER);break;case jr:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ut=q}},setLocked:function(q){w=q},setClear:function(q){$!==q&&(tt&&(q=1-q),i.clearDepth(q),$=q)},reset:function(){w=!1,it=null,ut=null,$=null,tt=!1}}}function r(){let w=!1,tt=null,it=null,ut=null,$=null,q=null,pt=null,Pt=null,$t=null;return{setTest:function(Xt){w||(Xt?j(i.STENCIL_TEST):dt(i.STENCIL_TEST))},setMask:function(Xt){tt!==Xt&&!w&&(i.stencilMask(Xt),tt=Xt)},setFunc:function(Xt,Ke,He){(it!==Xt||ut!==Ke||$!==He)&&(i.stencilFunc(Xt,Ke,He),it=Xt,ut=Ke,$=He)},setOp:function(Xt,Ke,He){(q!==Xt||pt!==Ke||Pt!==He)&&(i.stencilOp(Xt,Ke,He),q=Xt,pt=Ke,Pt=He)},setLocked:function(Xt){w=Xt},setClear:function(Xt){$t!==Xt&&(i.clearStencil(Xt),$t=Xt)},reset:function(){w=!1,tt=null,it=null,ut=null,$=null,q=null,pt=null,Pt=null,$t=null}}}const s=new e,a=new n,o=new r,c=new WeakMap,l=new WeakMap;let u={},d={},f=new WeakMap,m=[],v=null,M=!1,p=null,h=null,A=null,T=null,E=null,C=null,R=null,D=new kt(0,0,0),F=0,S=!1,x=null,P=null,z=null,G=null,X=null;const K=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,et=0;const H=i.getParameter(i.VERSION);H.indexOf("WebGL")!==-1?(et=parseFloat(/^WebGL (\d)/.exec(H)[1]),W=et>=1):H.indexOf("OpenGL ES")!==-1&&(et=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),W=et>=2);let st=null,ct={};const Et=i.getParameter(i.SCISSOR_BOX),Ot=i.getParameter(i.VIEWPORT),jt=new se().fromArray(Et),Qt=new se().fromArray(Ot);function Wt(w,tt,it,ut){const $=new Uint8Array(4),q=i.createTexture();i.bindTexture(w,q),i.texParameteri(w,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(w,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let pt=0;pt<it;pt++)w===i.TEXTURE_3D||w===i.TEXTURE_2D_ARRAY?i.texImage3D(tt,0,i.RGBA,1,1,ut,0,i.RGBA,i.UNSIGNED_BYTE,$):i.texImage2D(tt+pt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,$);return q}const Y={};Y[i.TEXTURE_2D]=Wt(i.TEXTURE_2D,i.TEXTURE_2D,1),Y[i.TEXTURE_CUBE_MAP]=Wt(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Y[i.TEXTURE_2D_ARRAY]=Wt(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Y[i.TEXTURE_3D]=Wt(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),j(i.DEPTH_TEST),a.setFunc(ni),Rt(!1),mt(Ks),j(i.CULL_FACE),te(pn);function j(w){u[w]!==!0&&(i.enable(w),u[w]=!0)}function dt(w){u[w]!==!1&&(i.disable(w),u[w]=!1)}function Ct(w,tt){return d[w]!==tt?(i.bindFramebuffer(w,tt),d[w]=tt,w===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=tt),w===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=tt),!0):!1}function St(w,tt){let it=m,ut=!1;if(w){it=f.get(tt),it===void 0&&(it=[],f.set(tt,it));const $=w.textures;if(it.length!==$.length||it[0]!==i.COLOR_ATTACHMENT0){for(let q=0,pt=$.length;q<pt;q++)it[q]=i.COLOR_ATTACHMENT0+q;it.length=$.length,ut=!0}}else it[0]!==i.BACK&&(it[0]=i.BACK,ut=!0);ut&&i.drawBuffers(it)}function Ht(w){return v!==w?(i.useProgram(w),v=w,!0):!1}const pe={[wn]:i.FUNC_ADD,[Ho]:i.FUNC_SUBTRACT,[Vo]:i.FUNC_REVERSE_SUBTRACT};pe[Go]=i.MIN,pe[ko]=i.MAX;const b={[Wo]:i.ZERO,[Xo]:i.ONE,[Yo]:i.SRC_COLOR,[Gr]:i.SRC_ALPHA,[Jo]:i.SRC_ALPHA_SATURATE,[jo]:i.DST_COLOR,[Ko]:i.DST_ALPHA,[qo]:i.ONE_MINUS_SRC_COLOR,[kr]:i.ONE_MINUS_SRC_ALPHA,[$o]:i.ONE_MINUS_DST_COLOR,[Zo]:i.ONE_MINUS_DST_ALPHA,[Qo]:i.CONSTANT_COLOR,[tl]:i.ONE_MINUS_CONSTANT_COLOR,[el]:i.CONSTANT_ALPHA,[nl]:i.ONE_MINUS_CONSTANT_ALPHA};function te(w,tt,it,ut,$,q,pt,Pt,$t,Xt){if(w===pn){M===!0&&(dt(i.BLEND),M=!1);return}if(M===!1&&(j(i.BLEND),M=!0),w!==zo){if(w!==p||Xt!==S){if((h!==wn||E!==wn)&&(i.blendEquation(i.FUNC_ADD),h=wn,E=wn),Xt)switch(w){case ti:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Zs:i.blendFunc(i.ONE,i.ONE);break;case js:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case $s:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",w);break}else switch(w){case ti:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Zs:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case js:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case $s:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",w);break}A=null,T=null,C=null,R=null,D.set(0,0,0),F=0,p=w,S=Xt}return}$=$||tt,q=q||it,pt=pt||ut,(tt!==h||$!==E)&&(i.blendEquationSeparate(pe[tt],pe[$]),h=tt,E=$),(it!==A||ut!==T||q!==C||pt!==R)&&(i.blendFuncSeparate(b[it],b[ut],b[q],b[pt]),A=it,T=ut,C=q,R=pt),(Pt.equals(D)===!1||$t!==F)&&(i.blendColor(Pt.r,Pt.g,Pt.b,$t),D.copy(Pt),F=$t),p=w,S=!1}function Dt(w,tt){w.side===en?dt(i.CULL_FACE):j(i.CULL_FACE);let it=w.side===Te;tt&&(it=!it),Rt(it),w.blending===ti&&w.transparent===!1?te(pn):te(w.blending,w.blendEquation,w.blendSrc,w.blendDst,w.blendEquationAlpha,w.blendSrcAlpha,w.blendDstAlpha,w.blendColor,w.blendAlpha,w.premultipliedAlpha),a.setFunc(w.depthFunc),a.setTest(w.depthTest),a.setMask(w.depthWrite),s.setMask(w.colorWrite);const ut=w.stencilWrite;o.setTest(ut),ut&&(o.setMask(w.stencilWriteMask),o.setFunc(w.stencilFunc,w.stencilRef,w.stencilFuncMask),o.setOp(w.stencilFail,w.stencilZFail,w.stencilZPass)),_t(w.polygonOffset,w.polygonOffsetFactor,w.polygonOffsetUnits),w.alphaToCoverage===!0?j(i.SAMPLE_ALPHA_TO_COVERAGE):dt(i.SAMPLE_ALPHA_TO_COVERAGE)}function Rt(w){x!==w&&(w?i.frontFace(i.CW):i.frontFace(i.CCW),x=w)}function mt(w){w!==Fo?(j(i.CULL_FACE),w!==P&&(w===Ks?i.cullFace(i.BACK):w===Oo?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):dt(i.CULL_FACE),P=w}function ee(w){w!==z&&(W&&i.lineWidth(w),z=w)}function _t(w,tt,it){w?(j(i.POLYGON_OFFSET_FILL),(G!==tt||X!==it)&&(i.polygonOffset(tt,it),G=tt,X=it)):dt(i.POLYGON_OFFSET_FILL)}function Nt(w){w?j(i.SCISSOR_TEST):dt(i.SCISSOR_TEST)}function de(w){w===void 0&&(w=i.TEXTURE0+K-1),st!==w&&(i.activeTexture(w),st=w)}function ae(w,tt,it){it===void 0&&(st===null?it=i.TEXTURE0+K-1:it=st);let ut=ct[it];ut===void 0&&(ut={type:void 0,texture:void 0},ct[it]=ut),(ut.type!==w||ut.texture!==tt)&&(st!==it&&(i.activeTexture(it),st=it),i.bindTexture(w,tt||Y[w]),ut.type=w,ut.texture=tt)}function y(){const w=ct[st];w!==void 0&&w.type!==void 0&&(i.bindTexture(w.type,null),w.type=void 0,w.texture=void 0)}function _(){try{i.compressedTexImage2D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function I(){try{i.compressedTexImage3D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function k(){try{i.texSubImage2D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function Z(){try{i.texSubImage3D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function V(){try{i.compressedTexSubImage2D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function Mt(){try{i.compressedTexSubImage3D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function nt(){try{i.texStorage2D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function gt(){try{i.texStorage3D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function vt(){try{i.texImage2D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function Q(){try{i.texImage3D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function lt(w){jt.equals(w)===!1&&(i.scissor(w.x,w.y,w.z,w.w),jt.copy(w))}function At(w){Qt.equals(w)===!1&&(i.viewport(w.x,w.y,w.z,w.w),Qt.copy(w))}function xt(w,tt){let it=l.get(tt);it===void 0&&(it=new WeakMap,l.set(tt,it));let ut=it.get(w);ut===void 0&&(ut=i.getUniformBlockIndex(tt,w.name),it.set(w,ut))}function at(w,tt){const ut=l.get(tt).get(w);c.get(tt)!==ut&&(i.uniformBlockBinding(tt,ut,w.__bindingPointIndex),c.set(tt,ut))}function Ut(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),u={},st=null,ct={},d={},f=new WeakMap,m=[],v=null,M=!1,p=null,h=null,A=null,T=null,E=null,C=null,R=null,D=new kt(0,0,0),F=0,S=!1,x=null,P=null,z=null,G=null,X=null,jt.set(0,0,i.canvas.width,i.canvas.height),Qt.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:j,disable:dt,bindFramebuffer:Ct,drawBuffers:St,useProgram:Ht,setBlending:te,setMaterial:Dt,setFlipSided:Rt,setCullFace:mt,setLineWidth:ee,setPolygonOffset:_t,setScissorTest:Nt,activeTexture:de,bindTexture:ae,unbindTexture:y,compressedTexImage2D:_,compressedTexImage3D:I,texImage2D:vt,texImage3D:Q,updateUBOMapping:xt,uniformBlockBinding:at,texStorage2D:nt,texStorage3D:gt,texSubImage2D:k,texSubImage3D:Z,compressedTexSubImage2D:V,compressedTexSubImage3D:Mt,scissor:lt,viewport:At,reset:Ut}}function If(i,t,e,n,r,s,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Lt,u=new WeakMap;let d;const f=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(y,_){return m?new OffscreenCanvas(y,_):rr("canvas")}function M(y,_,I){let k=1;const Z=ae(y);if((Z.width>I||Z.height>I)&&(k=I/Math.max(Z.width,Z.height)),k<1)if(typeof HTMLImageElement<"u"&&y instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&y instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&y instanceof ImageBitmap||typeof VideoFrame<"u"&&y instanceof VideoFrame){const V=Math.floor(k*Z.width),Mt=Math.floor(k*Z.height);d===void 0&&(d=v(V,Mt));const nt=_?v(V,Mt):d;return nt.width=V,nt.height=Mt,nt.getContext("2d").drawImage(y,0,0,V,Mt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Z.width+"x"+Z.height+") to ("+V+"x"+Mt+")."),nt}else return"data"in y&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Z.width+"x"+Z.height+")."),y;return y}function p(y){return y.generateMipmaps}function h(y){i.generateMipmap(y)}function A(y){return y.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:y.isWebGL3DRenderTarget?i.TEXTURE_3D:y.isWebGLArrayRenderTarget||y.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function T(y,_,I,k,Z=!1){if(y!==null){if(i[y]!==void 0)return i[y];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+y+"'")}let V=_;if(_===i.RED&&(I===i.FLOAT&&(V=i.R32F),I===i.HALF_FLOAT&&(V=i.R16F),I===i.UNSIGNED_BYTE&&(V=i.R8)),_===i.RED_INTEGER&&(I===i.UNSIGNED_BYTE&&(V=i.R8UI),I===i.UNSIGNED_SHORT&&(V=i.R16UI),I===i.UNSIGNED_INT&&(V=i.R32UI),I===i.BYTE&&(V=i.R8I),I===i.SHORT&&(V=i.R16I),I===i.INT&&(V=i.R32I)),_===i.RG&&(I===i.FLOAT&&(V=i.RG32F),I===i.HALF_FLOAT&&(V=i.RG16F),I===i.UNSIGNED_BYTE&&(V=i.RG8)),_===i.RG_INTEGER&&(I===i.UNSIGNED_BYTE&&(V=i.RG8UI),I===i.UNSIGNED_SHORT&&(V=i.RG16UI),I===i.UNSIGNED_INT&&(V=i.RG32UI),I===i.BYTE&&(V=i.RG8I),I===i.SHORT&&(V=i.RG16I),I===i.INT&&(V=i.RG32I)),_===i.RGB_INTEGER&&(I===i.UNSIGNED_BYTE&&(V=i.RGB8UI),I===i.UNSIGNED_SHORT&&(V=i.RGB16UI),I===i.UNSIGNED_INT&&(V=i.RGB32UI),I===i.BYTE&&(V=i.RGB8I),I===i.SHORT&&(V=i.RGB16I),I===i.INT&&(V=i.RGB32I)),_===i.RGBA_INTEGER&&(I===i.UNSIGNED_BYTE&&(V=i.RGBA8UI),I===i.UNSIGNED_SHORT&&(V=i.RGBA16UI),I===i.UNSIGNED_INT&&(V=i.RGBA32UI),I===i.BYTE&&(V=i.RGBA8I),I===i.SHORT&&(V=i.RGBA16I),I===i.INT&&(V=i.RGBA32I)),_===i.RGB&&(I===i.UNSIGNED_INT_5_9_9_9_REV&&(V=i.RGB9_E5),I===i.UNSIGNED_INT_10F_11F_11F_REV&&(V=i.R11F_G11F_B10F)),_===i.RGBA){const Mt=Z?nr:Gt.getTransfer(k);I===i.FLOAT&&(V=i.RGBA32F),I===i.HALF_FLOAT&&(V=i.RGBA16F),I===i.UNSIGNED_BYTE&&(V=Mt===qt?i.SRGB8_ALPHA8:i.RGBA8),I===i.UNSIGNED_SHORT_4_4_4_4&&(V=i.RGBA4),I===i.UNSIGNED_SHORT_5_5_5_1&&(V=i.RGB5_A1)}return(V===i.R16F||V===i.R32F||V===i.RG16F||V===i.RG32F||V===i.RGBA16F||V===i.RGBA32F)&&t.get("EXT_color_buffer_float"),V}function E(y,_){let I;return y?_===null||_===Ln||_===_i?I=i.DEPTH24_STENCIL8:_===nn?I=i.DEPTH32F_STENCIL8:_===mi&&(I=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Ln||_===_i?I=i.DEPTH_COMPONENT24:_===nn?I=i.DEPTH_COMPONENT32F:_===mi&&(I=i.DEPTH_COMPONENT16),I}function C(y,_){return p(y)===!0||y.isFramebufferTexture&&y.minFilter!==ze&&y.minFilter!==Ge?Math.log2(Math.max(_.width,_.height))+1:y.mipmaps!==void 0&&y.mipmaps.length>0?y.mipmaps.length:y.isCompressedTexture&&Array.isArray(y.image)?_.mipmaps.length:1}function R(y){const _=y.target;_.removeEventListener("dispose",R),F(_),_.isVideoTexture&&u.delete(_)}function D(y){const _=y.target;_.removeEventListener("dispose",D),x(_)}function F(y){const _=n.get(y);if(_.__webglInit===void 0)return;const I=y.source,k=f.get(I);if(k){const Z=k[_.__cacheKey];Z.usedTimes--,Z.usedTimes===0&&S(y),Object.keys(k).length===0&&f.delete(I)}n.remove(y)}function S(y){const _=n.get(y);i.deleteTexture(_.__webglTexture);const I=y.source,k=f.get(I);delete k[_.__cacheKey],a.memory.textures--}function x(y){const _=n.get(y);if(y.depthTexture&&(y.depthTexture.dispose(),n.remove(y.depthTexture)),y.isWebGLCubeRenderTarget)for(let k=0;k<6;k++){if(Array.isArray(_.__webglFramebuffer[k]))for(let Z=0;Z<_.__webglFramebuffer[k].length;Z++)i.deleteFramebuffer(_.__webglFramebuffer[k][Z]);else i.deleteFramebuffer(_.__webglFramebuffer[k]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[k])}else{if(Array.isArray(_.__webglFramebuffer))for(let k=0;k<_.__webglFramebuffer.length;k++)i.deleteFramebuffer(_.__webglFramebuffer[k]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let k=0;k<_.__webglColorRenderbuffer.length;k++)_.__webglColorRenderbuffer[k]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[k]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const I=y.textures;for(let k=0,Z=I.length;k<Z;k++){const V=n.get(I[k]);V.__webglTexture&&(i.deleteTexture(V.__webglTexture),a.memory.textures--),n.remove(I[k])}n.remove(y)}let P=0;function z(){P=0}function G(){const y=P;return y>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+y+" texture units while this GPU supports only "+r.maxTextures),P+=1,y}function X(y){const _=[];return _.push(y.wrapS),_.push(y.wrapT),_.push(y.wrapR||0),_.push(y.magFilter),_.push(y.minFilter),_.push(y.anisotropy),_.push(y.internalFormat),_.push(y.format),_.push(y.type),_.push(y.generateMipmaps),_.push(y.premultiplyAlpha),_.push(y.flipY),_.push(y.unpackAlignment),_.push(y.colorSpace),_.join()}function K(y,_){const I=n.get(y);if(y.isVideoTexture&&Nt(y),y.isRenderTargetTexture===!1&&y.isExternalTexture!==!0&&y.version>0&&I.__version!==y.version){const k=y.image;if(k===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(k.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Y(I,y,_);return}}else y.isExternalTexture&&(I.__webglTexture=y.sourceTexture?y.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,I.__webglTexture,i.TEXTURE0+_)}function W(y,_){const I=n.get(y);if(y.isRenderTargetTexture===!1&&y.version>0&&I.__version!==y.version){Y(I,y,_);return}e.bindTexture(i.TEXTURE_2D_ARRAY,I.__webglTexture,i.TEXTURE0+_)}function et(y,_){const I=n.get(y);if(y.isRenderTargetTexture===!1&&y.version>0&&I.__version!==y.version){Y(I,y,_);return}e.bindTexture(i.TEXTURE_3D,I.__webglTexture,i.TEXTURE0+_)}function H(y,_){const I=n.get(y);if(y.version>0&&I.__version!==y.version){j(I,y,_);return}e.bindTexture(i.TEXTURE_CUBE_MAP,I.__webglTexture,i.TEXTURE0+_)}const st={[Qr]:i.REPEAT,[Pn]:i.CLAMP_TO_EDGE,[ts]:i.MIRRORED_REPEAT},ct={[ze]:i.NEAREST,[dl]:i.NEAREST_MIPMAP_NEAREST,[Ri]:i.NEAREST_MIPMAP_LINEAR,[Ge]:i.LINEAR,[hr]:i.LINEAR_MIPMAP_NEAREST,[Dn]:i.LINEAR_MIPMAP_LINEAR},Et={[_l]:i.NEVER,[El]:i.ALWAYS,[gl]:i.LESS,[ao]:i.LEQUAL,[vl]:i.EQUAL,[Sl]:i.GEQUAL,[xl]:i.GREATER,[Ml]:i.NOTEQUAL};function Ot(y,_){if(_.type===nn&&t.has("OES_texture_float_linear")===!1&&(_.magFilter===Ge||_.magFilter===hr||_.magFilter===Ri||_.magFilter===Dn||_.minFilter===Ge||_.minFilter===hr||_.minFilter===Ri||_.minFilter===Dn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(y,i.TEXTURE_WRAP_S,st[_.wrapS]),i.texParameteri(y,i.TEXTURE_WRAP_T,st[_.wrapT]),(y===i.TEXTURE_3D||y===i.TEXTURE_2D_ARRAY)&&i.texParameteri(y,i.TEXTURE_WRAP_R,st[_.wrapR]),i.texParameteri(y,i.TEXTURE_MAG_FILTER,ct[_.magFilter]),i.texParameteri(y,i.TEXTURE_MIN_FILTER,ct[_.minFilter]),_.compareFunction&&(i.texParameteri(y,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(y,i.TEXTURE_COMPARE_FUNC,Et[_.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===ze||_.minFilter!==Ri&&_.minFilter!==Dn||_.type===nn&&t.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){const I=t.get("EXT_texture_filter_anisotropic");i.texParameterf(y,I.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,r.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function jt(y,_){let I=!1;y.__webglInit===void 0&&(y.__webglInit=!0,_.addEventListener("dispose",R));const k=_.source;let Z=f.get(k);Z===void 0&&(Z={},f.set(k,Z));const V=X(_);if(V!==y.__cacheKey){Z[V]===void 0&&(Z[V]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,I=!0),Z[V].usedTimes++;const Mt=Z[y.__cacheKey];Mt!==void 0&&(Z[y.__cacheKey].usedTimes--,Mt.usedTimes===0&&S(_)),y.__cacheKey=V,y.__webglTexture=Z[V].texture}return I}function Qt(y,_,I){return Math.floor(Math.floor(y/I)/_)}function Wt(y,_,I,k){const V=y.updateRanges;if(V.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,_.width,_.height,I,k,_.data);else{V.sort((Q,lt)=>Q.start-lt.start);let Mt=0;for(let Q=1;Q<V.length;Q++){const lt=V[Mt],At=V[Q],xt=lt.start+lt.count,at=Qt(At.start,_.width,4),Ut=Qt(lt.start,_.width,4);At.start<=xt+1&&at===Ut&&Qt(At.start+At.count-1,_.width,4)===at?lt.count=Math.max(lt.count,At.start+At.count-lt.start):(++Mt,V[Mt]=At)}V.length=Mt+1;const nt=i.getParameter(i.UNPACK_ROW_LENGTH),gt=i.getParameter(i.UNPACK_SKIP_PIXELS),vt=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,_.width);for(let Q=0,lt=V.length;Q<lt;Q++){const At=V[Q],xt=Math.floor(At.start/4),at=Math.ceil(At.count/4),Ut=xt%_.width,w=Math.floor(xt/_.width),tt=at,it=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,Ut),i.pixelStorei(i.UNPACK_SKIP_ROWS,w),e.texSubImage2D(i.TEXTURE_2D,0,Ut,w,tt,it,I,k,_.data)}y.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,nt),i.pixelStorei(i.UNPACK_SKIP_PIXELS,gt),i.pixelStorei(i.UNPACK_SKIP_ROWS,vt)}}function Y(y,_,I){let k=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(k=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(k=i.TEXTURE_3D);const Z=jt(y,_),V=_.source;e.bindTexture(k,y.__webglTexture,i.TEXTURE0+I);const Mt=n.get(V);if(V.version!==Mt.__version||Z===!0){e.activeTexture(i.TEXTURE0+I);const nt=Gt.getPrimaries(Gt.workingColorSpace),gt=_.colorSpace===fn?null:Gt.getPrimaries(_.colorSpace),vt=_.colorSpace===fn||nt===gt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,vt);let Q=M(_.image,!1,r.maxTextureSize);Q=de(_,Q);const lt=s.convert(_.format,_.colorSpace),At=s.convert(_.type);let xt=T(_.internalFormat,lt,At,_.colorSpace,_.isVideoTexture);Ot(k,_);let at;const Ut=_.mipmaps,w=_.isVideoTexture!==!0,tt=Mt.__version===void 0||Z===!0,it=V.dataReady,ut=C(_,Q);if(_.isDepthTexture)xt=E(_.format===vi,_.type),tt&&(w?e.texStorage2D(i.TEXTURE_2D,1,xt,Q.width,Q.height):e.texImage2D(i.TEXTURE_2D,0,xt,Q.width,Q.height,0,lt,At,null));else if(_.isDataTexture)if(Ut.length>0){w&&tt&&e.texStorage2D(i.TEXTURE_2D,ut,xt,Ut[0].width,Ut[0].height);for(let $=0,q=Ut.length;$<q;$++)at=Ut[$],w?it&&e.texSubImage2D(i.TEXTURE_2D,$,0,0,at.width,at.height,lt,At,at.data):e.texImage2D(i.TEXTURE_2D,$,xt,at.width,at.height,0,lt,At,at.data);_.generateMipmaps=!1}else w?(tt&&e.texStorage2D(i.TEXTURE_2D,ut,xt,Q.width,Q.height),it&&Wt(_,Q,lt,At)):e.texImage2D(i.TEXTURE_2D,0,xt,Q.width,Q.height,0,lt,At,Q.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){w&&tt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,ut,xt,Ut[0].width,Ut[0].height,Q.depth);for(let $=0,q=Ut.length;$<q;$++)if(at=Ut[$],_.format!==Be)if(lt!==null)if(w){if(it)if(_.layerUpdates.size>0){const pt=Sa(at.width,at.height,_.format,_.type);for(const Pt of _.layerUpdates){const $t=at.data.subarray(Pt*pt/at.data.BYTES_PER_ELEMENT,(Pt+1)*pt/at.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,Pt,at.width,at.height,1,lt,$t)}_.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,at.width,at.height,Q.depth,lt,at.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,$,xt,at.width,at.height,Q.depth,0,at.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else w?it&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,at.width,at.height,Q.depth,lt,At,at.data):e.texImage3D(i.TEXTURE_2D_ARRAY,$,xt,at.width,at.height,Q.depth,0,lt,At,at.data)}else{w&&tt&&e.texStorage2D(i.TEXTURE_2D,ut,xt,Ut[0].width,Ut[0].height);for(let $=0,q=Ut.length;$<q;$++)at=Ut[$],_.format!==Be?lt!==null?w?it&&e.compressedTexSubImage2D(i.TEXTURE_2D,$,0,0,at.width,at.height,lt,at.data):e.compressedTexImage2D(i.TEXTURE_2D,$,xt,at.width,at.height,0,at.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):w?it&&e.texSubImage2D(i.TEXTURE_2D,$,0,0,at.width,at.height,lt,At,at.data):e.texImage2D(i.TEXTURE_2D,$,xt,at.width,at.height,0,lt,At,at.data)}else if(_.isDataArrayTexture)if(w){if(tt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,ut,xt,Q.width,Q.height,Q.depth),it)if(_.layerUpdates.size>0){const $=Sa(Q.width,Q.height,_.format,_.type);for(const q of _.layerUpdates){const pt=Q.data.subarray(q*$/Q.data.BYTES_PER_ELEMENT,(q+1)*$/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,q,Q.width,Q.height,1,lt,At,pt)}_.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,lt,At,Q.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,xt,Q.width,Q.height,Q.depth,0,lt,At,Q.data);else if(_.isData3DTexture)w?(tt&&e.texStorage3D(i.TEXTURE_3D,ut,xt,Q.width,Q.height,Q.depth),it&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,lt,At,Q.data)):e.texImage3D(i.TEXTURE_3D,0,xt,Q.width,Q.height,Q.depth,0,lt,At,Q.data);else if(_.isFramebufferTexture){if(tt)if(w)e.texStorage2D(i.TEXTURE_2D,ut,xt,Q.width,Q.height);else{let $=Q.width,q=Q.height;for(let pt=0;pt<ut;pt++)e.texImage2D(i.TEXTURE_2D,pt,xt,$,q,0,lt,At,null),$>>=1,q>>=1}}else if(Ut.length>0){if(w&&tt){const $=ae(Ut[0]);e.texStorage2D(i.TEXTURE_2D,ut,xt,$.width,$.height)}for(let $=0,q=Ut.length;$<q;$++)at=Ut[$],w?it&&e.texSubImage2D(i.TEXTURE_2D,$,0,0,lt,At,at):e.texImage2D(i.TEXTURE_2D,$,xt,lt,At,at);_.generateMipmaps=!1}else if(w){if(tt){const $=ae(Q);e.texStorage2D(i.TEXTURE_2D,ut,xt,$.width,$.height)}it&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,lt,At,Q)}else e.texImage2D(i.TEXTURE_2D,0,xt,lt,At,Q);p(_)&&h(k),Mt.__version=V.version,_.onUpdate&&_.onUpdate(_)}y.__version=_.version}function j(y,_,I){if(_.image.length!==6)return;const k=jt(y,_),Z=_.source;e.bindTexture(i.TEXTURE_CUBE_MAP,y.__webglTexture,i.TEXTURE0+I);const V=n.get(Z);if(Z.version!==V.__version||k===!0){e.activeTexture(i.TEXTURE0+I);const Mt=Gt.getPrimaries(Gt.workingColorSpace),nt=_.colorSpace===fn?null:Gt.getPrimaries(_.colorSpace),gt=_.colorSpace===fn||Mt===nt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,gt);const vt=_.isCompressedTexture||_.image[0].isCompressedTexture,Q=_.image[0]&&_.image[0].isDataTexture,lt=[];for(let q=0;q<6;q++)!vt&&!Q?lt[q]=M(_.image[q],!0,r.maxCubemapSize):lt[q]=Q?_.image[q].image:_.image[q],lt[q]=de(_,lt[q]);const At=lt[0],xt=s.convert(_.format,_.colorSpace),at=s.convert(_.type),Ut=T(_.internalFormat,xt,at,_.colorSpace),w=_.isVideoTexture!==!0,tt=V.__version===void 0||k===!0,it=Z.dataReady;let ut=C(_,At);Ot(i.TEXTURE_CUBE_MAP,_);let $;if(vt){w&&tt&&e.texStorage2D(i.TEXTURE_CUBE_MAP,ut,Ut,At.width,At.height);for(let q=0;q<6;q++){$=lt[q].mipmaps;for(let pt=0;pt<$.length;pt++){const Pt=$[pt];_.format!==Be?xt!==null?w?it&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,pt,0,0,Pt.width,Pt.height,xt,Pt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,pt,Ut,Pt.width,Pt.height,0,Pt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):w?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,pt,0,0,Pt.width,Pt.height,xt,at,Pt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,pt,Ut,Pt.width,Pt.height,0,xt,at,Pt.data)}}}else{if($=_.mipmaps,w&&tt){$.length>0&&ut++;const q=ae(lt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,ut,Ut,q.width,q.height)}for(let q=0;q<6;q++)if(Q){w?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,lt[q].width,lt[q].height,xt,at,lt[q].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,Ut,lt[q].width,lt[q].height,0,xt,at,lt[q].data);for(let pt=0;pt<$.length;pt++){const $t=$[pt].image[q].image;w?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,pt+1,0,0,$t.width,$t.height,xt,at,$t.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,pt+1,Ut,$t.width,$t.height,0,xt,at,$t.data)}}else{w?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,xt,at,lt[q]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,Ut,xt,at,lt[q]);for(let pt=0;pt<$.length;pt++){const Pt=$[pt];w?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,pt+1,0,0,xt,at,Pt.image[q]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,pt+1,Ut,xt,at,Pt.image[q])}}}p(_)&&h(i.TEXTURE_CUBE_MAP),V.__version=Z.version,_.onUpdate&&_.onUpdate(_)}y.__version=_.version}function dt(y,_,I,k,Z,V){const Mt=s.convert(I.format,I.colorSpace),nt=s.convert(I.type),gt=T(I.internalFormat,Mt,nt,I.colorSpace),vt=n.get(_),Q=n.get(I);if(Q.__renderTarget=_,!vt.__hasExternalTextures){const lt=Math.max(1,_.width>>V),At=Math.max(1,_.height>>V);Z===i.TEXTURE_3D||Z===i.TEXTURE_2D_ARRAY?e.texImage3D(Z,V,gt,lt,At,_.depth,0,Mt,nt,null):e.texImage2D(Z,V,gt,lt,At,0,Mt,nt,null)}e.bindFramebuffer(i.FRAMEBUFFER,y),_t(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,k,Z,Q.__webglTexture,0,ee(_)):(Z===i.TEXTURE_2D||Z>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Z<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,k,Z,Q.__webglTexture,V),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Ct(y,_,I){if(i.bindRenderbuffer(i.RENDERBUFFER,y),_.depthBuffer){const k=_.depthTexture,Z=k&&k.isDepthTexture?k.type:null,V=E(_.stencilBuffer,Z),Mt=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,nt=ee(_);_t(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,nt,V,_.width,_.height):I?i.renderbufferStorageMultisample(i.RENDERBUFFER,nt,V,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,V,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Mt,i.RENDERBUFFER,y)}else{const k=_.textures;for(let Z=0;Z<k.length;Z++){const V=k[Z],Mt=s.convert(V.format,V.colorSpace),nt=s.convert(V.type),gt=T(V.internalFormat,Mt,nt,V.colorSpace),vt=ee(_);I&&_t(_)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,vt,gt,_.width,_.height):_t(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,vt,gt,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,gt,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function St(y,_){if(_&&_.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,y),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const k=n.get(_.depthTexture);k.__renderTarget=_,(!k.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),K(_.depthTexture,0);const Z=k.__webglTexture,V=ee(_);if(_.depthTexture.format===gi)_t(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Z,0,V):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Z,0);else if(_.depthTexture.format===vi)_t(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Z,0,V):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Z,0);else throw new Error("Unknown depthTexture format")}function Ht(y){const _=n.get(y),I=y.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==y.depthTexture){const k=y.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),k){const Z=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,k.removeEventListener("dispose",Z)};k.addEventListener("dispose",Z),_.__depthDisposeCallback=Z}_.__boundDepthTexture=k}if(y.depthTexture&&!_.__autoAllocateDepthBuffer){if(I)throw new Error("target.depthTexture not supported in Cube render targets");const k=y.texture.mipmaps;k&&k.length>0?St(_.__webglFramebuffer[0],y):St(_.__webglFramebuffer,y)}else if(I){_.__webglDepthbuffer=[];for(let k=0;k<6;k++)if(e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[k]),_.__webglDepthbuffer[k]===void 0)_.__webglDepthbuffer[k]=i.createRenderbuffer(),Ct(_.__webglDepthbuffer[k],y,!1);else{const Z=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,V=_.__webglDepthbuffer[k];i.bindRenderbuffer(i.RENDERBUFFER,V),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,V)}}else{const k=y.texture.mipmaps;if(k&&k.length>0?e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),Ct(_.__webglDepthbuffer,y,!1);else{const Z=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,V=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,V),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,V)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function pe(y,_,I){const k=n.get(y);_!==void 0&&dt(k.__webglFramebuffer,y,y.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),I!==void 0&&Ht(y)}function b(y){const _=y.texture,I=n.get(y),k=n.get(_);y.addEventListener("dispose",D);const Z=y.textures,V=y.isWebGLCubeRenderTarget===!0,Mt=Z.length>1;if(Mt||(k.__webglTexture===void 0&&(k.__webglTexture=i.createTexture()),k.__version=_.version,a.memory.textures++),V){I.__webglFramebuffer=[];for(let nt=0;nt<6;nt++)if(_.mipmaps&&_.mipmaps.length>0){I.__webglFramebuffer[nt]=[];for(let gt=0;gt<_.mipmaps.length;gt++)I.__webglFramebuffer[nt][gt]=i.createFramebuffer()}else I.__webglFramebuffer[nt]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){I.__webglFramebuffer=[];for(let nt=0;nt<_.mipmaps.length;nt++)I.__webglFramebuffer[nt]=i.createFramebuffer()}else I.__webglFramebuffer=i.createFramebuffer();if(Mt)for(let nt=0,gt=Z.length;nt<gt;nt++){const vt=n.get(Z[nt]);vt.__webglTexture===void 0&&(vt.__webglTexture=i.createTexture(),a.memory.textures++)}if(y.samples>0&&_t(y)===!1){I.__webglMultisampledFramebuffer=i.createFramebuffer(),I.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,I.__webglMultisampledFramebuffer);for(let nt=0;nt<Z.length;nt++){const gt=Z[nt];I.__webglColorRenderbuffer[nt]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,I.__webglColorRenderbuffer[nt]);const vt=s.convert(gt.format,gt.colorSpace),Q=s.convert(gt.type),lt=T(gt.internalFormat,vt,Q,gt.colorSpace,y.isXRRenderTarget===!0),At=ee(y);i.renderbufferStorageMultisample(i.RENDERBUFFER,At,lt,y.width,y.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+nt,i.RENDERBUFFER,I.__webglColorRenderbuffer[nt])}i.bindRenderbuffer(i.RENDERBUFFER,null),y.depthBuffer&&(I.__webglDepthRenderbuffer=i.createRenderbuffer(),Ct(I.__webglDepthRenderbuffer,y,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(V){e.bindTexture(i.TEXTURE_CUBE_MAP,k.__webglTexture),Ot(i.TEXTURE_CUBE_MAP,_);for(let nt=0;nt<6;nt++)if(_.mipmaps&&_.mipmaps.length>0)for(let gt=0;gt<_.mipmaps.length;gt++)dt(I.__webglFramebuffer[nt][gt],y,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+nt,gt);else dt(I.__webglFramebuffer[nt],y,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0);p(_)&&h(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(Mt){for(let nt=0,gt=Z.length;nt<gt;nt++){const vt=Z[nt],Q=n.get(vt);let lt=i.TEXTURE_2D;(y.isWebGL3DRenderTarget||y.isWebGLArrayRenderTarget)&&(lt=y.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(lt,Q.__webglTexture),Ot(lt,vt),dt(I.__webglFramebuffer,y,vt,i.COLOR_ATTACHMENT0+nt,lt,0),p(vt)&&h(lt)}e.unbindTexture()}else{let nt=i.TEXTURE_2D;if((y.isWebGL3DRenderTarget||y.isWebGLArrayRenderTarget)&&(nt=y.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(nt,k.__webglTexture),Ot(nt,_),_.mipmaps&&_.mipmaps.length>0)for(let gt=0;gt<_.mipmaps.length;gt++)dt(I.__webglFramebuffer[gt],y,_,i.COLOR_ATTACHMENT0,nt,gt);else dt(I.__webglFramebuffer,y,_,i.COLOR_ATTACHMENT0,nt,0);p(_)&&h(nt),e.unbindTexture()}y.depthBuffer&&Ht(y)}function te(y){const _=y.textures;for(let I=0,k=_.length;I<k;I++){const Z=_[I];if(p(Z)){const V=A(y),Mt=n.get(Z).__webglTexture;e.bindTexture(V,Mt),h(V),e.unbindTexture()}}}const Dt=[],Rt=[];function mt(y){if(y.samples>0){if(_t(y)===!1){const _=y.textures,I=y.width,k=y.height;let Z=i.COLOR_BUFFER_BIT;const V=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Mt=n.get(y),nt=_.length>1;if(nt)for(let vt=0;vt<_.length;vt++)e.bindFramebuffer(i.FRAMEBUFFER,Mt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+vt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,Mt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+vt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,Mt.__webglMultisampledFramebuffer);const gt=y.texture.mipmaps;gt&&gt.length>0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,Mt.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,Mt.__webglFramebuffer);for(let vt=0;vt<_.length;vt++){if(y.resolveDepthBuffer&&(y.depthBuffer&&(Z|=i.DEPTH_BUFFER_BIT),y.stencilBuffer&&y.resolveStencilBuffer&&(Z|=i.STENCIL_BUFFER_BIT)),nt){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Mt.__webglColorRenderbuffer[vt]);const Q=n.get(_[vt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Q,0)}i.blitFramebuffer(0,0,I,k,0,0,I,k,Z,i.NEAREST),c===!0&&(Dt.length=0,Rt.length=0,Dt.push(i.COLOR_ATTACHMENT0+vt),y.depthBuffer&&y.resolveDepthBuffer===!1&&(Dt.push(V),Rt.push(V),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Rt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Dt))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),nt)for(let vt=0;vt<_.length;vt++){e.bindFramebuffer(i.FRAMEBUFFER,Mt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+vt,i.RENDERBUFFER,Mt.__webglColorRenderbuffer[vt]);const Q=n.get(_[vt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,Mt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+vt,i.TEXTURE_2D,Q,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,Mt.__webglMultisampledFramebuffer)}else if(y.depthBuffer&&y.resolveDepthBuffer===!1&&c){const _=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function ee(y){return Math.min(r.maxSamples,y.samples)}function _t(y){const _=n.get(y);return y.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function Nt(y){const _=a.render.frame;u.get(y)!==_&&(u.set(y,_),y.update())}function de(y,_){const I=y.colorSpace,k=y.format,Z=y.type;return y.isCompressedTexture===!0||y.isVideoTexture===!0||I!==si&&I!==fn&&(Gt.getTransfer(I)===qt?(k!==Be||Z!==Ye)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",I)),_}function ae(y){return typeof HTMLImageElement<"u"&&y instanceof HTMLImageElement?(l.width=y.naturalWidth||y.width,l.height=y.naturalHeight||y.height):typeof VideoFrame<"u"&&y instanceof VideoFrame?(l.width=y.displayWidth,l.height=y.displayHeight):(l.width=y.width,l.height=y.height),l}this.allocateTextureUnit=G,this.resetTextureUnits=z,this.setTexture2D=K,this.setTexture2DArray=W,this.setTexture3D=et,this.setTextureCube=H,this.rebindTextures=pe,this.setupRenderTarget=b,this.updateRenderTargetMipmap=te,this.updateMultisampleRenderTarget=mt,this.setupDepthRenderbuffer=Ht,this.setupFrameBufferTexture=dt,this.useMultisampledRTT=_t}function Nf(i,t){function e(n,r=fn){let s;const a=Gt.getTransfer(r);if(n===Ye)return i.UNSIGNED_BYTE;if(n===Ls)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Us)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Qa)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===to)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===$a)return i.BYTE;if(n===Ja)return i.SHORT;if(n===mi)return i.UNSIGNED_SHORT;if(n===Ds)return i.INT;if(n===Ln)return i.UNSIGNED_INT;if(n===nn)return i.FLOAT;if(n===Mi)return i.HALF_FLOAT;if(n===eo)return i.ALPHA;if(n===no)return i.RGB;if(n===Be)return i.RGBA;if(n===gi)return i.DEPTH_COMPONENT;if(n===vi)return i.DEPTH_STENCIL;if(n===io)return i.RED;if(n===Is)return i.RED_INTEGER;if(n===ro)return i.RG;if(n===Ns)return i.RG_INTEGER;if(n===Fs)return i.RGBA_INTEGER;if(n===ji||n===$i||n===Ji||n===Qi)if(a===qt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===ji)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===$i)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ji)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Qi)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===ji)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===$i)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ji)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Qi)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===es||n===ns||n===is||n===rs)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===es)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ns)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===is)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===rs)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ss||n===as||n===os)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ss||n===as)return a===qt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===os)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===ls||n===cs||n===hs||n===us||n===ds||n===fs||n===ps||n===ms||n===_s||n===gs||n===vs||n===xs||n===Ms||n===Ss)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(n===ls)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===cs)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===hs)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===us)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ds)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===fs)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ps)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ms)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===_s)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===gs)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===vs)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===xs)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ms)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ss)return a===qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Es||n===ys||n===Ts)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(n===Es)return a===qt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ys)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ts)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===bs||n===As||n===Rs||n===ws)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(n===bs)return s.COMPRESSED_RED_RGTC1_EXT;if(n===As)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Rs)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ws)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===_i?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}const Ff=`
  3733. void main() {
  3734. gl_Position = vec4( position, 1.0 );
  3735. }`,Of=`
  3736. uniform sampler2DArray depthColor;
  3737. uniform float depthWidth;
  3738. uniform float depthHeight;
  3739. void main() {
  3740. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3741. if ( coord.x >= 1.0 ) {
  3742. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3743. } else {
  3744. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3745. }
  3746. }`;class Bf{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new Mo(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new gn({vertexShader:Ff,fragmentShader:Of,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new rn(new ar(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class zf extends Nn{constructor(t,e){super();const n=this;let r=null,s=1,a=null,o="local-floor",c=1,l=null,u=null,d=null,f=null,m=null,v=null;const M=typeof XRWebGLBinding<"u",p=new Bf,h={},A=e.getContextAttributes();let T=null,E=null;const C=[],R=[],D=new Lt;let F=null;const S=new Fe;S.viewport=new se;const x=new Fe;x.viewport=new se;const P=[S,x],z=new rc;let G=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let j=C[Y];return j===void 0&&(j=new Lr,C[Y]=j),j.getTargetRaySpace()},this.getControllerGrip=function(Y){let j=C[Y];return j===void 0&&(j=new Lr,C[Y]=j),j.getGripSpace()},this.getHand=function(Y){let j=C[Y];return j===void 0&&(j=new Lr,C[Y]=j),j.getHandSpace()};function K(Y){const j=R.indexOf(Y.inputSource);if(j===-1)return;const dt=C[j];dt!==void 0&&(dt.update(Y.inputSource,Y.frame,l||a),dt.dispatchEvent({type:Y.type,data:Y.inputSource}))}function W(){r.removeEventListener("select",K),r.removeEventListener("selectstart",K),r.removeEventListener("selectend",K),r.removeEventListener("squeeze",K),r.removeEventListener("squeezestart",K),r.removeEventListener("squeezeend",K),r.removeEventListener("end",W),r.removeEventListener("inputsourceschange",et);for(let Y=0;Y<C.length;Y++){const j=R[Y];j!==null&&(R[Y]=null,C[Y].disconnect(j))}G=null,X=null,p.reset();for(const Y in h)delete h[Y];t.setRenderTarget(T),m=null,f=null,d=null,r=null,E=null,Wt.stop(),n.isPresenting=!1,t.setPixelRatio(F),t.setSize(D.width,D.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return f!==null?f:m},this.getBinding=function(){return d===null&&M&&(d=new XRWebGLBinding(r,e)),d},this.getFrame=function(){return v},this.getSession=function(){return r},this.setSession=async function(Y){if(r=Y,r!==null){if(T=t.getRenderTarget(),r.addEventListener("select",K),r.addEventListener("selectstart",K),r.addEventListener("selectend",K),r.addEventListener("squeeze",K),r.addEventListener("squeezestart",K),r.addEventListener("squeezeend",K),r.addEventListener("end",W),r.addEventListener("inputsourceschange",et),A.xrCompatible!==!0&&await e.makeXRCompatible(),F=t.getPixelRatio(),t.getSize(D),M&&"createProjectionLayer"in XRWebGLBinding.prototype){let dt=null,Ct=null,St=null;A.depth&&(St=A.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,dt=A.stencil?vi:gi,Ct=A.stencil?_i:Ln);const Ht={colorFormat:e.RGBA8,depthFormat:St,scaleFactor:s};d=this.getBinding(),f=d.createProjectionLayer(Ht),r.updateRenderState({layers:[f]}),t.setPixelRatio(1),t.setSize(f.textureWidth,f.textureHeight,!1),E=new In(f.textureWidth,f.textureHeight,{format:Be,type:Ye,depthTexture:new xo(f.textureWidth,f.textureHeight,Ct,void 0,void 0,void 0,void 0,void 0,void 0,dt),stencilBuffer:A.stencil,colorSpace:t.outputColorSpace,samples:A.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{const dt={antialias:A.antialias,alpha:!0,depth:A.depth,stencil:A.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(r,e,dt),r.updateRenderState({baseLayer:m}),t.setPixelRatio(1),t.setSize(m.framebufferWidth,m.framebufferHeight,!1),E=new In(m.framebufferWidth,m.framebufferHeight,{format:Be,type:Ye,colorSpace:t.outputColorSpace,stencilBuffer:A.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}E.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await r.requestReferenceSpace(o),Wt.setContext(r),Wt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return p.getDepthTexture()};function et(Y){for(let j=0;j<Y.removed.length;j++){const dt=Y.removed[j],Ct=R.indexOf(dt);Ct>=0&&(R[Ct]=null,C[Ct].disconnect(dt))}for(let j=0;j<Y.added.length;j++){const dt=Y.added[j];let Ct=R.indexOf(dt);if(Ct===-1){for(let Ht=0;Ht<C.length;Ht++)if(Ht>=R.length){R.push(dt),Ct=Ht;break}else if(R[Ht]===null){R[Ht]=dt,Ct=Ht;break}if(Ct===-1)break}const St=C[Ct];St&&St.connect(dt)}}const H=new N,st=new N;function ct(Y,j,dt){H.setFromMatrixPosition(j.matrixWorld),st.setFromMatrixPosition(dt.matrixWorld);const Ct=H.distanceTo(st),St=j.projectionMatrix.elements,Ht=dt.projectionMatrix.elements,pe=St[14]/(St[10]-1),b=St[14]/(St[10]+1),te=(St[9]+1)/St[5],Dt=(St[9]-1)/St[5],Rt=(St[8]-1)/St[0],mt=(Ht[8]+1)/Ht[0],ee=pe*Rt,_t=pe*mt,Nt=Ct/(-Rt+mt),de=Nt*-Rt;if(j.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(de),Y.translateZ(Nt),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),St[10]===-1)Y.projectionMatrix.copy(j.projectionMatrix),Y.projectionMatrixInverse.copy(j.projectionMatrixInverse);else{const ae=pe+Nt,y=b+Nt,_=ee-de,I=_t+(Ct-de),k=te*b/y*ae,Z=Dt*b/y*ae;Y.projectionMatrix.makePerspective(_,I,k,Z,ae,y),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function Et(Y,j){j===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(j.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(r===null)return;let j=Y.near,dt=Y.far;p.texture!==null&&(p.depthNear>0&&(j=p.depthNear),p.depthFar>0&&(dt=p.depthFar)),z.near=x.near=S.near=j,z.far=x.far=S.far=dt,(G!==z.near||X!==z.far)&&(r.updateRenderState({depthNear:z.near,depthFar:z.far}),G=z.near,X=z.far),z.layers.mask=Y.layers.mask|6,S.layers.mask=z.layers.mask&3,x.layers.mask=z.layers.mask&5;const Ct=Y.parent,St=z.cameras;Et(z,Ct);for(let Ht=0;Ht<St.length;Ht++)Et(St[Ht],Ct);St.length===2?ct(z,S,x):z.projectionMatrix.copy(S.projectionMatrix),Ot(Y,z,Ct)};function Ot(Y,j,dt){dt===null?Y.matrix.copy(j.matrixWorld):(Y.matrix.copy(dt.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(j.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(j.projectionMatrix),Y.projectionMatrixInverse.copy(j.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=Cs*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return z},this.getFoveation=function(){if(!(f===null&&m===null))return c},this.setFoveation=function(Y){c=Y,f!==null&&(f.fixedFoveation=Y),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=Y)},this.hasDepthSensing=function(){return p.texture!==null},this.getDepthSensingMesh=function(){return p.getMesh(z)},this.getCameraTexture=function(Y){return h[Y]};let jt=null;function Qt(Y,j){if(u=j.getViewerPose(l||a),v=j,u!==null){const dt=u.views;m!==null&&(t.setRenderTargetFramebuffer(E,m.framebuffer),t.setRenderTarget(E));let Ct=!1;dt.length!==z.cameras.length&&(z.cameras.length=0,Ct=!0);for(let b=0;b<dt.length;b++){const te=dt[b];let Dt=null;if(m!==null)Dt=m.getViewport(te);else{const mt=d.getViewSubImage(f,te);Dt=mt.viewport,b===0&&(t.setRenderTargetTextures(E,mt.colorTexture,mt.depthStencilTexture),t.setRenderTarget(E))}let Rt=P[b];Rt===void 0&&(Rt=new Fe,Rt.layers.enable(b),Rt.viewport=new se,P[b]=Rt),Rt.matrix.fromArray(te.transform.matrix),Rt.matrix.decompose(Rt.position,Rt.quaternion,Rt.scale),Rt.projectionMatrix.fromArray(te.projectionMatrix),Rt.projectionMatrixInverse.copy(Rt.projectionMatrix).invert(),Rt.viewport.set(Dt.x,Dt.y,Dt.width,Dt.height),b===0&&(z.matrix.copy(Rt.matrix),z.matrix.decompose(z.position,z.quaternion,z.scale)),Ct===!0&&z.cameras.push(Rt)}const St=r.enabledFeatures;if(St&&St.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&M){d=n.getBinding();const b=d.getDepthInformation(dt[0]);b&&b.isValid&&b.texture&&p.init(b,r.renderState)}if(St&&St.includes("camera-access")&&M){t.state.unbindTexture(),d=n.getBinding();for(let b=0;b<dt.length;b++){const te=dt[b].camera;if(te){let Dt=h[te];Dt||(Dt=new Mo,h[te]=Dt);const Rt=d.getCameraImage(te);Dt.sourceTexture=Rt}}}}for(let dt=0;dt<C.length;dt++){const Ct=R[dt],St=C[dt];Ct!==null&&St!==void 0&&St.update(Ct,j,l||a)}jt&&jt(Y,j),j.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:j}),v=null}const Wt=new To;Wt.setAnimationLoop(Qt),this.setAnimationLoop=function(Y){jt=Y},this.dispose=function(){}}}const An=new qe,Hf=new oe;function Vf(i,t){function e(p,h){p.matrixAutoUpdate===!0&&p.updateMatrix(),h.value.copy(p.matrix)}function n(p,h){h.color.getRGB(p.fogColor.value,_o(i)),h.isFog?(p.fogNear.value=h.near,p.fogFar.value=h.far):h.isFogExp2&&(p.fogDensity.value=h.density)}function r(p,h,A,T,E){h.isMeshBasicMaterial||h.isMeshLambertMaterial?s(p,h):h.isMeshToonMaterial?(s(p,h),d(p,h)):h.isMeshPhongMaterial?(s(p,h),u(p,h)):h.isMeshStandardMaterial?(s(p,h),f(p,h),h.isMeshPhysicalMaterial&&m(p,h,E)):h.isMeshMatcapMaterial?(s(p,h),v(p,h)):h.isMeshDepthMaterial?s(p,h):h.isMeshDistanceMaterial?(s(p,h),M(p,h)):h.isMeshNormalMaterial?s(p,h):h.isLineBasicMaterial?(a(p,h),h.isLineDashedMaterial&&o(p,h)):h.isPointsMaterial?c(p,h,A,T):h.isSpriteMaterial?l(p,h):h.isShadowMaterial?(p.color.value.copy(h.color),p.opacity.value=h.opacity):h.isShaderMaterial&&(h.uniformsNeedUpdate=!1)}function s(p,h){p.opacity.value=h.opacity,h.color&&p.diffuse.value.copy(h.color),h.emissive&&p.emissive.value.copy(h.emissive).multiplyScalar(h.emissiveIntensity),h.map&&(p.map.value=h.map,e(h.map,p.mapTransform)),h.alphaMap&&(p.alphaMap.value=h.alphaMap,e(h.alphaMap,p.alphaMapTransform)),h.bumpMap&&(p.bumpMap.value=h.bumpMap,e(h.bumpMap,p.bumpMapTransform),p.bumpScale.value=h.bumpScale,h.side===Te&&(p.bumpScale.value*=-1)),h.normalMap&&(p.normalMap.value=h.normalMap,e(h.normalMap,p.normalMapTransform),p.normalScale.value.copy(h.normalScale),h.side===Te&&p.normalScale.value.negate()),h.displacementMap&&(p.displacementMap.value=h.displacementMap,e(h.displacementMap,p.displacementMapTransform),p.displacementScale.value=h.displacementScale,p.displacementBias.value=h.displacementBias),h.emissiveMap&&(p.emissiveMap.value=h.emissiveMap,e(h.emissiveMap,p.emissiveMapTransform)),h.specularMap&&(p.specularMap.value=h.specularMap,e(h.specularMap,p.specularMapTransform)),h.alphaTest>0&&(p.alphaTest.value=h.alphaTest);const A=t.get(h),T=A.envMap,E=A.envMapRotation;T&&(p.envMap.value=T,An.copy(E),An.x*=-1,An.y*=-1,An.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(An.y*=-1,An.z*=-1),p.envMapRotation.value.setFromMatrix4(Hf.makeRotationFromEuler(An)),p.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=h.reflectivity,p.ior.value=h.ior,p.refractionRatio.value=h.refractionRatio),h.lightMap&&(p.lightMap.value=h.lightMap,p.lightMapIntensity.value=h.lightMapIntensity,e(h.lightMap,p.lightMapTransform)),h.aoMap&&(p.aoMap.value=h.aoMap,p.aoMapIntensity.value=h.aoMapIntensity,e(h.aoMap,p.aoMapTransform))}function a(p,h){p.diffuse.value.copy(h.color),p.opacity.value=h.opacity,h.map&&(p.map.value=h.map,e(h.map,p.mapTransform))}function o(p,h){p.dashSize.value=h.dashSize,p.totalSize.value=h.dashSize+h.gapSize,p.scale.value=h.scale}function c(p,h,A,T){p.diffuse.value.copy(h.color),p.opacity.value=h.opacity,p.size.value=h.size*A,p.scale.value=T*.5,h.map&&(p.map.value=h.map,e(h.map,p.uvTransform)),h.alphaMap&&(p.alphaMap.value=h.alphaMap,e(h.alphaMap,p.alphaMapTransform)),h.alphaTest>0&&(p.alphaTest.value=h.alphaTest)}function l(p,h){p.diffuse.value.copy(h.color),p.opacity.value=h.opacity,p.rotation.value=h.rotation,h.map&&(p.map.value=h.map,e(h.map,p.mapTransform)),h.alphaMap&&(p.alphaMap.value=h.alphaMap,e(h.alphaMap,p.alphaMapTransform)),h.alphaTest>0&&(p.alphaTest.value=h.alphaTest)}function u(p,h){p.specular.value.copy(h.specular),p.shininess.value=Math.max(h.shininess,1e-4)}function d(p,h){h.gradientMap&&(p.gradientMap.value=h.gradientMap)}function f(p,h){p.metalness.value=h.metalness,h.metalnessMap&&(p.metalnessMap.value=h.metalnessMap,e(h.metalnessMap,p.metalnessMapTransform)),p.roughness.value=h.roughness,h.roughnessMap&&(p.roughnessMap.value=h.roughnessMap,e(h.roughnessMap,p.roughnessMapTransform)),h.envMap&&(p.envMapIntensity.value=h.envMapIntensity)}function m(p,h,A){p.ior.value=h.ior,h.sheen>0&&(p.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),p.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(p.sheenColorMap.value=h.sheenColorMap,e(h.sheenColorMap,p.sheenColorMapTransform)),h.sheenRoughnessMap&&(p.sheenRoughnessMap.value=h.sheenRoughnessMap,e(h.sheenRoughnessMap,p.sheenRoughnessMapTransform))),h.clearcoat>0&&(p.clearcoat.value=h.clearcoat,p.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(p.clearcoatMap.value=h.clearcoatMap,e(h.clearcoatMap,p.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,e(h.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(p.clearcoatNormalMap.value=h.clearcoatNormalMap,e(h.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===Te&&p.clearcoatNormalScale.value.negate())),h.dispersion>0&&(p.dispersion.value=h.dispersion),h.iridescence>0&&(p.iridescence.value=h.iridescence,p.iridescenceIOR.value=h.iridescenceIOR,p.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(p.iridescenceMap.value=h.iridescenceMap,e(h.iridescenceMap,p.iridescenceMapTransform)),h.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=h.iridescenceThicknessMap,e(h.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),h.transmission>0&&(p.transmission.value=h.transmission,p.transmissionSamplerMap.value=A.texture,p.transmissionSamplerSize.value.set(A.width,A.height),h.transmissionMap&&(p.transmissionMap.value=h.transmissionMap,e(h.transmissionMap,p.transmissionMapTransform)),p.thickness.value=h.thickness,h.thicknessMap&&(p.thicknessMap.value=h.thicknessMap,e(h.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=h.attenuationDistance,p.attenuationColor.value.copy(h.attenuationColor)),h.anisotropy>0&&(p.anisotropyVector.value.set(h.anisotropy*Math.cos(h.anisotropyRotation),h.anisotropy*Math.sin(h.anisotropyRotation)),h.anisotropyMap&&(p.anisotropyMap.value=h.anisotropyMap,e(h.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=h.specularIntensity,p.specularColor.value.copy(h.specularColor),h.specularColorMap&&(p.specularColorMap.value=h.specularColorMap,e(h.specularColorMap,p.specularColorMapTransform)),h.specularIntensityMap&&(p.specularIntensityMap.value=h.specularIntensityMap,e(h.specularIntensityMap,p.specularIntensityMapTransform))}function v(p,h){h.matcap&&(p.matcap.value=h.matcap)}function M(p,h){const A=t.get(h).light;p.referencePosition.value.setFromMatrixPosition(A.matrixWorld),p.nearDistance.value=A.shadow.camera.near,p.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function Gf(i,t,e,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(A,T){const E=T.program;n.uniformBlockBinding(A,E)}function l(A,T){let E=r[A.id];E===void 0&&(v(A),E=u(A),r[A.id]=E,A.addEventListener("dispose",p));const C=T.program;n.updateUBOMapping(A,C);const R=t.render.frame;s[A.id]!==R&&(f(A),s[A.id]=R)}function u(A){const T=d();A.__bindingPointIndex=T;const E=i.createBuffer(),C=A.__size,R=A.usage;return i.bindBuffer(i.UNIFORM_BUFFER,E),i.bufferData(i.UNIFORM_BUFFER,C,R),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,T,E),E}function d(){for(let A=0;A<o;A++)if(a.indexOf(A)===-1)return a.push(A),A;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(A){const T=r[A.id],E=A.uniforms,C=A.__cache;i.bindBuffer(i.UNIFORM_BUFFER,T);for(let R=0,D=E.length;R<D;R++){const F=Array.isArray(E[R])?E[R]:[E[R]];for(let S=0,x=F.length;S<x;S++){const P=F[S];if(m(P,R,S,C)===!0){const z=P.__offset,G=Array.isArray(P.value)?P.value:[P.value];let X=0;for(let K=0;K<G.length;K++){const W=G[K],et=M(W);typeof W=="number"||typeof W=="boolean"?(P.__data[0]=W,i.bufferSubData(i.UNIFORM_BUFFER,z+X,P.__data)):W.isMatrix3?(P.__data[0]=W.elements[0],P.__data[1]=W.elements[1],P.__data[2]=W.elements[2],P.__data[3]=0,P.__data[4]=W.elements[3],P.__data[5]=W.elements[4],P.__data[6]=W.elements[5],P.__data[7]=0,P.__data[8]=W.elements[6],P.__data[9]=W.elements[7],P.__data[10]=W.elements[8],P.__data[11]=0):(W.toArray(P.__data,X),X+=et.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,z,P.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function m(A,T,E,C){const R=A.value,D=T+"_"+E;if(C[D]===void 0)return typeof R=="number"||typeof R=="boolean"?C[D]=R:C[D]=R.clone(),!0;{const F=C[D];if(typeof R=="number"||typeof R=="boolean"){if(F!==R)return C[D]=R,!0}else if(F.equals(R)===!1)return F.copy(R),!0}return!1}function v(A){const T=A.uniforms;let E=0;const C=16;for(let D=0,F=T.length;D<F;D++){const S=Array.isArray(T[D])?T[D]:[T[D]];for(let x=0,P=S.length;x<P;x++){const z=S[x],G=Array.isArray(z.value)?z.value:[z.value];for(let X=0,K=G.length;X<K;X++){const W=G[X],et=M(W),H=E%C,st=H%et.boundary,ct=H+st;E+=st,ct!==0&&C-ct<et.storage&&(E+=C-ct),z.__data=new Float32Array(et.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=E,E+=et.storage}}}const R=E%C;return R>0&&(E+=C-R),A.__size=E,A.__cache={},this}function M(A){const T={boundary:0,storage:0};return typeof A=="number"||typeof A=="boolean"?(T.boundary=4,T.storage=4):A.isVector2?(T.boundary=8,T.storage=8):A.isVector3||A.isColor?(T.boundary=16,T.storage=12):A.isVector4?(T.boundary=16,T.storage=16):A.isMatrix3?(T.boundary=48,T.storage=48):A.isMatrix4?(T.boundary=64,T.storage=64):A.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",A),T}function p(A){const T=A.target;T.removeEventListener("dispose",p);const E=a.indexOf(T.__bindingPointIndex);a.splice(E,1),i.deleteBuffer(r[T.id]),delete r[T.id],delete s[T.id]}function h(){for(const A in r)i.deleteBuffer(r[A]);a=[],r={},s={}}return{bind:c,update:l,dispose:h}}class op{constructor(t={}){const{canvas:e=bl(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:f=!1}=t;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=a;const v=new Uint32Array(4),M=new Int32Array(4);let p=null,h=null;const A=[],T=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=mn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const E=this;let C=!1;this._outputColorSpace=Le;let R=0,D=0,F=null,S=-1,x=null;const P=new se,z=new se;let G=null;const X=new kt(0);let K=0,W=e.width,et=e.height,H=1,st=null,ct=null;const Et=new se(0,0,W,et),Ot=new se(0,0,W,et);let jt=!1;const Qt=new zs;let Wt=!1,Y=!1;const j=new oe,dt=new N,Ct=new se,St={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ht=!1;function pe(){return F===null?H:1}let b=n;function te(g,L){return e.getContext(g,L)}try{const g={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine","three.js r180"),e.addEventListener("webglcontextlost",it,!1),e.addEventListener("webglcontextrestored",ut,!1),e.addEventListener("webglcontextcreationerror",$,!1),b===null){const L="webgl2";if(b=te(L,g),b===null)throw te(L)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(g){throw console.error("THREE.WebGLRenderer: "+g.message),g}let Dt,Rt,mt,ee,_t,Nt,de,ae,y,_,I,k,Z,V,Mt,nt,gt,vt,Q,lt,At,xt,at,Ut;function w(){Dt=new Ju(b),Dt.init(),xt=new Nf(b,Dt),Rt=new Xu(b,Dt,t,xt),mt=new Uf(b,Dt),Rt.reversedDepthBuffer&&f&&mt.buffers.depth.setReversed(!0),ee=new ed(b),_t=new Mf,Nt=new If(b,Dt,mt,_t,Rt,xt,ee),de=new qu(E),ae=new $u(E),y=new oc(b),at=new ku(b,y),_=new Qu(b,y,ee,at),I=new id(b,_,y,ee),Q=new nd(b,Rt,Nt),nt=new Yu(_t),k=new xf(E,de,ae,Dt,Rt,at,nt),Z=new Vf(E,_t),V=new Ef,Mt=new wf(Dt),vt=new Gu(E,de,ae,mt,I,m,c),gt=new Df(E,I,Rt),Ut=new Gf(b,ee,Rt,mt),lt=new Wu(b,Dt,ee),At=new td(b,Dt,ee),ee.programs=k.programs,E.capabilities=Rt,E.extensions=Dt,E.properties=_t,E.renderLists=V,E.shadowMap=gt,E.state=mt,E.info=ee}w();const tt=new zf(E,b);this.xr=tt,this.getContext=function(){return b},this.getContextAttributes=function(){return b.getContextAttributes()},this.forceContextLoss=function(){const g=Dt.get("WEBGL_lose_context");g&&g.loseContext()},this.forceContextRestore=function(){const g=Dt.get("WEBGL_lose_context");g&&g.restoreContext()},this.getPixelRatio=function(){return H},this.setPixelRatio=function(g){g!==void 0&&(H=g,this.setSize(W,et,!1))},this.getSize=function(g){return g.set(W,et)},this.setSize=function(g,L,O=!0){if(tt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=g,et=L,e.width=Math.floor(g*H),e.height=Math.floor(L*H),O===!0&&(e.style.width=g+"px",e.style.height=L+"px"),this.setViewport(0,0,g,L)},this.getDrawingBufferSize=function(g){return g.set(W*H,et*H).floor()},this.setDrawingBufferSize=function(g,L,O){W=g,et=L,H=O,e.width=Math.floor(g*O),e.height=Math.floor(L*O),this.setViewport(0,0,g,L)},this.getCurrentViewport=function(g){return g.copy(P)},this.getViewport=function(g){return g.copy(Et)},this.setViewport=function(g,L,O,B){g.isVector4?Et.set(g.x,g.y,g.z,g.w):Et.set(g,L,O,B),mt.viewport(P.copy(Et).multiplyScalar(H).round())},this.getScissor=function(g){return g.copy(Ot)},this.setScissor=function(g,L,O,B){g.isVector4?Ot.set(g.x,g.y,g.z,g.w):Ot.set(g,L,O,B),mt.scissor(z.copy(Ot).multiplyScalar(H).round())},this.getScissorTest=function(){return jt},this.setScissorTest=function(g){mt.setScissorTest(jt=g)},this.setOpaqueSort=function(g){st=g},this.setTransparentSort=function(g){ct=g},this.getClearColor=function(g){return g.copy(vt.getClearColor())},this.setClearColor=function(){vt.setClearColor(...arguments)},this.getClearAlpha=function(){return vt.getClearAlpha()},this.setClearAlpha=function(){vt.setClearAlpha(...arguments)},this.clear=function(g=!0,L=!0,O=!0){let B=0;if(g){let U=!1;if(F!==null){const J=F.texture.format;U=J===Fs||J===Ns||J===Is}if(U){const J=F.texture.type,ot=J===Ye||J===Ln||J===mi||J===_i||J===Ls||J===Us,ft=vt.getClearColor(),ht=vt.getClearAlpha(),bt=ft.r,wt=ft.g,yt=ft.b;ot?(v[0]=bt,v[1]=wt,v[2]=yt,v[3]=ht,b.clearBufferuiv(b.COLOR,0,v)):(M[0]=bt,M[1]=wt,M[2]=yt,M[3]=ht,b.clearBufferiv(b.COLOR,0,M))}else B|=b.COLOR_BUFFER_BIT}L&&(B|=b.DEPTH_BUFFER_BIT),O&&(B|=b.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),b.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",it,!1),e.removeEventListener("webglcontextrestored",ut,!1),e.removeEventListener("webglcontextcreationerror",$,!1),vt.dispose(),V.dispose(),Mt.dispose(),_t.dispose(),de.dispose(),ae.dispose(),I.dispose(),at.dispose(),Ut.dispose(),k.dispose(),tt.dispose(),tt.removeEventListener("sessionstart",He),tt.removeEventListener("sessionend",Gs),xn.stop()};function it(g){g.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),C=!0}function ut(){console.log("THREE.WebGLRenderer: Context Restored."),C=!1;const g=ee.autoReset,L=gt.enabled,O=gt.autoUpdate,B=gt.needsUpdate,U=gt.type;w(),ee.autoReset=g,gt.enabled=L,gt.autoUpdate=O,gt.needsUpdate=B,gt.type=U}function $(g){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",g.statusMessage)}function q(g){const L=g.target;L.removeEventListener("dispose",q),pt(L)}function pt(g){Pt(g),_t.remove(g)}function Pt(g){const L=_t.get(g).programs;L!==void 0&&(L.forEach(function(O){k.releaseProgram(O)}),g.isShaderMaterial&&k.releaseShaderCache(g))}this.renderBufferDirect=function(g,L,O,B,U,J){L===null&&(L=St);const ot=U.isMesh&&U.matrixWorld.determinant()<0,ft=Po(g,L,O,B,U);mt.setMaterial(B,ot);let ht=O.index,bt=1;if(B.wireframe===!0){if(ht=_.getWireframeAttribute(O),ht===void 0)return;bt=2}const wt=O.drawRange,yt=O.attributes.position;let zt=wt.start*bt,Yt=(wt.start+wt.count)*bt;J!==null&&(zt=Math.max(zt,J.start*bt),Yt=Math.min(Yt,(J.start+J.count)*bt)),ht!==null?(zt=Math.max(zt,0),Yt=Math.min(Yt,ht.count)):yt!=null&&(zt=Math.max(zt,0),Yt=Math.min(Yt,yt.count));const re=Yt-zt;if(re<0||re===1/0)return;at.setup(U,B,ft,O,ht);let Jt,Zt=lt;if(ht!==null&&(Jt=y.get(ht),Zt=At,Zt.setIndex(Jt)),U.isMesh)B.wireframe===!0?(mt.setLineWidth(B.wireframeLinewidth*pe()),Zt.setMode(b.LINES)):Zt.setMode(b.TRIANGLES);else if(U.isLine){let Tt=B.linewidth;Tt===void 0&&(Tt=1),mt.setLineWidth(Tt*pe()),U.isLineSegments?Zt.setMode(b.LINES):U.isLineLoop?Zt.setMode(b.LINE_LOOP):Zt.setMode(b.LINE_STRIP)}else U.isPoints?Zt.setMode(b.POINTS):U.isSprite&&Zt.setMode(b.TRIANGLES);if(U.isBatchedMesh)if(U._multiDrawInstances!==null)xi("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Zt.renderMultiDrawInstances(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount,U._multiDrawInstances);else if(Dt.get("WEBGL_multi_draw"))Zt.renderMultiDraw(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount);else{const Tt=U._multiDrawStarts,ne=U._multiDrawCounts,Vt=U._multiDrawCount,be=ht?y.get(ht).bytesPerElement:1,Fn=_t.get(B).currentProgram.getUniforms();for(let Ae=0;Ae<Vt;Ae++)Fn.setValue(b,"_gl_DrawID",Ae),Zt.render(Tt[Ae]/be,ne[Ae])}else if(U.isInstancedMesh)Zt.renderInstances(zt,re,U.count);else if(O.isInstancedBufferGeometry){const Tt=O._maxInstanceCount!==void 0?O._maxInstanceCount:1/0,ne=Math.min(O.instanceCount,Tt);Zt.renderInstances(zt,re,ne)}else Zt.render(zt,re)};function $t(g,L,O){g.transparent===!0&&g.side===en&&g.forceSinglePass===!1?(g.side=Te,g.needsUpdate=!0,Ai(g,L,O),g.side=_n,g.needsUpdate=!0,Ai(g,L,O),g.side=en):Ai(g,L,O)}this.compile=function(g,L,O=null){O===null&&(O=g),h=Mt.get(O),h.init(L),T.push(h),O.traverseVisible(function(U){U.isLight&&U.layers.test(L.layers)&&(h.pushLight(U),U.castShadow&&h.pushShadow(U))}),g!==O&&g.traverseVisible(function(U){U.isLight&&U.layers.test(L.layers)&&(h.pushLight(U),U.castShadow&&h.pushShadow(U))}),h.setupLights();const B=new Set;return g.traverse(function(U){if(!(U.isMesh||U.isPoints||U.isLine||U.isSprite))return;const J=U.material;if(J)if(Array.isArray(J))for(let ot=0;ot<J.length;ot++){const ft=J[ot];$t(ft,O,U),B.add(ft)}else $t(J,O,U),B.add(J)}),h=T.pop(),B},this.compileAsync=function(g,L,O=null){const B=this.compile(g,L,O);return new Promise(U=>{function J(){if(B.forEach(function(ot){_t.get(ot).currentProgram.isReady()&&B.delete(ot)}),B.size===0){U(g);return}setTimeout(J,10)}Dt.get("KHR_parallel_shader_compile")!==null?J():setTimeout(J,10)})};let Xt=null;function Ke(g){Xt&&Xt(g)}function He(){xn.stop()}function Gs(){xn.start()}const xn=new To;xn.setAnimationLoop(Ke),typeof self<"u"&&xn.setContext(self),this.setAnimationLoop=function(g){Xt=g,tt.setAnimationLoop(g),g===null?xn.stop():xn.start()},tt.addEventListener("sessionstart",He),tt.addEventListener("sessionend",Gs),this.render=function(g,L){if(L!==void 0&&L.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;if(g.matrixWorldAutoUpdate===!0&&g.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),tt.enabled===!0&&tt.isPresenting===!0&&(tt.cameraAutoUpdate===!0&&tt.updateCamera(L),L=tt.getCamera()),g.isScene===!0&&g.onBeforeRender(E,g,L,F),h=Mt.get(g,T.length),h.init(L),T.push(h),j.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),Qt.setFromProjectionMatrix(j,ke,L.reversedDepth),Y=this.localClippingEnabled,Wt=nt.init(this.clippingPlanes,Y),p=V.get(g,A.length),p.init(),A.push(p),tt.enabled===!0&&tt.isPresenting===!0){const J=E.xr.getDepthSensingMesh();J!==null&&lr(J,L,-1/0,E.sortObjects)}lr(g,L,0,E.sortObjects),p.finish(),E.sortObjects===!0&&p.sort(st,ct),Ht=tt.enabled===!1||tt.isPresenting===!1||tt.hasDepthSensing()===!1,Ht&&vt.addToRenderList(p,g),this.info.render.frame++,Wt===!0&&nt.beginShadows();const O=h.state.shadowsArray;gt.render(O,g,L),Wt===!0&&nt.endShadows(),this.info.autoReset===!0&&this.info.reset();const B=p.opaque,U=p.transmissive;if(h.setupLights(),L.isArrayCamera){const J=L.cameras;if(U.length>0)for(let ot=0,ft=J.length;ot<ft;ot++){const ht=J[ot];Ws(B,U,g,ht)}Ht&&vt.render(g);for(let ot=0,ft=J.length;ot<ft;ot++){const ht=J[ot];ks(p,g,ht,ht.viewport)}}else U.length>0&&Ws(B,U,g,L),Ht&&vt.render(g),ks(p,g,L);F!==null&&D===0&&(Nt.updateMultisampleRenderTarget(F),Nt.updateRenderTargetMipmap(F)),g.isScene===!0&&g.onAfterRender(E,g,L),at.resetDefaultState(),S=-1,x=null,T.pop(),T.length>0?(h=T[T.length-1],Wt===!0&&nt.setGlobalState(E.clippingPlanes,h.state.camera)):h=null,A.pop(),A.length>0?p=A[A.length-1]:p=null};function lr(g,L,O,B){if(g.visible===!1)return;if(g.layers.test(L.layers)){if(g.isGroup)O=g.renderOrder;else if(g.isLOD)g.autoUpdate===!0&&g.update(L);else if(g.isLight)h.pushLight(g),g.castShadow&&h.pushShadow(g);else if(g.isSprite){if(!g.frustumCulled||Qt.intersectsSprite(g)){B&&Ct.setFromMatrixPosition(g.matrixWorld).applyMatrix4(j);const ot=I.update(g),ft=g.material;ft.visible&&p.push(g,ot,ft,O,Ct.z,null)}}else if((g.isMesh||g.isLine||g.isPoints)&&(!g.frustumCulled||Qt.intersectsObject(g))){const ot=I.update(g),ft=g.material;if(B&&(g.boundingSphere!==void 0?(g.boundingSphere===null&&g.computeBoundingSphere(),Ct.copy(g.boundingSphere.center)):(ot.boundingSphere===null&&ot.computeBoundingSphere(),Ct.copy(ot.boundingSphere.center)),Ct.applyMatrix4(g.matrixWorld).applyMatrix4(j)),Array.isArray(ft)){const ht=ot.groups;for(let bt=0,wt=ht.length;bt<wt;bt++){const yt=ht[bt],zt=ft[yt.materialIndex];zt&&zt.visible&&p.push(g,ot,zt,O,Ct.z,yt)}}else ft.visible&&p.push(g,ot,ft,O,Ct.z,null)}}const J=g.children;for(let ot=0,ft=J.length;ot<ft;ot++)lr(J[ot],L,O,B)}function ks(g,L,O,B){const U=g.opaque,J=g.transmissive,ot=g.transparent;h.setupLightsView(O),Wt===!0&&nt.setGlobalState(E.clippingPlanes,O),B&&mt.viewport(P.copy(B)),U.length>0&&bi(U,L,O),J.length>0&&bi(J,L,O),ot.length>0&&bi(ot,L,O),mt.buffers.depth.setTest(!0),mt.buffers.depth.setMask(!0),mt.buffers.color.setMask(!0),mt.setPolygonOffset(!1)}function Ws(g,L,O,B){if((O.isScene===!0?O.overrideMaterial:null)!==null)return;h.state.transmissionRenderTarget[B.id]===void 0&&(h.state.transmissionRenderTarget[B.id]=new In(1,1,{generateMipmaps:!0,type:Dt.has("EXT_color_buffer_half_float")||Dt.has("EXT_color_buffer_float")?Mi:Ye,minFilter:Dn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Gt.workingColorSpace}));const J=h.state.transmissionRenderTarget[B.id],ot=B.viewport||P;J.setSize(ot.z*E.transmissionResolutionScale,ot.w*E.transmissionResolutionScale);const ft=E.getRenderTarget(),ht=E.getActiveCubeFace(),bt=E.getActiveMipmapLevel();E.setRenderTarget(J),E.getClearColor(X),K=E.getClearAlpha(),K<1&&E.setClearColor(16777215,.5),E.clear(),Ht&&vt.render(O);const wt=E.toneMapping;E.toneMapping=mn;const yt=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),h.setupLightsView(B),Wt===!0&&nt.setGlobalState(E.clippingPlanes,B),bi(g,O,B),Nt.updateMultisampleRenderTarget(J),Nt.updateRenderTargetMipmap(J),Dt.has("WEBGL_multisampled_render_to_texture")===!1){let zt=!1;for(let Yt=0,re=L.length;Yt<re;Yt++){const Jt=L[Yt],Zt=Jt.object,Tt=Jt.geometry,ne=Jt.material,Vt=Jt.group;if(ne.side===en&&Zt.layers.test(B.layers)){const be=ne.side;ne.side=Te,ne.needsUpdate=!0,Xs(Zt,O,B,Tt,ne,Vt),ne.side=be,ne.needsUpdate=!0,zt=!0}}zt===!0&&(Nt.updateMultisampleRenderTarget(J),Nt.updateRenderTargetMipmap(J))}E.setRenderTarget(ft,ht,bt),E.setClearColor(X,K),yt!==void 0&&(B.viewport=yt),E.toneMapping=wt}function bi(g,L,O){const B=L.isScene===!0?L.overrideMaterial:null;for(let U=0,J=g.length;U<J;U++){const ot=g[U],ft=ot.object,ht=ot.geometry,bt=ot.group;let wt=ot.material;wt.allowOverride===!0&&B!==null&&(wt=B),ft.layers.test(O.layers)&&Xs(ft,L,O,ht,wt,bt)}}function Xs(g,L,O,B,U,J){g.onBeforeRender(E,L,O,B,U,J),g.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,g.matrixWorld),g.normalMatrix.getNormalMatrix(g.modelViewMatrix),U.onBeforeRender(E,L,O,B,g,J),U.transparent===!0&&U.side===en&&U.forceSinglePass===!1?(U.side=Te,U.needsUpdate=!0,E.renderBufferDirect(O,L,B,U,g,J),U.side=_n,U.needsUpdate=!0,E.renderBufferDirect(O,L,B,U,g,J),U.side=en):E.renderBufferDirect(O,L,B,U,g,J),g.onAfterRender(E,L,O,B,U,J)}function Ai(g,L,O){L.isScene!==!0&&(L=St);const B=_t.get(g),U=h.state.lights,J=h.state.shadowsArray,ot=U.state.version,ft=k.getParameters(g,U.state,J,L,O),ht=k.getProgramCacheKey(ft);let bt=B.programs;B.environment=g.isMeshStandardMaterial?L.environment:null,B.fog=L.fog,B.envMap=(g.isMeshStandardMaterial?ae:de).get(g.envMap||B.environment),B.envMapRotation=B.environment!==null&&g.envMap===null?L.environmentRotation:g.envMapRotation,bt===void 0&&(g.addEventListener("dispose",q),bt=new Map,B.programs=bt);let wt=bt.get(ht);if(wt!==void 0){if(B.currentProgram===wt&&B.lightsStateVersion===ot)return qs(g,ft),wt}else ft.uniforms=k.getUniforms(g),g.onBeforeCompile(ft,E),wt=k.acquireProgram(ft,ht),bt.set(ht,wt),B.uniforms=ft.uniforms;const yt=B.uniforms;return(!g.isShaderMaterial&&!g.isRawShaderMaterial||g.clipping===!0)&&(yt.clippingPlanes=nt.uniform),qs(g,ft),B.needsLights=Lo(g),B.lightsStateVersion=ot,B.needsLights&&(yt.ambientLightColor.value=U.state.ambient,yt.lightProbe.value=U.state.probe,yt.directionalLights.value=U.state.directional,yt.directionalLightShadows.value=U.state.directionalShadow,yt.spotLights.value=U.state.spot,yt.spotLightShadows.value=U.state.spotShadow,yt.rectAreaLights.value=U.state.rectArea,yt.ltc_1.value=U.state.rectAreaLTC1,yt.ltc_2.value=U.state.rectAreaLTC2,yt.pointLights.value=U.state.point,yt.pointLightShadows.value=U.state.pointShadow,yt.hemisphereLights.value=U.state.hemi,yt.directionalShadowMap.value=U.state.directionalShadowMap,yt.directionalShadowMatrix.value=U.state.directionalShadowMatrix,yt.spotShadowMap.value=U.state.spotShadowMap,yt.spotLightMatrix.value=U.state.spotLightMatrix,yt.spotLightMap.value=U.state.spotLightMap,yt.pointShadowMap.value=U.state.pointShadowMap,yt.pointShadowMatrix.value=U.state.pointShadowMatrix),B.currentProgram=wt,B.uniformsList=null,wt}function Ys(g){if(g.uniformsList===null){const L=g.currentProgram.getUniforms();g.uniformsList=er.seqWithValue(L.seq,g.uniforms)}return g.uniformsList}function qs(g,L){const O=_t.get(g);O.outputColorSpace=L.outputColorSpace,O.batching=L.batching,O.batchingColor=L.batchingColor,O.instancing=L.instancing,O.instancingColor=L.instancingColor,O.instancingMorph=L.instancingMorph,O.skinning=L.skinning,O.morphTargets=L.morphTargets,O.morphNormals=L.morphNormals,O.morphColors=L.morphColors,O.morphTargetsCount=L.morphTargetsCount,O.numClippingPlanes=L.numClippingPlanes,O.numIntersection=L.numClipIntersection,O.vertexAlphas=L.vertexAlphas,O.vertexTangents=L.vertexTangents,O.toneMapping=L.toneMapping}function Po(g,L,O,B,U){L.isScene!==!0&&(L=St),Nt.resetTextureUnits();const J=L.fog,ot=B.isMeshStandardMaterial?L.environment:null,ft=F===null?E.outputColorSpace:F.isXRRenderTarget===!0?F.texture.colorSpace:si,ht=(B.isMeshStandardMaterial?ae:de).get(B.envMap||ot),bt=B.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,wt=!!O.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),yt=!!O.morphAttributes.position,zt=!!O.morphAttributes.normal,Yt=!!O.morphAttributes.color;let re=mn;B.toneMapped&&(F===null||F.isXRRenderTarget===!0)&&(re=E.toneMapping);const Jt=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,Zt=Jt!==void 0?Jt.length:0,Tt=_t.get(B),ne=h.state.lights;if(Wt===!0&&(Y===!0||g!==x)){const ve=g===x&&B.id===S;nt.setState(B,g,ve)}let Vt=!1;B.version===Tt.__version?(Tt.needsLights&&Tt.lightsStateVersion!==ne.state.version||Tt.outputColorSpace!==ft||U.isBatchedMesh&&Tt.batching===!1||!U.isBatchedMesh&&Tt.batching===!0||U.isBatchedMesh&&Tt.batchingColor===!0&&U.colorTexture===null||U.isBatchedMesh&&Tt.batchingColor===!1&&U.colorTexture!==null||U.isInstancedMesh&&Tt.instancing===!1||!U.isInstancedMesh&&Tt.instancing===!0||U.isSkinnedMesh&&Tt.skinning===!1||!U.isSkinnedMesh&&Tt.skinning===!0||U.isInstancedMesh&&Tt.instancingColor===!0&&U.instanceColor===null||U.isInstancedMesh&&Tt.instancingColor===!1&&U.instanceColor!==null||U.isInstancedMesh&&Tt.instancingMorph===!0&&U.morphTexture===null||U.isInstancedMesh&&Tt.instancingMorph===!1&&U.morphTexture!==null||Tt.envMap!==ht||B.fog===!0&&Tt.fog!==J||Tt.numClippingPlanes!==void 0&&(Tt.numClippingPlanes!==nt.numPlanes||Tt.numIntersection!==nt.numIntersection)||Tt.vertexAlphas!==bt||Tt.vertexTangents!==wt||Tt.morphTargets!==yt||Tt.morphNormals!==zt||Tt.morphColors!==Yt||Tt.toneMapping!==re||Tt.morphTargetsCount!==Zt)&&(Vt=!0):(Vt=!0,Tt.__version=B.version);let be=Tt.currentProgram;Vt===!0&&(be=Ai(B,L,U));let Fn=!1,Ae=!1,li=!1;const ie=be.getUniforms(),Ce=Tt.uniforms;if(mt.useProgram(be.program)&&(Fn=!0,Ae=!0,li=!0),B.id!==S&&(S=B.id,Ae=!0),Fn||x!==g){mt.buffers.depth.getReversed()&&g.reversedDepth!==!0&&(g._reversedDepth=!0,g.updateProjectionMatrix()),ie.setValue(b,"projectionMatrix",g.projectionMatrix),ie.setValue(b,"viewMatrix",g.matrixWorldInverse);const Se=ie.map.cameraPosition;Se!==void 0&&Se.setValue(b,dt.setFromMatrixPosition(g.matrixWorld)),Rt.logarithmicDepthBuffer&&ie.setValue(b,"logDepthBufFC",2/(Math.log(g.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ie.setValue(b,"isOrthographic",g.isOrthographicCamera===!0),x!==g&&(x=g,Ae=!0,li=!0)}if(U.isSkinnedMesh){ie.setOptional(b,U,"bindMatrix"),ie.setOptional(b,U,"bindMatrixInverse");const ve=U.skeleton;ve&&(ve.boneTexture===null&&ve.computeBoneTexture(),ie.setValue(b,"boneTexture",ve.boneTexture,Nt))}U.isBatchedMesh&&(ie.setOptional(b,U,"batchingTexture"),ie.setValue(b,"batchingTexture",U._matricesTexture,Nt),ie.setOptional(b,U,"batchingIdTexture"),ie.setValue(b,"batchingIdTexture",U._indirectTexture,Nt),ie.setOptional(b,U,"batchingColorTexture"),U._colorsTexture!==null&&ie.setValue(b,"batchingColorTexture",U._colorsTexture,Nt));const Pe=O.morphAttributes;if((Pe.position!==void 0||Pe.normal!==void 0||Pe.color!==void 0)&&Q.update(U,O,be),(Ae||Tt.receiveShadow!==U.receiveShadow)&&(Tt.receiveShadow=U.receiveShadow,ie.setValue(b,"receiveShadow",U.receiveShadow)),B.isMeshGouraudMaterial&&B.envMap!==null&&(Ce.envMap.value=ht,Ce.flipEnvMap.value=ht.isCubeTexture&&ht.isRenderTargetTexture===!1?-1:1),B.isMeshStandardMaterial&&B.envMap===null&&L.environment!==null&&(Ce.envMapIntensity.value=L.environmentIntensity),Ae&&(ie.setValue(b,"toneMappingExposure",E.toneMappingExposure),Tt.needsLights&&Do(Ce,li),J&&B.fog===!0&&Z.refreshFogUniforms(Ce,J),Z.refreshMaterialUniforms(Ce,B,H,et,h.state.transmissionRenderTarget[g.id]),er.upload(b,Ys(Tt),Ce,Nt)),B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(er.upload(b,Ys(Tt),Ce,Nt),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ie.setValue(b,"center",U.center),ie.setValue(b,"modelViewMatrix",U.modelViewMatrix),ie.setValue(b,"normalMatrix",U.normalMatrix),ie.setValue(b,"modelMatrix",U.matrixWorld),B.isShaderMaterial||B.isRawShaderMaterial){const ve=B.uniformsGroups;for(let Se=0,cr=ve.length;Se<cr;Se++){const Mn=ve[Se];Ut.update(Mn,be),Ut.bind(Mn,be)}}return be}function Do(g,L){g.ambientLightColor.needsUpdate=L,g.lightProbe.needsUpdate=L,g.directionalLights.needsUpdate=L,g.directionalLightShadows.needsUpdate=L,g.pointLights.needsUpdate=L,g.pointLightShadows.needsUpdate=L,g.spotLights.needsUpdate=L,g.spotLightShadows.needsUpdate=L,g.rectAreaLights.needsUpdate=L,g.hemisphereLights.needsUpdate=L}function Lo(g){return g.isMeshLambertMaterial||g.isMeshToonMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isShadowMaterial||g.isShaderMaterial&&g.lights===!0}this.getActiveCubeFace=function(){return R},this.getActiveMipmapLevel=function(){return D},this.getRenderTarget=function(){return F},this.setRenderTargetTextures=function(g,L,O){const B=_t.get(g);B.__autoAllocateDepthBuffer=g.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),_t.get(g.texture).__webglTexture=L,_t.get(g.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:O,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(g,L){const O=_t.get(g);O.__webglFramebuffer=L,O.__useDefaultFramebuffer=L===void 0};const Uo=b.createFramebuffer();this.setRenderTarget=function(g,L=0,O=0){F=g,R=L,D=O;let B=!0,U=null,J=!1,ot=!1;if(g){const ht=_t.get(g);if(ht.__useDefaultFramebuffer!==void 0)mt.bindFramebuffer(b.FRAMEBUFFER,null),B=!1;else if(ht.__webglFramebuffer===void 0)Nt.setupRenderTarget(g);else if(ht.__hasExternalTextures)Nt.rebindTextures(g,_t.get(g.texture).__webglTexture,_t.get(g.depthTexture).__webglTexture);else if(g.depthBuffer){const yt=g.depthTexture;if(ht.__boundDepthTexture!==yt){if(yt!==null&&_t.has(yt)&&(g.width!==yt.image.width||g.height!==yt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Nt.setupDepthRenderbuffer(g)}}const bt=g.texture;(bt.isData3DTexture||bt.isDataArrayTexture||bt.isCompressedArrayTexture)&&(ot=!0);const wt=_t.get(g).__webglFramebuffer;g.isWebGLCubeRenderTarget?(Array.isArray(wt[L])?U=wt[L][O]:U=wt[L],J=!0):g.samples>0&&Nt.useMultisampledRTT(g)===!1?U=_t.get(g).__webglMultisampledFramebuffer:Array.isArray(wt)?U=wt[O]:U=wt,P.copy(g.viewport),z.copy(g.scissor),G=g.scissorTest}else P.copy(Et).multiplyScalar(H).floor(),z.copy(Ot).multiplyScalar(H).floor(),G=jt;if(O!==0&&(U=Uo),mt.bindFramebuffer(b.FRAMEBUFFER,U)&&B&&mt.drawBuffers(g,U),mt.viewport(P),mt.scissor(z),mt.setScissorTest(G),J){const ht=_t.get(g.texture);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_CUBE_MAP_POSITIVE_X+L,ht.__webglTexture,O)}else if(ot){const ht=L;for(let bt=0;bt<g.textures.length;bt++){const wt=_t.get(g.textures[bt]);b.framebufferTextureLayer(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0+bt,wt.__webglTexture,O,ht)}}else if(g!==null&&O!==0){const ht=_t.get(g.texture);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,ht.__webglTexture,O)}S=-1},this.readRenderTargetPixels=function(g,L,O,B,U,J,ot,ft=0){if(!(g&&g.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ht=_t.get(g).__webglFramebuffer;if(g.isWebGLCubeRenderTarget&&ot!==void 0&&(ht=ht[ot]),ht){mt.bindFramebuffer(b.FRAMEBUFFER,ht);try{const bt=g.textures[ft],wt=bt.format,yt=bt.type;if(!Rt.textureFormatReadable(wt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Rt.textureTypeReadable(yt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=g.width-B&&O>=0&&O<=g.height-U&&(g.textures.length>1&&b.readBuffer(b.COLOR_ATTACHMENT0+ft),b.readPixels(L,O,B,U,xt.convert(wt),xt.convert(yt),J))}finally{const bt=F!==null?_t.get(F).__webglFramebuffer:null;mt.bindFramebuffer(b.FRAMEBUFFER,bt)}}},this.readRenderTargetPixelsAsync=async function(g,L,O,B,U,J,ot,ft=0){if(!(g&&g.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ht=_t.get(g).__webglFramebuffer;if(g.isWebGLCubeRenderTarget&&ot!==void 0&&(ht=ht[ot]),ht)if(L>=0&&L<=g.width-B&&O>=0&&O<=g.height-U){mt.bindFramebuffer(b.FRAMEBUFFER,ht);const bt=g.textures[ft],wt=bt.format,yt=bt.type;if(!Rt.textureFormatReadable(wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Rt.textureTypeReadable(yt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const zt=b.createBuffer();b.bindBuffer(b.PIXEL_PACK_BUFFER,zt),b.bufferData(b.PIXEL_PACK_BUFFER,J.byteLength,b.STREAM_READ),g.textures.length>1&&b.readBuffer(b.COLOR_ATTACHMENT0+ft),b.readPixels(L,O,B,U,xt.convert(wt),xt.convert(yt),0);const Yt=F!==null?_t.get(F).__webglFramebuffer:null;mt.bindFramebuffer(b.FRAMEBUFFER,Yt);const re=b.fenceSync(b.SYNC_GPU_COMMANDS_COMPLETE,0);return b.flush(),await Al(b,re,4),b.bindBuffer(b.PIXEL_PACK_BUFFER,zt),b.getBufferSubData(b.PIXEL_PACK_BUFFER,0,J),b.deleteBuffer(zt),b.deleteSync(re),J}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(g,L=null,O=0){const B=Math.pow(2,-O),U=Math.floor(g.image.width*B),J=Math.floor(g.image.height*B),ot=L!==null?L.x:0,ft=L!==null?L.y:0;Nt.setTexture2D(g,0),b.copyTexSubImage2D(b.TEXTURE_2D,O,0,0,ot,ft,U,J),mt.unbindTexture()};const Io=b.createFramebuffer(),No=b.createFramebuffer();this.copyTextureToTexture=function(g,L,O=null,B=null,U=0,J=null){J===null&&(U!==0?(xi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),J=U,U=0):J=0);let ot,ft,ht,bt,wt,yt,zt,Yt,re;const Jt=g.isCompressedTexture?g.mipmaps[J]:g.image;if(O!==null)ot=O.max.x-O.min.x,ft=O.max.y-O.min.y,ht=O.isBox3?O.max.z-O.min.z:1,bt=O.min.x,wt=O.min.y,yt=O.isBox3?O.min.z:0;else{const Pe=Math.pow(2,-U);ot=Math.floor(Jt.width*Pe),ft=Math.floor(Jt.height*Pe),g.isDataArrayTexture?ht=Jt.depth:g.isData3DTexture?ht=Math.floor(Jt.depth*Pe):ht=1,bt=0,wt=0,yt=0}B!==null?(zt=B.x,Yt=B.y,re=B.z):(zt=0,Yt=0,re=0);const Zt=xt.convert(L.format),Tt=xt.convert(L.type);let ne;L.isData3DTexture?(Nt.setTexture3D(L,0),ne=b.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(Nt.setTexture2DArray(L,0),ne=b.TEXTURE_2D_ARRAY):(Nt.setTexture2D(L,0),ne=b.TEXTURE_2D),b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,L.flipY),b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),b.pixelStorei(b.UNPACK_ALIGNMENT,L.unpackAlignment);const Vt=b.getParameter(b.UNPACK_ROW_LENGTH),be=b.getParameter(b.UNPACK_IMAGE_HEIGHT),Fn=b.getParameter(b.UNPACK_SKIP_PIXELS),Ae=b.getParameter(b.UNPACK_SKIP_ROWS),li=b.getParameter(b.UNPACK_SKIP_IMAGES);b.pixelStorei(b.UNPACK_ROW_LENGTH,Jt.width),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,Jt.height),b.pixelStorei(b.UNPACK_SKIP_PIXELS,bt),b.pixelStorei(b.UNPACK_SKIP_ROWS,wt),b.pixelStorei(b.UNPACK_SKIP_IMAGES,yt);const ie=g.isDataArrayTexture||g.isData3DTexture,Ce=L.isDataArrayTexture||L.isData3DTexture;if(g.isDepthTexture){const Pe=_t.get(g),ve=_t.get(L),Se=_t.get(Pe.__renderTarget),cr=_t.get(ve.__renderTarget);mt.bindFramebuffer(b.READ_FRAMEBUFFER,Se.__webglFramebuffer),mt.bindFramebuffer(b.DRAW_FRAMEBUFFER,cr.__webglFramebuffer);for(let Mn=0;Mn<ht;Mn++)ie&&(b.framebufferTextureLayer(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,_t.get(g).__webglTexture,U,yt+Mn),b.framebufferTextureLayer(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,_t.get(L).__webglTexture,J,re+Mn)),b.blitFramebuffer(bt,wt,ot,ft,zt,Yt,ot,ft,b.DEPTH_BUFFER_BIT,b.NEAREST);mt.bindFramebuffer(b.READ_FRAMEBUFFER,null),mt.bindFramebuffer(b.DRAW_FRAMEBUFFER,null)}else if(U!==0||g.isRenderTargetTexture||_t.has(g)){const Pe=_t.get(g),ve=_t.get(L);mt.bindFramebuffer(b.READ_FRAMEBUFFER,Io),mt.bindFramebuffer(b.DRAW_FRAMEBUFFER,No);for(let Se=0;Se<ht;Se++)ie?b.framebufferTextureLayer(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,Pe.__webglTexture,U,yt+Se):b.framebufferTexture2D(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,Pe.__webglTexture,U),Ce?b.framebufferTextureLayer(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,ve.__webglTexture,J,re+Se):b.framebufferTexture2D(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,ve.__webglTexture,J),U!==0?b.blitFramebuffer(bt,wt,ot,ft,zt,Yt,ot,ft,b.COLOR_BUFFER_BIT,b.NEAREST):Ce?b.copyTexSubImage3D(ne,J,zt,Yt,re+Se,bt,wt,ot,ft):b.copyTexSubImage2D(ne,J,zt,Yt,bt,wt,ot,ft);mt.bindFramebuffer(b.READ_FRAMEBUFFER,null),mt.bindFramebuffer(b.DRAW_FRAMEBUFFER,null)}else Ce?g.isDataTexture||g.isData3DTexture?b.texSubImage3D(ne,J,zt,Yt,re,ot,ft,ht,Zt,Tt,Jt.data):L.isCompressedArrayTexture?b.compressedTexSubImage3D(ne,J,zt,Yt,re,ot,ft,ht,Zt,Jt.data):b.texSubImage3D(ne,J,zt,Yt,re,ot,ft,ht,Zt,Tt,Jt):g.isDataTexture?b.texSubImage2D(b.TEXTURE_2D,J,zt,Yt,ot,ft,Zt,Tt,Jt.data):g.isCompressedTexture?b.compressedTexSubImage2D(b.TEXTURE_2D,J,zt,Yt,Jt.width,Jt.height,Zt,Jt.data):b.texSubImage2D(b.TEXTURE_2D,J,zt,Yt,ot,ft,Zt,Tt,Jt);b.pixelStorei(b.UNPACK_ROW_LENGTH,Vt),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,be),b.pixelStorei(b.UNPACK_SKIP_PIXELS,Fn),b.pixelStorei(b.UNPACK_SKIP_ROWS,Ae),b.pixelStorei(b.UNPACK_SKIP_IMAGES,li),J===0&&L.generateMipmaps&&b.generateMipmap(ne),mt.unbindTexture()},this.initRenderTarget=function(g){_t.get(g).__webglFramebuffer===void 0&&Nt.setupRenderTarget(g)},this.initTexture=function(g){g.isCubeTexture?Nt.setTextureCube(g,0):g.isData3DTexture?Nt.setTexture3D(g,0):g.isDataArrayTexture||g.isCompressedArrayTexture?Nt.setTexture2DArray(g,0):Nt.setTexture2D(g,0),mt.unbindTexture()},this.resetState=function(){R=0,D=0,F=null,mt.reset(),at.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ke}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=Gt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Gt._getUnpackColorSpace()}}const Ya={type:"change"},Vs={type:"start"},Co={type:"end"},Zi=new co,qa=new dn,kf=Math.cos(70*Tl.DEG2RAD),ce=new N,ye=2*Math.PI,Kt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Vr=1e-6;class lp extends sc{constructor(t,e=null){super(t,e),this.state=Kt.NONE,this.target=new N,this.cursor=new N,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Qn.ROTATE,MIDDLE:Qn.DOLLY,RIGHT:Qn.PAN},this.touches={ONE:$n.ROTATE,TWO:$n.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new N,this._lastQuaternion=new Un,this._lastTargetPosition=new N,this._quat=new Un().setFromUnitVectors(t.up,new N(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Ma,this._sphericalDelta=new Ma,this._scale=1,this._panOffset=new N,this._rotateStart=new Lt,this._rotateEnd=new Lt,this._rotateDelta=new Lt,this._panStart=new Lt,this._panEnd=new Lt,this._panDelta=new Lt,this._dollyStart=new Lt,this._dollyEnd=new Lt,this._dollyDelta=new Lt,this._dollyDirection=new N,this._mouse=new Lt,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Xf.bind(this),this._onPointerDown=Wf.bind(this),this._onPointerUp=Yf.bind(this),this._onContextMenu=Qf.bind(this),this._onMouseWheel=Zf.bind(this),this._onKeyDown=jf.bind(this),this._onTouchStart=$f.bind(this),this._onTouchMove=Jf.bind(this),this._onMouseDown=qf.bind(this),this._onMouseMove=Kf.bind(this),this._interceptControlDown=tp.bind(this),this._interceptControlUp=ep.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Ya),this.update(),this.state=Kt.NONE}update(t=null){const e=this.object.position;ce.copy(e).sub(this.target),ce.applyQuaternion(this._quat),this._spherical.setFromVector3(ce),this.autoRotate&&this.state===Kt.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=ye:n>Math.PI&&(n-=ye),r<-Math.PI?r+=ye:r>Math.PI&&(r-=ye),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(ce.setFromSpherical(this._spherical),ce.applyQuaternion(this._quatInverse),e.copy(this.target).add(ce),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=ce.length();a=this._clampDistance(o*this._scale);const c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const o=new N(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;const l=new N(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=ce.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Zi.origin.copy(this.object.position),Zi.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Zi.direction))<kf?this.object.lookAt(this.target):(qa.setFromNormalAndCoplanarPoint(this.object.up,this.target),Zi.intersectPlane(qa,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Vr||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Vr||this._lastTargetPosition.distanceToSquared(this.target)>Vr?(this.dispatchEvent(Ya),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?ye/60*this.autoRotateSpeed*t:ye/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){ce.setFromMatrixColumn(e,0),ce.multiplyScalar(-t),this._panOffset.add(ce)}_panUp(t,e){this.screenSpacePanning===!0?ce.setFromMatrixColumn(e,1):(ce.setFromMatrixColumn(e,0),ce.crossVectors(this.object.up,ce)),ce.multiplyScalar(t),this._panOffset.add(ce)}_pan(t,e){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;ce.copy(r).sub(this.target);let s=ce.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*s/n.clientHeight,this.object.matrix),this._panUp(2*e*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),r=t-n.left,s=e-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(ye*this._rotateDelta.x/e.clientHeight),this._rotateUp(ye*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(ye*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-ye*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(ye*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-ye*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);this._panStart.set(n,r)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,r=t.pageY-e.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),r=.5*(t.pageX+n.x),s=.5*(t.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(ye*this._rotateDelta.x/e.clientHeight),this._rotateUp(ye*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),r=.5*(t.pageY+e.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,r=t.pageY-e.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(t.pageX+e.x)*.5,o=(t.pageY+e.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new Lt,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Wf(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function Xf(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function Yf(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Co),this.state=Kt.NONE;break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function qf(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Qn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Kt.DOLLY;break;case Qn.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Kt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Kt.ROTATE}break;case Qn.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Kt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Kt.PAN}break;default:this.state=Kt.NONE}this.state!==Kt.NONE&&this.dispatchEvent(Vs)}function Kf(i){switch(this.state){case Kt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Kt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Kt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function Zf(i){this.enabled===!1||this.enableZoom===!1||this.state!==Kt.NONE||(i.preventDefault(),this.dispatchEvent(Vs),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Co))}function jf(i){this.enabled!==!1&&this._handleKeyDown(i)}function $f(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case $n.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Kt.TOUCH_ROTATE;break;case $n.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Kt.TOUCH_PAN;break;default:this.state=Kt.NONE}break;case 2:switch(this.touches.TWO){case $n.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Kt.TOUCH_DOLLY_PAN;break;case $n.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Kt.TOUCH_DOLLY_ROTATE;break;default:this.state=Kt.NONE}break;default:this.state=Kt.NONE}this.state!==Kt.NONE&&this.dispatchEvent(Vs)}function Jf(i){switch(this._trackPointer(i),this.state){case Kt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Kt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Kt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Kt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Kt.NONE}}function Qf(i){this.enabled!==!1&&i.preventDefault()}function tp(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ep(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}export{ap as A,Ti as B,ip as C,sp as D,Wi as G,Ge as L,rp as M,lp as O,Fe as P,np as S,op as W,ar as a,en as b,rn as c,Pn as d,So as e};