index-ChvSLPwM.js 1.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180
  1. function __vite__mapDeps(indexes) {
  2. if (!__vite__mapDeps.viteFileDeps) {
  3. __vite__mapDeps.viteFileDeps = ["assets/howler-BzJY10nd.js","assets/_commonjsHelpers-Cpj98o6Y.js"]
  4. }
  5. return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
  6. }
  7. import{h as fo,p as Zt,F as ki,c as Ci,t as ua,z as ne,J as pi,x as mo,y as go,k as ti,M as jh,N as B2,v as wr,O as cD,Q as wx,R as ps,S as vo,T as dD,C as _x,U as Sx,q as Mn}from"./index-DhgeYuDI.js";import{o as uD,B as Ao}from"./index-4BuJZDJK.js";import{C as Ja}from"./vue3-count-to.esm-BMZ192BS.js";import{_ as zy}from"./index-DZAk9A4j.js";import{e as Wf}from"./index-B9bA2oXO.js";/* empty css */import{_ as F2,a as U2,b as N2}from"./button-icon-ByvyKiiQ.js";import"./omit-CgmmeuJY.js";const k2="/assets/img3-BIZtH8ZX.png",V2="/assets/img4-CVioGhgl.png",j2="/assets/img5-WJyEcHFi.png",G2="/assets/img8-BEdljHQR.png",H2="/assets/img1-TewenZ-t.png",W2="/assets/img2-Chvan6Xs.png",q2="/assets/img6-BoR3fMmO.png",X2="/assets/img7-RAwr14hh.png",Cr=e=>(mo("data-v-daf4835a"),e=e(),go(),e),pD={class:"the-box1"},fD={class:"box1-item"},mD=Cr(()=>ne("img",{src:k2,alt:""},null,-1)),gD={class:"box1-item-info"},vD=Cr(()=>ne("div",null,"机构床位统计",-1)),yD={class:"box1-item-num"},xD={class:"box1-item"},bD=Cr(()=>ne("img",{src:V2,alt:""},null,-1)),wD={class:"box1-item-info"},_D=Cr(()=>ne("div",null,"开放床位数",-1)),SD={class:"box1-item-num"},AD={class:"box1-item"},MD=Cr(()=>ne("img",{src:j2,alt:""},null,-1)),ED={class:"box1-item-info"},CD=Cr(()=>ne("div",null,"在住床位数",-1)),TD={class:"box1-item-num"},PD={class:"box1-item"},DD=Cr(()=>ne("img",{src:G2,alt:""},null,-1)),ID={class:"box1-item-info"},OD=Cr(()=>ne("div",null,"退住数",-1)),RD={class:"box1-item-num"},LD={class:"box1-item"},zD=Cr(()=>ne("img",{src:H2,alt:""},null,-1)),BD={class:"box1-item-info"},FD=Cr(()=>ne("div",null,"社区店",-1)),UD={class:"box1-item-num"},ND={class:"box1-item"},kD=Cr(()=>ne("img",{src:W2,alt:""},null,-1)),VD={class:"box1-item-info"},jD=Cr(()=>ne("div",null,"年体验服务人次",-1)),GD={class:"box1-item-num"},HD={class:"box1-item"},WD=Cr(()=>ne("img",{src:q2,alt:""},null,-1)),qD={class:"box1-item-info"},XD=Cr(()=>ne("div",null,"年服务人次",-1)),YD={class:"box1-item-num"},QD={class:"box1-item"},ZD=Cr(()=>ne("img",{src:X2,alt:""},null,-1)),KD={class:"box1-item-info"},JD=Cr(()=>ne("div",null,"年配餐人次",-1)),$D={class:"box1-item-num"},e3={__name:"box1",props:{overviewStatisticsData:{type:Object,default:{planBedCount:0,presetCount:0}}},setup(e){return(t,i)=>{const r=zy;return Zt(),ki("div",pD,[Ci(r,{wrap:"wrap"},{default:ua(()=>[ne("div",fD,[mD,ne("div",gD,[vD,ne("div",yD,pi(e.overviewStatisticsData.planBedCount),1)])]),ne("div",xD,[bD,ne("div",wD,[_D,ne("div",SD,pi(e.overviewStatisticsData.openBedCount),1)])]),ne("div",AD,[MD,ne("div",ED,[CD,ne("div",TD,pi(e.overviewStatisticsData.checkInCount),1)])]),ne("div",PD,[DD,ne("div",ID,[OD,ne("div",RD,pi(e.overviewStatisticsData.retreatCount),1)])]),ne("div",LD,[zD,ne("div",BD,[FD,ne("div",UD,pi(e.overviewStatisticsData.communityCount),1)])]),ne("div",ND,[kD,ne("div",VD,[jD,ne("div",GD,pi(e.overviewStatisticsData.serviceCount),1)])]),ne("div",HD,[WD,ne("div",qD,[XD,ne("div",YD,pi(e.overviewStatisticsData.homeBasedServiceCount),1)])]),ne("div",QD,[ZD,ne("div",KD,[JD,ne("div",$D,pi(e.overviewStatisticsData.homeBasedCateringCount),1)])])]),_:1})])}}},t3=fo(e3,[["__scopeId","data-v-daf4835a"]]),Tr=e=>(mo("data-v-7144156d"),e=e(),go(),e),i3={class:"the-box1"},r3={class:"box1-item"},s3=Tr(()=>ne("img",{src:H2,alt:""},null,-1)),a3={class:"box1-item-info"},n3=Tr(()=>ne("div",null,"总床位",-1)),o3={class:"box1-item-num"},l3={class:"box1-item"},h3=Tr(()=>ne("img",{src:W2,alt:""},null,-1)),c3={class:"box1-item-info"},d3=Tr(()=>ne("div",null,"预定数",-1)),u3={class:"box1-item-num"},p3={class:"box1-item"},f3=Tr(()=>ne("img",{src:k2,alt:""},null,-1)),m3={class:"box1-item-info"},g3=Tr(()=>ne("div",null,"已入住",-1)),v3={class:"box1-item-num"},y3={class:"box1-item"},x3=Tr(()=>ne("img",{src:V2,alt:""},null,-1)),b3={class:"box1-item-info"},w3=Tr(()=>ne("div",null,"空床位",-1)),_3={class:"box1-item-num"},S3={class:"box1-item"},A3=Tr(()=>ne("img",{src:j2,alt:""},null,-1)),M3={class:"box1-item-info"},E3=Tr(()=>ne("div",null,"入住率",-1)),C3={class:"box1-item-num"},T3={class:"box1-item"},P3=Tr(()=>ne("img",{src:q2,alt:""},null,-1)),D3={class:"box1-item-info"},I3=Tr(()=>ne("div",null,"员工数",-1)),O3={class:"box1-item-num"},R3={class:"box1-item"},L3=Tr(()=>ne("img",{src:X2,alt:""},null,-1)),z3={class:"box1-item-info"},B3=Tr(()=>ne("div",null,"护工数",-1)),F3={class:"box1-item-num"},U3={class:"box1-item"},N3=Tr(()=>ne("img",{src:G2,alt:""},null,-1)),k3={class:"box1-item-info"},V3=Tr(()=>ne("div",null,"退住数",-1)),j3={class:"box1-item-num"},G3={__name:"box1_2",props:{overviewStatisticsData:{type:Object,default:{planBedCount:0,presetCount:0}}},setup(e){return(t,i)=>{const r=zy;return Zt(),ki("div",i3,[Ci(r,{wrap:"wrap"},{default:ua(()=>[ne("div",r3,[s3,ne("div",a3,[n3,ne("div",o3,pi(e.overviewStatisticsData.bedCount),1)])]),ne("div",l3,[h3,ne("div",c3,[d3,ne("div",u3,pi(e.overviewStatisticsData.presetCount),1)])]),ne("div",p3,[f3,ne("div",m3,[g3,ne("div",v3,pi(e.overviewStatisticsData.checkInCount),1)])]),ne("div",y3,[x3,ne("div",b3,[w3,ne("div",_3,pi(e.overviewStatisticsData.emptyBedCount),1)])]),ne("div",S3,[A3,ne("div",M3,[E3,ne("div",C3,pi(e.overviewStatisticsData.occupancyRate),1)])]),ne("div",T3,[P3,ne("div",D3,[I3,ne("div",O3,pi(e.overviewStatisticsData.userCount),1)])]),ne("div",R3,[L3,ne("div",z3,[B3,ne("div",F3,pi(e.overviewStatisticsData.caregiverCount),1)])]),ne("div",U3,[N3,ne("div",k3,[V3,ne("div",j3,pi(e.overviewStatisticsData.retreatCount),1)])])]),_:1})])}}},H3=fo(G3,[["__scopeId","data-v-7144156d"]]),W3=e=>(mo("data-v-83895e41"),e=e(),go(),e),q3={class:"the-box2"},X3=W3(()=>ne("div",{id:"indexBox2BarEcharts",class:"indexBox2BarEcharts"},null,-1)),Y3=[X3],Q3={__name:"box2",props:{box2_data:{type:Object,default:{}}},setup(e){const t=Wf,i=ti(null),r=e;jh(()=>{i.value=r.box2_data,s()});function s(){const a=t.init(document.getElementById("indexBox2BarEcharts"));a.setOption({grid:{right:10,bottom:30,top:20},xAxis:{type:"category",splitLine:{show:!1},axisLine:{show:!1},axisTick:{show:!1},data:i.value.xaxis.map(n=>n),axisLabel:{color:"#A3C2CC",fontSize:16}},yAxis:{type:"value",splitLine:{show:!1},axisLabel:{color:"#A3C2CC",fontSize:16}},tooltip:{show:!0,trigger:"item",azisPointer:{type:""},backgroundColor:"rgba(24, 31, 64, 0.9)",color:"#ffffff",padding:0,borderColor:"transparent"},series:[{data:i.value.series.map(n=>n),type:"bar",showBackground:!0,backgroundStyle:{color:"rgba(40,80,132,0.2)"},barWidth:15,color:"#10E2A1",itemStyle:{color:"#10E2A1",borderRadius:5},label:{normal:{show:!0,position:"top",color:"#ffffff"},formatter:"{@value}"}},{data:i.value.series.map(n=>n),type:"line",color:"#0088FF",smooth:.5,itemStyle:{color:"#0088FF"},lineStyle:{width:4}}]}),window.onresize=function(){a.resize()}}return(a,n)=>(Zt(),ki("div",q3,Y3))}},Z3=fo(Q3,[["__scopeId","data-v-83895e41"]]),K3=e=>(mo("data-v-9995df7e"),e=e(),go(),e),J3={class:"the-box3"},$3=K3(()=>ne("div",{id:"indexBox6PieEchart66s",class:"indexBox6PieEcharts"},null,-1)),eI=[$3],tI={__name:"box3",props:{box3_data:{type:Object,default:{}}},emits:["set_listdata"],setup(e,{emit:t}){const i=Wf;B2();const r=e,s=ti(null);jh(()=>{s.value=r.box3_data,a()});function a(){let n={tooltip:{trigger:"item",show:!1},legend:{show:!1},series:[{type:"pie",radius:["40%","60%"],avoidLabelOverlap:!0,padAngle:2,itemStyle:{borderRadius:0},label:{show:!0,position:"outside",formatter:function(l){return`${l.data.name}${l.data.typeRatio}%`},color:"#C3CED9",fontSize:15},labelLine:{show:!0,length:10,length2:50,minTurnAngle:150,smooth:.5,lineStyle:{width:1,cap:"round",type:"dashed",fontSize:16}},emphasis:{label:{show:!1}},data:s.value.map((l,h)=>{const c=["#32C5FF","#33CC72","#FA6400","#FFCC66","#3399FF"];return{typeRatio:l.typeRatio,value:l.typeCount,name:l.typeName,labelLine:{lineStyle:{color:c[h]}},itemStyle:{color:c[h]},fontSize:16}})}]},o=i.getInstanceByDom(document.getElementById("indexBox6PieEchart66s"));o?o.clear():o=i.init(document.getElementById("indexBox6PieEchart66s")),o.setOption(n),window.onresize=function(){o.resize()}}return(n,o)=>(Zt(),ki("div",J3,eI))}},iI=fo(tI,[["__scopeId","data-v-9995df7e"]]),By="/assets/img-DJ4lsvjZ.png",Fy="/assets/img-name-C7ByjlUk.png",rI="/assets/img-title-C4ykapfs.png",wn=e=>(mo("data-v-1e4f3938"),e=e(),go(),e),sI={class:"the-box6"},aI={class:"box6-title"},nI={class:"box6-title-item"},oI={class:"box6-title-item-num"},lI=wn(()=>ne("img",{src:By,alt:""},null,-1)),hI={class:"box6-title-item-text"},cI=wn(()=>ne("span",{class:"showspan"}," 人",-1)),dI=wn(()=>ne("div",{class:"box6-title-item-type"},[ne("img",{src:Fy,alt:""}),ne("div",{class:"box6-title-item-text"},"户籍")],-1)),uI={class:"box6-title-item"},pI={class:"box6-title-item-num"},fI=wn(()=>ne("img",{src:By,alt:""},null,-1)),mI={class:"box6-title-item-text"},gI=wn(()=>ne("span",{class:"showspan"}," 人",-1)),vI=wn(()=>ne("div",{class:"box6-title-item-type"},[ne("img",{src:Fy,alt:""}),ne("div",{class:"box6-title-item-text"},"非户籍")],-1)),yI={class:"box6-title-item"},xI={class:"box6-title-item-num"},bI=wn(()=>ne("img",{src:By,alt:""},null,-1)),wI={class:"box6-title-item-text"},_I=wn(()=>ne("span",{class:"showspan"}," 人",-1)),SI=wn(()=>ne("div",{class:"box6-title-item-type"},[ne("img",{src:Fy,alt:""}),ne("div",{class:"box6-title-item-text"},"未知")],-1)),AI=cD('<div class="box6-content" data-v-1e4f3938><div class="box6-content-title" data-v-1e4f3938><img src="'+rI+'" alt="" data-v-1e4f3938><div class="box6-content-title-text" data-v-1e4f3938>经济来源统计</div></div><div class="indexBox6PieEchartsWrap" data-v-1e4f3938><div id="indexBox6PieEchart68s" class="indexBox6PieEcharts" data-v-1e4f3938></div></div></div>',1),MI={__name:"box6",props:{box6_data:{type:Object,default:{}}},setup(e){const t=Wf,i=ti(!1),r=ti({}),s=ti([]),a=e;jh(()=>{if(r.value=a.box6_data.household,a.box6_data.economic){let o=a.box6_data.economic,l=[{name:"养老保险",value:o.endowmentInsurance,valueradio:o.endowmentInsuranceRatio},{name:"城市低保",value:o.cityLowIncome,valueradio:o.cityLowIncomeRatio},{name:"子女供养",value:o.childrenSupport,valueradio:o.childrenSupportRatio},{name:"家庭存款",value:o.familyDeposit,valueradio:o.familyDepositRatio},{name:"离退休金",value:o.retirementPay,valueradio:o.retirementPayRatio},{name:"五保",value:o.fiveGuarantees,valueradio:o.fiveGuaranteesRatio},{name:"抚恤金",value:o.pension,valueradio:o.pensionRatio},{name:"商业保险",value:o.commercialInsurance,valueradio:o.commercialInsuranceRatio},{name:"其它",value:o.other,valueradio:o.otherRatio}];s.value=l,i.value=!0,n()}});function n(){console.log(1111);let o={tooltip:{trigger:"item",show:!1},legend:{show:!1},series:[{type:"pie",radius:["40%","60%"],avoidLabelOverlap:!0,padAngle:2,itemStyle:{borderRadius:0},label:{show:!0,position:"outside",formatter:function(h){return`${h.data.name} (${h.data.Ratio}%)`},color:"#C3CED9",fontSize:16},labelLine:{show:!0,length:10,length2:70,minTurnAngle:150,smooth:.5,lineStyle:{width:1,cap:"round",type:"dashed"}},emphasis:{label:{show:!1}},data:s.value.map((h,c)=>{const d=["#32C5FF","#33CC72","#FA6400","#FFCC66","#3399FF","#32C5FF","#33CC72","#FA6400","#FFCC66"];return{value:h.value,name:h.name,Ratio:h.valueradio,labelLine:{lineStyle:{color:d[c]}},itemStyle:{color:d[c]}}})}]},l=t.getInstanceByDom(document.getElementById("indexBox6PieEchart68s"));l=t.init(document.getElementById("indexBox6PieEchart68s")),console.log(o),l.setOption(o),l.resize(),window.onresize=function(){l.resize()}}return(o,l)=>(Zt(),ki("div",sI,[ne("div",aI,[ne("div",nI,[ne("div",oI,[lI,ne("div",hI,[Ci(wr(Ja),{"start-val":0,"end-val":r.value.householdTotal,duration:2600,class:"card-panel-num"},null,8,["end-val"]),cI])]),dI]),ne("div",uI,[ne("div",pI,[fI,ne("div",mI,[Ci(wr(Ja),{"start-val":0,"end-val":r.value.nonHouseholdTotal,duration:2600,class:"card-panel-num"},null,8,["end-val"]),gI])]),vI]),ne("div",yI,[ne("div",xI,[bI,ne("div",wI,[Ci(wr(Ja),{"start-val":0,"end-val":r.value.unknownTotal,duration:2600,class:"card-panel-num"},null,8,["end-val"]),_I])]),SI])]),AI]))}},EI=fo(MI,[["__scopeId","data-v-1e4f3938"]]),CI=e=>(mo("data-v-cb622758"),e=e(),go(),e),TI={class:"the-box7"},PI=CI(()=>ne("div",{id:"indexBox7BarEcharts",class:"indexBox7BarEcharts"},null,-1)),DI=[PI],II={__name:"box7",props:{box7_data:{type:Object,default:{}}},setup(e){const t=Wf,i=ti(null),r=e;jh(()=>{i.value=r.box7_data,s()});function s(){const a=t.init(document.getElementById("indexBox7BarEcharts"));a.setOption({grid:{right:10,bottom:30,top:20},xAxis:{type:"category",splitLine:{show:!1},axisLine:{show:!1},axisTick:{show:!1},data:i.value.xaxis.map(n=>n),axisLabel:{color:"#A3C2CC",fontSize:16}},yAxis:{type:"value",splitLine:{show:!1},axisLabel:{color:"#A3C2CC",fontSize:16}},series:[{data:i.value.series.map(n=>n),type:"bar",showBackground:!0,backgroundStyle:{color:"rgba(40,80,132,0.2)"},barWidth:15,color:"#31B3FF",itemStyle:{color:"#31B3FF",borderRadius:5},label:{normal:{show:!0,position:"top",color:"#ffffff"},formatter:"{@value}"}}]}),window.onresize=function(){a.resize()}}return(a,n)=>(Zt(),ki("div",TI,DI))}},OI=fo(II,[["__scopeId","data-v-cb622758"]]),RI="/assets/img1-B14zFtzx.png",LI="/assets/img2-BClo_7M5.png",zI="/assets/img3-B_b_Fv0N.png",BI="/assets/img4-WEfXPLlm.png",FI="/assets/img5-Coz65H-P.png",UI="/assets/img6-vWKTdQVS.png",yo=e=>(mo("data-v-f0e0c78d"),e=e(),go(),e),NI={class:"the-box8"},kI={class:"change-num"},VI={key:0,class:"btn",src:F2,alt:""},jI={key:1,class:"icon",src:U2,alt:""},GI={key:2,class:"icon",src:N2,alt:""},HI=yo(()=>ne("div",{class:"text"},"本月",-1)),WI={key:0,class:"btn",src:F2,alt:""},qI={key:1,class:"icon",src:U2,alt:""},XI={key:2,class:"icon",src:N2,alt:""},YI=yo(()=>ne("div",{class:"text"},"今日",-1)),QI={class:"box8-item"},ZI=yo(()=>ne("img",{src:RI,alt:""},null,-1)),KI={class:"box8-item-info"},JI={class:"box8-item-num"},$I={class:"box8-item"},eO=yo(()=>ne("img",{src:LI,alt:""},null,-1)),tO={class:"box8-item-info"},iO={class:"box8-item-num"},rO={class:"box8-item"},sO=yo(()=>ne("img",{src:zI,alt:""},null,-1)),aO={class:"box8-item-info"},nO={class:"box8-item-num"},oO={class:"box8-item"},lO=yo(()=>ne("img",{src:BI,alt:""},null,-1)),hO={class:"box8-item-info"},cO={class:"box8-item-num"},dO={class:"box8-item"},uO=yo(()=>ne("img",{src:FI,alt:""},null,-1)),pO={class:"box8-item-info"},fO={class:"box8-item-num"},mO={class:"box8-item"},gO=yo(()=>ne("img",{src:UI,alt:""},null,-1)),vO={class:"box8-item-info"},yO={class:"box8-item-num"},xO={__name:"box8",props:{businessStatisticsDats:{type:Object,default:{}}},setup(e){const t=ti("month"),i=r=>{t.value=r,t.value};return(r,s)=>{const a=zy;return Zt(),ki("div",NI,[ne("div",kI,[ne("div",{class:wx(["change-num-item",{isActive:t.value==="month"}]),onClick:s[0]||(s[0]=n=>i("month"))},[t.value==="month"?(Zt(),ki("img",VI)):ps("",!0),t.value==="month"?(Zt(),ki("img",jI)):(Zt(),ki("img",GI)),HI],2),ne("div",{class:wx(["change-num-item",{isActive:t.value==="day"}]),onClick:s[1]||(s[1]=n=>i("day"))},[t.value==="day"?(Zt(),ki("img",WI)):ps("",!0),t.value==="day"?(Zt(),ki("img",qI)):(Zt(),ki("img",XI)),YI],2)]),Ci(a,{wrap:"wrap"},{default:ua(()=>[ne("div",QI,[ZI,ne("div",KI,[ne("div",null,pi(t.value=="month"?"本月":"今日")+"咨询",1),ne("div",JI,[Ci(wr(Ja),{"start-val":0,"end-val":e.businessStatisticsDats.consultationCheckInCount,duration:2600,class:"card-panel-num"},null,8,["end-val"])])])]),ne("div",$I,[eO,ne("div",tO,[ne("div",null,pi(t.value=="month"?"本月":"今日")+"预订",1),ne("div",iO,[Ci(wr(Ja),{"start-val":0,"end-val":e.businessStatisticsDats.presetCount,duration:2600,class:"card-panel-num"},null,8,["end-val"])])])]),ne("div",rO,[sO,ne("div",aO,[ne("div",null,pi(t.value=="month"?"本月":"今日")+"试住",1),ne("div",nO,[Ci(wr(Ja),{"start-val":0,"end-val":e.businessStatisticsDats.tryStayCount,duration:2600,class:"card-panel-num"},null,8,["end-val"])])])]),ne("div",oO,[lO,ne("div",hO,[ne("div",null,pi(t.value=="month"?"本月":"今日")+"外出",1),ne("div",cO,[Ci(wr(Ja),{"start-val":0,"end-val":e.businessStatisticsDats.goOutCount,duration:2600,class:"card-panel-num"},null,8,["end-val"])])])]),ne("div",dO,[uO,ne("div",pO,[ne("div",null,pi(t.value=="month"?"本月":"今日")+"入住",1),ne("div",fO,[Ci(wr(Ja),{"start-val":0,"end-val":e.businessStatisticsDats.checkInCount,duration:2600,class:"card-panel-num"},null,8,["end-val"])])])]),ne("div",mO,[gO,ne("div",vO,[ne("div",null,pi(t.value=="month"?"本月":"今日")+"探视",1),ne("div",yO,[Ci(wr(Ja),{"start-val":0,"end-val":e.businessStatisticsDats.visitCount,duration:2600,class:"card-panel-num"},null,8,["end-val"])])])])]),_:1})])}}},bO=fo(xO,[["__scopeId","data-v-f0e0c78d"]]);var wO=Object.create,qf=Object.defineProperty,_O=Object.getOwnPropertyDescriptor,SO=Object.getOwnPropertyNames,AO=Object.getPrototypeOf,MO=Object.prototype.hasOwnProperty,EO=(e,t,i)=>t in e?qf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,fl=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),CO=(e,t)=>{for(var i in t)qf(e,i,{get:t[i],enumerable:!0})},TO=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of SO(t))!MO.call(e,s)&&s!==i&&qf(e,s,{get:()=>t[s],enumerable:!(r=_O(t,s))||r.enumerable});return e},xo=(e,t,i)=>(i=e!=null?wO(AO(e)):{},TO(t||!e||!e.__esModule?qf(i,"default",{value:e,enumerable:!0}):i,e)),Bc=(e,t,i)=>(EO(e,typeof t!="symbol"?t+"":t,i),i),PO=fl((e,t)=>{(function(i,r){typeof e=="object"?t.exports=r():typeof define=="function"&&define.amd?define(r):i.Alea=r()})(e,function(){return i.importState=function(s){var a=new i;return a.importState(s),a},i;function i(){return function(s){var a=0,n=0,o=0,l=1;s.length==0&&(s=[+new Date]);var h=r();a=h(" "),n=h(" "),o=h(" ");for(var c=0;c<s.length;c++)a-=h(s[c]),a<0&&(a+=1),n-=h(s[c]),n<0&&(n+=1),o-=h(s[c]),o<0&&(o+=1);h=null;var d=function(){var u=2091639*a+l*23283064365386963e-26;return a=n,n=o,o=u-(l=u|0)};return d.next=d,d.uint32=function(){return d()*4294967296},d.fract53=function(){return d()+(d()*2097152|0)*11102230246251565e-32},d.version="Alea 0.9",d.args=s,d.exportState=function(){return[a,n,o,l]},d.importState=function(u){a=+u[0]||0,n=+u[1]||0,o=+u[2]||0,l=+u[3]||0},d}(Array.prototype.slice.call(arguments))}function r(){var s=4022871197,a=function(n){n=n.toString();for(var o=0;o<n.length;o++){s+=n.charCodeAt(o);var l=.02519603282416938*s;s=l>>>0,l-=s,l*=s,s=l>>>0,l-=s,s+=l*4294967296}return(s>>>0)*23283064365386963e-26};return a.version="Mash 0.9",a}})}),Y2=fl((e,t)=>{(function(i,r){typeof e=="object"&&typeof t<"u"?r(e):typeof define=="function"&&define.amd?define(["exports"],r):r((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(e,function(i){i.SVD=function(r,s,a,n,o){if(s=s===void 0||s,a=a===void 0||a,o=1e-64/(n=n||Math.pow(2,-52)),!r)throw new TypeError("Matrix a is not defined");var l,h,c,d,u,p,f,g,m,v,y,x,w=r[0].length,_=r.length;if(_<w)throw new TypeError("Invalid matrix: m < n");for(var b=[],A=[],S=[],E=s==="f"?_:w,C=v=f=0;C<_;C++)A[C]=new Array(E).fill(0);for(C=0;C<w;C++)S[C]=new Array(w).fill(0);var T,D=new Array(w).fill(0);for(C=0;C<_;C++)for(l=0;l<w;l++)A[C][l]=r[C][l];for(C=0;C<w;C++){for(b[C]=f,m=0,c=C+1,l=C;l<_;l++)m+=Math.pow(A[l][C],2);if(m<o)f=0;else for(g=(p=A[C][C])*(f=p<0?Math.sqrt(m):-Math.sqrt(m))-m,A[C][C]=p-f,l=c;l<w;l++){for(m=0,h=C;h<_;h++)m+=A[h][C]*A[h][l];for(p=m/g,h=C;h<_;h++)A[h][l]=A[h][l]+p*A[h][C]}for(D[C]=f,m=0,l=c;l<w;l++)m+=Math.pow(A[C][l],2);if(m<o)f=0;else{for(g=(p=A[C][C+1])*(f=p<0?Math.sqrt(m):-Math.sqrt(m))-m,A[C][C+1]=p-f,l=c;l<w;l++)b[l]=A[C][l]/g;for(l=c;l<_;l++){for(m=0,h=c;h<w;h++)m+=A[l][h]*A[C][h];for(h=c;h<w;h++)A[l][h]=A[l][h]+m*b[h]}}v<(y=Math.abs(D[C])+Math.abs(b[C]))&&(v=y)}if(a)for(C=w-1;0<=C;C--){if(f!==0){for(g=A[C][C+1]*f,l=c;l<w;l++)S[l][C]=A[C][l]/g;for(l=c;l<w;l++){for(m=0,h=c;h<w;h++)m+=A[C][h]*S[h][l];for(h=c;h<w;h++)S[h][l]=S[h][l]+m*S[h][C]}}for(l=c;l<w;l++)S[C][l]=0,S[l][C]=0;S[C][C]=1,f=b[C],c=C}if(s){if(s==="f")for(C=w;C<_;C++){for(l=w;l<_;l++)A[C][l]=0;A[C][C]=1}for(C=w-1;0<=C;C--){for(c=C+1,f=D[C],l=c;l<E;l++)A[C][l]=0;if(f!==0){for(g=A[C][C]*f,l=c;l<E;l++){for(m=0,h=c;h<_;h++)m+=A[h][C]*A[h][l];for(p=m/g,h=C;h<_;h++)A[h][l]=A[h][l]+p*A[h][C]}for(l=C;l<_;l++)A[l][C]=A[l][C]/f}else for(l=C;l<_;l++)A[l][C]=0;A[C][C]=A[C][C]+1}}for(n*=v,h=w-1;0<=h;h--)for(var O=0;O<50;O++){for(T=!1,c=h;0<=c;c--){if(Math.abs(b[c])<=n){T=!0;break}if(Math.abs(D[c-1])<=n)break}if(!T){for(u=0,d=c-(m=1),C=c;C<h+1&&(p=m*b[C],b[C]=u*b[C],!(Math.abs(p)<=n));C++)if(f=D[C],D[C]=Math.sqrt(p*p+f*f),u=f/(g=D[C]),m=-p/g,s)for(l=0;l<_;l++)y=A[l][d],x=A[l][C],A[l][d]=y*u+x*m,A[l][C]=-y*m+x*u}if(x=D[h],c===h){if(x<0&&(D[h]=-x,a))for(l=0;l<w;l++)S[l][h]=-S[l][h];break}for(v=D[c],p=(((y=D[h-1])-x)*(y+x)+((f=b[h-1])-(g=b[h]))*(f+g))/(2*g*y),f=Math.sqrt(p*p+1),p=((v-x)*(v+x)+g*(y/(p<0?p-f:p+f)-g))/v,C=c+(m=u=1);C<h+1;C++){if(f=b[C],y=D[C],g=m*f,f*=u,x=Math.sqrt(p*p+g*g),p=v*(u=p/(b[C-1]=x))+f*(m=g/x),f=-v*m+f*u,g=y*m,y*=u,a)for(l=0;l<w;l++)v=S[l][C-1],x=S[l][C],S[l][C-1]=v*u+x*m,S[l][C]=-v*m+x*u;if(x=Math.sqrt(p*p+g*g),p=(u=p/(D[C-1]=x))*f+(m=g/x)*y,v=-m*f+u*y,s)for(l=0;l<_;l++)y=A[l][C-1],x=A[l][C],A[l][C-1]=y*u+x*m,A[l][C]=-y*m+x*u}b[c]=0,b[h]=p,D[h]=v}for(C=0;C<w;C++)D[C]<n&&(D[C]=0);return{u:A,q:D,v:S}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})}),DO=fl((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;function i(r){if(r===null||r===!0||r===!1)return NaN;var s=Number(r);return isNaN(s)?s:s<0?Math.ceil(s):Math.floor(s)}t.exports=e.default}),IO=fl((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;function i(r){var s=new Date(Date.UTC(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours(),r.getMinutes(),r.getSeconds(),r.getMilliseconds()));return s.setUTCFullYear(r.getFullYear()),r.getTime()-s.getTime()}t.exports=e.default}),OO=fl((e,t)=>{function i(a,n){function o(){this.constructor=a}o.prototype=n.prototype,a.prototype=new o}function r(a,n,o,l){this.message=a,this.expected=n,this.found=o,this.location=l,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,r)}i(r,Error),r.buildMessage=function(a,n){var o={literal:function(f){return'"'+h(f.text)+'"'},class:function(f){var g="",m;for(m=0;m<f.parts.length;m++)g+=f.parts[m]instanceof Array?c(f.parts[m][0])+"-"+c(f.parts[m][1]):c(f.parts[m]);return"["+(f.inverted?"^":"")+g+"]"},any:function(f){return"any character"},end:function(f){return"end of input"},other:function(f){return f.description}};function l(f){return f.charCodeAt(0).toString(16).toUpperCase()}function h(f){return f.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(g){return"\\x0"+l(g)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(g){return"\\x"+l(g)})}function c(f){return f.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(g){return"\\x0"+l(g)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(g){return"\\x"+l(g)})}function d(f){return o[f.type](f)}function u(f){var g=new Array(f.length),m,v;for(m=0;m<f.length;m++)g[m]=d(f[m]);if(g.sort(),g.length>0){for(m=1,v=1;m<g.length;m++)g[m-1]!==g[m]&&(g[v]=g[m],v++);g.length=v}switch(g.length){case 1:return g[0];case 2:return g[0]+" or "+g[1];default:return g.slice(0,-1).join(", ")+", or "+g[g.length-1]}}function p(f){return f?'"'+h(f)+'"':"end of input"}return"Expected "+u(a)+" but "+p(n)+" found."};function s(a,n){n=n!==void 0?n:{};var o={},l={svg_path:oi},h=oi,c=function(I){if(!I)return[];for(var L=[],Y=0;Y<I.length;Y++)L=L.concat.apply(L,I[Y]);var B=L[0];return B&&B.code=="m"&&(delete B.relative,B.code="M"),L},d=function(I,L){return La(I,L)},u=/^[Mm]/,p=ze(["M","m"],!1,!1),f=function(I,L,Y){var B=Js(I,[L]);return Y&&(B=B.concat(Js(I=="M"?"L":"l",Y[1]))),B},g=/^[Zz]/,m=ze(["Z","z"],!1,!1),v=function(){return Js("Z")},y=/^[Ll]/,x=ze(["L","l"],!1,!1),w=function(I,L){return Js(I,L)},_=/^[Hh]/,b=ze(["H","h"],!1,!1),A=function(I,L){return Js(I,L.map(function(Y){return{x:Y}}))},S=/^[Vv]/,E=ze(["V","v"],!1,!1),C=function(I,L){return Js(I,L.map(function(Y){return{y:Y}}))},T=/^[Cc]/,D=ze(["C","c"],!1,!1),O=function(I,L,Y){return{x1:I.x,y1:I.y,x2:L.x,y2:L.y,x:Y.x,y:Y.y}},P=/^[Ss]/,U=ze(["S","s"],!1,!1),W=function(I,L){return{x2:I.x,y2:I.y,x:L.x,y:L.y}},k=/^[Qq]/,F=ze(["Q","q"],!1,!1),Z=function(I,L){return{x1:I.x,y1:I.y,x:L.x,y:L.y}},X=/^[Tt]/,G=ze(["T","t"],!1,!1),q=/^[Aa]/,$=ze(["A","a"],!1,!1),Q=function(I,L,Y,B,J,Ae){return{rx:I,ry:L,xAxisRotation:Y,largeArc:B,sweep:J,x:Ae.x,y:Ae.y}},ee=function(I,L){return{x:I,y:L}},H=function(I){return I*1},he=function(I){return I.join("")*1},re=/^[01]/,te=ze(["0","1"],!1,!1),ae=function(I){return I=="1"},de=function(){return""},pe=",",be=je(",",!1),Le=function(I){return I.join("")},Me=".",Ve=je(".",!1),Ue=/^[eE]/,Ce=ze(["e","E"],!1,!1),Ee=/^[+\-]/,Ye=ze(["+","-"],!1,!1),qe=/^[0-9]/,V=ze([["0","9"]],!1,!1),z=function(I){return I.join("")},oe=/^[ \t\n\r]/,Se=ze([" "," ",`
  8. `,"\r"],!1,!1),R=0,Te=[{line:1,column:1}],ke=0,Oe=[],ue;if("startRule"in n){if(!(n.startRule in l))throw new Error(`Can't start parsing from rule "`+n.startRule+'".');h=l[n.startRule]}function je(I,L){return{type:"literal",text:I,ignoreCase:L}}function ze(I,L,Y){return{type:"class",parts:I,inverted:L,ignoreCase:Y}}function Xe(){return{type:"end"}}function it(I){var L=Te[I],Y;if(L)return L;for(Y=I-1;!Te[Y];)Y--;for(L=Te[Y],L={line:L.line,column:L.column};Y<I;)a.charCodeAt(Y)===10?(L.line++,L.column=1):L.column++,Y++;return Te[I]=L,L}function Qe(I,L){var Y=it(I),B=it(L);return{start:{offset:I,line:Y.line,column:Y.column},end:{offset:L,line:B.line,column:B.column}}}function Ke(I){R<ke||(R>ke&&(ke=R,Oe=[]),Oe.push(I))}function qt(I,L,Y){return new r(r.buildMessage(I,L),I,L,Y)}function oi(){var I,L,Y,B,J;for(I=R,L=[],Y=St();Y!==o;)L.push(Y),Y=St();if(L!==o)if(Y=K(),Y===o&&(Y=null),Y!==o){for(B=[],J=St();J!==o;)B.push(J),J=St();B!==o?(L=c(Y),I=L):(R=I,I=o)}else R=I,I=o;else R=I,I=o;return I}function K(){var I,L,Y,B,J,Ae;if(I=R,L=ge(),L!==o){for(Y=[],B=R,J=[],Ae=St();Ae!==o;)J.push(Ae),Ae=St();for(J!==o?(Ae=ge(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;){for(Y.push(B),B=R,J=[],Ae=St();Ae!==o;)J.push(Ae),Ae=St();J!==o?(Ae=ge(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o)}Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function ge(){var I,L,Y,B,J,Ae;if(I=R,L=Be(),L!==o){for(Y=[],B=R,J=[],Ae=St();Ae!==o;)J.push(Ae),Ae=St();for(J!==o?(Ae=_e(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;){for(Y.push(B),B=R,J=[],Ae=St();Ae!==o;)J.push(Ae),Ae=St();J!==o?(Ae=_e(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o)}Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function _e(){var I;return I=nt(),I===o&&(I=Et(),I===o&&(I=Yi(),I===o&&(I=$t(),I===o&&(I=Es(),I===o&&(I=xm(),I===o&&(I=N(),I===o&&(I=se(),I===o&&(I=He())))))))),I}function Be(){var I,L,Y,B,J,Ae,za;if(I=R,u.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(p)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=Je(),B!==o?(J=R,Ae=vt(),Ae===o&&(Ae=null),Ae!==o?(za=vi(),za!==o?(Ae=[Ae,za],J=Ae):(R=J,J=o)):(R=J,J=o),J===o&&(J=null),J!==o?(L=f(L,B,J),I=L):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function nt(){var I,L;return I=R,g.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(m)),L!==o&&(L=v()),I=L,I}function Et(){var I,L,Y,B;if(I=R,y.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(x)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=vi(),B!==o?(L=w(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function vi(){var I,L,Y,B,J,Ae;if(I=R,L=Je(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=Je(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=Je(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function Yi(){var I,L,Y,B;if(I=R,_.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(b)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=Ks(),B!==o?(L=A(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function Ks(){var I,L,Y,B,J,Ae;if(I=R,L=bt(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=bt(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=bt(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function $t(){var I,L,Y,B;if(I=R,S.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(E)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=Ks(),B!==o?(L=C(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function Es(){var I,L,Y,B;if(I=R,T.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(D)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=Gr(),B!==o?(L=w(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function Gr(){var I,L,Y,B,J,Ae;if(I=R,L=wl(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=wl(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=wl(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function wl(){var I,L,Y,B,J,Ae;return I=R,L=Je(),L!==o?(Y=vt(),Y===o&&(Y=null),Y!==o?(B=Je(),B!==o?(J=vt(),J===o&&(J=null),J!==o?(Ae=Je(),Ae!==o?(L=O(L,B,Ae),I=L):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o),I}function xm(){var I,L,Y,B;if(I=R,P.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(U)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=bm(),B!==o?(L=w(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function bm(){var I,L,Y,B,J,Ae;if(I=R,L=nc(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=nc(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=nc(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function nc(){var I,L,Y,B;return I=R,L=Je(),L!==o?(Y=vt(),Y===o&&(Y=null),Y!==o?(B=Je(),B!==o?(L=W(L,B),I=L):(R=I,I=o)):(R=I,I=o)):(R=I,I=o),I}function N(){var I,L,Y,B;if(I=R,k.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(F)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=le(),B!==o?(L=w(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function le(){var I,L,Y,B,J,Ae;if(I=R,L=me(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=me(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=me(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function me(){var I,L,Y,B;return I=R,L=Je(),L!==o?(Y=vt(),Y===o&&(Y=null),Y!==o?(B=Je(),B!==o?(L=Z(L,B),I=L):(R=I,I=o)):(R=I,I=o)):(R=I,I=o),I}function se(){var I,L,Y,B;if(I=R,X.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(G)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=ve(),B!==o?(L=w(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function ve(){var I,L,Y,B,J,Ae;if(I=R,L=Je(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=Je(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=Je(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function He(){var I,L,Y,B;if(I=R,q.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke($)),L!==o){for(Y=[],B=St();B!==o;)Y.push(B),B=St();Y!==o?(B=dt(),B!==o?(L=w(L,B),I=L):(R=I,I=o)):(R=I,I=o)}else R=I,I=o;return I}function dt(){var I,L,Y,B,J,Ae;if(I=R,L=pt(),L!==o){for(Y=[],B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=pt(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);B!==o;)Y.push(B),B=R,J=vt(),J===o&&(J=null),J!==o?(Ae=pt(),Ae!==o?(J=[J,Ae],B=J):(R=B,B=o)):(R=B,B=o);Y!==o?(L=d(L,Y),I=L):(R=I,I=o)}else R=I,I=o;return I}function pt(){var I,L,Y,B,J,Ae,za,wm,Qd,_m,Zd,Sm;return I=R,L=zt(),L!==o?(Y=vt(),Y===o&&(Y=null),Y!==o?(B=zt(),B!==o?(J=vt(),J===o&&(J=null),J!==o?(Ae=bt(),Ae!==o?(za=vt(),za!==o?(wm=wt(),wm!==o?(Qd=vt(),Qd===o&&(Qd=null),Qd!==o?(_m=wt(),_m!==o?(Zd=vt(),Zd===o&&(Zd=null),Zd!==o?(Sm=Je(),Sm!==o?(L=Q(L,B,Ae,wm,_m,Sm),I=L):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o)):(R=I,I=o),I}function Je(){var I,L,Y,B;return I=R,L=bt(),L!==o?(Y=vt(),Y===o&&(Y=null),Y!==o?(B=bt(),B!==o?(L=ee(L,B),I=L):(R=I,I=o)):(R=I,I=o)):(R=I,I=o),I}function zt(){var I,L;return I=R,L=ns(),L===o&&(L=Cs()),L!==o&&(L=H(L)),I=L,I}function bt(){var I,L,Y,B;return I=R,L=R,Y=At(),Y===o&&(Y=null),Y!==o?(B=ns(),B!==o?(Y=[Y,B],L=Y):(R=L,L=o)):(R=L,L=o),L===o&&(L=R,Y=At(),Y===o&&(Y=null),Y!==o?(B=Cs(),B!==o?(Y=[Y,B],L=Y):(R=L,L=o)):(R=L,L=o)),L!==o&&(L=he(L)),I=L,I}function wt(){var I,L;return I=R,re.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(te)),L!==o&&(L=ae(L)),I=L,I}function vt(){var I,L,Y,B,J;if(I=R,L=[],Y=St(),Y!==o)for(;Y!==o;)L.push(Y),Y=St();else L=o;if(L!==o)if(Y=zi(),Y===o&&(Y=null),Y!==o){for(B=[],J=St();J!==o;)B.push(J),J=St();B!==o?(L=[L,Y,B],I=L):(R=I,I=o)}else R=I,I=o;else R=I,I=o;if(I===o){if(I=R,L=R,Y=zi(),Y!==o){for(B=[],J=St();J!==o;)B.push(J),J=St();B!==o?(Y=[Y,B],L=Y):(R=L,L=o)}else R=L,L=o;L!==o&&(L=de()),I=L}return I}function zi(){var I;return a.charCodeAt(R)===44?(I=pe,R++):(I=o,Ke(be)),I}function ns(){var I,L,Y,B;return I=R,L=R,Y=Ra(),Y!==o?(B=li(),B===o&&(B=null),B!==o?(Y=[Y,B],L=Y):(R=L,L=o)):(R=L,L=o),L===o&&(L=R,Y=Cs(),Y!==o?(B=li(),B!==o?(Y=[Y,B],L=Y):(R=L,L=o)):(R=L,L=o)),L!==o&&(L=Le(L)),I=L,I}function Ra(){var I,L,Y,B,J;return I=R,L=R,Y=Cs(),Y===o&&(Y=null),Y!==o?(a.charCodeAt(R)===46?(B=Me,R++):(B=o,Ke(Ve)),B!==o?(J=Cs(),J!==o?(Y=[Y,B,J],L=Y):(R=L,L=o)):(R=L,L=o)):(R=L,L=o),L===o&&(L=R,Y=Cs(),Y!==o?(a.charCodeAt(R)===46?(B=Me,R++):(B=o,Ke(Ve)),B!==o?(Y=[Y,B],L=Y):(R=L,L=o)):(R=L,L=o)),L!==o&&(L=Le(L)),I=L,I}function li(){var I,L,Y,B,J;return I=R,L=R,Ue.test(a.charAt(R))?(Y=a.charAt(R),R++):(Y=o,Ke(Ce)),Y!==o?(B=At(),B===o&&(B=null),B!==o?(J=Cs(),J!==o?(Y=[Y,B,J],L=Y):(R=L,L=o)):(R=L,L=o)):(R=L,L=o),L!==o&&(L=Le(L)),I=L,I}function At(){var I;return Ee.test(a.charAt(R))?(I=a.charAt(R),R++):(I=o,Ke(Ye)),I}function Cs(){var I,L,Y;if(I=R,L=[],qe.test(a.charAt(R))?(Y=a.charAt(R),R++):(Y=o,Ke(V)),Y!==o)for(;Y!==o;)L.push(Y),qe.test(a.charAt(R))?(Y=a.charAt(R),R++):(Y=o,Ke(V));else L=o;return L!==o&&(L=z(L)),I=L,I}function St(){var I,L;return I=R,oe.test(a.charAt(R))?(L=a.charAt(R),R++):(L=o,Ke(Se)),L!==o&&(L=de()),I=L,I}function La(I,L){if(!L)return[I];for(var Y=[I],B=0,J=L.length;B<J;B++)Y[B+1]=L[B][1];return Y}var So={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var An in So)So[An.toUpperCase()]=So[An];function Js(I,L){L||(L=[{}]);for(var Y=L.length;Y--;){var B={code:I,command:So[I]};I==I.toLowerCase()&&(B.relative=!0);for(var J in L[Y])B[J]=L[Y][J];L[Y]=B}return L}if(ue=h(),ue!==o&&R===a.length)return ue;throw ue!==o&&R<a.length&&Ke(Xe()),qt(Oe,ke<a.length?a.charAt(ke):null,ke<a.length?Qe(ke,ke+1):Qe(ke,ke))}t.exports={SyntaxError:r,parse:s}}),Q2=fl((e,t)=>{var i=OO().parse;i.parseSVG=i,i.makeAbsolute=r,t.exports=i;function r(s){var a,n={x:0,y:0},o={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return s.forEach(function(l){l.command==="moveto"&&(a=l),l.x0=n.x,l.y0=n.y;for(var h in o)h in l&&(l[h]+=l.relative?l[o[h]]:0);"x"in l||(l.x=n.x),"y"in l||(l.y=n.y),l.relative=!1,l.code=l.code.toUpperCase(),l.command=="closepath"&&(l.x=a.x,l.y=a.y),n=l}),s}}),RO=fl((e,t)=>{t.exports=function(i,r){for(var s=i.split("."),a=r.split("."),n=0;n<3;n++){var o=Number(s[n]),l=Number(a[n]);if(o>l)return 1;if(l>o)return-1;if(!isNaN(o)&&isNaN(l))return 1;if(isNaN(o)&&!isNaN(l))return-1}return 0}}),Gh="149",os={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},LO=0,Ax=1,zO=2,Uy=1,BO=2,Fc=3,Ws=0,rr=1,Ar=2,Oi=0,Jo=1,Mx=2,Ex=3,Cx=4,FO=5,eh=100,UO=101,NO=102,Tx=103,Px=104,kO=200,VO=201,jO=202,GO=203,Z2=204,K2=205,HO=206,WO=207,qO=208,XO=209,YO=210,QO=0,ZO=1,KO=2,Pv=3,JO=4,$O=5,eR=6,tR=7,J2=0,iR=1,rR=2,_a=0,sR=1,aR=2,nR=3,oR=4,lR=5,$2=300,al=301,nl=302,Dv=303,Iv=304,Rd=306,nn=1e3,ai=1001,Ov=1002,_t=1003,Dx=1004,Am=1005,xt=1006,hR=1007,Ch=1008,Er=1009,cR=1010,dR=1011,eM=1012,uR=1013,on=1014,jt=1015,mn=1016,pR=1017,fR=1018,$o=1020,mR=1021,ni=1023,gR=1024,vR=1025,el=1026,ol=1027,wp=1028,yR=1029,Up=1030,xR=1031,tM=1033,Mm=33776,Em=33777,Cm=33778,Tm=33779,Ix=35840,Ox=35841,Rx=35842,Lx=35843,bR=36196,zx=37492,Bx=37496,Fx=37808,Ux=37809,Nx=37810,kx=37811,Vx=37812,jx=37813,Gx=37814,Hx=37815,Wx=37816,qx=37817,Xx=37818,Yx=37819,Qx=37820,Zx=37821,Pm=36492,wR=36283,Kx=36284,Jx=36285,$x=36286,iM=2200,rM=2201,Ny=2202,Np=2300,kp=2301,Dm=2302,lh=2400,hh=2401,Vp=2402,ky=2500,_R=2501,qs=3e3,gt=3001,_n=3200,sM=3201,SR=0,AR=1,pa="srgb",jp="srgb-linear",Im=7680,MR=519,Rv=35044,ER=35048,Lv="300 es",zv=1035,yr=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let i=this._listeners[e];if(i!==void 0){let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let t=this._listeners[e.type];if(t!==void 0){e.target=this;let i=t.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,e);e.target=null}}},xr=["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"],eb=1234567,Xc=Math.PI/180,cd=180/Math.PI;function ws(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(xr[e&255]+xr[e>>8&255]+xr[e>>16&255]+xr[e>>24&255]+"-"+xr[t&255]+xr[t>>8&255]+"-"+xr[t>>16&15|64]+xr[t>>24&255]+"-"+xr[i&63|128]+xr[i>>8&255]+"-"+xr[i>>16&255]+xr[i>>24&255]+xr[r&255]+xr[r>>8&255]+xr[r>>16&255]+xr[r>>24&255]).toLowerCase()}function Ti(e,t,i){return Math.max(t,Math.min(i,e))}function Vy(e,t){return(e%t+t)%t}function CR(e,t,i,r,s){return r+(e-t)*(s-r)/(i-t)}function TR(e,t,i){return e!==t?(i-e)/(t-e):0}function Yc(e,t,i){return(1-i)*e+i*t}function PR(e,t,i,r){return Yc(e,t,1-Math.exp(-i*r))}function DR(e,t=1){return t-Math.abs(Vy(e,t*2)-t)}function IR(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*(3-2*e))}function OR(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t),e*e*e*(e*(e*6-15)+10))}function RR(e,t){return e+Math.floor(Math.random()*(t-e+1))}function LR(e,t){return e+Math.random()*(t-e)}function zR(e){return e*(.5-Math.random())}function BR(e){e!==void 0&&(eb=e);let t=eb+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function FR(e){return e*Xc}function UR(e){return e*cd}function Bv(e){return(e&e-1)===0&&e!==0}function aM(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Gp(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function NR(e,t,i,r,s){let a=Math.cos,n=Math.sin,o=a(i/2),l=n(i/2),h=a((t+r)/2),c=n((t+r)/2),d=a((t-r)/2),u=n((t-r)/2),p=a((r-t)/2),f=n((r-t)/2);switch(s){case"XYX":e.set(o*c,l*d,l*u,o*h);break;case"YZY":e.set(l*u,o*c,l*d,o*h);break;case"ZXZ":e.set(l*d,l*u,o*c,o*h);break;case"XZX":e.set(o*c,l*f,l*p,o*h);break;case"YXY":e.set(l*p,o*c,l*f,o*h);break;case"ZYZ":e.set(l*f,l*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function ln(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function Kt(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw new Error("Invalid component type.")}}var Re=Object.freeze({__proto__:null,DEG2RAD:Xc,RAD2DEG:cd,ceilPowerOfTwo:aM,clamp:Ti,damp:PR,degToRad:FR,denormalize:ln,euclideanModulo:Vy,floorPowerOfTwo:Gp,generateUUID:ws,inverseLerp:TR,isPowerOfTwo:Bv,lerp:Yc,mapLinear:CR,normalize:Kt,pingpong:DR,radToDeg:UR,randFloat:LR,randFloatSpread:zR,randInt:RR,seededRandom:BR,setQuaternionFromProperEuler:NR,smootherstep:OR,smoothstep:IR}),j=class{constructor(e=0,t=0){j.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Di=class{constructor(){Di.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,i,r,s,a,n,o,l){let h=this.elements;return h[0]=e,h[1]=r,h[2]=n,h[3]=t,h[4]=s,h[5]=o,h[6]=i,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,a=i[0],n=i[3],o=i[6],l=i[1],h=i[4],c=i[7],d=i[2],u=i[5],p=i[8],f=r[0],g=r[3],m=r[6],v=r[1],y=r[4],x=r[7],w=r[2],_=r[5],b=r[8];return s[0]=a*f+n*v+o*w,s[3]=a*g+n*y+o*_,s[6]=a*m+n*x+o*b,s[1]=l*f+h*v+c*w,s[4]=l*g+h*y+c*_,s[7]=l*m+h*x+c*b,s[2]=d*f+u*v+p*w,s[5]=d*g+u*y+p*_,s[8]=d*m+u*x+p*b,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],n=e[5],o=e[6],l=e[7],h=e[8];return t*a*h-t*n*l-i*s*h+i*n*o+r*s*l-r*a*o}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],n=e[5],o=e[6],l=e[7],h=e[8],c=h*a-n*l,d=n*o-h*s,u=l*s-a*o,p=t*c+i*d+r*u;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=c*f,e[1]=(r*l-h*i)*f,e[2]=(n*i-r*a)*f,e[3]=d*f,e[4]=(h*t-r*o)*f,e[5]=(r*s-n*t)*f,e[6]=u*f,e[7]=(i*o-l*t)*f,e[8]=(a*t-i*s)*f,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,a,n){let o=Math.cos(s),l=Math.sin(s);return this.set(i*o,i*l,-i*(o*a+l*n)+a+e,-r*l,r*o,-r*(-l*a+o*n)+n+t,0,0,1),this}scale(e,t){return this.premultiply(Om.makeScale(e,t)),this}rotate(e){return this.premultiply(Om.makeRotation(-e)),this}translate(e,t){return this.premultiply(Om.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Om=new Di;function nM(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var kR={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Kd(e,t){return new kR[e](t)}function dd(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function VR(e,t,i){return new Promise(function(r,s){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:s();break;case e.TIMEOUT_EXPIRED:setTimeout(a,i);break;default:r()}}setTimeout(a,i)})}function tl(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function _p(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}var Rm={[pa]:{[jp]:tl},[jp]:{[pa]:_p}},Dr={legacyMode:!0,get workingColorSpace(){return jp},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,i){if(this.legacyMode||t===i||!t||!i)return e;if(Rm[t]&&Rm[t][i]!==void 0){let r=Rm[t][i];return e.r=r(e.r),e.g=r(e.g),e.b=r(e.b),e}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}},oM={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},Bi={r:0,g:0,b:0},Ts={h:0,s:0,l:0},Jd={h:0,s:0,l:0};function Lm(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(t-e)*6*i:i<1/2?t:i<2/3?e+(t-e)*6*(2/3-i):e}function $d(e,t){return t.r=e.r,t.g=e.g,t.b=e.b,t}var et=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&i===void 0?this.set(e):this.setRGB(e,t,i)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pa){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Dr.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=Dr.workingColorSpace){return this.r=e,this.g=t,this.b=i,Dr.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=Dr.workingColorSpace){if(e=Vy(e,1),t=Ti(t,0,1),i=Ti(i,0,1),t===0)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=Lm(a,s,e+1/3),this.g=Lm(a,s,e),this.b=Lm(a,s,e-1/3)}return Dr.toWorkingColorSpace(this,r),this}setStyle(e,t=pa){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s,a=r[1],n=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,Dr.toWorkingColorSpace(this,t),i(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,Dr.toWorkingColorSpace(this,t),i(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n)){let o=parseFloat(s[1])/360,l=parseFloat(s[2])/100,h=parseFloat(s[3])/100;return i(s[4]),this.setHSL(o,l,h,t)}break}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],a=s.length;if(a===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,Dr.toWorkingColorSpace(this,t),this;if(a===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,Dr.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=pa){let i=oM[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=tl(e.r),this.g=tl(e.g),this.b=tl(e.b),this}copyLinearToSRGB(e){return this.r=_p(e.r),this.g=_p(e.g),this.b=_p(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pa){return Dr.fromWorkingColorSpace($d(this,Bi),e),Ti(Bi.r*255,0,255)<<16^Ti(Bi.g*255,0,255)<<8^Ti(Bi.b*255,0,255)<<0}getHexString(e=pa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Dr.workingColorSpace){Dr.fromWorkingColorSpace($d(this,Bi),t);let i=Bi.r,r=Bi.g,s=Bi.b,a=Math.max(i,r,s),n=Math.min(i,r,s),o,l,h=(n+a)/2;if(n===a)o=0,l=0;else{let c=a-n;switch(l=h<=.5?c/(a+n):c/(2-a-n),a){case i:o=(r-s)/c+(r<s?6:0);break;case r:o=(s-i)/c+2;break;case s:o=(i-r)/c+4;break}o/=6}return e.h=o,e.s=l,e.l=h,e}getRGB(e,t=Dr.workingColorSpace){return Dr.fromWorkingColorSpace($d(this,Bi),t),e.r=Bi.r,e.g=Bi.g,e.b=Bi.b,e}getStyle(e=pa){return Dr.fromWorkingColorSpace($d(this,Bi),e),e!==pa?`color(${e} ${Bi.r} ${Bi.g} ${Bi.b})`:`rgb(${Bi.r*255|0},${Bi.g*255|0},${Bi.b*255|0})`}offsetHSL(e,t,i){return this.getHSL(Ts),Ts.h+=e,Ts.s+=t,Ts.l+=i,this.setHSL(Ts.h,Ts.s,Ts.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Ts),e.getHSL(Jd);let i=Yc(Ts.h,Jd.h,t),r=Yc(Ts.s,Jd.s,t),s=Yc(Ts.l,Jd.l,t);return this.setHSL(i,r,s),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};et.NAMES=oM;var _l,lM=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{_l===void 0&&(_l=dd("canvas")),_l.width=e.width,_l.height=e.height;let i=_l.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=_l}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=dd("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=tl(s[a]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(tl(t[i]/255)*255):t[i]=tl(t[i]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},hM=class{constructor(e=null){this.isSource=!0,this.uuid=ws(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,n=r.length;a<n;a++)r[a].isDataTexture?s.push(zm(r[a].image)):s.push(zm(r[a]))}else s=zm(r);i.url=s}return t||(e.images[this.uuid]=i),i}};function zm(e){return typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap?lM.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var jR=0,ci=class extends yr{constructor(e=ci.DEFAULT_IMAGE,t=ci.DEFAULT_MAPPING,i=ai,r=ai,s=xt,a=Ch,n=ni,o=Er,l=ci.DEFAULT_ANISOTROPY,h=qs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:jR++}),this.uuid=ws(),this.name="",this.source=new hM(e),this.mipmaps=[],this.mapping=t,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=n,this.internalFormat=null,this.type=o,this.offset=new j(0,0),this.repeat=new j(1,1),this.center=new j(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Di,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,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,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==$2)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case nn:e.x=e.x-Math.floor(e.x);break;case ai:e.x=e.x<0?0:1;break;case Ov:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case nn:e.y=e.y-Math.floor(e.y);break;case ai:e.y=e.y<0?0:1;break;case Ov:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}};ci.DEFAULT_IMAGE=null;ci.DEFAULT_MAPPING=$2;ci.DEFAULT_ANISOTROPY=1;var ct=class{constructor(e=0,t=0,i=0,r=1){ct.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+a[11]*r+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s,a=e.elements,n=a[0],o=a[4],l=a[8],h=a[1],c=a[5],d=a[9],u=a[2],p=a[6],f=a[10];if(Math.abs(o-h)<.01&&Math.abs(l-u)<.01&&Math.abs(d-p)<.01){if(Math.abs(o+h)<.1&&Math.abs(l+u)<.1&&Math.abs(d+p)<.1&&Math.abs(n+c+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let m=(n+1)/2,v=(c+1)/2,y=(f+1)/2,x=(o+h)/4,w=(l+u)/4,_=(d+p)/4;return m>v&&m>y?m<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(m),r=x/i,s=w/i):v>y?v<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(v),i=x/r,s=_/r):y<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(y),i=w/s,r=_/s),this.set(i,r,s,t),this}let g=Math.sqrt((p-d)*(p-d)+(l-u)*(l-u)+(h-o)*(h-o));return Math.abs(g)<.001&&(g=1),this.x=(p-d)/g,this.y=(l-u)/g,this.z=(h-o)/g,this.w=Math.acos((n+c+f-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Pt=class extends yr{constructor(e=1,t=1,i={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new ct(0,0,e,t),this.scissorTest=!1,this.viewport=new ct(0,0,e,t);let r={width:e,height:t,depth:1};this.texture=new ci(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps!==void 0?i.generateMipmaps:!1,this.texture.internalFormat=i.internalFormat!==void 0?i.internalFormat:null,this.texture.minFilter=i.minFilter!==void 0?i.minFilter:xt,this.depthBuffer=i.depthBuffer!==void 0?i.depthBuffer:!0,this.stencilBuffer=i.stencilBuffer!==void 0?i.stencilBuffer:!1,this.depthTexture=i.depthTexture!==void 0?i.depthTexture:null,this.samples=i.samples!==void 0?i.samples:0}setSize(e,t,i=1){(this.width!==e||this.height!==t||this.depth!==i)&&(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new hM(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},cM=class extends ci{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=_t,this.minFilter=_t,this.wrapR=ai,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},GR=class extends ci{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=_t,this.minFilter=_t,this.wrapR=ai,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},dM=class extends Pt{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLMultipleRenderTargets=!0;let s=this.texture;this.texture=[];for(let a=0;a<i;a++)this.texture[a]=s.clone(),this.texture[a].isRenderTargetTexture=!0}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,s=this.texture.length;r<s;r++)this.texture[r].image.width=e,this.texture[r].image.height=t,this.texture[r].image.depth=i;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.texture.length=0;for(let t=0,i=e.texture.length;t<i;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}},lt=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,a,n){let o=i[r+0],l=i[r+1],h=i[r+2],c=i[r+3],d=s[a+0],u=s[a+1],p=s[a+2],f=s[a+3];if(n===0){e[t+0]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c;return}if(n===1){e[t+0]=d,e[t+1]=u,e[t+2]=p,e[t+3]=f;return}if(c!==f||o!==d||l!==u||h!==p){let g=1-n,m=o*d+l*u+h*p+c*f,v=m>=0?1:-1,y=1-m*m;if(y>Number.EPSILON){let w=Math.sqrt(y),_=Math.atan2(w,m*v);g=Math.sin(g*_)/w,n=Math.sin(n*_)/w}let x=n*v;if(o=o*g+d*x,l=l*g+u*x,h=h*g+p*x,c=c*g+f*x,g===1-n){let w=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=w,l*=w,h*=w,c*=w}}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c}static multiplyQuaternionsFlat(e,t,i,r,s,a){let n=i[r],o=i[r+1],l=i[r+2],h=i[r+3],c=s[a],d=s[a+1],u=s[a+2],p=s[a+3];return e[t]=n*p+h*c+o*u-l*d,e[t+1]=o*p+h*d+l*c-n*u,e[t+2]=l*p+h*u+n*d-o*c,e[t+3]=h*p-n*c-o*d-l*u,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){let i=e._x,r=e._y,s=e._z,a=e._order,n=Math.cos,o=Math.sin,l=n(i/2),h=n(r/2),c=n(s/2),d=o(i/2),u=o(r/2),p=o(s/2);switch(a){case"XYZ":this._x=d*h*c+l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c-d*u*p;break;case"YXZ":this._x=d*h*c+l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c+d*u*p;break;case"ZXY":this._x=d*h*c-l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c-d*u*p;break;case"ZYX":this._x=d*h*c-l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c+d*u*p;break;case"YZX":this._x=d*h*c+l*u*p,this._y=l*u*c+d*h*p,this._z=l*h*p-d*u*c,this._w=l*h*c-d*u*p;break;case"XZY":this._x=d*h*c-l*u*p,this._y=l*u*c-d*h*p,this._z=l*h*p+d*u*c,this._w=l*h*c+d*u*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],s=t[8],a=t[1],n=t[5],o=t[9],l=t[2],h=t[6],c=t[10],d=i+n+c;if(d>0){let u=.5/Math.sqrt(d+1);this._w=.25/u,this._x=(h-o)*u,this._y=(s-l)*u,this._z=(a-r)*u}else if(i>n&&i>c){let u=2*Math.sqrt(1+i-n-c);this._w=(h-o)/u,this._x=.25*u,this._y=(r+a)/u,this._z=(s+l)/u}else if(n>c){let u=2*Math.sqrt(1+n-i-c);this._w=(s-l)/u,this._x=(r+a)/u,this._y=.25*u,this._z=(o+h)/u}else{let u=2*Math.sqrt(1+c-i-n);this._w=(a-r)/u,this._x=(s+l)/u,this._y=(o+h)/u,this._z=.25*u}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ti(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,s=e._z,a=e._w,n=t._x,o=t._y,l=t._z,h=t._w;return this._x=i*h+a*n+r*l-s*o,this._y=r*h+a*o+s*n-i*l,this._z=s*h+a*l+i*o-r*n,this._w=a*h-i*n-r*o-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let i=this._x,r=this._y,s=this._z,a=this._w,n=a*e._w+i*e._x+r*e._y+s*e._z;if(n<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,n=-n):this.copy(e),n>=1)return this._w=a,this._x=i,this._y=r,this._z=s,this;let o=1-n*n;if(o<=Number.EPSILON){let u=1-t;return this._w=u*a+t*this._w,this._x=u*i+t*this._x,this._y=u*r+t*this._y,this._z=u*s+t*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(o),h=Math.atan2(l,n),c=Math.sin((1-t)*h)/l,d=Math.sin(t*h)/l;return this._w=a*c+this._w*d,this._x=i*c+this._x*d,this._y=r*c+this._y*d,this._z=s*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),r=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(r),i*Math.sin(s),i*Math.cos(s),t*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},M=class{constructor(e=0,t=0,i=0){M.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(tb.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(tb.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,n=e.z,o=e.w,l=o*t+a*r-n*i,h=o*i+n*t-s*r,c=o*r+s*i-a*t,d=-s*t-a*i-n*r;return this.x=l*o+d*-s+h*-n-c*-a,this.y=h*o+d*-a+c*-s-l*-n,this.z=c*o+d*-n+l*-a-h*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,s=e.z,a=t.x,n=t.y,o=t.z;return this.x=r*o-s*n,this.y=s*a-i*o,this.z=i*n-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Bm.copy(this).projectOnVector(e),this.sub(Bm)}reflect(e){return this.sub(Bm.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Ti(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Bm=new M,tb=new lt,Si=class{constructor(e=new M(1/0,1/0,1/0),t=new M(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,i=1/0,r=1/0,s=-1/0,a=-1/0,n=-1/0;for(let o=0,l=e.length;o<l;o+=3){let h=e[o],c=e[o+1],d=e[o+2];h<t&&(t=h),c<i&&(i=c),d<r&&(r=d),h>s&&(s=h),c>a&&(a=c),d>n&&(n=d)}return this.min.set(t,i,r),this.max.set(s,a,n),this}setFromBufferAttribute(e){let t=1/0,i=1/0,r=1/0,s=-1/0,a=-1/0,n=-1/0;for(let o=0,l=e.count;o<l;o++){let h=e.getX(o),c=e.getY(o),d=e.getZ(o);h<t&&(t=h),c<i&&(i=c),d<r&&(r=d),h>s&&(s=h),c>a&&(a=c),d>n&&(n=d)}return this.min.set(t,i,r),this.max.set(s,a,n),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Mo.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0)if(t&&i.attributes!=null&&i.attributes.position!==void 0){let s=i.attributes.position;for(let a=0,n=s.count;a<n;a++)Mo.fromBufferAttribute(s,a).applyMatrix4(e.matrixWorld),this.expandByPoint(Mo)}else i.boundingBox===null&&i.computeBoundingBox(),Fm.copy(i.boundingBox),Fm.applyMatrix4(e.matrixWorld),this.union(Fm);let r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Mo),Mo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(oc),eu.subVectors(this.max,oc),Sl.subVectors(e.a,oc),Al.subVectors(e.b,oc),Ml.subVectors(e.c,oc),En.subVectors(Al,Sl),Cn.subVectors(Ml,Al),Eo.subVectors(Sl,Ml);let t=[0,-En.z,En.y,0,-Cn.z,Cn.y,0,-Eo.z,Eo.y,En.z,0,-En.x,Cn.z,0,-Cn.x,Eo.z,0,-Eo.x,-En.y,En.x,0,-Cn.y,Cn.x,0,-Eo.y,Eo.x,0];return!Um(t,Sl,Al,Ml,eu)||(t=[1,0,0,0,1,0,0,0,1],!Um(t,Sl,Al,Ml,eu))?!1:(tu.crossVectors(En,Cn),t=[tu.x,tu.y,tu.z],Um(t,Sl,Al,Ml,eu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Mo.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(Mo).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Ba[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ba[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ba[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ba[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ba[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ba[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ba[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ba[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ba),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Ba=[new M,new M,new M,new M,new M,new M,new M,new M],Mo=new M,Fm=new Si,Sl=new M,Al=new M,Ml=new M,En=new M,Cn=new M,Eo=new M,oc=new M,eu=new M,tu=new M,Co=new M;function Um(e,t,i,r,s){for(let a=0,n=e.length-3;a<=n;a+=3){Co.fromArray(e,a);let o=s.x*Math.abs(Co.x)+s.y*Math.abs(Co.y)+s.z*Math.abs(Co.z),l=t.dot(Co),h=i.dot(Co),c=r.dot(Co);if(Math.max(-Math.max(l,h,c),Math.min(l,h,c))>o)return!1}return!0}var HR=new Si,lc=new M,Nm=new M,$r=class{constructor(e=new M,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):HR.setFromPoints(e).getCenter(i);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,i.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;lc.subVectors(e,this.center);let t=lc.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(lc,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Nm.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(lc.copy(e.center).add(Nm)),this.expandByPoint(lc.copy(e.center).sub(Nm))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Fa=new M,km=new M,iu=new M,Tn=new M,Vm=new M,ru=new M,jm=new M,Hh=class{constructor(e=new M,t=new M(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Fa)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Fa.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Fa.copy(this.direction).multiplyScalar(t).add(this.origin),Fa.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){km.copy(e).add(t).multiplyScalar(.5),iu.copy(t).sub(e).normalize(),Tn.copy(this.origin).sub(km);let s=e.distanceTo(t)*.5,a=-this.direction.dot(iu),n=Tn.dot(this.direction),o=-Tn.dot(iu),l=Tn.lengthSq(),h=Math.abs(1-a*a),c,d,u,p;if(h>0)if(c=a*o-n,d=a*n-o,p=s*h,c>=0)if(d>=-p)if(d<=p){let f=1/h;c*=f,d*=f,u=c*(c+a*d+2*n)+d*(a*c+d+2*o)+l}else d=s,c=Math.max(0,-(a*d+n)),u=-c*c+d*(d+2*o)+l;else d=-s,c=Math.max(0,-(a*d+n)),u=-c*c+d*(d+2*o)+l;else d<=-p?(c=Math.max(0,-(-a*s+n)),d=c>0?-s:Math.min(Math.max(-s,-o),s),u=-c*c+d*(d+2*o)+l):d<=p?(c=0,d=Math.min(Math.max(-s,-o),s),u=d*(d+2*o)+l):(c=Math.max(0,-(a*s+n)),d=c>0?s:Math.min(Math.max(-s,-o),s),u=-c*c+d*(d+2*o)+l);else d=a>0?-s:s,c=Math.max(0,-(a*d+n)),u=-c*c+d*(d+2*o)+l;return i&&i.copy(this.direction).multiplyScalar(c).add(this.origin),r&&r.copy(iu).multiplyScalar(d).add(km),u}intersectSphere(e,t){Fa.subVectors(e.center,this.origin);let i=Fa.dot(this.direction),r=Fa.dot(Fa)-i*i,s=e.radius*e.radius;if(r>s)return null;let a=Math.sqrt(s-r),n=i-a,o=i+a;return n<0&&o<0?null:n<0?this.at(o,t):this.at(n,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,a,n,o,l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,d=this.origin;return l>=0?(i=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(i=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),h>=0?(s=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a<r||isNaN(r))&&(r=a),c>=0?(n=(e.min.z-d.z)*c,o=(e.max.z-d.z)*c):(n=(e.max.z-d.z)*c,o=(e.min.z-d.z)*c),i>o||n>r)||((n>i||i!==i)&&(i=n),(o<r||r!==r)&&(r=o),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Fa)!==null}intersectTriangle(e,t,i,r,s){Vm.subVectors(t,e),ru.subVectors(i,e),jm.crossVectors(Vm,ru);let a=this.direction.dot(jm),n;if(a>0){if(r)return null;n=1}else if(a<0)n=-1,a=-a;else return null;Tn.subVectors(this.origin,e);let o=n*this.direction.dot(ru.crossVectors(Tn,ru));if(o<0)return null;let l=n*this.direction.dot(Vm.cross(Tn));if(l<0||o+l>a)return null;let h=-n*Tn.dot(jm);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},we=class{constructor(){we.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,i,r,s,a,n,o,l,h,c,d,u,p,f,g){let m=this.elements;return m[0]=e,m[4]=t,m[8]=i,m[12]=r,m[1]=s,m[5]=a,m[9]=n,m[13]=o,m[2]=l,m[6]=h,m[10]=c,m[14]=d,m[3]=u,m[7]=p,m[11]=f,m[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new we().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/El.setFromMatrixColumn(e,0).length(),s=1/El.setFromMatrixColumn(e,1).length(),a=1/El.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,s=e.z,a=Math.cos(i),n=Math.sin(i),o=Math.cos(r),l=Math.sin(r),h=Math.cos(s),c=Math.sin(s);if(e.order==="XYZ"){let d=a*h,u=a*c,p=n*h,f=n*c;t[0]=o*h,t[4]=-o*c,t[8]=l,t[1]=u+p*l,t[5]=d-f*l,t[9]=-n*o,t[2]=f-d*l,t[6]=p+u*l,t[10]=a*o}else if(e.order==="YXZ"){let d=o*h,u=o*c,p=l*h,f=l*c;t[0]=d+f*n,t[4]=p*n-u,t[8]=a*l,t[1]=a*c,t[5]=a*h,t[9]=-n,t[2]=u*n-p,t[6]=f+d*n,t[10]=a*o}else if(e.order==="ZXY"){let d=o*h,u=o*c,p=l*h,f=l*c;t[0]=d-f*n,t[4]=-a*c,t[8]=p+u*n,t[1]=u+p*n,t[5]=a*h,t[9]=f-d*n,t[2]=-a*l,t[6]=n,t[10]=a*o}else if(e.order==="ZYX"){let d=a*h,u=a*c,p=n*h,f=n*c;t[0]=o*h,t[4]=p*l-u,t[8]=d*l+f,t[1]=o*c,t[5]=f*l+d,t[9]=u*l-p,t[2]=-l,t[6]=n*o,t[10]=a*o}else if(e.order==="YZX"){let d=a*o,u=a*l,p=n*o,f=n*l;t[0]=o*h,t[4]=f-d*c,t[8]=p*c+u,t[1]=c,t[5]=a*h,t[9]=-n*h,t[2]=-l*h,t[6]=u*c+p,t[10]=d-f*c}else if(e.order==="XZY"){let d=a*o,u=a*l,p=n*o,f=n*l;t[0]=o*h,t[4]=-c,t[8]=l*h,t[1]=d*c+f,t[5]=a*h,t[9]=u*c-p,t[2]=p*c-u,t[6]=n*h,t[10]=f*c+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(WR,e,qR)}lookAt(e,t,i){let r=this.elements;return ts.subVectors(e,t),ts.lengthSq()===0&&(ts.z=1),ts.normalize(),Pn.crossVectors(i,ts),Pn.lengthSq()===0&&(Math.abs(i.z)===1?ts.x+=1e-4:ts.z+=1e-4,ts.normalize(),Pn.crossVectors(i,ts)),Pn.normalize(),su.crossVectors(ts,Pn),r[0]=Pn.x,r[4]=su.x,r[8]=ts.x,r[1]=Pn.y,r[5]=su.y,r[9]=ts.y,r[2]=Pn.z,r[6]=su.z,r[10]=ts.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,s=this.elements,a=i[0],n=i[4],o=i[8],l=i[12],h=i[1],c=i[5],d=i[9],u=i[13],p=i[2],f=i[6],g=i[10],m=i[14],v=i[3],y=i[7],x=i[11],w=i[15],_=r[0],b=r[4],A=r[8],S=r[12],E=r[1],C=r[5],T=r[9],D=r[13],O=r[2],P=r[6],U=r[10],W=r[14],k=r[3],F=r[7],Z=r[11],X=r[15];return s[0]=a*_+n*E+o*O+l*k,s[4]=a*b+n*C+o*P+l*F,s[8]=a*A+n*T+o*U+l*Z,s[12]=a*S+n*D+o*W+l*X,s[1]=h*_+c*E+d*O+u*k,s[5]=h*b+c*C+d*P+u*F,s[9]=h*A+c*T+d*U+u*Z,s[13]=h*S+c*D+d*W+u*X,s[2]=p*_+f*E+g*O+m*k,s[6]=p*b+f*C+g*P+m*F,s[10]=p*A+f*T+g*U+m*Z,s[14]=p*S+f*D+g*W+m*X,s[3]=v*_+y*E+x*O+w*k,s[7]=v*b+y*C+x*P+w*F,s[11]=v*A+y*T+x*U+w*Z,s[15]=v*S+y*D+x*W+w*X,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],a=e[1],n=e[5],o=e[9],l=e[13],h=e[2],c=e[6],d=e[10],u=e[14],p=e[3],f=e[7],g=e[11],m=e[15];return p*(+s*o*c-r*l*c-s*n*d+i*l*d+r*n*u-i*o*u)+f*(+t*o*u-t*l*d+s*a*d-r*a*u+r*l*h-s*o*h)+g*(+t*l*c-t*n*u-s*a*c+i*a*u+s*n*h-i*l*h)+m*(-r*n*h-t*o*c+t*n*d+r*a*c-i*a*d+i*o*h)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],n=e[5],o=e[6],l=e[7],h=e[8],c=e[9],d=e[10],u=e[11],p=e[12],f=e[13],g=e[14],m=e[15],v=c*g*l-f*d*l+f*o*u-n*g*u-c*o*m+n*d*m,y=p*d*l-h*g*l-p*o*u+a*g*u+h*o*m-a*d*m,x=h*f*l-p*c*l+p*n*u-a*f*u-h*n*m+a*c*m,w=p*c*o-h*f*o-p*n*d+a*f*d+h*n*g-a*c*g,_=t*v+i*y+r*x+s*w;if(_===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let b=1/_;return e[0]=v*b,e[1]=(f*d*s-c*g*s-f*r*u+i*g*u+c*r*m-i*d*m)*b,e[2]=(n*g*s-f*o*s+f*r*l-i*g*l-n*r*m+i*o*m)*b,e[3]=(c*o*s-n*d*s-c*r*l+i*d*l+n*r*u-i*o*u)*b,e[4]=y*b,e[5]=(h*g*s-p*d*s+p*r*u-t*g*u-h*r*m+t*d*m)*b,e[6]=(p*o*s-a*g*s-p*r*l+t*g*l+a*r*m-t*o*m)*b,e[7]=(a*d*s-h*o*s+h*r*l-t*d*l-a*r*u+t*o*u)*b,e[8]=x*b,e[9]=(p*c*s-h*f*s-p*i*u+t*f*u+h*i*m-t*c*m)*b,e[10]=(a*f*s-p*n*s+p*i*l-t*f*l-a*i*m+t*n*m)*b,e[11]=(h*n*s-a*c*s-h*i*l+t*c*l+a*i*u-t*n*u)*b,e[12]=w*b,e[13]=(h*f*r-p*c*r+p*i*d-t*f*d-h*i*g+t*c*g)*b,e[14]=(p*n*r-a*f*r-p*i*o+t*f*o+a*i*g-t*n*g)*b,e[15]=(a*c*r-h*n*r+h*i*o-t*c*o-a*i*d+t*n*d)*b,this}scale(e){let t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),s=1-i,a=e.x,n=e.y,o=e.z,l=s*a,h=s*n;return this.set(l*a+i,l*n-r*o,l*o+r*n,0,l*n+r*o,h*n+i,h*o-r*a,0,l*o-r*n,h*o+r*a,s*o*o+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,s=t._x,a=t._y,n=t._z,o=t._w,l=s+s,h=a+a,c=n+n,d=s*l,u=s*h,p=s*c,f=a*h,g=a*c,m=n*c,v=o*l,y=o*h,x=o*c,w=i.x,_=i.y,b=i.z;return r[0]=(1-(f+m))*w,r[1]=(u+x)*w,r[2]=(p-y)*w,r[3]=0,r[4]=(u-x)*_,r[5]=(1-(d+m))*_,r[6]=(g+v)*_,r[7]=0,r[8]=(p+y)*b,r[9]=(g-v)*b,r[10]=(1-(d+f))*b,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,s=El.set(r[0],r[1],r[2]).length(),a=El.set(r[4],r[5],r[6]).length(),n=El.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Ps.copy(this);let o=1/s,l=1/a,h=1/n;return Ps.elements[0]*=o,Ps.elements[1]*=o,Ps.elements[2]*=o,Ps.elements[4]*=l,Ps.elements[5]*=l,Ps.elements[6]*=l,Ps.elements[8]*=h,Ps.elements[9]*=h,Ps.elements[10]*=h,t.setFromRotationMatrix(Ps),i.x=s,i.y=a,i.z=n,this}makePerspective(e,t,i,r,s,a){let n=this.elements,o=2*s/(t-e),l=2*s/(i-r),h=(t+e)/(t-e),c=(i+r)/(i-r),d=-(a+s)/(a-s),u=-2*a*s/(a-s);return n[0]=o,n[4]=0,n[8]=h,n[12]=0,n[1]=0,n[5]=l,n[9]=c,n[13]=0,n[2]=0,n[6]=0,n[10]=d,n[14]=u,n[3]=0,n[7]=0,n[11]=-1,n[15]=0,this}makeOrthographic(e,t,i,r,s,a){let n=this.elements,o=1/(t-e),l=1/(i-r),h=1/(a-s),c=(t+e)*o,d=(i+r)*l,u=(a+s)*h;return n[0]=2*o,n[4]=0,n[8]=0,n[12]=-c,n[1]=0,n[5]=2*l,n[9]=0,n[13]=-d,n[2]=0,n[6]=0,n[10]=-2*h,n[14]=-u,n[3]=0,n[7]=0,n[11]=0,n[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},El=new M,Ps=new we,WR=new M(0,0,0),qR=new M(1,1,1),Pn=new M,su=new M,ts=new M,ib=new we,rb=new lt,ji=class{constructor(e=0,t=0,i=0,r=ji.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,s=r[0],a=r[4],n=r[8],o=r[1],l=r[5],h=r[9],c=r[2],d=r[6],u=r[10];switch(t){case"XYZ":this._y=Math.asin(Ti(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(-h,u),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ti(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(n,u),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ti(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-c,u),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,s));break;case"ZYX":this._y=Math.asin(-Ti(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(o,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Ti(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,s)):(this._x=0,this._y=Math.atan2(n,u));break;case"XZY":this._z=Math.asin(-Ti(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(n,s)):(this._x=Math.atan2(-h,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return ib.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ib,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return rb.setFromEuler(this),this.setFromQuaternion(rb,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ji.DEFAULT_ORDER="XYZ";var jy=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},XR=0,sb=new M,Cl=new lt,Ua=new we,au=new M,hc=new M,YR=new M,QR=new lt,ab=new M(1,0,0),nb=new M(0,1,0),ob=new M(0,0,1),ZR={type:"added"},lb={type:"removed"},kt=class extends yr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:XR++}),this.uuid=ws(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=kt.DEFAULT_UP.clone();let e=new M,t=new ji,i=new lt,r=new M(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new we},normalMatrix:{value:new Di}}),this.matrix=new we,this.matrixWorld=new we,this.matrixAutoUpdate=kt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=kt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new jy,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Cl.setFromAxisAngle(e,t),this.quaternion.multiply(Cl),this}rotateOnWorldAxis(e,t){return Cl.setFromAxisAngle(e,t),this.quaternion.premultiply(Cl),this}rotateX(e){return this.rotateOnAxis(ab,e)}rotateY(e){return this.rotateOnAxis(nb,e)}rotateZ(e){return this.rotateOnAxis(ob,e)}translateOnAxis(e,t){return sb.copy(e).applyQuaternion(this.quaternion),this.position.add(sb.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ab,e)}translateY(e){return this.translateOnAxis(nb,e)}translateZ(e){return this.translateOnAxis(ob,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ua.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?au.copy(e):au.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),hc.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ua.lookAt(hc,au,this.up):Ua.lookAt(au,hc,this.up),this.quaternion.setFromRotationMatrix(Ua),r&&(Ua.extractRotation(r.matrixWorld),Cl.setFromRotationMatrix(Ua),this.quaternion.premultiply(Cl.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(ZR)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(lb)),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){let t=this.children[e];t.parent=null,t.dispatchEvent(lb)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Ua.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ua.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ua),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t){let i=[];this[e]===t&&i.push(this);for(let r=0,s=this.children.length;r<s;r++){let a=this.children[r].getObjectsByProperty(e,t);a.length>0&&(i=i.concat(a))}return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hc,e,YR),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(hc,QR,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++){let s=t[i];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let i=this.parent;if(e===!0&&i!==null&&i.matrixWorldAutoUpdate===!0&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let r=this.children;for(let s=0,a=r.length;s<a;s++){let n=r[s];n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let 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(),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()));function s(n,o){return n[o.uuid]===void 0&&(n[o.uuid]=o.toJSON(e)),o.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let n=this.geometry.parameters;if(n!==void 0&&n.shapes!==void 0){let o=n.shapes;if(Array.isArray(o))for(let l=0,h=o.length;l<h;l++){let c=o[l];s(e.shapes,c)}else s(e.shapes,o)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let n=[];for(let o=0,l=this.material.length;o<l;o++)n.push(s(e.materials,this.material[o]));r.material=n}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let n=0;n<this.children.length;n++)r.children.push(this.children[n].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let n=0;n<this.animations.length;n++){let o=this.animations[n];r.animations.push(s(e.animations,o))}}if(t){let n=a(e.geometries),o=a(e.materials),l=a(e.textures),h=a(e.images),c=a(e.shapes),d=a(e.skeletons),u=a(e.animations),p=a(e.nodes);n.length>0&&(i.geometries=n),o.length>0&&(i.materials=o),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),c.length>0&&(i.shapes=c),d.length>0&&(i.skeletons=d),u.length>0&&(i.animations=u),p.length>0&&(i.nodes=p)}return i.object=r,i;function a(n){let o=[];for(let l in n){let h=n[l];delete h.metadata,o.push(h)}return o}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}};kt.DEFAULT_UP=new M(0,1,0);kt.DEFAULT_MATRIX_AUTO_UPDATE=!0;kt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Ds=new M,Na=new M,Gm=new M,ka=new M,Tl=new M,Pl=new M,hb=new M,Hm=new M,Wm=new M,qm=new M,pr=class{constructor(e=new M,t=new M,i=new M){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Ds.subVectors(e,t),r.cross(Ds);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Ds.subVectors(r,t),Na.subVectors(i,t),Gm.subVectors(e,t);let a=Ds.dot(Ds),n=Ds.dot(Na),o=Ds.dot(Gm),l=Na.dot(Na),h=Na.dot(Gm),c=a*l-n*n;if(c===0)return s.set(-2,-1,-1);let d=1/c,u=(l*o-n*h)*d,p=(a*h-n*o)*d;return s.set(1-u-p,p,u)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,ka),ka.x>=0&&ka.y>=0&&ka.x+ka.y<=1}static getUV(e,t,i,r,s,a,n,o){return this.getBarycoord(e,t,i,r,ka),o.set(0,0),o.addScaledVector(s,ka.x),o.addScaledVector(a,ka.y),o.addScaledVector(n,ka.z),o}static isFrontFacing(e,t,i,r){return Ds.subVectors(i,t),Na.subVectors(e,t),Ds.cross(Na).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ds.subVectors(this.c,this.b),Na.subVectors(this.a,this.b),Ds.cross(Na).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return pr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return pr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,r,s){return pr.getUV(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return pr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return pr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,s=this.c,a,n;Tl.subVectors(r,i),Pl.subVectors(s,i),Hm.subVectors(e,i);let o=Tl.dot(Hm),l=Pl.dot(Hm);if(o<=0&&l<=0)return t.copy(i);Wm.subVectors(e,r);let h=Tl.dot(Wm),c=Pl.dot(Wm);if(h>=0&&c<=h)return t.copy(r);let d=o*c-h*l;if(d<=0&&o>=0&&h<=0)return a=o/(o-h),t.copy(i).addScaledVector(Tl,a);qm.subVectors(e,s);let u=Tl.dot(qm),p=Pl.dot(qm);if(p>=0&&u<=p)return t.copy(s);let f=u*l-o*p;if(f<=0&&l>=0&&p<=0)return n=l/(l-p),t.copy(i).addScaledVector(Pl,n);let g=h*p-u*c;if(g<=0&&c-h>=0&&u-p>=0)return hb.subVectors(s,r),n=(c-h)/(c-h+(u-p)),t.copy(r).addScaledVector(hb,n);let m=1/(g+f+d);return a=f*m,n=d*m,t.copy(i).addScaledVector(Tl,a).addScaledVector(Pl,n)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},KR=0,Ld=class extends yr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:KR++}),this.uuid=ws(),this.name="",this.type="Material",this.blending=Jo,this.side=Ws,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Z2,this.blendDst=K2,this.blendEquation=eh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Pv,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=MR,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Im,this.stencilZFail=Im,this.stencilZPass=Im,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}let r=this[t];if(r===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Jo&&(i.blending=this.blending),this.side!==Ws&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(i.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(i.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=this.flatShading),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){let a=[];for(let n in s){let o=s[n];delete o.metadata,a.push(o)}return a}if(t){let s=r(e.textures),a=r(e.images);s.length>0&&(i.textures=s),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},gn=class extends Ld{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new et(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=J2,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Mi=new M,nu=new j,tt=class{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=Rv,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)nu.fromBufferAttribute(this,t),nu.applyMatrix3(e),this.setXY(t,nu.x,nu.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Mi.fromBufferAttribute(this,t),Mi.applyMatrix3(e),this.setXYZ(t,Mi.x,Mi.y,Mi.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Mi.fromBufferAttribute(this,t),Mi.applyMatrix4(e),this.setXYZ(t,Mi.x,Mi.y,Mi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Mi.fromBufferAttribute(this,t),Mi.applyNormalMatrix(e),this.setXYZ(t,Mi.x,Mi.y,Mi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Mi.fromBufferAttribute(this,t),Mi.transformDirection(e),this.setXYZ(t,Mi.x,Mi.y,Mi.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ln(t,this.array)),t}setX(e,t){return this.normalized&&(t=Kt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ln(t,this.array)),t}setY(e,t){return this.normalized&&(t=Kt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=ln(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Kt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=ln(t,this.array)),t}setW(e,t){return this.normalized&&(t=Kt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Kt(t,this.array),i=Kt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Kt(t,this.array),i=Kt(i,this.array),r=Kt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=Kt(t,this.array),i=Kt(i,this.array),r=Kt(r,this.array),s=Kt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Rv&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}},uM=class extends tt{constructor(e,t,i){super(new Uint16Array(e),t,i)}},mh=class extends tt{constructor(e,t,i){super(new Uint32Array(e),t,i)}},Ie=class extends tt{constructor(e,t,i){super(new Float32Array(e),t,i)}},JR=0,ls=new we,Xm=new kt,Dl=new M,is=new Si,cc=new Si,Qi=new M,Ge=class extends yr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:JR++}),this.uuid=ws(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(nM(e)?mh:uM)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let s=new Di().getNormalMatrix(e);i.applyNormalMatrix(s),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return ls.makeRotationFromQuaternion(e),this.applyMatrix4(ls),this}rotateX(e){return ls.makeRotationX(e),this.applyMatrix4(ls),this}rotateY(e){return ls.makeRotationY(e),this.applyMatrix4(ls),this}rotateZ(e){return ls.makeRotationZ(e),this.applyMatrix4(ls),this}translate(e,t,i){return ls.makeTranslation(e,t,i),this.applyMatrix4(ls),this}scale(e,t,i){return ls.makeScale(e,t,i),this.applyMatrix4(ls),this}lookAt(e){return Xm.lookAt(e),Xm.updateMatrix(),this.applyMatrix4(Xm.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Dl).negate(),this.translate(Dl.x,Dl.y,Dl.z),this}setFromPoints(e){let t=[];for(let i=0,r=e.length;i<r;i++){let s=e[i];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Ie(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Si);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new M(-1/0,-1/0,-1/0),new M(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let s=t[i];is.setFromBufferAttribute(s),this.morphTargetsRelative?(Qi.addVectors(this.boundingBox.min,is.min),this.boundingBox.expandByPoint(Qi),Qi.addVectors(this.boundingBox.max,is.max),this.boundingBox.expandByPoint(Qi)):(this.boundingBox.expandByPoint(is.min),this.boundingBox.expandByPoint(is.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 $r);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new M,1/0);return}if(e){let i=this.boundingSphere.center;if(is.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){let n=t[s];cc.setFromBufferAttribute(n),this.morphTargetsRelative?(Qi.addVectors(is.min,cc.min),is.expandByPoint(Qi),Qi.addVectors(is.max,cc.max),is.expandByPoint(Qi)):(is.expandByPoint(cc.min),is.expandByPoint(cc.max))}is.getCenter(i);let r=0;for(let s=0,a=e.count;s<a;s++)Qi.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(Qi));if(t)for(let s=0,a=t.length;s<a;s++){let n=t[s],o=this.morphTargetsRelative;for(let l=0,h=n.count;l<h;l++)Qi.fromBufferAttribute(n,l),o&&(Dl.fromBufferAttribute(e,l),Qi.add(Dl)),r=Math.max(r,i.distanceToSquared(Qi))}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(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=e.array,r=t.position.array,s=t.normal.array,a=t.uv.array,n=r.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new tt(new Float32Array(4*n),4));let o=this.getAttribute("tangent").array,l=[],h=[];for(let E=0;E<n;E++)l[E]=new M,h[E]=new M;let c=new M,d=new M,u=new M,p=new j,f=new j,g=new j,m=new M,v=new M;function y(E,C,T){c.fromArray(r,E*3),d.fromArray(r,C*3),u.fromArray(r,T*3),p.fromArray(a,E*2),f.fromArray(a,C*2),g.fromArray(a,T*2),d.sub(c),u.sub(c),f.sub(p),g.sub(p);let D=1/(f.x*g.y-g.x*f.y);!isFinite(D)||(m.copy(d).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(D),v.copy(u).multiplyScalar(f.x).addScaledVector(d,-g.x).multiplyScalar(D),l[E].add(m),l[C].add(m),l[T].add(m),h[E].add(v),h[C].add(v),h[T].add(v))}let x=this.groups;x.length===0&&(x=[{start:0,count:i.length}]);for(let E=0,C=x.length;E<C;++E){let T=x[E],D=T.start,O=T.count;for(let P=D,U=D+O;P<U;P+=3)y(i[P+0],i[P+1],i[P+2])}let w=new M,_=new M,b=new M,A=new M;function S(E){b.fromArray(s,E*3),A.copy(b);let C=l[E];w.copy(C),w.sub(b.multiplyScalar(b.dot(C))).normalize(),_.crossVectors(A,C);let T=_.dot(h[E])<0?-1:1;o[E*4]=w.x,o[E*4+1]=w.y,o[E*4+2]=w.z,o[E*4+3]=T}for(let E=0,C=x.length;E<C;++E){let T=x[E],D=T.start,O=T.count;for(let P=D,U=D+O;P<U;P+=3)S(i[P+0]),S(i[P+1]),S(i[P+2])}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new tt(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,u=i.count;d<u;d++)i.setXYZ(d,0,0,0);let r=new M,s=new M,a=new M,n=new M,o=new M,l=new M,h=new M,c=new M;if(e)for(let d=0,u=e.count;d<u;d+=3){let p=e.getX(d+0),f=e.getX(d+1),g=e.getX(d+2);r.fromBufferAttribute(t,p),s.fromBufferAttribute(t,f),a.fromBufferAttribute(t,g),h.subVectors(a,s),c.subVectors(r,s),h.cross(c),n.fromBufferAttribute(i,p),o.fromBufferAttribute(i,f),l.fromBufferAttribute(i,g),n.add(h),o.add(h),l.add(h),i.setXYZ(p,n.x,n.y,n.z),i.setXYZ(f,o.x,o.y,o.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let d=0,u=t.count;d<u;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,s),c.subVectors(r,s),h.cross(c),i.setXYZ(d+0,h.x,h.y,h.z),i.setXYZ(d+1,h.x,h.y,h.z),i.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeBufferGeometries() instead."),this}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Qi.fromBufferAttribute(e,t),Qi.normalize(),e.setXYZ(t,Qi.x,Qi.y,Qi.z)}toNonIndexed(){function e(n,o){let l=n.array,h=n.itemSize,c=n.normalized,d=new l.constructor(o.length*h),u=0,p=0;for(let f=0,g=o.length;f<g;f++){n.isInterleavedBufferAttribute?u=o[f]*n.data.stride+n.offset:u=o[f]*h;for(let m=0;m<h;m++)d[p++]=l[u++]}return new tt(d,h,c)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new Ge,i=this.index.array,r=this.attributes;for(let n in r){let o=r[n],l=e(o,i);t.setAttribute(n,l)}let s=this.morphAttributes;for(let n in s){let o=[],l=s[n];for(let h=0,c=l.length;h<c;h++){let d=l[h],u=e(d,i);o.push(u)}t.morphAttributes[n]=o}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let n=0,o=a.length;n<o;n++){let l=a[n];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let o=this.parameters;for(let l in o)o[l]!==void 0&&(e[l]=o[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let o in i){let l=i[o];e.data.attributes[o]=l.toJSON(e.data)}let r={},s=!1;for(let o in this.morphAttributes){let l=this.morphAttributes[o],h=[];for(let c=0,d=l.length;c<d;c++){let u=l[c];h.push(u.toJSON(e.data))}h.length>0&&(r[o]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let n=this.boundingSphere;return n!==null&&(e.data.boundingSphere={center:n.center.toArray(),radius:n.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone(t));let r=e.attributes;for(let l in r){let h=r[l];this.setAttribute(l,h.clone(t))}let s=e.morphAttributes;for(let l in s){let h=[],c=s[l];for(let d=0,u=c.length;d<u;d++)h.push(c[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let l=0,h=a.length;l<h;l++){let c=a[l];this.addGroup(c.start,c.count,c.materialIndex)}let n=e.boundingBox;n!==null&&(this.boundingBox=n.clone());let o=e.boundingSphere;return o!==null&&(this.boundingSphere=o.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,e.parameters!==void 0&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}},cb=new we,Il=new Hh,Ym=new $r,dc=new M,uc=new M,pc=new M,Qm=new M,ou=new M,lu=new j,hu=new j,cu=new j,Zm=new M,du=new M,Jt=class extends kt{constructor(e=new Ge,t=new gn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let n=this.morphTargetInfluences;if(s&&n){ou.set(0,0,0);for(let o=0,l=s.length;o<l;o++){let h=n[o],c=s[o];h!==0&&(Qm.fromBufferAttribute(c,e),a?ou.addScaledVector(Qm,h):ou.addScaledVector(Qm.sub(t),h))}t.add(ou)}return this.isSkinnedMesh&&this.boneTransform(e,t),t}raycast(e,t){let i=this.geometry,r=this.material,s=this.matrixWorld;if(r===void 0||(i.boundingSphere===null&&i.computeBoundingSphere(),Ym.copy(i.boundingSphere),Ym.applyMatrix4(s),e.ray.intersectsSphere(Ym)===!1)||(cb.copy(s).invert(),Il.copy(e.ray).applyMatrix4(cb),i.boundingBox!==null&&Il.intersectsBox(i.boundingBox)===!1))return;let a,n=i.index,o=i.attributes.position,l=i.attributes.uv,h=i.attributes.uv2,c=i.groups,d=i.drawRange;if(n!==null)if(Array.isArray(r))for(let u=0,p=c.length;u<p;u++){let f=c[u],g=r[f.materialIndex],m=Math.max(f.start,d.start),v=Math.min(n.count,Math.min(f.start+f.count,d.start+d.count));for(let y=m,x=v;y<x;y+=3){let w=n.getX(y),_=n.getX(y+1),b=n.getX(y+2);a=uu(this,g,e,Il,l,h,w,_,b),a&&(a.faceIndex=Math.floor(y/3),a.face.materialIndex=f.materialIndex,t.push(a))}}else{let u=Math.max(0,d.start),p=Math.min(n.count,d.start+d.count);for(let f=u,g=p;f<g;f+=3){let m=n.getX(f),v=n.getX(f+1),y=n.getX(f+2);a=uu(this,r,e,Il,l,h,m,v,y),a&&(a.faceIndex=Math.floor(f/3),t.push(a))}}else if(o!==void 0)if(Array.isArray(r))for(let u=0,p=c.length;u<p;u++){let f=c[u],g=r[f.materialIndex],m=Math.max(f.start,d.start),v=Math.min(o.count,Math.min(f.start+f.count,d.start+d.count));for(let y=m,x=v;y<x;y+=3){let w=y,_=y+1,b=y+2;a=uu(this,g,e,Il,l,h,w,_,b),a&&(a.faceIndex=Math.floor(y/3),a.face.materialIndex=f.materialIndex,t.push(a))}}else{let u=Math.max(0,d.start),p=Math.min(o.count,d.start+d.count);for(let f=u,g=p;f<g;f+=3){let m=f,v=f+1,y=f+2;a=uu(this,r,e,Il,l,h,m,v,y),a&&(a.faceIndex=Math.floor(f/3),t.push(a))}}}};function $R(e,t,i,r,s,a,n,o){let l;if(t.side===rr?l=r.intersectTriangle(n,a,s,!0,o):l=r.intersectTriangle(s,a,n,t.side===Ws,o),l===null)return null;du.copy(o),du.applyMatrix4(e.matrixWorld);let h=i.ray.origin.distanceTo(du);return h<i.near||h>i.far?null:{distance:h,point:du.clone(),object:e}}function uu(e,t,i,r,s,a,n,o,l){e.getVertexPosition(n,dc),e.getVertexPosition(o,uc),e.getVertexPosition(l,pc);let h=$R(e,t,i,r,dc,uc,pc,Zm);if(h){s&&(lu.fromBufferAttribute(s,n),hu.fromBufferAttribute(s,o),cu.fromBufferAttribute(s,l),h.uv=pr.getUV(Zm,dc,uc,pc,lu,hu,cu,new j)),a&&(lu.fromBufferAttribute(a,n),hu.fromBufferAttribute(a,o),cu.fromBufferAttribute(a,l),h.uv2=pr.getUV(Zm,dc,uc,pc,lu,hu,cu,new j));let c={a:n,b:o,c:l,normal:new M,materialIndex:0};pr.getNormal(dc,uc,pc,c.normal),h.face=c}return h}var Xs=class extends Ge{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:a};let n=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);let o=[],l=[],h=[],c=[],d=0,u=0;p("z","y","x",-1,-1,i,t,e,a,s,0),p("z","y","x",1,-1,i,t,-e,a,s,1),p("x","z","y",1,1,e,i,t,r,a,2),p("x","z","y",1,-1,e,i,-t,r,a,3),p("x","y","z",1,-1,e,t,i,r,s,4),p("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(o),this.setAttribute("position",new Ie(l,3)),this.setAttribute("normal",new Ie(h,3)),this.setAttribute("uv",new Ie(c,2));function p(f,g,m,v,y,x,w,_,b,A,S){let E=x/b,C=w/A,T=x/2,D=w/2,O=_/2,P=b+1,U=A+1,W=0,k=0,F=new M;for(let Z=0;Z<U;Z++){let X=Z*C-D;for(let G=0;G<P;G++){let q=G*E-T;F[f]=q*v,F[g]=X*y,F[m]=O,l.push(F.x,F.y,F.z),F[f]=0,F[g]=0,F[m]=_>0?1:-1,h.push(F.x,F.y,F.z),c.push(G/b),c.push(1-Z/A),W+=1}}for(let Z=0;Z<A;Z++)for(let X=0;X<b;X++){let G=d+X+P*Z,q=d+X+P*(Z+1),$=d+(X+1)+P*(Z+1),Q=d+(X+1)+P*Z;o.push(G,q,Q),o.push(q,$,Q),k+=6}n.addGroup(u,k,S),u+=k,d+=W}}static fromJSON(e){return new Xs(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Th(e){let t={};for(let i in e){t[i]={};for(let r in e[i]){let s=e[i][r];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?t[i][r]=s.clone():Array.isArray(s)?t[i][r]=s.slice():t[i][r]=s}}return t}function Lr(e){let t={};for(let i=0;i<e.length;i++){let r=Th(e[i]);for(let s in r)t[s]=r[s]}return t}function eL(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].clone());return t}function pM(e){return e.getRenderTarget()===null&&e.outputEncoding===gt?pa:jp}var Wh={clone:Th,merge:Lr},tL=`void main() {
  9. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  10. }`,iL=`void main() {
  11. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  12. }`,Dt=class extends Ld{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=tL,this.fragmentShader=iL,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Th(e.uniforms),this.uniformsGroups=eL(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let s=this.uniforms[r].value;s&&s.isTexture?t.uniforms[r]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[r]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[r]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[r]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[r]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[r]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[r]={type:"m4",value:s.toArray()}:t.uniforms[r]={value:s}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},bo=class extends kt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new we,this.projectionMatrix=new we,this.projectionMatrixInverse=new we}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},_r=class extends bo{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=cd*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Xc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return cd*2*Math.atan(Math.tan(Xc*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,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(){let e=this.near,t=e*Math.tan(Xc*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let o=a.fullWidth,l=a.fullHeight;s+=a.offsetX*r/o,t-=a.offsetY*i/l,r*=a.width/o,i*=a.height/l}let n=this.filmOffset;n!==0&&(s+=e*n/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Ol=-90,Rl=1,rL=class extends kt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i;let r=new _r(Ol,Rl,e,t);r.layers=this.layers,r.up.set(0,1,0),r.lookAt(1,0,0),this.add(r);let s=new _r(Ol,Rl,e,t);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(-1,0,0),this.add(s);let a=new _r(Ol,Rl,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(0,1,0),this.add(a);let n=new _r(Ol,Rl,e,t);n.layers=this.layers,n.up.set(0,0,1),n.lookAt(0,-1,0),this.add(n);let o=new _r(Ol,Rl,e,t);o.layers=this.layers,o.up.set(0,1,0),o.lookAt(0,0,1),this.add(o);let l=new _r(Ol,Rl,e,t);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,-1),this.add(l)}update(e,t){this.parent===null&&this.updateMatrixWorld();let i=this.renderTarget,[r,s,a,n,o,l]=this.children,h=e.getRenderTarget(),c=e.toneMapping,d=e.xr.enabled;e.toneMapping=_a,e.xr.enabled=!1;let u=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,r),e.setRenderTarget(i,1),e.render(t,s),e.setRenderTarget(i,2),e.render(t,a),e.setRenderTarget(i,3),e.render(t,n),e.setRenderTarget(i,4),e.render(t,o),i.texture.generateMipmaps=u,e.setRenderTarget(i,5),e.render(t,l),e.setRenderTarget(h),e.toneMapping=c,e.xr.enabled=d,i.texture.needsPMREMUpdate=!0}},Gy=class extends ci{constructor(e,t,i,r,s,a,n,o,l,h){e=e!==void 0?e:[],t=t!==void 0?t:al,super(e,t,i,r,s,a,n,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},sL=class extends Pt{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Gy(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:xt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
  13. varying vec3 vWorldDirection;
  14. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  15. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  16. }
  17. void main() {
  18. vWorldDirection = transformDirection( position, modelMatrix );
  19. #include <begin_vertex>
  20. #include <project_vertex>
  21. }
  22. `,fragmentShader:`
  23. uniform sampler2D tEquirect;
  24. varying vec3 vWorldDirection;
  25. #include <common>
  26. void main() {
  27. vec3 direction = normalize( vWorldDirection );
  28. vec2 sampleUV = equirectUv( direction );
  29. gl_FragColor = texture2D( tEquirect, sampleUV );
  30. }
  31. `},r=new Xs(5,5,5),s=new Dt({name:"CubemapFromEquirect",uniforms:Th(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:rr,blending:Oi});s.uniforms.tEquirect.value=t;let a=new Jt(r,s),n=t.minFilter;return t.minFilter===Ch&&(t.minFilter=xt),new rL(1,10,this).update(e,a),t.minFilter=n,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,i,r){let s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(s)}},Km=new M,aL=new M,nL=new Di,qr=class{constructor(e=new M(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=Km.subVectors(i,t).cross(aL.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){let i=e.delta(Km),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(i).multiplyScalar(s).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||nL.getNormalMatrix(e),r=this.coplanarPoint(Km).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Ll=new $r,pu=new M,Hy=class{constructor(e=new qr,t=new qr,i=new qr,r=new qr,s=new qr,a=new qr){this.planes=[e,t,i,r,s,a]}set(e,t,i,r,s,a){let n=this.planes;return n[0].copy(e),n[1].copy(t),n[2].copy(i),n[3].copy(r),n[4].copy(s),n[5].copy(a),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){let t=this.planes,i=e.elements,r=i[0],s=i[1],a=i[2],n=i[3],o=i[4],l=i[5],h=i[6],c=i[7],d=i[8],u=i[9],p=i[10],f=i[11],g=i[12],m=i[13],v=i[14],y=i[15];return t[0].setComponents(n-r,c-o,f-d,y-g).normalize(),t[1].setComponents(n+r,c+o,f+d,y+g).normalize(),t[2].setComponents(n+s,c+l,f+u,y+m).normalize(),t[3].setComponents(n-s,c-l,f-u,y-m).normalize(),t[4].setComponents(n-a,c-h,f-p,y-v).normalize(),t[5].setComponents(n+a,c+h,f+p,y+v).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),Ll.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Ll)}intersectsSprite(e){return Ll.center.set(0,0,0),Ll.radius=.7071067811865476,Ll.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ll)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(pu.x=r.normal.x>0?e.max.x:e.min.x,pu.y=r.normal.y>0?e.max.y:e.min.y,pu.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(pu)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function fM(){let e=null,t=!1,i=null,r=null;function s(a,n){i(a,n),r=e.requestAnimationFrame(s)}return{start:function(){t!==!0&&i!==null&&(r=e.requestAnimationFrame(s),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(a){i=a},setContext:function(a){e=a}}}function oL(e,t){let i=t.isWebGL2,r=new WeakMap;function s(h,c){let d=h.array,u=h.usage,p=e.createBuffer();e.bindBuffer(c,p),e.bufferData(c,d,u),h.onUploadCallback();let f;if(d instanceof Float32Array)f=5126;else if(d instanceof Uint16Array)if(h.isFloat16BufferAttribute)if(i)f=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else f=5123;else if(d instanceof Int16Array)f=5122;else if(d instanceof Uint32Array)f=5125;else if(d instanceof Int32Array)f=5124;else if(d instanceof Int8Array)f=5120;else if(d instanceof Uint8Array)f=5121;else if(d instanceof Uint8ClampedArray)f=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:p,type:f,bytesPerElement:d.BYTES_PER_ELEMENT,version:h.version}}function a(h,c,d){let u=c.array,p=c.updateRange;e.bindBuffer(d,h),p.count===-1?e.bufferSubData(d,0,u):(i?e.bufferSubData(d,p.offset*u.BYTES_PER_ELEMENT,u,p.offset,p.count):e.bufferSubData(d,p.offset*u.BYTES_PER_ELEMENT,u.subarray(p.offset,p.offset+p.count)),p.count=-1),c.onUploadCallback()}function n(h){return h.isInterleavedBufferAttribute&&(h=h.data),r.get(h)}function o(h){h.isInterleavedBufferAttribute&&(h=h.data);let c=r.get(h);c&&(e.deleteBuffer(c.buffer),r.delete(h))}function l(h,c){if(h.isGLBufferAttribute){let u=r.get(h);(!u||u.version<h.version)&&r.set(h,{buffer:h.buffer,type:h.type,bytesPerElement:h.elementSize,version:h.version});return}h.isInterleavedBufferAttribute&&(h=h.data);let d=r.get(h);d===void 0?r.set(h,s(h,c)):d.version<h.version&&(a(d.buffer,h,c),d.version=h.version)}return{get:n,remove:o,update:l}}var Ea=class extends Ge{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let s=e/2,a=t/2,n=Math.floor(i),o=Math.floor(r),l=n+1,h=o+1,c=e/n,d=t/o,u=[],p=[],f=[],g=[];for(let m=0;m<h;m++){let v=m*d-a;for(let y=0;y<l;y++){let x=y*c-s;p.push(x,-v,0),f.push(0,0,1),g.push(y/n),g.push(1-m/o)}}for(let m=0;m<o;m++)for(let v=0;v<n;v++){let y=v+l*m,x=v+l*(m+1),w=v+1+l*(m+1),_=v+1+l*m;u.push(y,x,_),u.push(x,w,_)}this.setIndex(u),this.setAttribute("position",new Ie(p,3)),this.setAttribute("normal",new Ie(f,3)),this.setAttribute("uv",new Ie(g,2))}static fromJSON(e){return new Ea(e.width,e.height,e.widthSegments,e.heightSegments)}},lL=`#ifdef USE_ALPHAMAP
  32. diffuseColor.a *= texture2D( alphaMap, vUv ).g;
  33. #endif`,hL=`#ifdef USE_ALPHAMAP
  34. uniform sampler2D alphaMap;
  35. #endif`,cL=`#ifdef USE_ALPHATEST
  36. if ( diffuseColor.a < alphaTest ) discard;
  37. #endif`,dL=`#ifdef USE_ALPHATEST
  38. uniform float alphaTest;
  39. #endif`,uL=`#ifdef USE_AOMAP
  40. float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
  41. reflectedLight.indirectDiffuse *= ambientOcclusion;
  42. #if defined( USE_ENVMAP ) && defined( STANDARD )
  43. float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
  44. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  45. #endif
  46. #endif`,pL=`#ifdef USE_AOMAP
  47. uniform sampler2D aoMap;
  48. uniform float aoMapIntensity;
  49. #endif`,fL="vec3 transformed = vec3( position );",mL=`vec3 objectNormal = vec3( normal );
  50. #ifdef USE_TANGENT
  51. vec3 objectTangent = vec3( tangent.xyz );
  52. #endif`,gL=`vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  53. return RECIPROCAL_PI * diffuseColor;
  54. }
  55. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  56. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  57. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  58. }
  59. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  60. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  61. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  62. }
  63. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  64. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  65. float x2 = x * x;
  66. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  67. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  68. }
  69. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  70. float a2 = pow2( alpha );
  71. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  72. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  73. return 0.5 / max( gv + gl, EPSILON );
  74. }
  75. float D_GGX( const in float alpha, const in float dotNH ) {
  76. float a2 = pow2( alpha );
  77. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  78. return RECIPROCAL_PI * a2 / pow2( denom );
  79. }
  80. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {
  81. float alpha = pow2( roughness );
  82. vec3 halfDir = normalize( lightDir + viewDir );
  83. float dotNL = saturate( dot( normal, lightDir ) );
  84. float dotNV = saturate( dot( normal, viewDir ) );
  85. float dotNH = saturate( dot( normal, halfDir ) );
  86. float dotVH = saturate( dot( viewDir, halfDir ) );
  87. vec3 F = F_Schlick( f0, f90, dotVH );
  88. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  89. float D = D_GGX( alpha, dotNH );
  90. return F * ( V * D );
  91. }
  92. #ifdef USE_IRIDESCENCE
  93. vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {
  94. float alpha = pow2( roughness );
  95. vec3 halfDir = normalize( lightDir + viewDir );
  96. float dotNL = saturate( dot( normal, lightDir ) );
  97. float dotNV = saturate( dot( normal, viewDir ) );
  98. float dotNH = saturate( dot( normal, halfDir ) );
  99. float dotVH = saturate( dot( viewDir, halfDir ) );
  100. vec3 F = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );
  101. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  102. float D = D_GGX( alpha, dotNH );
  103. return F * ( V * D );
  104. }
  105. #endif
  106. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  107. const float LUT_SIZE = 64.0;
  108. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  109. const float LUT_BIAS = 0.5 / LUT_SIZE;
  110. float dotNV = saturate( dot( N, V ) );
  111. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  112. uv = uv * LUT_SCALE + LUT_BIAS;
  113. return uv;
  114. }
  115. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  116. float l = length( f );
  117. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  118. }
  119. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  120. float x = dot( v1, v2 );
  121. float y = abs( x );
  122. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  123. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  124. float v = a / b;
  125. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  126. return cross( v1, v2 ) * theta_sintheta;
  127. }
  128. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  129. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  130. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  131. vec3 lightNormal = cross( v1, v2 );
  132. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  133. vec3 T1, T2;
  134. T1 = normalize( V - N * dot( V, N ) );
  135. T2 = - cross( N, T1 );
  136. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  137. vec3 coords[ 4 ];
  138. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  139. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  140. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  141. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  142. coords[ 0 ] = normalize( coords[ 0 ] );
  143. coords[ 1 ] = normalize( coords[ 1 ] );
  144. coords[ 2 ] = normalize( coords[ 2 ] );
  145. coords[ 3 ] = normalize( coords[ 3 ] );
  146. vec3 vectorFormFactor = vec3( 0.0 );
  147. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  148. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  149. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  150. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  151. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  152. return vec3( result );
  153. }
  154. float G_BlinnPhong_Implicit( ) {
  155. return 0.25;
  156. }
  157. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  158. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  159. }
  160. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  161. vec3 halfDir = normalize( lightDir + viewDir );
  162. float dotNH = saturate( dot( normal, halfDir ) );
  163. float dotVH = saturate( dot( viewDir, halfDir ) );
  164. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  165. float G = G_BlinnPhong_Implicit( );
  166. float D = D_BlinnPhong( shininess, dotNH );
  167. return F * ( G * D );
  168. }
  169. #if defined( USE_SHEEN )
  170. float D_Charlie( float roughness, float dotNH ) {
  171. float alpha = pow2( roughness );
  172. float invAlpha = 1.0 / alpha;
  173. float cos2h = dotNH * dotNH;
  174. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  175. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  176. }
  177. float V_Neubelt( float dotNV, float dotNL ) {
  178. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  179. }
  180. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  181. vec3 halfDir = normalize( lightDir + viewDir );
  182. float dotNL = saturate( dot( normal, lightDir ) );
  183. float dotNV = saturate( dot( normal, viewDir ) );
  184. float dotNH = saturate( dot( normal, halfDir ) );
  185. float D = D_Charlie( sheenRoughness, dotNH );
  186. float V = V_Neubelt( dotNV, dotNL );
  187. return sheenColor * ( D * V );
  188. }
  189. #endif`,vL=`#ifdef USE_IRIDESCENCE
  190. const mat3 XYZ_TO_REC709 = mat3(
  191. 3.2404542, -0.9692660, 0.0556434,
  192. -1.5371385, 1.8760108, -0.2040259,
  193. -0.4985314, 0.0415560, 1.0572252
  194. );
  195. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  196. vec3 sqrtF0 = sqrt( fresnel0 );
  197. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  198. }
  199. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  200. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  201. }
  202. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  203. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  204. }
  205. vec3 evalSensitivity( float OPD, vec3 shift ) {
  206. float phase = 2.0 * PI * OPD * 1.0e-9;
  207. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  208. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  209. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  210. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  211. 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 ) );
  212. xyz /= 1.0685e-7;
  213. vec3 rgb = XYZ_TO_REC709 * xyz;
  214. return rgb;
  215. }
  216. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  217. vec3 I;
  218. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  219. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  220. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  221. if ( cosTheta2Sq < 0.0 ) {
  222. return vec3( 1.0 );
  223. }
  224. float cosTheta2 = sqrt( cosTheta2Sq );
  225. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  226. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  227. float R21 = R12;
  228. float T121 = 1.0 - R12;
  229. float phi12 = 0.0;
  230. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  231. float phi21 = PI - phi12;
  232. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  233. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  234. vec3 phi23 = vec3( 0.0 );
  235. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  236. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  237. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  238. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  239. vec3 phi = vec3( phi21 ) + phi23;
  240. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  241. vec3 r123 = sqrt( R123 );
  242. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  243. vec3 C0 = R12 + Rs;
  244. I = C0;
  245. vec3 Cm = Rs - T121;
  246. for ( int m = 1; m <= 2; ++ m ) {
  247. Cm *= r123;
  248. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  249. I += Cm * Sm;
  250. }
  251. return max( I, vec3( 0.0 ) );
  252. }
  253. #endif`,yL=`#ifdef USE_BUMPMAP
  254. uniform sampler2D bumpMap;
  255. uniform float bumpScale;
  256. vec2 dHdxy_fwd() {
  257. vec2 dSTdx = dFdx( vUv );
  258. vec2 dSTdy = dFdy( vUv );
  259. float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
  260. float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
  261. float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
  262. return vec2( dBx, dBy );
  263. }
  264. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  265. vec3 vSigmaX = dFdx( surf_pos.xyz );
  266. vec3 vSigmaY = dFdy( surf_pos.xyz );
  267. vec3 vN = surf_norm;
  268. vec3 R1 = cross( vSigmaY, vN );
  269. vec3 R2 = cross( vN, vSigmaX );
  270. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  271. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  272. return normalize( abs( fDet ) * surf_norm - vGrad );
  273. }
  274. #endif`,xL=`#if NUM_CLIPPING_PLANES > 0
  275. vec4 plane;
  276. #pragma unroll_loop_start
  277. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  278. plane = clippingPlanes[ i ];
  279. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  280. }
  281. #pragma unroll_loop_end
  282. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  283. bool clipped = true;
  284. #pragma unroll_loop_start
  285. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  286. plane = clippingPlanes[ i ];
  287. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  288. }
  289. #pragma unroll_loop_end
  290. if ( clipped ) discard;
  291. #endif
  292. #endif`,bL=`#if NUM_CLIPPING_PLANES > 0
  293. varying vec3 vClipPosition;
  294. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  295. #endif`,wL=`#if NUM_CLIPPING_PLANES > 0
  296. varying vec3 vClipPosition;
  297. #endif`,_L=`#if NUM_CLIPPING_PLANES > 0
  298. vClipPosition = - mvPosition.xyz;
  299. #endif`,SL=`#if defined( USE_COLOR_ALPHA )
  300. diffuseColor *= vColor;
  301. #elif defined( USE_COLOR )
  302. diffuseColor.rgb *= vColor;
  303. #endif`,AL=`#if defined( USE_COLOR_ALPHA )
  304. varying vec4 vColor;
  305. #elif defined( USE_COLOR )
  306. varying vec3 vColor;
  307. #endif`,ML=`#if defined( USE_COLOR_ALPHA )
  308. varying vec4 vColor;
  309. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  310. varying vec3 vColor;
  311. #endif`,EL=`#if defined( USE_COLOR_ALPHA )
  312. vColor = vec4( 1.0 );
  313. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  314. vColor = vec3( 1.0 );
  315. #endif
  316. #ifdef USE_COLOR
  317. vColor *= color;
  318. #endif
  319. #ifdef USE_INSTANCING_COLOR
  320. vColor.xyz *= instanceColor.xyz;
  321. #endif`,CL=`#define PI 3.141592653589793
  322. #define PI2 6.283185307179586
  323. #define PI_HALF 1.5707963267948966
  324. #define RECIPROCAL_PI 0.3183098861837907
  325. #define RECIPROCAL_PI2 0.15915494309189535
  326. #define EPSILON 1e-6
  327. #ifndef saturate
  328. #define saturate( a ) clamp( a, 0.0, 1.0 )
  329. #endif
  330. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  331. float pow2( const in float x ) { return x*x; }
  332. vec3 pow2( const in vec3 x ) { return x*x; }
  333. float pow3( const in float x ) { return x*x*x; }
  334. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  335. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  336. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  337. highp float rand( const in vec2 uv ) {
  338. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  339. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  340. return fract( sin( sn ) * c );
  341. }
  342. #ifdef HIGH_PRECISION
  343. float precisionSafeLength( vec3 v ) { return length( v ); }
  344. #else
  345. float precisionSafeLength( vec3 v ) {
  346. float maxComponent = max3( abs( v ) );
  347. return length( v / maxComponent ) * maxComponent;
  348. }
  349. #endif
  350. struct IncidentLight {
  351. vec3 color;
  352. vec3 direction;
  353. bool visible;
  354. };
  355. struct ReflectedLight {
  356. vec3 directDiffuse;
  357. vec3 directSpecular;
  358. vec3 indirectDiffuse;
  359. vec3 indirectSpecular;
  360. };
  361. struct GeometricContext {
  362. vec3 position;
  363. vec3 normal;
  364. vec3 viewDir;
  365. #ifdef USE_CLEARCOAT
  366. vec3 clearcoatNormal;
  367. #endif
  368. };
  369. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  370. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  371. }
  372. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  373. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  374. }
  375. mat3 transposeMat3( const in mat3 m ) {
  376. mat3 tmp;
  377. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  378. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  379. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  380. return tmp;
  381. }
  382. float luminance( const in vec3 rgb ) {
  383. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  384. return dot( weights, rgb );
  385. }
  386. bool isPerspectiveMatrix( mat4 m ) {
  387. return m[ 2 ][ 3 ] == - 1.0;
  388. }
  389. vec2 equirectUv( in vec3 dir ) {
  390. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  391. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  392. return vec2( u, v );
  393. }`,TL=`#ifdef ENVMAP_TYPE_CUBE_UV
  394. #define cubeUV_minMipLevel 4.0
  395. #define cubeUV_minTileSize 16.0
  396. float getFace( vec3 direction ) {
  397. vec3 absDirection = abs( direction );
  398. float face = - 1.0;
  399. if ( absDirection.x > absDirection.z ) {
  400. if ( absDirection.x > absDirection.y )
  401. face = direction.x > 0.0 ? 0.0 : 3.0;
  402. else
  403. face = direction.y > 0.0 ? 1.0 : 4.0;
  404. } else {
  405. if ( absDirection.z > absDirection.y )
  406. face = direction.z > 0.0 ? 2.0 : 5.0;
  407. else
  408. face = direction.y > 0.0 ? 1.0 : 4.0;
  409. }
  410. return face;
  411. }
  412. vec2 getUV( vec3 direction, float face ) {
  413. vec2 uv;
  414. if ( face == 0.0 ) {
  415. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  416. } else if ( face == 1.0 ) {
  417. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  418. } else if ( face == 2.0 ) {
  419. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  420. } else if ( face == 3.0 ) {
  421. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  422. } else if ( face == 4.0 ) {
  423. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  424. } else {
  425. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  426. }
  427. return 0.5 * ( uv + 1.0 );
  428. }
  429. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  430. float face = getFace( direction );
  431. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  432. mipInt = max( mipInt, cubeUV_minMipLevel );
  433. float faceSize = exp2( mipInt );
  434. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  435. if ( face > 2.0 ) {
  436. uv.y += faceSize;
  437. face -= 3.0;
  438. }
  439. uv.x += face * faceSize;
  440. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  441. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  442. uv.x *= CUBEUV_TEXEL_WIDTH;
  443. uv.y *= CUBEUV_TEXEL_HEIGHT;
  444. #ifdef texture2DGradEXT
  445. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  446. #else
  447. return texture2D( envMap, uv ).rgb;
  448. #endif
  449. }
  450. #define cubeUV_r0 1.0
  451. #define cubeUV_v0 0.339
  452. #define cubeUV_m0 - 2.0
  453. #define cubeUV_r1 0.8
  454. #define cubeUV_v1 0.276
  455. #define cubeUV_m1 - 1.0
  456. #define cubeUV_r4 0.4
  457. #define cubeUV_v4 0.046
  458. #define cubeUV_m4 2.0
  459. #define cubeUV_r5 0.305
  460. #define cubeUV_v5 0.016
  461. #define cubeUV_m5 3.0
  462. #define cubeUV_r6 0.21
  463. #define cubeUV_v6 0.0038
  464. #define cubeUV_m6 4.0
  465. float roughnessToMip( float roughness ) {
  466. float mip = 0.0;
  467. if ( roughness >= cubeUV_r1 ) {
  468. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  469. } else if ( roughness >= cubeUV_r4 ) {
  470. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  471. } else if ( roughness >= cubeUV_r5 ) {
  472. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  473. } else if ( roughness >= cubeUV_r6 ) {
  474. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  475. } else {
  476. mip = - 2.0 * log2( 1.16 * roughness ); }
  477. return mip;
  478. }
  479. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  480. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  481. float mipF = fract( mip );
  482. float mipInt = floor( mip );
  483. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  484. if ( mipF == 0.0 ) {
  485. return vec4( color0, 1.0 );
  486. } else {
  487. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  488. return vec4( mix( color0, color1, mipF ), 1.0 );
  489. }
  490. }
  491. #endif`,PL=`vec3 transformedNormal = objectNormal;
  492. #ifdef USE_INSTANCING
  493. mat3 m = mat3( instanceMatrix );
  494. transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
  495. transformedNormal = m * transformedNormal;
  496. #endif
  497. transformedNormal = normalMatrix * transformedNormal;
  498. #ifdef FLIP_SIDED
  499. transformedNormal = - transformedNormal;
  500. #endif
  501. #ifdef USE_TANGENT
  502. vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  503. #ifdef FLIP_SIDED
  504. transformedTangent = - transformedTangent;
  505. #endif
  506. #endif`,DL=`#ifdef USE_DISPLACEMENTMAP
  507. uniform sampler2D displacementMap;
  508. uniform float displacementScale;
  509. uniform float displacementBias;
  510. #endif`,IL=`#ifdef USE_DISPLACEMENTMAP
  511. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
  512. #endif`,OL=`#ifdef USE_EMISSIVEMAP
  513. vec4 emissiveColor = texture2D( emissiveMap, vUv );
  514. totalEmissiveRadiance *= emissiveColor.rgb;
  515. #endif`,RL=`#ifdef USE_EMISSIVEMAP
  516. uniform sampler2D emissiveMap;
  517. #endif`,LL="gl_FragColor = linearToOutputTexel( gl_FragColor );",zL=`vec4 LinearToLinear( in vec4 value ) {
  518. return value;
  519. }
  520. vec4 LinearTosRGB( in vec4 value ) {
  521. 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 );
  522. }`,BL=`#ifdef USE_ENVMAP
  523. #ifdef ENV_WORLDPOS
  524. vec3 cameraToFrag;
  525. if ( isOrthographic ) {
  526. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  527. } else {
  528. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  529. }
  530. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  531. #ifdef ENVMAP_MODE_REFLECTION
  532. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  533. #else
  534. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  535. #endif
  536. #else
  537. vec3 reflectVec = vReflect;
  538. #endif
  539. #ifdef ENVMAP_TYPE_CUBE
  540. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  541. #else
  542. vec4 envColor = vec4( 0.0 );
  543. #endif
  544. #ifdef ENVMAP_BLENDING_MULTIPLY
  545. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  546. #elif defined( ENVMAP_BLENDING_MIX )
  547. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  548. #elif defined( ENVMAP_BLENDING_ADD )
  549. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  550. #endif
  551. #endif`,FL=`#ifdef USE_ENVMAP
  552. uniform float envMapIntensity;
  553. uniform float flipEnvMap;
  554. #ifdef ENVMAP_TYPE_CUBE
  555. uniform samplerCube envMap;
  556. #else
  557. uniform sampler2D envMap;
  558. #endif
  559. #endif`,UL=`#ifdef USE_ENVMAP
  560. uniform float reflectivity;
  561. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  562. #define ENV_WORLDPOS
  563. #endif
  564. #ifdef ENV_WORLDPOS
  565. varying vec3 vWorldPosition;
  566. uniform float refractionRatio;
  567. #else
  568. varying vec3 vReflect;
  569. #endif
  570. #endif`,NL=`#ifdef USE_ENVMAP
  571. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  572. #define ENV_WORLDPOS
  573. #endif
  574. #ifdef ENV_WORLDPOS
  575. varying vec3 vWorldPosition;
  576. #else
  577. varying vec3 vReflect;
  578. uniform float refractionRatio;
  579. #endif
  580. #endif`,kL=`#ifdef USE_ENVMAP
  581. #ifdef ENV_WORLDPOS
  582. vWorldPosition = worldPosition.xyz;
  583. #else
  584. vec3 cameraToVertex;
  585. if ( isOrthographic ) {
  586. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  587. } else {
  588. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  589. }
  590. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  591. #ifdef ENVMAP_MODE_REFLECTION
  592. vReflect = reflect( cameraToVertex, worldNormal );
  593. #else
  594. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  595. #endif
  596. #endif
  597. #endif`,VL=`#ifdef USE_FOG
  598. vFogDepth = - mvPosition.z;
  599. #endif`,jL=`#ifdef USE_FOG
  600. varying float vFogDepth;
  601. #endif`,GL=`#ifdef USE_FOG
  602. #ifdef FOG_EXP2
  603. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  604. #else
  605. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  606. #endif
  607. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  608. #endif`,HL=`#ifdef USE_FOG
  609. uniform vec3 fogColor;
  610. varying float vFogDepth;
  611. #ifdef FOG_EXP2
  612. uniform float fogDensity;
  613. #else
  614. uniform float fogNear;
  615. uniform float fogFar;
  616. #endif
  617. #endif`,WL=`#ifdef USE_GRADIENTMAP
  618. uniform sampler2D gradientMap;
  619. #endif
  620. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  621. float dotNL = dot( normal, lightDirection );
  622. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  623. #ifdef USE_GRADIENTMAP
  624. return vec3( texture2D( gradientMap, coord ).r );
  625. #else
  626. vec2 fw = fwidth( coord ) * 0.5;
  627. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  628. #endif
  629. }`,qL=`#ifdef USE_LIGHTMAP
  630. vec4 lightMapTexel = texture2D( lightMap, vUv2 );
  631. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  632. reflectedLight.indirectDiffuse += lightMapIrradiance;
  633. #endif`,XL=`#ifdef USE_LIGHTMAP
  634. uniform sampler2D lightMap;
  635. uniform float lightMapIntensity;
  636. #endif`,YL=`LambertMaterial material;
  637. material.diffuseColor = diffuseColor.rgb;
  638. material.specularStrength = specularStrength;`,QL=`varying vec3 vViewPosition;
  639. struct LambertMaterial {
  640. vec3 diffuseColor;
  641. float specularStrength;
  642. };
  643. void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  644. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  645. vec3 irradiance = dotNL * directLight.color;
  646. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  647. }
  648. void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  649. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  650. }
  651. #define RE_Direct RE_Direct_Lambert
  652. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,ZL=`uniform bool receiveShadow;
  653. uniform vec3 ambientLightColor;
  654. uniform vec3 lightProbe[ 9 ];
  655. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  656. float x = normal.x, y = normal.y, z = normal.z;
  657. vec3 result = shCoefficients[ 0 ] * 0.886227;
  658. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  659. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  660. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  661. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  662. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  663. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  664. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  665. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  666. return result;
  667. }
  668. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  669. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  670. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  671. return irradiance;
  672. }
  673. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  674. vec3 irradiance = ambientLightColor;
  675. return irradiance;
  676. }
  677. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  678. #if defined ( PHYSICALLY_CORRECT_LIGHTS )
  679. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  680. if ( cutoffDistance > 0.0 ) {
  681. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  682. }
  683. return distanceFalloff;
  684. #else
  685. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  686. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  687. }
  688. return 1.0;
  689. #endif
  690. }
  691. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  692. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  693. }
  694. #if NUM_DIR_LIGHTS > 0
  695. struct DirectionalLight {
  696. vec3 direction;
  697. vec3 color;
  698. };
  699. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  700. void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {
  701. light.color = directionalLight.color;
  702. light.direction = directionalLight.direction;
  703. light.visible = true;
  704. }
  705. #endif
  706. #if NUM_POINT_LIGHTS > 0
  707. struct PointLight {
  708. vec3 position;
  709. vec3 color;
  710. float distance;
  711. float decay;
  712. };
  713. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  714. void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {
  715. vec3 lVector = pointLight.position - geometry.position;
  716. light.direction = normalize( lVector );
  717. float lightDistance = length( lVector );
  718. light.color = pointLight.color;
  719. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  720. light.visible = ( light.color != vec3( 0.0 ) );
  721. }
  722. #endif
  723. #if NUM_SPOT_LIGHTS > 0
  724. struct SpotLight {
  725. vec3 position;
  726. vec3 direction;
  727. vec3 color;
  728. float distance;
  729. float decay;
  730. float coneCos;
  731. float penumbraCos;
  732. };
  733. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  734. void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {
  735. vec3 lVector = spotLight.position - geometry.position;
  736. light.direction = normalize( lVector );
  737. float angleCos = dot( light.direction, spotLight.direction );
  738. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  739. if ( spotAttenuation > 0.0 ) {
  740. float lightDistance = length( lVector );
  741. light.color = spotLight.color * spotAttenuation;
  742. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  743. light.visible = ( light.color != vec3( 0.0 ) );
  744. } else {
  745. light.color = vec3( 0.0 );
  746. light.visible = false;
  747. }
  748. }
  749. #endif
  750. #if NUM_RECT_AREA_LIGHTS > 0
  751. struct RectAreaLight {
  752. vec3 color;
  753. vec3 position;
  754. vec3 halfWidth;
  755. vec3 halfHeight;
  756. };
  757. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  758. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  759. #endif
  760. #if NUM_HEMI_LIGHTS > 0
  761. struct HemisphereLight {
  762. vec3 direction;
  763. vec3 skyColor;
  764. vec3 groundColor;
  765. };
  766. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  767. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  768. float dotNL = dot( normal, hemiLight.direction );
  769. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  770. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  771. return irradiance;
  772. }
  773. #endif`,KL=`#if defined( USE_ENVMAP )
  774. vec3 getIBLIrradiance( const in vec3 normal ) {
  775. #if defined( ENVMAP_TYPE_CUBE_UV )
  776. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  777. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  778. return PI * envMapColor.rgb * envMapIntensity;
  779. #else
  780. return vec3( 0.0 );
  781. #endif
  782. }
  783. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  784. #if defined( ENVMAP_TYPE_CUBE_UV )
  785. vec3 reflectVec = reflect( - viewDir, normal );
  786. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  787. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  788. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  789. return envMapColor.rgb * envMapIntensity;
  790. #else
  791. return vec3( 0.0 );
  792. #endif
  793. }
  794. #endif`,JL=`ToonMaterial material;
  795. material.diffuseColor = diffuseColor.rgb;`,$L=`varying vec3 vViewPosition;
  796. struct ToonMaterial {
  797. vec3 diffuseColor;
  798. };
  799. void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  800. vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
  801. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  802. }
  803. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  804. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  805. }
  806. #define RE_Direct RE_Direct_Toon
  807. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,ez=`BlinnPhongMaterial material;
  808. material.diffuseColor = diffuseColor.rgb;
  809. material.specularColor = specular;
  810. material.specularShininess = shininess;
  811. material.specularStrength = specularStrength;`,tz=`varying vec3 vViewPosition;
  812. struct BlinnPhongMaterial {
  813. vec3 diffuseColor;
  814. vec3 specularColor;
  815. float specularShininess;
  816. float specularStrength;
  817. };
  818. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  819. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  820. vec3 irradiance = dotNL * directLight.color;
  821. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  822. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
  823. }
  824. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  825. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  826. }
  827. #define RE_Direct RE_Direct_BlinnPhong
  828. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,iz=`PhysicalMaterial material;
  829. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  830. vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
  831. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  832. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  833. material.roughness = min( material.roughness, 1.0 );
  834. #ifdef IOR
  835. material.ior = ior;
  836. #ifdef SPECULAR
  837. float specularIntensityFactor = specularIntensity;
  838. vec3 specularColorFactor = specularColor;
  839. #ifdef USE_SPECULARINTENSITYMAP
  840. specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;
  841. #endif
  842. #ifdef USE_SPECULARCOLORMAP
  843. specularColorFactor *= texture2D( specularColorMap, vUv ).rgb;
  844. #endif
  845. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  846. #else
  847. float specularIntensityFactor = 1.0;
  848. vec3 specularColorFactor = vec3( 1.0 );
  849. material.specularF90 = 1.0;
  850. #endif
  851. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  852. #else
  853. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  854. material.specularF90 = 1.0;
  855. #endif
  856. #ifdef USE_CLEARCOAT
  857. material.clearcoat = clearcoat;
  858. material.clearcoatRoughness = clearcoatRoughness;
  859. material.clearcoatF0 = vec3( 0.04 );
  860. material.clearcoatF90 = 1.0;
  861. #ifdef USE_CLEARCOATMAP
  862. material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
  863. #endif
  864. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  865. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;
  866. #endif
  867. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  868. material.clearcoatRoughness += geometryRoughness;
  869. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  870. #endif
  871. #ifdef USE_IRIDESCENCE
  872. material.iridescence = iridescence;
  873. material.iridescenceIOR = iridescenceIOR;
  874. #ifdef USE_IRIDESCENCEMAP
  875. material.iridescence *= texture2D( iridescenceMap, vUv ).r;
  876. #endif
  877. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  878. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum;
  879. #else
  880. material.iridescenceThickness = iridescenceThicknessMaximum;
  881. #endif
  882. #endif
  883. #ifdef USE_SHEEN
  884. material.sheenColor = sheenColor;
  885. #ifdef USE_SHEENCOLORMAP
  886. material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;
  887. #endif
  888. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  889. #ifdef USE_SHEENROUGHNESSMAP
  890. material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;
  891. #endif
  892. #endif`,rz=`struct PhysicalMaterial {
  893. vec3 diffuseColor;
  894. float roughness;
  895. vec3 specularColor;
  896. float specularF90;
  897. #ifdef USE_CLEARCOAT
  898. float clearcoat;
  899. float clearcoatRoughness;
  900. vec3 clearcoatF0;
  901. float clearcoatF90;
  902. #endif
  903. #ifdef USE_IRIDESCENCE
  904. float iridescence;
  905. float iridescenceIOR;
  906. float iridescenceThickness;
  907. vec3 iridescenceFresnel;
  908. vec3 iridescenceF0;
  909. #endif
  910. #ifdef USE_SHEEN
  911. vec3 sheenColor;
  912. float sheenRoughness;
  913. #endif
  914. #ifdef IOR
  915. float ior;
  916. #endif
  917. #ifdef USE_TRANSMISSION
  918. float transmission;
  919. float transmissionAlpha;
  920. float thickness;
  921. float attenuationDistance;
  922. vec3 attenuationColor;
  923. #endif
  924. };
  925. vec3 clearcoatSpecular = vec3( 0.0 );
  926. vec3 sheenSpecular = vec3( 0.0 );
  927. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  928. float dotNV = saturate( dot( normal, viewDir ) );
  929. float r2 = roughness * roughness;
  930. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  931. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  932. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  933. return saturate( DG * RECIPROCAL_PI );
  934. }
  935. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  936. float dotNV = saturate( dot( normal, viewDir ) );
  937. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  938. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  939. vec4 r = roughness * c0 + c1;
  940. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  941. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  942. return fab;
  943. }
  944. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  945. vec2 fab = DFGApprox( normal, viewDir, roughness );
  946. return specularColor * fab.x + specularF90 * fab.y;
  947. }
  948. #ifdef USE_IRIDESCENCE
  949. 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 ) {
  950. #else
  951. 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 ) {
  952. #endif
  953. vec2 fab = DFGApprox( normal, viewDir, roughness );
  954. #ifdef USE_IRIDESCENCE
  955. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  956. #else
  957. vec3 Fr = specularColor;
  958. #endif
  959. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  960. float Ess = fab.x + fab.y;
  961. float Ems = 1.0 - Ess;
  962. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  963. singleScatter += FssEss;
  964. multiScatter += Fms * Ems;
  965. }
  966. #if NUM_RECT_AREA_LIGHTS > 0
  967. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  968. vec3 normal = geometry.normal;
  969. vec3 viewDir = geometry.viewDir;
  970. vec3 position = geometry.position;
  971. vec3 lightPos = rectAreaLight.position;
  972. vec3 halfWidth = rectAreaLight.halfWidth;
  973. vec3 halfHeight = rectAreaLight.halfHeight;
  974. vec3 lightColor = rectAreaLight.color;
  975. float roughness = material.roughness;
  976. vec3 rectCoords[ 4 ];
  977. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  978. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  979. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  980. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  981. vec4 t1 = texture2D( ltc_1, uv );
  982. vec4 t2 = texture2D( ltc_2, uv );
  983. mat3 mInv = mat3(
  984. vec3( t1.x, 0, t1.y ),
  985. vec3( 0, 1, 0 ),
  986. vec3( t1.z, 0, t1.w )
  987. );
  988. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  989. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  990. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  991. }
  992. #endif
  993. void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  994. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  995. vec3 irradiance = dotNL * directLight.color;
  996. #ifdef USE_CLEARCOAT
  997. float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
  998. vec3 ccIrradiance = dotNLcc * directLight.color;
  999. clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1000. #endif
  1001. #ifdef USE_SHEEN
  1002. sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
  1003. #endif
  1004. #ifdef USE_IRIDESCENCE
  1005. reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );
  1006. #else
  1007. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );
  1008. #endif
  1009. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1010. }
  1011. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1012. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1013. }
  1014. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  1015. #ifdef USE_CLEARCOAT
  1016. clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1017. #endif
  1018. #ifdef USE_SHEEN
  1019. sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
  1020. #endif
  1021. vec3 singleScattering = vec3( 0.0 );
  1022. vec3 multiScattering = vec3( 0.0 );
  1023. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1024. #ifdef USE_IRIDESCENCE
  1025. computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1026. #else
  1027. computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1028. #endif
  1029. vec3 totalScattering = singleScattering + multiScattering;
  1030. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1031. reflectedLight.indirectSpecular += radiance * singleScattering;
  1032. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1033. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1034. }
  1035. #define RE_Direct RE_Direct_Physical
  1036. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1037. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1038. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1039. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1040. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1041. }`,sz=`
  1042. GeometricContext geometry;
  1043. geometry.position = - vViewPosition;
  1044. geometry.normal = normal;
  1045. geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1046. #ifdef USE_CLEARCOAT
  1047. geometry.clearcoatNormal = clearcoatNormal;
  1048. #endif
  1049. #ifdef USE_IRIDESCENCE
  1050. float dotNVi = saturate( dot( normal, geometry.viewDir ) );
  1051. if ( material.iridescenceThickness == 0.0 ) {
  1052. material.iridescence = 0.0;
  1053. } else {
  1054. material.iridescence = saturate( material.iridescence );
  1055. }
  1056. if ( material.iridescence > 0.0 ) {
  1057. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1058. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1059. }
  1060. #endif
  1061. IncidentLight directLight;
  1062. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1063. PointLight pointLight;
  1064. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1065. PointLightShadow pointLightShadow;
  1066. #endif
  1067. #pragma unroll_loop_start
  1068. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1069. pointLight = pointLights[ i ];
  1070. getPointLightInfo( pointLight, geometry, directLight );
  1071. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1072. pointLightShadow = pointLightShadows[ i ];
  1073. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1074. #endif
  1075. RE_Direct( directLight, geometry, material, reflectedLight );
  1076. }
  1077. #pragma unroll_loop_end
  1078. #endif
  1079. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1080. SpotLight spotLight;
  1081. vec4 spotColor;
  1082. vec3 spotLightCoord;
  1083. bool inSpotLightMap;
  1084. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1085. SpotLightShadow spotLightShadow;
  1086. #endif
  1087. #pragma unroll_loop_start
  1088. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1089. spotLight = spotLights[ i ];
  1090. getSpotLightInfo( spotLight, geometry, directLight );
  1091. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1092. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1093. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1094. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1095. #else
  1096. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1097. #endif
  1098. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1099. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1100. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1101. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1102. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1103. #endif
  1104. #undef SPOT_LIGHT_MAP_INDEX
  1105. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1106. spotLightShadow = spotLightShadows[ i ];
  1107. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1108. #endif
  1109. RE_Direct( directLight, geometry, material, reflectedLight );
  1110. }
  1111. #pragma unroll_loop_end
  1112. #endif
  1113. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1114. DirectionalLight directionalLight;
  1115. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1116. DirectionalLightShadow directionalLightShadow;
  1117. #endif
  1118. #pragma unroll_loop_start
  1119. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1120. directionalLight = directionalLights[ i ];
  1121. getDirectionalLightInfo( directionalLight, geometry, directLight );
  1122. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1123. directionalLightShadow = directionalLightShadows[ i ];
  1124. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1125. #endif
  1126. RE_Direct( directLight, geometry, material, reflectedLight );
  1127. }
  1128. #pragma unroll_loop_end
  1129. #endif
  1130. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1131. RectAreaLight rectAreaLight;
  1132. #pragma unroll_loop_start
  1133. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1134. rectAreaLight = rectAreaLights[ i ];
  1135. RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
  1136. }
  1137. #pragma unroll_loop_end
  1138. #endif
  1139. #if defined( RE_IndirectDiffuse )
  1140. vec3 iblIrradiance = vec3( 0.0 );
  1141. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1142. irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
  1143. #if ( NUM_HEMI_LIGHTS > 0 )
  1144. #pragma unroll_loop_start
  1145. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1146. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
  1147. }
  1148. #pragma unroll_loop_end
  1149. #endif
  1150. #endif
  1151. #if defined( RE_IndirectSpecular )
  1152. vec3 radiance = vec3( 0.0 );
  1153. vec3 clearcoatRadiance = vec3( 0.0 );
  1154. #endif`,az=`#if defined( RE_IndirectDiffuse )
  1155. #ifdef USE_LIGHTMAP
  1156. vec4 lightMapTexel = texture2D( lightMap, vUv2 );
  1157. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1158. irradiance += lightMapIrradiance;
  1159. #endif
  1160. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1161. iblIrradiance += getIBLIrradiance( geometry.normal );
  1162. #endif
  1163. #endif
  1164. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1165. radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
  1166. #ifdef USE_CLEARCOAT
  1167. clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
  1168. #endif
  1169. #endif`,nz=`#if defined( RE_IndirectDiffuse )
  1170. RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
  1171. #endif
  1172. #if defined( RE_IndirectSpecular )
  1173. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
  1174. #endif`,oz=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  1175. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1176. #endif`,lz=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  1177. uniform float logDepthBufFC;
  1178. varying float vFragDepth;
  1179. varying float vIsPerspective;
  1180. #endif`,hz=`#ifdef USE_LOGDEPTHBUF
  1181. #ifdef USE_LOGDEPTHBUF_EXT
  1182. varying float vFragDepth;
  1183. varying float vIsPerspective;
  1184. #else
  1185. uniform float logDepthBufFC;
  1186. #endif
  1187. #endif`,cz=`#ifdef USE_LOGDEPTHBUF
  1188. #ifdef USE_LOGDEPTHBUF_EXT
  1189. vFragDepth = 1.0 + gl_Position.w;
  1190. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1191. #else
  1192. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  1193. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  1194. gl_Position.z *= gl_Position.w;
  1195. }
  1196. #endif
  1197. #endif`,dz=`#ifdef USE_MAP
  1198. vec4 sampledDiffuseColor = texture2D( map, vUv );
  1199. #ifdef DECODE_VIDEO_TEXTURE
  1200. sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
  1201. #endif
  1202. diffuseColor *= sampledDiffuseColor;
  1203. #endif`,uz=`#ifdef USE_MAP
  1204. uniform sampler2D map;
  1205. #endif`,pz=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1206. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1207. #endif
  1208. #ifdef USE_MAP
  1209. diffuseColor *= texture2D( map, uv );
  1210. #endif
  1211. #ifdef USE_ALPHAMAP
  1212. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1213. #endif`,fz=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1214. uniform mat3 uvTransform;
  1215. #endif
  1216. #ifdef USE_MAP
  1217. uniform sampler2D map;
  1218. #endif
  1219. #ifdef USE_ALPHAMAP
  1220. uniform sampler2D alphaMap;
  1221. #endif`,mz=`float metalnessFactor = metalness;
  1222. #ifdef USE_METALNESSMAP
  1223. vec4 texelMetalness = texture2D( metalnessMap, vUv );
  1224. metalnessFactor *= texelMetalness.b;
  1225. #endif`,gz=`#ifdef USE_METALNESSMAP
  1226. uniform sampler2D metalnessMap;
  1227. #endif`,vz=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  1228. vColor *= morphTargetBaseInfluence;
  1229. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1230. #if defined( USE_COLOR_ALPHA )
  1231. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1232. #elif defined( USE_COLOR )
  1233. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1234. #endif
  1235. }
  1236. #endif`,yz=`#ifdef USE_MORPHNORMALS
  1237. objectNormal *= morphTargetBaseInfluence;
  1238. #ifdef MORPHTARGETS_TEXTURE
  1239. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1240. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1241. }
  1242. #else
  1243. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  1244. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  1245. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  1246. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  1247. #endif
  1248. #endif`,xz=`#ifdef USE_MORPHTARGETS
  1249. uniform float morphTargetBaseInfluence;
  1250. #ifdef MORPHTARGETS_TEXTURE
  1251. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1252. uniform sampler2DArray morphTargetsTexture;
  1253. uniform ivec2 morphTargetsTextureSize;
  1254. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1255. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1256. int y = texelIndex / morphTargetsTextureSize.x;
  1257. int x = texelIndex - y * morphTargetsTextureSize.x;
  1258. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1259. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1260. }
  1261. #else
  1262. #ifndef USE_MORPHNORMALS
  1263. uniform float morphTargetInfluences[ 8 ];
  1264. #else
  1265. uniform float morphTargetInfluences[ 4 ];
  1266. #endif
  1267. #endif
  1268. #endif`,bz=`#ifdef USE_MORPHTARGETS
  1269. transformed *= morphTargetBaseInfluence;
  1270. #ifdef MORPHTARGETS_TEXTURE
  1271. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1272. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1273. }
  1274. #else
  1275. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  1276. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  1277. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  1278. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  1279. #ifndef USE_MORPHNORMALS
  1280. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  1281. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  1282. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  1283. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  1284. #endif
  1285. #endif
  1286. #endif`,wz=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1287. #ifdef FLAT_SHADED
  1288. vec3 fdx = dFdx( vViewPosition );
  1289. vec3 fdy = dFdy( vViewPosition );
  1290. vec3 normal = normalize( cross( fdx, fdy ) );
  1291. #else
  1292. vec3 normal = normalize( vNormal );
  1293. #ifdef DOUBLE_SIDED
  1294. normal = normal * faceDirection;
  1295. #endif
  1296. #ifdef USE_TANGENT
  1297. vec3 tangent = normalize( vTangent );
  1298. vec3 bitangent = normalize( vBitangent );
  1299. #ifdef DOUBLE_SIDED
  1300. tangent = tangent * faceDirection;
  1301. bitangent = bitangent * faceDirection;
  1302. #endif
  1303. #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
  1304. mat3 vTBN = mat3( tangent, bitangent, normal );
  1305. #endif
  1306. #endif
  1307. #endif
  1308. vec3 geometryNormal = normal;`,_z=`#ifdef OBJECTSPACE_NORMALMAP
  1309. normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
  1310. #ifdef FLIP_SIDED
  1311. normal = - normal;
  1312. #endif
  1313. #ifdef DOUBLE_SIDED
  1314. normal = normal * faceDirection;
  1315. #endif
  1316. normal = normalize( normalMatrix * normal );
  1317. #elif defined( TANGENTSPACE_NORMALMAP )
  1318. vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
  1319. mapN.xy *= normalScale;
  1320. #ifdef USE_TANGENT
  1321. normal = normalize( vTBN * mapN );
  1322. #else
  1323. normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );
  1324. #endif
  1325. #elif defined( USE_BUMPMAP )
  1326. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1327. #endif`,Sz=`#ifndef FLAT_SHADED
  1328. varying vec3 vNormal;
  1329. #ifdef USE_TANGENT
  1330. varying vec3 vTangent;
  1331. varying vec3 vBitangent;
  1332. #endif
  1333. #endif`,Az=`#ifndef FLAT_SHADED
  1334. varying vec3 vNormal;
  1335. #ifdef USE_TANGENT
  1336. varying vec3 vTangent;
  1337. varying vec3 vBitangent;
  1338. #endif
  1339. #endif`,Mz=`#ifndef FLAT_SHADED
  1340. vNormal = normalize( transformedNormal );
  1341. #ifdef USE_TANGENT
  1342. vTangent = normalize( transformedTangent );
  1343. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1344. #endif
  1345. #endif`,Ez=`#ifdef USE_NORMALMAP
  1346. uniform sampler2D normalMap;
  1347. uniform vec2 normalScale;
  1348. #endif
  1349. #ifdef OBJECTSPACE_NORMALMAP
  1350. uniform mat3 normalMatrix;
  1351. #endif
  1352. #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
  1353. vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
  1354. vec3 q0 = dFdx( eye_pos.xyz );
  1355. vec3 q1 = dFdy( eye_pos.xyz );
  1356. vec2 st0 = dFdx( vUv.st );
  1357. vec2 st1 = dFdy( vUv.st );
  1358. vec3 N = surf_norm;
  1359. vec3 q1perp = cross( q1, N );
  1360. vec3 q0perp = cross( N, q0 );
  1361. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1362. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1363. float det = max( dot( T, T ), dot( B, B ) );
  1364. float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );
  1365. return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );
  1366. }
  1367. #endif`,Cz=`#ifdef USE_CLEARCOAT
  1368. vec3 clearcoatNormal = geometryNormal;
  1369. #endif`,Tz=`#ifdef USE_CLEARCOAT_NORMALMAP
  1370. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
  1371. clearcoatMapN.xy *= clearcoatNormalScale;
  1372. #ifdef USE_TANGENT
  1373. clearcoatNormal = normalize( vTBN * clearcoatMapN );
  1374. #else
  1375. clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );
  1376. #endif
  1377. #endif`,Pz=`#ifdef USE_CLEARCOATMAP
  1378. uniform sampler2D clearcoatMap;
  1379. #endif
  1380. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1381. uniform sampler2D clearcoatRoughnessMap;
  1382. #endif
  1383. #ifdef USE_CLEARCOAT_NORMALMAP
  1384. uniform sampler2D clearcoatNormalMap;
  1385. uniform vec2 clearcoatNormalScale;
  1386. #endif`,Dz=`#ifdef USE_IRIDESCENCEMAP
  1387. uniform sampler2D iridescenceMap;
  1388. #endif
  1389. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1390. uniform sampler2D iridescenceThicknessMap;
  1391. #endif`,Iz=`#ifdef OPAQUE
  1392. diffuseColor.a = 1.0;
  1393. #endif
  1394. #ifdef USE_TRANSMISSION
  1395. diffuseColor.a *= material.transmissionAlpha + 0.1;
  1396. #endif
  1397. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Oz=`vec3 packNormalToRGB( const in vec3 normal ) {
  1398. return normalize( normal ) * 0.5 + 0.5;
  1399. }
  1400. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1401. return 2.0 * rgb.xyz - 1.0;
  1402. }
  1403. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  1404. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  1405. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  1406. const float ShiftRight8 = 1. / 256.;
  1407. vec4 packDepthToRGBA( const in float v ) {
  1408. vec4 r = vec4( fract( v * PackFactors ), v );
  1409. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  1410. }
  1411. float unpackRGBAToDepth( const in vec4 v ) {
  1412. return dot( v, UnpackFactors );
  1413. }
  1414. vec2 packDepthToRG( in highp float v ) {
  1415. return packDepthToRGBA( v ).yx;
  1416. }
  1417. float unpackRGToDepth( const in highp vec2 v ) {
  1418. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  1419. }
  1420. vec4 pack2HalfToRGBA( vec2 v ) {
  1421. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1422. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1423. }
  1424. vec2 unpackRGBATo2Half( vec4 v ) {
  1425. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1426. }
  1427. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1428. return ( viewZ + near ) / ( near - far );
  1429. }
  1430. float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
  1431. return linearClipZ * ( near - far ) - near;
  1432. }
  1433. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1434. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1435. }
  1436. float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
  1437. return ( near * far ) / ( ( far - near ) * invClipZ - far );
  1438. }`,Rz=`#ifdef PREMULTIPLIED_ALPHA
  1439. gl_FragColor.rgb *= gl_FragColor.a;
  1440. #endif`,Lz=`vec4 mvPosition = vec4( transformed, 1.0 );
  1441. #ifdef USE_INSTANCING
  1442. mvPosition = instanceMatrix * mvPosition;
  1443. #endif
  1444. mvPosition = modelViewMatrix * mvPosition;
  1445. gl_Position = projectionMatrix * mvPosition;`,zz=`#ifdef DITHERING
  1446. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1447. #endif`,Bz=`#ifdef DITHERING
  1448. vec3 dithering( vec3 color ) {
  1449. float grid_position = rand( gl_FragCoord.xy );
  1450. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1451. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1452. return color + dither_shift_RGB;
  1453. }
  1454. #endif`,Fz=`float roughnessFactor = roughness;
  1455. #ifdef USE_ROUGHNESSMAP
  1456. vec4 texelRoughness = texture2D( roughnessMap, vUv );
  1457. roughnessFactor *= texelRoughness.g;
  1458. #endif`,Uz=`#ifdef USE_ROUGHNESSMAP
  1459. uniform sampler2D roughnessMap;
  1460. #endif`,Nz=`#if NUM_SPOT_LIGHT_COORDS > 0
  1461. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1462. #endif
  1463. #if NUM_SPOT_LIGHT_MAPS > 0
  1464. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1465. #endif
  1466. #ifdef USE_SHADOWMAP
  1467. #if NUM_DIR_LIGHT_SHADOWS > 0
  1468. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1469. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1470. struct DirectionalLightShadow {
  1471. float shadowBias;
  1472. float shadowNormalBias;
  1473. float shadowRadius;
  1474. vec2 shadowMapSize;
  1475. };
  1476. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1477. #endif
  1478. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1479. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1480. struct SpotLightShadow {
  1481. float shadowBias;
  1482. float shadowNormalBias;
  1483. float shadowRadius;
  1484. vec2 shadowMapSize;
  1485. };
  1486. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1487. #endif
  1488. #if NUM_POINT_LIGHT_SHADOWS > 0
  1489. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1490. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1491. struct PointLightShadow {
  1492. float shadowBias;
  1493. float shadowNormalBias;
  1494. float shadowRadius;
  1495. vec2 shadowMapSize;
  1496. float shadowCameraNear;
  1497. float shadowCameraFar;
  1498. };
  1499. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1500. #endif
  1501. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1502. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  1503. }
  1504. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1505. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1506. }
  1507. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  1508. float occlusion = 1.0;
  1509. vec2 distribution = texture2DDistribution( shadow, uv );
  1510. float hard_shadow = step( compare , distribution.x );
  1511. if (hard_shadow != 1.0 ) {
  1512. float distance = compare - distribution.x ;
  1513. float variance = max( 0.00000, distribution.y * distribution.y );
  1514. 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 );
  1515. }
  1516. return occlusion;
  1517. }
  1518. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1519. float shadow = 1.0;
  1520. shadowCoord.xyz /= shadowCoord.w;
  1521. shadowCoord.z += shadowBias;
  1522. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1523. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1524. if ( frustumTest ) {
  1525. #if defined( SHADOWMAP_TYPE_PCF )
  1526. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1527. float dx0 = - texelSize.x * shadowRadius;
  1528. float dy0 = - texelSize.y * shadowRadius;
  1529. float dx1 = + texelSize.x * shadowRadius;
  1530. float dy1 = + texelSize.y * shadowRadius;
  1531. float dx2 = dx0 / 2.0;
  1532. float dy2 = dy0 / 2.0;
  1533. float dx3 = dx1 / 2.0;
  1534. float dy3 = dy1 / 2.0;
  1535. shadow = (
  1536. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1537. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1538. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1539. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1540. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1541. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1542. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1543. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1544. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1545. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1546. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1547. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1548. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1549. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1550. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1551. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1552. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1553. ) * ( 1.0 / 17.0 );
  1554. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1555. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1556. float dx = texelSize.x;
  1557. float dy = texelSize.y;
  1558. vec2 uv = shadowCoord.xy;
  1559. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1560. uv -= f * texelSize;
  1561. shadow = (
  1562. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1563. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1564. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1565. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1566. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1567. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1568. f.x ) +
  1569. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1570. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1571. f.x ) +
  1572. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1573. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1574. f.y ) +
  1575. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1576. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1577. f.y ) +
  1578. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1579. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1580. f.x ),
  1581. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1582. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1583. f.x ),
  1584. f.y )
  1585. ) * ( 1.0 / 9.0 );
  1586. #elif defined( SHADOWMAP_TYPE_VSM )
  1587. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1588. #else
  1589. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1590. #endif
  1591. }
  1592. return shadow;
  1593. }
  1594. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1595. vec3 absV = abs( v );
  1596. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1597. absV *= scaleToCube;
  1598. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1599. vec2 planar = v.xy;
  1600. float almostATexel = 1.5 * texelSizeY;
  1601. float almostOne = 1.0 - almostATexel;
  1602. if ( absV.z >= almostOne ) {
  1603. if ( v.z > 0.0 )
  1604. planar.x = 4.0 - v.x;
  1605. } else if ( absV.x >= almostOne ) {
  1606. float signX = sign( v.x );
  1607. planar.x = v.z * signX + 2.0 * signX;
  1608. } else if ( absV.y >= almostOne ) {
  1609. float signY = sign( v.y );
  1610. planar.x = v.x + 2.0 * signY + 2.0;
  1611. planar.y = v.z * signY - 2.0;
  1612. }
  1613. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1614. }
  1615. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1616. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1617. vec3 lightToPosition = shadowCoord.xyz;
  1618. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1619. vec3 bd3D = normalize( lightToPosition );
  1620. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1621. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1622. return (
  1623. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1624. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1625. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1626. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1627. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1628. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1629. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1630. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1631. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1632. ) * ( 1.0 / 9.0 );
  1633. #else
  1634. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1635. #endif
  1636. }
  1637. #endif`,kz=`#if NUM_SPOT_LIGHT_COORDS > 0
  1638. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1639. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1640. #endif
  1641. #ifdef USE_SHADOWMAP
  1642. #if NUM_DIR_LIGHT_SHADOWS > 0
  1643. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1644. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1645. struct DirectionalLightShadow {
  1646. float shadowBias;
  1647. float shadowNormalBias;
  1648. float shadowRadius;
  1649. vec2 shadowMapSize;
  1650. };
  1651. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1652. #endif
  1653. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1654. struct SpotLightShadow {
  1655. float shadowBias;
  1656. float shadowNormalBias;
  1657. float shadowRadius;
  1658. vec2 shadowMapSize;
  1659. };
  1660. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1661. #endif
  1662. #if NUM_POINT_LIGHT_SHADOWS > 0
  1663. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1664. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1665. struct PointLightShadow {
  1666. float shadowBias;
  1667. float shadowNormalBias;
  1668. float shadowRadius;
  1669. vec2 shadowMapSize;
  1670. float shadowCameraNear;
  1671. float shadowCameraFar;
  1672. };
  1673. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1674. #endif
  1675. #endif`,Vz=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  1676. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1677. vec4 shadowWorldPosition;
  1678. #endif
  1679. #if defined( USE_SHADOWMAP )
  1680. #if NUM_DIR_LIGHT_SHADOWS > 0
  1681. #pragma unroll_loop_start
  1682. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1683. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1684. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1685. }
  1686. #pragma unroll_loop_end
  1687. #endif
  1688. #if NUM_POINT_LIGHT_SHADOWS > 0
  1689. #pragma unroll_loop_start
  1690. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1691. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1692. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1693. }
  1694. #pragma unroll_loop_end
  1695. #endif
  1696. #endif
  1697. #if NUM_SPOT_LIGHT_COORDS > 0
  1698. #pragma unroll_loop_start
  1699. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  1700. shadowWorldPosition = worldPosition;
  1701. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1702. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  1703. #endif
  1704. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  1705. }
  1706. #pragma unroll_loop_end
  1707. #endif`,jz=`float getShadowMask() {
  1708. float shadow = 1.0;
  1709. #ifdef USE_SHADOWMAP
  1710. #if NUM_DIR_LIGHT_SHADOWS > 0
  1711. DirectionalLightShadow directionalLight;
  1712. #pragma unroll_loop_start
  1713. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1714. directionalLight = directionalLightShadows[ i ];
  1715. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1716. }
  1717. #pragma unroll_loop_end
  1718. #endif
  1719. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1720. SpotLightShadow spotLight;
  1721. #pragma unroll_loop_start
  1722. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1723. spotLight = spotLightShadows[ i ];
  1724. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1725. }
  1726. #pragma unroll_loop_end
  1727. #endif
  1728. #if NUM_POINT_LIGHT_SHADOWS > 0
  1729. PointLightShadow pointLight;
  1730. #pragma unroll_loop_start
  1731. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1732. pointLight = pointLightShadows[ i ];
  1733. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1734. }
  1735. #pragma unroll_loop_end
  1736. #endif
  1737. #endif
  1738. return shadow;
  1739. }`,Gz=`#ifdef USE_SKINNING
  1740. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1741. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1742. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1743. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1744. #endif`,Hz=`#ifdef USE_SKINNING
  1745. uniform mat4 bindMatrix;
  1746. uniform mat4 bindMatrixInverse;
  1747. uniform highp sampler2D boneTexture;
  1748. uniform int boneTextureSize;
  1749. mat4 getBoneMatrix( const in float i ) {
  1750. float j = i * 4.0;
  1751. float x = mod( j, float( boneTextureSize ) );
  1752. float y = floor( j / float( boneTextureSize ) );
  1753. float dx = 1.0 / float( boneTextureSize );
  1754. float dy = 1.0 / float( boneTextureSize );
  1755. y = dy * ( y + 0.5 );
  1756. vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
  1757. vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
  1758. vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
  1759. vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
  1760. mat4 bone = mat4( v1, v2, v3, v4 );
  1761. return bone;
  1762. }
  1763. #endif`,Wz=`#ifdef USE_SKINNING
  1764. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  1765. vec4 skinned = vec4( 0.0 );
  1766. skinned += boneMatX * skinVertex * skinWeight.x;
  1767. skinned += boneMatY * skinVertex * skinWeight.y;
  1768. skinned += boneMatZ * skinVertex * skinWeight.z;
  1769. skinned += boneMatW * skinVertex * skinWeight.w;
  1770. transformed = ( bindMatrixInverse * skinned ).xyz;
  1771. #endif`,qz=`#ifdef USE_SKINNING
  1772. mat4 skinMatrix = mat4( 0.0 );
  1773. skinMatrix += skinWeight.x * boneMatX;
  1774. skinMatrix += skinWeight.y * boneMatY;
  1775. skinMatrix += skinWeight.z * boneMatZ;
  1776. skinMatrix += skinWeight.w * boneMatW;
  1777. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  1778. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  1779. #ifdef USE_TANGENT
  1780. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  1781. #endif
  1782. #endif`,Xz=`float specularStrength;
  1783. #ifdef USE_SPECULARMAP
  1784. vec4 texelSpecular = texture2D( specularMap, vUv );
  1785. specularStrength = texelSpecular.r;
  1786. #else
  1787. specularStrength = 1.0;
  1788. #endif`,Yz=`#ifdef USE_SPECULARMAP
  1789. uniform sampler2D specularMap;
  1790. #endif`,Qz=`#if defined( TONE_MAPPING )
  1791. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  1792. #endif`,Zz=`#ifndef saturate
  1793. #define saturate( a ) clamp( a, 0.0, 1.0 )
  1794. #endif
  1795. uniform float toneMappingExposure;
  1796. vec3 LinearToneMapping( vec3 color ) {
  1797. return toneMappingExposure * color;
  1798. }
  1799. vec3 ReinhardToneMapping( vec3 color ) {
  1800. color *= toneMappingExposure;
  1801. return saturate( color / ( vec3( 1.0 ) + color ) );
  1802. }
  1803. vec3 OptimizedCineonToneMapping( vec3 color ) {
  1804. color *= toneMappingExposure;
  1805. color = max( vec3( 0.0 ), color - 0.004 );
  1806. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  1807. }
  1808. vec3 RRTAndODTFit( vec3 v ) {
  1809. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  1810. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  1811. return a / b;
  1812. }
  1813. vec3 ACESFilmicToneMapping( vec3 color ) {
  1814. const mat3 ACESInputMat = mat3(
  1815. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  1816. vec3( 0.04823, 0.01566, 0.83777 )
  1817. );
  1818. const mat3 ACESOutputMat = mat3(
  1819. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  1820. vec3( -0.07367, -0.00605, 1.07602 )
  1821. );
  1822. color *= toneMappingExposure / 0.6;
  1823. color = ACESInputMat * color;
  1824. color = RRTAndODTFit( color );
  1825. color = ACESOutputMat * color;
  1826. return saturate( color );
  1827. }
  1828. vec3 CustomToneMapping( vec3 color ) { return color; }`,Kz=`#ifdef USE_TRANSMISSION
  1829. material.transmission = transmission;
  1830. material.transmissionAlpha = 1.0;
  1831. material.thickness = thickness;
  1832. material.attenuationDistance = attenuationDistance;
  1833. material.attenuationColor = attenuationColor;
  1834. #ifdef USE_TRANSMISSIONMAP
  1835. material.transmission *= texture2D( transmissionMap, vUv ).r;
  1836. #endif
  1837. #ifdef USE_THICKNESSMAP
  1838. material.thickness *= texture2D( thicknessMap, vUv ).g;
  1839. #endif
  1840. vec3 pos = vWorldPosition;
  1841. vec3 v = normalize( cameraPosition - pos );
  1842. vec3 n = inverseTransformDirection( normal, viewMatrix );
  1843. vec4 transmission = getIBLVolumeRefraction(
  1844. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  1845. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  1846. material.attenuationColor, material.attenuationDistance );
  1847. material.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );
  1848. totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );
  1849. #endif`,Jz=`#ifdef USE_TRANSMISSION
  1850. uniform float transmission;
  1851. uniform float thickness;
  1852. uniform float attenuationDistance;
  1853. uniform vec3 attenuationColor;
  1854. #ifdef USE_TRANSMISSIONMAP
  1855. uniform sampler2D transmissionMap;
  1856. #endif
  1857. #ifdef USE_THICKNESSMAP
  1858. uniform sampler2D thicknessMap;
  1859. #endif
  1860. uniform vec2 transmissionSamplerSize;
  1861. uniform sampler2D transmissionSamplerMap;
  1862. uniform mat4 modelMatrix;
  1863. uniform mat4 projectionMatrix;
  1864. varying vec3 vWorldPosition;
  1865. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  1866. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  1867. vec3 modelScale;
  1868. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  1869. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  1870. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  1871. return normalize( refractionVector ) * thickness * modelScale;
  1872. }
  1873. float applyIorToRoughness( const in float roughness, const in float ior ) {
  1874. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  1875. }
  1876. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  1877. float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  1878. #ifdef texture2DLodEXT
  1879. return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );
  1880. #else
  1881. return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );
  1882. #endif
  1883. }
  1884. vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  1885. if ( isinf( attenuationDistance ) ) {
  1886. return radiance;
  1887. } else {
  1888. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  1889. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance;
  1890. }
  1891. }
  1892. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  1893. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  1894. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  1895. const in vec3 attenuationColor, const in float attenuationDistance ) {
  1896. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  1897. vec3 refractedRayExit = position + transmissionRay;
  1898. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  1899. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  1900. refractionCoords += 1.0;
  1901. refractionCoords /= 2.0;
  1902. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  1903. vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );
  1904. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  1905. return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );
  1906. }
  1907. #endif`,$z=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
  1908. varying vec2 vUv;
  1909. #endif`,eB=`#ifdef USE_UV
  1910. #ifdef UVS_VERTEX_ONLY
  1911. vec2 vUv;
  1912. #else
  1913. varying vec2 vUv;
  1914. #endif
  1915. uniform mat3 uvTransform;
  1916. #endif`,tB=`#ifdef USE_UV
  1917. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  1918. #endif`,iB=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  1919. varying vec2 vUv2;
  1920. #endif`,rB=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  1921. attribute vec2 uv2;
  1922. varying vec2 vUv2;
  1923. uniform mat3 uv2Transform;
  1924. #endif`,sB=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  1925. vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
  1926. #endif`,aB=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  1927. vec4 worldPosition = vec4( transformed, 1.0 );
  1928. #ifdef USE_INSTANCING
  1929. worldPosition = instanceMatrix * worldPosition;
  1930. #endif
  1931. worldPosition = modelMatrix * worldPosition;
  1932. #endif`,nB=`varying vec2 vUv;
  1933. uniform mat3 uvTransform;
  1934. void main() {
  1935. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  1936. gl_Position = vec4( position.xy, 1.0, 1.0 );
  1937. }`,oB=`uniform sampler2D t2D;
  1938. uniform float backgroundIntensity;
  1939. varying vec2 vUv;
  1940. void main() {
  1941. vec4 texColor = texture2D( t2D, vUv );
  1942. #ifdef DECODE_VIDEO_TEXTURE
  1943. 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 );
  1944. #endif
  1945. texColor.rgb *= backgroundIntensity;
  1946. gl_FragColor = texColor;
  1947. #include <tonemapping_fragment>
  1948. #include <encodings_fragment>
  1949. }`,lB=`varying vec3 vWorldDirection;
  1950. #include <common>
  1951. void main() {
  1952. vWorldDirection = transformDirection( position, modelMatrix );
  1953. #include <begin_vertex>
  1954. #include <project_vertex>
  1955. gl_Position.z = gl_Position.w;
  1956. }`,hB=`#ifdef ENVMAP_TYPE_CUBE
  1957. uniform samplerCube envMap;
  1958. #elif defined( ENVMAP_TYPE_CUBE_UV )
  1959. uniform sampler2D envMap;
  1960. #endif
  1961. uniform float flipEnvMap;
  1962. uniform float backgroundBlurriness;
  1963. uniform float backgroundIntensity;
  1964. varying vec3 vWorldDirection;
  1965. #include <cube_uv_reflection_fragment>
  1966. void main() {
  1967. #ifdef ENVMAP_TYPE_CUBE
  1968. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  1969. #elif defined( ENVMAP_TYPE_CUBE_UV )
  1970. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  1971. #else
  1972. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  1973. #endif
  1974. texColor.rgb *= backgroundIntensity;
  1975. gl_FragColor = texColor;
  1976. #include <tonemapping_fragment>
  1977. #include <encodings_fragment>
  1978. }`,cB=`varying vec3 vWorldDirection;
  1979. #include <common>
  1980. void main() {
  1981. vWorldDirection = transformDirection( position, modelMatrix );
  1982. #include <begin_vertex>
  1983. #include <project_vertex>
  1984. gl_Position.z = gl_Position.w;
  1985. }`,dB=`uniform samplerCube tCube;
  1986. uniform float tFlip;
  1987. uniform float opacity;
  1988. varying vec3 vWorldDirection;
  1989. void main() {
  1990. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  1991. gl_FragColor = texColor;
  1992. gl_FragColor.a *= opacity;
  1993. #include <tonemapping_fragment>
  1994. #include <encodings_fragment>
  1995. }`,uB=`#include <common>
  1996. #include <uv_pars_vertex>
  1997. #include <displacementmap_pars_vertex>
  1998. #include <morphtarget_pars_vertex>
  1999. #include <skinning_pars_vertex>
  2000. #include <logdepthbuf_pars_vertex>
  2001. #include <clipping_planes_pars_vertex>
  2002. varying vec2 vHighPrecisionZW;
  2003. void main() {
  2004. #include <uv_vertex>
  2005. #include <skinbase_vertex>
  2006. #ifdef USE_DISPLACEMENTMAP
  2007. #include <beginnormal_vertex>
  2008. #include <morphnormal_vertex>
  2009. #include <skinnormal_vertex>
  2010. #endif
  2011. #include <begin_vertex>
  2012. #include <morphtarget_vertex>
  2013. #include <skinning_vertex>
  2014. #include <displacementmap_vertex>
  2015. #include <project_vertex>
  2016. #include <logdepthbuf_vertex>
  2017. #include <clipping_planes_vertex>
  2018. vHighPrecisionZW = gl_Position.zw;
  2019. }`,pB=`#if DEPTH_PACKING == 3200
  2020. uniform float opacity;
  2021. #endif
  2022. #include <common>
  2023. #include <packing>
  2024. #include <uv_pars_fragment>
  2025. #include <map_pars_fragment>
  2026. #include <alphamap_pars_fragment>
  2027. #include <alphatest_pars_fragment>
  2028. #include <logdepthbuf_pars_fragment>
  2029. #include <clipping_planes_pars_fragment>
  2030. varying vec2 vHighPrecisionZW;
  2031. void main() {
  2032. #include <clipping_planes_fragment>
  2033. vec4 diffuseColor = vec4( 1.0 );
  2034. #if DEPTH_PACKING == 3200
  2035. diffuseColor.a = opacity;
  2036. #endif
  2037. #include <map_fragment>
  2038. #include <alphamap_fragment>
  2039. #include <alphatest_fragment>
  2040. #include <logdepthbuf_fragment>
  2041. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  2042. #if DEPTH_PACKING == 3200
  2043. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2044. #elif DEPTH_PACKING == 3201
  2045. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2046. #endif
  2047. }`,fB=`#define DISTANCE
  2048. varying vec3 vWorldPosition;
  2049. #include <common>
  2050. #include <uv_pars_vertex>
  2051. #include <displacementmap_pars_vertex>
  2052. #include <morphtarget_pars_vertex>
  2053. #include <skinning_pars_vertex>
  2054. #include <clipping_planes_pars_vertex>
  2055. void main() {
  2056. #include <uv_vertex>
  2057. #include <skinbase_vertex>
  2058. #ifdef USE_DISPLACEMENTMAP
  2059. #include <beginnormal_vertex>
  2060. #include <morphnormal_vertex>
  2061. #include <skinnormal_vertex>
  2062. #endif
  2063. #include <begin_vertex>
  2064. #include <morphtarget_vertex>
  2065. #include <skinning_vertex>
  2066. #include <displacementmap_vertex>
  2067. #include <project_vertex>
  2068. #include <worldpos_vertex>
  2069. #include <clipping_planes_vertex>
  2070. vWorldPosition = worldPosition.xyz;
  2071. }`,mB=`#define DISTANCE
  2072. uniform vec3 referencePosition;
  2073. uniform float nearDistance;
  2074. uniform float farDistance;
  2075. varying vec3 vWorldPosition;
  2076. #include <common>
  2077. #include <packing>
  2078. #include <uv_pars_fragment>
  2079. #include <map_pars_fragment>
  2080. #include <alphamap_pars_fragment>
  2081. #include <alphatest_pars_fragment>
  2082. #include <clipping_planes_pars_fragment>
  2083. void main () {
  2084. #include <clipping_planes_fragment>
  2085. vec4 diffuseColor = vec4( 1.0 );
  2086. #include <map_fragment>
  2087. #include <alphamap_fragment>
  2088. #include <alphatest_fragment>
  2089. float dist = length( vWorldPosition - referencePosition );
  2090. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2091. dist = saturate( dist );
  2092. gl_FragColor = packDepthToRGBA( dist );
  2093. }`,gB=`varying vec3 vWorldDirection;
  2094. #include <common>
  2095. void main() {
  2096. vWorldDirection = transformDirection( position, modelMatrix );
  2097. #include <begin_vertex>
  2098. #include <project_vertex>
  2099. }`,vB=`uniform sampler2D tEquirect;
  2100. varying vec3 vWorldDirection;
  2101. #include <common>
  2102. void main() {
  2103. vec3 direction = normalize( vWorldDirection );
  2104. vec2 sampleUV = equirectUv( direction );
  2105. gl_FragColor = texture2D( tEquirect, sampleUV );
  2106. #include <tonemapping_fragment>
  2107. #include <encodings_fragment>
  2108. }`,yB=`uniform float scale;
  2109. attribute float lineDistance;
  2110. varying float vLineDistance;
  2111. #include <common>
  2112. #include <color_pars_vertex>
  2113. #include <fog_pars_vertex>
  2114. #include <morphtarget_pars_vertex>
  2115. #include <logdepthbuf_pars_vertex>
  2116. #include <clipping_planes_pars_vertex>
  2117. void main() {
  2118. vLineDistance = scale * lineDistance;
  2119. #include <color_vertex>
  2120. #include <morphcolor_vertex>
  2121. #include <begin_vertex>
  2122. #include <morphtarget_vertex>
  2123. #include <project_vertex>
  2124. #include <logdepthbuf_vertex>
  2125. #include <clipping_planes_vertex>
  2126. #include <fog_vertex>
  2127. }`,xB=`uniform vec3 diffuse;
  2128. uniform float opacity;
  2129. uniform float dashSize;
  2130. uniform float totalSize;
  2131. varying float vLineDistance;
  2132. #include <common>
  2133. #include <color_pars_fragment>
  2134. #include <fog_pars_fragment>
  2135. #include <logdepthbuf_pars_fragment>
  2136. #include <clipping_planes_pars_fragment>
  2137. void main() {
  2138. #include <clipping_planes_fragment>
  2139. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2140. discard;
  2141. }
  2142. vec3 outgoingLight = vec3( 0.0 );
  2143. vec4 diffuseColor = vec4( diffuse, opacity );
  2144. #include <logdepthbuf_fragment>
  2145. #include <color_fragment>
  2146. outgoingLight = diffuseColor.rgb;
  2147. #include <output_fragment>
  2148. #include <tonemapping_fragment>
  2149. #include <encodings_fragment>
  2150. #include <fog_fragment>
  2151. #include <premultiplied_alpha_fragment>
  2152. }`,bB=`#include <common>
  2153. #include <uv_pars_vertex>
  2154. #include <uv2_pars_vertex>
  2155. #include <envmap_pars_vertex>
  2156. #include <color_pars_vertex>
  2157. #include <fog_pars_vertex>
  2158. #include <morphtarget_pars_vertex>
  2159. #include <skinning_pars_vertex>
  2160. #include <logdepthbuf_pars_vertex>
  2161. #include <clipping_planes_pars_vertex>
  2162. void main() {
  2163. #include <uv_vertex>
  2164. #include <uv2_vertex>
  2165. #include <color_vertex>
  2166. #include <morphcolor_vertex>
  2167. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2168. #include <beginnormal_vertex>
  2169. #include <morphnormal_vertex>
  2170. #include <skinbase_vertex>
  2171. #include <skinnormal_vertex>
  2172. #include <defaultnormal_vertex>
  2173. #endif
  2174. #include <begin_vertex>
  2175. #include <morphtarget_vertex>
  2176. #include <skinning_vertex>
  2177. #include <project_vertex>
  2178. #include <logdepthbuf_vertex>
  2179. #include <clipping_planes_vertex>
  2180. #include <worldpos_vertex>
  2181. #include <envmap_vertex>
  2182. #include <fog_vertex>
  2183. }`,wB=`uniform vec3 diffuse;
  2184. uniform float opacity;
  2185. #ifndef FLAT_SHADED
  2186. varying vec3 vNormal;
  2187. #endif
  2188. #include <common>
  2189. #include <dithering_pars_fragment>
  2190. #include <color_pars_fragment>
  2191. #include <uv_pars_fragment>
  2192. #include <uv2_pars_fragment>
  2193. #include <map_pars_fragment>
  2194. #include <alphamap_pars_fragment>
  2195. #include <alphatest_pars_fragment>
  2196. #include <aomap_pars_fragment>
  2197. #include <lightmap_pars_fragment>
  2198. #include <envmap_common_pars_fragment>
  2199. #include <envmap_pars_fragment>
  2200. #include <fog_pars_fragment>
  2201. #include <specularmap_pars_fragment>
  2202. #include <logdepthbuf_pars_fragment>
  2203. #include <clipping_planes_pars_fragment>
  2204. void main() {
  2205. #include <clipping_planes_fragment>
  2206. vec4 diffuseColor = vec4( diffuse, opacity );
  2207. #include <logdepthbuf_fragment>
  2208. #include <map_fragment>
  2209. #include <color_fragment>
  2210. #include <alphamap_fragment>
  2211. #include <alphatest_fragment>
  2212. #include <specularmap_fragment>
  2213. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2214. #ifdef USE_LIGHTMAP
  2215. vec4 lightMapTexel = texture2D( lightMap, vUv2 );
  2216. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2217. #else
  2218. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2219. #endif
  2220. #include <aomap_fragment>
  2221. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2222. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2223. #include <envmap_fragment>
  2224. #include <output_fragment>
  2225. #include <tonemapping_fragment>
  2226. #include <encodings_fragment>
  2227. #include <fog_fragment>
  2228. #include <premultiplied_alpha_fragment>
  2229. #include <dithering_fragment>
  2230. }`,_B=`#define LAMBERT
  2231. varying vec3 vViewPosition;
  2232. #include <common>
  2233. #include <uv_pars_vertex>
  2234. #include <uv2_pars_vertex>
  2235. #include <displacementmap_pars_vertex>
  2236. #include <envmap_pars_vertex>
  2237. #include <color_pars_vertex>
  2238. #include <fog_pars_vertex>
  2239. #include <normal_pars_vertex>
  2240. #include <morphtarget_pars_vertex>
  2241. #include <skinning_pars_vertex>
  2242. #include <shadowmap_pars_vertex>
  2243. #include <logdepthbuf_pars_vertex>
  2244. #include <clipping_planes_pars_vertex>
  2245. void main() {
  2246. #include <uv_vertex>
  2247. #include <uv2_vertex>
  2248. #include <color_vertex>
  2249. #include <morphcolor_vertex>
  2250. #include <beginnormal_vertex>
  2251. #include <morphnormal_vertex>
  2252. #include <skinbase_vertex>
  2253. #include <skinnormal_vertex>
  2254. #include <defaultnormal_vertex>
  2255. #include <normal_vertex>
  2256. #include <begin_vertex>
  2257. #include <morphtarget_vertex>
  2258. #include <skinning_vertex>
  2259. #include <displacementmap_vertex>
  2260. #include <project_vertex>
  2261. #include <logdepthbuf_vertex>
  2262. #include <clipping_planes_vertex>
  2263. vViewPosition = - mvPosition.xyz;
  2264. #include <worldpos_vertex>
  2265. #include <envmap_vertex>
  2266. #include <shadowmap_vertex>
  2267. #include <fog_vertex>
  2268. }`,SB=`#define LAMBERT
  2269. uniform vec3 diffuse;
  2270. uniform vec3 emissive;
  2271. uniform float opacity;
  2272. #include <common>
  2273. #include <packing>
  2274. #include <dithering_pars_fragment>
  2275. #include <color_pars_fragment>
  2276. #include <uv_pars_fragment>
  2277. #include <uv2_pars_fragment>
  2278. #include <map_pars_fragment>
  2279. #include <alphamap_pars_fragment>
  2280. #include <alphatest_pars_fragment>
  2281. #include <aomap_pars_fragment>
  2282. #include <lightmap_pars_fragment>
  2283. #include <emissivemap_pars_fragment>
  2284. #include <envmap_common_pars_fragment>
  2285. #include <envmap_pars_fragment>
  2286. #include <fog_pars_fragment>
  2287. #include <bsdfs>
  2288. #include <lights_pars_begin>
  2289. #include <normal_pars_fragment>
  2290. #include <lights_lambert_pars_fragment>
  2291. #include <shadowmap_pars_fragment>
  2292. #include <bumpmap_pars_fragment>
  2293. #include <normalmap_pars_fragment>
  2294. #include <specularmap_pars_fragment>
  2295. #include <logdepthbuf_pars_fragment>
  2296. #include <clipping_planes_pars_fragment>
  2297. void main() {
  2298. #include <clipping_planes_fragment>
  2299. vec4 diffuseColor = vec4( diffuse, opacity );
  2300. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2301. vec3 totalEmissiveRadiance = emissive;
  2302. #include <logdepthbuf_fragment>
  2303. #include <map_fragment>
  2304. #include <color_fragment>
  2305. #include <alphamap_fragment>
  2306. #include <alphatest_fragment>
  2307. #include <specularmap_fragment>
  2308. #include <normal_fragment_begin>
  2309. #include <normal_fragment_maps>
  2310. #include <emissivemap_fragment>
  2311. #include <lights_lambert_fragment>
  2312. #include <lights_fragment_begin>
  2313. #include <lights_fragment_maps>
  2314. #include <lights_fragment_end>
  2315. #include <aomap_fragment>
  2316. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2317. #include <envmap_fragment>
  2318. #include <output_fragment>
  2319. #include <tonemapping_fragment>
  2320. #include <encodings_fragment>
  2321. #include <fog_fragment>
  2322. #include <premultiplied_alpha_fragment>
  2323. #include <dithering_fragment>
  2324. }`,AB=`#define MATCAP
  2325. varying vec3 vViewPosition;
  2326. #include <common>
  2327. #include <uv_pars_vertex>
  2328. #include <color_pars_vertex>
  2329. #include <displacementmap_pars_vertex>
  2330. #include <fog_pars_vertex>
  2331. #include <normal_pars_vertex>
  2332. #include <morphtarget_pars_vertex>
  2333. #include <skinning_pars_vertex>
  2334. #include <logdepthbuf_pars_vertex>
  2335. #include <clipping_planes_pars_vertex>
  2336. void main() {
  2337. #include <uv_vertex>
  2338. #include <color_vertex>
  2339. #include <morphcolor_vertex>
  2340. #include <beginnormal_vertex>
  2341. #include <morphnormal_vertex>
  2342. #include <skinbase_vertex>
  2343. #include <skinnormal_vertex>
  2344. #include <defaultnormal_vertex>
  2345. #include <normal_vertex>
  2346. #include <begin_vertex>
  2347. #include <morphtarget_vertex>
  2348. #include <skinning_vertex>
  2349. #include <displacementmap_vertex>
  2350. #include <project_vertex>
  2351. #include <logdepthbuf_vertex>
  2352. #include <clipping_planes_vertex>
  2353. #include <fog_vertex>
  2354. vViewPosition = - mvPosition.xyz;
  2355. }`,MB=`#define MATCAP
  2356. uniform vec3 diffuse;
  2357. uniform float opacity;
  2358. uniform sampler2D matcap;
  2359. varying vec3 vViewPosition;
  2360. #include <common>
  2361. #include <dithering_pars_fragment>
  2362. #include <color_pars_fragment>
  2363. #include <uv_pars_fragment>
  2364. #include <map_pars_fragment>
  2365. #include <alphamap_pars_fragment>
  2366. #include <alphatest_pars_fragment>
  2367. #include <fog_pars_fragment>
  2368. #include <normal_pars_fragment>
  2369. #include <bumpmap_pars_fragment>
  2370. #include <normalmap_pars_fragment>
  2371. #include <logdepthbuf_pars_fragment>
  2372. #include <clipping_planes_pars_fragment>
  2373. void main() {
  2374. #include <clipping_planes_fragment>
  2375. vec4 diffuseColor = vec4( diffuse, opacity );
  2376. #include <logdepthbuf_fragment>
  2377. #include <map_fragment>
  2378. #include <color_fragment>
  2379. #include <alphamap_fragment>
  2380. #include <alphatest_fragment>
  2381. #include <normal_fragment_begin>
  2382. #include <normal_fragment_maps>
  2383. vec3 viewDir = normalize( vViewPosition );
  2384. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  2385. vec3 y = cross( viewDir, x );
  2386. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  2387. #ifdef USE_MATCAP
  2388. vec4 matcapColor = texture2D( matcap, uv );
  2389. #else
  2390. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  2391. #endif
  2392. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  2393. #include <output_fragment>
  2394. #include <tonemapping_fragment>
  2395. #include <encodings_fragment>
  2396. #include <fog_fragment>
  2397. #include <premultiplied_alpha_fragment>
  2398. #include <dithering_fragment>
  2399. }`,EB=`#define NORMAL
  2400. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  2401. varying vec3 vViewPosition;
  2402. #endif
  2403. #include <common>
  2404. #include <uv_pars_vertex>
  2405. #include <displacementmap_pars_vertex>
  2406. #include <normal_pars_vertex>
  2407. #include <morphtarget_pars_vertex>
  2408. #include <skinning_pars_vertex>
  2409. #include <logdepthbuf_pars_vertex>
  2410. #include <clipping_planes_pars_vertex>
  2411. void main() {
  2412. #include <uv_vertex>
  2413. #include <beginnormal_vertex>
  2414. #include <morphnormal_vertex>
  2415. #include <skinbase_vertex>
  2416. #include <skinnormal_vertex>
  2417. #include <defaultnormal_vertex>
  2418. #include <normal_vertex>
  2419. #include <begin_vertex>
  2420. #include <morphtarget_vertex>
  2421. #include <skinning_vertex>
  2422. #include <displacementmap_vertex>
  2423. #include <project_vertex>
  2424. #include <logdepthbuf_vertex>
  2425. #include <clipping_planes_vertex>
  2426. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  2427. vViewPosition = - mvPosition.xyz;
  2428. #endif
  2429. }`,CB=`#define NORMAL
  2430. uniform float opacity;
  2431. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  2432. varying vec3 vViewPosition;
  2433. #endif
  2434. #include <packing>
  2435. #include <uv_pars_fragment>
  2436. #include <normal_pars_fragment>
  2437. #include <bumpmap_pars_fragment>
  2438. #include <normalmap_pars_fragment>
  2439. #include <logdepthbuf_pars_fragment>
  2440. #include <clipping_planes_pars_fragment>
  2441. void main() {
  2442. #include <clipping_planes_fragment>
  2443. #include <logdepthbuf_fragment>
  2444. #include <normal_fragment_begin>
  2445. #include <normal_fragment_maps>
  2446. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  2447. #ifdef OPAQUE
  2448. gl_FragColor.a = 1.0;
  2449. #endif
  2450. }`,TB=`#define PHONG
  2451. varying vec3 vViewPosition;
  2452. #include <common>
  2453. #include <uv_pars_vertex>
  2454. #include <uv2_pars_vertex>
  2455. #include <displacementmap_pars_vertex>
  2456. #include <envmap_pars_vertex>
  2457. #include <color_pars_vertex>
  2458. #include <fog_pars_vertex>
  2459. #include <normal_pars_vertex>
  2460. #include <morphtarget_pars_vertex>
  2461. #include <skinning_pars_vertex>
  2462. #include <shadowmap_pars_vertex>
  2463. #include <logdepthbuf_pars_vertex>
  2464. #include <clipping_planes_pars_vertex>
  2465. void main() {
  2466. #include <uv_vertex>
  2467. #include <uv2_vertex>
  2468. #include <color_vertex>
  2469. #include <morphcolor_vertex>
  2470. #include <beginnormal_vertex>
  2471. #include <morphnormal_vertex>
  2472. #include <skinbase_vertex>
  2473. #include <skinnormal_vertex>
  2474. #include <defaultnormal_vertex>
  2475. #include <normal_vertex>
  2476. #include <begin_vertex>
  2477. #include <morphtarget_vertex>
  2478. #include <skinning_vertex>
  2479. #include <displacementmap_vertex>
  2480. #include <project_vertex>
  2481. #include <logdepthbuf_vertex>
  2482. #include <clipping_planes_vertex>
  2483. vViewPosition = - mvPosition.xyz;
  2484. #include <worldpos_vertex>
  2485. #include <envmap_vertex>
  2486. #include <shadowmap_vertex>
  2487. #include <fog_vertex>
  2488. }`,PB=`#define PHONG
  2489. uniform vec3 diffuse;
  2490. uniform vec3 emissive;
  2491. uniform vec3 specular;
  2492. uniform float shininess;
  2493. uniform float opacity;
  2494. #include <common>
  2495. #include <packing>
  2496. #include <dithering_pars_fragment>
  2497. #include <color_pars_fragment>
  2498. #include <uv_pars_fragment>
  2499. #include <uv2_pars_fragment>
  2500. #include <map_pars_fragment>
  2501. #include <alphamap_pars_fragment>
  2502. #include <alphatest_pars_fragment>
  2503. #include <aomap_pars_fragment>
  2504. #include <lightmap_pars_fragment>
  2505. #include <emissivemap_pars_fragment>
  2506. #include <envmap_common_pars_fragment>
  2507. #include <envmap_pars_fragment>
  2508. #include <fog_pars_fragment>
  2509. #include <bsdfs>
  2510. #include <lights_pars_begin>
  2511. #include <normal_pars_fragment>
  2512. #include <lights_phong_pars_fragment>
  2513. #include <shadowmap_pars_fragment>
  2514. #include <bumpmap_pars_fragment>
  2515. #include <normalmap_pars_fragment>
  2516. #include <specularmap_pars_fragment>
  2517. #include <logdepthbuf_pars_fragment>
  2518. #include <clipping_planes_pars_fragment>
  2519. void main() {
  2520. #include <clipping_planes_fragment>
  2521. vec4 diffuseColor = vec4( diffuse, opacity );
  2522. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2523. vec3 totalEmissiveRadiance = emissive;
  2524. #include <logdepthbuf_fragment>
  2525. #include <map_fragment>
  2526. #include <color_fragment>
  2527. #include <alphamap_fragment>
  2528. #include <alphatest_fragment>
  2529. #include <specularmap_fragment>
  2530. #include <normal_fragment_begin>
  2531. #include <normal_fragment_maps>
  2532. #include <emissivemap_fragment>
  2533. #include <lights_phong_fragment>
  2534. #include <lights_fragment_begin>
  2535. #include <lights_fragment_maps>
  2536. #include <lights_fragment_end>
  2537. #include <aomap_fragment>
  2538. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  2539. #include <envmap_fragment>
  2540. #include <output_fragment>
  2541. #include <tonemapping_fragment>
  2542. #include <encodings_fragment>
  2543. #include <fog_fragment>
  2544. #include <premultiplied_alpha_fragment>
  2545. #include <dithering_fragment>
  2546. }`,DB=`#define STANDARD
  2547. varying vec3 vViewPosition;
  2548. #ifdef USE_TRANSMISSION
  2549. varying vec3 vWorldPosition;
  2550. #endif
  2551. #include <common>
  2552. #include <uv_pars_vertex>
  2553. #include <uv2_pars_vertex>
  2554. #include <displacementmap_pars_vertex>
  2555. #include <color_pars_vertex>
  2556. #include <fog_pars_vertex>
  2557. #include <normal_pars_vertex>
  2558. #include <morphtarget_pars_vertex>
  2559. #include <skinning_pars_vertex>
  2560. #include <shadowmap_pars_vertex>
  2561. #include <logdepthbuf_pars_vertex>
  2562. #include <clipping_planes_pars_vertex>
  2563. void main() {
  2564. #include <uv_vertex>
  2565. #include <uv2_vertex>
  2566. #include <color_vertex>
  2567. #include <morphcolor_vertex>
  2568. #include <beginnormal_vertex>
  2569. #include <morphnormal_vertex>
  2570. #include <skinbase_vertex>
  2571. #include <skinnormal_vertex>
  2572. #include <defaultnormal_vertex>
  2573. #include <normal_vertex>
  2574. #include <begin_vertex>
  2575. #include <morphtarget_vertex>
  2576. #include <skinning_vertex>
  2577. #include <displacementmap_vertex>
  2578. #include <project_vertex>
  2579. #include <logdepthbuf_vertex>
  2580. #include <clipping_planes_vertex>
  2581. vViewPosition = - mvPosition.xyz;
  2582. #include <worldpos_vertex>
  2583. #include <shadowmap_vertex>
  2584. #include <fog_vertex>
  2585. #ifdef USE_TRANSMISSION
  2586. vWorldPosition = worldPosition.xyz;
  2587. #endif
  2588. }`,IB=`#define STANDARD
  2589. #ifdef PHYSICAL
  2590. #define IOR
  2591. #define SPECULAR
  2592. #endif
  2593. uniform vec3 diffuse;
  2594. uniform vec3 emissive;
  2595. uniform float roughness;
  2596. uniform float metalness;
  2597. uniform float opacity;
  2598. #ifdef IOR
  2599. uniform float ior;
  2600. #endif
  2601. #ifdef SPECULAR
  2602. uniform float specularIntensity;
  2603. uniform vec3 specularColor;
  2604. #ifdef USE_SPECULARINTENSITYMAP
  2605. uniform sampler2D specularIntensityMap;
  2606. #endif
  2607. #ifdef USE_SPECULARCOLORMAP
  2608. uniform sampler2D specularColorMap;
  2609. #endif
  2610. #endif
  2611. #ifdef USE_CLEARCOAT
  2612. uniform float clearcoat;
  2613. uniform float clearcoatRoughness;
  2614. #endif
  2615. #ifdef USE_IRIDESCENCE
  2616. uniform float iridescence;
  2617. uniform float iridescenceIOR;
  2618. uniform float iridescenceThicknessMinimum;
  2619. uniform float iridescenceThicknessMaximum;
  2620. #endif
  2621. #ifdef USE_SHEEN
  2622. uniform vec3 sheenColor;
  2623. uniform float sheenRoughness;
  2624. #ifdef USE_SHEENCOLORMAP
  2625. uniform sampler2D sheenColorMap;
  2626. #endif
  2627. #ifdef USE_SHEENROUGHNESSMAP
  2628. uniform sampler2D sheenRoughnessMap;
  2629. #endif
  2630. #endif
  2631. varying vec3 vViewPosition;
  2632. #include <common>
  2633. #include <packing>
  2634. #include <dithering_pars_fragment>
  2635. #include <color_pars_fragment>
  2636. #include <uv_pars_fragment>
  2637. #include <uv2_pars_fragment>
  2638. #include <map_pars_fragment>
  2639. #include <alphamap_pars_fragment>
  2640. #include <alphatest_pars_fragment>
  2641. #include <aomap_pars_fragment>
  2642. #include <lightmap_pars_fragment>
  2643. #include <emissivemap_pars_fragment>
  2644. #include <bsdfs>
  2645. #include <iridescence_fragment>
  2646. #include <cube_uv_reflection_fragment>
  2647. #include <envmap_common_pars_fragment>
  2648. #include <envmap_physical_pars_fragment>
  2649. #include <fog_pars_fragment>
  2650. #include <lights_pars_begin>
  2651. #include <normal_pars_fragment>
  2652. #include <lights_physical_pars_fragment>
  2653. #include <transmission_pars_fragment>
  2654. #include <shadowmap_pars_fragment>
  2655. #include <bumpmap_pars_fragment>
  2656. #include <normalmap_pars_fragment>
  2657. #include <clearcoat_pars_fragment>
  2658. #include <iridescence_pars_fragment>
  2659. #include <roughnessmap_pars_fragment>
  2660. #include <metalnessmap_pars_fragment>
  2661. #include <logdepthbuf_pars_fragment>
  2662. #include <clipping_planes_pars_fragment>
  2663. void main() {
  2664. #include <clipping_planes_fragment>
  2665. vec4 diffuseColor = vec4( diffuse, opacity );
  2666. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2667. vec3 totalEmissiveRadiance = emissive;
  2668. #include <logdepthbuf_fragment>
  2669. #include <map_fragment>
  2670. #include <color_fragment>
  2671. #include <alphamap_fragment>
  2672. #include <alphatest_fragment>
  2673. #include <roughnessmap_fragment>
  2674. #include <metalnessmap_fragment>
  2675. #include <normal_fragment_begin>
  2676. #include <normal_fragment_maps>
  2677. #include <clearcoat_normal_fragment_begin>
  2678. #include <clearcoat_normal_fragment_maps>
  2679. #include <emissivemap_fragment>
  2680. #include <lights_physical_fragment>
  2681. #include <lights_fragment_begin>
  2682. #include <lights_fragment_maps>
  2683. #include <lights_fragment_end>
  2684. #include <aomap_fragment>
  2685. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  2686. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  2687. #include <transmission_fragment>
  2688. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  2689. #ifdef USE_SHEEN
  2690. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  2691. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
  2692. #endif
  2693. #ifdef USE_CLEARCOAT
  2694. float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
  2695. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  2696. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;
  2697. #endif
  2698. #include <output_fragment>
  2699. #include <tonemapping_fragment>
  2700. #include <encodings_fragment>
  2701. #include <fog_fragment>
  2702. #include <premultiplied_alpha_fragment>
  2703. #include <dithering_fragment>
  2704. }`,OB=`#define TOON
  2705. varying vec3 vViewPosition;
  2706. #include <common>
  2707. #include <uv_pars_vertex>
  2708. #include <uv2_pars_vertex>
  2709. #include <displacementmap_pars_vertex>
  2710. #include <color_pars_vertex>
  2711. #include <fog_pars_vertex>
  2712. #include <normal_pars_vertex>
  2713. #include <morphtarget_pars_vertex>
  2714. #include <skinning_pars_vertex>
  2715. #include <shadowmap_pars_vertex>
  2716. #include <logdepthbuf_pars_vertex>
  2717. #include <clipping_planes_pars_vertex>
  2718. void main() {
  2719. #include <uv_vertex>
  2720. #include <uv2_vertex>
  2721. #include <color_vertex>
  2722. #include <morphcolor_vertex>
  2723. #include <beginnormal_vertex>
  2724. #include <morphnormal_vertex>
  2725. #include <skinbase_vertex>
  2726. #include <skinnormal_vertex>
  2727. #include <defaultnormal_vertex>
  2728. #include <normal_vertex>
  2729. #include <begin_vertex>
  2730. #include <morphtarget_vertex>
  2731. #include <skinning_vertex>
  2732. #include <displacementmap_vertex>
  2733. #include <project_vertex>
  2734. #include <logdepthbuf_vertex>
  2735. #include <clipping_planes_vertex>
  2736. vViewPosition = - mvPosition.xyz;
  2737. #include <worldpos_vertex>
  2738. #include <shadowmap_vertex>
  2739. #include <fog_vertex>
  2740. }`,RB=`#define TOON
  2741. uniform vec3 diffuse;
  2742. uniform vec3 emissive;
  2743. uniform float opacity;
  2744. #include <common>
  2745. #include <packing>
  2746. #include <dithering_pars_fragment>
  2747. #include <color_pars_fragment>
  2748. #include <uv_pars_fragment>
  2749. #include <uv2_pars_fragment>
  2750. #include <map_pars_fragment>
  2751. #include <alphamap_pars_fragment>
  2752. #include <alphatest_pars_fragment>
  2753. #include <aomap_pars_fragment>
  2754. #include <lightmap_pars_fragment>
  2755. #include <emissivemap_pars_fragment>
  2756. #include <gradientmap_pars_fragment>
  2757. #include <fog_pars_fragment>
  2758. #include <bsdfs>
  2759. #include <lights_pars_begin>
  2760. #include <normal_pars_fragment>
  2761. #include <lights_toon_pars_fragment>
  2762. #include <shadowmap_pars_fragment>
  2763. #include <bumpmap_pars_fragment>
  2764. #include <normalmap_pars_fragment>
  2765. #include <logdepthbuf_pars_fragment>
  2766. #include <clipping_planes_pars_fragment>
  2767. void main() {
  2768. #include <clipping_planes_fragment>
  2769. vec4 diffuseColor = vec4( diffuse, opacity );
  2770. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2771. vec3 totalEmissiveRadiance = emissive;
  2772. #include <logdepthbuf_fragment>
  2773. #include <map_fragment>
  2774. #include <color_fragment>
  2775. #include <alphamap_fragment>
  2776. #include <alphatest_fragment>
  2777. #include <normal_fragment_begin>
  2778. #include <normal_fragment_maps>
  2779. #include <emissivemap_fragment>
  2780. #include <lights_toon_fragment>
  2781. #include <lights_fragment_begin>
  2782. #include <lights_fragment_maps>
  2783. #include <lights_fragment_end>
  2784. #include <aomap_fragment>
  2785. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2786. #include <output_fragment>
  2787. #include <tonemapping_fragment>
  2788. #include <encodings_fragment>
  2789. #include <fog_fragment>
  2790. #include <premultiplied_alpha_fragment>
  2791. #include <dithering_fragment>
  2792. }`,LB=`uniform float size;
  2793. uniform float scale;
  2794. #include <common>
  2795. #include <color_pars_vertex>
  2796. #include <fog_pars_vertex>
  2797. #include <morphtarget_pars_vertex>
  2798. #include <logdepthbuf_pars_vertex>
  2799. #include <clipping_planes_pars_vertex>
  2800. void main() {
  2801. #include <color_vertex>
  2802. #include <morphcolor_vertex>
  2803. #include <begin_vertex>
  2804. #include <morphtarget_vertex>
  2805. #include <project_vertex>
  2806. gl_PointSize = size;
  2807. #ifdef USE_SIZEATTENUATION
  2808. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  2809. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  2810. #endif
  2811. #include <logdepthbuf_vertex>
  2812. #include <clipping_planes_vertex>
  2813. #include <worldpos_vertex>
  2814. #include <fog_vertex>
  2815. }`,zB=`uniform vec3 diffuse;
  2816. uniform float opacity;
  2817. #include <common>
  2818. #include <color_pars_fragment>
  2819. #include <map_particle_pars_fragment>
  2820. #include <alphatest_pars_fragment>
  2821. #include <fog_pars_fragment>
  2822. #include <logdepthbuf_pars_fragment>
  2823. #include <clipping_planes_pars_fragment>
  2824. void main() {
  2825. #include <clipping_planes_fragment>
  2826. vec3 outgoingLight = vec3( 0.0 );
  2827. vec4 diffuseColor = vec4( diffuse, opacity );
  2828. #include <logdepthbuf_fragment>
  2829. #include <map_particle_fragment>
  2830. #include <color_fragment>
  2831. #include <alphatest_fragment>
  2832. outgoingLight = diffuseColor.rgb;
  2833. #include <output_fragment>
  2834. #include <tonemapping_fragment>
  2835. #include <encodings_fragment>
  2836. #include <fog_fragment>
  2837. #include <premultiplied_alpha_fragment>
  2838. }`,BB=`#include <common>
  2839. #include <fog_pars_vertex>
  2840. #include <morphtarget_pars_vertex>
  2841. #include <skinning_pars_vertex>
  2842. #include <shadowmap_pars_vertex>
  2843. void main() {
  2844. #include <beginnormal_vertex>
  2845. #include <morphnormal_vertex>
  2846. #include <skinbase_vertex>
  2847. #include <skinnormal_vertex>
  2848. #include <defaultnormal_vertex>
  2849. #include <begin_vertex>
  2850. #include <morphtarget_vertex>
  2851. #include <skinning_vertex>
  2852. #include <project_vertex>
  2853. #include <worldpos_vertex>
  2854. #include <shadowmap_vertex>
  2855. #include <fog_vertex>
  2856. }`,FB=`uniform vec3 color;
  2857. uniform float opacity;
  2858. #include <common>
  2859. #include <packing>
  2860. #include <fog_pars_fragment>
  2861. #include <bsdfs>
  2862. #include <lights_pars_begin>
  2863. #include <shadowmap_pars_fragment>
  2864. #include <shadowmask_pars_fragment>
  2865. void main() {
  2866. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  2867. #include <tonemapping_fragment>
  2868. #include <encodings_fragment>
  2869. #include <fog_fragment>
  2870. }`,UB=`uniform float rotation;
  2871. uniform vec2 center;
  2872. #include <common>
  2873. #include <uv_pars_vertex>
  2874. #include <fog_pars_vertex>
  2875. #include <logdepthbuf_pars_vertex>
  2876. #include <clipping_planes_pars_vertex>
  2877. void main() {
  2878. #include <uv_vertex>
  2879. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  2880. vec2 scale;
  2881. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  2882. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  2883. #ifndef USE_SIZEATTENUATION
  2884. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  2885. if ( isPerspective ) scale *= - mvPosition.z;
  2886. #endif
  2887. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  2888. vec2 rotatedPosition;
  2889. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  2890. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  2891. mvPosition.xy += rotatedPosition;
  2892. gl_Position = projectionMatrix * mvPosition;
  2893. #include <logdepthbuf_vertex>
  2894. #include <clipping_planes_vertex>
  2895. #include <fog_vertex>
  2896. }`,NB=`uniform vec3 diffuse;
  2897. uniform float opacity;
  2898. #include <common>
  2899. #include <uv_pars_fragment>
  2900. #include <map_pars_fragment>
  2901. #include <alphamap_pars_fragment>
  2902. #include <alphatest_pars_fragment>
  2903. #include <fog_pars_fragment>
  2904. #include <logdepthbuf_pars_fragment>
  2905. #include <clipping_planes_pars_fragment>
  2906. void main() {
  2907. #include <clipping_planes_fragment>
  2908. vec3 outgoingLight = vec3( 0.0 );
  2909. vec4 diffuseColor = vec4( diffuse, opacity );
  2910. #include <logdepthbuf_fragment>
  2911. #include <map_fragment>
  2912. #include <alphamap_fragment>
  2913. #include <alphatest_fragment>
  2914. outgoingLight = diffuseColor.rgb;
  2915. #include <output_fragment>
  2916. #include <tonemapping_fragment>
  2917. #include <encodings_fragment>
  2918. #include <fog_fragment>
  2919. }`,yt={alphamap_fragment:lL,alphamap_pars_fragment:hL,alphatest_fragment:cL,alphatest_pars_fragment:dL,aomap_fragment:uL,aomap_pars_fragment:pL,begin_vertex:fL,beginnormal_vertex:mL,bsdfs:gL,iridescence_fragment:vL,bumpmap_pars_fragment:yL,clipping_planes_fragment:xL,clipping_planes_pars_fragment:bL,clipping_planes_pars_vertex:wL,clipping_planes_vertex:_L,color_fragment:SL,color_pars_fragment:AL,color_pars_vertex:ML,color_vertex:EL,common:CL,cube_uv_reflection_fragment:TL,defaultnormal_vertex:PL,displacementmap_pars_vertex:DL,displacementmap_vertex:IL,emissivemap_fragment:OL,emissivemap_pars_fragment:RL,encodings_fragment:LL,encodings_pars_fragment:zL,envmap_fragment:BL,envmap_common_pars_fragment:FL,envmap_pars_fragment:UL,envmap_pars_vertex:NL,envmap_physical_pars_fragment:KL,envmap_vertex:kL,fog_vertex:VL,fog_pars_vertex:jL,fog_fragment:GL,fog_pars_fragment:HL,gradientmap_pars_fragment:WL,lightmap_fragment:qL,lightmap_pars_fragment:XL,lights_lambert_fragment:YL,lights_lambert_pars_fragment:QL,lights_pars_begin:ZL,lights_toon_fragment:JL,lights_toon_pars_fragment:$L,lights_phong_fragment:ez,lights_phong_pars_fragment:tz,lights_physical_fragment:iz,lights_physical_pars_fragment:rz,lights_fragment_begin:sz,lights_fragment_maps:az,lights_fragment_end:nz,logdepthbuf_fragment:oz,logdepthbuf_pars_fragment:lz,logdepthbuf_pars_vertex:hz,logdepthbuf_vertex:cz,map_fragment:dz,map_pars_fragment:uz,map_particle_fragment:pz,map_particle_pars_fragment:fz,metalnessmap_fragment:mz,metalnessmap_pars_fragment:gz,morphcolor_vertex:vz,morphnormal_vertex:yz,morphtarget_pars_vertex:xz,morphtarget_vertex:bz,normal_fragment_begin:wz,normal_fragment_maps:_z,normal_pars_fragment:Sz,normal_pars_vertex:Az,normal_vertex:Mz,normalmap_pars_fragment:Ez,clearcoat_normal_fragment_begin:Cz,clearcoat_normal_fragment_maps:Tz,clearcoat_pars_fragment:Pz,iridescence_pars_fragment:Dz,output_fragment:Iz,packing:Oz,premultiplied_alpha_fragment:Rz,project_vertex:Lz,dithering_fragment:zz,dithering_pars_fragment:Bz,roughnessmap_fragment:Fz,roughnessmap_pars_fragment:Uz,shadowmap_pars_fragment:Nz,shadowmap_pars_vertex:kz,shadowmap_vertex:Vz,shadowmask_pars_fragment:jz,skinbase_vertex:Gz,skinning_pars_vertex:Hz,skinning_vertex:Wz,skinnormal_vertex:qz,specularmap_fragment:Xz,specularmap_pars_fragment:Yz,tonemapping_fragment:Qz,tonemapping_pars_fragment:Zz,transmission_fragment:Kz,transmission_pars_fragment:Jz,uv_pars_fragment:$z,uv_pars_vertex:eB,uv_vertex:tB,uv2_pars_fragment:iB,uv2_pars_vertex:rB,uv2_vertex:sB,worldpos_vertex:aB,background_vert:nB,background_frag:oB,backgroundCube_vert:lB,backgroundCube_frag:hB,cube_vert:cB,cube_frag:dB,depth_vert:uB,depth_frag:pB,distanceRGBA_vert:fB,distanceRGBA_frag:mB,equirect_vert:gB,equirect_frag:vB,linedashed_vert:yB,linedashed_frag:xB,meshbasic_vert:bB,meshbasic_frag:wB,meshlambert_vert:_B,meshlambert_frag:SB,meshmatcap_vert:AB,meshmatcap_frag:MB,meshnormal_vert:EB,meshnormal_frag:CB,meshphong_vert:TB,meshphong_frag:PB,meshphysical_vert:DB,meshphysical_frag:IB,meshtoon_vert:OB,meshtoon_frag:RB,points_vert:LB,points_frag:zB,shadow_vert:BB,shadow_frag:FB,sprite_vert:UB,sprite_frag:NB},Pe={common:{diffuse:{value:new et(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Di},uv2Transform:{value:new Di},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new j(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new et(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new et(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Di}},sprite:{diffuse:{value:new et(16777215)},opacity:{value:1},center:{value:new j(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Di}}},ma={basic:{uniforms:Lr([Pe.common,Pe.specularmap,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.fog]),vertexShader:yt.meshbasic_vert,fragmentShader:yt.meshbasic_frag},lambert:{uniforms:Lr([Pe.common,Pe.specularmap,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.fog,Pe.lights,{emissive:{value:new et(0)}}]),vertexShader:yt.meshlambert_vert,fragmentShader:yt.meshlambert_frag},phong:{uniforms:Lr([Pe.common,Pe.specularmap,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.fog,Pe.lights,{emissive:{value:new et(0)},specular:{value:new et(1118481)},shininess:{value:30}}]),vertexShader:yt.meshphong_vert,fragmentShader:yt.meshphong_frag},standard:{uniforms:Lr([Pe.common,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.roughnessmap,Pe.metalnessmap,Pe.fog,Pe.lights,{emissive:{value:new et(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:yt.meshphysical_vert,fragmentShader:yt.meshphysical_frag},toon:{uniforms:Lr([Pe.common,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.gradientmap,Pe.fog,Pe.lights,{emissive:{value:new et(0)}}]),vertexShader:yt.meshtoon_vert,fragmentShader:yt.meshtoon_frag},matcap:{uniforms:Lr([Pe.common,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.fog,{matcap:{value:null}}]),vertexShader:yt.meshmatcap_vert,fragmentShader:yt.meshmatcap_frag},points:{uniforms:Lr([Pe.points,Pe.fog]),vertexShader:yt.points_vert,fragmentShader:yt.points_frag},dashed:{uniforms:Lr([Pe.common,Pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:yt.linedashed_vert,fragmentShader:yt.linedashed_frag},depth:{uniforms:Lr([Pe.common,Pe.displacementmap]),vertexShader:yt.depth_vert,fragmentShader:yt.depth_frag},normal:{uniforms:Lr([Pe.common,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,{opacity:{value:1}}]),vertexShader:yt.meshnormal_vert,fragmentShader:yt.meshnormal_frag},sprite:{uniforms:Lr([Pe.sprite,Pe.fog]),vertexShader:yt.sprite_vert,fragmentShader:yt.sprite_frag},background:{uniforms:{uvTransform:{value:new Di},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:yt.background_vert,fragmentShader:yt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:yt.backgroundCube_vert,fragmentShader:yt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:yt.cube_vert,fragmentShader:yt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:yt.equirect_vert,fragmentShader:yt.equirect_frag},distanceRGBA:{uniforms:Lr([Pe.common,Pe.displacementmap,{referencePosition:{value:new M},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:yt.distanceRGBA_vert,fragmentShader:yt.distanceRGBA_frag},shadow:{uniforms:Lr([Pe.lights,Pe.fog,{color:{value:new et(0)},opacity:{value:1}}]),vertexShader:yt.shadow_vert,fragmentShader:yt.shadow_frag}};ma.physical={uniforms:Lr([ma.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new j(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new et(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new j},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new et(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new et(1,1,1)},specularColorMap:{value:null}}]),vertexShader:yt.meshphysical_vert,fragmentShader:yt.meshphysical_frag};var fu={r:0,b:0,g:0};function kB(e,t,i,r,s,a,n){let o=new et(0),l=a===!0?0:1,h,c,d=null,u=0,p=null;function f(m,v){let y=!1,x=v.isScene===!0?v.background:null;x&&x.isTexture&&(x=(v.backgroundBlurriness>0?i:t).get(x));let w=e.xr,_=w.getSession&&w.getSession();_&&_.environmentBlendMode==="additive"&&(x=null),x===null?g(o,l):x&&x.isColor&&(g(x,1),y=!0),(e.autoClear||y)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),x&&(x.isCubeTexture||x.mapping===Rd)?(c===void 0&&(c=new Jt(new Xs(1,1,1),new Dt({name:"BackgroundCubeMaterial",uniforms:Th(ma.backgroundCube.uniforms),vertexShader:ma.backgroundCube.vertexShader,fragmentShader:ma.backgroundCube.fragmentShader,side:rr,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(b,A,S){this.matrixWorld.copyPosition(S.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(c)),c.material.uniforms.envMap.value=x,c.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,c.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=x.encoding!==gt,(d!==x||u!==x.version||p!==e.toneMapping)&&(c.material.needsUpdate=!0,d=x,u=x.version,p=e.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null)):x&&x.isTexture&&(h===void 0&&(h=new Jt(new Ea(2,2),new Dt({name:"BackgroundMaterial",uniforms:Th(ma.background.uniforms),vertexShader:ma.background.vertexShader,fragmentShader:ma.background.fragmentShader,side:Ws,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(h)),h.material.uniforms.t2D.value=x,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.toneMapped=x.encoding!==gt,x.matrixAutoUpdate===!0&&x.updateMatrix(),h.material.uniforms.uvTransform.value.copy(x.matrix),(d!==x||u!==x.version||p!==e.toneMapping)&&(h.material.needsUpdate=!0,d=x,u=x.version,p=e.toneMapping),h.layers.enableAll(),m.unshift(h,h.geometry,h.material,0,0,null))}function g(m,v){m.getRGB(fu,pM(e)),r.buffers.color.setClear(fu.r,fu.g,fu.b,v,n)}return{getClearColor:function(){return o},setClearColor:function(m,v=1){o.set(m),l=v,g(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(m){l=m,g(o,l)},render:f}}function VB(e,t,i,r){let s=e.getParameter(34921),a=r.isWebGL2?null:t.get("OES_vertex_array_object"),n=r.isWebGL2||a!==null,o={},l=m(null),h=l,c=!1;function d(P,U,W,k,F){let Z=!1;if(n){let X=g(k,W,U);h!==X&&(h=X,p(h.object)),Z=v(P,k,W,F),Z&&y(P,k,W,F)}else{let X=U.wireframe===!0;(h.geometry!==k.id||h.program!==W.id||h.wireframe!==X)&&(h.geometry=k.id,h.program=W.id,h.wireframe=X,Z=!0)}F!==null&&i.update(F,34963),(Z||c)&&(c=!1,S(P,U,W,k),F!==null&&e.bindBuffer(34963,i.get(F).buffer))}function u(){return r.isWebGL2?e.createVertexArray():a.createVertexArrayOES()}function p(P){return r.isWebGL2?e.bindVertexArray(P):a.bindVertexArrayOES(P)}function f(P){return r.isWebGL2?e.deleteVertexArray(P):a.deleteVertexArrayOES(P)}function g(P,U,W){let k=W.wireframe===!0,F=o[P.id];F===void 0&&(F={},o[P.id]=F);let Z=F[U.id];Z===void 0&&(Z={},F[U.id]=Z);let X=Z[k];return X===void 0&&(X=m(u()),Z[k]=X),X}function m(P){let U=[],W=[],k=[];for(let F=0;F<s;F++)U[F]=0,W[F]=0,k[F]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:W,attributeDivisors:k,object:P,attributes:{},index:null}}function v(P,U,W,k){let F=h.attributes,Z=U.attributes,X=0,G=W.getAttributes();for(let q in G)if(G[q].location>=0){let $=F[q],Q=Z[q];if(Q===void 0&&(q==="instanceMatrix"&&P.instanceMatrix&&(Q=P.instanceMatrix),q==="instanceColor"&&P.instanceColor&&(Q=P.instanceColor)),$===void 0||$.attribute!==Q||Q&&$.data!==Q.data)return!0;X++}return h.attributesNum!==X||h.index!==k}function y(P,U,W,k){let F={},Z=U.attributes,X=0,G=W.getAttributes();for(let q in G)if(G[q].location>=0){let $=Z[q];$===void 0&&(q==="instanceMatrix"&&P.instanceMatrix&&($=P.instanceMatrix),q==="instanceColor"&&P.instanceColor&&($=P.instanceColor));let Q={};Q.attribute=$,$&&$.data&&(Q.data=$.data),F[q]=Q,X++}h.attributes=F,h.attributesNum=X,h.index=k}function x(){let P=h.newAttributes;for(let U=0,W=P.length;U<W;U++)P[U]=0}function w(P){_(P,0)}function _(P,U){let W=h.newAttributes,k=h.enabledAttributes,F=h.attributeDivisors;W[P]=1,k[P]===0&&(e.enableVertexAttribArray(P),k[P]=1),F[P]!==U&&((r.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](P,U),F[P]=U)}function b(){let P=h.newAttributes,U=h.enabledAttributes;for(let W=0,k=U.length;W<k;W++)U[W]!==P[W]&&(e.disableVertexAttribArray(W),U[W]=0)}function A(P,U,W,k,F,Z){r.isWebGL2===!0&&(W===5124||W===5125)?e.vertexAttribIPointer(P,U,W,F,Z):e.vertexAttribPointer(P,U,W,k,F,Z)}function S(P,U,W,k){if(r.isWebGL2===!1&&(P.isInstancedMesh||k.isInstancedBufferGeometry)&&t.get("ANGLE_instanced_arrays")===null)return;x();let F=k.attributes,Z=W.getAttributes(),X=U.defaultAttributeValues;for(let G in Z){let q=Z[G];if(q.location>=0){let $=F[G];if($===void 0&&(G==="instanceMatrix"&&P.instanceMatrix&&($=P.instanceMatrix),G==="instanceColor"&&P.instanceColor&&($=P.instanceColor)),$!==void 0){let Q=$.normalized,ee=$.itemSize,H=i.get($);if(H===void 0)continue;let he=H.buffer,re=H.type,te=H.bytesPerElement;if($.isInterleavedBufferAttribute){let ae=$.data,de=ae.stride,pe=$.offset;if(ae.isInstancedInterleavedBuffer){for(let be=0;be<q.locationSize;be++)_(q.location+be,ae.meshPerAttribute);P.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let be=0;be<q.locationSize;be++)w(q.location+be);e.bindBuffer(34962,he);for(let be=0;be<q.locationSize;be++)A(q.location+be,ee/q.locationSize,re,Q,de*te,(pe+ee/q.locationSize*be)*te)}else{if($.isInstancedBufferAttribute){for(let ae=0;ae<q.locationSize;ae++)_(q.location+ae,$.meshPerAttribute);P.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=$.meshPerAttribute*$.count)}else for(let ae=0;ae<q.locationSize;ae++)w(q.location+ae);e.bindBuffer(34962,he);for(let ae=0;ae<q.locationSize;ae++)A(q.location+ae,ee/q.locationSize,re,Q,ee*te,ee/q.locationSize*ae*te)}}else if(X!==void 0){let Q=X[G];if(Q!==void 0)switch(Q.length){case 2:e.vertexAttrib2fv(q.location,Q);break;case 3:e.vertexAttrib3fv(q.location,Q);break;case 4:e.vertexAttrib4fv(q.location,Q);break;default:e.vertexAttrib1fv(q.location,Q)}}}}b()}function E(){D();for(let P in o){let U=o[P];for(let W in U){let k=U[W];for(let F in k)f(k[F].object),delete k[F];delete U[W]}delete o[P]}}function C(P){if(o[P.id]===void 0)return;let U=o[P.id];for(let W in U){let k=U[W];for(let F in k)f(k[F].object),delete k[F];delete U[W]}delete o[P.id]}function T(P){for(let U in o){let W=o[U];if(W[P.id]===void 0)continue;let k=W[P.id];for(let F in k)f(k[F].object),delete k[F];delete W[P.id]}}function D(){O(),c=!0,h!==l&&(h=l,p(h.object))}function O(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:d,reset:D,resetDefaultState:O,dispose:E,releaseStatesOfGeometry:C,releaseStatesOfProgram:T,initAttributes:x,enableAttribute:w,disableUnusedAttributes:b}}function jB(e,t,i,r){let s=r.isWebGL2,a;function n(h){a=h}function o(h,c){e.drawArrays(a,h,c),i.update(c,a,1)}function l(h,c,d){if(d===0)return;let u,p;if(s)u=e,p="drawArraysInstanced";else if(u=t.get("ANGLE_instanced_arrays"),p="drawArraysInstancedANGLE",u===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}u[p](a,h,c,d),i.update(c,a,d)}this.setMode=n,this.render=o,this.renderInstances=l}function GB(e,t,i){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(A){if(A==="highp"){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";A="mediump"}return A==="mediump"&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let n=typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext,o=i.precision!==void 0?i.precision:"highp",l=a(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);let h=n||t.has("WEBGL_draw_buffers"),c=i.logarithmicDepthBuffer===!0,d=e.getParameter(34930),u=e.getParameter(35660),p=e.getParameter(3379),f=e.getParameter(34076),g=e.getParameter(34921),m=e.getParameter(36347),v=e.getParameter(36348),y=e.getParameter(36349),x=u>0,w=n||t.has("OES_texture_float"),_=x&&w,b=n?e.getParameter(36183):0;return{isWebGL2:n,drawBuffers:h,getMaxAnisotropy:s,getMaxPrecision:a,precision:o,logarithmicDepthBuffer:c,maxTextures:d,maxVertexTextures:u,maxTextureSize:p,maxCubemapSize:f,maxAttributes:g,maxVertexUniforms:m,maxVaryings:v,maxFragmentUniforms:y,vertexTextures:x,floatFragmentTextures:w,floatVertexTextures:_,maxSamples:b}}function HB(e){let t=this,i=null,r=0,s=!1,a=!1,n=new qr,o=new Di,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let p=d.length!==0||u||r!==0||s;return s=u,r=d.length,p},this.beginShadows=function(){a=!0,c(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(d,u){i=c(d,u,0)},this.setState=function(d,u,p){let f=d.clippingPlanes,g=d.clipIntersection,m=d.clipShadows,v=e.get(d);if(!s||f===null||f.length===0||a&&!m)a?c(null):h();else{let y=a?0:r,x=y*4,w=v.clippingState||null;l.value=w,w=c(f,u,x,p);for(let _=0;_!==x;++_)w[_]=i[_];v.clippingState=w,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=y}};function h(){l.value!==i&&(l.value=i,l.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function c(d,u,p,f){let g=d!==null?d.length:0,m=null;if(g!==0){if(m=l.value,f!==!0||m===null){let v=p+g*4,y=u.matrixWorldInverse;o.getNormalMatrix(y),(m===null||m.length<v)&&(m=new Float32Array(v));for(let x=0,w=p;x!==g;++x,w+=4)n.copy(d[x]).applyMatrix4(y,o),n.normal.toArray(m,w),m[w+3]=n.constant}l.value=m,l.needsUpdate=!0}return t.numPlanes=g,t.numIntersection=0,m}}function WB(e){let t=new WeakMap;function i(n,o){return o===Dv?n.mapping=al:o===Iv&&(n.mapping=nl),n}function r(n){if(n&&n.isTexture&&n.isRenderTargetTexture===!1){let o=n.mapping;if(o===Dv||o===Iv)if(t.has(n)){let l=t.get(n).texture;return i(l,n.mapping)}else{let l=n.image;if(l&&l.height>0){let h=new sL(l.height/2);return h.fromEquirectangularTexture(e,n),t.set(n,h),n.addEventListener("dispose",s),i(h.texture,n.mapping)}else return null}}return n}function s(n){let o=n.target;o.removeEventListener("dispose",s);let l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function a(){t=new WeakMap}return{get:r,dispose:a}}var Xf=class extends bo{constructor(e=-1,t=1,i=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,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=e,this.view.fullHeight=t,this.view.offsetX=i,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(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=i-e,a=i+e,n=r+t,o=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,a=s+l*this.view.width,n-=h*this.view.offsetY,o=n-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,n,o,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},ch=4,db=[.125,.215,.35,.446,.526,.582],Uo=20,Jm=new Xf,ub=new et,$m=null,Lo=(1+Math.sqrt(5))/2,zl=1/Lo,pb=[new M(1,1,1),new M(-1,1,1),new M(1,1,-1),new M(-1,1,-1),new M(0,Lo,zl),new M(0,Lo,-zl),new M(zl,0,Lo),new M(-zl,0,Lo),new M(Lo,zl,0),new M(-Lo,zl,0)],fb=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){$m=this._renderer.getRenderTarget(),this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=vb(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=gb(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget($m),e.scissorTest=!1,mu(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===al||e.mapping===nl?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),$m=this._renderer.getRenderTarget();let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:xt,minFilter:xt,generateMipmaps:!1,type:mn,format:ni,encoding:qs,depthBuffer:!1},r=mb(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=mb(e,t,i);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=qB(s)),this._blurMaterial=XB(s,e,t)}return r}_compileMaterial(e){let t=new Jt(this._lodPlanes[0],e);this._renderer.compile(t,Jm)}_sceneToCubeUV(e,t,i,r){let s=new _r(90,1,t,i),a=[1,-1,1,1,1,1],n=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,h=o.toneMapping;o.getClearColor(ub),o.toneMapping=_a,o.autoClear=!1;let c=new gn({name:"PMREM.Background",side:rr,depthWrite:!1,depthTest:!1}),d=new Jt(new Xs,c),u=!1,p=e.background;p?p.isColor&&(c.color.copy(p),e.background=null,u=!0):(c.color.copy(ub),u=!0);for(let f=0;f<6;f++){let g=f%3;g===0?(s.up.set(0,a[f],0),s.lookAt(n[f],0,0)):g===1?(s.up.set(0,0,a[f]),s.lookAt(0,n[f],0)):(s.up.set(0,a[f],0),s.lookAt(0,0,n[f]));let m=this._cubeSize;mu(r,g*m,f>2?m:0,m,m),o.setRenderTarget(r),u&&o.render(d,s),o.render(e,s)}d.geometry.dispose(),d.material.dispose(),o.toneMapping=h,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===al||e.mapping===nl;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=vb()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=gb());let s=r?this._cubemapMaterial:this._equirectMaterial,a=new Jt(this._lodPlanes[0],s),n=s.uniforms;n.envMap.value=e;let o=this._cubeSize;mu(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(a,Jm)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let r=1;r<this._lodPlanes.length;r++){let s=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=pb[(r-1)%pb.length];this._blur(e,r-1,r,s,a)}t.autoClear=i}_blur(e,t,i,r,s){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",s),this._halfBlur(a,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,a,n){let o=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,c=new Jt(this._lodPlanes[r],l),d=l.uniforms,u=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*u):2*Math.PI/(2*Uo-1),f=s/p,g=isFinite(s)?1+Math.floor(h*f):Uo;g>Uo&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Uo}`);let m=[],v=0;for(let b=0;b<Uo;++b){let A=b/f,S=Math.exp(-A*A/2);m.push(S),b===0?v+=S:b<g&&(v+=2*S)}for(let b=0;b<m.length;b++)m[b]=m[b]/v;d.envMap.value=e.texture,d.samples.value=g,d.weights.value=m,d.latitudinal.value=a==="latitudinal",n&&(d.poleAxis.value=n);let{_lodMax:y}=this;d.dTheta.value=p,d.mipInt.value=y-i;let x=this._sizeLods[r],w=3*x*(r>y-ch?r-y+ch:0),_=4*(this._cubeSize-x);mu(t,w,_,3*x,2*x),o.setRenderTarget(t),o.render(c,Jm)}};function qB(e){let t=[],i=[],r=[],s=e,a=e-ch+1+db.length;for(let n=0;n<a;n++){let o=Math.pow(2,s);i.push(o);let l=1/o;n>e-ch?l=db[n-e+ch-1]:n===0&&(l=0),r.push(l);let h=1/(o-2),c=-h,d=1+h,u=[c,c,d,c,d,d,c,c,d,d,c,d],p=6,f=6,g=3,m=2,v=1,y=new Float32Array(g*f*p),x=new Float32Array(m*f*p),w=new Float32Array(v*f*p);for(let b=0;b<p;b++){let A=b%3*2/3-1,S=b>2?0:-1,E=[A,S,0,A+2/3,S,0,A+2/3,S+1,0,A,S,0,A+2/3,S+1,0,A,S+1,0];y.set(E,g*f*b),x.set(u,m*f*b);let C=[b,b,b,b,b,b];w.set(C,v*f*b)}let _=new Ge;_.setAttribute("position",new tt(y,g)),_.setAttribute("uv",new tt(x,m)),_.setAttribute("faceIndex",new tt(w,v)),t.push(_),s>ch&&s--}return{lodPlanes:t,sizeLods:i,sigmas:r}}function mb(e,t,i){let r=new Pt(e,t,i);return r.texture.mapping=Rd,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function mu(e,t,i,r,s){e.viewport.set(t,i,r,s),e.scissor.set(t,i,r,s)}function XB(e,t,i){let r=new Float32Array(Uo),s=new M(0,1,0);return new Dt({name:"SphericalGaussianBlur",defines:{n:Uo,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Wy(),fragmentShader:`
  2920. precision mediump float;
  2921. precision mediump int;
  2922. varying vec3 vOutputDirection;
  2923. uniform sampler2D envMap;
  2924. uniform int samples;
  2925. uniform float weights[ n ];
  2926. uniform bool latitudinal;
  2927. uniform float dTheta;
  2928. uniform float mipInt;
  2929. uniform vec3 poleAxis;
  2930. #define ENVMAP_TYPE_CUBE_UV
  2931. #include <cube_uv_reflection_fragment>
  2932. vec3 getSample( float theta, vec3 axis ) {
  2933. float cosTheta = cos( theta );
  2934. // Rodrigues' axis-angle rotation
  2935. vec3 sampleDirection = vOutputDirection * cosTheta
  2936. + cross( axis, vOutputDirection ) * sin( theta )
  2937. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  2938. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  2939. }
  2940. void main() {
  2941. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  2942. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  2943. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  2944. }
  2945. axis = normalize( axis );
  2946. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2947. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  2948. for ( int i = 1; i < n; i++ ) {
  2949. if ( i >= samples ) {
  2950. break;
  2951. }
  2952. float theta = dTheta * float( i );
  2953. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  2954. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  2955. }
  2956. }
  2957. `,blending:Oi,depthTest:!1,depthWrite:!1})}function gb(){return new Dt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Wy(),fragmentShader:`
  2958. precision mediump float;
  2959. precision mediump int;
  2960. varying vec3 vOutputDirection;
  2961. uniform sampler2D envMap;
  2962. #include <common>
  2963. void main() {
  2964. vec3 outputDirection = normalize( vOutputDirection );
  2965. vec2 uv = equirectUv( outputDirection );
  2966. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  2967. }
  2968. `,blending:Oi,depthTest:!1,depthWrite:!1})}function vb(){return new Dt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Wy(),fragmentShader:`
  2969. precision mediump float;
  2970. precision mediump int;
  2971. uniform float flipEnvMap;
  2972. varying vec3 vOutputDirection;
  2973. uniform samplerCube envMap;
  2974. void main() {
  2975. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  2976. }
  2977. `,blending:Oi,depthTest:!1,depthWrite:!1})}function Wy(){return`
  2978. precision mediump float;
  2979. precision mediump int;
  2980. attribute float faceIndex;
  2981. varying vec3 vOutputDirection;
  2982. // RH coordinate system; PMREM face-indexing convention
  2983. vec3 getDirection( vec2 uv, float face ) {
  2984. uv = 2.0 * uv - 1.0;
  2985. vec3 direction = vec3( uv, 1.0 );
  2986. if ( face == 0.0 ) {
  2987. direction = direction.zyx; // ( 1, v, u ) pos x
  2988. } else if ( face == 1.0 ) {
  2989. direction = direction.xzy;
  2990. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  2991. } else if ( face == 2.0 ) {
  2992. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  2993. } else if ( face == 3.0 ) {
  2994. direction = direction.zyx;
  2995. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  2996. } else if ( face == 4.0 ) {
  2997. direction = direction.xzy;
  2998. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  2999. } else if ( face == 5.0 ) {
  3000. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3001. }
  3002. return direction;
  3003. }
  3004. void main() {
  3005. vOutputDirection = getDirection( uv, faceIndex );
  3006. gl_Position = vec4( position, 1.0 );
  3007. }
  3008. `}function YB(e){let t=new WeakMap,i=null;function r(o){if(o&&o.isTexture){let l=o.mapping,h=l===Dv||l===Iv,c=l===al||l===nl;if(h||c)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let d=t.get(o);return i===null&&(i=new fb(e)),d=h?i.fromEquirectangular(o,d):i.fromCubemap(o,d),t.set(o,d),d.texture}else{if(t.has(o))return t.get(o).texture;{let d=o.image;if(h&&d&&d.height>0||c&&d&&s(d)){i===null&&(i=new fb(e));let u=h?i.fromEquirectangular(o):i.fromCubemap(o);return t.set(o,u),o.addEventListener("dispose",a),u.texture}else return null}}}return o}function s(o){let l=0,h=6;for(let c=0;c<h;c++)o[c]!==void 0&&l++;return l===h}function a(o){let l=o.target;l.removeEventListener("dispose",a);let h=t.get(l);h!==void 0&&(t.delete(l),h.dispose())}function n(){t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:r,dispose:n}}function QB(e){let t={};function i(r){if(t[r]!==void 0)return t[r];let s;switch(r){case"WEBGL_depth_texture":s=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=e.getExtension(r)}return t[r]=s,s}return{has:function(r){return i(r)!==null},init:function(r){r.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture")},get:function(r){let s=i(r);return s===null&&console.warn("THREE.WebGLRenderer: "+r+" extension not supported."),s}}}function ZB(e,t,i,r){let s={},a=new WeakMap;function n(d){let u=d.target;u.index!==null&&t.remove(u.index);for(let f in u.attributes)t.remove(u.attributes[f]);u.removeEventListener("dispose",n),delete s[u.id];let p=a.get(u);p&&(t.remove(p),a.delete(u)),r.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,i.memory.geometries--}function o(d,u){return s[u.id]===!0||(u.addEventListener("dispose",n),s[u.id]=!0,i.memory.geometries++),u}function l(d){let u=d.attributes;for(let f in u)t.update(u[f],34962);let p=d.morphAttributes;for(let f in p){let g=p[f];for(let m=0,v=g.length;m<v;m++)t.update(g[m],34962)}}function h(d){let u=[],p=d.index,f=d.attributes.position,g=0;if(p!==null){let y=p.array;g=p.version;for(let x=0,w=y.length;x<w;x+=3){let _=y[x+0],b=y[x+1],A=y[x+2];u.push(_,b,b,A,A,_)}}else{let y=f.array;g=f.version;for(let x=0,w=y.length/3-1;x<w;x+=3){let _=x+0,b=x+1,A=x+2;u.push(_,b,b,A,A,_)}}let m=new(nM(u)?mh:uM)(u,1);m.version=g;let v=a.get(d);v&&t.remove(v),a.set(d,m)}function c(d){let u=a.get(d);if(u){let p=d.index;p!==null&&u.version<p.version&&h(d)}else h(d);return a.get(d)}return{get:o,update:l,getWireframeAttribute:c}}function KB(e,t,i,r){let s=r.isWebGL2,a;function n(u){a=u}let o,l;function h(u){o=u.type,l=u.bytesPerElement}function c(u,p){e.drawElements(a,p,o,u*l),i.update(p,a,1)}function d(u,p,f){if(f===0)return;let g,m;if(s)g=e,m="drawElementsInstanced";else if(g=t.get("ANGLE_instanced_arrays"),m="drawElementsInstancedANGLE",g===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}g[m](a,p,o,u*l,f),i.update(p,a,f)}this.setMode=n,this.setIndex=h,this.render=c,this.renderInstances=d}function JB(e){let t={geometries:0,textures:0},i={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,n,o){switch(i.calls++,n){case 4:i.triangles+=o*(a/3);break;case 1:i.lines+=o*(a/2);break;case 3:i.lines+=o*(a-1);break;case 2:i.lines+=o*a;break;case 0:i.points+=o*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n);break}}function s(){i.frame++,i.calls=0,i.triangles=0,i.points=0,i.lines=0}return{memory:t,render:i,programs:null,autoReset:!0,reset:s,update:r}}function $B(e,t){return e[0]-t[0]}function e4(e,t){return Math.abs(t[1])-Math.abs(e[1])}function t4(e,t,i){let r={},s=new Float32Array(8),a=new WeakMap,n=new ct,o=[];for(let h=0;h<8;h++)o[h]=[h,0];function l(h,c,d,u){let p=h.morphTargetInfluences;if(t.isWebGL2===!0){let f=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,g=f!==void 0?f.length:0,m=a.get(c);if(m===void 0||m.count!==g){let x=function(){P.dispose(),a.delete(c),c.removeEventListener("dispose",x)};m!==void 0&&m.texture.dispose();let w=c.morphAttributes.position!==void 0,_=c.morphAttributes.normal!==void 0,b=c.morphAttributes.color!==void 0,A=c.morphAttributes.position||[],S=c.morphAttributes.normal||[],E=c.morphAttributes.color||[],C=0;w===!0&&(C=1),_===!0&&(C=2),b===!0&&(C=3);let T=c.attributes.position.count*C,D=1;T>t.maxTextureSize&&(D=Math.ceil(T/t.maxTextureSize),T=t.maxTextureSize);let O=new Float32Array(T*D*4*g),P=new cM(O,T,D,g);P.type=jt,P.needsUpdate=!0;let U=C*4;for(let W=0;W<g;W++){let k=A[W],F=S[W],Z=E[W],X=T*D*4*W;for(let G=0;G<k.count;G++){let q=G*U;w===!0&&(n.fromBufferAttribute(k,G),O[X+q+0]=n.x,O[X+q+1]=n.y,O[X+q+2]=n.z,O[X+q+3]=0),_===!0&&(n.fromBufferAttribute(F,G),O[X+q+4]=n.x,O[X+q+5]=n.y,O[X+q+6]=n.z,O[X+q+7]=0),b===!0&&(n.fromBufferAttribute(Z,G),O[X+q+8]=n.x,O[X+q+9]=n.y,O[X+q+10]=n.z,O[X+q+11]=Z.itemSize===4?n.w:1)}}m={count:g,texture:P,size:new j(T,D)},a.set(c,m),c.addEventListener("dispose",x)}let v=0;for(let x=0;x<p.length;x++)v+=p[x];let y=c.morphTargetsRelative?1:1-v;u.getUniforms().setValue(e,"morphTargetBaseInfluence",y),u.getUniforms().setValue(e,"morphTargetInfluences",p),u.getUniforms().setValue(e,"morphTargetsTexture",m.texture,i),u.getUniforms().setValue(e,"morphTargetsTextureSize",m.size)}else{let f=p===void 0?0:p.length,g=r[c.id];if(g===void 0||g.length!==f){g=[];for(let w=0;w<f;w++)g[w]=[w,0];r[c.id]=g}for(let w=0;w<f;w++){let _=g[w];_[0]=w,_[1]=p[w]}g.sort(e4);for(let w=0;w<8;w++)w<f&&g[w][1]?(o[w][0]=g[w][0],o[w][1]=g[w][1]):(o[w][0]=Number.MAX_SAFE_INTEGER,o[w][1]=0);o.sort($B);let m=c.morphAttributes.position,v=c.morphAttributes.normal,y=0;for(let w=0;w<8;w++){let _=o[w],b=_[0],A=_[1];b!==Number.MAX_SAFE_INTEGER&&A?(m&&c.getAttribute("morphTarget"+w)!==m[b]&&c.setAttribute("morphTarget"+w,m[b]),v&&c.getAttribute("morphNormal"+w)!==v[b]&&c.setAttribute("morphNormal"+w,v[b]),s[w]=A,y+=A):(m&&c.hasAttribute("morphTarget"+w)===!0&&c.deleteAttribute("morphTarget"+w),v&&c.hasAttribute("morphNormal"+w)===!0&&c.deleteAttribute("morphNormal"+w),s[w]=0)}let x=c.morphTargetsRelative?1:1-y;u.getUniforms().setValue(e,"morphTargetBaseInfluence",x),u.getUniforms().setValue(e,"morphTargetInfluences",s)}}return{update:l}}function i4(e,t,i,r){let s=new WeakMap;function a(l){let h=r.render.frame,c=l.geometry,d=t.get(l,c);return s.get(d)!==h&&(t.update(d),s.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.update(l.instanceMatrix,34962),l.instanceColor!==null&&i.update(l.instanceColor,34962)),d}function n(){s=new WeakMap}function o(l){let h=l.target;h.removeEventListener("dispose",o),i.remove(h.instanceMatrix),h.instanceColor!==null&&i.remove(h.instanceColor)}return{update:a,dispose:n}}var mM=new ci,gM=new cM,vM=new GR,yM=new Gy,yb=[],xb=[],bb=new Float32Array(16),wb=new Float32Array(9),_b=new Float32Array(4);function qh(e,t,i){let r=e[0];if(r==null||r<=0||r>0)return e;let s=t*i,a=yb[s];if(a===void 0&&(a=new Float32Array(s),yb[s]=a),t!==0){r.toArray(a,0);for(let n=1,o=0;n!==t;++n)o+=i,e[n].toArray(a,o)}return a}function Wi(e,t){if(e.length!==t.length)return!1;for(let i=0,r=e.length;i<r;i++)if(e[i]!==t[i])return!1;return!0}function qi(e,t){for(let i=0,r=t.length;i<r;i++)e[i]=t[i]}function Yf(e,t){let i=xb[t];i===void 0&&(i=new Int32Array(t),xb[t]=i);for(let r=0;r!==t;++r)i[r]=e.allocateTextureUnit();return i}function r4(e,t){let i=this.cache;i[0]!==t&&(e.uniform1f(this.addr,t),i[0]=t)}function s4(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(Wi(i,t))return;e.uniform2fv(this.addr,t),qi(i,t)}}function a4(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else if(t.r!==void 0)(i[0]!==t.r||i[1]!==t.g||i[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),i[0]=t.r,i[1]=t.g,i[2]=t.b);else{if(Wi(i,t))return;e.uniform3fv(this.addr,t),qi(i,t)}}function n4(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z||i[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(Wi(i,t))return;e.uniform4fv(this.addr,t),qi(i,t)}}function o4(e,t){let i=this.cache,r=t.elements;if(r===void 0){if(Wi(i,t))return;e.uniformMatrix2fv(this.addr,!1,t),qi(i,t)}else{if(Wi(i,r))return;_b.set(r),e.uniformMatrix2fv(this.addr,!1,_b),qi(i,r)}}function l4(e,t){let i=this.cache,r=t.elements;if(r===void 0){if(Wi(i,t))return;e.uniformMatrix3fv(this.addr,!1,t),qi(i,t)}else{if(Wi(i,r))return;wb.set(r),e.uniformMatrix3fv(this.addr,!1,wb),qi(i,r)}}function h4(e,t){let i=this.cache,r=t.elements;if(r===void 0){if(Wi(i,t))return;e.uniformMatrix4fv(this.addr,!1,t),qi(i,t)}else{if(Wi(i,r))return;bb.set(r),e.uniformMatrix4fv(this.addr,!1,bb),qi(i,r)}}function c4(e,t){let i=this.cache;i[0]!==t&&(e.uniform1i(this.addr,t),i[0]=t)}function d4(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y)&&(e.uniform2i(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(Wi(i,t))return;e.uniform2iv(this.addr,t),qi(i,t)}}function u4(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z)&&(e.uniform3i(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else{if(Wi(i,t))return;e.uniform3iv(this.addr,t),qi(i,t)}}function p4(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z||i[3]!==t.w)&&(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(Wi(i,t))return;e.uniform4iv(this.addr,t),qi(i,t)}}function f4(e,t){let i=this.cache;i[0]!==t&&(e.uniform1ui(this.addr,t),i[0]=t)}function m4(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y)&&(e.uniform2ui(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(Wi(i,t))return;e.uniform2uiv(this.addr,t),qi(i,t)}}function g4(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z)&&(e.uniform3ui(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else{if(Wi(i,t))return;e.uniform3uiv(this.addr,t),qi(i,t)}}function v4(e,t){let i=this.cache;if(t.x!==void 0)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z||i[3]!==t.w)&&(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(Wi(i,t))return;e.uniform4uiv(this.addr,t),qi(i,t)}}function y4(e,t,i){let r=this.cache,s=i.allocateTextureUnit();r[0]!==s&&(e.uniform1i(this.addr,s),r[0]=s),i.setTexture2D(t||mM,s)}function x4(e,t,i){let r=this.cache,s=i.allocateTextureUnit();r[0]!==s&&(e.uniform1i(this.addr,s),r[0]=s),i.setTexture3D(t||vM,s)}function b4(e,t,i){let r=this.cache,s=i.allocateTextureUnit();r[0]!==s&&(e.uniform1i(this.addr,s),r[0]=s),i.setTextureCube(t||yM,s)}function w4(e,t,i){let r=this.cache,s=i.allocateTextureUnit();r[0]!==s&&(e.uniform1i(this.addr,s),r[0]=s),i.setTexture2DArray(t||gM,s)}function _4(e){switch(e){case 5126:return r4;case 35664:return s4;case 35665:return a4;case 35666:return n4;case 35674:return o4;case 35675:return l4;case 35676:return h4;case 5124:case 35670:return c4;case 35667:case 35671:return d4;case 35668:case 35672:return u4;case 35669:case 35673:return p4;case 5125:return f4;case 36294:return m4;case 36295:return g4;case 36296:return v4;case 35678:case 36198:case 36298:case 36306:case 35682:return y4;case 35679:case 36299:case 36307:return x4;case 35680:case 36300:case 36308:case 36293:return b4;case 36289:case 36303:case 36311:case 36292:return w4}}function S4(e,t){e.uniform1fv(this.addr,t)}function A4(e,t){let i=qh(t,this.size,2);e.uniform2fv(this.addr,i)}function M4(e,t){let i=qh(t,this.size,3);e.uniform3fv(this.addr,i)}function E4(e,t){let i=qh(t,this.size,4);e.uniform4fv(this.addr,i)}function C4(e,t){let i=qh(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,i)}function T4(e,t){let i=qh(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,i)}function P4(e,t){let i=qh(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,i)}function D4(e,t){e.uniform1iv(this.addr,t)}function I4(e,t){e.uniform2iv(this.addr,t)}function O4(e,t){e.uniform3iv(this.addr,t)}function R4(e,t){e.uniform4iv(this.addr,t)}function L4(e,t){e.uniform1uiv(this.addr,t)}function z4(e,t){e.uniform2uiv(this.addr,t)}function B4(e,t){e.uniform3uiv(this.addr,t)}function F4(e,t){e.uniform4uiv(this.addr,t)}function U4(e,t,i){let r=this.cache,s=t.length,a=Yf(i,s);Wi(r,a)||(e.uniform1iv(this.addr,a),qi(r,a));for(let n=0;n!==s;++n)i.setTexture2D(t[n]||mM,a[n])}function N4(e,t,i){let r=this.cache,s=t.length,a=Yf(i,s);Wi(r,a)||(e.uniform1iv(this.addr,a),qi(r,a));for(let n=0;n!==s;++n)i.setTexture3D(t[n]||vM,a[n])}function k4(e,t,i){let r=this.cache,s=t.length,a=Yf(i,s);Wi(r,a)||(e.uniform1iv(this.addr,a),qi(r,a));for(let n=0;n!==s;++n)i.setTextureCube(t[n]||yM,a[n])}function V4(e,t,i){let r=this.cache,s=t.length,a=Yf(i,s);Wi(r,a)||(e.uniform1iv(this.addr,a),qi(r,a));for(let n=0;n!==s;++n)i.setTexture2DArray(t[n]||gM,a[n])}function j4(e){switch(e){case 5126:return S4;case 35664:return A4;case 35665:return M4;case 35666:return E4;case 35674:return C4;case 35675:return T4;case 35676:return P4;case 5124:case 35670:return D4;case 35667:case 35671:return I4;case 35668:case 35672:return O4;case 35669:case 35673:return R4;case 5125:return L4;case 36294:return z4;case 36295:return B4;case 36296:return F4;case 35678:case 36198:case 36298:case 36306:case 35682:return U4;case 35679:case 36299:case 36307:return N4;case 35680:case 36300:case 36308:case 36293:return k4;case 36289:case 36303:case 36311:case 36292:return V4}}var G4=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.setValue=_4(t.type)}},H4=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.size=t.size,this.setValue=j4(t.type)}},W4=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){if(t===void 0)return;let r=this.seq;for(let s=0,a=r.length;s!==a;++s){let n=r[s];n.setValue(e,t[n.id],i)}}},eg=/(\w+)(\])?(\[|\.)?/g;function Sb(e,t){e.seq.push(t),e.map[t.id]=t}function q4(e,t,i){let r=e.name,s=r.length;for(eg.lastIndex=0;;){let a=eg.exec(r),n=eg.lastIndex,o=a[1],l=a[2]==="]",h=a[3];if(l&&(o=o|0),h===void 0||h==="["&&n+2===s){Sb(i,h===void 0?new G4(o,e,t):new H4(o,e,t));break}else{let c=i.map[o];c===void 0&&(c=new W4(o),Sb(i,c)),i=c}}}var Sp=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,35718);for(let r=0;r<i;++r){let s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);q4(s,a,this)}}setValue(e,t,i,r){let s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){let r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,a=t.length;s!==a;++s){let n=t[s],o=i[n.id];o.needsUpdate!==!1&&n.setValue(e,o.value,r)}}static seqWithValue(e,t){let i=[];for(let r=0,s=e.length;r!==s;++r){let a=e[r];a.id in t&&i.push(a)}return i}};function Ab(e,t,i){let r=e.createShader(t);return e.shaderSource(r,i),e.compileShader(r),r}var X4=0;function Y4(e,t){let i=e.split(`
  3009. `),r=[],s=Math.max(t-6,0),a=Math.min(t+6,i.length);for(let n=s;n<a;n++){let o=n+1;r.push(`${o===t?">":" "} ${o}: ${i[n]}`)}return r.join(`
  3010. `)}function Q4(e){switch(e){case qs:return["Linear","( value )"];case gt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}function Mb(e,t,i){let r=e.getShaderParameter(t,35713),s=e.getShaderInfoLog(t).trim();if(r&&s==="")return"";let a=/ERROR: 0:(\d+)/.exec(s);if(a){let n=parseInt(a[1]);return i.toUpperCase()+`
  3011. `+s+`
  3012. `+Y4(e.getShaderSource(t),n)}else return s}function Z4(e,t){let i=Q4(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function K4(e,t){let i;switch(t){case sR:i="Linear";break;case aR:i="Reinhard";break;case nR:i="OptimizedCineon";break;case oR:i="ACESFilmic";break;case lR:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function J4(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||e.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Uc).join(`
  3013. `)}function $4(e){let t=[];for(let i in e){let r=e[i];r!==!1&&t.push("#define "+i+" "+r)}return t.join(`
  3014. `)}function eF(e,t){let i={},r=e.getProgramParameter(t,35721);for(let s=0;s<r;s++){let a=e.getActiveAttrib(t,s),n=a.name,o=1;a.type===35674&&(o=2),a.type===35675&&(o=3),a.type===35676&&(o=4),i[n]={type:a.type,location:e.getAttribLocation(t,n),locationSize:o}}return i}function Uc(e){return e!==""}function Eb(e,t){let i=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.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,i).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 Cb(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var tF=/^[ \t]*#include +<([\w\d./]+)>/gm;function Fv(e){return e.replace(tF,iF)}function iF(e,t){let i=yt[t];if(i===void 0)throw new Error("Can not resolve #include <"+t+">");return Fv(i)}var rF=/#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 Tb(e){return e.replace(rF,sF)}function sF(e,t,i,r){let s="";for(let a=parseInt(t);a<parseInt(i);a++)s+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return s}function Pb(e){let t="precision "+e.precision+` float;
  3015. precision `+e.precision+" int;";return e.precision==="highp"?t+=`
  3016. #define HIGH_PRECISION`:e.precision==="mediump"?t+=`
  3017. #define MEDIUM_PRECISION`:e.precision==="lowp"&&(t+=`
  3018. #define LOW_PRECISION`),t}function aF(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===Uy?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===BO?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===Fc&&(t="SHADOWMAP_TYPE_VSM"),t}function nF(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case al:case nl:t="ENVMAP_TYPE_CUBE";break;case Rd:t="ENVMAP_TYPE_CUBE_UV";break}return t}function oF(e){let t="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case nl:t="ENVMAP_MODE_REFRACTION";break}return t}function lF(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case J2:t="ENVMAP_BLENDING_MULTIPLY";break;case iR:t="ENVMAP_BLENDING_MIX";break;case rR:t="ENVMAP_BLENDING_ADD";break}return t}function hF(e){let t=e.envMapCubeUVHeight;if(t===null)return null;let i=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,i),7*16)),texelHeight:r,maxMip:i}}function cF(e,t,i,r){let s=e.getContext(),a=i.defines,n=i.vertexShader,o=i.fragmentShader,l=aF(i),h=nF(i),c=oF(i),d=lF(i),u=hF(i),p=i.isWebGL2?"":J4(i),f=$4(a),g=s.createProgram(),m,v,y=i.glslVersion?"#version "+i.glslVersion+`
  3019. `:"";i.isRawShaderMaterial?(m=[f].filter(Uc).join(`
  3020. `),m.length>0&&(m+=`
  3021. `),v=[p,f].filter(Uc).join(`
  3022. `),v.length>0&&(v+=`
  3023. `)):(m=[Pb(i),"#define SHADER_NAME "+i.shaderName,f,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularColorMap?"#define USE_SPECULARCOLORMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEENCOLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&i.flatShading===!1?"#define USE_MORPHNORMALS":"",i.morphColors&&i.isWebGL2?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3024. `].filter(Uc).join(`
  3025. `),v=[p,Pb(i),"#define SHADER_NAME "+i.shaderName,f,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.envMap?"#define "+c:"",i.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularColorMap?"#define USE_SPECULARCOLORMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEENCOLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==_a?"#define TONE_MAPPING":"",i.toneMapping!==_a?yt.tonemapping_pars_fragment:"",i.toneMapping!==_a?K4("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",yt.encodings_pars_fragment,Z4("linearToOutputTexel",i.outputEncoding),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"",`
  3026. `].filter(Uc).join(`
  3027. `)),n=Fv(n),n=Eb(n,i),n=Cb(n,i),o=Fv(o),o=Eb(o,i),o=Cb(o,i),n=Tb(n),o=Tb(o),i.isWebGL2&&i.isRawShaderMaterial!==!0&&(y=`#version 300 es
  3028. `,m=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  3029. `)+`
  3030. `+m,v=["#define varying in",i.glslVersion===Lv?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===Lv?"":"#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(`
  3031. `)+`
  3032. `+v);let x=y+m+n,w=y+v+o,_=Ab(s,35633,x),b=Ab(s,35632,w);if(s.attachShader(g,_),s.attachShader(g,b),i.index0AttributeName!==void 0?s.bindAttribLocation(g,0,i.index0AttributeName):i.morphTargets===!0&&s.bindAttribLocation(g,0,"position"),s.linkProgram(g),e.debug.checkShaderErrors){let E=s.getProgramInfoLog(g).trim(),C=s.getShaderInfoLog(_).trim(),T=s.getShaderInfoLog(b).trim(),D=!0,O=!0;if(s.getProgramParameter(g,35714)===!1){D=!1;let P=Mb(s,_,"vertex"),U=Mb(s,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(g,35715)+`
  3033. Program Info Log: `+E+`
  3034. `+P+`
  3035. `+U)}else E!==""?console.warn("THREE.WebGLProgram: Program Info Log:",E):(C===""||T==="")&&(O=!1);O&&(this.diagnostics={runnable:D,programLog:E,vertexShader:{log:C,prefix:m},fragmentShader:{log:T,prefix:v}})}s.deleteShader(_),s.deleteShader(b);let A;this.getUniforms=function(){return A===void 0&&(A=new Sp(s,g)),A};let S;return this.getAttributes=function(){return S===void 0&&(S=eF(s,g)),S},this.destroy=function(){r.releaseStatesOfProgram(this),s.deleteProgram(g),this.program=void 0},this.name=i.shaderName,this.id=X4++,this.cacheKey=t,this.usedTimes=1,this.program=g,this.vertexShader=_,this.fragmentShader=b,this}var dF=0,uF=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new pF(e),t.set(e,i)),i}},pF=class{constructor(e){this.id=dF++,this.code=e,this.usedTimes=0}};function fF(e,t,i,r,s,a,n){let o=new jy,l=new uF,h=[],c=s.isWebGL2,d=s.logarithmicDepthBuffer,u=s.vertexTextures,p=s.precision,f={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 g(S,E,C,T,D){let O=T.fog,P=D.geometry,U=S.isMeshStandardMaterial?T.environment:null,W=(S.isMeshStandardMaterial?i:t).get(S.envMap||U),k=W&&W.mapping===Rd?W.image.height:null,F=f[S.type];S.precision!==null&&(p=s.getMaxPrecision(S.precision),p!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",p,"instead."));let Z=P.morphAttributes.position||P.morphAttributes.normal||P.morphAttributes.color,X=Z!==void 0?Z.length:0,G=0;P.morphAttributes.position!==void 0&&(G=1),P.morphAttributes.normal!==void 0&&(G=2),P.morphAttributes.color!==void 0&&(G=3);let q,$,Q,ee;if(F){let ae=ma[F];q=ae.vertexShader,$=ae.fragmentShader}else q=S.vertexShader,$=S.fragmentShader,l.update(S),Q=l.getVertexShaderID(S),ee=l.getFragmentShaderID(S);let H=e.getRenderTarget(),he=S.alphaTest>0,re=S.clearcoat>0,te=S.iridescence>0;return{isWebGL2:c,shaderID:F,shaderName:S.type,vertexShader:q,fragmentShader:$,defines:S.defines,customVertexShaderID:Q,customFragmentShaderID:ee,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:p,instancing:D.isInstancedMesh===!0,instancingColor:D.isInstancedMesh===!0&&D.instanceColor!==null,supportsVertexTextures:u,outputEncoding:H===null?e.outputEncoding:H.isXRRenderTarget===!0?H.texture.encoding:qs,map:!!S.map,matcap:!!S.matcap,envMap:!!W,envMapMode:W&&W.mapping,envMapCubeUVHeight:k,lightMap:!!S.lightMap,aoMap:!!S.aoMap,emissiveMap:!!S.emissiveMap,bumpMap:!!S.bumpMap,normalMap:!!S.normalMap,objectSpaceNormalMap:S.normalMapType===AR,tangentSpaceNormalMap:S.normalMapType===SR,decodeVideoTexture:!!S.map&&S.map.isVideoTexture===!0&&S.map.encoding===gt,clearcoat:re,clearcoatMap:re&&!!S.clearcoatMap,clearcoatRoughnessMap:re&&!!S.clearcoatRoughnessMap,clearcoatNormalMap:re&&!!S.clearcoatNormalMap,iridescence:te,iridescenceMap:te&&!!S.iridescenceMap,iridescenceThicknessMap:te&&!!S.iridescenceThicknessMap,displacementMap:!!S.displacementMap,roughnessMap:!!S.roughnessMap,metalnessMap:!!S.metalnessMap,specularMap:!!S.specularMap,specularIntensityMap:!!S.specularIntensityMap,specularColorMap:!!S.specularColorMap,opaque:S.transparent===!1&&S.blending===Jo,alphaMap:!!S.alphaMap,alphaTest:he,gradientMap:!!S.gradientMap,sheen:S.sheen>0,sheenColorMap:!!S.sheenColorMap,sheenRoughnessMap:!!S.sheenRoughnessMap,transmission:S.transmission>0,transmissionMap:!!S.transmissionMap,thicknessMap:!!S.thicknessMap,combine:S.combine,vertexTangents:!!S.normalMap&&!!P.attributes.tangent,vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!P.attributes.color&&P.attributes.color.itemSize===4,vertexUvs:!!S.map||!!S.bumpMap||!!S.normalMap||!!S.specularMap||!!S.alphaMap||!!S.emissiveMap||!!S.roughnessMap||!!S.metalnessMap||!!S.clearcoatMap||!!S.clearcoatRoughnessMap||!!S.clearcoatNormalMap||!!S.iridescenceMap||!!S.iridescenceThicknessMap||!!S.displacementMap||!!S.transmissionMap||!!S.thicknessMap||!!S.specularIntensityMap||!!S.specularColorMap||!!S.sheenColorMap||!!S.sheenRoughnessMap,uvsVertexOnly:!(S.map||S.bumpMap||S.normalMap||S.specularMap||S.alphaMap||S.emissiveMap||S.roughnessMap||S.metalnessMap||S.clearcoatNormalMap||S.iridescenceMap||S.iridescenceThicknessMap||S.transmission>0||S.transmissionMap||S.thicknessMap||S.specularIntensityMap||S.specularColorMap||S.sheen>0||S.sheenColorMap||S.sheenRoughnessMap)&&!!S.displacementMap,fog:!!O,useFog:S.fog===!0,fogExp2:O&&O.isFogExp2,flatShading:!!S.flatShading,sizeAttenuation:S.sizeAttenuation,logarithmicDepthBuffer:d,skinning:D.isSkinnedMesh===!0,morphTargets:P.morphAttributes.position!==void 0,morphNormals:P.morphAttributes.normal!==void 0,morphColors:P.morphAttributes.color!==void 0,morphTargetsCount:X,morphTextureStride:G,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numClippingPlanes:n.numPlanes,numClipIntersection:n.numIntersection,dithering:S.dithering,shadowMapEnabled:e.shadowMap.enabled&&C.length>0,shadowMapType:e.shadowMap.type,toneMapping:S.toneMapped?e.toneMapping:_a,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Ar,flipSided:S.side===rr,useDepthPacking:!!S.depthPacking,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionDerivatives:S.extensions&&S.extensions.derivatives,extensionFragDepth:S.extensions&&S.extensions.fragDepth,extensionDrawBuffers:S.extensions&&S.extensions.drawBuffers,extensionShaderTextureLOD:S.extensions&&S.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||r.has("EXT_shader_texture_lod"),customProgramCacheKey:S.customProgramCacheKey()}}function m(S){let E=[];if(S.shaderID?E.push(S.shaderID):(E.push(S.customVertexShaderID),E.push(S.customFragmentShaderID)),S.defines!==void 0)for(let C in S.defines)E.push(C),E.push(S.defines[C]);return S.isRawShaderMaterial===!1&&(v(E,S),y(E,S),E.push(e.outputEncoding)),E.push(S.customProgramCacheKey),E.join()}function v(S,E){S.push(E.precision),S.push(E.outputEncoding),S.push(E.envMapMode),S.push(E.envMapCubeUVHeight),S.push(E.combine),S.push(E.vertexUvs),S.push(E.fogExp2),S.push(E.sizeAttenuation),S.push(E.morphTargetsCount),S.push(E.morphAttributeCount),S.push(E.numDirLights),S.push(E.numPointLights),S.push(E.numSpotLights),S.push(E.numSpotLightMaps),S.push(E.numHemiLights),S.push(E.numRectAreaLights),S.push(E.numDirLightShadows),S.push(E.numPointLightShadows),S.push(E.numSpotLightShadows),S.push(E.numSpotLightShadowsWithMaps),S.push(E.shadowMapType),S.push(E.toneMapping),S.push(E.numClippingPlanes),S.push(E.numClipIntersection),S.push(E.depthPacking)}function y(S,E){o.disableAll(),E.isWebGL2&&o.enable(0),E.supportsVertexTextures&&o.enable(1),E.instancing&&o.enable(2),E.instancingColor&&o.enable(3),E.map&&o.enable(4),E.matcap&&o.enable(5),E.envMap&&o.enable(6),E.lightMap&&o.enable(7),E.aoMap&&o.enable(8),E.emissiveMap&&o.enable(9),E.bumpMap&&o.enable(10),E.normalMap&&o.enable(11),E.objectSpaceNormalMap&&o.enable(12),E.tangentSpaceNormalMap&&o.enable(13),E.clearcoat&&o.enable(14),E.clearcoatMap&&o.enable(15),E.clearcoatRoughnessMap&&o.enable(16),E.clearcoatNormalMap&&o.enable(17),E.iridescence&&o.enable(18),E.iridescenceMap&&o.enable(19),E.iridescenceThicknessMap&&o.enable(20),E.displacementMap&&o.enable(21),E.specularMap&&o.enable(22),E.roughnessMap&&o.enable(23),E.metalnessMap&&o.enable(24),E.gradientMap&&o.enable(25),E.alphaMap&&o.enable(26),E.alphaTest&&o.enable(27),E.vertexColors&&o.enable(28),E.vertexAlphas&&o.enable(29),E.vertexUvs&&o.enable(30),E.vertexTangents&&o.enable(31),E.uvsVertexOnly&&o.enable(32),S.push(o.mask),o.disableAll(),E.fog&&o.enable(0),E.useFog&&o.enable(1),E.flatShading&&o.enable(2),E.logarithmicDepthBuffer&&o.enable(3),E.skinning&&o.enable(4),E.morphTargets&&o.enable(5),E.morphNormals&&o.enable(6),E.morphColors&&o.enable(7),E.premultipliedAlpha&&o.enable(8),E.shadowMapEnabled&&o.enable(9),E.physicallyCorrectLights&&o.enable(10),E.doubleSided&&o.enable(11),E.flipSided&&o.enable(12),E.useDepthPacking&&o.enable(13),E.dithering&&o.enable(14),E.specularIntensityMap&&o.enable(15),E.specularColorMap&&o.enable(16),E.transmission&&o.enable(17),E.transmissionMap&&o.enable(18),E.thicknessMap&&o.enable(19),E.sheen&&o.enable(20),E.sheenColorMap&&o.enable(21),E.sheenRoughnessMap&&o.enable(22),E.decodeVideoTexture&&o.enable(23),E.opaque&&o.enable(24),S.push(o.mask)}function x(S){let E=f[S.type],C;if(E){let T=ma[E];C=Wh.clone(T.uniforms)}else C=S.uniforms;return C}function w(S,E){let C;for(let T=0,D=h.length;T<D;T++){let O=h[T];if(O.cacheKey===E){C=O,++C.usedTimes;break}}return C===void 0&&(C=new cF(e,E,S,a),h.push(C)),C}function _(S){if(--S.usedTimes===0){let E=h.indexOf(S);h[E]=h[h.length-1],h.pop(),S.destroy()}}function b(S){l.remove(S)}function A(){l.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:x,acquireProgram:w,releaseProgram:_,releaseShaderCache:b,programs:h,dispose:A}}function mF(){let e=new WeakMap;function t(a){let n=e.get(a);return n===void 0&&(n={},e.set(a,n)),n}function i(a){e.delete(a)}function r(a,n,o){e.get(a)[n]=o}function s(){e=new WeakMap}return{get:t,remove:i,update:r,dispose:s}}function gF(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Db(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Ib(){let e=[],t=0,i=[],r=[],s=[];function a(){t=0,i.length=0,r.length=0,s.length=0}function n(d,u,p,f,g,m){let v=e[t];return v===void 0?(v={id:d.id,object:d,geometry:u,material:p,groupOrder:f,renderOrder:d.renderOrder,z:g,group:m},e[t]=v):(v.id=d.id,v.object=d,v.geometry=u,v.material=p,v.groupOrder=f,v.renderOrder=d.renderOrder,v.z=g,v.group=m),t++,v}function o(d,u,p,f,g,m){let v=n(d,u,p,f,g,m);p.transmission>0?r.push(v):p.transparent===!0?s.push(v):i.push(v)}function l(d,u,p,f,g,m){let v=n(d,u,p,f,g,m);p.transmission>0?r.unshift(v):p.transparent===!0?s.unshift(v):i.unshift(v)}function h(d,u){i.length>1&&i.sort(d||gF),r.length>1&&r.sort(u||Db),s.length>1&&s.sort(u||Db)}function c(){for(let d=t,u=e.length;d<u;d++){let p=e[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:i,transmissive:r,transparent:s,init:a,push:o,unshift:l,finish:c,sort:h}}function vF(){let e=new WeakMap;function t(r,s){let a=e.get(r),n;return a===void 0?(n=new Ib,e.set(r,[n])):s>=a.length?(n=new Ib,a.push(n)):n=a[s],n}function i(){e=new WeakMap}return{get:t,dispose:i}}function yF(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new M,color:new et};break;case"SpotLight":i={position:new M,direction:new M,color:new et,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new M,color:new et,distance:0,decay:0};break;case"HemisphereLight":i={direction:new M,skyColor:new et,groundColor:new et};break;case"RectAreaLight":i={color:new et,position:new M,halfWidth:new M,halfHeight:new M};break}return e[t.id]=i,i}}}function xF(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let i;switch(t.type){case"DirectionalLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new j};break;case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new j};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new j,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=i,i}}}var bF=0;function wF(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function _F(e,t){let i=new yF,r=xF(),s={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let c=0;c<9;c++)s.probe.push(new M);let a=new M,n=new we,o=new we;function l(c,d){let u=0,p=0,f=0;for(let T=0;T<9;T++)s.probe[T].set(0,0,0);let g=0,m=0,v=0,y=0,x=0,w=0,_=0,b=0,A=0,S=0;c.sort(wF);let E=d!==!0?Math.PI:1;for(let T=0,D=c.length;T<D;T++){let O=c[T],P=O.color,U=O.intensity,W=O.distance,k=O.shadow&&O.shadow.map?O.shadow.map.texture:null;if(O.isAmbientLight)u+=P.r*U*E,p+=P.g*U*E,f+=P.b*U*E;else if(O.isLightProbe)for(let F=0;F<9;F++)s.probe[F].addScaledVector(O.sh.coefficients[F],U);else if(O.isDirectionalLight){let F=i.get(O);if(F.color.copy(O.color).multiplyScalar(O.intensity*E),O.castShadow){let Z=O.shadow,X=r.get(O);X.shadowBias=Z.bias,X.shadowNormalBias=Z.normalBias,X.shadowRadius=Z.radius,X.shadowMapSize=Z.mapSize,s.directionalShadow[g]=X,s.directionalShadowMap[g]=k,s.directionalShadowMatrix[g]=O.shadow.matrix,w++}s.directional[g]=F,g++}else if(O.isSpotLight){let F=i.get(O);F.position.setFromMatrixPosition(O.matrixWorld),F.color.copy(P).multiplyScalar(U*E),F.distance=W,F.coneCos=Math.cos(O.angle),F.penumbraCos=Math.cos(O.angle*(1-O.penumbra)),F.decay=O.decay,s.spot[v]=F;let Z=O.shadow;if(O.map&&(s.spotLightMap[A]=O.map,A++,Z.updateMatrices(O),O.castShadow&&S++),s.spotLightMatrix[v]=Z.matrix,O.castShadow){let X=r.get(O);X.shadowBias=Z.bias,X.shadowNormalBias=Z.normalBias,X.shadowRadius=Z.radius,X.shadowMapSize=Z.mapSize,s.spotShadow[v]=X,s.spotShadowMap[v]=k,b++}v++}else if(O.isRectAreaLight){let F=i.get(O);F.color.copy(P).multiplyScalar(U),F.halfWidth.set(O.width*.5,0,0),F.halfHeight.set(0,O.height*.5,0),s.rectArea[y]=F,y++}else if(O.isPointLight){let F=i.get(O);if(F.color.copy(O.color).multiplyScalar(O.intensity*E),F.distance=O.distance,F.decay=O.decay,O.castShadow){let Z=O.shadow,X=r.get(O);X.shadowBias=Z.bias,X.shadowNormalBias=Z.normalBias,X.shadowRadius=Z.radius,X.shadowMapSize=Z.mapSize,X.shadowCameraNear=Z.camera.near,X.shadowCameraFar=Z.camera.far,s.pointShadow[m]=X,s.pointShadowMap[m]=k,s.pointShadowMatrix[m]=O.shadow.matrix,_++}s.point[m]=F,m++}else if(O.isHemisphereLight){let F=i.get(O);F.skyColor.copy(O.color).multiplyScalar(U*E),F.groundColor.copy(O.groundColor).multiplyScalar(U*E),s.hemi[x]=F,x++}}y>0&&(t.isWebGL2||e.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=Pe.LTC_FLOAT_1,s.rectAreaLTC2=Pe.LTC_FLOAT_2):e.has("OES_texture_half_float_linear")===!0?(s.rectAreaLTC1=Pe.LTC_HALF_1,s.rectAreaLTC2=Pe.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),s.ambient[0]=u,s.ambient[1]=p,s.ambient[2]=f;let C=s.hash;(C.directionalLength!==g||C.pointLength!==m||C.spotLength!==v||C.rectAreaLength!==y||C.hemiLength!==x||C.numDirectionalShadows!==w||C.numPointShadows!==_||C.numSpotShadows!==b||C.numSpotMaps!==A)&&(s.directional.length=g,s.spot.length=v,s.rectArea.length=y,s.point.length=m,s.hemi.length=x,s.directionalShadow.length=w,s.directionalShadowMap.length=w,s.pointShadow.length=_,s.pointShadowMap.length=_,s.spotShadow.length=b,s.spotShadowMap.length=b,s.directionalShadowMatrix.length=w,s.pointShadowMatrix.length=_,s.spotLightMatrix.length=b+A-S,s.spotLightMap.length=A,s.numSpotLightShadowsWithMaps=S,C.directionalLength=g,C.pointLength=m,C.spotLength=v,C.rectAreaLength=y,C.hemiLength=x,C.numDirectionalShadows=w,C.numPointShadows=_,C.numSpotShadows=b,C.numSpotMaps=A,s.version=bF++)}function h(c,d){let u=0,p=0,f=0,g=0,m=0,v=d.matrixWorldInverse;for(let y=0,x=c.length;y<x;y++){let w=c[y];if(w.isDirectionalLight){let _=s.directional[u];_.direction.setFromMatrixPosition(w.matrixWorld),a.setFromMatrixPosition(w.target.matrixWorld),_.direction.sub(a),_.direction.transformDirection(v),u++}else if(w.isSpotLight){let _=s.spot[f];_.position.setFromMatrixPosition(w.matrixWorld),_.position.applyMatrix4(v),_.direction.setFromMatrixPosition(w.matrixWorld),a.setFromMatrixPosition(w.target.matrixWorld),_.direction.sub(a),_.direction.transformDirection(v),f++}else if(w.isRectAreaLight){let _=s.rectArea[g];_.position.setFromMatrixPosition(w.matrixWorld),_.position.applyMatrix4(v),o.identity(),n.copy(w.matrixWorld),n.premultiply(v),o.extractRotation(n),_.halfWidth.set(w.width*.5,0,0),_.halfHeight.set(0,w.height*.5,0),_.halfWidth.applyMatrix4(o),_.halfHeight.applyMatrix4(o),g++}else if(w.isPointLight){let _=s.point[p];_.position.setFromMatrixPosition(w.matrixWorld),_.position.applyMatrix4(v),p++}else if(w.isHemisphereLight){let _=s.hemi[m];_.direction.setFromMatrixPosition(w.matrixWorld),_.direction.transformDirection(v),m++}}}return{setup:l,setupView:h,state:s}}function Ob(e,t){let i=new _F(e,t),r=[],s=[];function a(){r.length=0,s.length=0}function n(c){r.push(c)}function o(c){s.push(c)}function l(c){i.setup(r,c)}function h(c){i.setupView(r,c)}return{init:a,state:{lightsArray:r,shadowsArray:s,lights:i},setupLights:l,setupLightsView:h,pushLight:n,pushShadow:o}}function SF(e,t){let i=new WeakMap;function r(a,n=0){let o=i.get(a),l;return o===void 0?(l=new Ob(e,t),i.set(a,[l])):n>=o.length?(l=new Ob(e,t),o.push(l)):l=o[n],l}function s(){i=new WeakMap}return{get:r,dispose:s}}var xM=class extends Ld{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=_n,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},AF=class extends Ld{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new M,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},MF=`void main() {
  3036. gl_Position = vec4( position, 1.0 );
  3037. }`,EF=`uniform sampler2D shadow_pass;
  3038. uniform vec2 resolution;
  3039. uniform float radius;
  3040. #include <packing>
  3041. void main() {
  3042. const float samples = float( VSM_SAMPLES );
  3043. float mean = 0.0;
  3044. float squared_mean = 0.0;
  3045. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3046. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3047. for ( float i = 0.0; i < samples; i ++ ) {
  3048. float uvOffset = uvStart + i * uvStride;
  3049. #ifdef HORIZONTAL_PASS
  3050. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3051. mean += distribution.x;
  3052. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3053. #else
  3054. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3055. mean += depth;
  3056. squared_mean += depth * depth;
  3057. #endif
  3058. }
  3059. mean = mean / samples;
  3060. squared_mean = squared_mean / samples;
  3061. float std_dev = sqrt( squared_mean - mean * mean );
  3062. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3063. }`;function CF(e,t,i){let r=new Hy,s=new j,a=new j,n=new ct,o=new xM({depthPacking:sM}),l=new AF,h={},c=i.maxTextureSize,d={[Ws]:rr,[rr]:Ws,[Ar]:Ar},u=new Dt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new j},radius:{value:4}},vertexShader:MF,fragmentShader:EF}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let f=new Ge;f.setAttribute("position",new tt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new Jt(f,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Uy,this.render=function(w,_,b){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;let A=e.getRenderTarget(),S=e.getActiveCubeFace(),E=e.getActiveMipmapLevel(),C=e.state;C.setBlending(Oi),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,D=w.length;T<D;T++){let O=w[T],P=O.shadow;if(P===void 0){console.warn("THREE.WebGLShadowMap:",O,"has no shadow.");continue}if(P.autoUpdate===!1&&P.needsUpdate===!1)continue;s.copy(P.mapSize);let U=P.getFrameExtents();if(s.multiply(U),a.copy(P.mapSize),(s.x>c||s.y>c)&&(s.x>c&&(a.x=Math.floor(c/U.x),s.x=a.x*U.x,P.mapSize.x=a.x),s.y>c&&(a.y=Math.floor(c/U.y),s.y=a.y*U.y,P.mapSize.y=a.y)),P.map===null){let k=this.type!==Fc?{minFilter:_t,magFilter:_t}:{};P.map=new Pt(s.x,s.y,k),P.map.texture.name=O.name+".shadowMap",P.camera.updateProjectionMatrix()}e.setRenderTarget(P.map),e.clear();let W=P.getViewportCount();for(let k=0;k<W;k++){let F=P.getViewport(k);n.set(a.x*F.x,a.y*F.y,a.x*F.z,a.y*F.w),C.viewport(n),P.updateMatrices(O,k),r=P.getFrustum(),x(_,b,P.camera,O,this.type)}P.isPointLightShadow!==!0&&this.type===Fc&&v(P,b),P.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(A,S,E)};function v(w,_){let b=t.update(g);u.defines.VSM_SAMPLES!==w.blurSamples&&(u.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new Pt(s.x,s.y)),u.uniforms.shadow_pass.value=w.map.texture,u.uniforms.resolution.value=w.mapSize,u.uniforms.radius.value=w.radius,e.setRenderTarget(w.mapPass),e.clear(),e.renderBufferDirect(_,null,b,u,g,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value=w.mapSize,p.uniforms.radius.value=w.radius,e.setRenderTarget(w.map),e.clear(),e.renderBufferDirect(_,null,b,p,g,null)}function y(w,_,b,A,S,E){let C=null,T=b.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(T!==void 0)C=T;else if(C=b.isPointLight===!0?l:o,e.localClippingEnabled&&_.clipShadows===!0&&Array.isArray(_.clippingPlanes)&&_.clippingPlanes.length!==0||_.displacementMap&&_.displacementScale!==0||_.alphaMap&&_.alphaTest>0||_.map&&_.alphaTest>0){let D=C.uuid,O=_.uuid,P=h[D];P===void 0&&(P={},h[D]=P);let U=P[O];U===void 0&&(U=C.clone(),P[O]=U),C=U}return C.visible=_.visible,C.wireframe=_.wireframe,E===Fc?C.side=_.shadowSide!==null?_.shadowSide:_.side:C.side=_.shadowSide!==null?_.shadowSide:d[_.side],C.alphaMap=_.alphaMap,C.alphaTest=_.alphaTest,C.map=_.map,C.clipShadows=_.clipShadows,C.clippingPlanes=_.clippingPlanes,C.clipIntersection=_.clipIntersection,C.displacementMap=_.displacementMap,C.displacementScale=_.displacementScale,C.displacementBias=_.displacementBias,C.wireframeLinewidth=_.wireframeLinewidth,C.linewidth=_.linewidth,b.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(b.matrixWorld),C.nearDistance=A,C.farDistance=S),C}function x(w,_,b,A,S){if(w.visible===!1)return;if(w.layers.test(_.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&S===Fc)&&(!w.frustumCulled||r.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,w.matrixWorld);let C=t.update(w),T=w.material;if(Array.isArray(T)){let D=C.groups;for(let O=0,P=D.length;O<P;O++){let U=D[O],W=T[U.materialIndex];if(W&&W.visible){let k=y(w,W,A,b.near,b.far,S);e.renderBufferDirect(b,null,C,k,w,U)}}}else if(T.visible){let D=y(w,T,A,b.near,b.far,S);e.renderBufferDirect(b,null,C,D,w,null)}}let E=w.children;for(let C=0,T=E.length;C<T;C++)x(E[C],_,b,A,S)}}function TF(e,t,i){let r=i.isWebGL2;function s(){let K=!1,ge=new ct,_e=null,Be=new ct(0,0,0,0);return{setMask:function(nt){_e!==nt&&!K&&(e.colorMask(nt,nt,nt,nt),_e=nt)},setLocked:function(nt){K=nt},setClear:function(nt,Et,vi,Yi,Ks){Ks===!0&&(nt*=Yi,Et*=Yi,vi*=Yi),ge.set(nt,Et,vi,Yi),Be.equals(ge)===!1&&(e.clearColor(nt,Et,vi,Yi),Be.copy(ge))},reset:function(){K=!1,_e=null,Be.set(-1,0,0,0)}}}function a(){let K=!1,ge=null,_e=null,Be=null;return{setTest:function(nt){nt?he(2929):re(2929)},setMask:function(nt){ge!==nt&&!K&&(e.depthMask(nt),ge=nt)},setFunc:function(nt){if(_e!==nt){switch(nt){case QO:e.depthFunc(512);break;case ZO:e.depthFunc(519);break;case KO:e.depthFunc(513);break;case Pv:e.depthFunc(515);break;case JO:e.depthFunc(514);break;case $O:e.depthFunc(518);break;case eR:e.depthFunc(516);break;case tR:e.depthFunc(517);break;default:e.depthFunc(515)}_e=nt}},setLocked:function(nt){K=nt},setClear:function(nt){Be!==nt&&(e.clearDepth(nt),Be=nt)},reset:function(){K=!1,ge=null,_e=null,Be=null}}}function n(){let K=!1,ge=null,_e=null,Be=null,nt=null,Et=null,vi=null,Yi=null,Ks=null;return{setTest:function($t){K||($t?he(2960):re(2960))},setMask:function($t){ge!==$t&&!K&&(e.stencilMask($t),ge=$t)},setFunc:function($t,Es,Gr){(_e!==$t||Be!==Es||nt!==Gr)&&(e.stencilFunc($t,Es,Gr),_e=$t,Be=Es,nt=Gr)},setOp:function($t,Es,Gr){(Et!==$t||vi!==Es||Yi!==Gr)&&(e.stencilOp($t,Es,Gr),Et=$t,vi=Es,Yi=Gr)},setLocked:function($t){K=$t},setClear:function($t){Ks!==$t&&(e.clearStencil($t),Ks=$t)},reset:function(){K=!1,ge=null,_e=null,Be=null,nt=null,Et=null,vi=null,Yi=null,Ks=null}}}let o=new s,l=new a,h=new n,c=new WeakMap,d=new WeakMap,u={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,x=null,w=null,_=null,b=null,A=null,S=null,E=!1,C=null,T=null,D=null,O=null,P=null,U=e.getParameter(35661),W=!1,k=0,F=e.getParameter(7938);F.indexOf("WebGL")!==-1?(k=parseFloat(/^WebGL (\d)/.exec(F)[1]),W=k>=1):F.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),W=k>=2);let Z=null,X={},G=e.getParameter(3088),q=e.getParameter(2978),$=new ct().fromArray(G),Q=new ct().fromArray(q);function ee(K,ge,_e){let Be=new Uint8Array(4),nt=e.createTexture();e.bindTexture(K,nt),e.texParameteri(K,10241,9728),e.texParameteri(K,10240,9728);for(let Et=0;Et<_e;Et++)e.texImage2D(ge+Et,0,6408,1,1,0,6408,5121,Be);return nt}let H={};H[3553]=ee(3553,3553,1),H[34067]=ee(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),he(2929),l.setFunc(Pv),Ve(!1),Ue(Ax),he(2884),Le(Oi);function he(K){u[K]!==!0&&(e.enable(K),u[K]=!0)}function re(K){u[K]!==!1&&(e.disable(K),u[K]=!1)}function te(K,ge){return p[K]!==ge?(e.bindFramebuffer(K,ge),p[K]=ge,r&&(K===36009&&(p[36160]=ge),K===36160&&(p[36009]=ge)),!0):!1}function ae(K,ge){let _e=g,Be=!1;if(K)if(_e=f.get(ge),_e===void 0&&(_e=[],f.set(ge,_e)),K.isWebGLMultipleRenderTargets){let nt=K.texture;if(_e.length!==nt.length||_e[0]!==36064){for(let Et=0,vi=nt.length;Et<vi;Et++)_e[Et]=36064+Et;_e.length=nt.length,Be=!0}}else _e[0]!==36064&&(_e[0]=36064,Be=!0);else _e[0]!==1029&&(_e[0]=1029,Be=!0);Be&&(i.isWebGL2?e.drawBuffers(_e):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(_e))}function de(K){return m!==K?(e.useProgram(K),m=K,!0):!1}let pe={[eh]:32774,[UO]:32778,[NO]:32779};if(r)pe[Tx]=32775,pe[Px]=32776;else{let K=t.get("EXT_blend_minmax");K!==null&&(pe[Tx]=K.MIN_EXT,pe[Px]=K.MAX_EXT)}let be={[kO]:0,[VO]:1,[jO]:768,[Z2]:770,[YO]:776,[qO]:774,[HO]:772,[GO]:769,[K2]:771,[XO]:775,[WO]:773};function Le(K,ge,_e,Be,nt,Et,vi,Yi){if(K===Oi){v===!0&&(re(3042),v=!1);return}if(v===!1&&(he(3042),v=!0),K!==FO){if(K!==y||Yi!==E){if((x!==eh||b!==eh)&&(e.blendEquation(32774),x=eh,b=eh),Yi)switch(K){case Jo:e.blendFuncSeparate(1,771,1,771);break;case Mx:e.blendFunc(1,1);break;case Ex:e.blendFuncSeparate(0,769,0,1);break;case Cx:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",K);break}else switch(K){case Jo:e.blendFuncSeparate(770,771,1,771);break;case Mx:e.blendFunc(770,1);break;case Ex:e.blendFuncSeparate(0,769,0,1);break;case Cx:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",K);break}w=null,_=null,A=null,S=null,y=K,E=Yi}return}nt=nt||ge,Et=Et||_e,vi=vi||Be,(ge!==x||nt!==b)&&(e.blendEquationSeparate(pe[ge],pe[nt]),x=ge,b=nt),(_e!==w||Be!==_||Et!==A||vi!==S)&&(e.blendFuncSeparate(be[_e],be[Be],be[Et],be[vi]),w=_e,_=Be,A=Et,S=vi),y=K,E=!1}function Me(K,ge){K.side===Ar?re(2884):he(2884);let _e=K.side===rr;ge&&(_e=!_e),Ve(_e),K.blending===Jo&&K.transparent===!1?Le(Oi):Le(K.blending,K.blendEquation,K.blendSrc,K.blendDst,K.blendEquationAlpha,K.blendSrcAlpha,K.blendDstAlpha,K.premultipliedAlpha),l.setFunc(K.depthFunc),l.setTest(K.depthTest),l.setMask(K.depthWrite),o.setMask(K.colorWrite);let Be=K.stencilWrite;h.setTest(Be),Be&&(h.setMask(K.stencilWriteMask),h.setFunc(K.stencilFunc,K.stencilRef,K.stencilFuncMask),h.setOp(K.stencilFail,K.stencilZFail,K.stencilZPass)),Ee(K.polygonOffset,K.polygonOffsetFactor,K.polygonOffsetUnits),K.alphaToCoverage===!0?he(32926):re(32926)}function Ve(K){C!==K&&(K?e.frontFace(2304):e.frontFace(2305),C=K)}function Ue(K){K!==LO?(he(2884),K!==T&&(K===Ax?e.cullFace(1029):K===zO?e.cullFace(1028):e.cullFace(1032))):re(2884),T=K}function Ce(K){K!==D&&(W&&e.lineWidth(K),D=K)}function Ee(K,ge,_e){K?(he(32823),(O!==ge||P!==_e)&&(e.polygonOffset(ge,_e),O=ge,P=_e)):re(32823)}function Ye(K){K?he(3089):re(3089)}function qe(K){K===void 0&&(K=33984+U-1),Z!==K&&(e.activeTexture(K),Z=K)}function V(K,ge,_e){_e===void 0&&(Z===null?_e=33984+U-1:_e=Z);let Be=X[_e];Be===void 0&&(Be={type:void 0,texture:void 0},X[_e]=Be),(Be.type!==K||Be.texture!==ge)&&(Z!==_e&&(e.activeTexture(_e),Z=_e),e.bindTexture(K,ge||H[K]),Be.type=K,Be.texture=ge)}function z(){let K=X[Z];K!==void 0&&K.type!==void 0&&(e.bindTexture(K.type,null),K.type=void 0,K.texture=void 0)}function oe(){try{e.compressedTexImage2D.apply(e,arguments)}catch(K){console.error("THREE.WebGLState:",K)}}function Se(){try{e.compressedTexImage3D.apply(e,arguments)}catch(K){console.error("THREE.WebGLState:",K)}}function R(){try{e.texSubImage2D.apply(e,arguments)}catch(K){console.error("THREE.WebGLState:",K)}}function Te(){try{e.texSubImage3D.apply(e,arguments)}catch(K){console.error("THREE.WebGLState:",K)}}function ke(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(K){console.error("THREE.WebGLState:",K)}}function Oe(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(K){console.error("THREE.WebGLState:",K)}}function ue(){try{e.texStorage2D.apply(e,arguments)}catch(K){console.error("THREE.WebGLState:",K)}}function je(){try{e.texStorage3D.apply(e,arguments)}catch(K){console.error("THREE.WebGLState:",K)}}function ze(){try{e.texImage2D.apply(e,arguments)}catch(K){console.error("THREE.WebGLState:",K)}}function Xe(){try{e.texImage3D.apply(e,arguments)}catch(K){console.error("THREE.WebGLState:",K)}}function it(K){$.equals(K)===!1&&(e.scissor(K.x,K.y,K.z,K.w),$.copy(K))}function Qe(K){Q.equals(K)===!1&&(e.viewport(K.x,K.y,K.z,K.w),Q.copy(K))}function Ke(K,ge){let _e=d.get(ge);_e===void 0&&(_e=new WeakMap,d.set(ge,_e));let Be=_e.get(K);Be===void 0&&(Be=e.getUniformBlockIndex(ge,K.name),_e.set(K,Be))}function qt(K,ge){let _e=d.get(ge).get(K);c.get(ge)!==_e&&(e.uniformBlockBinding(ge,_e,K.__bindingPointIndex),c.set(ge,_e))}function oi(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),r===!0&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),u={},Z=null,X={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,x=null,w=null,_=null,b=null,A=null,S=null,E=!1,C=null,T=null,D=null,O=null,P=null,$.set(0,0,e.canvas.width,e.canvas.height),Q.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:he,disable:re,bindFramebuffer:te,drawBuffers:ae,useProgram:de,setBlending:Le,setMaterial:Me,setFlipSided:Ve,setCullFace:Ue,setLineWidth:Ce,setPolygonOffset:Ee,setScissorTest:Ye,activeTexture:qe,bindTexture:V,unbindTexture:z,compressedTexImage2D:oe,compressedTexImage3D:Se,texImage2D:ze,texImage3D:Xe,updateUBOMapping:Ke,uniformBlockBinding:qt,texStorage2D:ue,texStorage3D:je,texSubImage2D:R,texSubImage3D:Te,compressedTexSubImage2D:ke,compressedTexSubImage3D:Oe,scissor:it,viewport:Qe,reset:oi}}function PF(e,t,i,r,s,a,n){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,c=s.maxTextureSize,d=s.maxSamples,u=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,g,m=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(V,z){return v?new OffscreenCanvas(V,z):dd("canvas")}function x(V,z,oe,Se){let R=1;if((V.width>Se||V.height>Se)&&(R=Se/Math.max(V.width,V.height)),R<1||z===!0)if(typeof HTMLImageElement<"u"&&V instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&V instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&V instanceof ImageBitmap){let Te=z?Gp:Math.floor,ke=Te(R*V.width),Oe=Te(R*V.height);g===void 0&&(g=y(ke,Oe));let ue=oe?y(ke,Oe):g;return ue.width=ke,ue.height=Oe,ue.getContext("2d").drawImage(V,0,0,ke,Oe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+V.width+"x"+V.height+") to ("+ke+"x"+Oe+")."),ue}else return"data"in V&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+V.width+"x"+V.height+")."),V;return V}function w(V){return Bv(V.width)&&Bv(V.height)}function _(V){return o?!1:V.wrapS!==ai||V.wrapT!==ai||V.minFilter!==_t&&V.minFilter!==xt}function b(V,z){return V.generateMipmaps&&z&&V.minFilter!==_t&&V.minFilter!==xt}function A(V){e.generateMipmap(V)}function S(V,z,oe,Se,R=!1){if(o===!1)return z;if(V!==null){if(e[V]!==void 0)return e[V];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+V+"'")}let Te=z;return z===6403&&(oe===5126&&(Te=33326),oe===5131&&(Te=33325),oe===5121&&(Te=33321)),z===33319&&(oe===5126&&(Te=33328),oe===5131&&(Te=33327),oe===5121&&(Te=33323)),z===6408&&(oe===5126&&(Te=34836),oe===5131&&(Te=34842),oe===5121&&(Te=Se===gt&&R===!1?35907:32856),oe===32819&&(Te=32854),oe===32820&&(Te=32855)),(Te===33325||Te===33326||Te===33327||Te===33328||Te===34842||Te===34836)&&t.get("EXT_color_buffer_float"),Te}function E(V,z,oe){return b(V,oe)===!0||V.isFramebufferTexture&&V.minFilter!==_t&&V.minFilter!==xt?Math.log2(Math.max(z.width,z.height))+1:V.mipmaps!==void 0&&V.mipmaps.length>0?V.mipmaps.length:V.isCompressedTexture&&Array.isArray(V.image)?z.mipmaps.length:1}function C(V){return V===_t||V===Dx||V===Am?9728:9729}function T(V){let z=V.target;z.removeEventListener("dispose",T),O(z),z.isVideoTexture&&f.delete(z)}function D(V){let z=V.target;z.removeEventListener("dispose",D),U(z)}function O(V){let z=r.get(V);if(z.__webglInit===void 0)return;let oe=V.source,Se=m.get(oe);if(Se){let R=Se[z.__cacheKey];R.usedTimes--,R.usedTimes===0&&P(V),Object.keys(Se).length===0&&m.delete(oe)}r.remove(V)}function P(V){let z=r.get(V);e.deleteTexture(z.__webglTexture);let oe=V.source,Se=m.get(oe);delete Se[z.__cacheKey],n.memory.textures--}function U(V){let z=V.texture,oe=r.get(V),Se=r.get(z);if(Se.__webglTexture!==void 0&&(e.deleteTexture(Se.__webglTexture),n.memory.textures--),V.depthTexture&&V.depthTexture.dispose(),V.isWebGLCubeRenderTarget)for(let R=0;R<6;R++)e.deleteFramebuffer(oe.__webglFramebuffer[R]),oe.__webglDepthbuffer&&e.deleteRenderbuffer(oe.__webglDepthbuffer[R]);else{if(e.deleteFramebuffer(oe.__webglFramebuffer),oe.__webglDepthbuffer&&e.deleteRenderbuffer(oe.__webglDepthbuffer),oe.__webglMultisampledFramebuffer&&e.deleteFramebuffer(oe.__webglMultisampledFramebuffer),oe.__webglColorRenderbuffer)for(let R=0;R<oe.__webglColorRenderbuffer.length;R++)oe.__webglColorRenderbuffer[R]&&e.deleteRenderbuffer(oe.__webglColorRenderbuffer[R]);oe.__webglDepthRenderbuffer&&e.deleteRenderbuffer(oe.__webglDepthRenderbuffer)}if(V.isWebGLMultipleRenderTargets)for(let R=0,Te=z.length;R<Te;R++){let ke=r.get(z[R]);ke.__webglTexture&&(e.deleteTexture(ke.__webglTexture),n.memory.textures--),r.remove(z[R])}r.remove(z),r.remove(V)}let W=0;function k(){W=0}function F(){let V=W;return V>=l&&console.warn("THREE.WebGLTextures: Trying to use "+V+" texture units while this GPU supports only "+l),W+=1,V}function Z(V){let z=[];return z.push(V.wrapS),z.push(V.wrapT),z.push(V.wrapR||0),z.push(V.magFilter),z.push(V.minFilter),z.push(V.anisotropy),z.push(V.internalFormat),z.push(V.format),z.push(V.type),z.push(V.generateMipmaps),z.push(V.premultiplyAlpha),z.push(V.flipY),z.push(V.unpackAlignment),z.push(V.encoding),z.join()}function X(V,z){let oe=r.get(V);if(V.isVideoTexture&&Ye(V),V.isRenderTargetTexture===!1&&V.version>0&&oe.__version!==V.version){let Se=V.image;if(Se===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Se.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{re(oe,V,z);return}}i.bindTexture(3553,oe.__webglTexture,33984+z)}function G(V,z){let oe=r.get(V);if(V.version>0&&oe.__version!==V.version){re(oe,V,z);return}i.bindTexture(35866,oe.__webglTexture,33984+z)}function q(V,z){let oe=r.get(V);if(V.version>0&&oe.__version!==V.version){re(oe,V,z);return}i.bindTexture(32879,oe.__webglTexture,33984+z)}function $(V,z){let oe=r.get(V);if(V.version>0&&oe.__version!==V.version){te(oe,V,z);return}i.bindTexture(34067,oe.__webglTexture,33984+z)}let Q={[nn]:10497,[ai]:33071,[Ov]:33648},ee={[_t]:9728,[Dx]:9984,[Am]:9986,[xt]:9729,[hR]:9985,[Ch]:9987};function H(V,z,oe){if(oe?(e.texParameteri(V,10242,Q[z.wrapS]),e.texParameteri(V,10243,Q[z.wrapT]),(V===32879||V===35866)&&e.texParameteri(V,32882,Q[z.wrapR]),e.texParameteri(V,10240,ee[z.magFilter]),e.texParameteri(V,10241,ee[z.minFilter])):(e.texParameteri(V,10242,33071),e.texParameteri(V,10243,33071),(V===32879||V===35866)&&e.texParameteri(V,32882,33071),(z.wrapS!==ai||z.wrapT!==ai)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(V,10240,C(z.magFilter)),e.texParameteri(V,10241,C(z.minFilter)),z.minFilter!==_t&&z.minFilter!==xt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let Se=t.get("EXT_texture_filter_anisotropic");if(z.magFilter===_t||z.minFilter!==Am&&z.minFilter!==Ch||z.type===jt&&t.has("OES_texture_float_linear")===!1||o===!1&&z.type===mn&&t.has("OES_texture_half_float_linear")===!1)return;(z.anisotropy>1||r.get(z).__currentAnisotropy)&&(e.texParameterf(V,Se.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(z.anisotropy,s.getMaxAnisotropy())),r.get(z).__currentAnisotropy=z.anisotropy)}}function he(V,z){let oe=!1;V.__webglInit===void 0&&(V.__webglInit=!0,z.addEventListener("dispose",T));let Se=z.source,R=m.get(Se);R===void 0&&(R={},m.set(Se,R));let Te=Z(z);if(Te!==V.__cacheKey){R[Te]===void 0&&(R[Te]={texture:e.createTexture(),usedTimes:0},n.memory.textures++,oe=!0),R[Te].usedTimes++;let ke=R[V.__cacheKey];ke!==void 0&&(R[V.__cacheKey].usedTimes--,ke.usedTimes===0&&P(z)),V.__cacheKey=Te,V.__webglTexture=R[Te].texture}return oe}function re(V,z,oe){let Se=3553;(z.isDataArrayTexture||z.isCompressedArrayTexture)&&(Se=35866),z.isData3DTexture&&(Se=32879);let R=he(V,z),Te=z.source;i.bindTexture(Se,V.__webglTexture,33984+oe);let ke=r.get(Te);if(Te.version!==ke.__version||R===!0){i.activeTexture(33984+oe),e.pixelStorei(37440,z.flipY),e.pixelStorei(37441,z.premultiplyAlpha),e.pixelStorei(3317,z.unpackAlignment),e.pixelStorei(37443,0);let Oe=_(z)&&w(z.image)===!1,ue=x(z.image,Oe,!1,c);ue=qe(z,ue);let je=w(ue)||o,ze=a.convert(z.format,z.encoding),Xe=a.convert(z.type),it=S(z.internalFormat,ze,Xe,z.encoding,z.isVideoTexture);H(Se,z,je);let Qe,Ke=z.mipmaps,qt=o&&z.isVideoTexture!==!0,oi=ke.__version===void 0||R===!0,K=E(z,ue,je);if(z.isDepthTexture)it=6402,o?z.type===jt?it=36012:z.type===on?it=33190:z.type===$o?it=35056:it=33189:z.type===jt&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),z.format===el&&it===6402&&z.type!==eM&&z.type!==on&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),z.type=on,Xe=a.convert(z.type)),z.format===ol&&it===6402&&(it=34041,z.type!==$o&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),z.type=$o,Xe=a.convert(z.type))),oi&&(qt?i.texStorage2D(3553,1,it,ue.width,ue.height):i.texImage2D(3553,0,it,ue.width,ue.height,0,ze,Xe,null));else if(z.isDataTexture)if(Ke.length>0&&je){qt&&oi&&i.texStorage2D(3553,K,it,Ke[0].width,Ke[0].height);for(let ge=0,_e=Ke.length;ge<_e;ge++)Qe=Ke[ge],qt?i.texSubImage2D(3553,ge,0,0,Qe.width,Qe.height,ze,Xe,Qe.data):i.texImage2D(3553,ge,it,Qe.width,Qe.height,0,ze,Xe,Qe.data);z.generateMipmaps=!1}else qt?(oi&&i.texStorage2D(3553,K,it,ue.width,ue.height),i.texSubImage2D(3553,0,0,0,ue.width,ue.height,ze,Xe,ue.data)):i.texImage2D(3553,0,it,ue.width,ue.height,0,ze,Xe,ue.data);else if(z.isCompressedTexture)if(z.isCompressedArrayTexture){qt&&oi&&i.texStorage3D(35866,K,it,Ke[0].width,Ke[0].height,ue.depth);for(let ge=0,_e=Ke.length;ge<_e;ge++)Qe=Ke[ge],z.format!==ni?ze!==null?qt?i.compressedTexSubImage3D(35866,ge,0,0,0,Qe.width,Qe.height,ue.depth,ze,Qe.data,0,0):i.compressedTexImage3D(35866,ge,it,Qe.width,Qe.height,ue.depth,0,Qe.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):qt?i.texSubImage3D(35866,ge,0,0,0,Qe.width,Qe.height,ue.depth,ze,Xe,Qe.data):i.texImage3D(35866,ge,it,Qe.width,Qe.height,ue.depth,0,ze,Xe,Qe.data)}else{qt&&oi&&i.texStorage2D(3553,K,it,Ke[0].width,Ke[0].height);for(let ge=0,_e=Ke.length;ge<_e;ge++)Qe=Ke[ge],z.format!==ni?ze!==null?qt?i.compressedTexSubImage2D(3553,ge,0,0,Qe.width,Qe.height,ze,Qe.data):i.compressedTexImage2D(3553,ge,it,Qe.width,Qe.height,0,Qe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):qt?i.texSubImage2D(3553,ge,0,0,Qe.width,Qe.height,ze,Xe,Qe.data):i.texImage2D(3553,ge,it,Qe.width,Qe.height,0,ze,Xe,Qe.data)}else if(z.isDataArrayTexture)qt?(oi&&i.texStorage3D(35866,K,it,ue.width,ue.height,ue.depth),i.texSubImage3D(35866,0,0,0,0,ue.width,ue.height,ue.depth,ze,Xe,ue.data)):i.texImage3D(35866,0,it,ue.width,ue.height,ue.depth,0,ze,Xe,ue.data);else if(z.isData3DTexture)qt?(oi&&i.texStorage3D(32879,K,it,ue.width,ue.height,ue.depth),i.texSubImage3D(32879,0,0,0,0,ue.width,ue.height,ue.depth,ze,Xe,ue.data)):i.texImage3D(32879,0,it,ue.width,ue.height,ue.depth,0,ze,Xe,ue.data);else if(z.isFramebufferTexture){if(oi)if(qt)i.texStorage2D(3553,K,it,ue.width,ue.height);else{let ge=ue.width,_e=ue.height;for(let Be=0;Be<K;Be++)i.texImage2D(3553,Be,it,ge,_e,0,ze,Xe,null),ge>>=1,_e>>=1}}else if(Ke.length>0&&je){qt&&oi&&i.texStorage2D(3553,K,it,Ke[0].width,Ke[0].height);for(let ge=0,_e=Ke.length;ge<_e;ge++)Qe=Ke[ge],qt?i.texSubImage2D(3553,ge,0,0,ze,Xe,Qe):i.texImage2D(3553,ge,it,ze,Xe,Qe);z.generateMipmaps=!1}else qt?(oi&&i.texStorage2D(3553,K,it,ue.width,ue.height),i.texSubImage2D(3553,0,0,0,ze,Xe,ue)):i.texImage2D(3553,0,it,ze,Xe,ue);b(z,je)&&A(Se),ke.__version=Te.version,z.onUpdate&&z.onUpdate(z)}V.__version=z.version}function te(V,z,oe){if(z.image.length!==6)return;let Se=he(V,z),R=z.source;i.bindTexture(34067,V.__webglTexture,33984+oe);let Te=r.get(R);if(R.version!==Te.__version||Se===!0){i.activeTexture(33984+oe),e.pixelStorei(37440,z.flipY),e.pixelStorei(37441,z.premultiplyAlpha),e.pixelStorei(3317,z.unpackAlignment),e.pixelStorei(37443,0);let ke=z.isCompressedTexture||z.image[0].isCompressedTexture,Oe=z.image[0]&&z.image[0].isDataTexture,ue=[];for(let ge=0;ge<6;ge++)!ke&&!Oe?ue[ge]=x(z.image[ge],!1,!0,h):ue[ge]=Oe?z.image[ge].image:z.image[ge],ue[ge]=qe(z,ue[ge]);let je=ue[0],ze=w(je)||o,Xe=a.convert(z.format,z.encoding),it=a.convert(z.type),Qe=S(z.internalFormat,Xe,it,z.encoding),Ke=o&&z.isVideoTexture!==!0,qt=Te.__version===void 0||Se===!0,oi=E(z,je,ze);H(34067,z,ze);let K;if(ke){Ke&&qt&&i.texStorage2D(34067,oi,Qe,je.width,je.height);for(let ge=0;ge<6;ge++){K=ue[ge].mipmaps;for(let _e=0;_e<K.length;_e++){let Be=K[_e];z.format!==ni?Xe!==null?Ke?i.compressedTexSubImage2D(34069+ge,_e,0,0,Be.width,Be.height,Xe,Be.data):i.compressedTexImage2D(34069+ge,_e,Qe,Be.width,Be.height,0,Be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ke?i.texSubImage2D(34069+ge,_e,0,0,Be.width,Be.height,Xe,it,Be.data):i.texImage2D(34069+ge,_e,Qe,Be.width,Be.height,0,Xe,it,Be.data)}}}else{K=z.mipmaps,Ke&&qt&&(K.length>0&&oi++,i.texStorage2D(34067,oi,Qe,ue[0].width,ue[0].height));for(let ge=0;ge<6;ge++)if(Oe){Ke?i.texSubImage2D(34069+ge,0,0,0,ue[ge].width,ue[ge].height,Xe,it,ue[ge].data):i.texImage2D(34069+ge,0,Qe,ue[ge].width,ue[ge].height,0,Xe,it,ue[ge].data);for(let _e=0;_e<K.length;_e++){let Be=K[_e].image[ge].image;Ke?i.texSubImage2D(34069+ge,_e+1,0,0,Be.width,Be.height,Xe,it,Be.data):i.texImage2D(34069+ge,_e+1,Qe,Be.width,Be.height,0,Xe,it,Be.data)}}else{Ke?i.texSubImage2D(34069+ge,0,0,0,Xe,it,ue[ge]):i.texImage2D(34069+ge,0,Qe,Xe,it,ue[ge]);for(let _e=0;_e<K.length;_e++){let Be=K[_e];Ke?i.texSubImage2D(34069+ge,_e+1,0,0,Xe,it,Be.image[ge]):i.texImage2D(34069+ge,_e+1,Qe,Xe,it,Be.image[ge])}}}b(z,ze)&&A(34067),Te.__version=R.version,z.onUpdate&&z.onUpdate(z)}V.__version=z.version}function ae(V,z,oe,Se,R){let Te=a.convert(oe.format,oe.encoding),ke=a.convert(oe.type),Oe=S(oe.internalFormat,Te,ke,oe.encoding);r.get(z).__hasExternalTextures||(R===32879||R===35866?i.texImage3D(R,0,Oe,z.width,z.height,z.depth,0,Te,ke,null):i.texImage2D(R,0,Oe,z.width,z.height,0,Te,ke,null)),i.bindFramebuffer(36160,V),Ee(z)?u.framebufferTexture2DMultisampleEXT(36160,Se,R,r.get(oe).__webglTexture,0,Ce(z)):(R===3553||R>=34069&&R<=34074)&&e.framebufferTexture2D(36160,Se,R,r.get(oe).__webglTexture,0),i.bindFramebuffer(36160,null)}function de(V,z,oe){if(e.bindRenderbuffer(36161,V),z.depthBuffer&&!z.stencilBuffer){let Se=33189;if(oe||Ee(z)){let R=z.depthTexture;R&&R.isDepthTexture&&(R.type===jt?Se=36012:R.type===on&&(Se=33190));let Te=Ce(z);Ee(z)?u.renderbufferStorageMultisampleEXT(36161,Te,Se,z.width,z.height):e.renderbufferStorageMultisample(36161,Te,Se,z.width,z.height)}else e.renderbufferStorage(36161,Se,z.width,z.height);e.framebufferRenderbuffer(36160,36096,36161,V)}else if(z.depthBuffer&&z.stencilBuffer){let Se=Ce(z);oe&&Ee(z)===!1?e.renderbufferStorageMultisample(36161,Se,35056,z.width,z.height):Ee(z)?u.renderbufferStorageMultisampleEXT(36161,Se,35056,z.width,z.height):e.renderbufferStorage(36161,34041,z.width,z.height),e.framebufferRenderbuffer(36160,33306,36161,V)}else{let Se=z.isWebGLMultipleRenderTargets===!0?z.texture:[z.texture];for(let R=0;R<Se.length;R++){let Te=Se[R],ke=a.convert(Te.format,Te.encoding),Oe=a.convert(Te.type),ue=S(Te.internalFormat,ke,Oe,Te.encoding),je=Ce(z);oe&&Ee(z)===!1?e.renderbufferStorageMultisample(36161,je,ue,z.width,z.height):Ee(z)?u.renderbufferStorageMultisampleEXT(36161,je,ue,z.width,z.height):e.renderbufferStorage(36161,ue,z.width,z.height)}}e.bindRenderbuffer(36161,null)}function pe(V,z){if(z&&z.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,V),!(z.depthTexture&&z.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(z.depthTexture).__webglTexture||z.depthTexture.image.width!==z.width||z.depthTexture.image.height!==z.height)&&(z.depthTexture.image.width=z.width,z.depthTexture.image.height=z.height,z.depthTexture.needsUpdate=!0),X(z.depthTexture,0);let oe=r.get(z.depthTexture).__webglTexture,Se=Ce(z);if(z.depthTexture.format===el)Ee(z)?u.framebufferTexture2DMultisampleEXT(36160,36096,3553,oe,0,Se):e.framebufferTexture2D(36160,36096,3553,oe,0);else if(z.depthTexture.format===ol)Ee(z)?u.framebufferTexture2DMultisampleEXT(36160,33306,3553,oe,0,Se):e.framebufferTexture2D(36160,33306,3553,oe,0);else throw new Error("Unknown depthTexture format")}function be(V){let z=r.get(V),oe=V.isWebGLCubeRenderTarget===!0;if(V.depthTexture&&!z.__autoAllocateDepthBuffer){if(oe)throw new Error("target.depthTexture not supported in Cube render targets");pe(z.__webglFramebuffer,V)}else if(oe){z.__webglDepthbuffer=[];for(let Se=0;Se<6;Se++)i.bindFramebuffer(36160,z.__webglFramebuffer[Se]),z.__webglDepthbuffer[Se]=e.createRenderbuffer(),de(z.__webglDepthbuffer[Se],V,!1)}else i.bindFramebuffer(36160,z.__webglFramebuffer),z.__webglDepthbuffer=e.createRenderbuffer(),de(z.__webglDepthbuffer,V,!1);i.bindFramebuffer(36160,null)}function Le(V,z,oe){let Se=r.get(V);z!==void 0&&ae(Se.__webglFramebuffer,V,V.texture,36064,3553),oe!==void 0&&be(V)}function Me(V){let z=V.texture,oe=r.get(V),Se=r.get(z);V.addEventListener("dispose",D),V.isWebGLMultipleRenderTargets!==!0&&(Se.__webglTexture===void 0&&(Se.__webglTexture=e.createTexture()),Se.__version=z.version,n.memory.textures++);let R=V.isWebGLCubeRenderTarget===!0,Te=V.isWebGLMultipleRenderTargets===!0,ke=w(V)||o;if(R){oe.__webglFramebuffer=[];for(let Oe=0;Oe<6;Oe++)oe.__webglFramebuffer[Oe]=e.createFramebuffer()}else{if(oe.__webglFramebuffer=e.createFramebuffer(),Te)if(s.drawBuffers){let Oe=V.texture;for(let ue=0,je=Oe.length;ue<je;ue++){let ze=r.get(Oe[ue]);ze.__webglTexture===void 0&&(ze.__webglTexture=e.createTexture(),n.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&V.samples>0&&Ee(V)===!1){let Oe=Te?z:[z];oe.__webglMultisampledFramebuffer=e.createFramebuffer(),oe.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,oe.__webglMultisampledFramebuffer);for(let ue=0;ue<Oe.length;ue++){let je=Oe[ue];oe.__webglColorRenderbuffer[ue]=e.createRenderbuffer(),e.bindRenderbuffer(36161,oe.__webglColorRenderbuffer[ue]);let ze=a.convert(je.format,je.encoding),Xe=a.convert(je.type),it=S(je.internalFormat,ze,Xe,je.encoding,V.isXRRenderTarget===!0),Qe=Ce(V);e.renderbufferStorageMultisample(36161,Qe,it,V.width,V.height),e.framebufferRenderbuffer(36160,36064+ue,36161,oe.__webglColorRenderbuffer[ue])}e.bindRenderbuffer(36161,null),V.depthBuffer&&(oe.__webglDepthRenderbuffer=e.createRenderbuffer(),de(oe.__webglDepthRenderbuffer,V,!0)),i.bindFramebuffer(36160,null)}}if(R){i.bindTexture(34067,Se.__webglTexture),H(34067,z,ke);for(let Oe=0;Oe<6;Oe++)ae(oe.__webglFramebuffer[Oe],V,z,36064,34069+Oe);b(z,ke)&&A(34067),i.unbindTexture()}else if(Te){let Oe=V.texture;for(let ue=0,je=Oe.length;ue<je;ue++){let ze=Oe[ue],Xe=r.get(ze);i.bindTexture(3553,Xe.__webglTexture),H(3553,ze,ke),ae(oe.__webglFramebuffer,V,ze,36064+ue,3553),b(ze,ke)&&A(3553)}i.unbindTexture()}else{let Oe=3553;(V.isWebGL3DRenderTarget||V.isWebGLArrayRenderTarget)&&(o?Oe=V.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Oe,Se.__webglTexture),H(Oe,z,ke),ae(oe.__webglFramebuffer,V,z,36064,Oe),b(z,ke)&&A(Oe),i.unbindTexture()}V.depthBuffer&&be(V)}function Ve(V){let z=w(V)||o,oe=V.isWebGLMultipleRenderTargets===!0?V.texture:[V.texture];for(let Se=0,R=oe.length;Se<R;Se++){let Te=oe[Se];if(b(Te,z)){let ke=V.isWebGLCubeRenderTarget?34067:3553,Oe=r.get(Te).__webglTexture;i.bindTexture(ke,Oe),A(ke),i.unbindTexture()}}}function Ue(V){if(o&&V.samples>0&&Ee(V)===!1){let z=V.isWebGLMultipleRenderTargets?V.texture:[V.texture],oe=V.width,Se=V.height,R=16384,Te=[],ke=V.stencilBuffer?33306:36096,Oe=r.get(V),ue=V.isWebGLMultipleRenderTargets===!0;if(ue)for(let je=0;je<z.length;je++)i.bindFramebuffer(36160,Oe.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+je,36161,null),i.bindFramebuffer(36160,Oe.__webglFramebuffer),e.framebufferTexture2D(36009,36064+je,3553,null,0);i.bindFramebuffer(36008,Oe.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Oe.__webglFramebuffer);for(let je=0;je<z.length;je++){Te.push(36064+je),V.depthBuffer&&Te.push(ke);let ze=Oe.__ignoreDepthValues!==void 0?Oe.__ignoreDepthValues:!1;if(ze===!1&&(V.depthBuffer&&(R|=256),V.stencilBuffer&&(R|=1024)),ue&&e.framebufferRenderbuffer(36008,36064,36161,Oe.__webglColorRenderbuffer[je]),ze===!0&&(e.invalidateFramebuffer(36008,[ke]),e.invalidateFramebuffer(36009,[ke])),ue){let Xe=r.get(z[je]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Xe,0)}e.blitFramebuffer(0,0,oe,Se,0,0,oe,Se,R,9728),p&&e.invalidateFramebuffer(36008,Te)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ue)for(let je=0;je<z.length;je++){i.bindFramebuffer(36160,Oe.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+je,36161,Oe.__webglColorRenderbuffer[je]);let ze=r.get(z[je]).__webglTexture;i.bindFramebuffer(36160,Oe.__webglFramebuffer),e.framebufferTexture2D(36009,36064+je,3553,ze,0)}i.bindFramebuffer(36009,Oe.__webglMultisampledFramebuffer)}}function Ce(V){return Math.min(d,V.samples)}function Ee(V){let z=r.get(V);return o&&V.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&z.__useRenderToTexture!==!1}function Ye(V){let z=n.render.frame;f.get(V)!==z&&(f.set(V,z),V.update())}function qe(V,z){let oe=V.encoding,Se=V.format,R=V.type;return V.isCompressedTexture===!0||V.isVideoTexture===!0||V.format===zv||oe!==qs&&(oe===gt?o===!1?t.has("EXT_sRGB")===!0&&Se===ni?(V.format=zv,V.minFilter=xt,V.generateMipmaps=!1):z=lM.sRGBToLinear(z):(Se!==ni||R!==Er)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",oe)),z}this.allocateTextureUnit=F,this.resetTextureUnits=k,this.setTexture2D=X,this.setTexture2DArray=G,this.setTexture3D=q,this.setTextureCube=$,this.rebindTextures=Le,this.setupRenderTarget=Me,this.updateRenderTargetMipmap=Ve,this.updateMultisampleRenderTarget=Ue,this.setupDepthRenderbuffer=be,this.setupFrameBufferTexture=ae,this.useMultisampledRTT=Ee}function DF(e,t,i){let r=i.isWebGL2;function s(a,n=null){let o;if(a===Er)return 5121;if(a===pR)return 32819;if(a===fR)return 32820;if(a===cR)return 5120;if(a===dR)return 5122;if(a===eM)return 5123;if(a===uR)return 5124;if(a===on)return 5125;if(a===jt)return 5126;if(a===mn)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===mR)return 6406;if(a===ni)return 6408;if(a===gR)return 6409;if(a===vR)return 6410;if(a===el)return 6402;if(a===ol)return 34041;if(a===zv)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===wp)return 6403;if(a===yR)return 36244;if(a===Up)return 33319;if(a===xR)return 33320;if(a===tM)return 36249;if(a===Mm||a===Em||a===Cm||a===Tm)if(n===gt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===Mm)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===Em)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===Cm)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===Tm)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===Mm)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===Em)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===Cm)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===Tm)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===Ix||a===Ox||a===Rx||a===Lx)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===Ix)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===Ox)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===Rx)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===Lx)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===bR)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===zx||a===Bx)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(a===zx)return n===gt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===Bx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===Fx||a===Ux||a===Nx||a===kx||a===Vx||a===jx||a===Gx||a===Hx||a===Wx||a===qx||a===Xx||a===Yx||a===Qx||a===Zx)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(a===Fx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===Ux)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===Nx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===kx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===Vx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===jx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===Gx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===Hx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===Wx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===qx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===Xx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===Yx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===Qx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===Zx)return n===gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===Pm)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(a===Pm)return n===gt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(a===wR||a===Kx||a===Jx||a===$x)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(a===Pm)return o.COMPRESSED_RED_RGTC1_EXT;if(a===Kx)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===Jx)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===$x)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===$o?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[a]!==void 0?e[a]:null}return{convert:s}}var IF=class extends _r{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},hn=class extends kt{constructor(){super(),this.isGroup=!0,this.type="Group"}},OF={type:"move"},tg=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new hn,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 hn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new M,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new M),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new hn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new M,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new M),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,a=null,n=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(let f of e.hand.values()){let g=t.getJointPose(f,i),m=this._getHandJoint(l,f);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=g.radius),m.visible=g!==null}let h=l.joints["index-finger-tip"],c=l.joints["thumb-tip"],d=h.position.distanceTo(c.position),u=.02,p=.005;l.inputState.pinching&&d>u+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=u-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));n!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(n.matrix.fromArray(r.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),r.linearVelocity?(n.hasLinearVelocity=!0,n.linearVelocity.copy(r.linearVelocity)):n.hasLinearVelocity=!1,r.angularVelocity?(n.hasAngularVelocity=!0,n.angularVelocity.copy(r.angularVelocity)):n.hasAngularVelocity=!1,this.dispatchEvent(OF)))}return n!==null&&(n.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new hn;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Ph=class extends ci{constructor(e,t,i,r,s,a,n,o,l,h){if(h=h!==void 0?h:el,h!==el&&h!==ol)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===el&&(i=on),i===void 0&&h===ol&&(i=$o),super(null,r,s,a,n,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=n!==void 0?n:_t,this.minFilter=o!==void 0?o:_t,this.flipY=!1,this.generateMipmaps=!1}},RF=class extends yr{constructor(e,t){super();let i=this,r=null,s=1,a=null,n="local-floor",o=1,l=null,h=null,c=null,d=null,u=null,p=null,f=t.getContextAttributes(),g=null,m=null,v=[],y=[],x=new Set,w=new Map,_=new _r;_.layers.enable(1),_.viewport=new ct;let b=new _r;b.layers.enable(2),b.viewport=new ct;let A=[_,b],S=new IF;S.layers.enable(1),S.layers.enable(2);let E=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let q=v[G];return q===void 0&&(q=new tg,v[G]=q),q.getTargetRaySpace()},this.getControllerGrip=function(G){let q=v[G];return q===void 0&&(q=new tg,v[G]=q),q.getGripSpace()},this.getHand=function(G){let q=v[G];return q===void 0&&(q=new tg,v[G]=q),q.getHandSpace()};function T(G){let q=y.indexOf(G.inputSource);if(q===-1)return;let $=v[q];$!==void 0&&$.dispatchEvent({type:G.type,data:G.inputSource})}function D(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",D),r.removeEventListener("inputsourceschange",O);for(let G=0;G<v.length;G++){let q=y[G];q!==null&&(y[G]=null,v[G].disconnect(q))}E=null,C=null,e.setRenderTarget(g),u=null,d=null,c=null,r=null,m=null,X.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(G){s=G,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(G){n=G,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(G){l=G},this.getBaseLayer=function(){return d!==null?d:u},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(G){if(r=G,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",T),r.addEventListener("selectstart",T),r.addEventListener("selectend",T),r.addEventListener("squeeze",T),r.addEventListener("squeezestart",T),r.addEventListener("squeezeend",T),r.addEventListener("end",D),r.addEventListener("inputsourceschange",O),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let q={antialias:r.renderState.layers===void 0?f.antialias:!0,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};u=new XRWebGLLayer(r,t,q),r.updateRenderState({baseLayer:u}),m=new Pt(u.framebufferWidth,u.framebufferHeight,{format:ni,type:Er,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let q=null,$=null,Q=null;f.depth&&(Q=f.stencil?35056:33190,q=f.stencil?ol:el,$=f.stencil?$o:on);let ee={colorFormat:32856,depthFormat:Q,scaleFactor:s};c=new XRWebGLBinding(r,t),d=c.createProjectionLayer(ee),r.updateRenderState({layers:[d]}),m=new Pt(d.textureWidth,d.textureHeight,{format:ni,type:Er,depthTexture:new Ph(d.textureWidth,d.textureHeight,$,void 0,void 0,void 0,void 0,void 0,void 0,q),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let H=e.properties.get(m);H.__ignoreDepthValues=d.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await r.requestReferenceSpace(n),X.setContext(r),X.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function O(G){for(let q=0;q<G.removed.length;q++){let $=G.removed[q],Q=y.indexOf($);Q>=0&&(y[Q]=null,v[Q].disconnect($))}for(let q=0;q<G.added.length;q++){let $=G.added[q],Q=y.indexOf($);if(Q===-1){for(let H=0;H<v.length;H++)if(H>=y.length){y.push($),Q=H;break}else if(y[H]===null){y[H]=$,Q=H;break}if(Q===-1)break}let ee=v[Q];ee&&ee.connect($)}}let P=new M,U=new M;function W(G,q,$){P.setFromMatrixPosition(q.matrixWorld),U.setFromMatrixPosition($.matrixWorld);let Q=P.distanceTo(U),ee=q.projectionMatrix.elements,H=$.projectionMatrix.elements,he=ee[14]/(ee[10]-1),re=ee[14]/(ee[10]+1),te=(ee[9]+1)/ee[5],ae=(ee[9]-1)/ee[5],de=(ee[8]-1)/ee[0],pe=(H[8]+1)/H[0],be=he*de,Le=he*pe,Me=Q/(-de+pe),Ve=Me*-de;q.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX(Ve),G.translateZ(Me),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert();let Ue=he+Me,Ce=re+Me,Ee=be-Ve,Ye=Le+(Q-Ve),qe=te*re/Ce*Ue,V=ae*re/Ce*Ue;G.projectionMatrix.makePerspective(Ee,Ye,qe,V,Ue,Ce)}function k(G,q){q===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(q.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(r===null)return;S.near=b.near=_.near=G.near,S.far=b.far=_.far=G.far,(E!==S.near||C!==S.far)&&(r.updateRenderState({depthNear:S.near,depthFar:S.far}),E=S.near,C=S.far);let q=G.parent,$=S.cameras;k(S,q);for(let ee=0;ee<$.length;ee++)k($[ee],q);S.matrixWorld.decompose(S.position,S.quaternion,S.scale),G.matrix.copy(S.matrix),G.matrix.decompose(G.position,G.quaternion,G.scale);let Q=G.children;for(let ee=0,H=Q.length;ee<H;ee++)Q[ee].updateMatrixWorld(!0);$.length===2?W(S,_,b):S.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return S},this.getFoveation=function(){if(!(d===null&&u===null))return o},this.setFoveation=function(G){o=G,d!==null&&(d.fixedFoveation=G),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=G)},this.getPlanes=function(){return x};let F=null;function Z(G,q){if(h=q.getViewerPose(l||a),p=q,h!==null){let $=h.views;u!==null&&(e.setRenderTargetFramebuffer(m,u.framebuffer),e.setRenderTarget(m));let Q=!1;$.length!==S.cameras.length&&(S.cameras.length=0,Q=!0);for(let ee=0;ee<$.length;ee++){let H=$[ee],he=null;if(u!==null)he=u.getViewport(H);else{let te=c.getViewSubImage(d,H);he=te.viewport,ee===0&&(e.setRenderTargetTextures(m,te.colorTexture,d.ignoreDepthValues?void 0:te.depthStencilTexture),e.setRenderTarget(m))}let re=A[ee];re===void 0&&(re=new _r,re.layers.enable(ee),re.viewport=new ct,A[ee]=re),re.matrix.fromArray(H.transform.matrix),re.projectionMatrix.fromArray(H.projectionMatrix),re.viewport.set(he.x,he.y,he.width,he.height),ee===0&&S.matrix.copy(re.matrix),Q===!0&&S.cameras.push(re)}}for(let $=0;$<v.length;$++){let Q=y[$],ee=v[$];Q!==null&&ee!==void 0&&ee.update(Q,q,l||a)}if(F&&F(G,q),q.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:q.detectedPlanes});let $=null;for(let Q of x)q.detectedPlanes.has(Q)||($===null&&($=[]),$.push(Q));if($!==null)for(let Q of $)x.delete(Q),w.delete(Q),i.dispatchEvent({type:"planeremoved",data:Q});for(let Q of q.detectedPlanes)if(!x.has(Q))x.add(Q),w.set(Q,q.lastChangedTime),i.dispatchEvent({type:"planeadded",data:Q});else{let ee=w.get(Q);Q.lastChangedTime>ee&&(w.set(Q,Q.lastChangedTime),i.dispatchEvent({type:"planechanged",data:Q}))}}p=null}let X=new fM;X.setAnimationLoop(Z),this.setAnimationLoop=function(G){F=G},this.dispose=function(){}}};function LF(e,t){function i(g,m){m.color.getRGB(g.fogColor.value,pM(e)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,v,y,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),c(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),d(g,m),m.isMeshPhysicalMaterial&&u(g,m,x)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),f(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(a(g,m),m.isLineDashedMaterial&&n(g,m)):m.isPointsMaterial?o(g,m,v,y):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===rr&&(g.bumpScale.value*=-1)),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===rr&&g.normalScale.value.negate()),m.specularMap&&(g.specularMap.value=m.specularMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v=t.get(m).envMap;if(v&&(g.envMap.value=v,g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let w=e.physicallyCorrectLights!==!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*w}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity);let y;m.map?y=m.map:m.specularMap?y=m.specularMap:m.displacementMap?y=m.displacementMap:m.normalMap?y=m.normalMap:m.bumpMap?y=m.bumpMap:m.roughnessMap?y=m.roughnessMap:m.metalnessMap?y=m.metalnessMap:m.alphaMap?y=m.alphaMap:m.emissiveMap?y=m.emissiveMap:m.clearcoatMap?y=m.clearcoatMap:m.clearcoatNormalMap?y=m.clearcoatNormalMap:m.clearcoatRoughnessMap?y=m.clearcoatRoughnessMap:m.iridescenceMap?y=m.iridescenceMap:m.iridescenceThicknessMap?y=m.iridescenceThicknessMap:m.specularIntensityMap?y=m.specularIntensityMap:m.specularColorMap?y=m.specularColorMap:m.transmissionMap?y=m.transmissionMap:m.thicknessMap?y=m.thicknessMap:m.sheenColorMap?y=m.sheenColorMap:m.sheenRoughnessMap&&(y=m.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),g.uvTransform.value.copy(y.matrix));let x;m.aoMap?x=m.aoMap:m.lightMap&&(x=m.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uv2Transform.value.copy(x.matrix))}function a(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity}function n(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function o(g,m,v,y){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*v,g.scale.value=y*.5,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let x;m.map?x=m.map:m.alphaMap&&(x=m.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uvTransform.value.copy(x.matrix))}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v;m.map?v=m.map:m.alphaMap&&(v=m.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),g.uvTransform.value.copy(v.matrix))}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function c(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function d(g,m){g.roughness.value=m.roughness,g.metalness.value=m.metalness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function u(g,m,v){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),g.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===rr&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap)}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function f(g,m){g.referencePosition.value.copy(m.referencePosition),g.nearDistance.value=m.nearDistance,g.farDistance.value=m.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function zF(e,t,i,r){let s={},a={},n=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let w=x.program;r.uniformBlockBinding(y,w)}function h(y,x){let w=s[y.id];w===void 0&&(f(y),w=c(y),s[y.id]=w,y.addEventListener("dispose",m));let _=x.program;r.updateUBOMapping(y,_);let b=t.render.frame;a[y.id]!==b&&(u(y),a[y.id]=b)}function c(y){let x=d();y.__bindingPointIndex=x;let w=e.createBuffer(),_=y.__size,b=y.usage;return e.bindBuffer(35345,w),e.bufferData(35345,_,b),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,w),w}function d(){for(let y=0;y<o;y++)if(n.indexOf(y)===-1)return n.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(y){let x=s[y.id],w=y.uniforms,_=y.__cache;e.bindBuffer(35345,x);for(let b=0,A=w.length;b<A;b++){let S=w[b];if(p(S,b,_)===!0){let E=S.__offset,C=Array.isArray(S.value)?S.value:[S.value],T=0;for(let D=0;D<C.length;D++){let O=C[D],P=g(O);typeof O=="number"?(S.__data[0]=O,e.bufferSubData(35345,E+T,S.__data)):O.isMatrix3?(S.__data[0]=O.elements[0],S.__data[1]=O.elements[1],S.__data[2]=O.elements[2],S.__data[3]=O.elements[0],S.__data[4]=O.elements[3],S.__data[5]=O.elements[4],S.__data[6]=O.elements[5],S.__data[7]=O.elements[0],S.__data[8]=O.elements[6],S.__data[9]=O.elements[7],S.__data[10]=O.elements[8],S.__data[11]=O.elements[0]):(O.toArray(S.__data,T),T+=P.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,E,S.__data)}}e.bindBuffer(35345,null)}function p(y,x,w){let _=y.value;if(w[x]===void 0){if(typeof _=="number")w[x]=_;else{let b=Array.isArray(_)?_:[_],A=[];for(let S=0;S<b.length;S++)A.push(b[S].clone());w[x]=A}return!0}else if(typeof _=="number"){if(w[x]!==_)return w[x]=_,!0}else{let b=Array.isArray(w[x])?w[x]:[w[x]],A=Array.isArray(_)?_:[_];for(let S=0;S<b.length;S++){let E=b[S];if(E.equals(A[S])===!1)return E.copy(A[S]),!0}}return!1}function f(y){let x=y.uniforms,w=0,_=16,b=0;for(let A=0,S=x.length;A<S;A++){let E=x[A],C={boundary:0,storage:0},T=Array.isArray(E.value)?E.value:[E.value];for(let D=0,O=T.length;D<O;D++){let P=T[D],U=g(P);C.boundary+=U.boundary,C.storage+=U.storage}if(E.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),E.__offset=w,A>0){b=w%_;let D=_-b;b!==0&&D-C.boundary<0&&(w+=_-b,E.__offset=w)}w+=C.storage}return b=w%_,b>0&&(w+=_-b),y.__size=w,y.__cache={},this}function g(y){let x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function m(y){let x=y.target;x.removeEventListener("dispose",m);let w=n.indexOf(x.__bindingPointIndex);n.splice(w,1),e.deleteBuffer(s[x.id]),delete s[x.id],delete a[x.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);n=[],s={},a={}}return{bind:l,update:h,dispose:v}}function BF(){let e=dd("canvas");return e.style.display="block",e}function bM(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:BF(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,a=e.antialias!==void 0?e.antialias:!1,n=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,c;i!==null?c=i.getContextAttributes().alpha:c=e.alpha!==void 0?e.alpha:!1;let d=null,u=null,p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=qs,this.physicallyCorrectLights=!1,this.toneMapping=_a,this.toneMappingExposure=1;let g=this,m=!1,v=0,y=0,x=null,w=-1,_=null,b=new ct,A=new ct,S=null,E=t.width,C=t.height,T=1,D=null,O=null,P=new ct(0,0,E,C),U=new ct(0,0,E,C),W=!1,k=new Hy,F=!1,Z=!1,X=null,G=new we,q=new j,$=new M,Q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ee(){return x===null?T:1}let H=i;function he(N,le){for(let me=0;me<N.length;me++){let se=N[me],ve=t.getContext(se,le);if(ve!==null)return ve}return null}try{let N={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:n,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Gh}`),t.addEventListener("webglcontextlost",it,!1),t.addEventListener("webglcontextrestored",Qe,!1),t.addEventListener("webglcontextcreationerror",Ke,!1),H===null){let le=["webgl2","webgl","experimental-webgl"];if(g.isWebGL1Renderer===!0&&le.shift(),H=he(le,N),H===null)throw he(le)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}H.getShaderPrecisionFormat===void 0&&(H.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let re,te,ae,de,pe,be,Le,Me,Ve,Ue,Ce,Ee,Ye,qe,V,z,oe,Se,R,Te,ke,Oe,ue,je;function ze(){re=new QB(H),te=new GB(H,re,e),re.init(te),Oe=new DF(H,re,te),ae=new TF(H,re,te),de=new JB,pe=new mF,be=new PF(H,re,ae,pe,te,Oe,de),Le=new WB(g),Me=new YB(g),Ve=new oL(H,te),ue=new VB(H,re,Ve,te),Ue=new ZB(H,Ve,de,ue),Ce=new i4(H,Ue,Ve,de),R=new t4(H,te,be),z=new HB(pe),Ee=new fF(g,Le,Me,re,te,ue,z),Ye=new LF(g,pe),qe=new vF,V=new SF(re,te),Se=new kB(g,Le,Me,ae,Ce,c,n),oe=new CF(g,Ce,te),je=new zF(H,de,te,ae),Te=new jB(H,re,de,te),ke=new KB(H,re,de,te),de.programs=Ee.programs,g.capabilities=te,g.extensions=re,g.properties=pe,g.renderLists=qe,g.shadowMap=oe,g.state=ae,g.info=de}ze();let Xe=new RF(g,H);this.xr=Xe,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){let N=re.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){let N=re.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(N){N!==void 0&&(T=N,this.setSize(E,C,!1))},this.getSize=function(N){return N.set(E,C)},this.setSize=function(N,le,me){if(Xe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}E=N,C=le,t.width=Math.floor(N*T),t.height=Math.floor(le*T),me!==!1&&(t.style.width=N+"px",t.style.height=le+"px"),this.setViewport(0,0,N,le)},this.getDrawingBufferSize=function(N){return N.set(E*T,C*T).floor()},this.setDrawingBufferSize=function(N,le,me){E=N,C=le,T=me,t.width=Math.floor(N*me),t.height=Math.floor(le*me),this.setViewport(0,0,N,le)},this.getCurrentViewport=function(N){return N.copy(b)},this.getViewport=function(N){return N.copy(P)},this.setViewport=function(N,le,me,se){N.isVector4?P.set(N.x,N.y,N.z,N.w):P.set(N,le,me,se),ae.viewport(b.copy(P).multiplyScalar(T).floor())},this.getScissor=function(N){return N.copy(U)},this.setScissor=function(N,le,me,se){N.isVector4?U.set(N.x,N.y,N.z,N.w):U.set(N,le,me,se),ae.scissor(A.copy(U).multiplyScalar(T).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(N){ae.setScissorTest(W=N)},this.setOpaqueSort=function(N){D=N},this.setTransparentSort=function(N){O=N},this.getClearColor=function(N){return N.copy(Se.getClearColor())},this.setClearColor=function(){Se.setClearColor.apply(Se,arguments)},this.getClearAlpha=function(){return Se.getClearAlpha()},this.setClearAlpha=function(){Se.setClearAlpha.apply(Se,arguments)},this.clear=function(N=!0,le=!0,me=!0){let se=0;N&&(se|=16384),le&&(se|=256),me&&(se|=1024),H.clear(se)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",it,!1),t.removeEventListener("webglcontextrestored",Qe,!1),t.removeEventListener("webglcontextcreationerror",Ke,!1),qe.dispose(),V.dispose(),pe.dispose(),Le.dispose(),Me.dispose(),Ce.dispose(),ue.dispose(),je.dispose(),Ee.dispose(),Xe.dispose(),Xe.removeEventListener("sessionstart",Be),Xe.removeEventListener("sessionend",nt),X&&(X.dispose(),X=null),Et.stop()};function it(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function Qe(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let N=de.autoReset,le=oe.enabled,me=oe.autoUpdate,se=oe.needsUpdate,ve=oe.type;ze(),de.autoReset=N,oe.enabled=le,oe.autoUpdate=me,oe.needsUpdate=se,oe.type=ve}function Ke(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function qt(N){let le=N.target;le.removeEventListener("dispose",qt),oi(le)}function oi(N){K(N),pe.remove(N)}function K(N){let le=pe.get(N).programs;le!==void 0&&(le.forEach(function(me){Ee.releaseProgram(me)}),N.isShaderMaterial&&Ee.releaseShaderCache(N))}this.renderBufferDirect=function(N,le,me,se,ve,He){le===null&&(le=Q);let dt=ve.isMesh&&ve.matrixWorld.determinant()<0,pt=xm(N,le,me,se,ve);ae.setMaterial(se,dt);let Je=me.index,zt=1;se.wireframe===!0&&(Je=Ue.getWireframeAttribute(me),zt=2);let bt=me.drawRange,wt=me.attributes.position,vt=bt.start*zt,zi=(bt.start+bt.count)*zt;He!==null&&(vt=Math.max(vt,He.start*zt),zi=Math.min(zi,(He.start+He.count)*zt)),Je!==null?(vt=Math.max(vt,0),zi=Math.min(zi,Je.count)):wt!=null&&(vt=Math.max(vt,0),zi=Math.min(zi,wt.count));let ns=zi-vt;if(ns<0||ns===1/0)return;ue.setup(ve,se,pt,me,Je);let Ra,li=Te;if(Je!==null&&(Ra=Ve.get(Je),li=ke,li.setIndex(Ra)),ve.isMesh)se.wireframe===!0?(ae.setLineWidth(se.wireframeLinewidth*ee()),li.setMode(1)):li.setMode(4);else if(ve.isLine){let At=se.linewidth;At===void 0&&(At=1),ae.setLineWidth(At*ee()),ve.isLineSegments?li.setMode(1):ve.isLineLoop?li.setMode(2):li.setMode(3)}else ve.isPoints?li.setMode(0):ve.isSprite&&li.setMode(4);if(ve.isInstancedMesh)li.renderInstances(vt,ns,ve.count);else if(me.isInstancedBufferGeometry){let At=me._maxInstanceCount!==void 0?me._maxInstanceCount:1/0,Cs=Math.min(me.instanceCount,At);li.renderInstances(vt,ns,Cs)}else li.render(vt,ns)},this.compile=function(N,le){function me(se,ve,He){se.transparent===!0&&se.side===Ar&&se.forceSinglePass===!1?(se.side=rr,se.needsUpdate=!0,Gr(se,ve,He),se.side=Ws,se.needsUpdate=!0,Gr(se,ve,He),se.side=Ar):Gr(se,ve,He)}u=V.get(N),u.init(),f.push(u),N.traverseVisible(function(se){se.isLight&&se.layers.test(le.layers)&&(u.pushLight(se),se.castShadow&&u.pushShadow(se))}),u.setupLights(g.physicallyCorrectLights),N.traverse(function(se){let ve=se.material;if(ve)if(Array.isArray(ve))for(let He=0;He<ve.length;He++){let dt=ve[He];me(dt,N,se)}else me(ve,N,se)}),f.pop(),u=null};let ge=null;function _e(N){ge&&ge(N)}function Be(){Et.stop()}function nt(){Et.start()}let Et=new fM;Et.setAnimationLoop(_e),typeof self<"u"&&Et.setContext(self),this.setAnimationLoop=function(N){ge=N,Xe.setAnimationLoop(N),N===null?Et.stop():Et.start()},Xe.addEventListener("sessionstart",Be),Xe.addEventListener("sessionend",nt),this.render=function(N,le){if(le!==void 0&&le.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),le.parent===null&&le.matrixWorldAutoUpdate===!0&&le.updateMatrixWorld(),Xe.enabled===!0&&Xe.isPresenting===!0&&(Xe.cameraAutoUpdate===!0&&Xe.updateCamera(le),le=Xe.getCamera()),N.isScene===!0&&N.onBeforeRender(g,N,le,x),u=V.get(N,f.length),u.init(),f.push(u),G.multiplyMatrices(le.projectionMatrix,le.matrixWorldInverse),k.setFromProjectionMatrix(G),Z=this.localClippingEnabled,F=z.init(this.clippingPlanes,Z),d=qe.get(N,p.length),d.init(),p.push(d),vi(N,le,0,g.sortObjects),d.finish(),g.sortObjects===!0&&d.sort(D,O),F===!0&&z.beginShadows();let me=u.state.shadowsArray;if(oe.render(me,N,le),F===!0&&z.endShadows(),this.info.autoReset===!0&&this.info.reset(),Se.render(d,N),u.setupLights(g.physicallyCorrectLights),le.isArrayCamera){let se=le.cameras;for(let ve=0,He=se.length;ve<He;ve++){let dt=se[ve];Yi(d,N,dt,dt.viewport)}}else Yi(d,N,le);x!==null&&(be.updateMultisampleRenderTarget(x),be.updateRenderTargetMipmap(x)),N.isScene===!0&&N.onAfterRender(g,N,le),ue.resetDefaultState(),w=-1,_=null,f.pop(),f.length>0?u=f[f.length-1]:u=null,p.pop(),p.length>0?d=p[p.length-1]:d=null};function vi(N,le,me,se){if(N.visible===!1)return;if(N.layers.test(le.layers)){if(N.isGroup)me=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(le);else if(N.isLight)u.pushLight(N),N.castShadow&&u.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||k.intersectsSprite(N)){se&&$.setFromMatrixPosition(N.matrixWorld).applyMatrix4(G);let He=Ce.update(N),dt=N.material;dt.visible&&d.push(N,He,dt,me,$.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(N.isSkinnedMesh&&N.skeleton.frame!==de.render.frame&&(N.skeleton.update(),N.skeleton.frame=de.render.frame),!N.frustumCulled||k.intersectsObject(N))){se&&$.setFromMatrixPosition(N.matrixWorld).applyMatrix4(G);let He=Ce.update(N),dt=N.material;if(Array.isArray(dt)){let pt=He.groups;for(let Je=0,zt=pt.length;Je<zt;Je++){let bt=pt[Je],wt=dt[bt.materialIndex];wt&&wt.visible&&d.push(N,He,wt,me,$.z,bt)}}else dt.visible&&d.push(N,He,dt,me,$.z,null)}}let ve=N.children;for(let He=0,dt=ve.length;He<dt;He++)vi(ve[He],le,me,se)}function Yi(N,le,me,se){let ve=N.opaque,He=N.transmissive,dt=N.transparent;u.setupLightsView(me),F===!0&&z.setGlobalState(g.clippingPlanes,me),He.length>0&&Ks(ve,le,me),se&&ae.viewport(b.copy(se)),ve.length>0&&$t(ve,le,me),He.length>0&&$t(He,le,me),dt.length>0&&$t(dt,le,me),ae.buffers.depth.setTest(!0),ae.buffers.depth.setMask(!0),ae.buffers.color.setMask(!0),ae.setPolygonOffset(!1)}function Ks(N,le,me){let se=te.isWebGL2;X===null&&(X=new Pt(1,1,{generateMipmaps:!0,type:re.has("EXT_color_buffer_half_float")?mn:Er,minFilter:Ch,samples:se&&a===!0?4:0})),g.getDrawingBufferSize(q),se?X.setSize(q.x,q.y):X.setSize(Gp(q.x),Gp(q.y));let ve=g.getRenderTarget();g.setRenderTarget(X),g.clear();let He=g.toneMapping;g.toneMapping=_a,$t(N,le,me),g.toneMapping=He,be.updateMultisampleRenderTarget(X),be.updateRenderTargetMipmap(X),g.setRenderTarget(ve)}function $t(N,le,me){let se=le.isScene===!0?le.overrideMaterial:null;for(let ve=0,He=N.length;ve<He;ve++){let dt=N[ve],pt=dt.object,Je=dt.geometry,zt=se===null?dt.material:se,bt=dt.group;pt.layers.test(me.layers)&&Es(pt,le,me,Je,zt,bt)}}function Es(N,le,me,se,ve,He){N.onBeforeRender(g,le,me,se,ve,He),N.modelViewMatrix.multiplyMatrices(me.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),ve.onBeforeRender(g,le,me,se,N,He),ve.transparent===!0&&ve.side===Ar&&ve.forceSinglePass===!1?(ve.side=rr,ve.needsUpdate=!0,g.renderBufferDirect(me,le,se,ve,N,He),ve.side=Ws,ve.needsUpdate=!0,g.renderBufferDirect(me,le,se,ve,N,He),ve.side=Ar):g.renderBufferDirect(me,le,se,ve,N,He),N.onAfterRender(g,le,me,se,ve,He)}function Gr(N,le,me){le.isScene!==!0&&(le=Q);let se=pe.get(N),ve=u.state.lights,He=u.state.shadowsArray,dt=ve.state.version,pt=Ee.getParameters(N,ve.state,He,le,me),Je=Ee.getProgramCacheKey(pt),zt=se.programs;se.environment=N.isMeshStandardMaterial?le.environment:null,se.fog=le.fog,se.envMap=(N.isMeshStandardMaterial?Me:Le).get(N.envMap||se.environment),zt===void 0&&(N.addEventListener("dispose",qt),zt=new Map,se.programs=zt);let bt=zt.get(Je);if(bt!==void 0){if(se.currentProgram===bt&&se.lightsStateVersion===dt)return wl(N,pt),bt}else pt.uniforms=Ee.getUniforms(N),N.onBuild(me,pt,g),N.onBeforeCompile(pt,g),bt=Ee.acquireProgram(pt,Je),zt.set(Je,bt),se.uniforms=pt.uniforms;let wt=se.uniforms;(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(wt.clippingPlanes=z.uniform),wl(N,pt),se.needsLights=nc(N),se.lightsStateVersion=dt,se.needsLights&&(wt.ambientLightColor.value=ve.state.ambient,wt.lightProbe.value=ve.state.probe,wt.directionalLights.value=ve.state.directional,wt.directionalLightShadows.value=ve.state.directionalShadow,wt.spotLights.value=ve.state.spot,wt.spotLightShadows.value=ve.state.spotShadow,wt.rectAreaLights.value=ve.state.rectArea,wt.ltc_1.value=ve.state.rectAreaLTC1,wt.ltc_2.value=ve.state.rectAreaLTC2,wt.pointLights.value=ve.state.point,wt.pointLightShadows.value=ve.state.pointShadow,wt.hemisphereLights.value=ve.state.hemi,wt.directionalShadowMap.value=ve.state.directionalShadowMap,wt.directionalShadowMatrix.value=ve.state.directionalShadowMatrix,wt.spotShadowMap.value=ve.state.spotShadowMap,wt.spotLightMatrix.value=ve.state.spotLightMatrix,wt.spotLightMap.value=ve.state.spotLightMap,wt.pointShadowMap.value=ve.state.pointShadowMap,wt.pointShadowMatrix.value=ve.state.pointShadowMatrix);let vt=bt.getUniforms(),zi=Sp.seqWithValue(vt.seq,wt);return se.currentProgram=bt,se.uniformsList=zi,bt}function wl(N,le){let me=pe.get(N);me.outputEncoding=le.outputEncoding,me.instancing=le.instancing,me.skinning=le.skinning,me.morphTargets=le.morphTargets,me.morphNormals=le.morphNormals,me.morphColors=le.morphColors,me.morphTargetsCount=le.morphTargetsCount,me.numClippingPlanes=le.numClippingPlanes,me.numIntersection=le.numClipIntersection,me.vertexAlphas=le.vertexAlphas,me.vertexTangents=le.vertexTangents,me.toneMapping=le.toneMapping}function xm(N,le,me,se,ve){le.isScene!==!0&&(le=Q),be.resetTextureUnits();let He=le.fog,dt=se.isMeshStandardMaterial?le.environment:null,pt=x===null?g.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:qs,Je=(se.isMeshStandardMaterial?Me:Le).get(se.envMap||dt),zt=se.vertexColors===!0&&!!me.attributes.color&&me.attributes.color.itemSize===4,bt=!!se.normalMap&&!!me.attributes.tangent,wt=!!me.morphAttributes.position,vt=!!me.morphAttributes.normal,zi=!!me.morphAttributes.color,ns=se.toneMapped?g.toneMapping:_a,Ra=me.morphAttributes.position||me.morphAttributes.normal||me.morphAttributes.color,li=Ra!==void 0?Ra.length:0,At=pe.get(se),Cs=u.state.lights;if(F===!0&&(Z===!0||N!==_)){let B=N===_&&se.id===w;z.setState(se,N,B)}let St=!1;se.version===At.__version?(At.needsLights&&At.lightsStateVersion!==Cs.state.version||At.outputEncoding!==pt||ve.isInstancedMesh&&At.instancing===!1||!ve.isInstancedMesh&&At.instancing===!0||ve.isSkinnedMesh&&At.skinning===!1||!ve.isSkinnedMesh&&At.skinning===!0||At.envMap!==Je||se.fog===!0&&At.fog!==He||At.numClippingPlanes!==void 0&&(At.numClippingPlanes!==z.numPlanes||At.numIntersection!==z.numIntersection)||At.vertexAlphas!==zt||At.vertexTangents!==bt||At.morphTargets!==wt||At.morphNormals!==vt||At.morphColors!==zi||At.toneMapping!==ns||te.isWebGL2===!0&&At.morphTargetsCount!==li)&&(St=!0):(St=!0,At.__version=se.version);let La=At.currentProgram;St===!0&&(La=Gr(se,le,ve));let So=!1,An=!1,Js=!1,I=La.getUniforms(),L=At.uniforms;if(ae.useProgram(La.program)&&(So=!0,An=!0,Js=!0),se.id!==w&&(w=se.id,An=!0),So||_!==N){if(I.setValue(H,"projectionMatrix",N.projectionMatrix),te.logarithmicDepthBuffer&&I.setValue(H,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),_!==N&&(_=N,An=!0,Js=!0),se.isShaderMaterial||se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshStandardMaterial||se.envMap){let B=I.map.cameraPosition;B!==void 0&&B.setValue(H,$.setFromMatrixPosition(N.matrixWorld))}(se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshLambertMaterial||se.isMeshBasicMaterial||se.isMeshStandardMaterial||se.isShaderMaterial)&&I.setValue(H,"isOrthographic",N.isOrthographicCamera===!0),(se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshLambertMaterial||se.isMeshBasicMaterial||se.isMeshStandardMaterial||se.isShaderMaterial||se.isShadowMaterial||ve.isSkinnedMesh)&&I.setValue(H,"viewMatrix",N.matrixWorldInverse)}if(ve.isSkinnedMesh){I.setOptional(H,ve,"bindMatrix"),I.setOptional(H,ve,"bindMatrixInverse");let B=ve.skeleton;B&&(te.floatVertexTextures?(B.boneTexture===null&&B.computeBoneTexture(),I.setValue(H,"boneTexture",B.boneTexture,be),I.setValue(H,"boneTextureSize",B.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let Y=me.morphAttributes;if((Y.position!==void 0||Y.normal!==void 0||Y.color!==void 0&&te.isWebGL2===!0)&&R.update(ve,me,se,La),(An||At.receiveShadow!==ve.receiveShadow)&&(At.receiveShadow=ve.receiveShadow,I.setValue(H,"receiveShadow",ve.receiveShadow)),se.isMeshGouraudMaterial&&se.envMap!==null&&(L.envMap.value=Je,L.flipEnvMap.value=Je.isCubeTexture&&Je.isRenderTargetTexture===!1?-1:1),An&&(I.setValue(H,"toneMappingExposure",g.toneMappingExposure),At.needsLights&&bm(L,Js),He&&se.fog===!0&&Ye.refreshFogUniforms(L,He),Ye.refreshMaterialUniforms(L,se,T,C,X),Sp.upload(H,At.uniformsList,L,be)),se.isShaderMaterial&&se.uniformsNeedUpdate===!0&&(Sp.upload(H,At.uniformsList,L,be),se.uniformsNeedUpdate=!1),se.isSpriteMaterial&&I.setValue(H,"center",ve.center),I.setValue(H,"modelViewMatrix",ve.modelViewMatrix),I.setValue(H,"normalMatrix",ve.normalMatrix),I.setValue(H,"modelMatrix",ve.matrixWorld),ve.previousModelViewMatrix&&I.setValue(H,"previousModelViewMatrix",ve.previousModelViewMatrix),N.previousProjectionMatrix&&I.setValue(H,"previousProjectionMatrix",N.previousProjectionMatrix),se.isShaderMaterial||se.isRawShaderMaterial){let B=se.uniformsGroups;for(let J=0,Ae=B.length;J<Ae;J++)if(te.isWebGL2){let za=B[J];je.update(za,La),je.bind(za,La)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return La}function bm(N,le){N.ambientLightColor.needsUpdate=le,N.lightProbe.needsUpdate=le,N.directionalLights.needsUpdate=le,N.directionalLightShadows.needsUpdate=le,N.pointLights.needsUpdate=le,N.pointLightShadows.needsUpdate=le,N.spotLights.needsUpdate=le,N.spotLightShadows.needsUpdate=le,N.rectAreaLights.needsUpdate=le,N.hemisphereLights.needsUpdate=le}function nc(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(N,le,me){pe.get(N.texture).__webglTexture=le,pe.get(N.depthTexture).__webglTexture=me;let se=pe.get(N);se.__hasExternalTextures=!0,se.__hasExternalTextures&&(se.__autoAllocateDepthBuffer=me===void 0,se.__autoAllocateDepthBuffer||re.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),se.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(N,le){let me=pe.get(N);me.__webglFramebuffer=le,me.__useDefaultFramebuffer=le===void 0},this.setRenderTarget=function(N,le=0,me=0){x=N,v=le,y=me;let se=!0,ve=null,He=!1,dt=!1;if(N){let pt=pe.get(N);pt.__useDefaultFramebuffer!==void 0?(ae.bindFramebuffer(36160,null),se=!1):pt.__webglFramebuffer===void 0?be.setupRenderTarget(N):pt.__hasExternalTextures&&be.rebindTextures(N,pe.get(N.texture).__webglTexture,pe.get(N.depthTexture).__webglTexture);let Je=N.texture;(Je.isData3DTexture||Je.isDataArrayTexture||Je.isCompressedArrayTexture)&&(dt=!0);let zt=pe.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(ve=zt[le],He=!0):te.isWebGL2&&N.samples>0&&be.useMultisampledRTT(N)===!1?ve=pe.get(N).__webglMultisampledFramebuffer:ve=zt,b.copy(N.viewport),A.copy(N.scissor),S=N.scissorTest}else b.copy(P).multiplyScalar(T).floor(),A.copy(U).multiplyScalar(T).floor(),S=W;if(ae.bindFramebuffer(36160,ve)&&te.drawBuffers&&se&&ae.drawBuffers(N,ve),ae.viewport(b),ae.scissor(A),ae.setScissorTest(S),He){let pt=pe.get(N.texture);H.framebufferTexture2D(36160,36064,34069+le,pt.__webglTexture,me)}else if(dt){let pt=pe.get(N.texture),Je=le||0;H.framebufferTextureLayer(36160,36064,pt.__webglTexture,me||0,Je)}w=-1},this.readRenderTargetPixels=function(N,le,me,se,ve,He,dt){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pt=pe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&dt!==void 0&&(pt=pt[dt]),pt){ae.bindFramebuffer(36160,pt);try{let Je=N.texture,zt=Je.format,bt=Je.type;if(zt!==ni&&Oe.convert(zt)!==H.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let wt=bt===mn&&(re.has("EXT_color_buffer_half_float")||te.isWebGL2&&re.has("EXT_color_buffer_float"));if(bt!==Er&&Oe.convert(bt)!==H.getParameter(35738)&&!(bt===jt&&(te.isWebGL2||re.has("OES_texture_float")||re.has("WEBGL_color_buffer_float")))&&!wt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}le>=0&&le<=N.width-se&&me>=0&&me<=N.height-ve&&H.readPixels(le,me,se,ve,Oe.convert(zt),Oe.convert(bt),He)}finally{let Je=x!==null?pe.get(x).__webglFramebuffer:null;ae.bindFramebuffer(36160,Je)}}},this.readRenderTargetPixelsAsync=async function(N,le,me,se,ve,He,dt){if(!(N&&N.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let pt=pe.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&dt!==void 0&&(pt=pt[dt]),pt){let Je=N.texture,zt=Je.format,bt=Je.type;if(le>=0&&le<=N.width-se&&me>=0&&me<=N.height-ve){ae.bindFramebuffer(H.FRAMEBUFFER,pt);let wt=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,wt),H.bufferData(H.PIXEL_PACK_BUFFER,He.byteLength,H.STREAM_READ),H.readPixels(le,me,se,ve,Oe.convert(zt),Oe.convert(bt),0);let vt=x!==null?pe.get(x).__webglFramebuffer:null;ae.bindFramebuffer(H.FRAMEBUFFER,vt);let zi=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await VR(H,zi,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,wt),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,He),H.deleteBuffer(wt),H.deleteSync(zi),He}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(N,le,me=0){let se=Math.pow(2,-me),ve=Math.floor(le.image.width*se),He=Math.floor(le.image.height*se);be.setTexture2D(le,0),H.copyTexSubImage2D(3553,me,0,0,N.x,N.y,ve,He),ae.unbindTexture()},this.copyTextureToTexture=function(N,le,me,se=0){let ve=le.image.width,He=le.image.height,dt=Oe.convert(me.format),pt=Oe.convert(me.type);be.setTexture2D(me,0),H.pixelStorei(37440,me.flipY),H.pixelStorei(37441,me.premultiplyAlpha),H.pixelStorei(3317,me.unpackAlignment),le.isDataTexture?H.texSubImage2D(3553,se,N.x,N.y,ve,He,dt,pt,le.image.data):le.isCompressedTexture?H.compressedTexSubImage2D(3553,se,N.x,N.y,le.mipmaps[0].width,le.mipmaps[0].height,dt,le.mipmaps[0].data):H.texSubImage2D(3553,se,N.x,N.y,dt,pt,le.image),se===0&&me.generateMipmaps&&H.generateMipmap(3553),ae.unbindTexture()},this.copyTextureToTexture3D=function(N,le,me,se,ve=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let He=N.max.x-N.min.x+1,dt=N.max.y-N.min.y+1,pt=N.max.z-N.min.z+1,Je=Oe.convert(se.format),zt=Oe.convert(se.type),bt;if(se.isData3DTexture)be.setTexture3D(se,0),bt=32879;else if(se.isDataArrayTexture)be.setTexture2DArray(se,0),bt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}H.pixelStorei(37440,se.flipY),H.pixelStorei(37441,se.premultiplyAlpha),H.pixelStorei(3317,se.unpackAlignment);let wt=H.getParameter(3314),vt=H.getParameter(32878),zi=H.getParameter(3316),ns=H.getParameter(3315),Ra=H.getParameter(32877),li=me.isCompressedTexture?me.mipmaps[0]:me.image;H.pixelStorei(3314,li.width),H.pixelStorei(32878,li.height),H.pixelStorei(3316,N.min.x),H.pixelStorei(3315,N.min.y),H.pixelStorei(32877,N.min.z),me.isDataTexture||me.isData3DTexture?H.texSubImage3D(bt,ve,le.x,le.y,le.z,He,dt,pt,Je,zt,li.data):me.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),H.compressedTexSubImage3D(bt,ve,le.x,le.y,le.z,He,dt,pt,Je,li.data)):H.texSubImage3D(bt,ve,le.x,le.y,le.z,He,dt,pt,Je,zt,li),H.pixelStorei(3314,wt),H.pixelStorei(32878,vt),H.pixelStorei(3316,zi),H.pixelStorei(3315,ns),H.pixelStorei(32877,Ra),ve===0&&se.generateMipmaps&&H.generateMipmap(bt),ae.unbindTexture()},this.initRenderTarget=function(N){pe.get(N).__webglFramebuffer===void 0&&be.setupRenderTarget(N)},this.initTexture=function(N){N.isCubeTexture?be.setTextureCube(N,0):N.isData3DTexture?be.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?be.setTexture2DArray(N,0):be.setTexture2D(N,0),ae.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,ae.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var FF=class extends bM{};FF.prototype.isWebGL1Renderer=!0;var wM=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new et(e),this.near=t,this.far=i}clone(){return new wM(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Jr=class extends kt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},UF=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Rv,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ws()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ws()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ws()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ir=new M,Uv=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ir.fromBufferAttribute(this,t),Ir.applyMatrix4(e),this.setXYZ(t,Ir.x,Ir.y,Ir.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ir.fromBufferAttribute(this,t),Ir.applyNormalMatrix(e),this.setXYZ(t,Ir.x,Ir.y,Ir.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ir.fromBufferAttribute(this,t),Ir.transformDirection(e),this.setXYZ(t,Ir.x,Ir.y,Ir.z);return this}setX(e,t){return this.normalized&&(t=Kt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Kt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Kt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Kt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=ln(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ln(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ln(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ln(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Kt(t,this.array),i=Kt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Kt(t,this.array),i=Kt(i,this.array),r=Kt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Kt(t,this.array),i=Kt(i,this.array),r=Kt(r,this.array),s=Kt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new tt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Uv(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},_M=class extends kt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Ur=class extends ci{constructor(e=null,t=1,i=1,r,s,a,n,o,l=_t,h=_t,c,d){super(null,a,n,o,l,h,r,s,c,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Rb=new we,NF=new we,qy=class{constructor(e=[],t=[]){this.uuid=ws(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new we)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new we;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){let n=e[s]?e[s].matrixWorld:NF;Rb.multiplyMatrices(n,t[s]),Rb.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new qy(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=aM(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Ur(t,e,e,ni,jt);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new _M),this.bones.push(a),this.boneInverses.push(new we().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let a=t[r];e.bones.push(a.uuid);let n=i[r];e.boneInverses.push(n.toArray())}return e}},ud=class extends tt{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Lb=new we,zb=new we,gu=[],kF=new we,fc=new Jt,VF=class extends Jt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new ud(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1;for(let r=0;r<i;r++)this.setMatrixAt(r,kF)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){let i=this.matrixWorld,r=this.count;if(fc.geometry=this.geometry,fc.material=this.material,fc.material!==void 0)for(let s=0;s<r;s++){this.getMatrixAt(s,Lb),zb.multiplyMatrices(i,Lb),fc.matrixWorld=zb,fc.raycast(e,gu);for(let a=0,n=gu.length;a<n;a++){let o=gu[a];o.instanceId=s,o.object=this,t.push(o)}gu.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new ud(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}},wo=class extends Ld{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new et(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Bb=new M,Fb=new M,Ub=new we,ig=new Hh,vu=new $r,Hp=class extends kt{constructor(e=new Ge,t=new wo){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)Bb.fromBufferAttribute(t,r-1),Fb.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Bb.distanceTo(Fb);e.setAttribute("lineDistance",new Ie(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),vu.copy(i.boundingSphere),vu.applyMatrix4(r),vu.radius+=s,e.ray.intersectsSphere(vu)===!1)return;Ub.copy(r).invert(),ig.copy(e.ray).applyMatrix4(Ub);let n=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,l=new M,h=new M,c=new M,d=new M,u=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let g=Math.max(0,a.start),m=Math.min(p.count,a.start+a.count);for(let v=g,y=m-1;v<y;v+=u){let x=p.getX(v),w=p.getX(v+1);if(l.fromBufferAttribute(f,x),h.fromBufferAttribute(f,w),ig.distanceSqToSegment(l,h,d,c)>o)continue;d.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(d);_<e.near||_>e.far||t.push({distance:_,point:c.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,a.start),m=Math.min(f.count,a.start+a.count);for(let v=g,y=m-1;v<y;v+=u){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),ig.distanceSqToSegment(l,h,d,c)>o)continue;d.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(d);x<e.near||x>e.far||t.push({distance:x,point:c.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}},Nb=new M,kb=new M,zd=class extends Hp{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)Nb.fromBufferAttribute(t,r),kb.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Nb.distanceTo(kb);e.setAttribute("lineDistance",new Ie(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},jF=class extends ci{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:xt,this.magFilter=s!==void 0?s:xt,this.generateMipmaps=!1;let h=this;function c(){h.needsUpdate=!0,e.requestVideoFrameCallback(c)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(c)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},GF=class extends ci{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Da=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,a;t?a=t:a=e*i[s-1];let n=0,o=s-1,l;for(;n<=o;)if(r=Math.floor(n+(o-n)/2),l=i[r]-a,l<0)n=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===a)return r/(s-1);let h=i[r],c=i[r+1]-h,d=(a-h)/c;return(r+d)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),a=this.getPoint(r),n=t||(s.isVector2?new j:new M);return n.copy(a).sub(s).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new M,r=[],s=[],a=[],n=new M,o=new we;for(let u=0;u<=e;u++){let p=u/e;r[u]=this.getTangentAt(p,new M)}s[0]=new M,a[0]=new M;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),c=Math.abs(r[0].y),d=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),d<=l&&i.set(0,0,1),n.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],n),a[0].crossVectors(r[0],s[0]);for(let u=1;u<=e;u++){if(s[u]=s[u-1].clone(),a[u]=a[u-1].clone(),n.crossVectors(r[u-1],r[u]),n.length()>Number.EPSILON){n.normalize();let p=Math.acos(Ti(r[u-1].dot(r[u]),-1,1));s[u].applyMatrix4(o.makeRotationAxis(n,p))}a[u].crossVectors(r[u],s[u])}if(t===!0){let u=Math.acos(Ti(s[0].dot(s[e]),-1,1));u/=e,r[0].dot(n.crossVectors(s[0],s[e]))>0&&(u=-u);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],u*p)),a[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Qf=class extends Da{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,n=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=n,this.aRotation=o}getPoint(e,t){let i=t||new j,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);let n=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);if(this.aRotation!==0){let h=Math.cos(this.aRotation),c=Math.sin(this.aRotation),d=o-this.aX,u=l-this.aY;o=d*h-u*c+this.aX,l=d*c+u*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},HF=class extends Qf{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}};function Xy(){let e=0,t=0,i=0,r=0;function s(a,n,o,l){e=a,t=o,i=-3*a+3*n-2*o-l,r=2*a-2*n+o+l}return{initCatmullRom:function(a,n,o,l,h){s(n,o,h*(o-a),h*(l-n))},initNonuniformCatmullRom:function(a,n,o,l,h,c,d){let u=(n-a)/h-(o-a)/(h+c)+(o-n)/c,p=(o-n)/c-(l-n)/(c+d)+(l-o)/d;u*=c,p*=c,s(n,o,u,p)},calc:function(a){let n=a*a,o=n*a;return e+t*a+i*n+r*o}}}var yu=new M,rg=new Xy,sg=new Xy,ag=new Xy,WF=class extends Da{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new M){let i=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e,n=Math.floor(a),o=a-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/s)+1)*s:o===0&&n===s-1&&(n=s-2,o=1);let l,h;this.closed||n>0?l=r[(n-1)%s]:(yu.subVectors(r[0],r[1]).add(r[0]),l=yu);let c=r[n%s],d=r[(n+1)%s];if(this.closed||n+2<s?h=r[(n+2)%s]:(yu.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=yu),this.curveType==="centripetal"||this.curveType==="chordal"){let u=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(c),u),f=Math.pow(c.distanceToSquared(d),u),g=Math.pow(d.distanceToSquared(h),u);f<1e-4&&(f=1),p<1e-4&&(p=f),g<1e-4&&(g=f),rg.initNonuniformCatmullRom(l.x,c.x,d.x,h.x,p,f,g),sg.initNonuniformCatmullRom(l.y,c.y,d.y,h.y,p,f,g),ag.initNonuniformCatmullRom(l.z,c.z,d.z,h.z,p,f,g)}else this.curveType==="catmullrom"&&(rg.initCatmullRom(l.x,c.x,d.x,h.x,this.tension),sg.initCatmullRom(l.y,c.y,d.y,h.y,this.tension),ag.initCatmullRom(l.z,c.z,d.z,h.z,this.tension));return i.set(rg.calc(o),sg.calc(o),ag.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new M().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Vb(e,t,i,r,s){let a=(r-t)*.5,n=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+a+n)*l+(-3*i+3*r-2*a-n)*o+a*e+i}function qF(e,t){let i=1-e;return i*i*t}function XF(e,t){return 2*(1-e)*e*t}function YF(e,t){return e*e*t}function Qc(e,t,i,r){return qF(e,t)+XF(e,i)+YF(e,r)}function QF(e,t){let i=1-e;return i*i*i*t}function ZF(e,t){let i=1-e;return 3*i*i*e*t}function KF(e,t){return 3*(1-e)*e*e*t}function JF(e,t){return e*e*e*t}function Zc(e,t,i,r,s){return QF(e,t)+ZF(e,i)+KF(e,r)+JF(e,s)}var Vs=class extends Da{constructor(e=new j,t=new j,i=new j,r=new j){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new j){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(Zc(e,r.x,s.x,a.x,n.x),Zc(e,r.y,s.y,a.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Ap=class extends Da{constructor(e=new M,t=new M,i=new M,r=new M){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new M){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(Zc(e,r.x,s.x,a.x,n.x),Zc(e,r.y,s.y,a.y,n.y),Zc(e,r.z,s.z,a.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Hs=class extends Da{constructor(e=new j,t=new j){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new j){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new j;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},SM=class extends Da{constructor(e=new M,t=new M){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new M){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ho=class extends Da{constructor(e=new j,t=new j,i=new j){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new j){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(Qc(e,r.x,s.x,a.x),Qc(e,r.y,s.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},$F=class extends Da{constructor(e=new M,t=new M,i=new M){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new M){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(Qc(e,r.x,s.x,a.x),Qc(e,r.y,s.y,a.y),Qc(e,r.z,s.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Yy=class extends Da{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new j){let i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),n=s-a,o=r[a===0?a:a-1],l=r[a],h=r[a>r.length-2?r.length-1:a+1],c=r[a>r.length-3?r.length-1:a+2];return i.set(Vb(n,o.x,l.x,h.x,c.x),Vb(n,o.y,l.y,h.y,c.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new j().fromArray(r))}return this}},eU=Object.freeze({__proto__:null,ArcCurve:HF,CatmullRomCurve3:WF,CubicBezierCurve:Vs,CubicBezierCurve3:Ap,EllipseCurve:Qf,LineCurve:Hs,LineCurve3:SM,QuadraticBezierCurve:ho,QuadraticBezierCurve3:$F,SplineCurve:Yy}),AM=class extends Da{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Hs(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let a=r[s]-i,n=this.curves[s],o=n.getLength(),l=o===0?0:1-a/o;return n.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let a=s[r],n=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,o=a.getPoints(n);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new eU[r.type]().fromJSON(r))}return this}},Wp=class extends AM{constructor(e){super(),this.type="Path",this.currentPoint=new j,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new Hs(this.currentPoint.clone(),new j(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new ho(this.currentPoint.clone(),new j(e,t),new j(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){let n=new Vs(this.currentPoint.clone(),new j(e,t),new j(i,r),new j(s,a));return this.curves.push(n),this.currentPoint.set(s,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Yy(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){let n=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+n,t+o,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,n,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,a,n,o),this}absellipse(e,t,i,r,s,a,n,o){let l=new Qf(e,t,i,r,s,a,n,o);if(this.curves.length>0){let c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},MM=class extends Ge{constructor(e=[new j(0,-.5),new j(.5,0),new j(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Ti(r,0,Math.PI*2);let s=[],a=[],n=[],o=[],l=[],h=1/t,c=new M,d=new j,u=new M,p=new M,f=new M,g=0,m=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,u.x=m*1,u.y=-g,u.z=m*0,f.copy(u),u.normalize(),o.push(u.x,u.y,u.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,u.x=m*1,u.y=-g,u.z=m*0,p.copy(u),u.x+=f.x,u.y+=f.y,u.z+=f.z,u.normalize(),o.push(u.x,u.y,u.z),f.copy(p)}for(let v=0;v<=t;v++){let y=i+v*h*r,x=Math.sin(y),w=Math.cos(y);for(let _=0;_<=e.length-1;_++){c.x=e[_].x*x,c.y=e[_].y,c.z=e[_].x*w,a.push(c.x,c.y,c.z),d.x=v/t,d.y=_/(e.length-1),n.push(d.x,d.y);let b=o[3*_+0]*x,A=o[3*_+1],S=o[3*_+0]*w;l.push(b,A,S)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,w=x,_=x+e.length,b=x+e.length+1,A=x+1;s.push(w,_,A),s.push(b,A,_)}this.setIndex(s),this.setAttribute("position",new Ie(a,3)),this.setAttribute("uv",new Ie(n,2)),this.setAttribute("normal",new Ie(l,3))}static fromJSON(e){return new MM(e.points,e.segments,e.phiStart,e.phiLength)}},Qy=class extends Ge{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,n=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:n,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],c=[],d=[],u=[],p=0,f=[],g=i/2,m=0;v(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Ie(c,3)),this.setAttribute("normal",new Ie(d,3)),this.setAttribute("uv",new Ie(u,2));function v(){let x=new M,w=new M,_=0,b=(t-e)/i;for(let A=0;A<=s;A++){let S=[],E=A/s,C=E*(t-e)+e;for(let T=0;T<=r;T++){let D=T/r,O=D*o+n,P=Math.sin(O),U=Math.cos(O);w.x=C*P,w.y=-E*i+g,w.z=C*U,c.push(w.x,w.y,w.z),x.set(P,b,U).normalize(),d.push(x.x,x.y,x.z),u.push(D,1-E),S.push(p++)}f.push(S)}for(let A=0;A<r;A++)for(let S=0;S<s;S++){let E=f[S][A],C=f[S+1][A],T=f[S+1][A+1],D=f[S][A+1];h.push(E,C,D),h.push(C,T,D),_+=6}l.addGroup(m,_,0),m+=_}function y(x){let w=p,_=new j,b=new M,A=0,S=x===!0?e:t,E=x===!0?1:-1;for(let T=1;T<=r;T++)c.push(0,g*E,0),d.push(0,E,0),u.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let D=T/r*o+n,O=Math.cos(D),P=Math.sin(D);b.x=S*P,b.y=g*E,b.z=S*O,c.push(b.x,b.y,b.z),d.push(0,E,0),_.x=O*.5+.5,_.y=P*.5*E+.5,u.push(_.x,_.y),p++}for(let T=0;T<r;T++){let D=w+T,O=C+T;x===!0?h.push(O,O+1,D):h.push(O+1,O,D),A+=3}l.addGroup(m,A,x===!0?1:2),m+=A}}static fromJSON(e){return new Qy(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Zy=class extends Qy{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,n=Math.PI*2){super(0,e,t,i,r,s,a,n),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:n}}static fromJSON(e){return new Zy(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Ky=class extends Ge{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],a=[];n(r),l(i),h(),this.setAttribute("position",new Ie(s,3)),this.setAttribute("normal",new Ie(s.slice(),3)),this.setAttribute("uv",new Ie(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(v){let y=new M,x=new M,w=new M;for(let _=0;_<t.length;_+=3)u(t[_+0],y),u(t[_+1],x),u(t[_+2],w),o(y,x,w,v)}function o(v,y,x,w){let _=w+1,b=[];for(let A=0;A<=_;A++){b[A]=[];let S=v.clone().lerp(x,A/_),E=y.clone().lerp(x,A/_),C=_-A;for(let T=0;T<=C;T++)T===0&&A===_?b[A][T]=S:b[A][T]=S.clone().lerp(E,T/C)}for(let A=0;A<_;A++)for(let S=0;S<2*(_-A)-1;S++){let E=Math.floor(S/2);S%2===0?(d(b[A][E+1]),d(b[A+1][E]),d(b[A][E])):(d(b[A][E+1]),d(b[A+1][E+1]),d(b[A+1][E]))}}function l(v){let y=new M;for(let x=0;x<s.length;x+=3)y.x=s[x+0],y.y=s[x+1],y.z=s[x+2],y.normalize().multiplyScalar(v),s[x+0]=y.x,s[x+1]=y.y,s[x+2]=y.z}function h(){let v=new M;for(let y=0;y<s.length;y+=3){v.x=s[y+0],v.y=s[y+1],v.z=s[y+2];let x=g(v)/2/Math.PI+.5,w=m(v)/Math.PI+.5;a.push(x,1-w)}p(),c()}function c(){for(let v=0;v<a.length;v+=6){let y=a[v+0],x=a[v+2],w=a[v+4],_=Math.max(y,x,w),b=Math.min(y,x,w);_>.9&&b<.1&&(y<.2&&(a[v+0]+=1),x<.2&&(a[v+2]+=1),w<.2&&(a[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function u(v,y){let x=v*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function p(){let v=new M,y=new M,x=new M,w=new M,_=new j,b=new j,A=new j;for(let S=0,E=0;S<s.length;S+=9,E+=6){v.set(s[S+0],s[S+1],s[S+2]),y.set(s[S+3],s[S+4],s[S+5]),x.set(s[S+6],s[S+7],s[S+8]),_.set(a[E+0],a[E+1]),b.set(a[E+2],a[E+3]),A.set(a[E+4],a[E+5]),w.copy(v).add(y).add(x).divideScalar(3);let C=g(w);f(_,E+0,v,C),f(b,E+2,y,C),f(A,E+4,x,C)}}function f(v,y,x,w){w<0&&v.x===1&&(a[y]=v.x-1),x.x===0&&x.z===0&&(a[y]=w/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new Ky(e.vertices,e.indices,e.radius,e.details)}},EM=class extends Ky{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new EM(e.radius,e.detail)}},qp=class extends Wp{constructor(e){super(e),this.uuid=ws(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Wp().fromJSON(r))}return this}},tU={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,a=CM(e,0,s,i,!0),n=[];if(!a||a.next===a.prev)return n;let o,l,h,c,d,u,p;if(r&&(a=nU(e,t,a,i)),e.length>80*i){o=h=e[0],l=c=e[1];for(let f=i;f<s;f+=i)d=e[f],u=e[f+1],d<o&&(o=d),u<l&&(l=u),d>h&&(h=d),u>c&&(c=u);p=Math.max(h-o,c-l),p=p!==0?32767/p:0}return pd(a,n,i,o,l,p,0),n}};function CM(e,t,i,r,s){let a,n;if(s===vU(e,t,i,r)>0)for(a=t;a<i;a+=r)n=jb(a,e[a],e[a+1],n);else for(a=i-r;a>=t;a-=r)n=jb(a,e[a],e[a+1],n);return n&&Zf(n,n.next)&&(md(n),n=n.next),n}function ll(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(Zf(i,i.next)||hi(i.prev,i,i.next)===0)){if(md(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function pd(e,t,i,r,s,a,n){if(!e)return;!n&&a&&dU(e,r,s,a);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,a?rU(e,r,s,a):iU(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),md(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=sU(ll(e),t,i),pd(e,t,i,r,s,a,2)):n===2&&aU(e,t,i,r,s,a):pd(ll(e),t,i,r,s,a,1);break}}}function iU(e){let t=e.prev,i=e,r=e.next;if(hi(t,i,r)>=0)return!1;let s=t.x,a=i.x,n=r.x,o=t.y,l=i.y,h=r.y,c=s<a?s<n?s:n:a<n?a:n,d=o<l?o<h?o:h:l<h?l:h,u=s>a?s>n?s:n:a>n?a:n,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=c&&f.x<=u&&f.y>=d&&f.y<=p&&dh(s,o,a,l,n,h,f.x,f.y)&&hi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function rU(e,t,i,r){let s=e.prev,a=e,n=e.next;if(hi(s,a,n)>=0)return!1;let o=s.x,l=a.x,h=n.x,c=s.y,d=a.y,u=n.y,p=o<l?o<h?o:h:l<h?l:h,f=c<d?c<u?c:u:d<u?d:u,g=o>l?o>h?o:h:l>h?l:h,m=c>d?c>u?c:u:d>u?d:u,v=Nv(p,f,t,i,r),y=Nv(g,m,t,i,r),x=e.prevZ,w=e.nextZ;for(;x&&x.z>=v&&w&&w.z<=y;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==n&&dh(o,c,l,d,h,u,x.x,x.y)&&hi(x.prev,x,x.next)>=0||(x=x.prevZ,w.x>=p&&w.x<=g&&w.y>=f&&w.y<=m&&w!==s&&w!==n&&dh(o,c,l,d,h,u,w.x,w.y)&&hi(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==n&&dh(o,c,l,d,h,u,x.x,x.y)&&hi(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;w&&w.z<=y;){if(w.x>=p&&w.x<=g&&w.y>=f&&w.y<=m&&w!==s&&w!==n&&dh(o,c,l,d,h,u,w.x,w.y)&&hi(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function sU(e,t,i){let r=e;do{let s=r.prev,a=r.next.next;!Zf(s,a)&&TM(s,r,r.next,a)&&fd(s,a)&&fd(a,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(a.i/i|0),md(r),md(r.next),r=e=a),r=r.next}while(r!==e);return ll(r)}function aU(e,t,i,r,s,a){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&fU(n,o)){let l=PM(n,o);n=ll(n,n.next),l=ll(l,l.next),pd(n,t,i,r,s,a,0),pd(l,t,i,r,s,a,0);return}o=o.next}n=n.next}while(n!==e)}function nU(e,t,i,r){let s=[],a,n,o,l,h;for(a=0,n=t.length;a<n;a++)o=t[a]*r,l=a<n-1?t[a+1]*r:e.length,h=CM(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(pU(h));for(s.sort(oU),a=0;a<s.length;a++)i=lU(s[a],i);return i}function oU(e,t){return e.x-t.x}function lU(e,t){let i=hU(e,t);if(!i)return t;let r=PM(i,e);return ll(r,r.next),ll(i,i.next)}function hU(e,t){let i=t,r=-1/0,s,a=e.x,n=e.y;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){let u=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(u<=a&&u>r&&(r=u,s=i.x<i.next.x?i:i.next,u===a))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,c=1/0,d;i=s;do a>=i.x&&i.x>=l&&a!==i.x&&dh(n<h?a:r,n,l,h,n<h?r:a,n,i.x,i.y)&&(d=Math.abs(n-i.y)/(a-i.x),fd(i,e)&&(d<c||d===c&&(i.x>s.x||i.x===s.x&&cU(s,i)))&&(s=i,c=d)),i=i.next;while(i!==o);return s}function cU(e,t){return hi(e.prev,e,t.prev)<0&&hi(t.next,e,e.next)<0}function dU(e,t,i,r){let s=e;do s.z===0&&(s.z=Nv(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,uU(s)}function uU(e){let t,i,r,s,a,n,o,l,h=1;do{for(i=e,e=null,a=null,n=0;i;){for(n++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),a?a.nextZ=s:e=s,s.prevZ=a,a=s;i=r}a.nextZ=null,h*=2}while(n>1);return e}function Nv(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function pU(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function dh(e,t,i,r,s,a,n,o){return(s-n)*(t-o)>=(e-n)*(a-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(a-o)>=(s-n)*(r-o)}function fU(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!mU(e,t)&&(fd(e,t)&&fd(t,e)&&gU(e,t)&&(hi(e.prev,e,t.prev)||hi(e,t.prev,t))||Zf(e,t)&&hi(e.prev,e,e.next)>0&&hi(t.prev,t,t.next)>0)}function hi(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Zf(e,t){return e.x===t.x&&e.y===t.y}function TM(e,t,i,r){let s=bu(hi(e,t,i)),a=bu(hi(e,t,r)),n=bu(hi(i,r,e)),o=bu(hi(i,r,t));return!!(s!==a&&n!==o||s===0&&xu(e,i,t)||a===0&&xu(e,r,t)||n===0&&xu(i,e,r)||o===0&&xu(i,t,r))}function xu(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function bu(e){return e>0?1:e<0?-1:0}function mU(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&TM(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function fd(e,t){return hi(e.prev,e,e.next)<0?hi(e,t,e.next)>=0&&hi(e,e.prev,t)>=0:hi(e,t,e.prev)<0||hi(e,e.next,t)<0}function gU(e,t){let i=e,r=!1,s=(e.x+t.x)/2,a=(e.y+t.y)/2;do i.y>a!=i.next.y>a&&i.next.y!==i.y&&s<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function PM(e,t){let i=new kv(e.i,e.x,e.y),r=new kv(t.i,t.x,t.y),s=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,a.next=r,r.prev=a,r}function jb(e,t,i,r){let s=new kv(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function md(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function kv(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function vU(e,t,i,r){let s=0;for(let a=t,n=i-r;a<i;a+=r)s+=(e[n]-e[a])*(e[a+1]+e[n+1]),n=a;return s}var DM=class{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return DM.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Gb(e),Hb(i,e);let a=e.length;t.forEach(Gb);for(let o=0;o<t.length;o++)r.push(a),a+=t[o].length,Hb(i,t[o]);let n=tU.triangulate(i,r);for(let o=0;o<n.length;o+=3)s.push(n.slice(o,o+3));return s}};function Gb(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Hb(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var IM=class extends Ky{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new IM(e.radius,e.detail)}},gh=class extends Ge{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:n},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(a+n,Math.PI),l=0,h=[],c=new M,d=new M,u=[],p=[],f=[],g=[];for(let m=0;m<=i;m++){let v=[],y=m/i,x=0;m==0&&a==0?x=.5/t:m==i&&o==Math.PI&&(x=-.5/t);for(let w=0;w<=t;w++){let _=w/t;c.x=-e*Math.cos(r+_*s)*Math.sin(a+y*n),c.y=e*Math.cos(a+y*n),c.z=e*Math.sin(r+_*s)*Math.sin(a+y*n),p.push(c.x,c.y,c.z),d.copy(c).normalize(),f.push(d.x,d.y,d.z),g.push(_+x,1-y),v.push(l++)}h.push(v)}for(let m=0;m<i;m++)for(let v=0;v<t;v++){let y=h[m][v+1],x=h[m][v],w=h[m+1][v],_=h[m+1][v+1];(m!==0||a>0)&&u.push(y,x,_),(m!==i-1||o<Math.PI)&&u.push(x,w,_)}this.setIndex(u),this.setAttribute("position",new Ie(p,3)),this.setAttribute("normal",new Ie(f,3)),this.setAttribute("uv",new Ie(g,2))}static fromJSON(e){return new gh(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},OM=class extends Ge{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);let a=[],n=[],o=[],l=[],h=new M,c=new M,d=new M;for(let u=0;u<=i;u++)for(let p=0;p<=r;p++){let f=p/r*s,g=u/i*Math.PI*2;c.x=(e+t*Math.cos(g))*Math.cos(f),c.y=(e+t*Math.cos(g))*Math.sin(f),c.z=t*Math.sin(g),n.push(c.x,c.y,c.z),h.x=e*Math.cos(f),h.y=e*Math.sin(f),d.subVectors(c,h).normalize(),o.push(d.x,d.y,d.z),l.push(p/r),l.push(u/i)}for(let u=1;u<=i;u++)for(let p=1;p<=r;p++){let f=(r+1)*u+p-1,g=(r+1)*(u-1)+p-1,m=(r+1)*(u-1)+p,v=(r+1)*u+p;a.push(f,g,v),a.push(g,m,v)}this.setIndex(a),this.setAttribute("position",new Ie(n,3)),this.setAttribute("normal",new Ie(o,3)),this.setAttribute("uv",new Ie(l,2))}static fromJSON(e){return new OM(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},RM=class extends Ge{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);let n=[],o=[],l=[],h=[],c=new M,d=new M,u=new M,p=new M,f=new M,g=new M,m=new M;for(let y=0;y<=i;++y){let x=y/i*s*Math.PI*2;v(x,s,a,e,u),v(x+.01,s,a,e,p),g.subVectors(p,u),m.addVectors(p,u),f.crossVectors(g,m),m.crossVectors(f,g),f.normalize(),m.normalize();for(let w=0;w<=r;++w){let _=w/r*Math.PI*2,b=-t*Math.cos(_),A=t*Math.sin(_);c.x=u.x+(b*m.x+A*f.x),c.y=u.y+(b*m.y+A*f.y),c.z=u.z+(b*m.z+A*f.z),o.push(c.x,c.y,c.z),d.subVectors(c,u).normalize(),l.push(d.x,d.y,d.z),h.push(y/i),h.push(w/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let w=(r+1)*(y-1)+(x-1),_=(r+1)*y+(x-1),b=(r+1)*y+x,A=(r+1)*(y-1)+x;n.push(w,_,A),n.push(_,b,A)}this.setIndex(n),this.setAttribute("position",new Ie(o,3)),this.setAttribute("normal",new Ie(l,3)),this.setAttribute("uv",new Ie(h,2));function v(y,x,w,_,b){let A=Math.cos(y),S=Math.sin(y),E=w/x*y,C=Math.cos(E);b.x=_*(2+C)*.5*A,b.y=_*(2+C)*S*.5,b.z=_*Math.sin(E)*.5}}static fromJSON(e){return new RM(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},yU=class extends Dt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};function Dn(e,t,i){return LM(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function wu(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function LM(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function xU(e){function t(s,a){return e[s]-e[a]}let i=e.length,r=new Array(i);for(let s=0;s!==i;++s)r[s]=s;return r.sort(t),r}function Wb(e,t,i){let r=e.length,s=new e.constructor(r);for(let a=0,n=0;n!==r;++a){let o=i[a]*t;for(let l=0;l!==t;++l)s[n++]=e[o+l]}return s}function zM(e,t,i,r){let s=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[s++];if(a===void 0)return;let n=a[r];if(n!==void 0)if(Array.isArray(n))do n=a[r],n!==void 0&&(t.push(a.time),i.push.apply(i,n)),a=e[s++];while(a!==void 0);else if(n.toArray!==void 0)do n=a[r],n!==void 0&&(t.push(a.time),n.toArray(i,i.length)),a=e[s++];while(a!==void 0);else do n=a[r],n!==void 0&&(t.push(a.time),i.push(n)),a=e[s++];while(a!==void 0)}var Kf=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let n=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===n)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){let n=t[1];e<n&&(i=2,s=n);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break t}a=i,i=0;break i}break e}for(;i<a;){let n=i+a>>>1;e<t[n]?a=n:i=n+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},bU=class extends Kf{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:lh,endingEnd:lh}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,a=e+1,n=r[s],o=r[a];if(n===void 0)switch(this.getSettings_().endingStart){case hh:s=e,n=2*t-i;break;case Vp:s=r.length-2,n=t+r[s]-r[s+1];break;default:s=e,n=i}if(o===void 0)switch(this.getSettings_().endingEnd){case hh:a=e,o=2*i-t;break;case Vp:a=1,o=i+r[1]-r[0];break;default:a=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-n),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this._offsetPrev,c=this._offsetNext,d=this._weightPrev,u=this._weightNext,p=(i-t)/(r-t),f=p*p,g=f*p,m=-d*g+2*d*f-d*p,v=(1+d)*g+(-1.5-2*d)*f+(-.5+d)*p+1,y=(-1-u)*g+(1.5+u)*f+.5*p,x=u*g-u*f;for(let w=0;w!==n;++w)s[w]=m*a[h+w]+v*a[l+w]+y*a[o+w]+x*a[c+w];return s}},BM=class extends Kf{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=(i-t)/(r-t),c=1-h;for(let d=0;d!==n;++d)s[d]=a[l+d]*c+a[o+d]*h;return s}},wU=class extends Kf{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Ia=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=wu(t,this.TimeBufferType),this.values=wu(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:wu(e.times,Array),values:wu(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new wU(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new BM(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new bU(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Np:t=this.InterpolantFactoryMethodDiscrete;break;case kp:t=this.InterpolantFactoryMethodLinear;break;case Dm:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Np;case this.InterpolantFactoryMethodLinear:return kp;case this.InterpolantFactoryMethodSmooth:return Dm}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);let n=this.getValueSize();this.times=Dn(i,s,a),this.values=Dn(this.values,s*n,a*n)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let n=0;n!==s;n++){let o=i[n];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,o),e=!1;break}if(a!==null&&a>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,o,a),e=!1;break}a=o}if(r!==void 0&&LM(r))for(let n=0,o=r.length;n!==o;++n){let l=r[n];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,l),e=!1;break}}return e}optimize(){let e=Dn(this.times),t=Dn(this.values),i=this.getValueSize(),r=this.getInterpolation()===Dm,s=e.length-1,a=1;for(let n=1;n<s;++n){let o=!1,l=e[n],h=e[n+1];if(l!==h&&(n!==1||l!==e[0]))if(r)o=!0;else{let c=n*i,d=c-i,u=c+i;for(let p=0;p!==i;++p){let f=t[c+p];if(f!==t[d+p]||f!==t[u+p]){o=!0;break}}}if(o){if(n!==a){e[a]=e[n];let c=n*i,d=a*i;for(let u=0;u!==i;++u)t[d+u]=t[c+u]}++a}}if(s>0){e[a]=e[s];for(let n=s*i,o=a*i,l=0;l!==i;++l)t[o+l]=t[n+l];++a}return a!==e.length?(this.times=Dn(e,0,a),this.values=Dn(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=Dn(this.times,0),t=Dn(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Ia.prototype.TimeBufferType=Float32Array;Ia.prototype.ValueBufferType=Float32Array;Ia.prototype.DefaultInterpolation=kp;var Xh=class extends Ia{};Xh.prototype.ValueTypeName="bool";Xh.prototype.ValueBufferType=Array;Xh.prototype.DefaultInterpolation=Np;Xh.prototype.InterpolantFactoryMethodLinear=void 0;Xh.prototype.InterpolantFactoryMethodSmooth=void 0;var FM=class extends Ia{};FM.prototype.ValueTypeName="color";var Xp=class extends Ia{};Xp.prototype.ValueTypeName="number";var _U=class extends Kf{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let h=l+n;l!==h;l+=4)lt.slerpFlat(s,0,a,l-n,a,l,o);return s}},Bd=class extends Ia{InterpolantFactoryMethodLinear(e){return new _U(this.times,this.values,this.getValueSize(),e)}};Bd.prototype.ValueTypeName="quaternion";Bd.prototype.DefaultInterpolation=kp;Bd.prototype.InterpolantFactoryMethodSmooth=void 0;var Yh=class extends Ia{};Yh.prototype.ValueTypeName="string";Yh.prototype.ValueBufferType=Array;Yh.prototype.DefaultInterpolation=Np;Yh.prototype.InterpolantFactoryMethodLinear=void 0;Yh.prototype.InterpolantFactoryMethodSmooth=void 0;var Yp=class extends Ia{};Yp.prototype.ValueTypeName="vector";var Vv=class{constructor(e,t=-1,i,r=ky){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=ws(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,n=i.length;a!==n;++a)t.push(AU(i[a]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(Ia.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,a=[];for(let n=0;n<s;n++){let o=[],l=[];o.push((n+s-1)%s,n,(n+1)%s),l.push(0,1,0);let h=xU(o);o=Wb(o,1,h),l=Wb(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),a.push(new Xp(".morphTargetInfluences["+t[n].name+"]",o,l).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let n=0,o=e.length;n<o;n++){let l=e[n],h=l.name.match(s);if(h&&h.length>1){let c=h[1],d=r[c];d||(r[c]=d=[]),d.push(l)}}let a=[];for(let n in r)a.push(this.CreateFromMorphTargetSequence(n,r[n],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,c,d,u,p){if(d.length!==0){let f=[],g=[];zM(d,f,g,u),f.length!==0&&p.push(new h(c,f,g))}},r=[],s=e.name||"default",a=e.fps||30,n=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let c=l[h].keys;if(!(!c||c.length===0))if(c[0].morphTargets){let d={},u;for(u=0;u<c.length;u++)if(c[u].morphTargets)for(let p=0;p<c[u].morphTargets.length;p++)d[c[u].morphTargets[p]]=-1;for(let p in d){let f=[],g=[];for(let m=0;m!==c[u].morphTargets.length;++m){let v=c[u];f.push(v.time),g.push(v.morphTarget===p?1:0)}r.push(new Xp(".morphTargetInfluence["+p+"]",f,g))}o=d.length*a}else{let d=".bones["+t[h].name+"]";i(Yp,d+".position",c,"pos",r),i(Bd,d+".quaternion",c,"rot",r),i(Yp,d+".scale",c,"scl",r)}}return r.length===0?null:new this(s,o,r,n)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function SU(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Xp;case"vector":case"vector2":case"vector3":case"vector4":return Yp;case"color":return FM;case"quaternion":return Bd;case"bool":case"boolean":return Xh;case"string":return Yh}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function AU(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=SU(e.type);if(e.times===void 0){let i=[],r=[];zM(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var Qp={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},UM=class{constructor(e,t,i){let r=this,s=!1,a=0,n=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){n++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,n),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,n),a===n&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,c){return l.push(h,c),this},this.removeHandler=function(h){let c=l.indexOf(h);return c!==-1&&l.splice(c,2),this},this.getHandler=function(h){for(let c=0,d=l.length;c<d;c+=2){let u=l[c],p=l[c+1];if(u.global&&(u.lastIndex=0),u.test(h))return p}return null}}},MU=new UM,Fd=class{constructor(e){this.manager=e!==void 0?e:MU,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},Va={},EU=class extends Error{constructor(e,t){super(e),this.response=t}},jv=class extends Fd{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=Qp.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Va[e]!==void 0){Va[e].push({onLoad:t,onProgress:i,onError:r});return}Va[e]=[],Va[e].push({onLoad:t,onProgress:i,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),n=this.mimeType,o=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=Va[e],c=l.body.getReader(),d=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),u=d?parseInt(d):0,p=u!==0,f=0,g=new ReadableStream({start(m){v();function v(){c.read().then(({done:y,value:x})=>{if(y)m.close();else{f+=x.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:u});for(let _=0,b=h.length;_<b;_++){let A=h[_];A.onProgress&&A.onProgress(w)}m.enqueue(x),v()}})}}});return new Response(g)}else throw new EU(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,n));case"json":return l.json();default:if(n===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(n),c=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(c);return l.arrayBuffer().then(u=>d.decode(u))}}}).then(l=>{Qp.add(e,l);let h=Va[e];delete Va[e];for(let c=0,d=h.length;c<d;c++){let u=h[c];u.onLoad&&u.onLoad(l)}}).catch(l=>{let h=Va[e];if(h===void 0)throw this.manager.itemError(e),l;delete Va[e];for(let c=0,d=h.length;c<d;c++){let u=h[c];u.onError&&u.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},CU=class extends Fd{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,a=Qp.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;let n=dd("img");function o(){h(),Qp.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(c){h(),r&&r(c),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){n.removeEventListener("load",o,!1),n.removeEventListener("error",l,!1)}return n.addEventListener("load",o,!1),n.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(n.crossOrigin=this.crossOrigin),s.manager.itemStart(e),n.src=e,n}},TU=class extends Fd{constructor(e){super(e)}load(e,t,i,r){let s=new ci,a=new CU(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(n){s.image=n,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},Ud=class extends kt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new et(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},PU=class extends Ud{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new et(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},ng=new we,qb=new M,Xb=new M,Jy=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new j(512,512),this.map=null,this.mapPass=null,this.matrix=new we,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Hy,this._frameExtents=new j(1,1),this._viewportCount=1,this._viewports=[new ct(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;qb.setFromMatrixPosition(e.matrixWorld),t.position.copy(qb),Xb.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Xb),t.updateMatrixWorld(),ng.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ng),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(ng)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},DU=class extends Jy{constructor(){super(new _r(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=cd*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},IU=class extends Ud{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.target=new kt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new DU}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Yb=new we,mc=new M,og=new M,OU=class extends Jy{constructor(){super(new _r(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new j(4,2),this._viewportCount=6,this._viewports=[new ct(2,1,1,1),new ct(0,1,1,1),new ct(3,1,1,1),new ct(1,1,1,1),new ct(3,0,1,1),new ct(1,0,1,1)],this._cubeDirections=[new M(1,0,0),new M(-1,0,0),new M(0,0,1),new M(0,0,-1),new M(0,1,0),new M(0,-1,0)],this._cubeUps=[new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,0,1),new M(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),mc.setFromMatrixPosition(e.matrixWorld),i.position.copy(mc),og.copy(i.position),og.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(og),i.updateMatrixWorld(),r.makeTranslation(-mc.x,-mc.y,-mc.z),Yb.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Yb)}},RU=class extends Ud{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new OU}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},LU=class extends Jy{constructor(){super(new Xf(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},zU=class extends Ud{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(kt.DEFAULT_UP),this.updateMatrix(),this.target=new kt,this.shadow=new LU}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},NM=class extends Ge{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},kM=class extends Fd{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new jv(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(n){try{t(s.parse(JSON.parse(n)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(d,u){if(t[u]!==void 0)return t[u];let p=d.interleavedBuffers[u],f=s(d,p.buffer),g=Kd(p.type,f),m=new UF(g,p.stride);return m.uuid=p.uuid,t[u]=m,m}function s(d,u){if(i[u]!==void 0)return i[u];let p=d.arrayBuffers[u],f=new Uint32Array(p).buffer;return i[u]=f,f}let a=e.isInstancedBufferGeometry?new NM:new Ge,n=e.data.index;if(n!==void 0){let d=Kd(n.type,n.array);a.setIndex(new tt(d,1))}let o=e.data.attributes;for(let d in o){let u=o[d],p;if(u.isInterleavedBufferAttribute){let f=r(e.data,u.data);p=new Uv(f,u.itemSize,u.offset,u.normalized)}else{let f=Kd(u.type,u.array),g=u.isInstancedBufferAttribute?ud:tt;p=new g(f,u.itemSize,u.normalized)}u.name!==void 0&&(p.name=u.name),u.usage!==void 0&&p.setUsage(u.usage),u.updateRange!==void 0&&(p.updateRange.offset=u.updateRange.offset,p.updateRange.count=u.updateRange.count),a.setAttribute(d,p)}let l=e.data.morphAttributes;if(l)for(let d in l){let u=l[d],p=[];for(let f=0,g=u.length;f<g;f++){let m=u[f],v;if(m.isInterleavedBufferAttribute){let y=r(e.data,m.data);v=new Uv(y,m.itemSize,m.offset,m.normalized)}else{let y=Kd(m.type,m.array);v=new tt(y,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.name),p.push(v)}a.morphAttributes[d]=p}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let d=0,u=h.length;d!==u;++d){let p=h[d];a.addGroup(p.start,p.count,p.materialIndex)}let c=e.data.boundingSphere;if(c!==void 0){let d=new M;c.center!==void 0&&d.fromArray(c.center),a.boundingSphere=new $r(d,c.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},BU=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Qb(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=Qb();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function Qb(){return(typeof performance>"u"?Date:performance).now()}var FU=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,a=this.cumulativeWeight;if(a===0){for(let n=0;n!==r;++n)i[s+n]=i[n];a=t}else{a+=t;let n=t/a;this._mixBufferRegion(i,s,0,n,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){lt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let a=this._workIndex*s;lt.multiplyQuaternionsFlat(e,a,e,t,e,i),lt.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){let a=1-r;for(let n=0;n!==s;++n){let o=t+n;e[o]=e[o]*a+e[i+n]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){let n=t+a;e[n]=e[n]+e[i+a]*r}}},$y="\\[\\]\\.:\\/",UU=new RegExp("["+$y+"]","g"),e1="[^"+$y+"]",NU="[^"+$y.replace("\\.","")+"]",kU=/((?:WC+[\/:])*)/.source.replace("WC",e1),VU=/(WCOD+)?/.source.replace("WCOD",NU),jU=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",e1),GU=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",e1),HU=new RegExp("^"+kU+VU+jU+GU+"$"),WU=["material","materials","bones","map"],qU=class{constructor(e,t,i){let r=i||Xt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Xt=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Xt.parseTrackName(t),this.node=Xt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Xt.Composite(e,t,i):new Xt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(UU,"")}static parseTrackName(e){let t=HU.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);WU.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let a=0;a<s.length;a++){let n=s[a];if(n.name===t||n.uuid===t)return n;let o=i(n.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=Xt.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let a=e[r];if(a===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let n=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?n=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(n=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][n]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Xt.Composite=qU;Xt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Xt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Xt.prototype.GetterByBindingType=[Xt.prototype._getValue_direct,Xt.prototype._getValue_array,Xt.prototype._getValue_arrayElement,Xt.prototype._getValue_toArray];Xt.prototype.SetterByBindingTypeAndVersioning=[[Xt.prototype._setValue_direct,Xt.prototype._setValue_direct_setNeedsUpdate,Xt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Xt.prototype._setValue_array,Xt.prototype._setValue_array_setNeedsUpdate,Xt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Xt.prototype._setValue_arrayElement,Xt.prototype._setValue_arrayElement_setNeedsUpdate,Xt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Xt.prototype._setValue_fromArray,Xt.prototype._setValue_fromArray_setNeedsUpdate,Xt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var XU=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,a=s.length,n=new Array(a),o={endingStart:lh,endingEnd:lh};for(let l=0;l!==a;++l){let h=s[l].createInterpolant(null);n[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=n,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=rM,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,a=s/r,n=r/s;e.warp(1,a,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,a=this.timeScale,n=this._timeScaleInterpolant;n===null&&(n=r._lendControlInterpolant(),this._timeScaleInterpolant=n);let o=n.parameterPositions,l=n.sampleValues;return o[0]=s,o[1]=s+i,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let o=(e-s)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let a=this._updateTime(t),n=this._updateWeight(e);if(n>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case _R:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(a),l[h].accumulateAdditive(n);break;case ky:default:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(a),l[h].accumulate(r,n)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,a=i===Ny;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===iM){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,s+=Math.abs(n);let o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=hh,r.endingEnd=hh):(e?r.endingStart=this.zeroSlopeAtStart?hh:lh:r.endingStart=Vp,t?r.endingEnd=this.zeroSlopeAtEnd?hh:lh:r.endingEnd=Vp)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let n=a.parameterPositions,o=a.sampleValues;return n[0]=s,o[0]=t,n[1]=s+e,o[1]=i,this}},YU=new Float32Array(1),QU=class extends yr{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let c=0;c!==s;++c){let d=r[c],u=d.name,p=h[u];if(p!==void 0)++p.referenceCount,a[c]=p;else{if(p=a[c],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,u));continue}let f=t&&t._propertyBindings[c].binding.parsedPath;p=new FU(Xt.create(i,u,f),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,u),a[c]=p}n[c].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{let n=a.knownActions;e._byClipCacheIndex=n.length,n.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,a=this._actionsByClip,n=a[s],o=n.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let c=n.actionByRoot,d=(e._localRoot||this._root).uuid;delete c[d],o.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,n=a[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete n[s],Object.keys(n).length===0&&delete a[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new BM(new Float32Array(2),new Float32Array(2),1,YU),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,a=typeof e=="string"?Vv.findByName(r,e):e,n=a!==null?a.uuid:e,o=this._actionsByClip[n],l=null;if(i===void 0&&(a!==null?i=a.blendMode:i=ky),o!==void 0){let c=o.actionByRoot[s];if(c!==void 0&&c.blendMode===i)return c;l=o.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;let h=new XU(this,a,t,i);return this._bindAction(h,l),this._addInactiveAction(h,n,s),h}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?Vv.findByName(i,e):e,a=s?s.uuid:e,n=this._actionsByClip[a];return n!==void 0&&n.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,a);let n=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)n[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let a=s.knownActions;for(let n=0,o=a.length;n!==o;++n){let l=a[n];this._deactivateAction(l);let h=l._cacheIndex,c=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,c._cacheIndex=h,t[h]=c,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let a in i){let n=i[a].actionByRoot,o=n[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let a in s){let n=s[a];n.restoreOriginalState(),this._removeInactiveBinding(n)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},ye=class{constructor(e){this.value=e}clone(){return new ye(this.value.clone===void 0?this.value:this.value.clone())}},VM=class{constructor(e,t,i=0,r=1/0){this.ray=new Hh(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new jy,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return Gv(e,this,i,t),i.sort(Zb),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Gv(e[r],this,i,t);return i.sort(Zb),i}};function Zb(e,t){return e.distance-t.distance}function Gv(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let a=0,n=s.length;a<n;a++)Gv(s[a],t,i,!0)}}var Kb=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Ti(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Jb=new j,t1=class{constructor(e=new j(1/0,1/0),t=new j(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Jb.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Jb.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},$b=new M,_u=new M,_s=class{constructor(e=new M,t=new M){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){$b.subVectors(e,this.start),_u.subVectors(this.end,this.start);let i=_u.dot(_u),r=_u.dot($b)/i;return t&&(r=Ti(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},ew=new M,ZU=class extends kt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Ge,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,n=1,o=32;a<o;a++,n++){let l=a/o*Math.PI*2,h=n/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new Ie(r,3));let s=new wo({fog:!1,toneMapped:!1});this.cone=new zd(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),ew.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(ew),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},KU=class extends Jt{constructor(e,t,i){let r=new gh(t,4,2),s=new gn({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},tw=new M,Su=new M,iw=new M,JU=class extends kt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new Ge;r.setAttribute("position",new Ie([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new wo({fog:!1,toneMapped:!1});this.lightPlane=new Hp(r,s),this.add(this.lightPlane),r=new Ge,r.setAttribute("position",new Ie([0,0,0,0,0,1],3)),this.targetLine=new Hp(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),tw.setFromMatrixPosition(this.light.matrixWorld),Su.setFromMatrixPosition(this.light.target.matrixWorld),iw.subVectors(Su,tw),this.lightPlane.lookAt(Su),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Su),this.targetLine.scale.z=iw.length()}},Au=new M,di=new bo,Zp=class extends zd{constructor(e){let t=new Ge,i=new wo({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};n("n1","n2"),n("n2","n4"),n("n4","n3"),n("n3","n1"),n("f1","f2"),n("f2","f4"),n("f4","f3"),n("f3","f1"),n("n1","f1"),n("n2","f2"),n("n3","f3"),n("n4","f4"),n("p","n1"),n("p","n2"),n("p","n3"),n("p","n4"),n("u1","u2"),n("u2","u3"),n("u3","u1"),n("c","t"),n("p","c"),n("cn1","cn2"),n("cn3","cn4"),n("cf1","cf2"),n("cf3","cf4");function n(p,f){o(p),o(f)}function o(p){r.push(0,0,0),s.push(0,0,0),a[p]===void 0&&(a[p]=[]),a[p].push(r.length/3-1)}t.setAttribute("position",new Ie(r,3)),t.setAttribute("color",new Ie(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();let l=new et(16755200),h=new et(16711680),c=new et(43775),d=new et(16777215),u=new et(3355443);this.setColors(l,h,c,d,u)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;di.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),yi("c",t,e,di,0,0,-1),yi("t",t,e,di,0,0,1),yi("n1",t,e,di,-i,-r,-1),yi("n2",t,e,di,i,-r,-1),yi("n3",t,e,di,-i,r,-1),yi("n4",t,e,di,i,r,-1),yi("f1",t,e,di,-i,-r,1),yi("f2",t,e,di,i,-r,1),yi("f3",t,e,di,-i,r,1),yi("f4",t,e,di,i,r,1),yi("u1",t,e,di,i*.7,r*1.1,-1),yi("u2",t,e,di,-i*.7,r*1.1,-1),yi("u3",t,e,di,0,r*2,-1),yi("cf1",t,e,di,-i,0,1),yi("cf2",t,e,di,i,0,1),yi("cf3",t,e,di,0,-r,1),yi("cf4",t,e,di,0,r,1),yi("cn1",t,e,di,-i,0,-1),yi("cn2",t,e,di,i,0,-1),yi("cn3",t,e,di,0,-r,-1),yi("cn4",t,e,di,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function yi(e,t,i,r,s,a,n){Au.set(s,a,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,c=o.length;h<c;h++)l.setXYZ(o[h],Au.x,Au.y,Au.z)}}var Kp=class extends zd{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ge;s.setIndex(new tt(i,1)),s.setAttribute("position",new Ie(r,3)),super(s,new wo({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},$U=class extends zd{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ge;r.setAttribute("position",new Ie(t,3)),r.setAttribute("color",new Ie(i,3));let s=new wo({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new et,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},sn=eN();function eN(){let e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),r=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){let h=l-127;h<-27?(r[l]=0,r[l|256]=32768,s[l]=24,s[l|256]=24):h<-14?(r[l]=1024>>-h-14,r[l|256]=1024>>-h-14|32768,s[l]=-h-1,s[l|256]=-h-1):h<=15?(r[l]=h+15<<10,r[l|256]=h+15<<10|32768,s[l]=13,s[l|256]=13):h<128?(r[l]=31744,r[l|256]=64512,s[l]=24,s[l|256]=24):(r[l]=31744,r[l|256]=64512,s[l]=13,s[l|256]=13)}let a=new Uint32Array(2048),n=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,c=0;for(;!(h&8388608);)h<<=1,c-=8388608;h&=-8388609,c+=947912704,a[l]=h|c}for(let l=1024;l<2048;++l)a[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)n[l]=l<<23;n[31]=1199570944,n[32]=2147483648;for(let l=33;l<63;++l)n[l]=2147483648+(l-32<<23);n[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:i,baseTable:r,shiftTable:s,mantissaTable:a,exponentTable:n,offsetTable:o}}function tN(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Ti(e,-65504,65504),sn.floatView[0]=e;let t=sn.uint32View[0],i=t>>23&511;return sn.baseTable[i]+((t&8388607)>>sn.shiftTable[i])}function iN(e){let t=e>>10;return sn.uint32View[0]=sn.mantissaTable[sn.offsetTable[t]+(e&1023)]+sn.exponentTable[t],sn.floatView[0]}var rN=Object.freeze({__proto__:null,fromHalfFloat:iN,toHalfFloat:tN});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Gh}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Gh);var gc=".",i1=Symbol("target"),jM=Symbol("unsubscribe");function Hv(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function sN(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var va=Array.isArray;function r1(e){return typeof e=="symbol"}var aN={after:(e,t)=>va(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>va(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=gc),r1(t)?e+t.toString():e+t):e,initial:e=>{if(va(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(gc);return t===-1?"":e.slice(0,t)},last:e=>{if(va(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(gc);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(va(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(gc);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(gc,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},ms=aN;function nN(e){return typeof e=="object"&&typeof e.next=="function"}function oN(e,t,i,r,s){let a=e.next;if(t.name==="entries")e.next=function(){let n=a.call(this);return n.done===!1&&(n.value[0]=s(n.value[0],t,n.value[0],r),n.value[1]=s(n.value[1],t,n.value[0],r)),n};else if(t.name==="values"){let n=i[i1].keys();e.next=function(){let o=a.call(this);return o.done===!1&&(o.value=s(o.value,t,n.next().value,r)),o}}else e.next=function(){let n=a.call(this);return n.done===!1&&(n.value=s(n.value,t,n.value,r)),n};return e}function rw(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&r1(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var lN=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let s=e[r],a=s||e;this._pathCache.set(a,t);let n=this._proxyCache.get(a);return n===void 0&&(n=s===void 0?new Proxy(e,i):e,this._proxyCache.set(a,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,ms.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,s){if(!this._equals(s,i)||!(t in e)){let a=this._getOwnPropertyDescriptor(e,t);return a!==void 0&&"set"in a?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Wv(e){return toString.call(e)==="[object Object]"}function Mu(){return!0}function Bl(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var GM=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),hN=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),HM={push:Mu,pop:Mu,shift:Mu,unshift:Mu,copyWithin:Bl,reverse:Bl,sort:Bl,splice:Bl,flat:Bl,fill:Bl},cN=new Set([...GM,...hN,...Object.keys(HM)]);function Eu(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var WM=["keys","values","entries"],qM=new Set(["has","toString"]),XM={add:Eu,clear:Eu,delete:Eu,forEach:Eu},dN=new Set([...qM,...Object.keys(XM),...WM]);function Cu(e,t){if(e.size!==t.size)return!0;let i;for(let[r,s]of e)if(i=t.get(r),i!==s||i===void 0&&!t.has(r))return!0;return!1}var uN=new Set([...qM,"get"]),YM={set:Cu,clear:Cu,delete:Cu,forEach:Cu},pN=new Set([...uN,...Object.keys(YM),...WM]),co=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return GM.has(e)}_shallowClone(e){let t=e;if(Wv(e))t={...e};else if(va(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(va(r)?this._onIsChanged=HM[t]:r instanceof Set?this._onIsChanged=XM[t]:r instanceof Map&&(this._onIsChanged=YM[t]),r):i}update(e,t,i){let r=ms.after(e,this._path);if(t!=="length"){let s=this.clone;ms.walk(r,a=>{s&&s[a]&&(this._clonedCache.has(s[a])||(s[a]=this._shallowClone(s[a])),s=s[a])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),s&&s[t]&&(s[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],ms.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},sw=class extends co{static isHandledMethod(e){return cN.has(e)}},fN=class extends co{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},aw=class extends co{static isHandledMethod(e){return dN.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},nw=class extends co{static isHandledMethod(e){return pN.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},mN=class extends co{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},gN=class extends co{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},th=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return Wv(e)||va(e)||Hv(e)}static isHandledMethod(e,t){return Wv(e)?co.isHandledMethod(t):va(e)?sw.isHandledMethod(t):e instanceof Set?aw.isHandledMethod(t):e instanceof Map?nw.isHandledMethod(t):Hv(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=co;va(e)?r=sw:e instanceof Date?r=fN:e instanceof Set?r=aw:e instanceof Map?r=nw:e instanceof WeakSet?r=mN:e instanceof WeakMap&&(r=gN),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,s=th.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},vN={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},s1=(e,t,i={})=>{i={...vN,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:a,ignoreDetached:n,details:o}=i,l=new lN(s),h=typeof i.onValidate=="function",c=new th(h),d=(y,x,w,_,b)=>!h||c.isCloning||i.onValidate(ms.concat(l.getPath(y),x),w,_,b)===!0,u=(y,x,w,_)=>{!rw(l,i,x)&&!(n&&l.isDetached(y,e))&&p(l.getPath(y),x,w,_)},p=(y,x,w,_,b)=>{c.isCloning?c.update(y,x,_):t(ms.concat(y,x),w,_,b)},f=y=>y&&(y[r]||y),g=(y,x,w,_)=>sN(y)||w==="constructor"||a&&!th.isHandledMethod(x,w)||rw(l,i,w)||l.isGetInvariant(x,w)||n&&l.isDetached(x,e)?y:(_===void 0&&(_=l.getPath(x)),l.getProxy(y,ms.concat(_,w),m,r)),m={get(y,x,w){if(r1(x)){if(x===r||x===i1)return y;if(x===jM&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let _=Hv(y)?Reflect.get(y,x):Reflect.get(y,x,w);return g(_,y,x)},set(y,x,w,_){w=f(w);let b=y[r]||y,A=b[x];if(s(A,w)&&x in y)return!0;let S=d(y,x,w,A);return S&&l.setProperty(b,x,w,_,A)?(u(y,x,y[x],A),!0):!S},defineProperty(y,x,w){if(!l.isSameDescriptor(w,y,x)){let _=y[x];d(y,x,w.value,_)&&l.defineProperty(y,x,w,_)&&u(y,x,w.value,_)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let w=Reflect.get(y,x),_=d(y,x,void 0,w);return _&&l.deleteProperty(y,x,w)?(u(y,x,void 0,w),!0):!_},apply(y,x,w){let _=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,_,w);if((o===!1||o!==!0&&!o.includes(y.name))&&th.isHandledType(_)){let b=ms.initial(l.getPath(y)),A=th.isHandledMethod(_,y.name);c.start(_,b,w);let S=Reflect.apply(y,c.preferredThisArg(y,x,_),A?w.map(T=>f(T)):w),E=c.isChanged(_,s),C=c.stop();if(th.isHandledType(S)&&A&&(x instanceof Map&&y.name==="get"&&(b=ms.concat(b,w[0])),S=l.getProxy(S,b,m)),E){let T={name:y.name,args:w,result:S},D=c.isCloning?ms.initial(b):b,O=c.isCloning?ms.last(b):"";d(ms.get(e,D),O,_,C,T)?p(D,O,_,C,T):c.undo(_)}return(x instanceof Map||x instanceof Set)&&nN(S)?oN(S,y,x,b,g):S}return Reflect.apply(y,x,w)}},v=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};s1.target=e=>e&&e[i1]||e;s1.unsubscribe=e=>e[jM]||e;var ow=s1,yN=typeof global=="object"&&global&&global.Object===Object&&global,QM=yN,xN=typeof self=="object"&&self&&self.Object===Object&&self,bN=QM||xN||Function("return this")(),Qs=bN,wN=Qs.Symbol,As=wN,ZM=Object.prototype,_N=ZM.hasOwnProperty,SN=ZM.toString,vc=As?As.toStringTag:void 0;function AN(e){var t=_N.call(e,vc),i=e[vc];try{e[vc]=void 0;var r=!0}catch{}var s=SN.call(e);return r&&(t?e[vc]=i:delete e[vc]),s}var MN=AN,EN=Object.prototype,CN=EN.toString;function TN(e){return CN.call(e)}var PN=TN,DN="[object Null]",IN="[object Undefined]",lw=As?As.toStringTag:void 0;function ON(e){return e==null?e===void 0?IN:DN:lw&&lw in Object(e)?MN(e):PN(e)}var ml=ON;function RN(e){return e!=null&&typeof e=="object"}var vn=RN,LN="[object Symbol]";function zN(e){return typeof e=="symbol"||vn(e)&&ml(e)==LN}var Nd=zN;function BN(e,t){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i<r;)s[i]=t(e[i],i,e);return s}var KM=BN,FN=Array.isArray,Ca=FN,UN=1/0,hw=As?As.prototype:void 0,cw=hw?hw.toString:void 0;function JM(e){if(typeof e=="string")return e;if(Ca(e))return KM(e,JM)+"";if(Nd(e))return cw?cw.call(e):"";var t=e+"";return t=="0"&&1/e==-UN?"-0":t}var $M=JM,NN=/\s/;function kN(e){for(var t=e.length;t--&&NN.test(e.charAt(t)););return t}var eE=kN,VN=/^\s+/;function jN(e){return e&&e.slice(0,eE(e)+1).replace(VN,"")}var GN=jN;function HN(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Ys=HN,dw=NaN,WN=/^[-+]0x[0-9a-f]+$/i,qN=/^0b[01]+$/i,XN=/^0o[0-7]+$/i,YN=parseInt;function QN(e){if(typeof e=="number")return e;if(Nd(e))return dw;if(Ys(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ys(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=GN(e);var i=qN.test(e);return i||XN.test(e)?YN(e.slice(2),i?2:8):WN.test(e)?dw:+e}var uw=QN;function ZN(e){return e}var tE=ZN,KN="[object AsyncFunction]",JN="[object Function]",$N="[object GeneratorFunction]",ek="[object Proxy]";function tk(e){if(!Ys(e))return!1;var t=ml(e);return t==JN||t==$N||t==KN||t==ek}var iE=tk,ik=Qs["__core-js_shared__"],lg=ik,pw=function(){var e=/[^.]+$/.exec(lg&&lg.keys&&lg.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function rk(e){return!!pw&&pw in e}var sk=rk,ak=Function.prototype,nk=ak.toString;function ok(e){if(e!=null){try{return nk.call(e)}catch{}try{return e+""}catch{}}return""}var gl=ok,lk=/[\\^$.*+?()[\]{}|]/g,hk=/^\[object .+?Constructor\]$/,ck=Function.prototype,dk=Object.prototype,uk=ck.toString,pk=dk.hasOwnProperty,fk=RegExp("^"+uk.call(pk).replace(lk,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function mk(e){if(!Ys(e)||sk(e))return!1;var t=iE(e)?fk:hk;return t.test(gl(e))}var gk=mk;function vk(e,t){return e==null?void 0:e[t]}var yk=vk;function xk(e,t){var i=yk(e,t);return gk(i)?i:void 0}var vl=xk,bk=vl(Qs,"WeakMap"),qv=bk,fw=Object.create,wk=function(){function e(){}return function(t){if(!Ys(t))return{};if(fw)return fw(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),_k=wk;function Sk(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var Ak=Sk;function Mk(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var Ek=Mk,Ck=800,Tk=16,Pk=Date.now;function Dk(e){var t=0,i=0;return function(){var r=Pk(),s=Tk-(r-i);if(i=r,s>0){if(++t>=Ck)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Ik=Dk;function Ok(e){return function(){return e}}var Rk=Ok,Lk=function(){try{var e=vl(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Jp=Lk,zk=Jp?function(e,t){return Jp(e,"toString",{configurable:!0,enumerable:!1,value:Rk(t),writable:!0})}:tE,Bk=zk,Fk=Ik(Bk),Uk=Fk;function Nk(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var kk=Nk;function Vk(e,t,i,r){for(var s=e.length,a=i+(r?1:-1);r?a--:++a<s;)if(t(e[a],a,e))return a;return-1}var jk=Vk;function Gk(e){return e!==e}var Hk=Gk;function Wk(e,t,i){for(var r=i-1,s=e.length;++r<s;)if(e[r]===t)return r;return-1}var qk=Wk;function Xk(e,t,i){return t===t?qk(e,t,i):jk(e,Hk,i)}var Yk=Xk,Qk=9007199254740991,Zk=/^(?:0|[1-9]\d*)$/;function Kk(e,t){var i=typeof e;return t=t??Qk,!!t&&(i=="number"||i!="symbol"&&Zk.test(e))&&e>-1&&e%1==0&&e<t}var a1=Kk;function Jk(e,t,i){t=="__proto__"&&Jp?Jp(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var rE=Jk;function $k(e,t){return e===t||e!==e&&t!==t}var n1=$k,e5=Object.prototype,t5=e5.hasOwnProperty;function i5(e,t,i){var r=e[t];(!(t5.call(e,t)&&n1(r,i))||i===void 0&&!(t in e))&&rE(e,t,i)}var o1=i5;function r5(e,t,i,r){var s=!i;i||(i={});for(var a=-1,n=t.length;++a<n;){var o=t[a],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?rE(i,o,l):o1(i,o,l)}return i}var kd=r5,mw=Math.max;function s5(e,t,i){return t=mw(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,a=mw(r.length-t,0),n=Array(a);++s<a;)n[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(n),Ak(e,this,o)}}var a5=s5,n5=9007199254740991;function o5(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=n5}var l1=o5;function l5(e){return e!=null&&l1(e.length)&&!iE(e)}var sE=l5,h5=Object.prototype;function c5(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||h5;return e===i}var h1=c5;function d5(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var u5=d5,p5="[object Arguments]";function f5(e){return vn(e)&&ml(e)==p5}var gw=f5,aE=Object.prototype,m5=aE.hasOwnProperty,g5=aE.propertyIsEnumerable,v5=gw(function(){return arguments}())?gw:function(e){return vn(e)&&m5.call(e,"callee")&&!g5.call(e,"callee")},c1=v5;function y5(){return!1}var x5=y5,nE=typeof exports=="object"&&exports&&!exports.nodeType&&exports,vw=nE&&typeof module=="object"&&module&&!module.nodeType&&module,b5=vw&&vw.exports===nE,yw=b5?Qs.Buffer:void 0,w5=yw?yw.isBuffer:void 0,_5=w5||x5,$p=_5,S5="[object Arguments]",A5="[object Array]",M5="[object Boolean]",E5="[object Date]",C5="[object Error]",T5="[object Function]",P5="[object Map]",D5="[object Number]",I5="[object Object]",O5="[object RegExp]",R5="[object Set]",L5="[object String]",z5="[object WeakMap]",B5="[object ArrayBuffer]",F5="[object DataView]",U5="[object Float32Array]",N5="[object Float64Array]",k5="[object Int8Array]",V5="[object Int16Array]",j5="[object Int32Array]",G5="[object Uint8Array]",H5="[object Uint8ClampedArray]",W5="[object Uint16Array]",q5="[object Uint32Array]",si={};si[U5]=si[N5]=si[k5]=si[V5]=si[j5]=si[G5]=si[H5]=si[W5]=si[q5]=!0;si[S5]=si[A5]=si[B5]=si[M5]=si[F5]=si[E5]=si[C5]=si[T5]=si[P5]=si[D5]=si[I5]=si[O5]=si[R5]=si[L5]=si[z5]=!1;function X5(e){return vn(e)&&l1(e.length)&&!!si[ml(e)]}var Y5=X5;function Q5(e){return function(t){return e(t)}}var d1=Q5,oE=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Kc=oE&&typeof module=="object"&&module&&!module.nodeType&&module,Z5=Kc&&Kc.exports===oE,hg=Z5&&QM.process,K5=function(){try{var e=Kc&&Kc.require&&Kc.require("util").types;return e||hg&&hg.binding&&hg.binding("util")}catch{}}(),Dh=K5,xw=Dh&&Dh.isTypedArray,J5=xw?d1(xw):Y5,lE=J5,$5=Object.prototype,eV=$5.hasOwnProperty;function tV(e,t){var i=Ca(e),r=!i&&c1(e),s=!i&&!r&&$p(e),a=!i&&!r&&!s&&lE(e),n=i||r||s||a,o=n?u5(e.length,String):[],l=o.length;for(var h in e)(t||eV.call(e,h))&&!(n&&(h=="length"||s&&(h=="offset"||h=="parent")||a&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||a1(h,l)))&&o.push(h);return o}var hE=tV;function iV(e,t){return function(i){return e(t(i))}}var cE=iV,rV=cE(Object.keys,Object),sV=rV,aV=Object.prototype,nV=aV.hasOwnProperty;function oV(e){if(!h1(e))return sV(e);var t=[];for(var i in Object(e))nV.call(e,i)&&i!="constructor"&&t.push(i);return t}var lV=oV;function hV(e){return sE(e)?hE(e):lV(e)}var u1=hV;function cV(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var dV=cV,uV=Object.prototype,pV=uV.hasOwnProperty;function fV(e){if(!Ys(e))return dV(e);var t=h1(e),i=[];for(var r in e)r=="constructor"&&(t||!pV.call(e,r))||i.push(r);return i}var mV=fV;function gV(e){return sE(e)?hE(e,!0):mV(e)}var Ho=gV,vV=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yV=/^\w*$/;function xV(e,t){if(Ca(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Nd(e)?!0:yV.test(e)||!vV.test(e)||t!=null&&e in Object(t)}var bV=xV,wV=vl(Object,"create"),gd=wV;function _V(){this.__data__=gd?gd(null):{},this.size=0}var SV=_V;function AV(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var MV=AV,EV="__lodash_hash_undefined__",CV=Object.prototype,TV=CV.hasOwnProperty;function PV(e){var t=this.__data__;if(gd){var i=t[e];return i===EV?void 0:i}return TV.call(t,e)?t[e]:void 0}var DV=PV,IV=Object.prototype,OV=IV.hasOwnProperty;function RV(e){var t=this.__data__;return gd?t[e]!==void 0:OV.call(t,e)}var LV=RV,zV="__lodash_hash_undefined__";function BV(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=gd&&t===void 0?zV:t,this}var FV=BV;function Qh(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Qh.prototype.clear=SV;Qh.prototype.delete=MV;Qh.prototype.get=DV;Qh.prototype.has=LV;Qh.prototype.set=FV;var bw=Qh;function UV(){this.__data__=[],this.size=0}var NV=UV;function kV(e,t){for(var i=e.length;i--;)if(n1(e[i][0],t))return i;return-1}var Jf=kV,VV=Array.prototype,jV=VV.splice;function GV(e){var t=this.__data__,i=Jf(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():jV.call(t,i,1),--this.size,!0}var HV=GV;function WV(e){var t=this.__data__,i=Jf(t,e);return i<0?void 0:t[i][1]}var qV=WV;function XV(e){return Jf(this.__data__,e)>-1}var YV=XV;function QV(e,t){var i=this.__data__,r=Jf(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var ZV=QV;function Zh(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Zh.prototype.clear=NV;Zh.prototype.delete=HV;Zh.prototype.get=qV;Zh.prototype.has=YV;Zh.prototype.set=ZV;var $f=Zh,KV=vl(Qs,"Map"),vd=KV;function JV(){this.size=0,this.__data__={hash:new bw,map:new(vd||$f),string:new bw}}var $V=JV;function ej(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var tj=ej;function ij(e,t){var i=e.__data__;return tj(t)?i[typeof t=="string"?"string":"hash"]:i.map}var em=ij;function rj(e){var t=em(this,e).delete(e);return this.size-=t?1:0,t}var sj=rj;function aj(e){return em(this,e).get(e)}var nj=aj;function oj(e){return em(this,e).has(e)}var lj=oj;function hj(e,t){var i=em(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var cj=hj;function Kh(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Kh.prototype.clear=$V;Kh.prototype.delete=sj;Kh.prototype.get=nj;Kh.prototype.has=lj;Kh.prototype.set=cj;var tm=Kh,dj="Expected a function";function p1(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(dj);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],a=i.cache;if(a.has(s))return a.get(s);var n=e.apply(this,r);return i.cache=a.set(s,n)||a,n};return i.cache=new(p1.Cache||tm),i}p1.Cache=tm;var uj=p1,pj=500;function fj(e){var t=uj(e,function(r){return i.size===pj&&i.clear(),r}),i=t.cache;return t}var mj=fj,gj=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,vj=/\\(\\)?/g,yj=mj(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(gj,function(i,r,s,a){t.push(s?a.replace(vj,"$1"):r||i)}),t}),xj=yj;function bj(e){return e==null?"":$M(e)}var dE=bj;function wj(e,t){return Ca(e)?e:bV(e,t)?[e]:xj(dE(e))}var Jh=wj,_j=1/0;function Sj(e){if(typeof e=="string"||Nd(e))return e;var t=e+"";return t=="0"&&1/e==-_j?"-0":t}var im=Sj;function Aj(e,t){t=Jh(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[im(t[i++])];return i&&i==r?e:void 0}var uE=Aj;function Mj(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var f1=Mj,ww=As?As.isConcatSpreadable:void 0;function Ej(e){return Ca(e)||c1(e)||!!(ww&&e&&e[ww])}var Cj=Ej;function pE(e,t,i,r,s){var a=-1,n=e.length;for(i||(i=Cj),s||(s=[]);++a<n;){var o=e[a];t>0&&i(o)?t>1?pE(o,t-1,i,r,s):f1(s,o):r||(s[s.length]=o)}return s}var Tj=pE;function Pj(e){var t=e==null?0:e.length;return t?Tj(e,1):[]}var Dj=Pj;function Ij(e){return Uk(a5(e,void 0,Dj),e+"")}var fE=Ij,Oj=cE(Object.getPrototypeOf,Object),m1=Oj,Rj="[object Object]",Lj=Function.prototype,zj=Object.prototype,mE=Lj.toString,Bj=zj.hasOwnProperty,Fj=mE.call(Object);function Uj(e){if(!vn(e)||ml(e)!=Rj)return!1;var t=m1(e);if(t===null)return!0;var i=Bj.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&mE.call(i)==Fj}var Nj=Uj;function kj(e,t,i){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),i=i>s?s:i,i<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var a=Array(s);++r<s;)a[r]=e[r+t];return a}var gE=kj;function Vj(e,t,i){var r=e.length;return i=i===void 0?r:i,!t&&i>=r?e:gE(e,t,i)}var jj=Vj,Gj="\\ud800-\\udfff",Hj="\\u0300-\\u036f",Wj="\\ufe20-\\ufe2f",qj="\\u20d0-\\u20ff",Xj=Hj+Wj+qj,Yj="\\ufe0e\\ufe0f",Qj="\\u200d",Zj=RegExp("["+Qj+Gj+Xj+Yj+"]");function Kj(e){return Zj.test(e)}var Jj=Kj;function $j(e){return e.split("")}var e6=$j,vE="\\ud800-\\udfff",t6="\\u0300-\\u036f",i6="\\ufe20-\\ufe2f",r6="\\u20d0-\\u20ff",s6=t6+i6+r6,a6="\\ufe0e\\ufe0f",n6="["+vE+"]",Xv="["+s6+"]",Yv="\\ud83c[\\udffb-\\udfff]",o6="(?:"+Xv+"|"+Yv+")",yE="[^"+vE+"]",xE="(?:\\ud83c[\\udde6-\\uddff]){2}",bE="[\\ud800-\\udbff][\\udc00-\\udfff]",l6="\\u200d",wE=o6+"?",_E="["+a6+"]?",h6="(?:"+l6+"(?:"+[yE,xE,bE].join("|")+")"+_E+wE+")*",c6=_E+wE+h6,d6="(?:"+[yE+Xv+"?",Xv,xE,bE,n6].join("|")+")",u6=RegExp(Yv+"(?="+Yv+")|"+d6+c6,"g");function p6(e){return e.match(u6)||[]}var f6=p6;function m6(e){return Jj(e)?f6(e):e6(e)}var _w=m6;function g6(){this.__data__=new $f,this.size=0}var v6=g6;function y6(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var x6=y6;function b6(e){return this.__data__.get(e)}var w6=b6;function _6(e){return this.__data__.has(e)}var S6=_6,A6=200;function M6(e,t){var i=this.__data__;if(i instanceof $f){var r=i.__data__;if(!vd||r.length<A6-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new tm(r)}return i.set(e,t),this.size=i.size,this}var E6=M6;function $h(e){var t=this.__data__=new $f(e);this.size=t.size}$h.prototype.clear=v6;$h.prototype.delete=x6;$h.prototype.get=w6;$h.prototype.has=S6;$h.prototype.set=E6;var Mp=$h;function C6(e,t){return e&&kd(t,u1(t),e)}var T6=C6;function P6(e,t){return e&&kd(t,Ho(t),e)}var D6=P6,SE=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sw=SE&&typeof module=="object"&&module&&!module.nodeType&&module,I6=Sw&&Sw.exports===SE,Aw=I6?Qs.Buffer:void 0,Mw=Aw?Aw.allocUnsafe:void 0;function O6(e,t){if(t)return e.slice();var i=e.length,r=Mw?Mw(i):new e.constructor(i);return e.copy(r),r}var R6=O6;function L6(e,t){for(var i=-1,r=e==null?0:e.length,s=0,a=[];++i<r;){var n=e[i];t(n,i,e)&&(a[s++]=n)}return a}var z6=L6;function B6(){return[]}var AE=B6,F6=Object.prototype,U6=F6.propertyIsEnumerable,Ew=Object.getOwnPropertySymbols,N6=Ew?function(e){return e==null?[]:(e=Object(e),z6(Ew(e),function(t){return U6.call(e,t)}))}:AE,g1=N6;function k6(e,t){return kd(e,g1(e),t)}var V6=k6,j6=Object.getOwnPropertySymbols,G6=j6?function(e){for(var t=[];e;)f1(t,g1(e)),e=m1(e);return t}:AE,ME=G6;function H6(e,t){return kd(e,ME(e),t)}var W6=H6;function q6(e,t,i){var r=t(e);return Ca(e)?r:f1(r,i(e))}var EE=q6;function X6(e){return EE(e,u1,g1)}var Qv=X6;function Y6(e){return EE(e,Ho,ME)}var CE=Y6,Q6=vl(Qs,"DataView"),Zv=Q6,Z6=vl(Qs,"Promise"),Kv=Z6,K6=vl(Qs,"Set"),Jv=K6,Cw="[object Map]",J6="[object Object]",Tw="[object Promise]",Pw="[object Set]",Dw="[object WeakMap]",Iw="[object DataView]",$6=gl(Zv),eG=gl(vd),tG=gl(Kv),iG=gl(Jv),rG=gl(qv),zo=ml;(Zv&&zo(new Zv(new ArrayBuffer(1)))!=Iw||vd&&zo(new vd)!=Cw||Kv&&zo(Kv.resolve())!=Tw||Jv&&zo(new Jv)!=Pw||qv&&zo(new qv)!=Dw)&&(zo=function(e){var t=ml(e),i=t==J6?e.constructor:void 0,r=i?gl(i):"";if(r)switch(r){case $6:return Iw;case eG:return Cw;case tG:return Tw;case iG:return Pw;case rG:return Dw}return t});var yd=zo,sG=Object.prototype,aG=sG.hasOwnProperty;function nG(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&aG.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var oG=nG,lG=Qs.Uint8Array,ef=lG;function hG(e){var t=new e.constructor(e.byteLength);return new ef(t).set(new ef(e)),t}var v1=hG;function cG(e,t){var i=t?v1(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var dG=cG,uG=/\w*$/;function pG(e){var t=new e.constructor(e.source,uG.exec(e));return t.lastIndex=e.lastIndex,t}var fG=pG,Ow=As?As.prototype:void 0,Rw=Ow?Ow.valueOf:void 0;function mG(e){return Rw?Object(Rw.call(e)):{}}var gG=mG;function vG(e,t){var i=t?v1(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var yG=vG,xG="[object Boolean]",bG="[object Date]",wG="[object Map]",_G="[object Number]",SG="[object RegExp]",AG="[object Set]",MG="[object String]",EG="[object Symbol]",CG="[object ArrayBuffer]",TG="[object DataView]",PG="[object Float32Array]",DG="[object Float64Array]",IG="[object Int8Array]",OG="[object Int16Array]",RG="[object Int32Array]",LG="[object Uint8Array]",zG="[object Uint8ClampedArray]",BG="[object Uint16Array]",FG="[object Uint32Array]";function UG(e,t,i){var r=e.constructor;switch(t){case CG:return v1(e);case xG:case bG:return new r(+e);case TG:return dG(e,i);case PG:case DG:case IG:case OG:case RG:case LG:case zG:case BG:case FG:return yG(e,i);case wG:return new r;case _G:case MG:return new r(e);case SG:return fG(e);case AG:return new r;case EG:return gG(e)}}var NG=UG;function kG(e){return typeof e.constructor=="function"&&!h1(e)?_k(m1(e)):{}}var VG=kG,jG="[object Map]";function GG(e){return vn(e)&&yd(e)==jG}var HG=GG,Lw=Dh&&Dh.isMap,WG=Lw?d1(Lw):HG,qG=WG,XG="[object Set]";function YG(e){return vn(e)&&yd(e)==XG}var QG=YG,zw=Dh&&Dh.isSet,ZG=zw?d1(zw):QG,KG=ZG,JG=1,$G=2,eH=4,TE="[object Arguments]",tH="[object Array]",iH="[object Boolean]",rH="[object Date]",sH="[object Error]",PE="[object Function]",aH="[object GeneratorFunction]",nH="[object Map]",oH="[object Number]",DE="[object Object]",lH="[object RegExp]",hH="[object Set]",cH="[object String]",dH="[object Symbol]",uH="[object WeakMap]",pH="[object ArrayBuffer]",fH="[object DataView]",mH="[object Float32Array]",gH="[object Float64Array]",vH="[object Int8Array]",yH="[object Int16Array]",xH="[object Int32Array]",bH="[object Uint8Array]",wH="[object Uint8ClampedArray]",_H="[object Uint16Array]",SH="[object Uint32Array]",ei={};ei[TE]=ei[tH]=ei[pH]=ei[fH]=ei[iH]=ei[rH]=ei[mH]=ei[gH]=ei[vH]=ei[yH]=ei[xH]=ei[nH]=ei[oH]=ei[DE]=ei[lH]=ei[hH]=ei[cH]=ei[dH]=ei[bH]=ei[wH]=ei[_H]=ei[SH]=!0;ei[sH]=ei[PE]=ei[uH]=!1;function Ep(e,t,i,r,s,a){var n,o=t&JG,l=t&$G,h=t&eH;if(i&&(n=s?i(e,r,s,a):i(e)),n!==void 0)return n;if(!Ys(e))return e;var c=Ca(e);if(c){if(n=oG(e),!o)return Ek(e,n)}else{var d=yd(e),u=d==PE||d==aH;if($p(e))return R6(e,o);if(d==DE||d==TE||u&&!s){if(n=l||u?{}:VG(e),!o)return l?W6(e,D6(n,e)):V6(e,T6(n,e))}else{if(!ei[d])return s?e:{};n=NG(e,d,o)}}a||(a=new Mp);var p=a.get(e);if(p)return p;a.set(e,n),KG(e)?e.forEach(function(m){n.add(Ep(m,t,i,m,e,a))}):qG(e)&&e.forEach(function(m,v){n.set(v,Ep(m,t,i,v,e,a))});var f=h?l?CE:Qv:l?Ho:u1,g=c?void 0:f(e);return kk(g||e,function(m,v){g&&(v=m,m=e[v]),o1(n,v,Ep(m,t,i,v,e,a))}),n}var IE=Ep,AH=1,MH=4;function EH(e){return IE(e,AH|MH)}var rm=EH,CH="__lodash_hash_undefined__";function TH(e){return this.__data__.set(e,CH),this}var PH=TH;function DH(e){return this.__data__.has(e)}var IH=DH;function tf(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new tm;++t<i;)this.add(e[t])}tf.prototype.add=tf.prototype.push=PH;tf.prototype.has=IH;var OH=tf;function RH(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var LH=RH;function zH(e,t){return e.has(t)}var BH=zH,FH=1,UH=2;function NH(e,t,i,r,s,a){var n=i&FH,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=a.get(e),c=a.get(t);if(h&&c)return h==t&&c==e;var d=-1,u=!0,p=i&UH?new OH:void 0;for(a.set(e,t),a.set(t,e);++d<o;){var f=e[d],g=t[d];if(r)var m=n?r(g,f,d,t,e,a):r(f,g,d,e,t,a);if(m!==void 0){if(m)continue;u=!1;break}if(p){if(!LH(t,function(v,y){if(!BH(p,y)&&(f===v||s(f,v,i,r,a)))return p.push(y)})){u=!1;break}}else if(!(f===g||s(f,g,i,r,a))){u=!1;break}}return a.delete(e),a.delete(t),u}var OE=NH;function kH(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var VH=kH;function jH(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var GH=jH,HH=1,WH=2,qH="[object Boolean]",XH="[object Date]",YH="[object Error]",QH="[object Map]",ZH="[object Number]",KH="[object RegExp]",JH="[object Set]",$H="[object String]",eW="[object Symbol]",tW="[object ArrayBuffer]",iW="[object DataView]",Bw=As?As.prototype:void 0,cg=Bw?Bw.valueOf:void 0;function rW(e,t,i,r,s,a,n){switch(i){case iW:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case tW:return!(e.byteLength!=t.byteLength||!a(new ef(e),new ef(t)));case qH:case XH:case ZH:return n1(+e,+t);case YH:return e.name==t.name&&e.message==t.message;case KH:case $H:return e==t+"";case QH:var o=VH;case JH:var l=r&HH;if(o||(o=GH),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=WH,n.set(e,t);var c=OE(o(e),o(t),r,s,a,n);return n.delete(e),c;case eW:if(cg)return cg.call(e)==cg.call(t)}return!1}var sW=rW,aW=1,nW=Object.prototype,oW=nW.hasOwnProperty;function lW(e,t,i,r,s,a){var n=i&aW,o=Qv(e),l=o.length,h=Qv(t),c=h.length;if(l!=c&&!n)return!1;for(var d=l;d--;){var u=o[d];if(!(n?u in t:oW.call(t,u)))return!1}var p=a.get(e),f=a.get(t);if(p&&f)return p==t&&f==e;var g=!0;a.set(e,t),a.set(t,e);for(var m=n;++d<l;){u=o[d];var v=e[u],y=t[u];if(r)var x=n?r(y,v,u,t,e,a):r(v,y,u,e,t,a);if(!(x===void 0?v===y||s(v,y,i,r,a):x)){g=!1;break}m||(m=u=="constructor")}if(g&&!m){var w=e.constructor,_=t.constructor;w!=_&&"constructor"in e&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof _=="function"&&_ instanceof _)&&(g=!1)}return a.delete(e),a.delete(t),g}var hW=lW,cW=1,Fw="[object Arguments]",Uw="[object Array]",Tu="[object Object]",dW=Object.prototype,Nw=dW.hasOwnProperty;function uW(e,t,i,r,s,a){var n=Ca(e),o=Ca(t),l=n?Uw:yd(e),h=o?Uw:yd(t);l=l==Fw?Tu:l,h=h==Fw?Tu:h;var c=l==Tu,d=h==Tu,u=l==h;if(u&&$p(e)){if(!$p(t))return!1;n=!0,c=!1}if(u&&!c)return a||(a=new Mp),n||lE(e)?OE(e,t,i,r,s,a):sW(e,t,l,i,r,s,a);if(!(i&cW)){var p=c&&Nw.call(e,"__wrapped__"),f=d&&Nw.call(t,"__wrapped__");if(p||f){var g=p?e.value():e,m=f?t.value():t;return a||(a=new Mp),s(g,m,i,r,a)}}return u?(a||(a=new Mp),hW(e,t,i,r,s,a)):!1}var pW=uW;function RE(e,t,i,r,s){return e===t?!0:e==null||t==null||!vn(e)&&!vn(t)?e!==e&&t!==t:pW(e,t,i,r,RE,s)}var fW=RE;function mW(e,t){return e!=null&&t in Object(e)}var gW=mW;function vW(e,t,i){t=Jh(t,e);for(var r=-1,s=t.length,a=!1;++r<s;){var n=im(t[r]);if(!(a=e!=null&&i(e,n)))break;e=e[n]}return a||++r!=s?a:(s=e==null?0:e.length,!!s&&l1(s)&&a1(n,s)&&(Ca(e)||c1(e)))}var yW=vW;function xW(e,t){return e!=null&&yW(e,t,gW)}var bW=xW,wW=function(){return Qs.Date.now()},dg=wW,_W="Expected a function",SW=Math.max,AW=Math.min;function MW(e,t,i){var r,s,a,n,o,l,h=0,c=!1,d=!1,u=!0;if(typeof e!="function")throw new TypeError(_W);t=uw(t)||0,Ys(i)&&(c=!!i.leading,d="maxWait"in i,a=d?SW(uw(i.maxWait)||0,t):a,u="trailing"in i?!!i.trailing:u);function p(b){var A=r,S=s;return r=s=void 0,h=b,n=e.apply(S,A),n}function f(b){return h=b,o=setTimeout(v,t),c?p(b):n}function g(b){var A=b-l,S=b-h,E=t-A;return d?AW(E,a-S):E}function m(b){var A=b-l,S=b-h;return l===void 0||A>=t||A<0||d&&S>=a}function v(){var b=dg();if(m(b))return y(b);o=setTimeout(v,g(b))}function y(b){return o=void 0,u&&r?p(b):(r=s=void 0,n)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function w(){return o===void 0?n:y(dg())}function _(){var b=dg(),A=m(b);if(r=arguments,s=this,l=b,A){if(o===void 0)return f(l);if(d)return clearTimeout(o),o=setTimeout(v,t),p(l)}return o===void 0&&(o=setTimeout(v,t)),n}return _.cancel=x,_.flush=w,_}var xd=MW;function EW(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var CW=EW;function TW(e,t){return e>t}var PW=TW;function DW(e,t){return t.length<2?e:uE(e,gE(t,0,-1))}var IW=DW;function OW(e,t){return fW(e,t)}var y1=OW;function RW(e,t,i){for(var r=-1,s=e.length;++r<s;){var a=e[r],n=t(a);if(n!=null&&(o===void 0?n===n&&!Nd(n):i(n,o)))var o=n,l=a}return l}var LW=RW;function zW(e){return e&&e.length?LW(e,tE,PW):void 0}var BW=zW;function FW(e,t){return t=Jh(t,e),e=IW(e,t),e==null||delete e[im(CW(t))]}var UW=FW;function NW(e){return Nj(e)?void 0:e}var kW=NW,VW=1,jW=2,GW=4,HW=fE(function(e,t){var i={};if(e==null)return i;var r=!1;t=KM(t,function(a){return a=Jh(a,e),r||(r=a.length>1),a}),kd(e,CE(e),i),r&&(i=IE(i,VW|jW|GW,kW));for(var s=t.length;s--;)UW(i,t[s]);return i}),$v=HW;function WW(e,t,i,r){if(!Ys(e))return e;t=Jh(t,e);for(var s=-1,a=t.length,n=a-1,o=e;o!=null&&++s<a;){var l=im(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=n){var c=o[l];h=r?r(c,l,o):void 0,h===void 0&&(h=Ys(c)?c:a1(t[s+1])?[]:{})}o1(o,l,h),o=o[l]}return e}var qW=WW;function XW(e,t,i){for(var r=-1,s=t.length,a={};++r<s;){var n=t[r],o=uE(e,n);i(o,n)&&qW(a,Jh(n,e),o)}return a}var YW=XW;function QW(e,t){return YW(e,t,function(i,r){return bW(e,r)})}var ZW=QW,KW=fE(function(e,t){return e==null?{}:ZW(e,t)}),Sa=KW,JW="Expected a function";function $W(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(JW);return Ys(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),xd(e,t,{leading:r,maxWait:t,trailing:s})}var e8=$W;function t8(e,t){for(var i=e.length;i--&&Yk(t,e[i],0)>-1;);return i}var i8=t8;function r8(e,t,i){if(e=dE(e),e&&(i||t===void 0))return e.slice(0,eE(e)+1);if(!e||!(t=$M(t)))return e;var r=_w(e),s=i8(r,_w(t))+1;return jj(r,0,s).join("")}var s8=r8;function LE(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Ms(e,t){return Object.setPrototypeOf(e,t),e}var a8=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),n8=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),o8=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||sm&&"ontouchend"in document,l8=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,h8=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,c8=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},d8=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},u8=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},zE=a8();zE&&u8();var sm=n8(),ec=o8(),p8=l8(),ss=h8(),kw=c8(),f8=Number(d8());function BE(e){return Array.isArray(e)?e:[e]}function FE(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function Pu(e){return sm?e.metaKey:e.ctrlKey}function m8(e){return e.wheelDeltaY===0||e.deltaY===0?sm&&e.shiftKey&&Math.abs(e.wheelDeltaX)>=120?!1:e.wheelDeltaX?e.wheelDeltaX===-3*e.deltaX||e.wheelDeltaX===-3*window.devicePixelRatio*e.deltaX:e.deltaMode===0:e.wheelDeltaY?e.wheelDeltaY===-3*e.deltaY||e.wheelDeltaY===-3*window.devicePixelRatio*e.deltaY:e.deltaMode===0}var at=[],rf={},Nc={},Cp={};function UE(e){at.includes(e)||at.push(e)}function vh(e){delete rf[e.pointerId];for(let t=0;t<at.length;t++)if(at[t].pointerId===e.pointerId){at.splice(t,1);break}}function g8(){at.splice(0,at.length)}function sf(e){if(e.pointerType!=="touch")return;let t=rf[e.pointerId];t===void 0&&(t={x:0,y:0},rf[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function ug(e){let t=e.pointerId===at[0].pointerId?at[1]:at[0];return rf[t.pointerId]}function NE(e){Nc[e.key]=!0,Cp[e.key]=Cp[e.key]===void 0?1:Cp[e.key]+1}function kE(e){if(sm&&Nc.Meta)for(let t in Nc)Nc[t]=!1;else Nc[e.key]=!1;Cp={}}function v8(e){e.addEventListener("pointerdown",UE,!0),e.addEventListener("pointerdown",sf,!0),e.addEventListener("pointermove",sf,!0),e.addEventListener("pointerup",vh,!0),e.addEventListener("pointercancel",vh,!0),e.addEventListener("pointerleave",vh,!0),window.addEventListener("keydown",NE,!0),window.addEventListener("keyup",kE,!0)}function y8(e){e.removeEventListener("pointerdown",UE,!0),e.removeEventListener("pointerdown",sf,!0),e.removeEventListener("pointermove",sf,!0),e.removeEventListener("pointerup",vh,!0),e.removeEventListener("pointercancel",vh,!0),e.removeEventListener("pointerleave",vh,!0),window.removeEventListener("keydown",NE,!0),window.removeEventListener("keyup",kE,!0)}var VE,x8=new Promise(e=>{VE=e}),Du;function b8(e){if(Du)return Du;async function t(){let i=e??"https://unpkg.com/@splinetool/navmesh-wasm@1.10.53/build",r=vo(()=>import("./navmesh-D1xgHkvw.js"),__vite__mapDeps([])),[s,a]=await Promise.all([r,fetch(`${i}/navmesh.wasm`).then(l=>l.arrayBuffer())]),n=s.default,o=await n({wasmBinary:a});VE(o)}return Du=t(),Du}var jE,w8=new Promise(e=>{jE=e}),Iu;function _8(){if(Iu)return Iu;async function e(){let t=await vo(()=>import("./physics-CUo4NZCQ.js"),__vite__mapDeps([]));await t.init(),jE(t)}return Iu=e(),Iu}var $e=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,$e.prototype),r}}add(e,t){var i;return((i=this.runOp({type:1,id:e,data:t}))==null?void 0:i.data)??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:s,data:a}=e,n={...t,[s]:a};return Object.setPrototypeOf(n,$e.prototype),{data:n,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,$e.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function x1(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&x1(r)}return Object.freeze(e)}function S8(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var GE=class extends Error{};function pg(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Qn(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let a=e;e=t,t=a}let r=[],s=1/(i+1);for(let a=0;a<i;a++){let n=e+(t-e)*(a+.75+Math.random()*.5)*s;r.push(n)}return r}function b1(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function A8(){return typeof process<"u"}function HE(e,t){for(let i of e)t(i.id,i.data)!==!0&&HE(i.children,t)}function WE(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)WE(i,t)}var fr=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,fr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)x1(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){var t;return(t=this.get(e))==null?void 0:t.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){var t;return e===null?this:(t=this.get(e))==null?void 0:t.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&WE(i,t)}}traverse(e){HE(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),s=r.findIndex(n=>n.id===e);if(s<0)throw new Error("not expected");let a=r[s];return r=[...r],r[s]={...a,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let a=r,n=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===n);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:a}}Object.setPrototypeOf(r,fr.prototype);let s=r;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:s,children:a}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:s,children:a};return o=[...o,l],o.sort((h,c)=>h.fi-c.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(n=>n.id===t);e.localIndex=s,r=[...r];let a=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let d=t;for(;d!==null;){if(d===void 0)throw new Error;if(d===r)throw new GE("cyclic tree");d=this.parent(d)}}let s=this.parent(r);if(s===void 0)return null;let a=s,n=this.childrenArray(s),o=n.findIndex(d=>d.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(s,n);s=t,n=h.childrenArray(s);let c=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((d,u)=>d.fi-u.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(s,n),{data:h,actual:e,reverse:{type:9,parent:a,fi:c,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>S8(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),s=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...s,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return Qn(0,i,i);{let s=r[0].fi;return Qn(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let a=r.find(n=>n.fi>s.fi);if(a===void 0){let n=r[r.length-1].fi;return Qn(n,n+i,i)}else return Qn(s.fi,a.fi,i)}}},af;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,a={},n=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");a[l]=n[h],n[h]=s[l],o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}else{let s=r.props,a={},n={...i},o=!1;if(s)for(let l of Object.keys(s)){a[l]=n[l];let h=s[l];h===void 0?delete n[l]:n[l]=h,o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}}e.runOp=t})(af||(af={}));var We=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,We.prototype)}deepFreeze(){let e=0;for(;e<this.length;)x1(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){var t;return(t=this.get(e))==null?void 0:t.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(a=>a.id===e);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,We.prototype);let t=e;return A8()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,s=this,a={fi:t,id:i,data:r};return s=[...s,a],s.sort((n,o)=>n.fi-o.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(a=>a.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let a=r[s].fi,n={...r[s],fi:t};return r[s]=n,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return Qn(0,t,t);{let r=i[0].fi;return Qn(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(a=>a.fi>r.fi);if(s===void 0){let a=i[i.length-1].fi;return Qn(a,a+t,t)}else return Qn(r.fi,s.fi,t)}}};function Ih(e){return e&&typeof e=="object"&&e instanceof Ri}var Ri=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,s={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!Ih(i))return null;r+=1}i=i?pg(i):new Ri;for(let[o,l]of Object.entries(e.props)){let h=i[o];s[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=pg(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=pg(o);l[e.path[r-1]]=i,i=l}else{let l=new Ri;l[e.path[r-1]]=i,i=l}}r-=1}let a=Object.setPrototypeOf(i,Ri.prototype),n={...e,props:s};return{data:a,actual:e,reverse:n}}},so;(e=>{function t(s,a){return bd(s,a)??s}e.apply=t;function i(s,a){return _1(s,a)}e.merge=i;function r(s,a){let n=0,o=a.path,l=s;for(;n<o.length&&l!==void 0;){if(l=Gi.zoomOnce(l,o[n]),l===void 0)return a;if(!Ih(l))return;n+=1}if(l===void 0)return a;if(Ih(l))if(a.type===0){let h={...a.props};for(let c of Object.keys(l))delete h[c];return{...a,props:h}}else if(a.type===1||a.type===4||a.type===7){let h=w1([a],l);return h?(console.log(h),h):a}else return a}e.filterOp=r})(so||(so={}));function w1(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=bd(s.data,t[a]);if(i=i||n!==void 0,n===void 0&&(n=s.data),s.children){let o=w1(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:a,data:n,children:o}}else return{...s,id:a,data:n}});if(i)return r}function M8(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=bd(s.data,t[a]);return i=i||n!==void 0,n===void 0&&(n=s.data),{...s,id:a,data:n}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function bd(e,t){if(!Ih(t))return t;if(e instanceof fr){let i=w1(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof We)return M8(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,a)=>{let n=bd(s,t[a]);return i=i||n!==void 0,n===void 0&&(n=s),n});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof Ri)return _1(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,a]of Object.entries(e)){let n=bd(a,t[s]);r=r||n!==void 0,n===void 0&&(n=a),i[s]=n}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function _1(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Ih(t))return t;if(!Ih(e))return so.apply(e,t);let i=new Set;for(let s of Object.keys(e))i.add(s);for(let s of Object.keys(t))i.add(s);let r=new Ri;for(let s of i){let a=_1(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=a}return r}function E8(e,t){let i={cur:[],result:[],len:0};return e=wd(e,t,i)??e,[e,i.result]}function nf(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function of(e){e&&(e.len-=1)}function C8(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function qE(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=wd(a.data,t,nf(i,n));of(i),r=r||l!==void 0,l===void 0&&(l=a.data);let h=qE(a.children,t,i);return h!==void 0?r=!0:h=a.children,{...a,id:n,data:l,children:h}});if(r)return s}function T8(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=wd(a.data,t,nf(i,n));return of(i),r=r||l!==void 0,l===void 0&&(l=a.data),{...a,id:n,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function wd(e,t,i){if(e instanceof fr){let r=qE(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof We)return T8(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((a,n)=>{let o=wd(a,t,nf(i,n));return of(i),r=r||o!==void 0,o===void 0&&(o=a),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!b1(e)){let r={},s=!1;for(let[a,n]of Object.entries(e))if(a!=="name"&&a!=="variableId"){let o=t[a];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,a=o}let l=wd(n,t,nf(i,a));of(i),s=s||l!==void 0,l===void 0&&(l=n),r[a]=l}else r[a]=n;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&C8(i),r}else return}}var lf;(e=>{function t(i,r){let s=Gi.zoom(r,i.path);if(typeof s=="object"){let a={};for(let n of Object.keys(i.props))a[n]=s[n];return{...i,props:a}}else return{...i,props:{}}}e.replaceProps=t})(lf||(lf={}));var tr;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){var c;return((c=r(l,h))==null?void 0:c.data)??l}e.applySimple=i;function r(l,h){var u,p;let c=h.path;for(var d=[];;){let f;if(l instanceof Ri&&h.type===0&&(f=l.runOp({...h,path:c.slice(d.length)}),f===null&&(f=void 0)),f===void 0&&d.length===c.length&&(l instanceof fr||l instanceof We||l instanceof $e?f=l.runOp(h):f=af.runOp(l,h)),f!==void 0)if(f!==null){let v=f.data;for(let y=d.length-1;y>=0;y--){let x=c[y],w=d[y];if(w instanceof fr){if(typeof x=="number")throw new Error("illegal arg");v=w.modifyById(x,v)}else if(w instanceof We){if(typeof x=="number")throw new Error("illegal arg");v=w.modifyById(x,v)}else if(w instanceof $e){if(typeof x=="number")throw new Error("illegal arg");v=w.modifyById(x,v)}else if(w instanceof Ri){let _={...w,[x]:v};v=Object.setPrototypeOf(_,Ri.prototype)}else if(typeof w=="object")if(Array.isArray(w)){if(typeof x=="string"&&(x=parseInt(x),isNaN(x)))throw new Error("Invalid path");let _=v;v=[...w],v[x]=_}else v={...w,[x]:v};else return null}return{data:v,actual:{...f.actual,path:c},reverse:{...f.reverse,path:c}}}else return null;let g=c[d.length],m;if(l instanceof fr){if(typeof g=="number")throw new Error("");m=(u=l.get(g))==null?void 0:u.data}else if(l instanceof We){if(typeof g=="number")throw new Error("");m=(p=l.get(g))==null?void 0:p.data}else l!==null&&(m=l[g]);if(m!==void 0)d.push(l),l=m;else return null}}e.apply=r;function s(l,h){for(let c=0;c<l.length&&c<h.length;c++)if(l[c]!==h[c])return!0;return!1}e.pathDisjoint=s;function a(l,h){if(l.length!==h.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==h[c])return!1;return!0}e.pathEq=a;function n(l,h){return s(l.path,h.path)}e.commutative=n;function o(l,h){return l.type===0&&h.type===0&&a(l.path,h.path)?Object.keys(l.props).every(c=>h.props[c]!==void 0):!1}e.subsumed=o})(tr||(tr={}));var e0;(e=>{function t(){return[]}e.empty=t;function i(h,c){let d=[];for(let u of h){let[p,...f]=u.path;p===c&&d.push({...u,path:f})}return d}e.removePrefix=i;function r(h,c){return h.map(d=>({...d,path:[c,...d.path]}))}e.addPrefix=r;function s(h,c){return[...h,...c]}e.concat=s;function a(h,c){return[...h.filter(d=>!c.some(u=>tr.subsumed(d,u))),...c]}e.compress=a;function n(h,c){return h.every(d=>c.every(u=>tr.commutative(d,u)))}e.commutative=n;function o(h,c){for(let d of c){let u=l(h,d);u!==null&&(h=u.data)}return h}e.applyAll=o;function l(h,c){var d=h;let u=[],p=[];for(let f of c)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let g,m,v;if(f.type===3?(g=Gi.zoom(d,[...f.path,f.id]),v=tr.apply(d,{...f,type:2})):(g=Gi.zoom(d,[...f.path,f.id,"value"]),v=tr.apply(d,f)),v!==null){d=v.data;let[y,x]=E8(d,{[f.id]:g});d=y;for(let w=0;w<x.length;w++){let _=x[w],b=_.pop();if(typeof b=="number"){let A=[b];for(let E=w+1;E<x.length;E++){let C=x[E],T=C[C.length-1];if(typeof T=="number"&&Gi.equal(_,C.slice(0,C.length-1)))A.push(T),x.splice(E,1);else break}let S=Gi.zoom(d,_);m=S.map((E,C)=>A.includes(C)?f.id:E),g=S,b=_.pop()}else{if(b==="alphaOverride"||b==="alpha"){g/=100;let A=g,S=Gi.zoom(d,_.slice(0,_.length-2)),E=S.layers.map(C=>C.id===_[_.length-1]?{...C,data:{...C.data,[b]:A}}:C);Object.setPrototypeOf(E,Object.getPrototypeOf(S.layers)),S.layers=E}m=f.id}u.push({type:0,path:_,props:{[b]:g}}),p.push({type:0,path:_,props:{[b]:m}})}p.push(v.reverse),u.push(v.actual)}}else{let g=tr.apply(d,f);g!==null&&(u.push(g.actual),d=g.data,p.push(g.reverse))}}catch(g){if(g instanceof GE)return null;throw g}return{data:d,actual:u,reverse:p.reverse()}}e.apply=l})(e0||(e0={}));var XE=Symbol(),P8=Symbol(),am=Symbol(),Vd=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof QE);){let a=r._path,n=r._current;if(a!==""&&s.splice(0,0,a),r=r._parent,r===null)return;r.update(a,n)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[am];i&&i(),delete this._children[e]}}}},D8=class extends Vd{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,af.runOp(this._current,e),e.path)}},I8=class extends Vd{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,$e.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},YE={get(e,t){if(t===am)return()=>{e._parent=null};if(t===XE)return e._current;if(t===P8)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[t];if(s!==void 0)return s;let a=i[t],n=nm(e,t,a);return n!==a?(r===void 0&&(r={},e._children=r),r[t]=n,n):a},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},O8={...YE,set(e,t,i){let r={type:0,props:{[t]:wi(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},R8={...YE,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},S1=class extends Vd{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[am]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){var n;let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=(n=t.get(e))==null?void 0:n.data,a=nm(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):s}add(e,t,i,r,s){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:s})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},A1=class extends Vd{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[am]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,s=this._current[i].fi;e(this.data(this._current[i].id),r,s)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){var n;let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=(n=t.get(e))==null?void 0:n.data,a=nm(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function fg(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Gi.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var QE=class extends Vd{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){fg(this.ts,t,e),fg(this.actual,i,e),fg(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function nm(e,t,i){return i instanceof fr?new S1(e,t,i):i instanceof We?new A1(e,t,i):i instanceof $e?new Proxy(new I8(e,t,i),R8):i!==null&&typeof i=="object"?b1(i)?i:new Proxy(new D8(e,t,i),O8):i}function ZE(e){let t=new QE(e);return[nm(t,"",e),t]}function _d(e,t){let[i,r]=ZE(e);return t(i),r.result()}function wi(e){return e instanceof S1||e instanceof A1?e._current:e!==null&&typeof e=="object"?e[XE]:e}var Gi;(e=>{function t(a,n){if(n.length===a.length)for(var o=0;o<a.length;){if(a[o]!==n[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(a,n,o){let l=s(o,a);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...n};return Object.keys(l).forEach(c=>{delete h[c]}),h}else return n}e.removeOverridden=i;function r(a,n){if((a instanceof fr||a instanceof S1)&&typeof n=="string"||(a instanceof We||a instanceof A1)&&typeof n=="string")return a.data(n);if(typeof n=="number"&&Array.isArray(a)||typeof n=="string"&&typeof a=="object"&&a!==null)return a[n]}e.zoomOnce=r;function s(a,n,o=0){for(;o<n.length&&a!==void 0;)a=r(a,n[o]),o+=1;return a}e.zoom=s})(Gi||(Gi={}));function L8(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Qt(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var KE=class{},Vw=class extends KE{constructor(e){super(),this.id=e}},jw=class extends KE{constructor(e){super(),this.data=e}},t0;try{t0=new TextDecoder}catch{}var Ne,ao,ie=0,Yr={},Bt,Zn,gs=0,ya=0,rs,pn,kr=[],Nt,Gw={useRecords:!1,mapsAsObjects:!0},JE=class{},$E=new JE;$E.name="MessagePack 0xC1";var Oh=!1,hf=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Ne)return aC(()=>(r0(),this?this.unpack(e,t):hf.prototype.unpack.call(Gw,e,t)));ao=t>-1?t:e.length,ie=0,ya=0,Zn=null,rs=null,Ne=e;try{Nt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Ne=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof hf){if(Yr=this,this.structures)return Bt=this.structures,Ou();(!Bt||Bt.length>0)&&(Bt=[])}else Yr=Gw,(!Bt||Bt.length>0)&&(Bt=[]);return Ou()}unpackMultiple(e,t){let i,r=0;try{Oh=!0;let s=e.length,a=this?this.unpack(e,s):lm.unpack(e,s);if(t){for(t(a);ie<s;)if(r=ie,t(Ou())===!1)return}else{for(i=[a];ie<s;)r=ie,i.push(Ou());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{Oh=!1,r0()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let s=e[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],s=t[i];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Ou(){try{if(!Yr.trusted&&!Oh){let t=Bt.sharedLength||0;t<Bt.length&&(Bt.length=t)}let e=fi();if(ie==ao)Bt.restoreStructures&&Hw(),Bt=null,Ne=null,pn&&(pn=null);else if(ie>ao){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Oh)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw Bt.restoreStructures&&Hw(),r0(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function Hw(){for(let e in Bt.restoreStructures)Bt[e]=Bt.restoreStructures[e];Bt.restoreStructures=null}function fi(){let e=Ne[ie++];if(e<160)if(e<128){if(e<64)return e;{let t=Bt[e&63]||Yr.getStructures&&eC()[e&63];return t?(t.read||(t.read=M1(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,Yr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[iC()]=fi();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(fi(),fi());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=fi();return t}else if(e<192){let t=e-160;if(ya>=ie)return Zn.slice(ie-gs,(ie+=t)-gs);if(ya==0&&ao<140){let i=t<16?E1(t):tC(t);if(i!=null)return i}return i0(t)}else{let t;switch(e){case 192:return null;case 193:return rs?(t=fi(),t>0?rs[1].slice(rs.position1,rs.position1+=t):rs[0].slice(rs.position0,rs.position0-=t)):$E;case 194:return!1;case 195:return!0;case 196:return mg(Ne[ie++]);case 197:return t=Nt.getUint16(ie),ie+=2,mg(t);case 198:return t=Nt.getUint32(ie),ie+=4,mg(t);case 199:return To(Ne[ie++]);case 200:return t=Nt.getUint16(ie),ie+=2,To(t);case 201:return t=Nt.getUint32(ie),ie+=4,To(t);case 202:if(t=Nt.getFloat32(ie),Yr.useFloat32>2){let i=C1[(Ne[ie]&127)<<1|Ne[ie+1]>>7];return ie+=4,(i*t+(t>0?.5:-.5)>>0)/i}return ie+=4,t;case 203:return t=Nt.getFloat64(ie),ie+=8,t;case 204:return Ne[ie++];case 205:return t=Nt.getUint16(ie),ie+=2,t;case 206:return t=Nt.getUint32(ie),ie+=4,t;case 207:return Yr.int64AsNumber?(t=Nt.getUint32(ie)*4294967296,t+=Nt.getUint32(ie+4)):t=Nt.getBigUint64(ie),ie+=8,t;case 208:return Nt.getInt8(ie++);case 209:return t=Nt.getInt16(ie),ie+=2,t;case 210:return t=Nt.getInt32(ie),ie+=4,t;case 211:return Yr.int64AsNumber?(t=Nt.getInt32(ie)*4294967296,t+=Nt.getUint32(ie+4)):t=Nt.getBigInt64(ie),ie+=8,t;case 212:if(t=Ne[ie++],t==114)return Qw(Ne[ie++]&63);{let i=kr[t];if(i)return i.read?(ie++,i.read(fi())):i.noBuffer?(ie++,i()):i(Ne.subarray(ie,++ie));throw new Error("Unknown extension "+t)}case 213:return t=Ne[ie],t==114?(ie++,Qw(Ne[ie++]&63,Ne[ie++])):To(2);case 214:return To(4);case 215:return To(8);case 216:return To(16);case 217:return t=Ne[ie++],ya>=ie?Zn.slice(ie-gs,(ie+=t)-gs):B8(t);case 218:return t=Nt.getUint16(ie),ie+=2,ya>=ie?Zn.slice(ie-gs,(ie+=t)-gs):F8(t);case 219:return t=Nt.getUint32(ie),ie+=4,ya>=ie?Zn.slice(ie-gs,(ie+=t)-gs):U8(t);case 220:return t=Nt.getUint16(ie),ie+=2,qw(t);case 221:return t=Nt.getUint32(ie),ie+=4,qw(t);case 222:return t=Nt.getUint16(ie),ie+=2,Xw(t);case 223:return t=Nt.getUint32(ie),ie+=4,Xw(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var z8=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function M1(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(a=>z8.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}}")(fi);return e.highByte===0&&(e.read=Ww(t,e.read)),s()}let r={};for(let s=0,a=e.length;s<a;s++){let n=e[s];r[n]=fi()}return r}return i.count=0,e.highByte===0?Ww(t,i):i}var Ww=(e,t)=>function(){let i=Ne[ie++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=Bt[r]||eC()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=M1(s,e)),s.read()};function eC(){let e=aC(()=>(Ne=null,Yr.getStructures()));return Bt=Yr._mergeStructures(e,Bt)}var i0=om,B8=om,F8=om,U8=om;function om(e){let t;if(e<16&&(t=E1(e)))return t;if(e>64&&t0)return t0.decode(Ne.subarray(ie,ie+=e));let i=ie+e,r=[];for(t="";ie<i;){let s=Ne[ie++];if(!(s&128))r.push(s);else if((s&224)===192){let a=Ne[ie++]&63;r.push((s&31)<<6|a)}else if((s&240)===224){let a=Ne[ie++]&63,n=Ne[ie++]&63;r.push((s&31)<<12|a<<6|n)}else if((s&248)===240){let a=Ne[ie++]&63,n=Ne[ie++]&63,o=Ne[ie++]&63,l=(s&7)<<18|a<<12|n<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(s);r.length>=4096&&(t+=Ki.apply(String,r),r.length=0)}return r.length>0&&(t+=Ki.apply(String,r)),t}function qw(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=fi();return t}function Xw(e){if(Yr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[iC()]=fi();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(fi(),fi());return t}}var Ki=String.fromCharCode;function tC(e){let t=ie,i=new Array(e);for(let r=0;r<e;r++){let s=Ne[ie++];if((s&128)>0){ie=t;return}i[r]=s}return Ki.apply(String,i)}function E1(e){if(e<4)if(e<2){if(e===0)return"";{let t=Ne[ie++];if((t&128)>1){ie-=1;return}return Ki(t)}}else{let t=Ne[ie++],i=Ne[ie++];if((t&128)>0||(i&128)>0){ie-=2;return}if(e<3)return Ki(t,i);let r=Ne[ie++];if((r&128)>0){ie-=3;return}return Ki(t,i,r)}else{let t=Ne[ie++],i=Ne[ie++],r=Ne[ie++],s=Ne[ie++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){ie-=4;return}if(e<6){if(e===4)return Ki(t,i,r,s);{let a=Ne[ie++];if((a&128)>0){ie-=5;return}return Ki(t,i,r,s,a)}}else if(e<8){let a=Ne[ie++],n=Ne[ie++];if((a&128)>0||(n&128)>0){ie-=6;return}if(e<7)return Ki(t,i,r,s,a,n);let o=Ne[ie++];if((o&128)>0){ie-=7;return}return Ki(t,i,r,s,a,n,o)}else{let a=Ne[ie++],n=Ne[ie++],o=Ne[ie++],l=Ne[ie++];if((a&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){ie-=8;return}if(e<10){if(e===8)return Ki(t,i,r,s,a,n,o,l);{let h=Ne[ie++];if((h&128)>0){ie-=9;return}return Ki(t,i,r,s,a,n,o,l,h)}}else if(e<12){let h=Ne[ie++],c=Ne[ie++];if((h&128)>0||(c&128)>0){ie-=10;return}if(e<11)return Ki(t,i,r,s,a,n,o,l,h,c);let d=Ne[ie++];if((d&128)>0){ie-=11;return}return Ki(t,i,r,s,a,n,o,l,h,c,d)}else{let h=Ne[ie++],c=Ne[ie++],d=Ne[ie++],u=Ne[ie++];if((h&128)>0||(c&128)>0||(d&128)>0||(u&128)>0){ie-=12;return}if(e<14){if(e===12)return Ki(t,i,r,s,a,n,o,l,h,c,d,u);{let p=Ne[ie++];if((p&128)>0){ie-=13;return}return Ki(t,i,r,s,a,n,o,l,h,c,d,u,p)}}else{let p=Ne[ie++],f=Ne[ie++];if((p&128)>0||(f&128)>0){ie-=14;return}if(e<15)return Ki(t,i,r,s,a,n,o,l,h,c,d,u,p,f);let g=Ne[ie++];if((g&128)>0){ie-=15;return}return Ki(t,i,r,s,a,n,o,l,h,c,d,u,p,f,g)}}}}}function mg(e){return Yr.copyBuffers?Uint8Array.prototype.slice.call(Ne,ie,ie+=e):Ne.subarray(ie,ie+=e)}function To(e){let t=Ne[ie++];if(kr[t])return kr[t](Ne.subarray(ie,ie+=e));throw new Error("Unknown extension type "+t)}var Yw=new Array(4096);function iC(){let e=Ne[ie++];if(e>=160&&e<192){if(e=e-160,ya>=ie)return Zn.slice(ie-gs,(ie+=e)-gs);if(!(ya==0&&ao<180))return i0(e)}else return ie--,fi();let t=(e<<5^(e>1?Nt.getUint16(ie):e>0?Ne[ie]:0))&4095,i=Yw[t],r=ie,s=ie+e-3,a,n=0;if(i&&i.bytes==e){for(;r<s;){if(a=Nt.getUint32(r),a!=i[n++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(a=Ne[r++],a!=i[n++]){r=1879048192;break}if(r===s)return ie=r,i.string;s-=3,r=ie}for(i=[],Yw[t]=i,i.bytes=e;r<s;)a=Nt.getUint32(r),i.push(a),r+=4;for(s+=3;r<s;)a=Ne[r++],i.push(a);let o=e<16?E1(e):tC(e);return o!=null?i.string=o:i.string=i0(e)}var Qw=(e,t)=>{var i=fi();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=Bt[e];return s&&s.isShared&&((Bt.restoreStructures||(Bt.restoreStructures=[]))[e]=s),Bt[e]=i,i.read=M1(i,r),i.read()},rC=typeof self=="object"?self:global;kr[0]=()=>{};kr[0].noBuffer=!0;kr[101]=()=>{let e=fi();return(rC[e[0]]||Error)(e[1])};kr[105]=e=>{let t=Nt.getUint32(ie-4);pn||(pn=new Map);let i=Ne[ie],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};pn.set(t,s);let a=fi();return s.used?Object.assign(r,a):(s.target=a,a)};kr[112]=e=>{let t=Nt.getUint32(ie-4),i=pn.get(t);return i.used=!0,i.target};kr[115]=()=>new Set(fi());var sC=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");kr[116]=e=>{let t=e[0],i=sC[t];if(!i)throw new Error("Could not find typed array for code "+t);return new rC[i](Uint8Array.prototype.slice.call(e,1).buffer)};kr[120]=()=>{let e=fi();return new RegExp(e[0],e[1])};kr[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=ie;ie+=t-4,rs=[fi(),fi()],rs.position0=0,rs.position1=0;let r=ie;ie=i;try{return fi()}finally{ie=r}};kr[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function aC(e){let t=ao,i=ie,r=gs,s=ya,a=Zn,n=pn,o=rs,l=new Uint8Array(Ne.slice(0,ao)),h=Bt,c=Bt.slice(0,Bt.length),d=Yr,u=Oh,p=e();return ao=t,ie=i,gs=r,ya=s,Zn=a,pn=n,rs=o,Ne=l,Oh=u,Bt=h,Bt.splice(0,Bt.length,...c),Yr=d,Nt=new DataView(Ne.buffer,Ne.byteOffset,Ne.byteLength),p}function r0(){Ne=null,pn=null,Bt=null}function N8(e){e.unpack?kr[e.type]=e.unpack:kr[e.type]=e}var C1=new Array(147);for(let e=0;e<256;e++)C1[e]=+("1e"+Math.floor(45.15-e*.30103));var lm=new hf({useRecords:!1});lm.unpack;lm.unpackMultiple;lm.unpack;var k8=new Float32Array(1);new Uint8Array(k8.buffer,0,4);var Tp;try{Tp=new TextEncoder}catch{}var cf,T1,hm=typeof Buffer<"u",gg=hm?Buffer.allocUnsafeSlow:Uint8Array,nC=hm?Buffer:Uint8Array,Zw=hm?4294967296:2144337920,xe,xi,ce=0,$s,ea=null,V8=/[\u0080-\uFFFF]/,yc=Symbol("record-id"),oC=class extends hf{constructor(e){super(e),this.offset=0;let t,i,r,s,a,n=0,o=nC.prototype.utf8Write?function(b,A,S){return xe.utf8Write(b,A,S)}:Tp&&Tp.encodeInto?function(b,A){return Tp.encodeInto(b,xe.subarray(A)).written}:!1,l=this;e||(e={});let h=e&&e.sequential,c=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=c?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let u=e.maxOwnStructures;u==null&&(u=c?32:64),h&&!e.saveStructures&&(this.structures=[]);let p=d>32||u+d>64,f=d+64,g=d+u+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let m=[],v=0,y=0;this.pack=this.encode=function(b,A){if(xe||(xe=new gg(8192),xi=new DataView(xe.buffer,0,8192),ce=0),$s=xe.length-10,$s-ce<2048?(xe=new gg(xe.length),xi=new DataView(xe.buffer,0,xe.length),$s=xe.length-10,ce=0):ce=ce+7&2147483640,t=ce,a=l.structuredClone?new Map:null,l.bundleStrings?(ea=["",""],xe[ce++]=214,xe[ce++]=98,ea.position=ce-t,ce+=4):ea=null,i=l.structures,i){i.uninitialized&&(i=l._mergeStructures(l.getStructures()));let S=i.sharedLength||0;if(S>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let E=0;E<S;E++){let C=i[E];if(!C)continue;let T,D=i.transitions;for(let O=0,P=C.length;O<P;O++){let U=C[O];T=D[U],T||(T=D[U]=Object.create(null)),D=T}D[yc]=E+64}n=S}h||(i.nextId=S+64)}r&&(r=!1),s=i||[];try{if(x(b),ea){xi.setUint32(ea.position+t,ce-ea.position-t);let S=ea;ea=null,x(S[0]),x(S[1])}if(l.offset=ce,a&&a.idsToInsert){ce+=a.idsToInsert.length*6,ce>$s&&_(ce),l.offset=ce;let S=G8(xe.subarray(t,ce),a.idsToInsert);return a=null,S}return A&H8?(xe.start=t,xe.end=ce,xe):xe.subarray(t,ce)}finally{if(i){if(y<10&&y++,v>1e4)i.transitions=null,y=0,v=0,m.length>0&&(m=[]);else if(m.length>0&&!h){for(let S=0,E=m.length;S<E;S++)m[S][yc]=0;m=[]}if(r&&l.saveStructures){let S=i.sharedLength||d;i.length>S&&(i=i.slice(0,S));let E=xe.subarray(t,ce);return l.saveStructures(i,n)===!1?(l._mergeStructures(l.getStructures()),l.pack(b)):(n=S,E)}}A&W8&&(ce=t)}};let x=b=>{ce>$s&&(xe=_(ce));var A=typeof b,S;if(A==="string"){let E=b.length;if(ea&&E>=8&&E<4096){let D=V8.test(b);ea[D?0:1]+=b,xe[ce++]=193,x(D?-E:E);return}let C;E<32?C=1:E<256?C=2:E<65536?C=3:C=5;let T=E*3;if(ce+T>$s&&(xe=_(ce+T)),E<64||!o){let D,O,P,U=ce+C;for(D=0;D<E;D++)O=b.charCodeAt(D),O<128?xe[U++]=O:O<2048?(xe[U++]=O>>6|192,xe[U++]=O&63|128):(O&64512)===55296&&((P=b.charCodeAt(D+1))&64512)===56320?(O=65536+((O&1023)<<10)+(P&1023),D++,xe[U++]=O>>18|240,xe[U++]=O>>12&63|128,xe[U++]=O>>6&63|128,xe[U++]=O&63|128):(xe[U++]=O>>12|224,xe[U++]=O>>6&63|128,xe[U++]=O&63|128);S=U-ce-C}else S=o(b,ce+C,T);S<32?xe[ce++]=160|S:S<256?(C<2&&xe.copyWithin(ce+2,ce+1,ce+1+S),xe[ce++]=217,xe[ce++]=S):S<65536?(C<3&&xe.copyWithin(ce+3,ce+2,ce+2+S),xe[ce++]=218,xe[ce++]=S>>8,xe[ce++]=S&255):(C<5&&xe.copyWithin(ce+5,ce+3,ce+3+S),xe[ce++]=219,xi.setUint32(ce,S),ce+=4),ce+=S}else if(A==="number")if(b>>>0===b)b<64?xe[ce++]=b:b<256?(xe[ce++]=204,xe[ce++]=b):b<65536?(xe[ce++]=205,xe[ce++]=b>>8,xe[ce++]=b&255):(xe[ce++]=206,xi.setUint32(ce,b),ce+=4);else if(b>>0===b)b>=-32?xe[ce++]=256+b:b>=-128?(xe[ce++]=208,xe[ce++]=b+256):b>=-32768?(xe[ce++]=209,xi.setInt16(ce,b),ce+=2):(xe[ce++]=210,xi.setInt32(ce,b),ce+=4);else{let E;if((E=this.useFloat32)>0&&b<4294967296&&b>=-2147483648){xe[ce++]=202,xi.setFloat32(ce,b);let C;if(E<4||(C=b*C1[(xe[ce]&127)<<1|xe[ce+1]>>7])>>0===C){ce+=4;return}else ce--}xe[ce++]=203,xi.setFloat64(ce,b),ce+=8}else if(A==="object")if(!b)xe[ce++]=192;else{if(a){let C=a.get(b);if(C){if(!C.id){let T=a.idsToInsert||(a.idsToInsert=[]);C.id=T.push(C)}xe[ce++]=214,xe[ce++]=112,xi.setUint32(ce,C.id),ce+=4;return}else a.set(b,{offset:ce-t})}let E=b.constructor;if(E===Object)w(b,!0);else if(E===Array){S=b.length,S<16?xe[ce++]=144|S:S<65536?(xe[ce++]=220,xe[ce++]=S>>8,xe[ce++]=S&255):(xe[ce++]=221,xi.setUint32(ce,S),ce+=4);for(let C=0;C<S;C++)x(b[C])}else if(E===Map){S=b.size,S<16?xe[ce++]=128|S:S<65536?(xe[ce++]=222,xe[ce++]=S>>8,xe[ce++]=S&255):(xe[ce++]=223,xi.setUint32(ce,S),ce+=4);for(let[C,T]of b)x(C),x(T)}else{for(let C=0,T=cf.length;C<T;C++){let D=T1[C];if(b instanceof D){let O=cf[C];if(O.write){O.type&&(xe[ce++]=212,xe[ce++]=O.type,xe[ce++]=0),x(O.write.call(this,b));return}let P=xe,U=xi,W=ce;xe=null;let k;try{k=O.pack.call(this,b,F=>(xe=P,P=null,ce+=F,ce>$s&&_(ce),{target:xe,targetView:xi,position:ce-F}),x)}finally{P&&(xe=P,xi=U,ce=W,$s=xe.length-10)}k&&(k.length+ce>$s&&_(k.length+ce),ce=j8(k,xe,ce,O.type));return}}w(b,!b.hasOwnProperty)}}else if(A==="boolean")xe[ce++]=b?195:194;else if(A==="bigint"){if(b<BigInt(1)<<BigInt(63)&&b>=-(BigInt(1)<<BigInt(63)))xe[ce++]=211,xi.setBigInt64(ce,b);else if(b<BigInt(1)<<BigInt(64)&&b>0)xe[ce++]=207,xi.setBigUint64(ce,b);else if(this.largeBigIntToFloat)xe[ce++]=203,xi.setFloat64(ce,Number(b));else throw new RangeError(b+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ce+=8}else if(A==="undefined")this.encodeUndefinedAsNil?xe[ce++]=192:(xe[ce++]=212,xe[ce++]=0,xe[ce++]=0);else if(A==="function")x(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+A)},w=this.useRecords===!1?this.variableMapSize?b=>{let A=Object.keys(b),S=A.length;S<16?xe[ce++]=128|S:S<65536?(xe[ce++]=222,xe[ce++]=S>>8,xe[ce++]=S&255):(xe[ce++]=223,xi.setUint32(ce,S),ce+=4);let E;for(let C=0;C<S;C++)x(E=A[C]),x(b[E])}:(b,A)=>{xe[ce++]=222;let S=ce-t;ce+=2;let E=0;for(let C in b)(A||b.hasOwnProperty(C))&&(x(C),x(b[C]),E++);xe[S+++t]=E>>8,xe[S+t]=E&255}:b=>{let A=Object.keys(b),S,E=s.transitions||(s.transitions=Object.create(null)),C=0;for(let D=0,O=A.length;D<O;D++){let P=A[D];S=E[P],S||(S=E[P]=Object.create(null),C++),E=S}let T=E[yc];if(T)T>=96&&p?(xe[ce++]=((T-=96)&31)+96,xe[ce++]=T>>5):xe[ce++]=T;else{T=s.nextId,T||(T=64),T<f&&this.shouldShareStructure&&!this.shouldShareStructure(A)?(T=s.nextOwnId,T<g||(T=f),s.nextOwnId=T+1):(T>=g&&(T=f),s.nextId=T+1);let D=A.highByte=T>=96&&p?T-96>>5:-1;E[yc]=T,s[T-64]=A,T<f?(A.isShared=!0,s.sharedLength=T-63,r=!0,D>=0?(xe[ce++]=(T&31)+96,xe[ce++]=D):xe[ce++]=T):(D>=0?(xe[ce++]=213,xe[ce++]=114,xe[ce++]=(T&31)+96,xe[ce++]=D):(xe[ce++]=212,xe[ce++]=114,xe[ce++]=T),C&&(v+=y*C),m.length>=u&&(m.shift()[yc]=0),m.push(E),x(A))}for(let D=0,O=A.length;D<O;D++)x(b[A[D]])},_=b=>{let A;if(b>16777216){if(b-t>Zw)throw new Error("Packed buffer would be larger than maximum buffer size");A=Math.min(Zw,Math.round(Math.max((b-t)*(b>67108864?1.25:2),4194304)/4096)*4096)}else A=(Math.max(b-t<<2,xe.length-1)>>12)+1<<12;let S=new gg(A);return xi=new DataView(S.buffer,0,A),xe.copy?xe.copy(S,0,t,b):S.set(xe.slice(t,b)),ce-=t,t=0,$s=S.length-10,xe=S}}useBuffer(e){xe=e,xi=new DataView(xe.buffer,xe.byteOffset,xe.byteLength),ce=0}};T1=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,JE];cf=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:a,position:n}=t(6);s[n++]=214,s[n++]=255,a.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:s,targetView:a,position:n}=t(10);s[n++]=215,s[n++]=255,a.setUint32(n,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),a.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:a,position:n}=t(3);s[n++]=212,s[n++]=255,s[n++]=255}else{let{target:s,targetView:a,position:n}=t(15);s[n++]=199,s[n++]=12,s[n++]=255,a.setUint32(n,e.getMilliseconds()*1e6),a.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(s[a++]=212,s[a++]=115,s[a++]=0),i(r)}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=101,r[s++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=120,r[s++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?Kw(e,16,t):Jw(hm?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==nC&&this.structuredClone?Kw(e,sC.indexOf(i.name),t):Jw(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function Kw(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:a,position:n}=i(4+s);a[n++]=199,a[n++]=s+1}else if(s+1<65536){var{target:a,position:n}=i(5+s);a[n++]=200,a[n++]=s+1>>8,a[n++]=s+1&255}else{var{target:a,position:n,targetView:o}=i(7+s);a[n++]=201,o.setUint32(n,s+1),n+=4}a[n++]=116,a[n++]=t,a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n)}function Jw(e,t){let i=e.byteLength;var r,s;if(i<256){var{target:r,position:s}=t(i+2);r[s++]=196,r[s++]=i}else if(i<65536){var{target:r,position:s}=t(i+3);r[s++]=197,r[s++]=i>>8,r[s++]=i&255}else{var{target:r,position:s,targetView:a}=t(i+5);r[s++]=198,a.setUint32(s,i),s+=4}r.set(e,s)}function j8(e,t,i,r){let s=e.length;switch(s){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:s<256?(t[i++]=199,t[i++]=s):s<65536?(t[i++]=200,t[i++]=s>>8,t[i++]=s&255):(t[i++]=201,t[i++]=s>>24,t[i++]=s>>16&255,t[i++]=s>>8&255,t[i++]=s&255)}return t[i++]=r,t.set(e,i),i+=s,i}function G8(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((a,n)=>a.offset>n.offset?1:-1);i=t.pop();){let a=i.offset,n=i.id;e.copyWithin(a+r,a,s),r-=6;let o=a+r;e[o++]=214,e[o++]=105,e[o++]=n>>24,e[o++]=n>>16&255,e[o++]=n>>8&255,e[o++]=n&255,s=a}return e}function tc(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");T1.unshift(e.Class),cf.unshift(e)}N8(e)}var lC=new oC({useRecords:!1});lC.pack;lC.pack;var H8=512,W8=1024,$w=new oC({structuredClone:!0});tc({Class:$e.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,$e.prototype),e}});tc({Class:We.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,We.prototype),e}});tc({Class:fr.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,fr.prototype),e}});tc({Class:Vw.prototype.constructor,type:4,write(e){return e.id},read(e){return new Vw(e)}});tc({Class:jw.prototype.constructor,type:5,write(e){return e.data},read(e){return new jw(e)}});tc({Class:Ri.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Ri.prototype),e}});function q8(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function s0(e){if(b1(e))return e;if(Array.isArray(e))return e.map(s0);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=s0(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var a0;(e=>{function t(s){return $w.pack(s)}e.serialize=t;function i(s){return $w.unpack(s)}e.deserialize=i;function r(s){return q8(t(s0(s))).toString()}e.checksum=r})(a0||(a0={}));var e_;(e=>{function t(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=t;function i(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=i})(e_||(e_={}));function t_(e){return e==="MouseDown"||e==="MouseUp"||e==="KeyDown"||e==="KeyUp"||e==="Collision"||e==="Trigger"}var br={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},i_;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,actions:new We}:{type:r,disabled:!1,key:void 0,actions:new We}}e.defaultData=i})(i_||(i_={}));var df;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(df||(df={}));var n0;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:df.propertyDefaultData(s),rOperand:{...df.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,a){return{type:"State",object:s??null,state:a??null}}e.stateDefaultData=r})(n0||(n0={}));var r_;(e=>{function t(i){return i.find(r=>r==="ifActions"||r==="elseActions")!==void 0}e.isConditionalSubActions=t})(r_||(r_={}));var s_;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new We,outActions:new We,condition:n0.distanceDefaultData(r)}}e.defaultData=i})(s_||(s_={}));var a_;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new We,drop:new We}})(a_||(a_={}));var o0;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new We})(o0||(o0={}));var l0;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(l0||(l0={}));var n_;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new We}}e.defaultData=i})(n_||(n_={}));var o_;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new We}}e.defaultData=i})(o_||(o_={}));var l_;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new We}}e.defaultData=i})(l_||(l_={}));var h_;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,target:"character",actions:new We}}e.defaultData=i})(h_||(h_={}));var c_;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,target:"all",triggeringObjects:[],actions:new We,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(c_||(c_={}));var h0;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(n){return n.type==="Resize"}e.is=t;function i(n){return typeof n=="string"?n:"custom"}e.sizeToDevice=i;function r(n){return typeof n=="string"?[...e.defaultSizes[n]]:[...n]}e.deviceToSize=r;function s(){let n={size:"mobile",operator:"<",actions:new We},o={size:"tablet",operator:"<",actions:new We},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new We},h=new We;return h.push({id:Re.generateUUID(),fi:0,data:n},{id:Re.generateUUID(),fi:1,data:o},{id:Re.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:h}}e.defaultData=s;function a(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new We}}e.defaultBreakpointData=a})(h0||(h0={}));var c0;(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}e.is=t;function i(){return{disabled:!1,type:"VariableChange",actions:new We,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(c0||(c0={}));var d_;(e=>{function t(r){return r.type==="API"}e.is=t;function i(){return{disabled:!1,type:"API",successActions:new We,errorActions:new We,userAPIId:""}}e.defaultData=i})(d_||(d_={}));var u_;(e=>{function t(r){return r.type==="WEBHOOK"}e.is=t;function i(){return{disabled:!1,type:"WEBHOOK",actions:new We,userWebhookId:""}}e.defaultData=i})(u_||(u_={}));var p_;(e=>{function t(r){return r.type==="AIAssistantListener"}e.is=t;function i(){return{disabled:!1,type:"AIAssistantListener",actions:new We,analysis:"average",analysisRange:[0,71],analysisSingle:0}}e.defaultData=i})(p_||(p_={}));var f_;(e=>{function t(r){return r.type==="AIAssistantTrigger"}e.is=t;function i(){return{disabled:!1,description:"",type:"AIAssistantTrigger",actions:new We}}e.defaultData=i})(f_||(f_={}));var ic="personal camera",Jc="a218fcc3-276b-49b9-b485-49037fd14f5f",X8=2960946,as=5526619,cn;(e=>{function t(f,g){return f[0]===g[0]&&f[1]===g[1]}e.isEqual=t;function i(f,g,m){return[f[0]+(g[0]-f[0])*m,f[1]+(g[1]-f[1])*m]}e.lerp=i;function r(f,g){return[f[0]+g[0],f[1]+g[1]]}e.add=r;function s(f,g){return[f[0]-g[0],f[1]-g[1]]}e.sub=s;function a(f,g){return[f[0]*g[0],f[1]*g[1]]}e.multiply=a;function n(f,g){return[f[0]/g[0],f[1]/g[1]]}e.divide=n;function o(f,g){return Math.pow(g[0]-f[0],2)+Math.pow(g[1]-f[1],2)}e.distanceSquared=o;function l(f,g){return Math.sqrt(o(f,g))}e.distance=l;function h(f,g){return f[0]*g[0]+f[1]*g[1]}e.dot=h;function c(f,g){return[f[0]*g,f[1]*g]}e.scalarMultiply=c;function d(f,g,m){let v=e.sub(g,f),y=e.sub(m,f),x=e.dot(v,y)/e.dot(v,v),w=e.scalarMultiply(v,x);return e.add(f,w)}e.projectionOnto=d;function u(f,g,m){return l(f,d(f,g,m))}e.projectionOntoDistance=u;function p(f,g){return[(f[0]+g[0])*.5,(f[1]+g[1])*.5]}e.center=p})(cn||(cn={}));var il;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function s(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=s;function a(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=a;function n(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=n;function o(l,h,c){return[l[0]+(h[0]-l[0])*c,l[1]+(h[1]-l[1])*c,l[2]+(h[2]-l[2])*c]}e.lerp=o})(il||(il={}));var uf;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]&&r[2]===s[2]&&r[3]===s[3]}e.isEqual=t;function i(r,s,a){return[r[0]+(s[0]-r[0])*a,r[1]+(s[1]-r[1])*a,r[2]+(s[2]-r[2])*a,r[3]+(s[3]-r[3])*a]}e.lerp=i})(uf||(uf={}));var m_;(e=>{let t=180/Math.PI,i=Math.PI/180;function r(o){return typeof o=="number"?o*t:o}function s(o){return typeof o=="number"?o*i:o}function a(o){return[r(o[0]),r(o[1]),r(o[2])]}e.radToDeg=a;function n(o){return[s(o[0]),s(o[1]),s(o[2])]}e.degToRad=n})(m_||(m_={}));var Rh;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,a){for(let n=0;n<16;n++)if(s[n]!==a[n])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,a){let n=a.slice(0);for(var o=0,l=a.length;o<l;o+=3){let h=s[3]*a[o]+s[7]*a[o+1]+s[11]*a[o+2]+s[15];n[o]=(s[0]*a[o]+s[4]*a[o+1]+s[8]*a[o+2]+s[12])/h,n[o+1]=(s[1]*a[o]+s[5]*a[o+1]+s[9]*a[o+2]+s[13])/h,n[o+2]=(s[2]*a[o]+s[6]*a[o+1]+s[10]*a[o+2]+s[14])/h}return n}e.applyMatrix4=r})(Rh||(Rh={}));var ur;(e=>{function t(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}e.toRgb255a1=i;function r(h){return{r:h.r,g:h.g,b:h.b}}e.clone=r;function s(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}e.fromHex=s;function a(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}e.toHex=a;function n(h,c){return h.r===c.r&&h.g===c.g&&h.b===c.b}e.equals=n;function o(h,c){return h.r.toFixed(2)===c.r.toFixed(2)&&h.g.toFixed(2)===c.g.toFixed(2)&&h.b.toFixed(2)===c.b.toFixed(2)}e.equalsFixed=o;function l(h,c,d){return{r:h.r+(c.r-h.r)*d,g:h.g+(c.g-h.g)*d,b:h.b+(c.b-h.b)*d}}e.lerp=l})(ur||(ur={}));var Ht;(e=>{e.white={...ur.white,a:1},e.transparent={...ur.white,a:0};function t(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}e.from0to1=t;function i(l,h){return{...ur.fromHex(l),a:h}}e.fromHexAndA=i;function r(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}e.toRgb255a1=r;function s(l,h){return ur.equals(l,h)&&l.a===h.a}e.equals=s;function a(l,h){return ur.equalsFixed(l,h)&&l.a.toFixed(2)===h.a.toFixed(2)}e.equalsFixed=a;function n(l,h,c){return{r:l.r+(h.r-l.r)*c,g:l.g+(h.g-l.g)*c,b:l.b+(h.b-l.b)*c,a:l.a+(h.a-l.a)*c}}e.lerp=n;function o({r:l,g:h,b:c,a:d}=e.white){return`rgba(${l*255}, ${h*255}, ${c*255}, ${d})`}e.toStyle=o})(Ht||(Ht={}));var d0;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(d0||(d0={}));var Y8=(e=>(e[e.LINEAR=0]="LINEAR",e[e.EASE=1]="EASE",e[e.EASE_IN=2]="EASE_IN",e[e.EASE_OUT=3]="EASE_OUT",e[e.EASE_IN_OUT=4]="EASE_IN_OUT",e[e.CUBIC=5]="CUBIC",e[e.SPRING=6]="SPRING",e))(Y8||{}),u0;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(u0||(u0={}));var p0;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(p0||(p0={}));var Vn;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(Vn||(Vn={}));function g_(e){return typeof e=="string"&&e.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!1}var hl;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(hl||(hl={}));var Lh;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){var r,s;return i.type==="PerspectiveCamera"?((r=i.perspective)==null?void 0:r.zoom)??1:((s=i.orthographic)==null?void 0:s.zoom)??1}e.getZoom=t})(Lh||(Lh={}));var Kn;(e=>{function t(r,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*s,0,0]},grid:{count:[2,2,2],size:r.map(a=>a*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,s){let a={...r};if(hC.forEach(n=>{Object.assign(a,{[n]:s[n]??r[n]})}),a.radial={...r.radial},s.radial){let n=r.radial,o=s.radial;cC.forEach(l=>{Object.assign(a.radial,{[l]:o[l]??n[l]})})}if(a.linear={...r.linear},s.linear){let n=r.linear,o=s.linear;dC.forEach(l=>{Object.assign(a.linear,{[l]:o[l]??n[l]})})}if(a.grid={...r.grid},s.grid){let n=r.grid,o=s.grid;uC.forEach(l=>{Object.assign(a.grid,{[l]:o[l]??n[l]})})}if(a.toObject={...r.toObject},s.toObject){let n=r.toObject,o=s.toObject;pC.forEach(l=>{Object.assign(a.toObject,{[l]:o[l]??n[l]})})}if(a.randomnessObject={...r.randomnessObject},s.randomnessObject){let n=r.randomnessObject,o=s.randomnessObject;fC.forEach(l=>{Object.assign(a.randomnessObject,{[l]:o[l]??n[l]})})}return a}e.merge=i})(Kn||(Kn={}));var f0;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let a=[];r.count!==void 0&&a.push({type:0,path:s,props:{count:r.count}});for(let n of t){let o=r[n];o&&Object.keys(o).length>0&&a.push({type:0,path:[...s,n],props:o})}return a}e.toOps=i})(f0||(f0={}));var hC=["count"],cC=["radius","start","end","position","scale","rotation"],dC=["position","scale","rotation"],uC=["count","size"],pC=["count","position","scale","rotation"],fC=["strength","scale","rotation","position","movement","seed","freqScale"],m0;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(m0||(m0={}));var g0;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:Ht.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Ht.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Ht.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(g0||(g0={}));var pf;(e=>(e.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...e.defaultCollisionData}))(pf||(pf={}));var zh;(e=>e.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(zh||(zh={}));var v0;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(v0||(v0={}));var y0;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(y0||(y0={}));var x0;(e=>e.defaultData={...y0.defaultData,...v0.defaultData})(x0||(x0={}));var v_;(e=>{function t(i,r){var a,n;let s=[];if("material"in i){let o=typeof i.material=="string"?r.materials[i.material]??((a=r.lib.materials[i.material])==null?void 0:a.asset):i.material;o&&s.push(o)}else if("materials"in i)for(let o of i.materials){let l=typeof o=="string"?r.materials[o]??((n=r.lib.materials[o])==null?void 0:n.asset):o;l&&s.push(l)}return s}e.getMaterialData=t})(v_||(v_={}));var ff;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ff||(ff={}));var y_;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="particle"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(y_||(y_={}));function Q8(e){return e.type!=="displace"}var x_;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(x_||(x_={}));var mC=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Z8=["wrapping","image","video","name","minFilter","magFilter"],Ji;(e=>{function t(a,n){let{texture:o,...l}=n;if(Object.assign(a,l),o){let h=a.texture;h&&Object.assign(h,o)}}e.patch=t;function i(a,n){return a==="light"&&n?r(n):s(a)}e.defaultData=i;function r(a){let n={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...n,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...n,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...n,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...n,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(a){let n={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...n,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...n,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:ff.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...n,type:"color",color:ur.fromHex(as)};case"depth":return{...n,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...n,type:"normal",cnormal:[1,1,1]};case"gradient":return{...n,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...n,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...ur.fromHex(6710886),a:1},colorB:{...ur.fromHex(6710886),a:1},colorC:{...ur.fromHex(16777215),a:1},colorD:{...ur.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...n,type:"fresnel",color:Ht.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...n,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...n,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Ht.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...n,type:"outline",outlineColor:Ht.fromHexAndA(0,1),contourColor:Ht.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...n,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...n,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...n,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...ur.fromHex(0),a:1},colorB:{...ur.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Ji||(Ji={}));var ir;(e=>{function t(c){return!c.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}e.isMergable=t;function i(c){let d="";return c.layers.forEach(u=>{Object.entries(u.data).forEach(([p,f])=>{d+=`${p}${f}`,Array.isArray(f)?f.forEach(g=>d+=`${g}`):typeof f=="object"?Object.values(f).forEach(g=>{typeof g=="number"?d+=`${g.toFixed(4)}`:d+=`${g}`}):d+=`${f}`})}),d}e.getHash=i;function r(){return{layers:new We}}e.defaultEmptyData=r;function s(c="layer1",d="layer2"){return n("phong",c,d)}e.defaultData=s;function a(c,d){return{...c,name:d}}e.withName=a;function n(c,d="layer1",u="layer2"){let p=new We;return p.push({fi:0,data:Ji.defaultData("light",c),id:d}),p.push({fi:1,data:Ji.defaultData("color"),id:u}),{layers:p}}e.defaultTwoLayerData=n;function o(c){let d=Ji.defaultData("texture");c&&Object.assign(d.texture,{image:c});let u=new We;return u.push({fi:0,data:d,id:"layer1"}),u.push({fi:1,data:{...Ji.defaultData("transmission"),alpha:1},id:"layer2"}),u.push({fi:2,data:{...Ji.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:u}}e.defaultUIObjectMaterial=o;function l(c,d="phong",u="layer1",p="layer2"){let f=Ji.defaultData("texture");Object.assign(f.texture,{image:c});let g=new We;return g.push({fi:0,data:f,id:u}),g.push({fi:1,data:Ji.defaultData("light",d),id:p}),{layers:g}}e.defaultTwoLayerTextureData=l;function h(c,d="phong",u="layer1",p="layer2"){let f=Ji.defaultData("video");Object.assign(f.texture,{video:c});let g=new We;return g.push({fi:0,data:f,id:u}),g.push({fi:1,data:Ji.defaultData("light",d),id:p}),{layers:g}}e.defaultTwoLayerVideoTextureData=h})(ir||(ir={}));var mf;(e=>{function t(){return{points:new We,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(mf||(mf={}));var gf;(e=>{function t(){return{points:new We,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(gf||(gf={}));var gC={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},b0;(e=>{function t(i,r){let s={...i};return yC.forEach(a=>{Object.assign(s,{[a]:r[a]??i[a]})}),s}e.merge=t})(b0||(b0={}));var vC={shape:gC,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},yC=["depth","offset","angle","twist","startScale","endScale"],vf;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"||r==="InputGeometry"}e.isParametricMesh=i})(vf||(vf={}));var w0;(e=>{function t(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,b0.merge(s.extrusion,r.extrusion))),s}e.merge=t})(w0||(w0={}));var Gn;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:gf.defaultData(),extrusion:vC};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:mf.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="ShapeBlendGeometry")return{type:i,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="InputGeometry")return{...e.defaultData("TextGeometry"),type:i,editable:!0};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}e.defaultData=t})(Gn||(Gn={}));var vg=["width","height","depth"],_0;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:ur.white,near:.1,far:2e3})(_0||(_0={}));var yf;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})(yf||(yf={}));var S0;(e=>e.defaultData={softShadowQuality:"low"})(S0||(S0={}));var A0;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(A0||(A0={}));var M0;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(M0||(M0={}));var Bh;(e=>e.defaultData={usePhysics:!1,gravity:-10})(Bh||(Bh={}));var E0;(e=>e.defaultData={playCamera:ic,gameControlObject:null})(E0||(E0={}));var C0;(e=>e.defaultData={backgroundColor:Ht.fromHexAndA(X8,1),postprocessing:yf.defaultData,fog:_0.defaultData,globalPhysics:Bh.defaultData,ambient:A0.defaultData,ao:M0.defaultData,shadow:S0.defaultData,publish:E0.defaultData})(C0||(C0={}));var T0;(e=>e.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(T0||(T0={}));var b_;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(b_||(b_={}));var Fh;(e=>{e.identity={...d0.identity,hiddenMatrix:Rh.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,a){return{position:(a==null?void 0:a.position)||s.position,rotation:(a==null?void 0:a.rotation)||s.rotation,scale:(a==null?void 0:a.scale)||s.scale,hiddenMatrix:(a==null?void 0:a.hiddenMatrix)||s.hiddenMatrix}}e.merge=i;function r(s,a){return LE({position:il.isEqual(s.position,a.position)?void 0:a.position,rotation:il.isEqual(s.rotation,a.rotation)?void 0:a.rotation,scale:il.isEqual(s.scale,a.scale)?null:a.scale,hiddenMatrix:Rh.isEqual(s.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}e.diff=r})(Fh||(Fh={}));var Hi;(e=>e.defaultData={states:new We,events:new We,visible:!0,raycastLock:!1,physics:zh.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Fh.identity,cloner:null})(Hi||(Hi={}));var P0;(e=>e.defaultData={type:"Empty",...Hi.defaultData})(P0||(P0={}));var w_;(e=>e.defaultData={type:"ParticleCollider",...T0.defaultData,...Hi.defaultData})(w_||(w_={}));var __;(e=>e.defaultData={type:"Component",...Hi.defaultData})(__||(__={}));var S_;(e=>e.defaultData={type:"Particle",...Hi.defaultData,...pf.defaultData})(S_||(S_={}));var Hn;(e=>e.defaultData={type:"Mesh",...Hi.defaultData,...x0.defaultData})(Hn||(Hn={}));var Sd;(e=>e.defaultData={...Hi.defaultData,...Fh.identity,position:[0,0,Lh.DefaultTargetOffset],...Lh.defaultData})(Sd||(Sd={}));var D0;(e=>{function t(i){return{...Hi.defaultData,...g0.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(D0||(D0={}));var xf;(e=>{function t(r,s,a=0){for(;a<s.length;){let n=r?r[s[a]]:void 0;if(s.length===a+1)return n;if(n)r=n.descendants,a+=1;else return}}e.resolveWithDes=t;function i(r,s,a=0){let n=t(r,s,a);if(n){let o=Object.keys(n);if(o.length===1&&o[0]==="descendants")return}return n}e.resolve=i})(xf||(xf={}));var Jn;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Hi.defaultData,...s,component:r,overrides:new Ri,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=Fh.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(Jn||(Jn={}));var Uh;(e=>{e.defaultData={type:"Page",...Hi.defaultData,physics:{...zh.defaultData,fusedBody:!1},...C0.defaultData,camera:Sd.defaultData};function t(i){return i.uiScene!==void 0}e.isUIPage=t})(Uh||(Uh={}));var I0;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Rh.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:zh.defaultData,states:new We,events:new We,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Lh.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Hi.defaultData,...Hn.defaultData,geometry:Gn.defaultData("RectangleGeometry"),material:ir.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Hi.defaultData,...Hn.defaultData,geometry:Gn.defaultData("BooleanGeometry"),material:ir.defaultTwoLayerData("phong","layer1","layer2")},e.defaultShapeBlendObject={name:"Shape Blend",...Hi.defaultData,...Hn.defaultData,geometry:Gn.defaultData("ShapeBlendGeometry"),material:ir.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Hi.defaultData,...Hn.defaultData,geometry:Gn.defaultData("TextGeometry"),material:ir.defaultTwoLayerData("phong","layer1","layer2")},e.defaultInputObject={name:"Input",...Hi.defaultData,...Hn.defaultData,geometry:Gn.defaultData("InputGeometry"),material:ir.defaultTwoLayerData("phong","layer1","layer2")}))(I0||(I0={}));var Wo;(e=>{function t(a,n){let o={name:n};return a.type==="Mesh"?(o.geometry={},"material"in a&&(o.material={layers:new Ri}),"materials"in a&&(o.materials=a.materials.map(l=>({layers:new Ri})))):hl.is(a.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(a,n){if(n===void 0)return a;let o={...a};return"material"in o&&"material"in n&&n.material&&(o.material=_d(o.material,l=>{if(typeof l!="string")for(let[h,c]of Object.entries(n.material.layers)){let d=l.layers.data(h);d&&Ji.patch(d,c)}}).data),o.materials&&n.materials&&(o.materials=_d(o.materials,l=>{var h,c;for(let d=0;d<o.materials.length;d++){let u=n.materials[d];if(typeof u!="string")for(let[p,f]of Object.entries(u.layers)){let g=(c=(h=l[d])==null?void 0:h.layers)==null?void 0:c.data(p);g&&Ji.patch(g,f)}}}).data),o}function r(a,n){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function c(d,u){for(let[p,f]of Object.entries(u.layers)){let{texture:g,...m}=f;if(g!==void 0&&Object.keys(g).length>0){let v={path:[...d,"layers",p,"texture"],props:g,type:0};l.push(v)}if(Object.keys(m).length>0){let v={path:[...d,"layers",p],props:m,type:0};l.push(v)}}}for(let[d,u]of Object.entries(n))if(d!=="name")if(d==="cloner")l.push(...f0.toOps(u,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:u.slide,offset:u.offset},type:0});else if(d==="material")c(["material"],u);else if(d==="materials")for(let[p,f]of Object.entries(u))c(["materials",p],f);else if(h[d]===0){if(d==="geometry"&&u.extrusion!==void 0){let p={path:[d,"extrusion"],props:u.extrusion,type:0};l.push(p),u={...u},delete u.extrusion}if(Object.keys(u).length>0){let p={path:[d],props:u,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[d]=u;return l}e.toOps=r;function s(a,n){var l,h,c,d,u,p;if(n===void 0)return a;let o={...a};if(Object.assign(o,Fh.merge(o,n)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:((l=n.pathSnapping)==null?void 0:l.slide)??((h=o.pathSnapping)==null?void 0:h.slide)??0,offset:((c=n.pathSnapping)==null?void 0:c.offset)??((d=o.pathSnapping)==null?void 0:d.offset)??0})}),hl.is(a.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let f=n;((u=f.orthographic)==null?void 0:u.zoom)!==void 0&&(o.orthographic.zoom=f.orthographic.zoom),((p=f.perspective)==null?void 0:p.zoom)!==void 0&&(o.perspective.zoom=f.perspective.zoom),f.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=f.isUpVectorFlipped),f.targetOffset!==void 0&&(o.targetOffset=f.targetOffset)}else if(a.type==="Mesh")"geometry"in n&&Object.assign(o,{geometry:w0.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:Kn.merge(o.cloner,n.cloner)});else if(a.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:Kn.merge(o.cloner,n.cloner)});else if(m0.is(a.type)){let f=n;f.intensity!==void 0&&(o.intensity=f.intensity),f.color!==void 0&&(typeof f.color=="string"?o.color=f.color:o.color=ur.clone(f.color))}return o}e.patch=s})(Wo||(Wo={}));var bf;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(bf||(bf={}));var dn;(e=>e.defaultData={orbitControls:bf.defaultData,playPage:Jc,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(dn||(dn={}));var O0;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(O0||(O0={}));var R0;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(R0||(R0={}));var qo;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...O0.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:R0.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(qo||(qo={}));var Ad;(e=>{function t(r){return r.find(s=>s.data.type==="Page"&&s.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,s,a){r.scene.objects.traverseFrom(s,(n,o)=>{var l;if(o.type==="Instance"){let h=(l=Sf.getComponentData(r,o.component))==null?void 0:l.data;h&&a(n,o,h.events)}else a(n,o,o.events)})}e.traverseModuleInstances=i})(Ad||(Ad={}));var Xo;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",e.defaultLight={fi:-1,data:D0.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function t(s=!0,a=[]){let n=[],o=I0.defaultMeshObject;s&&(n.push({...e.defaultLight}),n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:o,children:[]})),n.push(...a);let l=new fr;return l.push({fi:1,id:Jc,data:{...Uh.defaultData,name:"Scene 1"},children:n}),l}e.createDefaultObjectTreeWithPage=t,e.defaultData={objects:t(),publish:dn.defaultData,styles:qo.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new fr,publish:dn.defaultData,styles:qo.defaultData()}},e.emptyDataWithPage=function(s=!0){return{objects:t(s),publish:dn.defaultData,styles:qo.defaultData()}},e.emptyData=function(){return{objects:new fr,publish:{...dn.defaultData},styles:qo.defaultData()}};function i(s){return{...e.defaultData,objects:Ms(s,fr.prototype)}}e.withObjs=i;function r(s,a){return i([{id:s,data:a,children:[],fi:0}])}e.withObj=r})(Xo||(Xo={}));var $c;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})($c||($c={}));var L0;(e=>(e.defaultData=t=>({url:t,name:"New Webhook",parametersSchemas:new We}),e.defaultParameterValueByType=t=>t==="number"?0:t==="boolean"?!1:""))(L0||(L0={}));var A_;(e=>e.defaultData=(t,i="GET")=>({url:t,method:i,name:"New API",headers:new We,queries:new We,autoStart:!0}))(A_||(A_={}));var mr;(e=>{function t(n){return n.textValue!==void 0}e.isTextValue=t;function i(n){return typeof n=="number"}e.isNumber=i;function r(n){return typeof n=="boolean"}e.isBoolean=r;function s(n){return t(n)?"string":r(n)?"boolean":"number"}e.typeOfVariable=s;function a(n){return e.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(o=>o.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():e.isBoolean(n)?n?"True":"False":e.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}e.getDisplayedValue=a})(mr||(mr={}));var z0;(e=>e.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(z0||(z0={}));var M_;(e=>e.all=[...z0.all,"components"])(M_||(M_={}));var E_;(e=>{function t(){return{images:new $e,videos:new $e,colors:new $e,audios:new $e,particles:new $e,fonts:new $e,materials:new $e,components:new $e,variables:new $e,userAPIs:new $e,userWebhooks:new $e}}e.defaultData=t})(E_||(E_={}));var yn;(e=>{function t(){return{images:new $e,videos:new $e,colors:new $e,audios:new $e,particles:new $e,fonts:new $e,materials:new $e,components:new $e,variables:new $e,userAPIs:new $e,userWebhooks:new $e}}e.defaultData=t})(yn||(yn={}));var vs;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ms(n,$e.prototype)}e.defaultColors=t;function i(){return Ms({},$e.prototype)}e.defaultImages=i;function r(){return{catelogs:new $e,materials:new $e,images:new $e,videos:new $e,colors:new $e,audios:new $e,particles:new $e,fonts:new $e,variables:new We,userAPIs:new $e,userWebhooks:new $e,lib:yn.defaultData()}}e.emptyData=r;function s(n){switch(n){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",n)}}e.defaultVariables=s;function a(n,o){if(o.format==="HH:mm:ss"){let l=Math.floor(n/3600),h=Math.floor((n-l*3600)/60),c=Math.round(n-l*3600-h*60);return{textValue:[l,h,c]}}else if(o.format==="mm:ss"){let l=Math.floor(n/60),h=Math.round(n-l*60);return{textValue:[l,h]}}else return o.format==="number"?n=Math.round(n):n=Math.round(n*1e3)/1e3,n}e.getFormattedTimerTime=a})(vs||(vs={}));var wf;(e=>e.list=["idle","move","jump","run"])(wf||(wf={}));var _f;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","▲"],["rotPosY","◀"],["rotNegX","▼"],["rotNegY","▶"],["jump","Space"],["run","⇧"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new We,move:new We,jump:new We,run:new We},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ht.fromHexAndA(3728051,1)}}))(_f||(_f={}));function C_(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],a=[0,1];for(let o=2;o<10;o++)s.push(s[1]),a.push(1);let n={...Sa(wi(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:a,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,n)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...wi(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Wn(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function qn(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,a)=>{s===void 0&&(r.materials[a]=ir.defaultData(),s=r.materials[a]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=ir.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=ir.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==Ri.prototype&&t(s.material)})})}function K8(e){Object.assign(e.scene.publish,{orbitControls:{...bf.defaultData,...wi(e.scene.publish.orbitControls)}})}function J8(e){Object.assign(e.scene.publish.settings,{video:{...dn.defaultData.settings.video,...wi(e.scene.publish.settings.video)}})}function $8(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,a]of Object.entries(r))if((mC.includes(s)||typeof a=="boolean")&&delete r[s],s==="texture")for(let[n,o]of Object.entries(a))(Z8.includes(n)||typeof o=="boolean")&&delete a[n]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let a=s;a.material?t(a.material):a.materials&&a.materials.forEach(n=>{t(n)})})})}function e9(e){e.scene.publish.withBackground=!0}function t9(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function i9(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(s=>s+1),r.linear.scale=r.linear.scale.map(s=>s+1))})}function r9(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function s9(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=wi(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=wi(i).booleanExclude!==!0)}})}function a9(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function n9(e){function t(r){Object.setPrototypeOf(r,Ri.prototype),r.texture&&Object.setPrototypeOf(r.texture,Ri.prototype)}function i(r){Object.setPrototypeOf(r,Ri.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(a=>{let n=a;if(n.material){let o=wi(n.material).layers;i(o),n.material.layers=o}if(n.materials)for(let o=0;o<n.materials.length;o++){let l=n.materials[o],h=wi(l).layers;i(h),l.layers=h}})})}function T_(e){e.layers===void 0&&Object.assign(e,ir.defaultTwoLayerData("lambert"))}function yg(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let s={...wi(t),colors:i,steps:r};Object.assign(t,s)}})}function o9(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function P_(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&yg(r)}):"material"in i&&typeof i.material!="string"&&yg(i.material)}),Object.values(e.shared.materials).forEach(t=>yg(t))}function l9(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function h9(e){e.shared.audios=Ms({},$e.prototype)}function c9(e){e.shared.videos=Ms({},$e.prototype)}function d9(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let s={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:s})}})}function u9(e){Object.entries(wi(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(wi(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function p9(e){e.scene.publish.settings.web.preload=!1}function D_(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function I_(e){e.layers&&e.layers.forEach(t=>{Q8(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function f9(e){e.shared.fonts=Ms({},$e.prototype)}function m9(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function g9(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let a=ir.defaultTwoLayerData("phong"),n=typeof s.color=="string"?e.shared.colors[s.color]:s.color;a.layers[1].data.color={r:n.r,g:n.g,b:n.b},a.layers[1].data.alpha=s.alpha;let o=m9(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Hi.defaultData,...Hn.defaultData,flatShading:!1,wireframe:!1,geometry:{...Gn.defaultData("TextGeometry"),width:s.width,height:s.height,font:o,depth:0,horizontalAlign:s.horizontalAlign,verticalAlign:s.verticalAlign,fontSize:s.fontSize*1.40625,lineHeight:s.lineHeight/1.40625,letterSpacing:s.letterSpacing-1,text:s.text,textTransform:s.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:a,states:wi(s.states),events:wi(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=wi(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function v9(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(s=>{if(t[Number(s.type)])if(Object.assign(s,{type:t[Number(s.type)]}),s.type==="Audio"&&"audioEvent"in s&&(Object.assign(s,{playAudio:s.audioEvent}),delete s.audioEvent),s.type==="GameControl")Object.assign(s,{gameActions:{idle:new We,move:new We,jump:new We}});else{let a=new We;Object.assign(s,{actions:a}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&a.push({fi:0,id:Re.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((n,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(c,Sa(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(c,{control1:{...n.control1},control2:{...n.control2}});let d={repeat:n.repeat?-1:0,delay:n.delay,delayDirection:n.delayDirection,direction:n.cycle&&n.rewind?"pingpong-rewind":n.cycle?"pingpong":"normal"},u={state:n.state,...d,...c},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new We({fi:0,id:Re.generateUUID(),data:h},{fi:1,id:Re.generateUUID(),data:u})};a.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function y9(e){e.scene.objects.traverse((t,i)=>{function r(s,a){var l;let n=new We,o=[];if(i.events.forEach((h,c,d)=>{if(h.type==="Audio"&&h.trigger===a){let u;o.push(c),h.interaction==="play"?u={...Sa(h,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in h?h.after:void 0,toggle:"after"in h?h.toggle:void 0,type:"Audio"}:(h.interaction==="pause"||h.interaction==="stop")&&(u={...Sa(h,"interaction","delay","object","playAudio"),type:"Audio"}),u&&n.push({fi:d,id:c,data:u})}}),o.forEach(h=>i.events.delete(h)),n.length){let h=(l=i.events.find(c=>c.type===s))==null?void 0:l.data;h?"actions"in h&&h.actions.insertBefore(null,n):i.events.insertBefore(null,[{id:Re.generateUUID(),data:{type:s,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function O_(e){var i;let t=(i=e.layers.find(r=>r.type==="light"))==null?void 0:i.data;if((t==null?void 0:t.category)==="basic"){let r=Ji.defaultData("light","phong"),s=t;Object.assign(s,r),s.visible=!1}}function R_(e){Wn(e,O_),qn(e,O_)}function x9(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function b9(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function w9(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=ir.defaultTwoLayerData("phong"))})}function _9(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function S9(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function A9(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function M9(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function E9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function C9(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function T9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=_f.defaultDataThirdPerson.navmesh)})})}function P9(e){e.scene.styles||(e.scene.styles=qo.defaultData())}function L_(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function D9(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),qn(e,L_),Wn(e,L_)}function I9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new We})})})}function O9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","⇧"],["none","Ctrl"]])})})}function z_(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function R9(e,t){if(t<1&&(qn(e,C_),Wn(e,C_),e.schema=1),t<2&&(K8(e),e.schema=2),t<3&&($8(e),e.schema=3),t<4&&(e9(e),e.schema=4),t<5&&(t9(e),e.schema=5),t<6&&(i9(e),e.schema=6),t<7&&(r9(e),e.schema=7),t<8&&(e.schema=8),t<9&&(P_(e),e.schema=9),t<10&&(o9(e),e.schema=10),t<11&&(l9(e),e.schema=11),t<12&&(P_(e),e.schema=12),t<13&&(h9(e),e.schema=13),t<14&&(d9(e),e.schema=14),t<15&&(u9(e),e.schema=15),t<16&&(p9(e),e.schema=16),t<17&&(qn(e,D_),Wn(e,D_),e.schema=17),t<18&&(qn(e,T_),Wn(e,T_),e.schema=18),t<19&&(J8(e),e.schema=19),t<20&&(f9(e),g9(e),e.schema=20),t<21&&(v9(e),y9(e),e.schema=21),t<22&&(R_(e),e.schema=22),t<23&&(x9(e),e.schema=23),t<24&&(b9(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(c9(e),t<25&&(e.schema=25)),t<26&&(s9(e),e.schema=26),t<27&&(a9(e),e.schema=27),t<28&&(R_(e),e.schema=28),t<29&&(n9(e),e.schema=29),t<30&&(w9(e),e.schema=30),t<31&&(_9(e),e.schema=31),t<33&&(S9(e),e.schema=33),t<34&&(A9(e),e.schema=34),t<35&&(M9(e),e.schema=35),t<36&&(E9(e),e.schema=36),t<37&&(C9(e),e.schema=37),t<38&&(qn(e,I_),Wn(e,I_),e.schema=38),t<39&&(T9(e),e.schema=39),t<40&&(P9(e),e.schema=40),t<41&&(D9(e),e.schema=41),t<42&&(I9(e),e.schema=42),t<43&&(O9(e),e.schema=43),t<99){qn(e,z_),Wn(e,z_),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=ic);let i=wi(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=Jc,r.insertBefore(null,null,[{id:Jc,data:{...Uh.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:Sa(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:Sa(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Bh.defaultData,...Sa(e.scene.environment,"usePhysics","gravity")},camera:wi(e.scene.ownerCamera)??Uh.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==Xo.TRASH_CAN_ID&&r.move(Jc,n.fi,n.id);let s=0,a=0;e.shared.penumbraSize&&e.scene.objects.traverse((n,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(s,2)],s+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(a,1)],a+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,zh.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function B_(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function L9(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function z9(e){var t;Array.isArray(wi(e.events))&&((t=e.events)==null||t.forEach(i=>{"disabled"in i||(i.disabled=!1),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress")&&(i.mode=i.mode||"Object")}))}var ih=180/Math.PI;function F_(e){e.rotation=e.rotation.slice(0,3).map(t=>t*ih)}function xC(e){var i,r;F_(e),e.type==="Page"&&F_(e.camera),(i=e.states)==null||i.forEach(s=>{s.rotation===void 0||s.rotation===null||(s.rotation=s.rotation.slice(0,3).map(a=>a*ih))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*ih),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*ih),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=ih,t.extrusion.twist*=ih),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(wi(e.events))&&((r=e.events)==null||r.forEach(s=>{(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="MousePress"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="KeyPress"||s.type==="Collision"||s.type==="Trigger")&&(s.runMode=s.toggle?"Toggle":"Repeat")}))}function B9(e){e.shared.variables=Ms({},$e.prototype)}function F9(e){let t=wi(e.shared.variables);e.shared.variables=Ms(Object.entries(t??{}).map(([i,r],s)=>({fi:s,id:i,data:r})),We.prototype)}var $a=117;function bC(e,t){t(e.data);for(let i of e.children)bC(i,t)}function U9(e){let t=e.schema??104;t!==$a&&t<105&&(bC(e.asset,xC),e.schema=105)}function N9(e){e.shared.particles=Ms({},$e.prototype),e.shared.lib&&(e.shared.lib.particles=yn.defaultData().particles)}function k9(e){e.scene.objects.traverse((t,i)=>{i.type==="Particle"&&typeof i.renderMaterial.size=="number"&&Object.assign(i.renderMaterial,{size:[i.renderMaterial.size,i.renderMaterial.size]})})}function V9(e){e.scene.objects.traverse((t,i)=>{i.type==="Page"&&(i.postprocessing.depthOfField.focusDistance=100,i.postprocessing.depthOfField.focalLength=20,i.postprocessing.depthOfField.bokehScale=5)})}function j9(e){e.scene.objects.traverse((t,i)=>{var r;Array.isArray(wi(i.events))!==!1&&((r=i.events)==null||r.forEach(s=>{var n,o,l,h,c,d,u,p,f,g,m;let a=s.runMode;s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp"||s.type==="Collision"||s.type==="Trigger"?(n=s.actions)==null||n.forEach(v=>{v.type==="Transition"&&(v.runMode=a??"Repeat"),(v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode=a==="Toggle"?"Toggle":"Normal")}):s.type==="MouseHover"||s.type==="MousePress"||s.type==="KeyPress"?(o=s.actions)==null||o.forEach(v=>{(v.type==="Transition"||v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Toggle")}):s.type==="GameControl"?(delete s.actions,Object.keys(s.gameActions).forEach(v=>{var y;(y=s.gameActions[v])==null||y.forEach(x=>{x.type==="Transition"&&(x.runMode="Repeat"),x.type==="Animation"&&(x.runMode="Normal")})})):s.type==="DragDrop"?(delete s.actions,(h=(l=s.dragDropActions)==null?void 0:l.drag)==null||h.forEach(v=>{(v.type==="Transition"||v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Toggle")}),(d=(c=s.dragDropActions)==null?void 0:c.drop)==null||d.forEach(v=>{(v.type==="Transition"||v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Toggle")})):s.type==="Resize"?(delete s.actions,(u=s.breakpoints)==null||u.forEach(v=>{var y;(y=v.actions)==null||y.forEach(x=>{(x.type==="Transition"||x.type==="Animation"||x.type==="SwitchCamera")&&(x.runMode="Toggle")})})):s.type==="Start"?(p=s.actions)==null||p.forEach(v=>{v.type==="Transition"&&(v.runMode="Once"),(v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Normal")}):s.type==="VariableChange"||s.type==="Scroll"?(f=s.actions)==null||f.forEach(v=>{v.type==="Transition"&&(v.runMode="Repeat"),(v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Normal")}):s.type==="Conditional"&&(delete s.actions,(g=s.inActions)==null||g.forEach(v=>{v.type==="Transition"&&(v.runMode="Repeat"),(v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Normal")}),(m=s.outActions)==null||m.forEach(v=>{v.type==="Transition"&&(v.runMode="Repeat"),(v.type==="Animation"||v.type==="SwitchCamera")&&(v.runMode="Normal")}))}))})}function G9(e){e.shared.userAPIs=Ms({},$e.prototype),e.shared.userWebhooks=Ms({},$e.prototype),e.shared.lib&&(e.shared.lib.userAPIs=yn.defaultData().userAPIs,e.shared.lib.userWebhooks=yn.defaultData().userWebhooks)}function H9(e){e.scene.publish.settings.videoStatic===void 0&&(e.scene.publish.settings.videoStatic=dn.defaultData.settings.videoStatic)}function wC(e){let t=e.schema??0;if(t!==$a){console.warn("updating from ",t,"to ",$a),R9(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=dn.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(qn(e,B_),Wn(e,B_),e.schema=101),t<102&&(L9(e),e.schema=102),t<104&&(e.shared.catelogs=new $e,e.shared.lib=yn.defaultData(),e.schema=104),t<105&&(B9(e),e.scene.objects.traverse((i,r)=>{xC(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))U9(i);t<106&&(F9(e),e.schema=106),t<107&&(e.shared.lib.variables=yn.defaultData().variables,e.schema=107),t<109&&(N9(e),e.schema=109),t<110&&(k9(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{z9(r)}),e.schema=111),t<112&&(V9(e),e.schema=112),t<113&&(j9(e),e.schema=113),t<114&&(e.scene.publish.settings.web.imageQuality===void 0&&(e.scene.publish.settings.web.imageQuality=70),e.schema=114),t<115&&(G9(e),e.schema=115),t<116&&(H9(e),e.schema=116),t<117&&(e.scene.publish.settings.web.pixelRatioMobile===void 0&&(e.scene.publish.settings.web.pixelRatioMobile=0),e.scene.publish.settings.web.pixelRatioDesktop===void 0&&(e.scene.publish.settings.web.pixelRatioDesktop=0),e.schema=117)}}var Sf;(e=>{e.defaultData={schema:$a,scene:Xo.defaultData,frames:new $e().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",$c.defaultData),shared:{...vs.emptyData(),colors:vs.defaultColors()}},e.emptyDataForImports=function(){let a=Xo.emptyDataWithPage();return{schema:$a,scene:a,frames:new $e().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",$c.defaultData),shared:{...vs.emptyData(),colors:vs.defaultColors(),images:vs.defaultImages()}}},e.emptyData=function(){return{schema:$a,scene:Xo.emptyDataWithPage(),frames:new $e().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",$c.defaultData),shared:vs.emptyData()}},e.clipboard2dData=function(){return{schema:$a,scene:Xo.emptyData(),frames:new $e,shared:vs.emptyData()}},e.collabHelper={...e0,updateSchema(a){return(a.schema??0)<$a?_d(a,wC):(a.schema??0)-$a}};function t(a){let n=e.collabHelper.updateSchema(a);return typeof n=="number"?n===0?a:null:n.data}e.updateSchemaDirectly=t;function i(a){return{...a,shared:{...a.shared,lib:yn.defaultData()}}}e.withoutLib=i;function r(a,n){let o=a.scene.objects.get(n);if(o&&o.data.type==="Component")return o;{let l=a.shared.lib.components[n];if(l)return l.asset}}e.getComponentData=r;function s(a){let n=Object.values(a.shared.userAPIs);for(let o of n){let l=o.headers;for(let h of l)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}e.hasSensitiveData=s})(Sf||(Sf={}));var B0;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(B0||(B0={}));var U_;(e=>{function t(i){return!0}e.is=t})(U_||(U_={}));var Af;(e=>{e.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(r,s){return{position:(s==null?void 0:s.position)??r.position,rotation:(s==null?void 0:s.rotation)??r.rotation,scale:(s==null?void 0:s.scale)??r.scale,shear:(s==null?void 0:s.shear)??r.shear}}e.merge=t;function i(r,s){return LE({position:cn.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:cn.isEqual(r.scale,s.scale)?void 0:s.scale,shear:r.shear&&s.shear&&cn.isEqual(r.shear,s.shear)?void 0:s.shear})}e.diff=i})(Af||(Af={}));var F0;(e=>e.defaultData={horizontalConstraint:0,verticalConstraint:0})(F0||(F0={}));var N_;(e=>e.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})(N_||(N_={}));var Mf;(e=>e.defaultData={opacity:1,fill:{color:Ht.fromHexAndA(as,1),enabled:!0},stroke:{color:Ht.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Ht.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Ht.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Mf||(Mf={}));var Yo;(e=>{function t(n,o){return{name:o}}e.newEmpty=t;function i(n,o){if(o===void 0)return n;let l={...n},h=["width","height","cornerRadius"];for(let c of h)c in l&&c in o&&o[c]!==void 0&&Object.assign(l,{[c]:o[c]});return l}function r(n,o){if(o===void 0)return n;let l={...n};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}function s(n,o){if(o===void 0)return n;let l={...n};return Object.assign(l,Af.merge(l,o)),l=i(l,o),l=r(l,o),l}e.patch=s;function a(n,o){let l,h=[];for(let[c,d]of Object.entries(o))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},h.push(l)),l.props[c]=d);return h}e.toOps=a})(Yo||(Yo={}));var Md;(e=>e.defaultData={...Af.defaultData,...F0.defaultData,states:new We,events:new We,visible:!0,raycastLock:!1})(Md||(Md={}));var Nh;(e=>e.defaultData={...Md.defaultData,...Mf.defaultData})(Nh||(Nh={}));var Ef;(e=>e.defaultData={cornerRadius:[0,0,0,0]})(Ef||(Ef={}));var U0;(e=>e.defaultData={...Nh.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(U0||(U0={}));var Ed;(e=>e.defaultData={...Nh.defaultData,...Ef.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Ed||(Ed={}));var N0;(e=>e.defaultData={...Nh.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(N0||(N0={}));var k0;(e=>e.defaultData={...Nh.defaultData,type:"path2d",path:"",name:"Path"})(k0||(k0={}));var k_;(e=>{function t(i){return i.type==="ellipse2d"||i.type==="rectangle2d"||i.type==="text2d"||i.type==="vector2d"||i.type==="path2d"}e.is=t})(k_||(k_={}));var Cf;(e=>e.defaultData={...Md.defaultData,name:"Group",type:"group2d"})(Cf||(Cf={}));var V0;(e=>e.defaultData=()=>({...Md.defaultData,...Ef.defaultData,...Mf.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Ht.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Ht.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(V0||(V0={}));var rl;(e=>{function t(n){switch(n){case"rectangle2d":return{...Ed.defaultData};case"ellipse2d":return{...U0.defaultData};case"text2d":return{...N0.defaultData};case"vector2d":return{...Ed.defaultData};case"path2d":return{...k0.defaultData};case"frame2d":return{...V0.defaultData()};case"group2d":return{...Cf.defaultData}}}e.defaultData=t;function i(n){return"width"in n&&"height"in n?[typeof n.width=="number"?n.width*.5:0,typeof n.height=="number"?n.height*.5:0]:[0,0]}e.getPivot=i;function r(n){return n.type==="rectangle2d"||n.type==="ellipse2d"||n.type==="text2d"||n.type==="frame2d"}e.isResizeable=r;function s(n){return n.type==="frame2d"&&n.autoLayout!==void 0}e.isAutoLayoutable=s;function a(n){return n.type==="rectangle2d"||n.type==="frame2d"}e.hasCorners=a})(rl||(rl={}));var j0;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new fr},e.emptyData=function(){return{type:"scene2d",objects:new fr}}))(j0||(j0={}));function Qo(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),a={},n={},o=e[0].morphTargetsRelative,l=new Ge,h=0;for(let c=0;c<e.length;++c){let d=e[c],u=0;if(i!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in d.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(d.attributes[p]),u++}if(u!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in d.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;n[p]===void 0&&(n[p]=[]),n[p].push(d.morphAttributes[p])}if(t){let p;if(i)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,c),h+=p}}if(i){let c=0,d=[];for(let u=0;u<e.length;++u){let p=e[u].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+c);c+=e[u].attributes.position.count}l.setIndex(d)}for(let c in a){let d=V_(a[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(let c in n){let d=n[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let u=0;u<d;++u){let p=[];for(let g=0;g<n[c].length;++g)p.push(n[c][g][u]);let f=V_(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(f)}}return l}function V_(e){let t,i,r,s=0;for(let o=0;o<e.length;++o){let l=e[o];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=l.itemSize),i!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=l.array.length}let a=new t(s),n=0;for(let o=0;o<e.length;++o)a.set(e[o].array,n),n+=e[o].array.length;return new tt(a,i,r)}var W9=Math.pow(2,-24),Ru=class{constructor(){}};function xa(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function j_(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let s=e[r+3]-e[r];s>i&&(i=s,t=r)}return t}function G_(e,t){t.set(e)}function H_(e,t,i){let r,s;for(let a=0;a<3;a++){let n=a+3;r=e[a],s=t[a],i[a]=r<s?r:s,r=e[n],s=t[n],i[n]=r>s?r:s}}function Lu(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],a=t[e+2*r+1],n=s-a,o=s+a;n<i[r]&&(i[r]=n),o>i[r+3]&&(i[r+3]=o)}}function xc(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function q9(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;i>65535?s=new Uint32Array(new r(4*i)):s=new Uint16Array(new r(2*i)),e.setIndex(new tt(s,1));for(let a=0;a<i;a++)s[a]=a}}function X9(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let s of e.groups)i.add(s.start),i.add(s.start+s.count);let r=Array.from(i.values()).sort((s,a)=>s-a);for(let s=0;s<r.length-1;s++){let a=r[s],n=r[s+1];t.push({offset:a/3,count:(n-a)/3})}return t}function xg(e,t,i,r,s=null){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0,d=1/0,u=1/0,p=1/0,f=-1/0,g=-1/0,m=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let w=e[y+0],_=e[y+1],b=w-_,A=w+_;b<a&&(a=b),A>l&&(l=A),v&&w<d&&(d=w),v&&w>f&&(f=w);let S=e[y+2],E=e[y+3],C=S-E,T=S+E;C<n&&(n=C),T>h&&(h=T),v&&S<u&&(u=S),v&&S>g&&(g=S);let D=e[y+4],O=e[y+5],P=D-O,U=D+O;P<o&&(o=P),U>c&&(c=U),v&&D<p&&(p=D),v&&D>m&&(m=D)}r[0]=a,r[1]=n,r[2]=o,r[3]=l,r[4]=h,r[5]=c,v&&(s[0]=d,s[1]=u,s[2]=p,s[3]=f,s[4]=g,s[5]=m)}function Y9(e,t,i,r){let s=1/0,a=1/0,n=1/0,o=-1/0,l=-1/0,h=-1/0;for(let c=t*6,d=(t+i)*6;c<d;c+=6){let u=e[c+0];u<s&&(s=u),u>o&&(o=u);let p=e[c+2];p<a&&(a=p),p>l&&(l=p);let f=e[c+4];f<n&&(n=f),f>h&&(h=f)}r[0]=s,r[1]=a,r[2]=n,r[3]=o,r[4]=l,r[5]=h}function Q9(e,t,i,r,s){let a=i,n=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;a<=n&&t[a*6+l]<o;)a++;for(;a<=n&&t[n*6+l]>=o;)n--;if(a<n){for(let h=0;h<3;h++){let c=e[a*3+h];e[a*3+h]=e[n*3+h],e[n*3+h]=c;let d=t[a*6+h*2+0];t[a*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=d;let u=t[a*6+h*2+1];t[a*6+h*2+1]=t[n*6+h*2+1],t[n*6+h*2+1]=u}a++,n--}else return a}}var Xa=32,Z9=(e,t)=>e.candidate-t.candidate,In=new Array(Xa).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),zu=new Float32Array(6);function K9(e,t,i,r,s,a){let n=-1,o=0;if(a===0)n=j_(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(a===1)n=j_(e),n!==-1&&(o=J9(i,r,s,n));else if(a===2){let l=xc(e),h=1.25*s,c=r*6,d=(r+s)*6;for(let u=0;u<3;u++){let p=t[u],f=(t[u+3]-p)/Xa;if(s<Xa/4){let g=[...In];g.length=s;let m=0;for(let y=c;y<d;y+=6,m++){let x=g[m];x.candidate=i[y+2*u],x.count=0;let{bounds:w,leftCacheBounds:_,rightCacheBounds:b}=x;for(let A=0;A<3;A++)b[A]=1/0,b[A+3]=-1/0,_[A]=1/0,_[A+3]=-1/0,w[A]=1/0,w[A+3]=-1/0;Lu(y,i,w)}g.sort(Z9);let v=s;for(let y=0;y<v;y++){let x=g[y];for(;y+1<v&&g[y+1].candidate===x.candidate;)g.splice(y+1,1),v--}for(let y=c;y<d;y+=6){let x=i[y+2*u];for(let w=0;w<v;w++){let _=g[w];x>=_.candidate?Lu(y,i,_.rightCacheBounds):(Lu(y,i,_.leftCacheBounds),_.count++)}}for(let y=0;y<v;y++){let x=g[y],w=x.count,_=s-x.count,b=x.leftCacheBounds,A=x.rightCacheBounds,S=0;w!==0&&(S=xc(b)/l);let E=0;_!==0&&(E=xc(A)/l);let C=1+1.25*(S*w+E*_);C<h&&(n=u,h=C,o=x.candidate)}}else{for(let v=0;v<Xa;v++){let y=In[v];y.count=0,y.candidate=p+f+v*f;let x=y.bounds;for(let w=0;w<3;w++)x[w]=1/0,x[w+3]=-1/0}for(let v=c;v<d;v+=6){let y=~~((i[v+2*u]-p)/f);y>=Xa&&(y=Xa-1);let x=In[y];x.count++,Lu(v,i,x.bounds)}let g=In[Xa-1];G_(g.bounds,g.rightCacheBounds);for(let v=Xa-2;v>=0;v--){let y=In[v],x=In[v+1];H_(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let m=0;for(let v=0;v<Xa-1;v++){let y=In[v],x=y.count,w=y.bounds,_=In[v+1].rightCacheBounds;x!==0&&(m===0?G_(w,zu):H_(w,zu,zu)),m+=x;let b=0,A=0;m!==0&&(b=xc(zu)/l);let S=s-m;S!==0&&(A=xc(_)/l);let E=1+1.25*(b*m+A*S);E<h&&(n=u,h=E,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:o}}function J9(e,t,i,r){let s=0;for(let a=t,n=t+i;a<n;a++)s+=e[a*6+r*2];return s/i}function $9(e,t){let i=e.attributes.position,r=e.index.array,s=r.length/3,a=new Float32Array(s*6),n=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let c=["getX","getY","getZ"];for(let d=0;d<s;d++){let u=d*3,p=d*6,f,g,m;n?(f=r[u+0],g=r[u+1],m=r[u+2]):(f=r[u+0]*h+l,g=r[u+1]*h+l,m=r[u+2]*h+l);for(let v=0;v<3;v++){let y,x,w;n?(y=i[c[v]](f),x=i[c[v]](g),w=i[c[v]](m)):(y=o[f+v],x=o[g+v],w=o[m+v]);let _=y;x<_&&(_=x),w<_&&(_=w);let b=y;x>b&&(b=x),w>b&&(b=w);let A=(b-_)/2,S=v*2;a[p+S+0]=_+A,a[p+S+1]=A+(Math.abs(_)+A)*W9,_<t[v]&&(t[v]=_),b>t[v+3]&&(t[v+3]=b)}}return a}function e7(e,t){function i(v){u&&u(v/p)}function r(v,y,x,w=null,_=0){if(!f&&_>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),x<=c||_>=l)return i(y+x),v.offset=y,v.count=x,v;let b=K9(v.boundingData,w,n,y,x,d);if(b.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let A=Q9(o,n,y,x,b);if(A===y||A===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=b.axis;let S=new Ru,E=y,C=A-y;v.left=S,S.boundingData=new Float32Array(6),xg(n,E,C,S.boundingData,a),r(S,E,C,a,_+1);let T=new Ru,D=A,O=x-C;v.right=T,T.boundingData=new Float32Array(6),xg(n,D,O,T.boundingData,a),r(T,D,O,a,_+1)}return v}q9(e,t);let s=new Float32Array(6),a=new Float32Array(6),n=$9(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,c=t.maxLeafTris,d=t.strategy,u=t.onProgress,p=e.index.count/3,f=!1,g=[],m=X9(e);if(m.length===1){let v=m[0],y=new Ru;y.boundingData=s,Y9(n,v.offset,v.count,a),r(y,v.offset,v.count,a),g.push(y)}else for(let v of m){let y=new Ru;y.boundingData=new Float32Array(6),xg(n,v.offset,v.count,y.boundingData,a),r(y,v.offset,v.count,a),g.push(y)}return g}function t7(e,t){let i=e7(e,t),r,s,a,n=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<i.length;c++){let d=i[c],u=l(d),p=new o(32*u);r=new Float32Array(p),s=new Uint32Array(p),a=new Uint16Array(p),h(0,d),n.push(p)}return n;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function h(c,d){let u=c/4,p=c/2,f=!!d.count,g=d.boundingData;for(let m=0;m<6;m++)r[u+m]=g[m];if(f){let m=d.offset,v=d.count;return s[u+6]=m,a[p+14]=v,a[p+15]=65535,c+32}else{let m=d.left,v=d.right,y=d.splitAxis,x;if(x=h(c+32,m),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[u+6]=x/4,x=h(x,v),s[u+7]=y,x}}}var xn=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,a=e.length;s<a;s++){let n=e[s][t];i=n<i?n:i,r=n>r?n:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,a=t.length;s<a;s++){let n=t[s],o=e.dot(n);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};xn.prototype.setFromBox=function(){let e=new M;return function(t,i){let r=i.min,s=i.max,a=1/0,n=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+s.x*(1-o),e.y=r.y*l+s.y*(1-l),e.z=r.z*h+s.z*(1-h);let c=t.dot(e);a=Math.min(c,a),n=Math.max(c,n)}this.min=a,this.max=n}}();var i7=function(){let e=new M,t=new M,i=new M;return function(r,s,a){let n=r.start,o=e,l=s.start,h=t;i.subVectors(n,l),e.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let c=i.dot(h),d=h.dot(o),u=h.dot(h),p=i.dot(o),f=o.dot(o)*u-d*d,g,m;f!==0?g=(c*d-p*u)/f:g=0,m=(c+g*d)/u,a.x=g,a.y=m}}(),P1=function(){let e=new j,t=new M,i=new M;return function(r,s,a,n){i7(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,a),s.at(l,n);return}else if(o>=0&&o<=1){l<0?s.at(0,n):s.at(1,n),r.closestPointToPoint(n,!0,a);return}else if(l>=0&&l<=1){o<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,n);return}else{let h;o<0?h=r.start:h=r.end;let c;l<0?c=s.start:c=s.end;let d=t,u=i;if(r.closestPointToPoint(c,!0,t),s.closestPointToPoint(h,!0,i),d.distanceToSquared(c)<=u.distanceToSquared(h)){a.copy(d),n.copy(c);return}else{a.copy(h),n.copy(u);return}}}}(),r7=function(){let e=new M,t=new M,i=new qr,r=new _s;return function(s,a){let{radius:n,center:o}=s,{a:l,b:h,c}=a;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let d=a.getPlane(i);if(Math.abs(d.distanceToPoint(o))<=n){let u=d.projectPoint(o,t);if(a.containsPoint(u))return!0}return!1}}(),s7=1e-15;function Fl(e){return Math.abs(e)<s7}var bn=class extends pr{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new M),this.satBounds=new Array(4).fill().map(()=>new xn),this.points=[this.a,this.b,this.c],this.sphere=new $r,this.plane=new qr,this.needsUpdate=!0}intersectsSphere(e){return r7(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,a=this.satBounds,n=s[0],o=a[0];this.getNormal(n),o.setFromPoints(n,r);let l=s[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,r);let c=s[2],d=a[2];c.subVectors(t,i),d.setFromPoints(c,r);let u=s[3],p=a[3];u.subVectors(i,e),p.setFromPoints(u,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(n,e),this.needsUpdate=!1}};bn.prototype.closestPointToSegment=function(){let e=new M,t=new M,i=new _s;return function(r,s=null,a=null){let{start:n,end:o}=r,l=this.points,h,c=1/0;for(let d=0;d<3;d++){let u=(d+1)%3;i.start.copy(l[d]),i.end.copy(l[u]),P1(i,r,e,t),h=e.distanceToSquared(t),h<c&&(c=h,s&&s.copy(e),a&&a.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<c&&(c=h,s&&s.copy(e),a&&a.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<c&&(c=h,s&&s.copy(e),a&&a.copy(o)),Math.sqrt(c)}}();bn.prototype.intersectsTriangle=function(){let e=new bn,t=new Array(3),i=new Array(3),r=new xn,s=new xn,a=new M,n=new M,o=new M,l=new M,h=new _s,c=new _s,d=new _s;return function(u,p=null,f=!1){this.needsUpdate&&this.update(),u.isExtendedTriangle?u.needsUpdate&&u.update():(e.copy(u),e.update(),u=e);let g=this.plane,m=u.plane;if(Math.abs(g.normal.dot(m.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;i[0]=u.a,i[1]=u.b,i[2]=u.c;for(let _=0;_<4;_++){let b=v[_],A=y[_];if(r.setFromPoints(A,i),b.isSeparated(r))return!1}let x=u.satBounds,w=u.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let _=0;_<4;_++){let b=x[_],A=w[_];if(r.setFromPoints(A,t),b.isSeparated(r))return!1}for(let _=0;_<4;_++){let b=y[_];for(let A=0;A<4;A++){let S=w[A];if(a.crossVectors(b,S),r.setFromPoints(a,t),s.setFromPoints(a,i),r.isSeparated(s))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,y=!1,x=0;for(let O=0;O<3;O++){let P=v[O],U=v[(O+1)%3];h.start.copy(P),h.end.copy(U),h.delta(n);let W=y?c.start:c.end,k=Fl(m.distanceToPoint(P));if(Fl(m.normal.dot(n))&&k){c.copy(h),x=2;break}if((m.intersectLine(h,W)||k)&&!Fl(W.distanceTo(U))){if(x++,y)break;y=!0}}if(x===1&&u.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(x!==2)return!1;let w=u.points,_=!1,b=0;for(let O=0;O<3;O++){let P=w[O],U=w[(O+1)%3];h.start.copy(P),h.end.copy(U),h.delta(o);let W=_?d.start:d.end,k=Fl(g.distanceToPoint(P));if(Fl(g.normal.dot(o))&&k){d.copy(h),b=2;break}if((g.intersectLine(h,W)||k)&&!Fl(W.distanceTo(U))){if(b++,_)break;_=!0}}if(b===1&&this.containsPoint(d.end))return p&&(p.start.copy(d.end),p.end.copy(d.end)),!0;if(b!==2)return!1;if(c.delta(n),d.delta(o),n.dot(o)<0){let O=d.start;d.start=d.end,d.end=O}let A=c.start.dot(n),S=c.end.dot(n),E=d.start.dot(n),C=d.end.dot(n),T=S<E,D=A<C;return A!==C&&E!==S&&T===D?!1:(p&&(l.subVectors(c.start,d.start),l.dot(n)>0?p.start.copy(c.start):p.start.copy(d.start),l.subVectors(c.end,d.end),l.dot(n)<0?p.end.copy(c.end):p.end.copy(d.end)),!0)}}}();bn.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();bn.prototype.distanceToTriangle=function(){let e=new M,t=new M,i=["a","b","c"],r=new _s,s=new _s;return function(a,n=null,o=null){let l=n||o?r:null;if(this.intersectsTriangle(a,l))return(n||o)&&(n&&l.getCenter(n),o&&l.getCenter(o)),0;let h=1/0;for(let c=0;c<3;c++){let d,u=i[c],p=a[u];this.closestPointToPoint(p,e),d=p.distanceToSquared(e),d<h&&(h=d,n&&n.copy(e),o&&o.copy(p));let f=this[u];a.closestPointToPoint(f,e),d=f.distanceToSquared(e),d<h&&(h=d,n&&n.copy(f),o&&o.copy(e))}for(let c=0;c<3;c++){let d=i[c],u=i[(c+1)%3];r.set(this[d],this[u]);for(let p=0;p<3;p++){let f=i[p],g=i[(p+1)%3];s.set(a[f],a[g]),P1(r,s,e,t);let m=e.distanceToSquared(t);m<h&&(h=m,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Ta=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new M,this.max=new M,this.matrix=new we,this.invMatrix=new we,this.points=new Array(8).fill().map(()=>new M),this.satAxes=new Array(3).fill().map(()=>new M),this.satBounds=new Array(3).fill().map(()=>new xn),this.alignedSatBounds=new Array(3).fill().map(()=>new xn),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Ta.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let c=0;c<=1;c++){let d=1*l|2*h|4*c,u=r[d];u.x=l?i.x:t.x,u.y=h?i.y:t.y,u.z=c?i.z:t.z,u.applyMatrix4(e)}let s=this.satBounds,a=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=a[l],c=s[l],d=1<<l,u=r[d];h.subVectors(n,u),c.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Ta.prototype.intersectsBox=function(){let e=new xn;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,a=this.satAxes,n=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,n[0].isSeparated(e)||(e.min=i.y,e.max=r.y,n[1].isSeparated(e))||(e.min=i.z,e.max=r.z,n[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=a[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Ta.prototype.intersectsTriangle=function(){let e=new bn,t=new Array(3),i=new xn,r=new xn,s=new M;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(e.copy(a),e.update(),a=e);let n=this.satBounds,o=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let d=0;d<3;d++){let u=n[d],p=o[d];if(i.setFromPoints(p,t),u.isSeparated(i))return!1}let l=a.satBounds,h=a.satAxes,c=this.points;for(let d=0;d<3;d++){let u=l[d],p=h[d];if(i.setFromPoints(p,c),u.isSeparated(i))return!1}for(let d=0;d<3;d++){let u=o[d];for(let p=0;p<4;p++){let f=h[p];if(s.crossVectors(u,f),i.setFromPoints(s,t),r.setFromPoints(s,c),i.isSeparated(r))return!1}}return!0}}();Ta.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Ta.prototype.distanceToPoint=function(){let e=new M;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Ta.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new _s),i=new Array(12).fill().map(()=>new _s),r=new M,s=new M;return function(a,n=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(o||l)&&(a.getCenter(s),this.closestPointToPoint(s,r),a.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=n*n,c=a.min,d=a.max,u=this.points,p=1/0;for(let g=0;g<8;g++){let m=u[g];s.copy(m).clamp(c,d);let v=m.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(m),l&&l.copy(s),v<h))return Math.sqrt(v)}let f=0;for(let g=0;g<3;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){let y=(g+1)%3,x=(g+2)%3,w=m<<y|v<<x,_=1<<g|m<<y|v<<x,b=u[w],A=u[_];t[f].set(b,A);let S=e[g],E=e[y],C=e[x],T=i[f],D=T.start,O=T.end;D[S]=c[S],D[E]=m?c[E]:d[E],D[C]=v?c[C]:d[E],O[S]=d[S],O[E]=m?c[E]:d[E],O[C]=v?c[C]:d[E],f++}for(let g=0;g<=1;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){s.x=g?d.x:c.x,s.y=m?d.y:c.y,s.z=v?d.z:c.z,this.closestPointToPoint(s,r);let y=s.distanceToSquared(r);if(y<p&&(p=y,o&&o.copy(r),l&&l.copy(s),y<h))return Math.sqrt(y)}for(let g=0;g<12;g++){let m=t[g];for(let v=0;v<12;v++){let y=i[v];P1(m,y,r,s);let x=r.distanceToSquared(s);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}}return Math.sqrt(p)}}();var Ul=new M,Nl=new M,kl=new M,Bu=new j,Fu=new j,Uu=new j,W_=new M,q_=new M,X_=new M,Nu=new M;function a7(e,t,i,r,s,a){let n;return a===rr?n=e.intersectTriangle(r,i,t,!0,s):n=e.intersectTriangle(t,i,r,a!==Ar,s),n===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function n7(e,t,i,r,s,a,n,o,l){Ul.fromBufferAttribute(t,a),Nl.fromBufferAttribute(t,n),kl.fromBufferAttribute(t,o);let h=a7(e,Ul,Nl,kl,Nu,l);if(h){r&&(Bu.fromBufferAttribute(r,a),Fu.fromBufferAttribute(r,n),Uu.fromBufferAttribute(r,o),h.uv=pr.getInterpolation(Nu,Ul,Nl,kl,Bu,Fu,Uu,new j)),s&&(Bu.fromBufferAttribute(s,a),Fu.fromBufferAttribute(s,n),Uu.fromBufferAttribute(s,o),h.uv1=pr.getInterpolation(Nu,Ul,Nl,kl,Bu,Fu,Uu,new j)),i&&(W_.fromBufferAttribute(i,a),q_.fromBufferAttribute(i,n),X_.fromBufferAttribute(i,o),h.normal=pr.getInterpolation(Nu,Ul,Nl,kl,W_,q_,X_,new M),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let c={a,b:n,c:o,normal:new M,materialIndex:0};pr.getNormal(Ul,Nl,kl,c.normal),h.face=c,h.faceIndex=a}return h}function _C(e,t,i,r,s){let a=r*3,n=e.index.getX(a),o=e.index.getX(a+1),l=e.index.getX(a+2),{position:h,normal:c,uv:d,uv1:u}=e.attributes,p=n7(i,h,c,d,u,n,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function o7(e,t,i,r,s,a){for(let n=r,o=r+s;n<o;n++)_C(e,t,i,n,a)}function l7(e,t,i,r,s){let a=1/0,n=null;for(let o=r,l=r+s;o<l;o++){let h=_C(e,t,i,o);h&&h.distance<a&&(n=h,a=h.distance)}return n}function ga(e,t,i,r){let s=e.a,a=e.b,n=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),s.x=r.getX(o),s.y=r.getY(o),s.z=r.getZ(o),a.x=r.getX(l),a.y=r.getY(l),a.z=r.getZ(l),n.x=r.getX(h),n.y=r.getY(h),n.z=r.getZ(h)}function Y_(e,t,i,r,s,a,n){let o=i.index,l=i.attributes.position;for(let h=e,c=t+e;h<c;h++)if(ga(n,h*3,o,l),n.needsUpdate=!0,r(n,h,s,a))return!0;return!1}var SC=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function Xn(e,t){return t[e+15]===65535}function yh(e,t){return t[e+6]}function Cd(e,t){return t[e+14]}function Td(e){return e+8}function Pd(e,t){return t[e+6]}function h7(e,t){return t[e+7]}var uh=new Si,Tf=new M,c7=["x","y","z"];function G0(e,t,i,r,s){let a=e*2,n=rc,o=no,l=oo;if(Xn(a,o)){let h=yh(e,l),c=Cd(a,o);o7(t,i,r,h,c,s)}else{let h=Td(e);Pf(h,n,r,Tf)&&G0(h,t,i,r,s);let c=Pd(e,l);Pf(c,n,r,Tf)&&G0(c,t,i,r,s)}}function H0(e,t,i,r){let s=e*2,a=rc,n=no,o=oo;if(Xn(s,n)){let l=yh(e,o),h=Cd(s,n);return l7(t,i,r,l,h)}else{let l=h7(e,o),h=c7[l],c=r.direction[h]>=0,d,u;c?(d=Td(e),u=Pd(e,o)):(d=Pd(e,o),u=Td(e));let p=Pf(d,a,r,Tf)?H0(d,t,i,r):null;if(p){let g=p.point[h];if(c?g<=a[u+l]:g>=a[u+l+3])return p}let f=Pf(u,a,r,Tf)?H0(u,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var d7=function(){let e,t,i=[],r=new SC(()=>new Si);return function(...a){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let n=s(...a);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),n};function s(a,n,o,l,h=null,c=0,d=0){function u(y){let x=y*2,w=no,_=oo;for(;!Xn(x,w);)y=Td(y),x=y*2;return yh(y,_)}function p(y){let x=y*2,w=no,_=oo;for(;!Xn(x,w);)y=Pd(y,_),x=y*2;return yh(y,_)+Cd(x,w)}let f=a*2,g=rc,m=no,v=oo;if(Xn(f,m)){let y=yh(a,v),x=Cd(f,m);return xa(a,g,e),l(y,x,!1,d,c+a,e)}else{let y=Td(a),x=Pd(a,v),w=y,_=x,b,A,S,E;if(h&&(S=e,E=t,xa(w,g,S),xa(_,g,E),b=h(S),A=h(E),A<b)){w=x,_=y;let W=b;b=A,A=W,S=E}S||(S=e,xa(w,g,S));let C=Xn(w*2,m),T=o(S,C,b,d+1,c+w),D;if(T===2){let W=u(w),k=p(w)-W;D=l(W,k,!0,d+1,c+w,S)}else D=T&&s(w,n,o,l,h,c,d+1);if(D)return!0;E=t,xa(_,g,E);let O=Xn(_*2,m),P=o(E,O,A,d+1,c+_),U;if(P===2){let W=u(_),k=p(_)-W;U=l(W,k,!0,d+1,c+_,E)}else U=P&&s(_,n,o,l,h,c,d+1);return!!U}}}(),u7=function(){let e=new bn,t=new bn,i=new we,r=new Ta,s=new Ta;return function a(n,o,l,h,c=null){let d=n*2,u=rc,p=no,f=oo;if(c===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),c=r),Xn(d,p)){let g=o,m=g.index,v=g.attributes.position,y=l.index,x=l.attributes.position,w=yh(n,f),_=Cd(d,p);if(i.copy(h).invert(),l.boundsTree)return xa(n,u,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:b=>s.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(h),b.b.applyMatrix4(h),b.c.applyMatrix4(h),b.needsUpdate=!0;for(let A=w*3,S=(_+w)*3;A<S;A+=3)if(ga(t,A,m,v),t.needsUpdate=!0,b.intersectsTriangle(t))return!0;return!1}});for(let b=w*3,A=_+w*3;b<A;b+=3){ga(e,b,m,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let S=0,E=y.count;S<E;S+=3)if(ga(t,S,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let g=n+8,m=f[n+6];return xa(g,u,uh),!!(c.intersectsBox(uh)&&a(g,o,l,h,c)||(xa(m,u,uh),c.intersectsBox(uh)&&a(m,o,l,h,c)))}}}();function Pf(e,t,i,r){return xa(e,t,uh),i.intersectBox(uh,r)}var W0=[],Pp,rc,no,oo;function kc(e){Pp&&W0.push(Pp),Pp=e,rc=new Float32Array(e),no=new Uint16Array(e),oo=new Uint32Array(e)}function ku(){Pp=null,rc=null,no=null,oo=null,W0.length&&kc(W0.pop())}var bg=Symbol("skip tree generation"),wg=new Si,_g=new Si,Vl=new we,Po=new Ta,bc=new Ta,wc=new M,Vu=new M,p7=new M,f7=new M,m7=new M,Q_=new Si,ta=new SC(()=>new bn),ed=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),ed.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,s=i.getIndex(),a;return t.cloneBuffers?a={roots:r.map(n=>n.slice()),index:s.array.slice()}:a={roots:r,index:s.array},a}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),ed.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,a=new ed(t,{...i,[bg]:!0});if(a._roots=s,i.setIndex){let n=t.getIndex();if(n===null){let o=new tt(e.index,1,!1);t.setIndex(o)}else n.array!==r&&(n.array.set(r),n.needsUpdate=!0)}return a}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[bg]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[bg]||(this._roots=t7(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Si))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,s,a,n,o,l=0,h=this._roots;for(let d=0,u=h.length;d<u;d++)s=h[d],a=new Uint32Array(s),n=new Uint16Array(s),o=new Float32Array(s),c(0,l),l+=s.byteLength;function c(d,u,p=!1){let f=d*2;if(n[f+15]===65535){let g=a[d+6],m=n[f+14],v=1/0,y=1/0,x=1/0,w=-1/0,_=-1/0,b=-1/0;for(let A=3*g,S=3*(g+m);A<S;A++){let E=i[A],C=r.getX(E),T=r.getY(E),D=r.getZ(E);C<v&&(v=C),C>w&&(w=C),T<y&&(y=T),T>_&&(_=T),D<x&&(x=D),D>b&&(b=D)}return o[d+0]!==v||o[d+1]!==y||o[d+2]!==x||o[d+3]!==w||o[d+4]!==_||o[d+5]!==b?(o[d+0]=v,o[d+1]=y,o[d+2]=x,o[d+3]=w,o[d+4]=_,o[d+5]=b,!0):!1}else{let g=d+8,m=a[d+6],v=g+u,y=m+u,x=p,w=!1,_=!1;e?x||(w=e.has(v),_=e.has(y),x=!w&&!_):(w=!0,_=!0);let b=x||w,A=x||_,S=!1;b&&(S=c(g,u,x));let E=!1;A&&(E=c(m,u,x));let C=S||E;if(C)for(let T=0;T<3;T++){let D=g+T,O=m+T,P=o[D],U=o[D+3],W=o[O],k=o[O+3];o[d+T]=P<W?P:W,o[d+T+3]=U>k?U:k}return C}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);a(0);function a(n,o=0){let l=n*2,h=s[l+15]===65535;if(h){let c=r[n+6],d=s[l+14];e(o,h,new Float32Array(i,n*4,6),c,d)}else{let c=n+8,d=r[n+6],u=r[n+7];e(o,h,new Float32Array(i,n*4,6),u)||(a(c,o+1),a(d,o+1))}}}raycast(e,t=Ws){let i=this._roots,r=this.geometry,s=[],a=t.isMaterial,n=Array.isArray(t),o=r.groups,l=a?t.side:t;for(let h=0,c=i.length;h<c;h++){let d=n?t[o[h].materialIndex].side:l,u=s.length;if(kc(i[h]),G0(0,r,d,e,s),ku(),n){let p=o[h].materialIndex;for(let f=u,g=s.length;f<g;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=Ws){let i=this._roots,r=this.geometry,s=t.isMaterial,a=Array.isArray(t),n=null,o=r.groups,l=s?t.side:t;for(let h=0,c=i.length;h<c;h++){let d=a?t[o[h].materialIndex].side:l;kc(i[h]);let u=H0(0,r,d,e);ku(),u!=null&&(n==null||u.distance<n.distance)&&(n=u,a&&(u.face.materialIndex=o[h].materialIndex))}return n}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if(kc(s),r=u7(0,i,e,t),ku(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let d=t;t=(u,p,f,g)=>{let m=p*3;return d(u,m,m+1,m+2,f,g)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=ta.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let d=o;o=(u,p,f,g,m)=>d(u,p,f,g,m)?!0:Y_(u,p,r,l,f,g,s)}else o||(l?o=(d,u,p,f)=>Y_(d,u,r,l,p,f,s):o=(d,u,p)=>p);let h=!1,c=0;for(let d of this._roots){if(kc(d),h=d7(0,r,n,o,a,c),ku(),h)break;c+=d.byteLength}return ta.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,a=this.geometry.index,n=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;Vl.copy(t).invert();let h=ta.getPrimitive(),c=ta.getPrimitive();if(s){let u=function(p,f,g,m,v,y,x,w){for(let _=g,b=g+m;_<b;_++){ga(c,_*3,o,l),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let A=p,S=p+f;A<S;A++)if(ga(h,A*3,a,n),h.needsUpdate=!0,s(h,c,A,_,v,y,x,w))return!0}return!1};if(r){let p=r;r=function(f,g,m,v,y,x,w,_){return p(f,g,m,v,y,x,w,_)?!0:u(f,g,m,v,y,x,w,_)}}else r=u}e.getBoundingBox(_g),_g.applyMatrix4(t);let d=this.shapecast({intersectsBounds:u=>_g.intersectsBox(u),intersectsRange:(u,p,f,g,m,v)=>(wg.copy(v),wg.applyMatrix4(Vl),e.shapecast({intersectsBounds:y=>wg.intersectsBox(y),intersectsRange:(y,x,w,_,b)=>r(u,p,y,x,g,m,_,b)}))});return ta.releasePrimitive(h),ta.releasePrimitive(c),d}intersectsBox(e,t){return Po.set(e.min,e.max,t),Po.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Po.intersectsBox(i),intersectsTriangle:i=>Po.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Po.set(e.boundingBox.min,e.boundingBox.max,t),Po.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,c=e.index,d=ta.getPrimitive(),u=ta.getPrimitive(),p=Vu,f=p7,g=null,m=null;r&&(g=f7,m=m7);let v=1/0,y=null,x=null;return Vl.copy(t).invert(),bc.matrix.copy(Vl),this.shapecast({boundsTraverseOrder:w=>Po.distanceToBox(w),intersectsBounds:(w,_,b)=>b<v&&b<a?(_&&(bc.min.copy(w.min),bc.max.copy(w.max),bc.needsUpdate=!0),!0):!1,intersectsRange:(w,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:b=>bc.distanceToBox(b),intersectsBounds:(b,A,S)=>S<v&&S<a,intersectsRange:(b,A)=>{for(let S=b*3,E=(b+A)*3;S<E;S+=3){ga(u,S,c,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let C=w*3,T=(w+_)*3;C<T;C+=3){ga(d,C,l,o),d.needsUpdate=!0;let D=d.distanceToTriangle(u,p,g);if(D<v&&(f.copy(p),m&&m.copy(g),v=D,y=C/3,x=S/3),D<s)return!0}}}});{let b=c?c.count:h.count;for(let A=0,S=b;A<S;A+=3){ga(u,A,c,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let E=w*3,C=(w+_)*3;E<C;E+=3){ga(d,E,l,o),d.needsUpdate=!0;let T=d.distanceToTriangle(u,p,g);if(T<v&&(f.copy(p),m&&m.copy(g),v=T,y=E/3,x=A/3),T<s)return!0}}}}}),ta.releasePrimitive(d),ta.releasePrimitive(u),v===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=v,i.faceIndex=y,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(Vl),f.applyMatrix4(Vl),r.distance=f.sub(r.point).length(),r.faceIndex=x),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,a=r*r,n=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(wc.copy(e).clamp(h.min,h.max),wc.distanceToSquared(e)),intersectsBounds:(h,c,d)=>d<n&&d<a,intersectsTriangle:(h,c)=>{h.closestPointToPoint(e,wc);let d=e.distanceToSquared(wc);return d<n&&(Vu.copy(wc),n=d,o=c),d<s}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy(Vu):t.point=Vu.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{xa(0,new Float32Array(t),Q_),e.union(Q_)}),e}},q0=xo(PO()),g7=.5*(Math.sqrt(3)-1),_c=(3-Math.sqrt(3))/6,v7=1/3,ia=1/6,td=e=>Math.floor(e)|0,Z_=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),Sg=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function y7(e=Math.random){let t=AC(e),i=new Float64Array(t).map(s=>Z_[s%12*2]),r=new Float64Array(t).map(s=>Z_[s%12*2+1]);return function(s,a){let n=0,o=0,l=0,h=(s+a)*g7,c=td(s+h),d=td(a+h),u=(c+d)*_c,p=c-u,f=d-u,g=s-p,m=a-f,v,y;g>m?(v=1,y=0):(v=0,y=1);let x=g-v+_c,w=m-y+_c,_=g-1+2*_c,b=m-1+2*_c,A=c&255,S=d&255,E=.5-g*g-m*m;if(E>=0){let D=A+t[S],O=i[D],P=r[D];E*=E,n=E*E*(O*g+P*m)}let C=.5-x*x-w*w;if(C>=0){let D=A+v+t[S+y],O=i[D],P=r[D];C*=C,o=C*C*(O*x+P*w)}let T=.5-_*_-b*b;if(T>=0){let D=A+1+t[S+1],O=i[D],P=r[D];T*=T,l=T*T*(O*_+P*b)}return 70*(n+o+l)}}function x7(e=Math.random){let t=AC(e),i=new Float64Array(t).map(a=>Sg[a%12*3]),r=new Float64Array(t).map(a=>Sg[a%12*3+1]),s=new Float64Array(t).map(a=>Sg[a%12*3+2]);return function(a,n,o){let l,h,c,d,u=(a+n+o)*v7,p=td(a+u),f=td(n+u),g=td(o+u),m=(p+f+g)*ia,v=p-m,y=f-m,x=g-m,w=a-v,_=n-y,b=o-x,A,S,E,C,T,D;w>=_?_>=b?(A=1,S=0,E=0,C=1,T=1,D=0):w>=b?(A=1,S=0,E=0,C=1,T=0,D=1):(A=0,S=0,E=1,C=1,T=0,D=1):_<b?(A=0,S=0,E=1,C=0,T=1,D=1):w<b?(A=0,S=1,E=0,C=0,T=1,D=1):(A=0,S=1,E=0,C=1,T=1,D=0);let O=w-A+ia,P=_-S+ia,U=b-E+ia,W=w-C+2*ia,k=_-T+2*ia,F=b-D+2*ia,Z=w-1+3*ia,X=_-1+3*ia,G=b-1+3*ia,q=p&255,$=f&255,Q=g&255,ee=.6-w*w-_*_-b*b;if(ee<0)l=0;else{let te=q+t[$+t[Q]];ee*=ee,l=ee*ee*(i[te]*w+r[te]*_+s[te]*b)}let H=.6-O*O-P*P-U*U;if(H<0)h=0;else{let te=q+A+t[$+S+t[Q+E]];H*=H,h=H*H*(i[te]*O+r[te]*P+s[te]*U)}let he=.6-W*W-k*k-F*F;if(he<0)c=0;else{let te=q+C+t[$+T+t[Q+D]];he*=he,c=he*he*(i[te]*W+r[te]*k+s[te]*F)}let re=.6-Z*Z-X*X-G*G;if(re<0)d=0;else{let te=q+1+t[$+1+t[Q+1]];re*=re,d=re*re*(i[te]*Z+r[te]*X+s[te]*G)}return 32*(l+h+c+d)}}function AC(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),s=t[i];t[i]=t[r],t[r]=s}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Is=new pr,b7=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;Is.a.fromBufferAttribute(e,r),Is.b.fromBufferAttribute(e,r+1),Is.c.fromBufferAttribute(e,r+2),s*=Is.getArea(),t[r/3]=s}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,s=-1;for(;i<=r;){let a=Math.ceil((i+r)/2);if(a===0||t[a-1]<=e&&t[a]>e){s=a;break}else e<t[a]?r=a-1:i=a+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),Is.a.fromBufferAttribute(this.positionAttribute,e*3),Is.b.fromBufferAttribute(this.positionAttribute,e*3+1),Is.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Is.a,r).addScaledVector(Is.b,s).addScaledVector(Is.c,1-(r+s)),Is.getNormal(i),this}},w7=xo(Y2()),_7=new we,S7=new we,A7=new we,cl;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(cl||(cl={}));var D1=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new we,this.copyPreviousMatrix=!0,this.hiddenMatrix=new we,this.matrixWorldRigid=new we,this.shearScale=new we,this.shearScaleInv=new we}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof kt&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)cl.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)cl.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:s,q:a}=(0,w7.SVD)(i),n=_7.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=S7.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=A7.copy(o).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new we().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof we?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,a,n){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},M7=class extends D1(kt){},E7=e=>e.type==="Mesh",gr=class extends M7{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];(i==null?void 0:i.object)!==t&&(i&&this.remove(i),i=new gr(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){var e;return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&((e=this.object.dataPatched.cloner)==null?void 0:e.hideBase)===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return E7(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}},No=new M,ko=new M,xh=new we,MC=[new M(-1,1,1),new M(-1,-1,1),new M(1,-1,1),new M(1,1,1),new M(-1,1,-1),new M(-1,-1,-1),new M(1,-1,-1),new M(1,1,-1)],C7=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],T7=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],K_=(e,t,i)=>{e.updateEntityBoxSize(No,ko),xh.copy(t).multiply(e.matrixWorld),ko.x===0&&ko.y===0&&ko.z===0?i.push(new M(No.x,No.y,No.z).applyMatrix4(xh)):MC.forEach(r=>{i.push(r.clone().multiply(ko).add(No).applyMatrix4(xh))})},J_=class extends Si{constructor(){super(...arguments),this.matrix=new we,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new we().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new M);return}K_(s,t,r)}}):K_(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(xh.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(ko).multiplyScalar(.5),this.getCenter(No),xh.copy(this.matrix).setPosition(No),this.vertices=MC.map(e=>e.clone().multiply(ko).applyMatrix4(xh))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=C7.map(([e,t])=>new _s(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new M))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=T7.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},$n={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},P7=class extends AM{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let a=0,n=this.curves;a<n.length;a++){let o=n[a],l=a===0?r[a]:r[a]-r[a-1],h=Math.ceil(e*l/s),c=o.getPoints(h);for(let d=0;d<c.length;d++){let u=c[d];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},X0=.001;function Y0(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=X0}function Ag(e,t){let i=new M(...e.position),r=new M(...e.controlNext.position),s=new M(...t.controlPrevious.position),a=new M(...t.position);return Y0(i,r,a)&&Y0(i,s,a)}function EC(e){let t=e.points.map(c=>new M(...c.data.position)),i=[e.points[0]],r=new M(...i[0].data.position);for(let c=0;c<e.points.length-1;c++)Y0(r,t[c],t[c+1])||(i.push(e.points[c]),r=t[c]);i.push(e.points[e.points.length-1]);let s=e.isClosed,a=i.length-(s?0:1),n=i.length,o=[];for(let c=0;c<n;c++){let d=i[c].data,u=new M(...d.position),p=new M(...d.controlPrevious.position),f=new M(...d.controlNext.position),g={position:u,baseRoundness:d.roundness,controlPrevious:p,controlNext:f};if(d.roundness===0||!e.isClosed&&(c===0||c===n-1)){o[c]={...g,removedLength:0};continue}let m=s&&c==0?n-1:c-1,v=s&&c==n-1?0:c+1,y=i[m].data,x=i[v].data,w=new M(...y.position),_=new M(...x.position),b=w.clone().sub(u).normalize(),A=_.clone().sub(u).normalize();Object.assign(g,{prevDir:b,nextDir:A});let S=Ag(y,d),E=Ag(d,x);if(!S||!E)o[c]={...g,removedLength:0};else{let C=b.clone().add(A).normalize(),T=C.clone().cross(b).length()/b.dot(C);o[c]={...g,tan:T,removedLength:d.roundness/T}}}for(let c=0;c<a;c++){let d=c,u=s&&c===n-1?0:c+1,p=o[d],f=o[u];if(p.removedLength!==0||f.removedLength!==0){let g=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,g/2),f.removedLength=Math.min(f.removedLength,g/2)}}let l=[];for(let c=0;c<a;c++){let d=c,u=s&&c===n-1?0:c+1,p=o[d],f=o[u],g=null;if(!Ag(i[d].data,i[u].data))p.position.distanceTo(f.position)>X0&&(g=new Ap(p.position,p.controlNext,f.controlPrevious,f.position));else{let m=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&m.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),m.distanceTo(v)>X0&&(g=new Ap(m,m.clone().lerp(v,.3),v.clone().lerp(m,.3),v))}l[2*c+1]=g}for(let c=0;c<n;c++){let d=o[c];if(d.removedLength===0){l[2*c]=null;continue}let u=d.position,p=d.prevDir.clone().multiplyScalar(d.removedLength).add(u),f=d.nextDir.clone().multiplyScalar(d.removedLength).add(u),g=d.tan*d.removedLength,m=d.prevDir.clone().add(d.nextDir).normalize(),v=p.clone().lerp(f,.5),y=p.distanceTo(f)/2,x=m.clone().multiplyScalar(Math.sqrt(Math.pow(g,2)-Math.pow(y,2))).add(v),w=m.clone().multiplyScalar(-g).add(x),_=u.distanceTo(w)/u.distanceTo(v),b=d.prevDir.clone().multiplyScalar(_*u.distanceTo(p)).add(u),A=b.clone().lerp(w,2),S=p.clone().lerp(b,4/3),E=f.clone().lerp(A,4/3);l[2*c]=new Ap(p,S,E,f)}let h=new P7;return l.forEach(c=>{c&&h.add(c)}),h}var Tt;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(Tt||(Tt={}));var en=e=>Tt.is(e),D7={type:"completeState",isfromEntity:!0},I7=["x","y","z"],Mg=new M,O7=new M().set(0,1,0),I1=e=>class extends D1(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new J_,this._recursiveBBox=new J_,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(Tt.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(Tt.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(Tt.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let s of this.data.states)Wo.toOps(this.data,s.data).forEach(a=>{let n=lf.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(n,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=Wo.patch(this.data,s),Wo.toOps(this.data,s).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{en(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(Tt.is(i[r]))return i[r];if(Tt.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Tt.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)en(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{Tt.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)en(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)en(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)en(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>en(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*Re.RAD2DEG,this.rotation.y*Re.RAD2DEG,this.rotation.z*Re.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return $v(i,t)}getTransformValues(t,i,r){return i[t].map((s,a)=>(r==null?void 0:r.shared.getVariable(s,[this.uuid,t,I7[a]]))??s)}updateTransformState(t,i){let r=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(Mg.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(Re.DEG2RAD),this.rotation.setFromVector3(Mg),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??Rh.identity)),r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)Tt.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Tt.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return $v(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,s){let a=this.data;this.data=i;let n=t,o=Qt(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if((this==null?void 0:this.stateSelection)===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(c=>c===void 0)){let c=this.data;if(c!==void 0){let d=Gi.zoom(c,t.path.slice(2));if(d)for(let u in t.props)t.props[u]===void 0&&u in d&&(h[u]=d[u])}}n={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:c,...d}=l;l=d}if(t.props.material!==void 0&&"material"in l){let{material:c,...d}=l;l=d}let h=Gi.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,Wo.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Qt(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let c of Object.keys(t.props)){l[l.length-1]=c;let d=r.scene.findInstance([this.uuid,...l]);d&&(d.overrideData=t.props[c],d.updateState(so.apply(d.component.data,d.overrideData),r))}}else{let c=r.scene.findInstance([this.uuid,...l]);if(c){let d=Gi.zoom(c.component.data,h);if(t={...t,path:h},t.type===0){let u=t.props;if(d)for(let[p,f]of Object.entries(t.props))f===void 0&&(u===t.props&&(u={...t.props}),u[p]=d[p]);t={...t,props:u}}c.overrideData=xf.resolve(i.overrides,l),c.updateByOp(t,tr.applySimple(c.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let c of Jn.rootOverrideProps)c in t.props&&(h===void 0&&(h={}),h[c]=t.props[c]);h&&(l={...t,props:h})}else for(let h of Jn.rootOverrideProps)if(Qt(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let c=so.filterOp(h.overrideData,l);c&&h.updateByOp(c,tr.applySimple(h.data,c),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let c=so.filterOp(h.overrideData,t);if(c){let d;a===h.data&&t===c?d=i:d=tr.applySimple(h.data,c),h.updateByOp(c,d,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!hl.is(t.props.type)&&$n.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){$n.changeEntityProptotype(this,i,r);for(let s of this.children)Tt.is(s)&&s.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){var s;if(t.path.length===0&&t.type===0?this.updateState(t.props,r):t.type===0&&("resolutionLevel"in t.props||"useChildrenColors"in t.props)&&this.updateState(i,r),t.path[0]==="morphTargetInfluences"&&t.type===0){let a=(s=i.morphTargetInfluences.get(t.path[1]))==null?void 0:s.data.name;a&&this.updateMorphInfluences(a,r.shared.getVariable(t.props.value,[this.uuid,"morphTargetInfluences",a]))}if(Qt(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Qt(t.path,["cloner"])!==null){let a=tr.drop(t,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible(r.scene)}}updatePathSnapping(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){var f,g,m,v,y;let i=((f=this._updatedPathSnapping)==null?void 0:f.pathId)??this.dataPatched.pathSnapping.pathId,r=((g=this._updatedPathSnapping)==null?void 0:g.slide)??this.dataPatched.pathSnapping.slide??0,s=((m=this._updatedPathSnapping)==null?void 0:m.offset)??this.dataPatched.pathSnapping.offset??0,a=((v=this._updatedPathSnapping)==null?void 0:v.orientation)??this.dataPatched.pathSnapping.orientation;if(i===null)return;let n=t.find(i);if(!n||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=n.data;if(o.geometry.path.points.length<=1)return;let l=EC(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let c=null;try{c=l.curves.length?l.getPointAt(h):null}catch{}if(c===null)return;let d=this.parent?(y=this.parent)==null?void 0:y.matrixWorld:new we;n.updateMatrixWorld();let u=new we().multiplyMatrices(d.clone().invert(),n.matrixWorld);c.applyMatrix4(u);let p={position:c.toArray(),rotation:o.rotation};if(a==="tangential"){let x=new we().extractRotation(n.matrixWorld),w=l.getTangentAt(h).applyMatrix4(x).add(c),_=new we().lookAt(c,w,O7),b=Mg.setFromEuler(new ji().setFromRotationMatrix(_)).multiplyScalar(Re.RAD2DEG);p={...p,rotation:b.toArray()}}this.updateTransformState(p),this.traverseEntity(x=>{x._cameraType&&x.dispatchEvent(D7)})}updateVisible(t){var r;if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||((r=this.dataPatched.cloner)==null?void 0:r.hideBase)!==!0),!t)return;let i=!1;this.traverseEntity(s=>{if(s.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(i==null?void 0:i.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof $n.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new $n.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}},CC=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var l,h;let i=(l=e.parameters)==null?void 0:l.radiusTop,r=(h=e.parameters)==null?void 0:h.radiusBottom,s=Object.assign({},(t==null?void 0:t.parameters)??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);s.thetaLength=Re.clamp(s.thetaLength,0,360);let a=s.width/2,n=s.radiusTop??a,o=s.radiusBottom??a;if(n===o?(n=a,o=a):n>o?(n=a,o=o*a/n):(n=n*a/o,o=a),s.shapeBlendNode){n=i??a,o=r??a;let c=Math.max(n,o)*2;s.width=c,s.depth=c}return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(s.height??s.width),depth:Math.abs(s.depth??s.width),radiusTop:n,radiusBottom:o})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:c,cornerRadius:d,cornerSegments:u,hollow:p}=e.parameters,f;return l===0?(f=new Ge,f.setAttribute("position",new Ie([],3))):d||p?f=new TC(h,c,r,s,a,n,o,l*Math.PI/180,d,d,u,p):f=new Qy(h,c,r,s,a,n,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function On(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function $_(e){return new j(e.y,-e.x)}var TC=class extends Ge{constructor(e,t,i,r,s,a,n,o,l,h,c,d,u=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,a=a!==void 0?a:!1,n=n!==void 0?n:0,o=o!==void 0?o:Math.PI*2,a&&(l=0,h=0);let p=[],f=[],g=[],m=[],v=0,y=i/2,x=new M,w=new M;u&&e==0&&(e=l),u&&t==0&&(t=h);let _=new j(e,y),b=new j(t,-y),A=null,S=null,E=null,C=null,T=_.clone().sub(b),D=0,O=0,P=0;d>0&&(D=Math.min(e,t)*(1-d),O=e-D,P=t-D);let U=_.clone();U.x-=D;let W=Math.PI-T.angle(),k=T.angle(),F=Math.tan(k/2),Z=Math.tan(W/2),X=F+Z,G=d?X:Z,q=d?X:F;if(l=Math.min(l,(e-O)/G,T.length()/X),h=Math.min(h,(t-P)/q,T.length()/X),l>0){let re=l/F;A=_.clone().sub(new j(re,l)),d&&(E=A.clone(),E.x-=D-X*l),_.sub(T.clone().setLength(re))}if(h>0){let re=h/Z;S=b.clone().sub(new j(re,-h)),b.add(T.clone().setLength(re)),d&&(C=S.clone(),C.x-=D-X*h,U.sub(T.clone().setLength(re)))}T=_.clone().sub(b);let $=T.length()<.5,Q=[];for(let re=0;re<=r;re++){let te=[],ae=re/r,de=ae*o+n,pe=new j(Math.sin(de),Math.cos(de));C&&S?(ee(te,ae,pe,W,h,C,-1,!0),ee(te,ae,pe,k,h,S,-1,!1)):S?(H(te,pe,S.x,0,-1),ee(te,ae,pe,k,h,S,-1,!1)):a||H(te,pe,t,P,-1);let be=$_(T).normalize();if(On(be,pe,x),!$)for(let Le=0;Le<=s;Le++){let Me=Le/s,Ve=T.clone().multiplyScalar(Me).add(b);On(Ve,pe,w),f.push(w.x,w.y,w.z),g.push(x.x,x.y,x.z),m.push(ae,.5+w.y/i),te.push(v++)}if(E&&A?(ee(te,ae,pe,W,l,A,1,!1),ee(te,ae,pe,k,l,E,1,!0)):A?(ee(te,ae,pe,W,l,A,1,!1),H(te,pe,A.x,0,1)):a||H(te,pe,e,O,1),d&&!$){let Le=$_(T).multiplyScalar(-1).normalize();On(Le,pe,x);for(let Me=0;Me<=s;Me++){let Ve=Me/s,Ue=T.clone().multiplyScalar(-Ve).add(U);On(Ue,pe,w),f.push(w.x,w.y,w.z),g.push(x.x,x.y,x.z),m.push(ae,.5+w.y/i),te.push(v++)}}d&&!a&&te.push(te[0]),Q.push(te)}for(let re=0;re<Q.length-1;re++)for(let te=0;te<Q[0].length-1;te++){if(a&&d&&te==s)continue;let ae=Q[re][te],de=Q[re+1][te],pe=Q[re+1][te+1],be=Q[re][te+1],Le=f[pe*3+0],Me=f[pe*3+2];p.push(ae,de,be),(Le!=0||Me!=0)&&p.push(de,pe,be)}o<Math.PI*2&&(he(-1,Q[0],n),he(1,Q[Q.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new Ie(f,3)),this.setAttribute("normal",new Ie(g,3)),this.setAttribute("uv",new Ie(m,2));function ee(re,te,ae,de,pe,be,Le,Me){for(let Ve=0;Ve<c+1;Ve++){let Ue=Ve/c,Ce=Le<0?Ue:1-Ue;Me&&(Ce-=1),Ce*=de;let Ee=new j(Math.sin(Ce),Math.cos(Ce)*Le),Ye=Ee.clone().multiplyScalar(pe).add(be);On(Ye,ae,w),f.push(w.x,w.y,w.z),On(Ee,ae,x),g.push(x.x,x.y,x.z),m.push(te,.5+w.y/i),re.push(v++)}}function H(re,te,ae,de,pe){let be=new M,Le=new j,Me=[ae,de];pe<0&&Me.reverse();for(let Ve of Me)Le.set(Ve,y*pe),On(Le,te,be),f.push(be.x,be.y,be.z),g.push(0,pe,0),m.push(.5,.5),re.push(v++)}function he(re,te,ae){let de=new j(Math.sin(ae),Math.cos(ae)),pe=new j(-Math.cos(ae),Math.sin(ae)),be=new M,Le=re<0?(Ue,Ce,Ee)=>p.push(Ue,Ce,Ee):(Ue,Ce,Ee)=>p.push(Ue,Ee,Ce),Me=new j((e+t+O+P)/4,0);On(Me,de,be),f.push(be.x,be.y,be.z),g.push(pe.x,0,pe.y),m.push(.5,.5);let Ve=v++;for(let Ue of te){let Ce=f.slice(Ue*3,Ue*3+3);f.push(...Ce),g.push(pe.x,0,pe.y);let Ee=m.slice(Ue*2,Ue*2+2);m.push(...Ee),v++}for(let Ue=Ve+1;Ue<v-1;Ue++)Le(Ve,Ue,Ue+1);Le(Ve,v-1,Ve+1)}}},R7=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=Re.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:c,cornerSegments:d}=e.parameters,u;return l===0?(u=new Ge,u.setAttribute("position",new Ie([],3))):h>0||c>0||l<360?u=new TC(0,t/2,r,s,a,n,o,l*Math.PI/180,h,c,d,0,!0):u=new Zy(t/2,r,s,a,n),u.scale(1,1,i/t),Object.assign(u,{userData:{...e,type:"ConeGeometry"}})}},L7=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:a,depthSegments:n,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o===0?h=new Xs(t,i,r,s,a,n):h=new z7(t,i,r,s,a,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Eg=Math.PI/2,z7=class extends Ge{constructor(e=1,t=1,i=1,r=1,s=1,a=1,n=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),s=Math.floor(s),a=Math.floor(a),o=Math.floor(o),n=Math.min(n,e/2,t/2,i/2);let l=[],h=[],c=[],d=[],u=0;p("z","y","x",-1,-1,i,t,e,a,s),p("z","y","x",1,-1,i,t,-e,a,s),p("x","z","y",1,1,e,i,t,r,a),p("x","z","y",1,-1,e,i,-t,r,a),p("x","y","z",1,-1,e,t,i,r,s),p("x","y","z",-1,-1,e,t,-i,r,s),n>0&&(f("z","y","x",-1,-1,1,i,t,e,a),f("z","y","x",1,-1,-1,i,t,e,a),f("z","y","x",-1,1,-1,i,t,e,a),f("z","y","x",1,1,1,i,t,e,a),f("x","y","z",-1,-1,-1,e,t,i,r),f("x","y","z",1,-1,1,e,t,i,r),f("x","y","z",-1,1,1,e,t,i,r),f("x","y","z",1,1,-1,e,t,i,r),f("y","x","z",-1,-1,1,t,e,i,s),f("y","x","z",1,-1,-1,t,e,i,s),f("y","x","z",1,1,1,t,e,i,s),f("y","x","z",-1,1,-1,t,e,i,s),g(1,1,1),g(-1,1,1),g(1,-1,1),g(-1,-1,1),g(1,1,-1),g(-1,1,-1),g(1,-1,-1),g(-1,-1,-1)),this.setIndex(l),this.setAttribute("position",new Ie(h,3)),this.setAttribute("normal",new Ie(c,3)),this.setAttribute("uv",new Ie(d,2));function p(m,v,y,x,w,_,b,A,S,E){let C=(_-2*n)/S,T=(b-2*n)/E,D=_/2-n,O=b/2-n,P=A/2,U=S+1,W=E+1,k=0,F=new M;for(let Z=0;Z<W;Z++){let X=Z*T-O;for(let G=0;G<U;G++){let q=G*C-D;F[m]=q*x,F[v]=X*w,F[y]=P,h.push(F.x,F.y,F.z),F[m]=0,F[v]=0,F[y]=A>0?1:-1,c.push(F.x,F.y,F.z),d.push(G/S),d.push(1-Z/E),k+=1}}for(let Z=0;Z<E;Z++)for(let X=0;X<S;X++){let G=u+X+U*Z,q=u+X+U*(Z+1),$=u+(X+1)+U*(Z+1),Q=u+(X+1)+U*Z;l.push(G,q,Q),l.push(q,$,Q)}u+=k}function f(m,v,y,x,w,_,b,A,S,E){let C=(b-2*n)/E,T=b/2-n,D=A/2-n,O=S/2,P=E+1,U=0,W=new M,k=new M;for(let F=0;F<o+1;F++){let Z=F/o*Eg,X=Math.sin(Z)*n,G=(1-Math.cos(Z))*n,q=Math.sin(Z),$=Math.cos(Z);W[v]=(D+X)*w,W[y]=(O-G)*_,k[m]=0,k[v]=q*Math.sign(W[v]),k[y]=$*Math.sign(W[y]);for(let Q=0;Q<P;Q++){let ee=Q*C-T;W[m]=ee*x,h.push(W.x,W.y,W.z),c.push(k.x,k.y,k.z),d.push(Q/E),d.push(0),U+=1}}for(let F=0;F<o;F++)for(let Z=0;Z<E;Z++){let X=u+Z+P*F,G=u+Z+P*(F+1),q=u+(Z+1)+P*(F+1),$=u+(Z+1)+P*F;l.push(X,G,$),l.push(G,q,$)}u+=U}function g(m,v,y){let x=new M,w=new M(e/2,t/2,i/2);w.subScalar(n);let _=[],b=m*v*y>0?(S,E,C)=>l.push(S,E,C):(S,E,C)=>l.push(S,C,E);for(let S=0;S<=o;S++){let E=[],C=Eg*(1-S/o),T=Math.cos(C),D=Math.sin(C),O=0;for(let P=0;P<=S;P++){let U=Math.cos(O),W=Math.sin(O);x.x=T*U,x.y=D,x.z=T*W;let k=w.clone().addScaledVector(x,n);h.push(m*k.x,v*k.y,y*k.z),c.push(m*x.x,v*x.y,y*x.z),d.push(0,0),E.push(u++),O+=Eg/S}_.push(E)}let A=_.length-1;for(let S=0;S<A;S++){let E=_[S],C=_[S+1],T=E.length-1;b(E[0],C[1],C[0]);for(let D=1;D<=T;D++)b(E[D-1],E[D],C[D]),b(E[D],C[D+1],C[D])}}}},O1=class extends Ge{constructor(e=[],t=[],i="",r=1,s=.2,a=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),c(),this.setAttribute("position",new Ie(n,3)),this.setAttribute("normal",new Ie(l,3)),this.setAttribute("uv",new Ie(o,2));return;function h(){var k;s=Math.min(1-1e-5,s),s==0&&(a=0);let d={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],u=new M,p=u.clone(),f=new pr,g=s*r,m=r-g,v=a+1,y=new M,x=(F,Z)=>y.subVectors(F,Z).normalize(),w=(F,Z)=>Array(F).fill(void 0).map(Z),_=w(e.length/3,(F,Z)=>new M().fromArray(e,Z*3).setLength(r)),b=[],A=1e6;for(let F=0;F<_.length;F++){let Z=_[F],X=[],G,q,$,Q=1e10,ee=-1;for(;(ee=t.indexOf(F,ee+1))!=-1;){let te=ee-ee%3;G=t[te+(ee+1)%3],q=t[te+(ee+2)%3],$=Z.distanceToSquared(_[G]),Q=Math.min(Q,$),X.push([G,q,$])}Q+=1e-6;let H=[],he=0,re=X.length;for(let te=0;te<re;te++){[G,q,$]=X[he];let ae=((k=b[G])==null?void 0:k.includes(F))==!0;$<=Q&&H.push(G+ +ae*A),he=X.findIndex(de=>de[0]==q)}b.push(H)}let S=[];{let F=0,Z=0,X,G,q=d==3;for(let $=0;$<=a;$++){X=$*($+1)/2,G=($+1)*($+2)/2;for(let Q=0;Q<a-$;Q++)[F,Z]=[X+Q+$+2,G+Q+$+3],S.push(X,G,...q?[Z,X]:[F,G],Z,F),[X,G]=[F,Z];S.push(X,G,X+a+2)}}let E=u.clone(),C=u.clone(),T=u.clone(),D=u.clone(),O=u.clone(),P=[],U=w(_.length,()=>w(d,()=>u.clone()));for(let F=0;F<_.length;F++){u.copy(_[F]).normalize(),E.copy(u).multiplyScalar(m);let Z=b[F];for(let H=0;H<Z.length;H++){let he=Z[H],re=Z[(H+1)%d];f.setFromPointsAndIndices(_,F,he%A,re%A),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(E,U[F][H])}let X=[],G=[],q=[],$=new M;a==0&&[...U[F]].reduce((H,he)=>H.add(he),$).multiplyScalar(1/d);for(let H=0;H<d;H++){let he=[],re=(H-1+d)%d,te=U[F][re],ae=U[F][H];u.copy(te).sub(E),p.copy(ae).sub(E);let de=E.angleTo(u),pe=u.angleTo(p),be=Math.cos(de)*g;a==0?C.copy($):C.copy(E).setLength(m+be),G.push(be);let Le=[C,te,ae];for(let Me=0;Me<2;Me++){let Ve=Le[Me],Ue=Le[Me+1];D.subVectors(Ve,E),O.subVectors(Ue,E),T.crossVectors(D,O).normalize();for(let Ce=0;Ce<v;Ce++){let Ee=[de,pe][Me]*Ce/v;u.copy(D).applyAxisAngle(T,Ee).add(E),X.push(u.clone()),Me&&(x(u,E),he.push([Ce==0?Ve:u.clone(),y.clone()]))}Me&&(x(Ue,E),he.push([Ue,y.clone()]))}q.push(he)}P.push(q);let Q=2*v,ee=2;for(let H=0;H<d;H++){let he=Q*H,re=Q*((H+1)%d),te=[X[he]];for(let de=1;de<v;de++){D=X[he+de],O=X[re+de],te.push(D);for(let pe=1,be=de-ee+1;pe<=be;pe++)u.lerpVectors(D,O,pe/(be+1)),u.sub(E).setLength(G[H]).add(E),te.push(u.clone());te.push(O)}for(let de=0;de<v;de++)te.push(X[de+v+he]);te.push(X[re+v]);let ae=S.map(de=>te[de]);n.push(...ae.map(de=>[de.x,de.y,de.z]).flat()),l.push(...ae.map(de=>(x(de,E),[y.x,y.y,y.z])).flat())}}let W=[];for(let F=0;F<b.length;F++)for(let Z=0;Z<d;Z++){let X=b[F][Z];if(X<A){let G=b[X].findIndex(Q=>Q%A==F),q=P[F][Z],$=P[X][G];for(let Q=0;Q<v;Q++){let ee=q[Q],H=$[v-Q],he=q[Q+1],re=$[v-(Q+1)];[ee,H,he,he,H,re].forEach(te=>{n.push(te[0].x,te[0].y,te[0].z),l.push(te[1].x,te[1].y,te[1].z)})}W.push(q[0][0],$[v][0],q[v][0],$[0][0])}}for(;W.length;){let F,Z,X,G;[F,Z]=W.splice(0,2);let q=[F];for(;F!=Z;)q.push(Z),X=W.indexOf(Z),G=X%2,Z=W.splice(X-G,2)[1-G];y.subVectors(q[0],q[1]).cross(u.subVectors(q[0],q[2])).normalize();let $=y.dot(q[0])<0;$&&y.negate();for(let Q=1;Q<=q.length-2;Q++)[q[Q+ +$],q[Q+1-+$],q[0]].forEach(ee=>{n.push(ee.x,ee.y,ee.z),l.push(y.x,y.y,y.z)})}}function c(){let d=new M;for(let b=0;b<n.length;b+=3){d.x=n[b+0],d.y=n[b+1],d.z=n[b+2];let A=w(d)/2/Math.PI+.5,S=_(d)/Math.PI+.5;o.push(A,1-S)}let u=new M,p=new M,f=new M,g=new M,m=new j,v=new j,y=new j,x=(b,A,S,E)=>{E<0&&b.x===1&&(o[A]=b.x-1),S.x===0&&S.z===0&&(o[A]=E/2/Math.PI+.5)};for(let b=0,A=0;b<n.length;b+=9,A+=6){u.set(n[b+0],n[b+1],n[b+2]),p.set(n[b+3],n[b+4],n[b+5]),f.set(n[b+6],n[b+7],n[b+8]),m.set(o[A+0],o[A+1]),v.set(o[A+2],o[A+3]),y.set(o[A+4],o[A+5]),g.copy(u).add(p).add(f).divideScalar(3);let S=w(g);x(m,A+0,u,S),x(v,A+2,p,S),x(y,A+4,f,S)}for(let b=0;b<o.length;b+=6){let A=o[b+0],S=o[b+2],E=o[b+4],C=Math.max(A,S,E),T=Math.min(A,S,E);C>.9&&T<.1&&(A<.2&&(o[b+0]+=1),S<.2&&(o[b+2]+=1),E<.2&&(o[b+4]+=1))}function w(b){return Math.atan2(b.z,-b.x)}function _(b){return Math.atan2(-b.y,Math.sqrt(b.x*b.x+b.z*b.z))}}}static fromJSON(e){return new O1(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},B7=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new PC(t*.5,a,n):new EM(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},PC=class extends O1{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(a,n,o,e,t,i),this.type=o}static fromJSON(e){return new PC(e.radius,e.corner,e.cornerSides)}},Sc=1e-12,R1=class{constructor(e){this.position=new j,this.startPosition=new j,this.uuid=Re.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new R1(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Q0=class extends R1{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new Q0(this.parent).copy(this)}},bh=class extends R1{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new Q0(this),new Q0(this))}static create(e,t){let i=new bh(e,new j(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new bh(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){var i,r;let e=(i=this.curveBefore)==null?void 0:i.getTangentAt(1),t=(r=this.curveAfter)==null?void 0:r.getTangentAt(0);return[e,t]}computeNormals(e=new j,t=new j){let[i,r]=this.computeTangents();return i&&r&&(eS(i,e),eS(r,t)),[e,t]}computeTangent(e=new j){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new j){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function eS(e,t=new j){let i=e.length();return t.set(-e.y/i,e.x/i)}var L1=e=>e,sc=new j,cm=new j,F7=new j,U7=new j,N7=new j,k7=new j,DC=new M,IC=new M;function V7(e){let t=new j;t.addVectors(e.v0,sc.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new j;return i.addVectors(e.v2,cm.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Vs(e.v0,t,i,e.v2)}function Vc(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function j7(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function G7(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function OC(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-a*a)/(2*s*r))}function H7(e,t,i){return iS(e,t)&&iS(t,i)&&Z0(e.position,t.position,i.position)}function Z0(e,t,i){return sc.copy(t).sub(e).cross(cm.copy(i).sub(e))===0}function W7(e,t,i,r,s){let a=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(e.y-t.y)/a,h=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(t.x-e.x)/a;return r.set(o+l,n+h),s.set(o-l,n-h),[r,s]}function q7(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function X7(e,t,i,r,s,a){let n=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,c=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),d;return OC(t,e,i)>Math.PI&&(c*=-1),Vc(h,o)?d=(o+h)*(r/c-.5)*8/3/(n-l):d=(n+l)*(r/c-.5)*8/3/(h-o),s.set(t.x-d*o,t.y+d*n),a.set(i.x+d*h,i.y-d*l),[s,a]}function tS(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function iS(e,t){return Z0(e.position,e.controls[1].position,t.position)&&Z0(e.position,t.controls[0].position,t.position)}function Y7(e,t,i,r,s=.5){let a=sc.subVectors(t,e).multiplyScalar(s).add(e),n=cm.subVectors(i,t).multiplyScalar(s).add(t),o=F7.subVectors(r,i).multiplyScalar(s).add(i),l=a,h=U7.subVectors(n,a).multiplyScalar(s).add(a),c=N7.subVectors(o,n).multiplyScalar(s).add(n),d=o,u=k7.subVectors(c,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,u.x,u.y,c.x,c.y,d.x,d.y,r.x,r.y]}function Q7(e,t,i=12,r=!0){let s=IC.set(0,0,0),a,n=0;for(let o=0;o<t.length;o++){let l=L1(t[o]),h=sc,c=sl(l,i);for(let d=0;d<=c;d++)if(l instanceof Vs||l instanceof ho||l instanceof Hs){if(l.getPoint(d/c,h),s.set(h.x,h.y,0),a!==void 0&&G7(a,s))continue;a===void 0&&(a=DC),a.copy(s),e.setXYZ(n,s.x,s.y,s.z),n++}}return r&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),e}function Z7(e,t,i,r=12,s=!0){let a=IC.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,c=L1(t[l]),d=sc,u=sl(c,r);o.push(u);for(let p=0;p<=u;p++)if(c instanceof Vs||c instanceof ho||c instanceof Hs){if(c.getPoint(p/u,d),a.set(d.x,d.y,0),h==null?void 0:h.equals(a))continue;h===void 0?h=DC:(e.setXYZ(n,h.x,h.y,h.z),n++,e.setXYZ(n,a.x,a.y,a.z),n++),h.copy(a)}}return s&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}function rS(e,t=12,i=!1){let r=[];for(let s=0,a=e.length;s<a;s++){let n=e[s],o=0;if(i&&n.roundedCurveCorner!==void 0){let l=sl(n.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=sl(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=sl(e[0].roundedCurveCorner,t)*.5),r}function sl(e,t=12){return e&&e instanceof Qf?t*2:e&&(e instanceof Hs||e instanceof SM)?1:e&&e instanceof Yy?t*e.points.length:t}function K7(e,t,i=12,r=!0){let s,a=0;for(let n=0;n<t.length;n++){let o=L1(t[n]),l=sl(o,i),h=sc;for(let c=0;c<=l;c++)if(o instanceof Vs||o instanceof ho||o instanceof Hs){if(o.getPoint(c/l,h),s!==void 0&&j7(s,h,Sc))continue;s===void 0&&(s=cm),s.copy(h),e.push(h.x,h.y),a++}}return Vc(e[0],e[e.length-2],Sc)&&Vc(e[1],e[e.length-1],Sc)&&(e.pop(),e.pop()),r&&a>1&&!(Vc(e[a-1],e[1],Sc)&&Vc(e[a-2],e[0],Sc))&&(e.push(e[0],e[1]),a++),e}var Cg=new j,J7=new j,$7=new j,eq=new j,tq=new j,iq=new j,mi=class extends qp{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new qr(new M(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=Re.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new mi;return r.isClosed=e.isClosed,r.points=e.points.map(s=>bh.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>mi.createFromState(s)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let s=0,a=this.shapeHoles.length;s<a;s++){let n=this.shapeHoles[s],o=n.points.length,l=n.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],a=e-t;if(a<=s.points.length-1)return s.points[a];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],a=s.points.indexOf(e);if(a>=0)return t+a;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=Cg.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let a=this.points[r];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=Re.generateUUID()){let r;e instanceof j?r=e:r=new j(e,t);let s=new bh(i,r);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return Q7(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=rS(this.points,e,!1),this.roundedCurveDivisions=rS(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return Z7(e,this.curves,t,i,this.autoClose).reduce((r,s)=>r+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),K7(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=sl(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=r.reduce((n,o)=>n+o,0));for(let n=0,o=r.length;n<o;n++){let l=r[n];if(a<i+l)return[n,(a-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,n=a[e];if(tS(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(Cg.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=a[l];return(t-o)/n}dispose(){}_applyCurveForPoint(e,t){tS(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(r,s)}}let e=this.getLastPoint();if(e!=null&&e.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],a=this.points[i-1]??this.points[this.points.length-1],n=this.points[i+1]??this.points[0],o=s.roundness,l=a&&n&&H7(a,s,n);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,c=s.curveAfter;if(h===void 0||c===void 0)continue;let d=s.roundedCurveBefore,u=s.roundedCurveAfter,p=h.getLength(),f=c.getLength(),g=Math.min(o,p*.499),m=Math.min(o,f*.499),v=Math.min(g,m),y=1-v/p,x=v/f,w=h.getPointAt(y,Cg),_=c.getPointAt(x,J7);this._subSplitCurve(h,d,y,w,void 0),this._subSplitCurve(c,u,x,void 0,_);let b;if(this.useCubicForRoundedCorners){let A=OC(w,s.position,_)/2,S=Math.tan(A)*w.distanceTo(s.position),[E,C]=W7(w,_,S,$7,eq),T=q7(E,C,s.position),[D,O]=X7(T,w,_,S,tq,iq);b=new Vs(w.clone(),D.clone(),O.clone(),_.clone())}else b=new ho(w.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=b,this.roundedCurves.splice(i+t,0,b),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof Hs)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let a=e,n=t,o=a.getUtoTmapping(i,0),l=Y7(a.v0,a.v1,a.v2,a.v3,o);return r!==void 0&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),s!==void 0&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return t}clone(){let e=new mi(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var i;this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let r=0;r<t;r++){let s=r*7,a=e.points[s+0],n=e.points[s+1],o=e.points[s+2],l=e.points[s+3],h=e.points[s+4],c=e.points[s+5],d=e.points[s+6],u=new bh(Re.generateUUID(),new j(a,n));u.controls[0].position.set(o,l),u.controls[1].position.set(h,c),u.roundness=d,this.points.push(u)}return this.shapeHoles=(i=e.shapeHoles)!=null&&i.length?e.shapeHoles.map(r=>{let s=new mi;return s.fromJSON(r),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(s,a)=>{a instanceof Vs&&a.v3.equals(s.position)&&s.controls[0].position.copy(a.v2)},r=s=>{let a=[],n,o;for(n=0,o=s.length;n<o;n++)s[n]instanceof ho&&(s[n]=V7(s[n]));for(n=0,o=s.length;n<o;n++){let c=s[n],d=n>0?s[n-1]:null,u;c instanceof Vs?(u=this.createPoint(c.v0),u.controls[1].position.copy(c.v1)):c instanceof Hs&&(u=this.createPoint(c.v1)),u!==void 0&&(d!==null&&i(u,d),a.push(u))}let l=s[s.length-1],h=!1;return l instanceof Vs?l.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(l.v2),h=!0):l instanceof Hs&&l.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=r(e.curves),e instanceof qp&&(this.shapeHoles=e.holes.map(s=>{let a=new mi;return a.fromShape(s),a})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){var r;let i=(r=this.getPointByUuid(e))==null?void 0:r.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){var r;let i=(r=this.getPointByUuid(e))==null?void 0:r.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},K0=Math.PI*2;function Tg({x:e,y:t},i,r,s,a){return{x:e*i+s,y:t*r+a}}function rq(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),s=Math.sin(e),a=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:a+n*i,y:n-a*i},{x:a,y:n}]}function sS(e,t,i,r){let s=e*r-t*i<0?-1:1,a=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(a)}function sq(e,t,i,r,s,a,n,o,l,h){let c=Math.pow(s,2),d=Math.pow(a,2),u=Math.pow(n,2),p=Math.pow(o,2),f=c*d-c*p-d*u;f<0&&(f=0),f/=c*p+d*u,f=Math.sqrt(f)*(l===h?-1:1);let g=f*s/a*o,m=f*-a/s*n,v=g+(e+i)/2,y=m+(t+r)/2,x=(n-g)/s,w=(o-m)/a,_=(-n-g)/s,b=(-o-m)/a,A=sS(1,0,x,w),S=sS(x,w,_,b);return!h&&S>0&&(S-=K0),h&&S<0&&(S+=K0),{centerx:v,centery:y,ang1:A,ang2:S}}function aq({px:e,py:t,cx:i,cy:r,rx:s,ry:a,largeArcFlag:n,sweepFlag:o}){let l=[];if(s===0||a===0)return[];let h=(e-i)/2,c=(t-r)/2;if(h===0&&c===0)return[];s=Math.abs(s),a=Math.abs(a);let d=Math.pow(h,2)/Math.pow(s,2)+Math.pow(c,2)/Math.pow(a,2);d>1&&(s*=Math.sqrt(d),a*=Math.sqrt(d));let u=sq(e,t,i,r,s,a,h,c,n,o),{ang1:p,ang2:f}=u,{centerx:g,centery:m}=u,v=Math.abs(f)/(K0/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);f/=y;for(let x=0;x<y;x++)l.push(rq(p,f)),p+=f;return l.map(x=>{let{x:w,y:_}=Tg(x[0],s,a,g,m),{x:b,y:A}=Tg(x[1],s,a,g,m),{x:S,y:E}=Tg(x[2],s,a,g,m);return{x1:w,y1:_,x2:b,y2:A,x:S,y:E}})}var Gt;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Gt||(Gt={}));var Pi;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Pi||(Pi={}));function ot(e,t){if(!e)throw t||"Assertion Failed!"}var Ze=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){ot(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?s<a?i.t-t.t+(t.t-r.t)*(s/(s+a)):i.t-r.t+(r.t-t.t)*(a/(s+a)):0},e.edgeSign=function(t,i,r){ot(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?(i.t-r.t)*s+(i.t-t.t)*a:0},e.transEval=function(t,i,r){ot(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?s<a?i.s-t.s+(t.s-r.s)*(s/(s+a)):i.s-r.s+(r.s-t.s)*(a/(s+a)):0},e.transSign=function(t,i,r){ot(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?(i.s-r.s)*s+(i.s-t.s)*a:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,s){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+s)/2:i+(s-i)*(t/(t+r)):s+(i-s)*(r/(t+r))},e.intersect=function(t,i,r,s,a){var n,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,s)||(l=r,r=s,s=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.vertLeq(r,i)?e.vertLeq(i,s)?(n=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,i.s)):(n=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,s.s)):a.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,s)||(l=r,r=s,s=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.transLeq(r,i)?e.transLeq(i,s)?(n=e.transEval(t,r,i),o=e.transEval(r,i,s),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,i.t)):(n=e.transSign(t,r,i),o=-e.transSign(t,s,i),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,s.t)):a.t=(r.t+i.t)/2},e}(),Ac=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),ju=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),rh=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),aS=function(){function e(){var t=new rh,i=new Ac,r=new ju(0),s=new ju(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=s,s.next=s,s.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=s}return e.prototype.makeEdge_=function(t){var i=new ju(0),r=new ju(1);t.Sym.side<t.side&&(t=t.Sym);var s=t.Sym.next;return r.next=s,s.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,s=i.Onext;r.Sym.Lnext=i,s.Sym.Lnext=t,t.Onext=s,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var s=t;ot(s,"Vertex can't be null!");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i;var n=i;do n.Org=s,n=n.Onext;while(n!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;ot(s,"Face can't be null");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var n=i;do n.Lface=s,n=n.Lnext;while(n!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,s=r;do s.Org=i,s=s.Onext;while(s!==r);var a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.makeEdge=function(){var t=new rh,i=new rh,r=new Ac,s=this.makeEdge_(this.eHead);return this.makeVertex_(t,s,this.vHead),this.makeVertex_(i,s.Sym,this.vHead),this.makeFace_(r,s,this.fHead),s},e.prototype.splice=function(t,i){var r=!1,s=!1;if(t!==i){if(i.Org!==t.Org&&(s=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!s){var a=new rh;this.makeVertex_(a,i,t.Org),t.Org.anEdge=t}if(!r){var n=new Ac;this.makeFace_(n,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var s=new Ac;this.makeFace_(s,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var s=new rh;return this.makeVertex_(s,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,s=this.makeEdge_(t),a=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(a,i),s.Org=t.Dst,a.Org=i.Org,s.Lface=a.Lface=t.Lface,t.Lface.anEdge=a,!r){var n=new Ac;this.makeFace_(n,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,a,n,o;s=i.Lnext;do r=s,s=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),a=r.Sym,a.Onext===a?this.killVertex_(a.Org,null):(a.Org.anEdge=a.Onext,this.splice_(a,a.Oprev)),this.killEdge_(r));while(r!=i);n=t.prev,o=t.next,o.prev=n,n.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,s,a,n,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,n=r.Org;s=r.Lnext,a=r.Sym,a&&a.Lface&&a.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(a.Lface),o+l-2<=t&&Ze.vertCCW(r.Lprev.Org,r.Org,a.Lnext.Lnext.Org)&&Ze.vertCCW(a.Lprev.Org,a.Org,r.Lnext.Lnext.Org)&&(s=a.Lnext,this.delete(a),r=null,a=null)),!(r&&r.Lnext.Org===n);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,a,n,o,l,h;for(a=t,a=t;(s=a.next)!==t;a=s){ot(s.prev===a),l=s.anEdge;do ot(l.Sym!==l),ot(l.Sym.Sym===l),ot(l.Lnext.Onext.Sym===l),ot(l.Onext.Sym.Lnext===l),ot(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(ot(s.prev===a&&s.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){ot(n.prev===o),l=n.anEdge;do ot(l.Sym!==l),ot(l.Sym.Sym===l),ot(l.Lnext.Onext.Sym===l),ot(l.Onext.Sym.Lnext===l),ot(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(ot(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)ot(l.Sym.next===h.Sym),ot(l.Sym!==l),ot(l.Sym.Sym===l),ot(l.Org!==null),ot(l.Dst!==null),ot(l.Lnext.Onext.Sym===l),ot(l.Onext.Sym.Lnext===l);ot(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),nS=function(){function e(){this.handle=null}return e}(),oS=function(){function e(){this.key=null,this.node=0}return e}(),nq=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new nS,this.handles[r]=new oS;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,s,a,n;for(s=i[t].handle;;){if(n=t<<1,n<this.size&&this.leq(r[i[n+1].handle].key,r[i[n].handle].key)&&++n,ot(n<=this.max),a=i[n].handle,n>this.size||this.leq(r[s].key,r[a].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,a,n;for(s=i[t].handle;;){if(n=t>>1,a=i[n].handle,n===0||this.leq(r[a].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var s,a;for(a=this.nodes.length,this.nodes.length=this.max+1,s=a;s<this.nodes.length;s++)this.nodes[s]=new nS;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new oS}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,s=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),s},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,s;ot(t>=1&&t<=this.max&&r[t].key!==null),s=r[t].node,i[s].handle=i[this.size].handle,r[i[s].handle].node=s,--this.size,s<=this.size&&(s<=1||this.leq(r[i[s>>1].handle].key,r[i[s].handle].key)?this.floatDown_(s):this.floatUp_(s)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),Pg=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),lS=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),oq=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new lS,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new lS;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),lq=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var s=t.event,a=i.eUp,n=r.eUp;if(a.Dst===s)return n.Dst===s?Ze.vertLeq(a.Org,n.Org)?Ze.edgeSign(n.Dst,a.Org,n.Org)<=0:Ze.edgeSign(a.Dst,n.Org,a.Org)>=0:Ze.edgeSign(n.Dst,s,n.Org)<=0;if(n.Dst===s)return Ze.edgeSign(a.Dst,s,a.Org)>=0;var o=Ze.edgeEval(a.Dst,s,a.Org),l=Ze.edgeEval(n.Dst,s,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&ot(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){ot(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,s;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(s=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),s===null)return null;e.fixUpperEdge(t,i,s),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var s=new Pg;return s.eUp=r,s.nodeUp=t.dict.insertBefore(i.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,r.activeRegion=s,s},e.isWindingInside=function(t,i){switch(t.windingRule){case Gt.ODD:return(i&1)!==0;case Gt.NONZERO:return i!==0;case Gt.POSITIVE:return i>0;case Gt.NEGATIVE:return i<0;case Gt.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,s=r.Lface;s.inside=i.inside,s.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var s,a=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,a=e.regionBelow(n),s=a.eUp,s.Org!=o.Org){if(!a.fixUpperEdge){e.finishRegion(t,n);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,a,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,n),o=a.eUp,n=a}return o},e.addRightEdges=function(t,i,r,s,a,n){var o,l,h,c,d=!0;h=r;do ot(Ze.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(a===null&&(a=e.regionBelow(i).eUp.Rprev),l=i,c=a;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===c.Org;)h.Onext!==c&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(c.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!d&&e.checkForRightSplice(t,l)&&(e.addWinding(h,c),e.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=o,c=h;l.dirty=!0,ot(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=Ze.vertL1dist(i,t),a=Ze.vertL1dist(r,t),n=.5*a/(s+a),o=.5*s/(s+a);t.coords[0]+=n*i.coords[0]+o*r.coords[0],t.coords[1]+=n*i.coords[1]+o*r.coords[1],t.coords[2]+=n*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,a,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,a,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp;if(Ze.vertLeq(s.Org,a.Org)){if(Ze.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;Ze.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,a.Oprev,s)):(t.mesh.splitEdge(a.Sym),t.mesh.splice(s,a.Oprev),i.dirty=r.dirty=!0)}else{if(Ze.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n;if(ot(!Ze.vertEq(s.Dst,a.Dst)),Ze.vertLeq(s.Dst,a.Dst)){if(Ze.edgeSign(s.Dst,a.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,n=t.mesh.splitEdge(s),t.mesh.splice(a.Sym,n),n.Lface.inside=i.inside}else{if(Ze.edgeSign(a.Dst,s.Dst,a.Org)>0)return!1;i.dirty=r.dirty=!0,n=t.mesh.splitEdge(a),t.mesh.splice(s.Lnext,a.Sym),n.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n=s.Org,o=a.Org,l=s.Dst,h=a.Dst,c,d,u=new rh,p,f;if(ot(!Ze.vertEq(h,l)),ot(Ze.edgeSign(l,t.event,n)<=0),ot(Ze.edgeSign(h,t.event,o)>=0),ot(n!==t.event&&o!==t.event),ot(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(c=Math.min(n.t,l.t),d=Math.max(o.t,h.t),c>d))return!1;if(Ze.vertLeq(n,o)){if(Ze.edgeSign(h,n,o)>0)return!1}else if(Ze.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),Ze.intersect(l,n,h,o,u),ot(Math.min(n.t,l.t)<=u.t),ot(u.t<=Math.max(o.t,h.t)),ot(Math.min(h.s,l.s)<=u.s),ot(u.s<=Math.max(o.s,n.s)),Ze.vertLeq(u,t.event)&&(u.s=t.event.s,u.t=t.event.t),p=Ze.vertLeq(n,o)?n:o,Ze.vertLeq(p,u)&&(u.s=p.s,u.t=p.t),Ze.vertEq(u,n)||Ze.vertEq(u,o)?(e.checkForRightSplice(t,i),!1):!Ze.vertEq(l,t.event)&&Ze.edgeSign(l,t.event,u)>=0||!Ze.vertEq(h,t.event)&&Ze.edgeSign(h,t.event,u)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Sym,s),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,s.Oprev,s,s,!0),!0):l===t.event?(t.mesh.splitEdge(a.Sym),t.mesh.splice(s.Lnext,a.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=a.Oprev,a=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,a.Onext,s.Rprev,f,!0),!0):(Ze.edgeSign(l,t.event,u)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),Ze.edgeSign(h,t.event,u)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(a.Sym),t.mesh.splice(a.Oprev,s),s.Org.s=u.s,s.Org.t=u.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,n,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),s,a;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,s=i.eUp,a=r.eUp,s.Dst!==a.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(a),r=e.regionBelow(i),a=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==a.Org)if(s.Dst!==a.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||a.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===a.Org&&s.Dst===a.Dst&&(e.addWinding(a,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,a=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Ze.vertEq(o.Org,t.event)&&(t.mesh.splice(a.Oprev,o),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),Ze.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h){e.addRightEdges(t,i,r.Onext,a,a,!0);return}Ze.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,a,n,o,l;if(s=i.eUp,Ze.vertEq(s.Org,r)){ot(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Ze.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}ot(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,a=o=n.Onext,l.fixUpperEdge&&(ot(a!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=a.Oprev),t.mesh.splice(r.anEdge,n),Ze.edgeGoesLeft(a)||(a=null),e.addRightEdges(t,i,n.Onext,o,a,!0)},e.connectLeftVertex=function(t,i){var r,s,a,n,o,l,h=new Pg;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(n=r.eUp,o=s.eUp,Ze.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(a=Ze.vertLeq(o.Dst,n.Dst)?r:s,r.inside||a.fixUpperEdge){if(a===r)l=t.mesh.connect(i.anEdge.Sym,n.Lnext);else{var c=t.mesh.connect(o.Dnext,i.anEdge);l=c.Sym}a.fixUpperEdge?e.fixUpperEdge(t,a,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var s=e.topLeftRegion(t,r.activeRegion);ot(s!==null);var a=e.regionBelow(s),n=a.eUp,o=e.finishLeftRegions(t,a,null);o.Onext===n?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,n,n,!0)},e.addSentinel=function(t,i,r,s){var a=new Pg,n=t.mesh.makeEdge();n.Org.s=r,n.Org.t=s,n.Dst.s=i,n.Dst.t=s,t.event=n.Dst,a.eUp=n,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=t.dict.insert(a)},e.initEdgeDict=function(t){t.dict=new oq(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,a=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,a,n),e.addSentinel(t,s,a,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(ot(i.fixUpperEdge),ot(++r===1)),ot(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,a=t.mesh.eHead;for(i=a.next;i!==a;i=r)r=i.next,s=i.Lnext,Ze.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,a=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)a++;for(a+=8,i=t.pq=new nq(a,Ze.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,a;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,a=r.anEdge,ot(a.Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),t.mesh.delete(a));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!Ze.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),hq=function(){function e(){this.mesh=new aS,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=Gt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,s,a,n,o,l=[0,0,0],h=[0,0,0],c=[0,0,0],d=[0,0,0],u=[0,0,0],p=[null,null,null],f=[null,null,null],g=this.mesh.vHead;i=g.next;for(var m=0;m<3;++m)a=i.coords[m],h[m]=a,f[m]=i,l[m]=a,p[m]=i;for(i=g.next;i!==g;i=i.next)for(var v=0;v<3;++v)a=i.coords[v],a<h[v]&&(h[v]=a,f[v]=i),a>l[v]&&(l[v]=a,p[v]=i);var y=0;if(l[1]-h[1]>l[0]-h[0]&&(y=1),l[2]-h[2]>l[y]-h[y]&&(y=2),h[y]>=l[y]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[y],s=p[y],c[0]=r.coords[0]-s.coords[0],c[1]=r.coords[1]-s.coords[1],c[2]=r.coords[2]-s.coords[2],i=g.next;i!==g;i=i.next)d[0]=i.coords[0]-s.coords[0],d[1]=i.coords[1]-s.coords[1],d[2]=i.coords[2]-s.coords[2],u[0]=c[1]*d[2]-c[2]*d[1],u[1]=c[2]*d[0]-c[0]*d[2],u[2]=c[0]*d[1]-c[1]*d[0],n=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],n>o&&(o=n,t[0]=u[0],t[1]=u[1],t[2]=u[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,a=0,n=t.next;n!==t;n=n.next)if(s=n.anEdge,!(s.winding<=0))do a+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==n.anEdge);if(a<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,s,a=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),a=!0),r=this.sUnit,s=this.tUnit;var n=this.longAxis_(i);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,s[n]=0,s[(n+1)%3]=0,s[(n+2)%3]=i[n]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,s);a&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Ze.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ze.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var a=void 0;r.Lnext!==s;)if(Ze.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Ze.edgeGoesLeft(s.Lnext)||Ze.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)a=t.connect(s.Lnext,s),s=a.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(Ze.edgeGoesRight(r.Lprev)||Ze.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)a=t.connect(r,r.Lprev),r=a.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)a=t.connect(s.Lnext,s),s=a.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var s,a=t.eHead.next;a!==t.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?i:-i:r?t.delete(a):a.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,s){var a,n=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){a=c.anEdge,l=0;do{var h=a.Org;h.n===-1&&(h.n=o,o++),l++,a=a.Lnext}while(a!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=n,++n}this.elementCount=n,i===Pi.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*s,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var d=h.n*s;this.vertices[d+0]=h.coords[0],this.vertices[d+1]=h.coords[1],s>2&&(this.vertices[d+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var u=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(c.inside){a=c.anEdge,l=0;do{var h=a.Org;this.elements[u++]=h.n,l++,a=a.Lnext}while(a!==c.anEdge);for(var p=l;p<r;++p)this.elements[u++]=-1;if(i===Pi.CONNECTED_POLYGONS){a=c.anEdge;do this.elements[u++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==c.anEdge);for(var f=l;f<r;++f)this.elements[u++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,a=0,n=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){s=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==s);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,c=0;a=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){n=0,s=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,n++,r=r.Lnext;while(r!==s);this.elements[c++]=a,this.elements[c++]=n,a+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new aS),t<2&&(t=2),t>3&&(t=3);for(var r=null,s=0;s<i.length;s+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[s+0],r.Org.coords[1]=i[s+1],t>2?r.Org.coords[2]=i[s+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,s,a,n){if(t===void 0&&(t=Gt.ODD),i===void 0&&(i=Pi.POLYGONS),n===void 0&&(n=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),lq.computeInterior(this,n);var o=this.mesh;return i===Pi.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===Pi.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function eo(e){var t=e.windingRule,i=t===void 0?Gt.ODD:t,r=e.elementType,s=r===void 0?Pi.POLYGONS:r,a=e.polySize,n=a===void 0?3:a,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,c=h===void 0?[0,0,1]:h,d=e.contours,u=d===void 0?[]:d,p=e.strict,f=p===void 0?!0:p,g=e.debug,m=g===void 0?!1:g;if(!u&&f)throw new Error("Contours can't be empty");if(u){var v=new hq;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<u.length;y++)v.addContour(l||2,u[y]);return v.tesselate(i,s,n,l,c,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:m?v.mesh:void 0}}}Gt.ODD;Gt.NONZERO;Gt.POSITIVE;Gt.NEGATIVE;Gt.ABS_GEQ_TWO;Pi.POLYGONS;Pi.CONNECTED_POLYGONS;Pi.BOUNDARY_CONTOURS;var J0=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*J0.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} → ${e}`);let i=e*J0.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,a=0,n=new Float32Array(r,a*s,3*e);a+=3*e;let o=new Float32Array(r,a*s,3*e);a+=3*e;let l=new Float32Array(r,a*s,2*e);t?(n.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(n.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=n,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} → ${this.size}`),this.realloc(this.size,!0)}},RC=J0;RC.eSize=8*Float32Array.BYTES_PER_ELEMENT;var cq=class{constructor(e=[],t=(i,r)=>i<r?-1:i>r?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:i}=this,r=t[e];for(;e>0;){let s=e-1>>1,a=t[s];if(i(r,a)>=0)break;t[e]=a,e=s}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,s=t[e];for(;e<r;){let a=(e<<1)+1,n=a+1;if(n<this.length&&i(t[n],t[a])<0&&(a=n),i(t[a],s)>=0)break;t[e]=t[a],e=a}t[e]=s}};function dq(e,t,i=1,r=!1){let s=1/0,a=1/0,n=-1/0,o=-1/0;for(let[y,x]of e[0])y<s&&(s=y),x<a&&(a=x),y>n&&(n=y),x>o&&(o=x);let l=n-s,h=o-a,c=Math.max(i,Math.min(l,h));if(c===i){let y=[s,a];return y.distance=0,y.distance}let d=new cq([],(y,x)=>x.max-y.max),u=pq(e),p=new Df(s+l/2,a+h/2,0,e);p.d>u.d&&(u=p);let f=2;function g(y,x,w){let _=new Df(y,x,w,e);if(f++,_.max>u.d+i&&d.push(_),_.d>u.d&&(u=_,r&&console.log(`found best ${Math.round(1e4*_.d)/1e4} after ${f} probes`),u.d>t))return t}let m=c/2;for(let y=s;y<n;y+=c)for(let x=a;x<o;x+=c)g(y+m,x+m,m);for(;d.length;){let{max:y,x,y:w,h:_}=d.pop();if(y-u.d<=i)break;m=_/2,g(x-m,w-m,m),g(x+m,w-m,m),g(x-m,w+m,m),g(x+m,w+m,m)}r&&console.log(`num probes: ${f}
  3064. best distance: ${u.d}`);let v=[u.x,u.y];return v.distance=u.d,v.distance}function Df(e,t,i,r){this.x=e,this.y=t,this.h=i,this.d=uq(e,t,r),this.max=this.d+this.h*Math.SQRT2}function uq(e,t,i){let r=!1,s=1/0;for(let a of i)for(let n=0,o=a.length,l=o-1;n<o;l=n++){let h=a[n],c=a[l];h[1]>t!=c[1]>t&&e<(c[0]-h[0])*(t-h[1])/(c[1]-h[1])+h[0]&&(r=!r),s=Math.min(s,fq(e,t,h,c))}return s===0?0:(r?1:-1)*Math.sqrt(s)}function pq(e){let t=0,i=0,r=0,s=e[0];for(let n=0,o=s.length,l=o-1;n<o;l=n++){let h=s[n],c=s[l],d=h[0]*c[1]-c[0]*h[1];i+=(h[0]+c[0])*d,r+=(h[1]+c[1])*d,t+=d*3}let a=new Df(i/t,r/t,0,e);return t===0||a.d<0?new Df(s[0][0],s[0][1],0,e):a}function fq(e,t,i,r){let s=i[0],a=i[1],n=r[0]-s,o=r[1]-a;if(n!==0||o!==0){let l=((e-s)*n+(t-a)*o)/(n*n+o*o);l>1?(s=r[0],a=r[1]):l>0&&(s+=n*l,a+=o*l)}return n=e-s,o=t-a,n*n+o*o}var z1={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},LC={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},zC={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},Dg=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),B1=class extends Ge{constructor(e,t,i=0,r=12,s=3,a=Gt.ODD,n=!1){super(),this.forPathBevel=n,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=s;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(E=>{let C=E.extractShapePointsToFlatArray([],r),T=[];for(let D=C.length-1;D>=1;D-=2){let O=C[D-1],P=C[D-0];T.push(O,P)}return T}),h=[],c=[];for(let E=0;E<o.length;E+=2)c.push([o[E],o[E+1]]);h.push(c);for(let E=0;E<l.length;E++){let C=l[E],T=[];for(let D=0;D<C.length;D+=2)T.push([C[D],C[D+1]]);h.push(T)}let d;e.isText?d=new t1().setFromPoints(e.points.map(E=>E.position)).getSize(new j).length()*.1:h[0].length===0?d=i:i>0?d=dq(h,i):d=1e-5,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,d,t/2),this._bevelSegments=Math.floor(s));let u;try{u=eo({windingRule:a,elementType:Pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{u=z1}let p;try{p=eo({windingRule:Gt.ODD,elementType:Pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=LC}if(!u)throw new Error("error generating geometry");let f=u.elementCount;if(p){u.elementCount+=p.elementCount;for(let E=0;E<p.elements.length;E++){let C=p.elements[E],T=E%2===0?u.vertexCount:0;u.elements.push(C+T)}for(let E=0;E<p.vertexIndices.length;E++){let C=p.vertexIndices[E],T=u.vertexCount;u.vertexIndices.push(C+T)}for(let E=0;E<p.vertices.length;E++){let C=p.vertices[E];u.vertices.push(C)}}let g=1/0,m=-1/0,v=1/0,y=-1/0;for(let E=0,C=u.vertexCount;E<C;E++){let T=E*2,D=u.vertices[T+0],O=u.vertices[T+1];D<g&&(g=D),D>m&&(m=D),O<v&&(v=O),O>y&&(y=O)}this._minX=g,this._minY=v,this._width=m-g,this._height=y-v,this._buffer=new RC(this._computeBufferEstimatedSize(u));let x=[],w=[];for(let E=u.elementCount-1;E>=0;E--){let C=E>=f,T=E*2,D=u.elements[T+0],O=u.elements[T+1],P=D+O,U={start:D,count:O,normals:[],continuous:[],concave:[]},W=D,k=P-1,F=D+1,Z=this._shape.roundedCurves.length;do{let Q=W-D,ee=u.vertices[k*2+0],H=u.vertices[k*2+1],he=u.vertices[W*2+0],re=u.vertices[W*2+1],te=u.vertices[F*2+0],ae=u.vertices[F*2+1],de=he-ee,pe=re-H,be=Math.sqrt(de*de+pe*pe);de/=be,pe/=be;let Le=he-te,Me=re-ae,Ve=Math.sqrt(Le*Le+Me*Me);Le/=Ve,Me/=Ve,U.normals[Q*2+0]=-Me,U.normals[Q*2+1]=Le,U.concave[Q]=de*Me-pe*Le>0;let Ue=u.vertexIndices[W];if(Array.isArray(Ue))U.continuous[Q]=!1;else{let[Ce,Ee]=this._shape.getCurveIndexFromVertexId(Ue-1,!0);if(Ee>0&&Ee<1)U.continuous[Q]=!0;else{let Ye=Ee===1?Ce+1:Ce-1;Ye=(Ye+Z)%Z;let qe=Ee===1?0:1,V=this._shape.roundedCurves[Ce].getTangent(Ee),z=this._shape.roundedCurves[Ye].getTangent(qe);U.continuous[Q]=V.dot(z)>.95}}C&&(U.normals[Q*2+0]*=-1,U.normals[Q*2+1]*=-1),[k,W,F]=[W,F,F+1],F>=P&&(F-=O)}while(F!==D+1);let X=[];X.push({bevelI:0,angle:0,size:0,boundary:{vertices:u.vertices.slice(D*2,P*2),vertexCount:O,vertexIndices:new Array(O).fill(!0).map((Q,ee)=>[ee,ee]),elements:[0,O],elementCount:1,mesh:null},reverseMap:[],insetPoints:u.vertices.slice(D*2,P*2)});let G=0;for(let Q=1;Q<=this._bevelSegments;Q++){let ee=Q/this._bevelSegments*Math.PI/2,H=(1-Math.cos(ee))*this._bevel,he=[],re=[],te=0;for(let de=0;de<O;de++){let pe=de*2,be=(de-1+O)%O*2,Le=u.vertices[U.start*2+pe+0],Me=u.vertices[U.start*2+pe+1],Ve=-U.normals[be+0]*H,Ue=-U.normals[be+1]*H,Ce=-U.normals[pe+0]*H,Ee=-U.normals[pe+1]*H;if(U.concave[de]||!U.concave[de]&&C){let Ye=Math.atan2(Ue,Ve),qe=Math.atan2(Ee,Ce);qe>Ye&&(qe-=Math.PI*2);let V=qe-Ye;if(U.continuous[de]||C){let z=Ye+V/2,oe=Math.cos(z)*H,Se=Math.sin(z)*H;he[2*te+0]=Le+oe*(C?-1:1),he[2*te+1]=Me+Se*(C?-1:1),re[te]=de,te++}else{let z=Math.max(1,Math.floor(r/4*Math.abs(V)/Math.PI));for(let oe=0;oe<=z;oe++){let Se=Ye+V*(oe/z),R=Math.cos(Se)*H,Te=Math.sin(Se)*H;he[2*te+0]=Le+R,he[2*te+1]=Me+Te,re[te]=de,te++}}}else he[2*te+0]=Le+Ve,he[2*te+1]=Me+Ue,re[te]=de,te++,he[2*te+0]=Le,he[2*te+1]=Me,re[te]=de,te++,he[2*te+0]=Le+Ce,he[2*te+1]=Me+Ee,re[te]=de,te++}let ae=eo({windingRule:Gt.POSITIVE,elementType:Pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[he],edgeCreateCallback:de=>{let pe=de.Org.idx,be=re[pe],Le=re[(pe+1)%re.length];de.idx=[be,Le],de.Sym.idx=[Le,be]},vertexIdCallback:de=>{let pe=de.Lprev.idx;return[pe?pe[1]:0,de.idx?de.idx[0]:0]}});if(!ae)throw console.log("Error"),new Error(`error generating bevel geometry for ${Q}'th loop`);if(!ae.vertexCount){let de=(Q-1)/this._bevelSegments*Math.PI/2;G=(1-Math.sin(de))*this._bevel;break}for(let de=0;de<ae.vertexIndices.length;de++){let[pe,be]=ae.vertexIndices[de];if(pe===be)continue;let Le=be;be<pe&&(Le+=O);for(let Me=pe;Me<Le;Me++){let Ve=Me%O,Ue=(Me+1)%O;if(!U.continuous[Ve]||!U.continuous[Ue]){ae.vertexIndices[de]=[pe,Ve],ae.vertexIndices.splice(de+1,0,[Ue,be]),ae.vertices.splice((de+1)*2,0,ae.vertices[de*2],ae.vertices[de*2+1]);break}}}X.push({bevelI:Q,angle:ee,size:H,boundary:ae,reverseMap:re,insetPoints:he})}let q=(Q,ee,H)=>{let he=0,re=Q.boundary.vertexIndices.length;for(;he<re&&H(Q.boundary.vertexIndices[ee]);)ee=(ee+1)%re,he++;return he},$=x.length;for(let Q=1;Q<X.length;Q++){let ee=X[Q-1],H=X[Q],he=ee.boundary.vertexIndices.length,re=H.boundary.vertexIndices.length;if(!he||!re)break;let te=U.concave.length,ae=0,de=Dg(ae,O);for(;!ee.boundary.vertexIndices.filter(de).length||!H.boundary.vertexIndices.filter(de).length;)ae++,de=Dg(ae,O);let pe=ee.boundary.vertexIndices.findIndex(de),be=H.boundary.vertexIndices.findIndex(de);do pe=(pe+1)%he;while(de(ee.boundary.vertexIndices[pe]));do be=(be+1)%re;while(de(H.boundary.vertexIndices[be]));ae=(ae+1)%O;let Le=ae,Me=0,Ve=this._buildBevelVert(U,ee,(pe-1+he)%he,void 0,Me),Ue=this._buildBevelVert(U,H,(be-1+re)%re,void 0,Me),Ce=Ve,Ee=Ue,Ye,qe,V=!1;do{Me=(ae||te)/te,de=Dg(ae,O);let z=q(ee,pe,de),oe=q(H,be,de),Se=V;if(V=!1,z&&!oe){for(let R=0;R<z;R++)Ye=this._buildBevelVert(U,ee,(pe+R)%he,R/(z-1),Me),x.push(Ce.topN,Ye.topP,Ee.topN),n===!1&&x.push(Ye.bottomP,Ce.bottomN,Ee.bottomN),Ce=Ye;V=!0}else if(!z&&oe)for(let R=0;R<oe;R++)qe=this._buildBevelVert(U,H,(be+R)%re,R/(oe-1),Me),x.push(Ee.topN,Ce.topP,qe.topP),n===!1&&x.push(Ce.bottomP,Ee.bottomN,qe.bottomP),Ee=qe;else if(z&&oe)if(Ye=this._buildBevelVert(U,ee,pe,0,Me),qe=this._buildBevelVert(U,H,be,0,Me),Se?(x.push(Ce.topN,qe.topP,Ee.topN),x.push(Ce.topN,Ye.topP,qe.topP),n===!1&&(x.push(qe.bottomP,Ce.bottomN,Ee.bottomN),x.push(qe.bottomP,Ye.bottomP,Ce.bottomN))):(x.push(Ee.topN,Ce.topN,Ye.topP),x.push(Ee.topN,Ye.topP,qe.topP),n===!1&&(x.push(Ye.bottomP,Ce.bottomN,Ee.bottomN),x.push(Ye.bottomP,Ee.bottomN,qe.bottomP))),Ce=Ye,Ee=qe,z===oe)for(let R=1;R<z;R++)Ye=this._buildBevelVert(U,ee,(pe+R)%he,R/(z-1),Me),qe=this._buildBevelVert(U,H,(be+R)%re,R/(oe-1),Me),x.push(Ce.topN,Ye.topP,Ee.topN),x.push(Ee.topN,Ye.topP,qe.topP),n===!1&&(x.push(Ye.bottomP,Ce.bottomN,Ee.bottomN),x.push(Ye.bottomP,Ee.bottomN,qe.bottomP)),Ce=Ye,Ee=qe;else if(z>oe){let R=z/oe,Te=0;for(let ke=1;ke<z;ke++)Ye=this._buildBevelVert(U,ee,(pe+ke)%he,ke/(z-1),Me),x.push(Ce.topN,Ye.topP,Ee.topN),n===!1&&x.push(Ye.bottomP,Ce.bottomN,Ee.bottomN),Ce=Ye,ke>(Te+1)*R&&(Te++,qe=this._buildBevelVert(U,H,(be+Te)%re,Te/(oe-1),Me),x.push(Ee.topN,Ye.topP,qe.topP),n===!1&&x.push(Ye.bottomP,Ee.bottomN,qe.bottomP),Ee=qe)}else{let R=oe/z,Te=0;for(let ke=1;ke<oe;ke++)qe=this._buildBevelVert(U,H,(be+ke)%re,ke/(oe-1),Me),x.push(Ee.topN,Ye.topP,qe.topP),n===!1&&x.push(Ye.bottomP,Ee.bottomN,qe.bottomP),Ee=qe,ke>(Te+1)*R&&(Te++,Ye=this._buildBevelVert(U,ee,(pe+Te)%he,Te/(z-1),Me),x.push(Ce.topN,Ye.topP,Ee.topN),n===!1&&x.push(Ye.bottomP,Ce.bottomN,Ee.bottomN),Ce=Ye)}pe=(pe+z)%he,be=(be+oe)%re,ae=(ae+1)%te}while(ae!==Le)}if(n===!1&&this._depth>this._bevel*2&&this._buildWall(X,U,x),C){let Q=[];for(let ee=x.length-1;ee>=$+2;ee-=3){let H=x[ee-2],he=x[ee-1],re=x[ee-0];Q.push(re,he,H)}x.splice($,x.length-$,...Q)}if(C){let Q=[];for(let ee=X[X.length-1].boundary.vertices.length-1;ee>=1;ee-=2){let H=X[X.length-1].boundary.vertices[ee-1],he=X[X.length-1].boundary.vertices[ee-0];Q.push(H,he)}w.push(Q)}if(!C){let Q=X[X.length-1],ee;try{ee=eo({windingRule:X.length>1?Gt.POSITIVE:Gt.ODD,elementType:Pi.POLYGONS,vertexSize:2,strict:!0,contours:[Q.insetPoints,...w]})}catch{ee=zC}if(!ee)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<d&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let H=0;H<ee.elementCount*3;H+=3){let he=this._buildSurfaceVert(ee,ee.elements[H+0],G),re=this._buildSurfaceVert(ee,ee.elements[H+1],G),te=this._buildSurfaceVert(ee,ee.elements[H+2],G);x.push(he.top,re.top,te.top),n===!1&&x.push(te.bottom,re.bottom,he.bottom)}}this.vertexCache={}}this._buffer.shrink();let _=new tt(Uint32Array.from(x),1),b=new tt(this._buffer.positions,3),A=new tt(this._buffer.normals,3),S=new tt(this._buffer.uvs,2);b.needsUpdate=!0,A.needsUpdate=!0,S.needsUpdate=!0,_.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",A),this.setAttribute("uv",S),this.setIndex(_)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,a=r.boundary.vertexCount;s<a;s++){let n=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%a);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}_buildSurfaceVert(e,t,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[t*2+0],a=e.vertices[t*2+1],n=(s-this._minX)/this._width,o=(a-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,c=l*2,d={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[c+0]=n,this._buffer.uvs[c+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[c+2]=n,this._buffer.uvs[c+3]=o),this.vertexCache[r]=d,d}_buildBevelVert(e,t,i,r=1,s){let a=`${t.bevelI}:${i}`;if(a in this.vertexCache&&s!==0&&s!==1&&(!s||s===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[n,o]=t.boundary.vertexIndices[i],l,h,c,d;n!==o?(h=n,l=o,d=!1,c=e.continuous[h]&&e.continuous[l]):(l=n,h=(l-1+e.count)%e.count,d=e.concave[l]&&t.bevelI>0,c=e.continuous[l]||d);let u=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,g=l*2,m=h*2,v=t.boundary.vertices[f+0],y=t.boundary.vertices[f+1],x=(1-p)*this._bevel,w=(v-this._minX)/this._width,_=(y-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(w=s),_=1);let b=e.normals[g+0],A=e.normals[g+1],S=e.normals[m+0],E=e.normals[m+1];if(d){let P=S-b,U=E-A;b=b+P*(1-r),A=A+U*(1-r);let W=Math.sqrt(b*b+A*A);b/=W,A/=W}let C=this.forPathBevel?this._buffer.get(c?1:2):this._buffer.get(c?2:4),T=C*3,D=C*2,O={i,fi:l,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1,pathBevelUCoord:s};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=b*u,this._buffer.normals[T+1]=A*u,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=w,this._buffer.uvs[D+1]=_,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=b*u,this._buffer.normals[T+4]=A*u,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=_,this._buffer.uvs[D+3]=w),c||(this.forPathBevel?(C+=1,T+=3,D+=2):(C+=2,T+=6,D+=4),O.topP=C+0,O.bottomP=C+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=S*u,this._buffer.normals[T+1]=E*u,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=w,this._buffer.uvs[D+1]=_,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=S*u,this._buffer.normals[T+4]=E*u,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=_,this._buffer.uvs[D+3]=w)),this.vertexCache[a]=O,O}clone(){let e=new B1(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=rm(this.userData),e}},BC=class extends Ge{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=Gt.ODD,this.elementType=Pi.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Gt.ODD,elementType:Pi.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(u=>u.extractShapePointsToFlatArray([],this._curveSegments)),a,n=!0,o=!0,l,h;for(let u=0,p=r.length/2;u<p;u++){let f=u*2,g=r[f+0],m=r[f+1];if(l!==void 0&&g!==l&&(n=!1),h!==void 0&&m!==h&&(o=!1),l=g,h=m,!n&&!o)break}if(!n&&!o)try{a=eo({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=z1}let c=(a==null?void 0:a.vertexCount)??1,d=(a==null?void 0:a.elementCount)??1;if(this._positionAttribute=new tt(new Float32Array(c*3),3),this._normalAttribute=new tt(new Float32Array(c*3),3),this._uvAttribute=new tt(new Float32Array(c*2),2),this._indexAttribute=new tt(new Uint32Array(d*3),1),a){let u=1/0,p=-1/0,f=1/0,g=-1/0;for(let y=0,x=c;y<x;y++){let w=y*2,_=a.vertices[w+0],b=a.vertices[w+1];_<u&&(u=_),_>p&&(p=_),b<f&&(f=b),b>g&&(g=b)}let m=p-u,v=g-f;for(let y=0,x=c;y<x;y++){let w=y*2,_=a.vertices[w+0],b=a.vertices[w+1],A=(_-u)/m,S=(b-f)/v;this._positionAttribute.setXYZ(y,_,b,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,A,S)}for(let y=0,x=d;y<x;y++){let w=y*3,_=a.elements[w+0],b=a.elements[w+1],A=a.elements[w+2];this._indexAttribute.setX(w+0,_),this._indexAttribute.setX(w+1,b),this._indexAttribute.setX(w+2,A)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,((a==null?void 0:a.elementCount)??1)*3)}clone(){let e=new BC(this._shape,this._curveSegments);return e.userData=rm(this.userData),e}},FC=class extends B1{constructor(e,t,i=0,r=12,s=3,a=Gt.ODD){super(e,t,i,r,s,a),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,a=r.boundary.vertexCount;s<a;s++){let n=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%a);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}clone(){let e=new FC(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=rm(this.userData),e}},yl=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var h,c;let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Gt.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.abs(i.depth??0),n=e.shape??(t==null?void 0:t.shape),o=(n==null?void 0:n.roundness)??i.roundness;n!==void 0&&(n instanceof mi?(n.width!==r||n.height!==s)&&n.applySize(r,s):n=new mi(r,s).fromJSON(n),((h=e.parameters)==null?void 0:h.roundness)!==void 0&&((c=e.parameters)==null?void 0:c.roundness)>0&&n.update());let l=n??new mi(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:a,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:a,windingRule:n}=e.parameters;e.shape.roundness=a;let o;return t<=0?o=new BC(e.shape,s,{windingRule:n}):o=new FC(e.shape,t,i,s,r,n),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},UC=Math.PI*2,F1=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return i.angle=Re.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof mi?e.shape:new mi,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:s,innerRadius:a,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,c=t*.5,d=i*.5,u=mq(h,c,d,s*Math.PI/180,r,a);h.isClosed=!0,h.update();let p;return s===0?(p=new Ge,p.setAttribute("position",new Ie([],3))):p=yl.create({shape:h,parameters:{subdivisions:u,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}}),Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function mq(e,t,i,r,s,a){if(r>=UC)return s>30||s%4===0?(vq(e,t,i,a),Math.round(s/4)):hS(e,r,s,t,i,a);r=Math.max(r,.001);let n={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=aq({px:n.x,py:n.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?gq(e,n.x,n.y,h,s,t,i,a):hS(e,r,s,t,i,a)}function gq(e,t,i,r,s,a,n,o){let l=Math.round(s/r.length);e.addPoint(wh(t,i));for(let h=0,c=r.length;h<c;h++){let d=r[h],u=e.points[h],p=wh(d.x,d.y);u.controls[1].position.set(d.x1,d.y1),p.controls[0].position.set(d.x2,d.y2),e.addPoint(p)}return o>0?NC(e,a,n,o):e.addPoint(wh(0,0)),l}function hS(e,t,i,r,s,a){let n=-t/i;for(let o=0;o<=i;o++){let l=n*o,h=Math.sin(l)*r,c=Math.cos(l)*s;e.addPoint(wh(h,c))}return t<UC?a>0?NC(e,r,s,a):e.addPoint(wh(0,0)):(e.removePoint(e.points[e.points.length-1]),a>0&&kC(e,r,s,a)),1}function vq(e,t,i,r=0,s=0,a=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(Gu(s-t,a,s-t,a-l,s-t,a+l)),e.addPoint(Gu(s,a+i,s-o,a+i,s+o,a+i)),e.addPoint(Gu(s+t,a,s+t,a+l,s+t,a-l)),e.addPoint(Gu(s,a-i,s+o,a-i,s-o,a-i)),r>0&&kC(e,t,i,r)}function wh(e,t){return new bh(Re.generateUUID(),new j(e,t))}function Gu(e,t,i,r,s,a){let n=wh(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(s,a),n}function NC(e,t,i,r){VC(e,t,i,r).forEach(s=>e.addPoint(s))}function kC(e,t,i,r){let s=VC(e,t,i,r),a=new mi;s.forEach(n=>a.addPoint(n)),a.isClosed=!0,e.shapeHoles.push(a)}function VC(e,t,i,r){let s=r*t/100,a=s*(Math.abs(i)/Math.abs(t)),n=new j(s/t,a/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=Re.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(n);let h=l.controls[0].position.clone().multiply(n),c=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(c),l.controls[1].position.copy(h)}),o}var yq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),a=Math.abs(i.depth??r),n=Math.abs(Math.min(r,a))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:a,radius:n,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:s,revolutions:a,segments:n,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:c,cornerSegments:d}=e.parameters,u=new jC(!1,t,i,r,s,a,n,o,l,h,c,d);return Object.assign(u,{userData:{...e,type:"HelixGeometry"}})}},Ig=new mh([0,0,0],1),jC=class extends Ge{constructor(e=!0,t=1,i=1,r=1,s=1,a=1,n=1,o=1,l=1,h=1,c=1,d=1){if(super(),a===0)return;let u=e&&a===1;u&&(d=0),c>100&&(c=100),c===0&&(d=0);let p=()=>new M,f=new M,g=p(),m=p(),v=p(),y,x,w,_,b,A,S,E,C=p(),T=p(),D=p(),O=p(),P=p(),U=p(),W=p(),k=p(),F=i-2*o+.001,Z=F/a,X=Math.ceil(n*a),G=X+1,q=F/X,$=-F/2,Q=h+1,ee=2*Math.PI/h,H=Math.PI/2/d,he=.01,re=Math.min((1-c/100)*o,o-he),te=o-re,ae=0,de=2,pe=d*de+de,be=Q*pe/de,Le=be+Q*G,Me=Math.max(0,Q*(G+pe)),[Ve,Ue,Ce]=[3,3,2].map(ue=>Array(Me*ue).fill(0)),Ee=[],Ye=s-o;function qe(ue,je){let ze=Math.PI/2;A=je*q,E=2*Math.PI*(A%Z)/Z+ze,A+=$,S=Math.sin(E)*Ye,b=Math.cos(E)*Ye,e?ue.set(b,S,A):ue.set(b,A,S)}qe(f,-1e-10),qe(g,0),C.copy(f),qe(f,1);let V=f.distanceTo(g),z=u?0:te+re,oe=V*X+2*z,Se=re,R=oe-z;for(let ue=0;ue<=X;ue++){qe(m,ue),k.subVectors(m,C).normalize(),C.copy(m),U.copy(m).setComponent(+e+1,0).normalize(),W.crossVectors(k,U).normalize();let je=ue===0,ze=ue===X,Xe=je?3*Math.PI/2:H,it=je?Se:R,Qe=je?Q:Le,Ke=je?0:Me-Q,qt=k.clone().multiplyScalar(je?-te:te).add(m),oi=k.clone().multiplyScalar(je?-1:1).normalize();for(let K=0;K<Q;K++){let ge=K*ee;if(T.addVectors(f.copy(U).multiplyScalar(o*Math.cos(ge)),g.copy(W).multiplyScalar(o*Math.sin(ge))),D.copy(T).normalize(),je||ze){u||(ae=Ke+K,[0,1,2].forEach(_e=>{Ve[ae*3+_e]=qt.getComponent(_e),Ue[ae*3+_e]=oi.getComponent(_e)}),Ce[ae*2]=+ze,Ce[ae*2+1]=K/h),g.copy(D).multiplyScalar(re),v.addVectors(m,g);for(let _e=0;_e<d;_e++){let Be=_e*H+Xe;O.addVectors(f.copy(k).multiplyScalar(te*Math.sin(Be)),g.copy(D).multiplyScalar(te*Math.cos(Be))),P.copy(O).normalize(),g.addVectors(v,O),O.normalize(),ae=Qe+_e*Q+K,[0,1,2].forEach(Et=>{Ve[ae*3+Et]=g.getComponent(Et),Ue[ae*3+Et]=P.getComponent(Et)});let nt=+je+Math.sin(Be);Ce[ae*2]=(it+te*nt)/oe,Ce[ae*2+1]=K/h}}g.addVectors(m,T),ae=be+ue*Q+K,[0,1,2].forEach(_e=>{Ve[ae*3+_e]=g.getComponent(_e),Ue[ae*3+_e]=D.getComponent(_e)}),Ce[ae*2]=(z+ue*V)/oe,Ce[ae*2+1]=K/h}}let Te=G+2*d+de,[ke,Oe]=[+u,Te-1];for(let ue=ke;ue<=Oe-1;ue++){let je=u&&ue===Oe-1;for(let ze=0;ze<Q-1;ze++)y=ue*Q+ze,x=y+1,w=(je?ze:y)+Q,_=(je?ze+1:x)+Q,ue===0?Ee.push(x,_,w):ue===Te-2?Ee.push(y,x,w):Ee.push(y,x,w,x,_,w)}this.setIndex(Ee),this.setAttribute("position",new Ie(Ve,3)),this.setAttribute("normal",new Ie(Ue,3)),this.setAttribute("uv",new Ie(Ce,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),s,a,n,o,l=6*(t-1)*e.radialSegments,h=t,c=h===t;for(let d=0;d<e.radialSegments;d++)s=h*i+d,a=s+1,n=(c?d:s)+i,o=(c?d+1:a)+i,r[l++]=s,r[l++]=a,r[l++]=n,r[l++]=a,r[l++]=o,r[l++]=n;return r.length=l,Ig.array=r,Ig.count=r.length,Ig}},xq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new GC(t*.5,a,n):new IM(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},GC=class extends O1{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],n="IcosahedronGeometry";super(s,a,n,e,t,i),this.type=n}static fromJSON(e){return new GC(e.radius,e.corner,e.cornerSides)}},bq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r;(((r=e.parameters)==null?void 0:r.points)??[]).forEach(s=>{Array.isArray(s)&&(s.x=s[0],s.y=s[1])});let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,s=new qp;s.moveTo(t[0].x,t[0].y),s.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let a=new MM(s.extractPoints(r).shape,i);return a.rotateZ(Math.PI),Object.assign(a,{userData:{...e,type:"LatheGeometry"}})}},ra=new we,Og=new kt,Hu=new M,If=class extends yr{constructor(){super(),this.uuid=Re.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new Di().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];s.normal.applyMatrix3(t).normalize();for(let a=0,n=s.vertexNormals.length;a<n;a++)s.vertexNormals[a].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return ra.makeRotationX(e),this.applyMatrix4(ra),this}rotateY(e){return ra.makeRotationY(e),this.applyMatrix4(ra),this}rotateZ(e){return ra.makeRotationZ(e),this.applyMatrix4(ra),this}translate(e,t,i){return ra.makeTranslation(e,t,i),this.applyMatrix4(ra),this}scale(e,t,i){return ra.makeScale(e,t,i),this.applyMatrix4(ra),this}lookAt(e){return Og.lookAt(e),Og.updateMatrix(),this.applyMatrix4(Og.matrix),this}fromBufferGeometry(e){let t=this,i=e.index!==null?e.index:void 0,r=e.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,a=r.normal,n=r.color,o=r.uv,l=r.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)t.vertices.push(new M().fromBufferAttribute(s,d)),n!==void 0&&t.colors.push(new et().fromBufferAttribute(n,d));function h(d,u,p,f){let g=n===void 0?[]:[t.colors[d].clone(),t.colors[u].clone(),t.colors[p].clone()],m=a===void 0?[]:[new M().fromBufferAttribute(a,d),new M().fromBufferAttribute(a,u),new M().fromBufferAttribute(a,p)],v=new $0(d,u,p,m,g,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new j().fromBufferAttribute(o,d),new j().fromBufferAttribute(o,u),new j().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new j().fromBufferAttribute(l,d),new j().fromBufferAttribute(l,u),new j().fromBufferAttribute(l,p)])}let c=e.groups;if(c.length>0)for(let d=0;d<c.length;d++){let u=c[d],p=u.start,f=u.count;for(let g=p,m=p+f;g<m;g+=3)i!==void 0?h(i.getX(g),i.getX(g+1),i.getX(g+2),u.materialIndex):h(g,g+1,g+2,u.materialIndex)}else if(i!==void 0)for(let d=0;d<i.count;d+=3)h(i.getX(d),i.getX(d+1),i.getX(d+2));else for(let d=0;d<s.count;d+=3)h(d,d+1,d+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Hu).negate(),this.translate(Hu.x,Hu.y,Hu.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new we;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let e=new M,t=new M;for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],a=this.vertices[s.a],n=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,n),t.subVectors(a,n),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let i=0,r=this.vertices.length;i<r;i++)t[i]=new M;if(e){let i=new M,r=new M;for(let s=0,a=this.faces.length;s<a;s++){let n=this.faces[s],o=this.vertices[n.a],l=this.vertices[n.b],h=this.vertices[n.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[n.a].add(i),t[n.b].add(i),t[n.c].add(i)}}else{this.computeFaceNormals();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let i=0,r=this.vertices.length;i<r;i++)t[i].normalize();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],a=s.vertexNormals;a.length===3?(a[0].copy(t[s.a]),a[1].copy(t[s.b]),a[2].copy(t[s.c])):(a[0]=t[s.a].clone(),a[1]=t[s.b].clone(),a[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let i=this.faces[e],r=i.vertexNormals;r.length===3?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,a=r.vertexNormals.length;s<a;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new If;e.faces=this.faces;for(let t=0,i=this.morphTargets.length;t<i;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,a=this.morphNormals[t].vertexNormals;for(let n=0,o=this.faces.length;n<o;n++){let l=new M,h={a:new M,b:new M,c:new M};s.push(l),a.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,a=this.faces.length;s<a;s++){let n=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(n.normal),l.a.copy(n.vertexNormals[0]),l.b.copy(n.vertexNormals[1]),l.c.copy(n.vertexNormals[2])}}for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Si),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new $r),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,i=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let r,s=this.vertices.length,a=this.vertices,n=e.vertices,o=this.faces,l=e.faces,h=this.colors,c=e.colors;t!==void 0&&(r=new Di().getNormalMatrix(t));for(let d=0,u=n.length;d<u;d++){let p=n[d].clone();t!==void 0&&p.applyMatrix4(t),a.push(p)}for(let d=0,u=c.length;d<u;d++)h.push(c[d].clone());for(let d=0,u=l.length;d<u;d++){let p=l[d],f,g,m=p.vertexNormals,v=p.vertexColors,y=new $0(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let x=0,w=m.length;x<w;x++)f=m[x].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let x=0,w=v.length;x<w;x++)g=v[x],y.vertexColors.push(g.clone());y.materialIndex=p.materialIndex+i,o.push(y)}for(let d=0,u=e.faceVertexUvs.length;d<u;d++){let p=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let f=0,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,x=m.length;y<x;y++)v.push(m[y].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},i=[],r=[],s=Math.pow(10,e);for(let o=0,l=this.vertices.length;o<l;o++){let h=this.vertices[o],c=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[c]===void 0?(t[c]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[c]]}let a=[];for(let o=0,l=this.faces.length;o<l;o++){let h=this.faces[o];h.a=r[h.a],h.b=r[h.b],h.c=r[h.c];let c=[h.a,h.b,h.c];for(let d=0;d<3;d++)if(c[d]===c[(d+1)%3]){a.push(o);break}}for(let o=a.length-1;o>=0;o--){let l=a[o];this.faces.splice(l,1);for(let h=0,c=this.faceVertexUvs.length;h<c;h++)this.faceVertexUvs[h].splice(l,1)}let n=this.vertices.length-i.length;return this.vertices=i,n}setFromPoints(e){this.vertices=[];for(let t=0,i=e.length;t<i;t++){let r=e[t];this.vertices.push(new M(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let o=0;o<t;o++)e[o]._id=o;function i(o,l){return o.materialIndex-l.materialIndex}e.sort(i);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],a,n;r&&r.length===t&&(a=[]),s&&s.length===t&&(n=[]);for(let o=0;o<t;o++){let l=e[o]._id;a&&a.push(r[l]),n&&n.push(s[l])}a&&(this.faceVertexUvs[0]=a),n&&(this.faceVertexUvs[1]=n)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let f in p)p[f]!==void 0&&(e[f]=p[f]);return e}let t=[];for(let p=0;p<this.vertices.length;p++){let f=this.vertices[p];t.push(f.x,f.y,f.z)}let i=[],r=[],s={},a=[],n={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],g=!0,m=!1,v=this.faceVertexUvs[0][p]!==void 0,y=f.normal.length()>0,x=f.vertexNormals.length>0,w=f.color.r!==1||f.color.g!==1||f.color.b!==1,_=f.vertexColors.length>0,b=0;if(b=h(b,0,0),b=h(b,1,g),b=h(b,2,m),b=h(b,3,v),b=h(b,4,y),b=h(b,5,x),b=h(b,6,w),b=h(b,7,_),i.push(b),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let A=this.faceVertexUvs[0][p];i.push(u(A[0]),u(A[1]),u(A[2]))}if(y&&i.push(c(f.normal)),x){let A=f.vertexNormals;i.push(c(A[0]),c(A[1]),c(A[2]))}if(w&&i.push(d(f.color)),_){let A=f.vertexColors;i.push(d(A[0]),d(A[1]),d(A[2]))}}function h(p,f,g){return g?p|1<<f:p&~(1<<f)}function c(p){let f=p.x.toString()+p.y.toString()+p.z.toString();return s[f]!==void 0||(s[f]=r.length/3,r.push(p.x,p.y,p.z)),s[f]}function d(p){let f=p.r.toString()+p.g.toString()+p.b.toString();return n[f]!==void 0||(n[f]=a.length,a.push(p.getHex())),n[f]}function u(p){let f=p.x.toString()+p.y.toString();return l[f]!==void 0||(l[f]=o.length/2,o.push(p.x,p.y)),l[f]}return e.data={},e.data.vertices=t,e.data.normals=r,a.length>0&&(e.data.colors=a),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new If().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let d=0,u=t.length;d<u;d++)this.vertices.push(t[d].clone());let i=e.colors;for(let d=0,u=i.length;d<u;d++)this.colors.push(i[d].clone());let r=e.faces;for(let d=0,u=r.length;d<u;d++)this.faces.push(r[d].clone());for(let d=0,u=e.faceVertexUvs.length;d<u;d++){let p=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let f=0,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,x=m.length;y<x;y++){let w=m[y];v.push(w.clone())}this.faceVertexUvs[d].push(v)}}let s=e.morphTargets;for(let d=0,u=s.length;d<u;d++){let p={};if(p.name=s[d].name,s[d].vertices!==void 0){p.vertices=[];for(let f=0,g=s[d].vertices.length;f<g;f++)p.vertices.push(s[d].vertices[f].clone())}if(s[d].normals!==void 0){p.normals=[];for(let f=0,g=s[d].normals.length;f<g;f++)p.normals.push(s[d].normals[f].clone())}this.morphTargets.push(p)}let a=e.morphNormals;for(let d=0,u=a.length;d<u;d++){let p={};if(a[d].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,g=a[d].vertexNormals.length;f<g;f++){let m=a[d].vertexNormals[f],v={};v.a=m.a.clone(),v.b=m.b.clone(),v.c=m.c.clone(),p.vertexNormals.push(v)}}if(a[d].faceNormals!==void 0){p.faceNormals=[];for(let f=0,g=a[d].faceNormals.length;f<g;f++)p.faceNormals.push(a[d].faceNormals[f].clone())}this.morphNormals.push(p)}let n=e.skinWeights;for(let d=0,u=n.length;d<u;d++)this.skinWeights.push(n[d].clone());let o=e.skinIndices;for(let d=0,u=o.length;d<u;d++)this.skinIndices.push(o[d].clone());let l=e.lineDistances;for(let d=0,u=l.length;d<u;d++)this.lineDistances.push(l[d]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new wq().fromGeometry(this),t=new Ge,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",Wu.call(new tt(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",Wu.call(new tt(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",cS.call(new tt(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",dS.call(new tt(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",dS.call(new tt(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],a=e.morphTargets[r];for(let n=0,o=a.length;n<o;n++){let l=a[n],h=new Ie(l.data.length*3,3);h.name=l.name,s.push(Wu.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Ie(e.skinIndices.length*4,4);t.setAttribute("skinIndex",uS.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Ie(e.skinWeights.length*4,4);t.setAttribute("skinWeight",uS.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new Ge,i=e.geometry;if(e.isPoints||e.isLine){let r=new Ie(i.vertices.length*3,3),s=new Ie(i.colors.length*3,3);if(t.setAttribute("position",Wu.call(r,i.vertices)),t.setAttribute("color",cS.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let a=new Ie(i.lineDistances.length,1);t.setAttribute("lineDistance",_q.call(a,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};If.prototype.isGeometry=!0;var wq=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,s,a=e.faces;for(r=0;r<a.length;r++){let n=a[r];n.materialIndex!==s&&(s=n.materialIndex,i!==void 0&&(i.count=r*3-i.start,t.push(i)),i={start:r*3,materialIndex:s})}i!==void 0&&(i.count=r*3-i.start,t.push(i)),this.groups=t}fromGeometry(e){let t=e.faces,i=e.vertices,r=e.faceVertexUvs,s=r[0]&&r[0].length>0,a=r[1]&&r[1].length>0,n=e.morphTargets,o=n.length,l;if(o>0){l=[];for(let m=0;m<o;m++)l[m]={name:n[m].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,c=h.length,d;if(c>0){d=[];for(let m=0;m<c;m++)d[m]={name:h[m].name,data:[]};this.morphTargets.normal=d}let u=e.skinIndices,p=e.skinWeights,f=u.length===i.length,g=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m<t.length;m++){let v=t[m];this.vertices.push(i[v.a],i[v.b],i[v.c]);let y=v.vertexNormals;if(y.length===3)this.normals.push(y[0],y[1],y[2]);else{let w=v.normal;this.normals.push(w,w,w)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let w=v.color;this.colors.push(w,w,w)}if(s===!0){let w=r[0][m];w!==void 0?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new j,new j,new j))}if(a===!0){let w=r[1][m];w!==void 0?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new j,new j,new j))}for(let w=0;w<o;w++){let _=n[w].vertices;l[w].data.push(_[v.a],_[v.b],_[v.c])}for(let w=0;w<c;w++){let _=h[w].vertexNormals[m];d[w].data.push(_.a,_.b,_.c)}f&&this.skinIndices.push(u[v.a],u[v.b],u[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},$0=class{constructor(e,t,i,r,s,a=0){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new M,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new et,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=a}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};function _q(e){return this.array.set(e),this}function cS(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),a=new et),t[i++]=a.r,t[i++]=a.g,t[i++]=a.b}return this}function dS(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),a=new j),t[i++]=a.x,t[i++]=a.y}return this}function Wu(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),a=new M),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z}return this}function uS(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),a=new ct),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z,t[i++]=a.w}return this}var Sq=["a","b","c"];function Aq(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function Rg(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),a=r+"_"+s;return i.get(a)}function Lg(e,t,i,r,s,a){let n=Math.min(e,t),o=Math.max(e,t),l=n+"_"+o,h;if(r.has(l))h=r.get(l);else{let c=i[n],d=i[o];h={a:c,b:d,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),a[e].edges.push(h),a[t].edges.push(h)}function Mq(e,t,i,r){let s,a,n;for(s=0,a=e.length;s<a;s++)i[s]={edges:[]};for(s=0,a=t.length;s<a;s++)n=t[s],Lg(n.a,n.b,e,r,n,i),Lg(n.b,n.c,e,r,n,i),Lg(n.c,n.a,e,r,n,i)}function qu(e,t,i,r,s){e.push(new $0(t,i,r,void 0,void 0,s))}function jl(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function Xu(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var Eq=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Ge?e=new If().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new M,i,r,s,a,n,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],c=h!==void 0&&h.length>0,d=[],u=new Map;Mq(o,l,d,u);let p=[],f,g,m,v,y,x,w;for(let he of Array.from(u.keys())){for(g=u.get(he),m=new M,y=3/8,x=1/8,w=g.faces.length,w!=2&&(y=.5,x=0,w!=1),m.addVectors(g.a,g.b).multiplyScalar(y),t.set(0,0,0),a=0;a<w;a++){for(v=g.faces[a],n=0;n<3&&(f=o[Aq(v,Sq[n])],!(f!==g.a&&f!==g.b));n++);f&&t.add(f)}t.multiplyScalar(x),m.add(t),g.newEdge=p.length,p.push(m)}let _,b,A,S,E,C,T,D=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],E=d[r].edges,i=E.length,i==3?_=3/16:i>3&&(_=3/(8*i)),b=1-i*Number(_),A=_,i<=2&&(i==2?(b=3/4,A=1/8):i==1||i==0),T=C.clone().multiplyScalar(b),t.set(0,0,0),a=0;a<i;a++)S=E[a],f=S.a!==C?S.a:S.b,t.add(f);t.multiplyScalar(Number(A)),T.add(t),D.push(T)}let O=D.concat(p),P=D.length,U,W,k,F=[],Z=[],X,G,q,$,Q=new j,ee=new j,H=new j;for(r=0,s=l.length;r<s;r++)v=l[r],U=Number(Rg(v.a,v.b,u).newEdge)+P,W=Number(Rg(v.b,v.c,u).newEdge)+P,k=Number(Rg(v.c,v.a,u).newEdge)+P,qu(F,U,W,k,v.materialIndex),qu(F,v.a,U,k,v.materialIndex),qu(F,v.b,W,U,v.materialIndex),qu(F,v.c,k,W,v.materialIndex),c&&(X=h[r],G=X[0],q=X[1],$=X[2],Q.set(jl(G.x,q.x),jl(G.y,q.y)),ee.set(jl(q.x,$.x),jl(q.y,$.y)),H.set(jl(G.x,$.x),jl(G.y,$.y)),Xu(Z,Q,ee,H),Xu(Z,G,Q,H),Xu(Z,q,ee,Q),Xu(Z,$,H,ee));e.vertices=O,e.faces=F,c&&(e.faceVertexUvs[0]=Z)}},Fi=new M,Cq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??(t==null?void 0:t.geometry)??new Ge().copy(new Xs(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Fi),r={width:Fi.x,height:Fi.y,depth:Fi.z,subdivisions:0}):r=t.parameters;let s={...r,...e.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:i}}static build(e){let{width:t,height:i,depth:r,subdivisions:s}=e.parameters,a=e.geometry??new Ge().copy(new Xs(100,100,100)),n=a.userData.parameters;n===void 0?(a.computeBoundingBox(),a.boundingBox.getSize(Fi)):Fi.set(n.width,n.height,n.depth),(t!==Fi.x||i!==Fi.y||r!==Fi.z)&&a.scale(Fi.x===0?1:t/Fi.x,Fi.y===0?1:i/Fi.y,Fi.z===0?1:r/Fi.z);let o=a.originalGeometry;try{s>0?(o===void 0||(n==null?void 0:n.subdivisions)!==s)&&(o===void 0&&(o=a),a=new Eq(s).modify(o).toBufferGeometry()):(o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals())}catch{o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals()}return o!==void 0&&Object.assign(a,{originalGeometry:o}),delete e.geometry,Object.assign(a,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new kM(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(Fi);let a=100/Fi.x;Object.assign(s.parameters,{width:100,height:Fi.y*a,depth:Fi.z*a}),t(this.build(s))})}},HC=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof mi?e.shape:new mi,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,c=i*.5,d=0,u=0,p=2*Math.PI/r;for(let g=0;g<r;g++){let m=p*g,v=d+Math.sin(m)*h,y=u+Math.cos(m)*c;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let g=0,m=l.points.length;g<m;g++)l.points[g].roundness=s;l.roundness=s,l.update();let f=yl.create({shape:l,parameters:{roundness:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},Tq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,heightSegments:a,openEnded:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=new Dq(t*.5,i,s,a,n,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function Mc(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function zg(e,t,i,r,s,a){let n=t.clone().sub(e),o=i.clone().sub(e),l=n.angleTo(o);if(n.normalize(),o.normalize(),r===s){let h=n.add(o).normalize();a.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=n.angleTo(o);a.copy(e),a.addScaledVector(n,s/Math.sin(h)),a.addScaledVector(o,r/Math.sin(h))}}function Pq(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var Dq=class extends Ge{constructor(e=.5,t=1,i=4,r=1,s=!1,a=0,n=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),n=Math.floor(n);let o=[],l=[],h=[],c=[],d=0,u=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),g=2*Math.PI/i,m=(i-2)*Math.PI/i,v=Math.PI-m,y=new M(0,-u,0),x=new M(0,u,0),w=new j(e,-u),_=new j(f,-u),b=new j(0,x.y).sub(_),A=new j(0,x.y).sub(w),S=new j(b.y,-b.x).normalize(),E=new j(A.y,-A.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-b.angle())/2)-1e-8;a=Math.min(a,C);let T;{let k=new M(S.x,S.y,0),F=new M(Math.cos(g)*k.x,k.y,Math.sin(g)*k.x);T=k.angleTo(F)}let D=a/Math.tan((Math.PI-b.angle())/2),O=a/Math.tan((Math.PI-T)/2),P=new M;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),c.push(0,0);let k=d++,F=[],Z=w.clone(),X=D/Math.cos(Math.PI/i);Z.x-=X;for(let G=0;G<i;G++){let q=G/i*Math.PI*2+p,$=new j(Math.sin(q),Math.cos(q));Mc(Z,$,P),l.push(P.x,P.y,P.z),h.push(0,-1,0),c.push(0,0),F.push(d++)}for(let G=0;G<F.length;G++)o.push(F[G],k,F[(G+1)%F.length])}{let k=new M,F=new M,Z=new M,X=new M,G=new M,q=new M;for(let $=0;$<i;$++){let Q=$/i*Math.PI*2+p,ee=($+.5)/i*Math.PI*2+p,H=($+1)/i*Math.PI*2+p,he=new j(Math.sin(Q),Math.cos(Q)),re=new j(Math.sin(ee),Math.cos(ee)),te=new j(Math.sin(H),Math.cos(H));Mc(w,he,F),Mc(w,te,Z),Mc(S,re,k),zg(x,F,Z,O,O,X),l.push(X.x,X.y,X.z),zg(F,x,Z,O,D,G),l.push(G.x,G.y,G.z),zg(Z,F,x,D,O,q),l.push(q.x,q.y,q.z),h.push(k.x,k.y,k.z),h.push(k.x,k.y,k.z),h.push(k.x,k.y,k.z),c.push(0,0),c.push(0,0),c.push(0,0);let ae=d++,de=d++,pe=d++;if(o.push(ae,de,pe),a>0){{let Me=F.clone().add(Z).multiplyScalar(.5),Ve=x.clone().sub(Me).normalize(),Ue=y.clone().sub(Me).normalize().add(Ve).normalize().multiplyScalar(-1),Ce=q.clone().sub(G);U(Me,Ce,Ue,b.angle())}let be,Le;{let Me=new M;Mc(E,te,Me);let Ve=q.clone().add(X).multiplyScalar(.5);Ve=Pq(Ve,Z,x);let Ue=q.clone().sub(X);[be,Le]=U(Ve,Ue,Me,T,X.y)}{let Me=be,Ve=Me.clone().setY(0).normalize(),Ue=new M(0,-1,0),Ce=Ve.clone().cross(Ue);W(Me,Ve,Ue,Ce)}{let Me=b.angle(),Ve=Math.PI-Me,Ue=x.clone();Ue.y-=a/Math.sin(Me-Math.PI/2);let Ce=new M,Ee=[];for(let qe=0;qe<n;qe++){let V=[],z=Math.PI/2-Ve*qe/n,oe=Math.cos(z),Se=Math.sin(z),R=ee;for(let Te=0;Te<=qe;Te++){let ke=Math.cos(R),Oe=Math.sin(R);k.x=oe*Oe,k.y=Se,k.z=oe*ke,Ce.copy(Ue).addScaledVector(k,a),l.push(Ce.x,Ce.y,Ce.z),h.push(k.x,k.y,k.z),c.push(0,0),V.push(d++),R+=Math.PI*2/qe/i}Ee.push(V)}Le.reverse(),Ee.push(Le);let Ye=Ee.length-1;for(let qe=0;qe<Ye;qe++){let V=Ee[qe],z=Ee[qe+1],oe=V.length-1;o.push(z[1],V[0],z[0]);for(let Se=1;Se<=oe;Se++)o.push(V[Se],V[Se-1],z[Se]),o.push(z[Se+1],V[Se],z[Se])}}}}}this.setIndex(o),this.setAttribute("position",new Ie(l,3)),this.setAttribute("normal",new Ie(h,3)),this.setAttribute("uv",new Ie(c,2));function U(k,F,Z,X,G){let q=-X/2,$=(Math.PI-X)/2,Q=F.clone().normalize().cross(Z);k.addScaledVector(Z,-a/Math.sin($));let ee=new M,H=new M,he=1,re=d,te=[];for(let ae=0;ae<=n;ae++){let de=q+ae/n*X;H.set(0,0,0),H.addScaledVector(Q,Math.sin(de)),H.addScaledVector(Z,Math.cos(de));for(let pe=0;pe<=he;pe++){let be=pe/he-.5;if(ee.copy(k),ee.addScaledVector(F,be),ee.addScaledVector(H,a),G!=null){let Le=Math.max(0,ee.y-G);ee.addScaledVector(F,-Le/F.y)}l.push(ee.x,ee.y,ee.z),h.push(H.x,H.y,H.z),c.push(0,0),pe===0&&te.push(d),d++}}for(let ae=0;ae<n;ae++)for(let de=0;de<he;de++){let pe=re+de+(he+1)*ae,be=pe+(he+1),Le=be+1,Me=pe+1;o.push(pe,be,Me),o.push(be,Le,Me)}return[k.clone().addScaledVector(F,.5),te]}function W(k,F,Z,X){let G=Math.PI/2,q=A.angle()-G,$=[],Q=new M,ee=new M;for(let he=0;he<=n;he++){let re=[],te=he/n;for(let ae=0;ae<=he;ae++){let de=((he?ae/he:0)-.5)*v,pe=Math.cos(de),be=Math.sin(de),Le=Math.atan(Math.tan(q)*pe),Me=(G+Le)*te,Ve=Math.cos(Me),Ue=Math.sin(Me);Q.set(0,0,0),Q.addScaledVector(F,Ue*pe),Q.addScaledVector(Z,Ve),Q.addScaledVector(X,Ue*be),ee.copy(k).addScaledVector(Q,a),l.push(ee.x,ee.y,ee.z),h.push(Q.x,Q.y,Q.z),c.push(0,0),re.push(d++)}$.push(re)}let H=$.length-1;for(let he=0;he<H;he++){let re=$[he],te=$[he+1],ae=re.length-1;o.push(re[0],te[1],te[0]);for(let de=1;de<=ae;de++)o.push(re[de-1],re[de],te[de]),o.push(re[de],te[de+1],te[de])}}}},U1=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign((t==null?void 0:t.ui)??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof mi?e.shape:new mi,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:s,cornerType:a,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},c={x:-h.x,y:-h.y},d={x:h.x,y:h.y};function u(w,_,b){return _>i&&b>r?Math.min(w*i/_,w*r/b):_>i?w*i/_:b>r?w*r/b:w}let p=[];p[0]=s[0]===0?0:u(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:u(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:u(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:u(s[3],s[3]+s[0],s[3]+s[2]);let f=c.x,g=d.x,m=d.y,v=c.y;t.addPoint(t.createPoint(f,m)),t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let w=0,_=t.points.length;w<_;w++)t.points[w].roundness=p[w],w>0&&p[w]!==p[w-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=a!==1,t.update();let x=yl.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},Iq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},e.parameters);return i.thetaLength=Re.clamp(i.thetaLength,0,180),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:s=64,heightSegments:a=64,phiStart:n,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,c;return h===0?(c=new Ge,c.setAttribute("position",new Ie([],3))):c=new gh(.5*t,s,a,n,o,l,h*Re.DEG2RAD),c.scale(1,i/t,r/t),Object.assign(c,{userData:{...e,type:"SphereGeometry"}})}},Oq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:s=8}=e.parameters,a=new Ea(t,i,r,s);return a.scale(1,1,1),Object.assign(a,{userData:{...e,type:"PlaneGeometry"}})}},Rq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:s,cornerRadius:a,cornerSegments:n}=e.parameters,o=new Lq(t,i,r,s,a,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},Lq=class extends Ge{constructor(e=1,t=1,i=1,r=90,s=10,a=24){super(),this.type="BackdropGeometry";let n=[],o=[],l=[],h=.001;s==0&&(a=1),a=Math.max(1,Math.floor(a)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let c=[],d=Math.PI/2,u=(he=0,re=0,te=0)=>new M(he,re,te),p=u(),f=u(),[g,m,v]=[t/2,e/2,i/2],y=-m,x=+m,[w,_,b]=[u(y,-g,+v),u(y,-g,-v),u(y,+g,-v)],A=(he,re=!1)=>Math.sin(he-Math.PI/(1+ +re)),S=(he,re=!1)=>Math.cos(he-Math.PI/(1+ +re));b.y=Math.sin(r)*t-g;let E=Math.cos(r)*t-v,C=w.z-h;r<=d?(b.z=Math.min(E,C),b.z==C&&(b.y-=(E-C)/Math.tan(d-r))):_.z=Math.min(_.z-E-v,w.z-h),p.subVectors(w,_),f.subVectors(b,_);let T=Math.min(p.length(),f.length())*s/100,D=T*Math.tan(r/2),O=T/Math.cos(r/2),P=p.clone().normalize().add(f.normalize()).setLength(O).add(_);p.set(0,A(r,!0),S(r,!0)),c.push([b,p.clone()]);let U=(Math.PI-r)/a;for(let he=0;he<=a;he++){let re=d+r+he*U;p.set(0,Math.sin(re)*D,Math.cos(re)*D),p.add(P),f.set(0,A(re),S(re)),c.push([p.clone(),f.clone()])}c.push([w,u(0,1,0)]);let W=Math.sin(U/2)*D*2,k=c.length-1,F=c[0][0].distanceTo(c[1][0]),Z=c[k-1][0].distanceTo(c[k][0]),X=F+W*a+Z;c[0].push(1);for(let he=0;he<=a;he++)c[he+1].push(1-(F+he*W)/X);c[k].push(0);let[G,q,$]=c[0],Q,ee,H;for(let he=1;he<c.length;he++)[Q,ee,H]=c[he],n.push(y,G.y,G.z,y,Q.y,Q.z,x,G.y,G.z,x,G.y,G.z,y,Q.y,Q.z,x,Q.y,Q.z),o.push(0,q.y,q.z,0,ee.y,ee.z,0,q.y,q.z,0,q.y,q.z,0,ee.y,ee.z,0,ee.y,ee.z),l.push(0,$,0,H,1,$,1,$,0,H,1,H),[G,q,$]=[Q,ee,H];this.setAttribute("position",new Ie(n,3)),this.setAttribute("normal",new Ie(o,3)),this.setAttribute("uv",new Ie(l,2))}},WC=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof mi?e.shape:new mi,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:a,angle:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,c=e.shape,d=t*.5,u=i*.5,p=0,f=0,g=n*Math.PI/360/s,m=Math.PI/2*3*-1,v=d*r/100,y=u*r/100;if(s===3&&r===50){g=2*Math.PI/s;for(let w=0;w<s;w++){let _=g*w,b=p+Math.sin(_)*d,A=f+Math.cos(_)*u;c.addPoint(c.createPoint(b,A))}}else for(let w=0;w<s;w++){let _=p+Math.cos(m)*d,b=f+Math.sin(m)*u;c.addPoint(c.createPoint(_,b)),m+=g,_=p+Math.cos(m)*v,b=f+Math.sin(m)*y,c.addPoint(c.createPoint(_,b)),m+=g}c.isClosed=!0;for(let w=0,_=c.points.length;w<_;w++)c.points[w].roundness=a;c.roundness=a,c.update();let x=yl.create({shape:c,parameters:{roundness:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},zq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new Ea(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},Bq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width);i.shapeBlendNode&&(s=r);let a=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:a})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:a,arc:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=Fq(t,i,r,t*.5,n,a,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function Fq(e,t,i,r,s,a,n,o,l,h,c){[t,i]=[i,t],n=t/2;let d=Re.clamp(s/360,0,1);if(d===0){let u=new Ge;return u.setAttribute("position",new Ie([],3)),u}return d===1&&(h=0),new jC(!0,e,t,i,r,d,a,n,o,l,h,c)}var Uq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??i.width*.125})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:s,p:a,q:n}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new RM(o,i,r,s,a,n);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},Nq=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof mi?e.shape:new mi,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n,isRect:o}=e.parameters,l=e.shape,h=t*.5,c=i*.5;o?(l.addPoint(l.createPoint(-h,c)),l.addPoint(l.createPoint(h,-c)),l.addPoint(l.createPoint(-h,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(h,-c)),l.addPoint(l.createPoint(-h,-c))),l.isClosed=!0;for(let u=0,p=l.points.length;u<p;u++)l.points[u].roundness=r;l.roundness=r,l.update();let d=yl.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n}});return Object.assign(d,{userData:{...e,type:"TriangleGeometry"}})}};function kq(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}function Vq(e){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(e.toLowerCase())}function jq(e,t,i){let r,s,a,n=Math.floor(e*6),o=e*6-n,l=i*(1-t),h=i*(1-o*t),c=i*(1-(1-o)*t);switch(n%6){case 0:r=i,s=c,a=l;break;case 1:r=h,s=i,a=l;break;case 2:r=l,s=i,a=c;break;case 3:r=l,s=h,a=i;break;case 4:r=c,s=l,a=i;break;case 5:default:r=i,s=l,a=h;break}return{r:r*255,g:s*255,b:a*255}}function Gq(e,t,i){e/=255,t/=255,i/=255;let r=Math.max(e,t,i),s=Math.min(e,t,i),a=r,n=r-s,o=r==0?0:n/r,l;if(r==s)l=0;else{switch(r){case e:l=(t-i)/n+(t<i?6:0);break;case t:l=(i-e)/n+2;break;case i:default:l=(e-t)/n+4;break}l/=6}return{h:l,s:o,v:a}}function Hq(e){return e=Math.floor(e),{r:e>>16&255,g:e>>8&255,b:e&255}}function Wq(e,t,i){return(e<<16)+(t<<8)+i}function qq(e,t,i){return e=Math.round(e),t=Math.round(t),i=Math.round(i),"#"+[e,t,i].map(r=>r.toString(16).padStart(2,"0")).join("").toUpperCase()}function Xq(e){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(t,(r,s,a,n)=>String(s+s+a+a+n+n));let i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return i?{r:parseInt(i[1],16),g:parseInt(i[2],16),b:parseInt(i[3],16)}:null}var Yq={parseRgba:Vq,hsvToRgb:jq,rgbToHsv:Gq,hexToRgb:Hq,rgbToHex:Wq,rgbToHexString:qq,hexStringToRgb:Xq},Qq=class{add(e,t,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(r){this[r]=this[r]||[],t&&this[r][i?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(i){i.call(t&&t.context?t.context:t,t)})}},Zq=class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(t=>{if(typeof t!="object"||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)})}},fe=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+fe.version}static addUnaryOp(e){return fe.max_unop_len=Math.max(e.length,fe.max_unop_len),fe.unary_ops[e]=1,fe}static addBinaryOp(e,t,i){return fe.max_binop_len=Math.max(e.length,fe.max_binop_len),fe.binary_ops[e]=t,i?fe.right_associative.add(e):fe.right_associative.delete(e),fe}static addIdentifierChar(e){return fe.additional_identifier_chars.add(e),fe}static addLiteral(e,t){return fe.literals[e]=t,fe}static removeUnaryOp(e){return delete fe.unary_ops[e],e.length===fe.max_unop_len&&(fe.max_unop_len=fe.getMaxKeyLen(fe.unary_ops)),fe}static removeAllUnaryOps(){return fe.unary_ops={},fe.max_unop_len=0,fe}static removeIdentifierChar(e){return fe.additional_identifier_chars.delete(e),fe}static removeBinaryOp(e){return delete fe.binary_ops[e],e.length===fe.max_binop_len&&(fe.max_binop_len=fe.getMaxKeyLen(fe.binary_ops)),fe.right_associative.delete(e),fe}static removeAllBinaryOps(){return fe.binary_ops={},fe.max_binop_len=0,fe}static removeLiteral(e){return delete fe.literals[e],fe}static removeAllLiterals(){return fe.literals={},fe}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new fe(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return fe.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!fe.binary_ops[String.fromCharCode(e)]||fe.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return fe.isIdentifierStart(e)||fe.isDecimalDigit(e)}throwError(e){let t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(fe.hooks[e]){let i={context:this,node:t};return fe.hooks.run(e,i),i.node}return t}searchHook(e){if(fe.hooks[e]){let t={context:this};return fe.hooks[e].find(function(i){return i.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===fe.SPACE_CODE||e===fe.TAB_CODE||e===fe.LF_CODE||e===fe.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:fe.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],i,r;for(;this.index<this.expr.length;)if(i=this.code,i===fe.SEMCOL_CODE||i===fe.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(i===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,fe.max_binop_len),t=e.length;for(;t>0;){if(fe.binary_ops.hasOwnProperty(e)&&(!fe.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!fe.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,i,r,s,a,n,o,l;if(a=this.gobbleToken(),!a||(t=this.gobbleBinaryOp(),!t))return a;for(s={value:t,prec:fe.binaryPrecedence(t),right_a:fe.right_associative.has(t)},n=this.gobbleToken(),n||this.throwError("Expected expression after "+t),r=[a,s,n];t=this.gobbleBinaryOp();){if(i=fe.binaryPrecedence(t),i===0){this.index-=t.length;break}s={value:t,prec:i,right_a:fe.right_associative.has(t)},l=t;let h=c=>s.right_a&&c.right_a?i>c.prec:i<=c.prec;for(;r.length>2&&h(r[r.length-2]);)n=r.pop(),t=r.pop().value,a=r.pop(),e={type:fe.BINARY_EXP,operator:t,left:a,right:n},r.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),r.push(s,e)}for(o=r.length-1,e=r[o];o>1;)e={type:fe.BINARY_EXP,operator:r[o-1].value,left:r[o-2],right:e},o-=2;return e}gobbleToken(){let e,t,i,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(e=this.code,fe.isDecimalDigit(e)||e===fe.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===fe.SQUOTE_CODE||e===fe.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===fe.OBRACK_CODE)r=this.gobbleArray();else{for(t=this.expr.substr(this.index,fe.max_unop_len),i=t.length;i>0;){if(fe.unary_ops.hasOwnProperty(t)&&(!fe.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!fe.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=i;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:fe.UNARY_EXP,operator:t,argument:s,prefix:!0})}t=t.substr(0,--i)}fe.isIdentifierStart(e)?(r=this.gobbleIdentifier(),fe.literals.hasOwnProperty(r.name)?r={type:fe.LITERAL,value:fe.literals[r.name],raw:r.name}:r.name===fe.this_str&&(r={type:fe.THIS_EXP})):e===fe.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===fe.PERIOD_CODE||t===fe.OBRACK_CODE||t===fe.OPAREN_CODE||t===fe.QUMARK_CODE;){let i;if(t===fe.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==fe.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===fe.OBRACK_CODE?(e={type:fe.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},this.gobbleSpaces(),t=this.code,t!==fe.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===fe.OPAREN_CODE?e={type:fe.CALL_EXP,arguments:this.gobbleArguments(fe.CPAREN_CODE),callee:e}:(t===fe.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),e={type:fe.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),i&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,i;for(;fe.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===fe.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);fe.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(e+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(e+=this.expr.charAt(this.index++));fe.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);fe.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return i=this.code,fe.isIdentifierStart(i)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(i===fe.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===fe.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:fe.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,i=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===i){r=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":e+=`
  3065. `;break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=s}else e+=s}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:fe.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(fe.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,fe.isIdentifierPart(e));)this.index++;return{type:fe.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],i=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===e){i=!0,this.index++,e===fe.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}else if(s===fe.COMMA_CODE){if(this.index++,r++,r!==t.length){if(e===fe.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===fe.CBRACK_CODE)for(let a=t.length;a<r;a++)t.push(null)}}else if(t.length!==r&&r!==0)this.throwError("Expected comma");else{let a=this.gobbleExpression();(!a||a.type===fe.COMPOUND)&&this.throwError("Expected comma"),t.push(a)}}return i||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(fe.CPAREN_CODE);if(this.code===fe.CPAREN_CODE)return this.index++,e.length===1?e[0]:e.length?{type:fe.SEQUENCE_EXP,expressions:e}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:fe.ARRAY_EXP,elements:this.gobbleArguments(fe.CBRACK_CODE)}}},Kq=new Qq;Object.assign(fe,{hooks:Kq,plugins:new Zq(fe),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});fe.max_unop_len=fe.getMaxKeyLen(fe.unary_ops);fe.max_binop_len=fe.getMaxKeyLen(fe.binary_ops);var kh=e=>new fe(e).parse(),Jq=Object.getOwnPropertyNames(fe);Jq.forEach(e=>{kh[e]===void 0&&e!=="prototype"&&(kh[e]=fe[e])});kh.Jsep=fe;var $q="ConditionalExpression",eX={name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let i=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),t.node={type:$q,test:i,consequent:r,alternate:s},i.operator&&e.binary_ops[i.operator]<=.9){let a=i;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;t.node.test=a.right,a.right=t.node,t.node=i}}else this.throwError("Expected :")}})}};kh.plugins.register(eX);function dm(e){return{all:e=e||new Map,on:function(t,i){var r=e.get(t);r?r.push(i):e.set(t,[i])},off:function(t,i){var r=e.get(t);r&&(i?r.splice(r.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var r=e.get(t);r&&r.slice().map(function(s){s(i)}),(r=e.get("*"))&&r.slice().map(function(s){s(t,i)})}}}var qC=class{constructor(e,t,i){var r;this.id=e,this.userAPI=t,this.result=void 0,this.error="null",this.isPrefetched=!1,this.isLoading=!1,this.isLoaded=!1,this.prefetchPromise=new Promise(s=>s()),this.emitter=dm(),this._innerCallUserAPI=async s=>{var a,n,o;this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await aX(this.userAPI,s),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(l){let h=((o=(n=(a=l.message)==null?void 0:a.split("_:_"))==null?void 0:n[0])==null?void 0:o.replace("status:",""))??"null";this.error=h,this.result=null,this.emitter.emit("error",{userAPIId:this.id})}this.isLoading=!1,this.isPrefetched=!0,this.isLoaded=!0},((r=t==null?void 0:t.integration)==null?void 0:r.type)==="OpenAI"?this.result={content:""}:t.method==="GET"&&t.url!==""&&(this.prefetchPromise=this.prefetch(i)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=xd(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?xd(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(e){await this.callUserAPI(e)}async callUserAPI(e){await this._debouncedCallUserAPI(e)}update(e,t,i=!0){this.userAPI=e,this._updateDebouncedCallUserAPI(),this.userAPI.url!==""&&this.userAPI.method==="GET"&&i&&this._debouncedPrefetch(t)}retrieveValue(e){if(this.result)try{return Gi.zoom(this.result,e)}catch(t){console.error(t)}}retrieveZoomedKeyValues(e){if(this.result){let t=e&&e.length?Gi.zoom(this.result,e):this.result;if(sX(t))return Object.entries(t);if(rX(t))return t.map((i,r)=>[r.toString(),i]);throw iX(t)?new Error("This path points to a value, use retrieveValue() instead. "+(e==null?void 0:e.join("."))):new Error("Path error"+(e==null?void 0:e.join(".")))}}dispose(){}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}get autostart(){return this.userAPI.autoStart}};function tX(e){let t=new Headers;return e.headers.forEach(i=>{i.data.key!==""&&t.append(i.data.key,i.data.value)}),t}function iX(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function rX(e){return Array.isArray(e)}function sX(e){return typeof e=="object"&&e!==null}async function aX(e,t,i=new AbortController){var l,h,c,d;let r,s=e.url,a=((l=e.proxy)==null?void 0:l.enabled)??!1,n;if(((h=e.integration)==null?void 0:h.type)==="OpenAI"){let u=jc(e.integration.prompt===""?[]:JSON.parse(e.integration.prompt),t),p=e.integration.behavior===""?[]:jc(JSON.parse(e.integration.behavior),t);n=`{
  3066. "model": "${e.integration.model}",
  3067. "messages": [${e.integration.useBehavior?`
  3068. {
  3069. "role": "system",
  3070. "content": "${p}"
  3071. },`:""}
  3072. {
  3073. "role": "user",
  3074. "content": "${u}"
  3075. }
  3076. ]
  3077. }`}if(a){s=`https://apis.spline.design/file/${e.proxy.fileId}/external-api/request?uuidexternalapi=${e.proxy.proxyId}`;let u;n!==void 0?u=n:e.method==="POST"&&e.body&&(u=jc(JSON.parse(e.body),t)),u!==void 0&&(s+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else((c=e.integration)==null?void 0:c.type)==="OpenAI"?r=n:e.method==="POST"&&e.body&&(r=jc(JSON.parse(e.body),t));let o=await fetch(s,{method:a?"GET":e.method,headers:a?void 0:tX(e),signal:i.signal,body:r});if(!o.ok)throw new Error("status:"+o.status+"_:_"+o.statusText);if(((d=e.integration)==null?void 0:d.type)==="OpenAI"){let u=await o.json();return a&&(u=u.response),{content:u.choices[0].message.content}}else{let u=await o.json();return a&&(u=u.response),u}}var XC=(e,t)=>{if(typeof e=="string"){let i=t.getVariable(e);if(i)return XC(i,t)}return mr.isBoolean(e)?mr.getDisplayedValue(e).toLowerCase():mr.getDisplayedValue(e)},jc=(e,t)=>e.map((i,r)=>{if("text"in i)return i.text;if("type"in i){if(i.type==="paragraph")return(r>0?`
  3078. `:"")+jc(i.children,t);if(i.type==="variable"){let s=t.getVariable(i.variableId);if(s!==void 0)return XC(s,t)}}return""}).join(""),nX=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],oX=["0","1","2","3","4","5","6","7","8","9","."],lX=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function hX(e){return typeof e!="string"?!1:!isNaN(e)&&!isNaN(parseFloat(e))}kh.addBinaryOp("^",11,!0);function YC(e,t,i="number"){let r="";for(let n=0;n<e.length;n++){let o=e[n];if("objType"in o&&o.objType==="api"){let l=JSON.parse(o.id),h=l[0],c=t.getUserAPI(h);if(c!==void 0&&c instanceof qC){let d=c.retrieveValue(l.slice(1));d!==void 0&&(r+=d)}continue}if("objType"in o&&o.objType==="webhook"){let l=JSON.parse(o.id),[h,c]=l,d=t.getUserWebhook(h);if(d!==void 0){let u=d.getParameterValue(c);u!==void 0&&(r+=u)}continue}if("objType"in o&&o.objType==="aiAssistant"){let l=t.openAIRealtime;if("objId"in o&&o.objId!==void 0){let h;if(t.scene.data.objects.traverse((c,d)=>{var p;let u=(p=d.events)==null?void 0:p.find(f=>f.id===o.objId);u&&(h=u)}),h!==void 0&&h.data.type==="AIAssistantListener"){let c=l==null?void 0:l.computeAnalysisForListenerEvent(h.data);if(c!==void 0){r+=c;continue}}}r+=(l==null?void 0:l.voice)??0;continue}if("id"in o){let l=e[n-1];if(n>0&&"id"in l){console.error("Two variables in a row",e);return}let h=t.getVariable(o.id),c=mr.getDisplayedValue(h);i==="number"&&mr.isTextValue(h)&&Array.isArray(h.textValue)&&h.textValue.length===1?c=parseFloat(c).toString():i==="boolean"&&mr.isBoolean(h)?c=h?"true":"false":i==="boolean"&&mr.isTextValue(h)&&!Array.isArray(h.textValue)&&(c='"'+c+'"'),r+=c;continue}else if(i==="string"){o.name!=='"'&&(o.name!=="+"||o.escaped)&&(r+=o.name),o.name==="+"&&!o.escaped&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+o.name);continue}if(o.name==="and"){r+="&&";continue}if(o.name==="or"){r+="||";continue}if(o.name==="True"){r+="true";continue}if(o.name==="False"){r+="false";continue}if(i==="boolean"&&!hX(o.name)&&!oX.includes(o.name)&&!nX.includes(o.name)&&!lX.includes(o.name.replace(/\($/g,""))){r+='"'+o.name+'"';continue}r+=o.name}if(i==="string")return r;if(e.length===0){if(i==="number")return 0;if(i==="boolean")return!1}let s;try{s=kh(r)}catch(n){console.error(r,n);return}let a;try{a=Rt(s)}catch(n){console.error(r,s,n)}return a}function Rt(e){switch(e.type){case"BinaryExpression":switch(e.operator){case"==":return+(Rt(e.left)===Rt(e.right));case"!=":return+(Rt(e.left)!==Rt(e.right));case">":return+(Rt(e.left)>Rt(e.right));case">=":return+(Rt(e.left)>=Rt(e.right));case"<":return+(Rt(e.left)<Rt(e.right));case"<=":return+(Rt(e.left)<=Rt(e.right));case"+":return Rt(e.left)+Rt(e.right);case"-":return Rt(e.left)-Rt(e.right);case"*":return Rt(e.left)*Rt(e.right);case"/":return Rt(e.left)/Rt(e.right);case"%":return Rt(e.left)%Rt(e.right);case"&&":return Rt(e.left)&&Rt(e.right);case"||":return Rt(e.left)||Rt(e.right);case"^":return Math.pow(Rt(e.left),Rt(e.right));default:throw new Error("Unknown operator: "+e.operator)}case"UnaryExpression":switch(e.operator){case"-":return-Rt(e.argument);case"!":return+!Rt(e.argument);default:throw new Error("Unknown operator: "+e.operator)}case"Identifier":throw new Error("Unknown identifier: "+e.name);case"Literal":return e.value;case"CallExpression":if(e.callee.type==="Identifier"){if(e.callee.name==="random"){let t=0,i=1;if(e.arguments.length>=1)try{t=Rt(e.arguments[0])}catch(r){console.warn(r)}if(e.arguments.length>=2)try{i=Rt(e.arguments[1])}catch(r){console.warn(r)}return t=Math.min(i,t),i=Math.max(i,t),t+Math.random()*(i-t)}return Math[e.callee.name].apply(null,e.arguments.map(Rt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+e.type)}}var cX=new we,dX=new we;function uX(e,t,i){let r=[new M,new M,new M],s=[new M,new M,new M];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(s[0],s[1],s[2]),r.forEach((a,n)=>{let o=s[n],l=Re.lerp(a.length(),o.length(),i);a.lerp(o,i).setLength(l)}),new we().makeBasis(r[0],r[1],r[2])}var pX=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},(t==null?void 0:t.parameters)??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.abs(i.depth??0),n=(t==null?void 0:t.shapeData)??F1.create({parameters:gC}).userData.shape;return{path:e.path??gf.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:a,extrusion:{...vC,...i.extrusion}}),shapeData:n}}static build(e){if(e.path.points.length>=2){let t=new fX(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new Ge,{userData:{...e,type:"PathGeometry"}})}},fX=class extends Ge{constructor(e){super(),this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!kq(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:i,offset:r}=this.inputs.parameters.extrusion;i=Math.max(0,Math.min(i,1)),r=Math.max(0,Math.min(r,1));let s=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(r*s),n=this.inputs.path.isClosed?Math.ceil((i+r)*s):Math.ceil(Math.min(1,i+r)*s),o=Math.min(Math.max(2,n-a+1),s+2),l=[],h=[];for(let k=0;k<o;k++){let F=this.inputs.path.isClosed?(k+a)%e.length:Math.min(k+a,e.length-1);l.push(e[F].clone()),h.push(t[F].clone())}let c=(k,F,Z)=>{l[k]=l[k].clone().lerp(l[F],Z),h[k]=uX(h[k],h[F],Z)},d=0,u=r*s%1;(!this.inputs.path.isClosed||i<=1)&&(u||r===0)&&(d=u,c(0,1,d));let p=0,f=(r+i)*s%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&f&&(p=f,c(l.length-1,l.length-2,1-p)),i===0){let k=l.length-1;l[k].copy(l[0]),h[k].copy(h[0])}this._applyPathModifiers(h,d,p);let{bevel:g,bevelSides:m}=this.inputs.parameters.extrusion,v=g>0?this.inputs.parameters.extrusion.capType:"flat",y=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(y=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:x,infos:w,vertices:_}=this._computeShapePoints(y),b=0,A;v==="round"&&(A=new B1(this.inputs.shapeData,2*g,g,y,m,void 0,!0),b=A.getAttribute("position").count);let S=0,E=0;w.sort((k,F)=>k.start-F.start),w.forEach(k=>{k.verticesStart=S,k.verticesCount=k.continuous.reduce((F,Z,X)=>F+(X===0||!Z?2:1),0),E+=k.verticesCount,S=E});let C=E*o,T,D=0;if(this._isOpenEnded()&&v==="flat"){try{T=eo({windingRule:Gt.ODD,elementType:Pi.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:x})}catch{T=zC}D=T.vertexCount}let O=C+2*D+b*2,P=C+2*D,U={positions:new Float32Array(O*3),normals:new Float32Array(O*3),uvs:new Float32Array(O*2)},W=[];if(w.forEach(k=>{this._extrudeRegion(k,_,h,l,U,W,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(this._closeEnd(T,C,W,U,h[0],l[0],!1),this._closeEnd(T,C+D,W,U,h[h.length-1],l[l.length-1],!0)),A){U.positions.set(A.getAttribute("position").array,P*3),U.normals.set(A.getAttribute("normal").array,P*3),U.uvs.set(A.getAttribute("uv").array,P*2);for(let X=P;X<P+b;X++)U.uvs[X*2+1]=1e-4;let k=W.length;W.push(...A.getIndex().array.map(X=>X+P)),P+=b,U.positions.set(A.getAttribute("position").array,P*3),U.normals.set(A.getAttribute("normal").array,P*3),U.uvs.set(A.getAttribute("uv").array,P*2);let F=W.length;W.push(...A.getIndex().array.map(X=>X+P)),this.setAttribute("position",new tt(U.positions,3)),this.setAttribute("normal",new tt(U.normals,3)),this.setAttribute("uv",new tt(U.uvs,2)),this.setIndex(W);let Z=cX;Z.copy(h[h.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(Z,P,O),Z.copy(h[0]).setPosition(l[0]).multiply(dX.makeScale(1,1,-1)),this.applyMatrix4OnRange(Z,P-b,P),this.reverseIndicesOnRange(k,F)}else this.setAttribute("position",new tt(U.positions,3)),this.setAttribute("normal",new tt(U.normals,3)),this.setAttribute("uv",new tt(U.uvs,2)),this.setIndex(W)}_extractPathPoints(){let e=EC(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(e.length<2)return[];let t=[e[0]];return e.forEach(i=>{t[t.length-1].distanceToSquared(i)>.001&&t.push(i)}),this.inputs.path.isClosed&&t[t.length-1].distanceTo(t[0])<.001&&t.pop(),t}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,s=new M,a=new M,n=new M,o=new M,l=new M(0,1,0);for(let f=0;f<i;f++){let g=e[f],m;f===0?m=r?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):m=e[f-1];let v;f===i-1?v=r?e[1]:g.clone().multiplyScalar(2).sub(e[f-1]):v=e[f+1];let y=g.clone().sub(m).normalize(),x=v.clone().sub(g).normalize(),w=y.clone().add(x).normalize();n.copy(w),f===0&&(w.equals(l)||w.clone().negate().equals(l))&&l.set(0,0,1);let _=l.clone().cross(w).normalize(),b=w.clone().cross(_).normalize();l.copy(b),o.copy(_),f===0&&(s.copy(b),a.copy(w));let A=new we().makeBasis(_,b,w);t.push(A)}let h=r?a:n,c=r?s:new M(0,1,0),d=h.clone().cross(o).normalize(),u=Math.acos(c.dot(d));if(isNaN(u))return t;let p=c.clone().cross(d);h.dot(p)>0&&(u*=-1);for(let f=1;f<t.length;f++){let g=new we().makeRotationZ(u*f/t.length);t[f].multiply(g)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:a,startScale:n,endScale:o}=this.inputs.parameters.extrusion,l=new we,h=new we;return e.forEach((c,d)=>{let u=d===0?0:d===r-1?1:(d-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(Re.lerp(s,s+a,u)*Re.DEG2RAD);let p=Re.lerp(n,o,u);h.makeScale(p,p,p),c.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=Gt.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(h=>{let c=h.extractShapePointsToFlatArray([],e),d=[];for(let u=c.length-1;u>=1;u-=2){let p=c[u-1],f=c[u-0];d.push(p,f)}return d}),a;try{a=eo({windingRule:t,elementType:Pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{a=z1}let n;try{n=eo({windingRule:Gt.ODD,elementType:Pi.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{n=LC}if(!a)throw new Error("error generating geometry");let o=a.elementCount;if(n){a.elementCount+=n.elementCount;for(let h=0;h<n.elements.length;h++){let c=n.elements[h],d=h%2===0?a.vertexCount:0;a.elements.push(c+d)}for(let h=0;h<n.vertexIndices.length;h++){let c=n.vertexIndices[h],d=a.vertexCount;a.vertexIndices.push(c+d)}for(let h=0;h<n.vertices.length;h++){let c=n.vertices[h];a.vertices.push(c)}}for(let h=0,c=a.vertexCount;h<c;h++){let d=h*2;a.vertices[d+0],a.vertices[d+1]}let l=[];for(let h=a.elementCount-1;h>=0;h--){let c=h>=o,d=h*2,u=a.elements[d+0],p=a.elements[d+1],f=u+p,g={start:u,count:p,normals:[],isHole:c,continuous:[],verticesStart:0,verticesCount:0};l.push(g);let m=u,v=f-1,y=u+1,x=i.roundedCurves.length;do{let w=m-u;a.vertices[v*2+0],a.vertices[v*2+1];let _=a.vertices[m*2+0],b=a.vertices[m*2+1],A=a.vertices[y*2+0],S=a.vertices[y*2+1],E=_-A,C=b-S,T=Math.sqrt(E*E+C*C);E/=T,C/=T,g.normals[w*2+0]=-C,g.normals[w*2+1]=E;let D=a.vertexIndices[m];if(Array.isArray(D))g.continuous[w]=!1;else{let[O,P]=i.getCurveIndexFromVertexId(D-1,!0);if(P>0&&P<1)g.continuous[w]=!0;else{let U=P===1?O+1:O-1;U=(U+x)%x;let W=P===1?0:1,k=i.roundedCurves[O].getTangent(P),F=i.roundedCurves[U].getTangent(W);g.continuous[w]=k.dot(F)>.95}}c&&(g.normals[w*2+0]*=-1,g.normals[w*2+1]*=-1),[v,m,y]=[m,y,y+1],y>=f&&(y-=p)}while(y!==u+1)}return{regions:[r,...s],infos:l,vertices:a.vertices}}_insertVertex(e,t,i,r,s){let a=t*2,n=t*3;e.positions[n+0]=i.x,e.positions[n+1]=i.y,e.positions[n+2]=i.z,e.normals[n+0]=r.x,e.normals[n+1]=r.y,e.normals[n+2]=r.z,e.uvs[a+0]=s.x,e.uvs[a+1]=s.y}_extrudeRegion(e,t,i,r,s,a,n){let o=new M,l=new M,h=new M,c=new M,d=new j;i.forEach((p,f)=>{let g=r[f],m=e.verticesStart*i.length+e.verticesCount*f;for(let v=0;v<e.count;v++){let y=(e.start+v)*2;if(o.set(t[y+0],t[y+1],0),h.copy(o).applyMatrix4(p).add(g),e.continuous[v])c.set(e.normals[v*2+0],e.normals[v*2+1],0);else{let x=v===0?(e.start+e.count-1)*2:y-2;l.set(t[x+0],t[x+1],0),c.copy(o).sub(l),c.set(-c.y,c.x,0),e.isHole||c.negate()}if(c.applyMatrix4(p).normalize(),d.set(v===0?1:v/e.count,f/(i.length-1)),this._insertVertex(s,m,h,c,d),m++,!e.continuous[v]||v===0){if(v===0)c.set(e.normals[v*2+0],e.normals[v*2+1],0),d.set(0,f/(i.length-1));else{let x=v===e.count-1?e.start*2:y+2;l.set(t[x+0],t[x+1],0),c.copy(l).sub(o),c.set(-c.y,c.x,0),e.isHole||c.negate()}c.applyMatrix4(p).normalize(),this._insertVertex(s,m,h,c,d),m++}}});let u=i.length-1;for(let p=0;p<u;p++){let f=e.verticesStart*i.length+e.verticesCount*p,g=e.verticesStart*i.length+e.verticesCount*(p+1),m=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&m++;let y=v===e.count-1?0:m+1,x=f+m,w=f+y,_=g+y,b=g+m;e.isHole?a.push(x,_,w,x,b,_):a.push(x,w,_,x,_,b),m++}}}_closeEnd(e,t,i,r,s,a,n){let o=e.vertexCount,l=new M(0,0,n?-1:1).applyMatrix4(s),h=new M,c=new j;for(let u=0;u<o;u++){let p=2*u;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(s).add(a),this._insertVertex(r,t+u,h,l,c)}let d=e.elements;for(let u=0;u<e.elementCount;u++){let p=3*u,f=d[p+0]+t,g=d[p+(n?1:2)]+t,m=d[p+(n?2:1)]+t;i.push(f,g,m)}}applyMatrix4OnRange(e,t,i){let r=e.elements,s=new Di().getNormalMatrix(e).elements,a,n,o,l,h=this.attributes.position,c=this.attributes.normal;if(!h||!c)return;let d=h.array,u=c.array,p=h.itemSize;for(let f=t*p,g=i*p;f<g;f+=p){if(f===t)debugger;a=d[f+0],n=d[f+1],o=d[f+2],l=1/(r[3]*a+r[7]*n+r[11]*o+r[15]),d[f+0]=(r[0]*a+r[4]*n+r[8]*o+r[12])*l,d[f+1]=(r[1]*a+r[5]*n+r[9]*o+r[13])*l,d[f+2]=(r[2]*a+r[6]*n+r[10]*o+r[14])*l,a=u[f+0],n=u[f+1],o=u[f+2],u[f+0]=s[0]*a+s[3]*n+s[6]*o,u[f+1]=s[1]*a+s[4]*n+s[7]*o,u[f+2]=s[2]*a+s[5]*n+s[8]*o}h.needsUpdate=!0,c.needsUpdate=!0}reverseIndicesOnRange(e,t){let i=this.index;if(i){for(let r=e;r<t;r+=3){let s=i.getX(r),a=i.getX(r+1),n=i.getX(r+2);i.setXYZ(r,n,a,s)}i.needsUpdate=!0}}};function QC(){let e=new Ge;return e.setAttribute("position",new tt(new Float32Array([]),3)),e.setIndex(new tt(new Uint16Array([]),1)),e}var mX=QC().attributes,gX=12,vX=1,ey=class extends Ge{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,mX),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i!=null&&i.isLoaded?(this.font=i,this.update(e,t)):this.updateFont(e.font,t).then(()=>{this.update(e,t),t==null||t.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e,t){let i=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!(i!=null&&i.isLoaded)){console.warn("Cannot update text because its font is not loaded");return}let{width:r,height:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o,text:l,textTransform:h}=e,c=mr.getDisplayedValue(l),d=h===2?c.toUpperCase():h===3?c.toLowerCase():c,u=yX(e,i,d,t),{shapes:p,charWidths:f,charCoords:g}=i.generateShapes(u,e,t),m=(typeof r=="number"?r:Number(t.getVariable(r)))*.5,v=(typeof s=="number"?s:Number(t.getVariable(s)))*.5,y=p.map(_=>new mi().fromShape(_,!0));this.vectorShapes=y;let x=y.map(_=>yl.create({shape:_,parameters:{depth:a,extrudeBevelSegments:o,extrudeBevelSize:n,windingRule:a<=0?Gt.NONZERO:Gt.ODD,subdivisions:this.isLowResolution&&a>0?vX:gX}})),w=x.length?Qo(x):QC();w.translate(-m,v,0),this.dispose(),this.wrappedText=u,this.charCoords=g,this.charWidths=f,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([_,b])=>{this.setAttribute(_,b)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Ms(new Ge,ey.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},t)}get text(){return this.userData.parameters.text??""}};function yX(e,t,i,r){let s=typeof e.width=="string"?Number(r.getVariable(e.width)):e.width,a=[""],n="";for(let o of i)n+=o,o===" "||o===`
  3079. `?(a[a.length-1]+=n,n="",o===`
  3080. `&&a.push("")):t.getTextWidth(a[a.length-1]+n,e)>s&&(a[a.length-1].length&&a.push(""),t.getTextWidth(a[a.length-1]+n,e)>s&&(n.length===1?(a[a.length-1]+=n,n=""):(a[a.length-1]+=n.slice(0,-1),n=n[n.length-1],a.push(""))));return a[a.length-1]+=n,a}var ZC,KC=new Promise(e=>{ZC=e}),pS=!1,Yu;function xX(e){if(pS)return;if(Yu)return Yu;async function t(){let i=e??"https://unpkg.com/@splinetool/modelling-wasm@1.10.53/build",r=vo(()=>import("./process-efgVNNca.js"),__vite__mapDeps([])),[s,a]=await Promise.all([r,fetch(`${i}/process.wasm`).then(l=>l.arrayBuffer())]),n=s.default,o=await n({wasmBinary:a});ZC(o),pS=!0}return Yu=t(),Yu}var bX=["font"];function Dd(e,t,i,r){var h,c;let s,a,n;e.type==="PathGeometry"?(a=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(a={...e},n=[[]]);for(let d of n){let u=a;for(let p of d)u=u[p];for(s in u){let p=u[s];g_(p)&&!bX.includes(s)&&(u[s]=t.getVariable(p,[r.uuid,"geometry",...d,s]),g_(u[s])&&(u[s]=1))}}let o={parameters:a,type:a.type};if(a.type==="PathGeometry")o.path=a.path;else if(a.type==="VectorGeometry"){let d=mi.createFromState(a.shape,a.width,a.height);o.shape=d}else if(a.type==="NonParametricGeometry"){if(a.data.groups&&((h=a.data.groups)==null||h.forEach(d=>d.materialIndex=Math.max(d.materialIndex??0,0))),o.geometry=new kM().parse(a),o.geometry.groups.length===0){let d=o.geometry;d.addGroup(0,Math.max(((c=d.getIndex())==null?void 0:c.count)??0,d.getAttribute("position").count),0)}}else if(a.type==="SubdivGeometry"){let d=new zr(a,i);return d.data=e,d}else{if(a.type==="TextGeometry")return new ey(a,t);if(a.type==="InputGeometry")return new ey(a,t);if(a.type==="UIGeometry")return U1.create({parameters:{width:a.width,height:a.height,cornerRadius:a.cornerRadius,cornerType:a.cornerType}})}let l;try{l=yS(o)}catch(d){console.error(d)}if(!l){let d=mi.createFromState(mf.defaultData(),100,100);o.shape=d,l=yS(o)}return l}var wX=new we;function ty(e,t,i,r){let s=e.position.array,a=e.normal.array,n=wX.makeScale(t,i,r).invert().elements,o,l,h;for(var c=0,d=s.length;c<d;c+=3)s[c]*=t,s[c+1]*=i,s[c+2]*=r,o=a[c],l=a[c+1],h=a[c+2],a[c]=n[0]*o+n[4]*l+n[8]*h,a[c+1]=n[1]*o+n[5]*l+n[9]*h,a[c+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var Qu=new Si,Gl=new M,rt;KC.then(e=>{rt=e});var fS=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),mS=new Uint32Array([0,1,2,3]),gS=new Uint8Array([4]),zr=class extends Ge{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=il.div(t,i);this.subdividedGeometry&&ty(this.subdividedGeometry.attributes,...r),this.originalGeometry&&ty(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(Gl.fromArray(r));let a=Gl.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=zr.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Xs(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(zr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new $r,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;Qu.setFromBufferAttribute(t),Qu.getCenter(i),e.boundingSphere.radius=i.distanceTo(Qu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Qu.getSize(Gl);let r={width:Gl.x,height:Gl.y,depth:Gl.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,a,n,o=(e==null?void 0:e.phongAngle)??35;i===!1&&(o=-1),t&&(rt.free_bvh(t),rt.free_subdivision_surface(t));try{s=zr.allocate(e,r)}catch(l){console.error(l,e),s=zr.allocate({positionWASM:fS,indexWASM:mS,verticesPerFaceWASM:gS},r)}if(rt.set_destination_refinement_level(s,0),a=zr.buildLevel(s,!0,o),e.subdivisions>0)try{rt.set_destination_refinement_level(s,e.subdivisions),n=zr.buildLevel(s,!1,o)}catch{try{rt.set_destination_refinement_level(s,e.subdivisions-1),n=zr.buildLevel(s,!1,o)}catch{n=null}}else n=null;return{subdivPointer:s,originalGeometry:a,subdividedGeometry:n}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0||e.path!==void 0?t.geometry:Dd(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let a,n,o,l;({positions:a,triIndices:l}=um(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let c=e.radialSegments*e.heightSegments*3*2,d=c+e.radialSegments*3;h=[c,d]}return{indices:n,verticesPerFace:o}=JC(a,l,r,h),{positions:a,indices:n,verticesPerFace:o}}static allocate(e,t){var x;let i,r,s,a=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=fS,r=mS,s=gS);let o=i.length,l=r.length,h=s.length,c=i.length+a.length+n.length,d=r.length+s.length,u=c*Float32Array.BYTES_PER_ELEMENT+d*Uint32Array.BYTES_PER_ELEMENT,p=c*Float32Array.BYTES_PER_ELEMENT,f=rt._malloc(u),g=new Float32Array(rt.HEAPF32.buffer,f,c),m=new Uint32Array(rt.HEAPU32.buffer,f+p,d);g.set(i,0),g.set(a,i.length),g.set(n,i.length+a.length),m.set(r,0),m.set(s,r.length);let v;(x=e==null?void 0:e.scaleBaked)!=null&&x.some(w=>w!==1)&&(v=new we().makeScale(...e.scaleBaked)),t&&(v?v.premultiply(t):v=t);let y=v?rt.alloc_subdivision_surface2(f,o,f+p,l,f+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,v.elements):rt.alloc_subdivision_surface(f,o,f+p,l,f+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return rt._free(f),y}static buildLevel(e,t,i,r,s){let a=s?rt.get_mesh_data2(e,t?rt.Level.CONTROL:rt.Level.REFINED,i,s.elements):rt.get_mesh_data(e,t?rt.Level.CONTROL:rt.Level.REFINED,i),n=8,o=rt.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(4,8),h=0,c=rt.HEAPU32[o[h]>>2],d=rt.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let u=rt.HEAPU32[o[h]>>2],p=rt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=rt.HEAPU32[o[h]>>2],g=rt.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=rt.HEAPU32[o[h]>>2],v=rt.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new Ge;if(y.setIndex(new mh(v,1)),y.setAttribute("position",new Ie(d,3)),y.setAttribute("normal",new Ie(p,3)),t){y.setAttribute("faceMap",new mh(g,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new tt(x,4))}return rt.free_mesh_data(a),y.userData.type="SubdivGeometry",y}r.getAttribute("position").copyArray(d),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,rt.free_mesh_data(a)}static freeSubdivPointer(e){rt.free_bvh(e),rt.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=rt.get_wireframe_data_for_base_level(e),s=4,a=rt.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(2,4),o=0,l=rt.HEAPU32[a[o]>>2],h=rt.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let c=rt.HEAPU32[a[o]>>2],d=rt.HEAPU32.subarray(c>>2,(c>>2)+n[o]);if(t===void 0){let u=new Ge;u.setAttribute("position",new Ie(h,3));let p=new Float32Array(h.length);for(let f=0,g=h.length;f<g;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return u.setAttribute("color",new tt(p,3)),u.setIndex(new mh(d,1)),rt.free_wireframe_data_for_base_level(r),u}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,rt.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||rt.set_destination_refinement_level(e,t);let s=i?rt.get_topological_data2(e,r?rt.Level.CONTROL:rt.Level.REFINED,i.elements):rt.get_topological_data(e,r?rt.Level.CONTROL:rt.Level.REFINED),a=6,n=rt.HEAPU32.subarray(s>>2,(s>>2)+a),o=n.subarray(3,6),l=0,h=rt.HEAPU32[n[l]>>2],c=new Float32Array(rt.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let d=rt.HEAPU32[n[l]>>2],u=new Uint32Array(rt.HEAPU32.subarray(d>>2,(d>>2)+o[l]));l++;let p=rt.HEAPU32[n[l]>>2],f=new Uint8Array(rt.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return rt.free_topological_data(s),{positions:c,indices:u,verticesPerFace:f}}},vS=["getX","getY","getZ"];function um(e,t){let i={},r=t?t.count:e.count,s=0,a=[],n=[],o=1e4;for(let h=0;h<r;h++){let c=t?t.getX(h):h,d="";for(let u=0;u<3;u++)d+=`${~~(e[vS[u]](c)*o)},`;if(d in i)a.push(i[d]);else{for(let u=0;u<3;u++)n.push(e[vS[u]](c));i[d]=s,a.push(s),s++}}let l=[];for(let h=0;h<a.length;h+=3)a[h]===a[h+1]||a[h]===a[h+2]||a[h+1]===a[h+2]||l.push(a[h],a[h+1],a[h+2]);return{positions:n,triIndices:l}}var Zu=new M,Bg=new M,Fg=new M,Ug=new M;function JC(e,t,i,r){let s=[],a=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let u=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%u===0)}let c=0;for(let u=0;u<l.length;u+=2)c+=(l[u]-l[(u===0?l.length:u)-2])*(l[u+1]+l[(u===0?l.length:u)-1]);e.length=0;let d=0;if(c<0)for(let u=0;u<l.length;u+=2)e.push(l[u],l[u+1],0),s.push(d++);else for(let u=l.length-2;u>=0;u-=2)e.push(l[u],l[u+1],0),s.push(d++);return a.push(d),{indices:s,verticesPerFace:a}}let n=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===n||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===n||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===n||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Zu.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),Bg.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),Fg.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),Ug.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),Bg.sub(Zu).normalize(),Fg.sub(Zu).normalize(),Ug.sub(Zu).normalize();let l=Bg.cross(Fg).dot(Ug);Math.abs(l)>.005||r&&r.some((h,c)=>c%2===1?!1:o>=r[c]&&o<r[c+1])?(s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3):(s.push(t[o],t[o+1],t[o+4],t[o+5]),a.push(4),o+=6)}else s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],c=0;for(let d=0,u=0;d<e.length;d+=3,u++)e[d+2]===0&&(l.push(u),c++),e[d+2]===n&&h.push(u);if(i.userData.parameters.extrudeBevelSize===0){let d=h[0];h[0]=h[1],h[1]=d}l.reverse(),s.push(...l,...h),a.push(c,c)}return{indices:s,verticesPerFace:a}}var Za={};CO(Za,{calcBoolean:()=>EX,calcBooleanTopological:()=>MX,freeMeshSet:()=>DX,getMeshSet:()=>CX,hasOpenEdges:()=>TX,transformMeshSet:()=>PX});var $C,_X=new Promise(e=>{$C=e}),Ku;function SX(e){if(Ku)return Ku;async function t(){let i=e??"https://unpkg.com/@splinetool/boolean-wasm@1.10.53/build",r=vo(()=>import("./boolean-Bni0TW63.js"),__vite__mapDeps([])),[s,a]=await Promise.all([r,fetch(`${i}/boolean.wasm`).then(l=>l.arrayBuffer())]),n=s.default,o=await n({wasmBinary:a});$C(o)}return Ku=t(),Ku}var Ct,_h;_X.then(e=>Ct=e);function AX(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:a,triIndices:n}=um(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=JC(a,n,e);o=h.length,r=[];for(let c=0,d=0;c<o;c++){r.push(h[c]);for(let u=0;u<h[c];u++)r.push(l[d++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,c=0;c<r.length;)r[c++]=3,o++,r[c++]=n[h++],r[c++]=n[h++],r[c++]=n[h++]}return{positions:a,faceIndices:r,nFaces:o}}function eT(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,a=Ct._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(Ct.HEAPU32.buffer,a,t):new Float32Array(Ct.HEAPF32.buffer,a,t)).set(e,0),a}function tT(e){switch(e){case 0:return Ct.OP.UNION;case 1:return Ct.OP.INTERSECTION;case 2:return Ct.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+e)}}function MX(e,t){_h===void 0&&(_h=Ct.init_csg());let i=eT(e),r=Ct.csg_calc_topological(_h,i,e.length,tT(t));Ct._free(i);let s=6,a=Ct.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(3,6),o=0,l=Ct.HEAPU32[a[o]>>2],h=new Float32Array(Ct.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let c=Ct.HEAPU32[a[o]>>2],d=new Uint32Array(Ct.HEAPU32.subarray(c>>2,(c>>2)+n[o]));o++;let u=Ct.HEAPU32[a[o]>>2],p=new Uint8Array(Ct.HEAPU32.subarray(u>>2,(u>>2)+n[o]));return Ct.free_mesh_data(r),{positions:h,indices:d,verticesPerFace:p}}function EX(e,t,i,r){_h===void 0&&(_h=Ct.init_csg());let s=eT(e),a=Ct.csg_calc(_h,s,e.length,r,tT(t));Ct._free(s);let n=5,o=Ct.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(2,5),h=0,c=Ct.HEAPU32[o[h]>>2],d=Ct.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let u=Ct.HEAPU32[o[h]>>2],p=Ct.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Ie(d,3)),i.setAttribute("normal",new Ie(p,3));let g=Ct.HEAPF32.subarray((a>>2)+5,(a>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new $r),i.boundingSphere.center.set(g[0],g[1],g[2]),i.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,i.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},Ct.free_mesh_data(a),f}function CX(e,t,i){if(Ct===void 0)return-1;let r,s,a;if(t&&e.userData.positions!==void 0){let m=e.userData;a=m.verticesPerFace.length,r=m.positions,s=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+a);for(let v=0,y=0,x=0;v<m.verticesPerFace.length;v++){s[x++]=m.verticesPerFace[v];for(let w=0;w<m.verticesPerFace[v];w++)s[x++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:a}=AX(e,t,i));let n=r.length,o=s.length,l=r.length,h=s.length,c=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,u=Ct._malloc(c),p=new Float32Array(Ct.HEAPF32.buffer,u,l),f=new Uint32Array(Ct.HEAPU32.buffer,u+d,h);p.set(r,0),f.set(s,0);let g=Ct.get_csg_mesh(u,n,u+d,o,a);return Ct._free(u),g}function TX(e){return Ct.has_open_edges(e)}function PX(e,t){Ct.transform_csg_mesh(e,t.elements)}function DX(e){Ct.free_csg_mesh(e)}var IX={ConeGeometry:R7,CubeGeometry:L7,CylinderGeometry:CC,DodecahedronGeometry:B7,EllipseGeometry:F1,HelixGeometry:yq,IcosahedronGeometry:xq,LatheGeometry:bq,NonParametricGeometry:Cq,PolygonGeometry:HC,PyramidGeometry:Tq,RectangleGeometry:U1,SphereGeometry:Iq,PlaneGeometry:Oq,BackdropGeometry:Rq,StarGeometry:WC,TextFrameGeometry:zq,TorusGeometry:Bq,TorusKnotGeometry:Uq,TriangleGeometry:Nq,PathGeometry:pX,VectorGeometry:yl},yS=e=>IX[e.type].create(e);function Hl(e){return e!==null&&"booleanOp"in e}var iT=class extends I1(Jt){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new we}updateVisible(e){super.updateVisible(e),this.visible=!Hl(this.parent)&&this.visible,Hl(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Za.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Hl(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof iT&&(e.freeBooleanPointer(),Hl(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&Hl(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),Hl(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},Ju=new Si;function N1(e,t=0,i=e.count,r,s){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0;for(let d=t;d<i;d++){let u=e.getX(d),p=e.getY(d),f=e.getZ(d);u<a&&(a=u),p<n&&(n=p),f<o&&(o=f),u>l&&(l=u),p>h&&(h=p),f>c&&(c=f)}Ju.min.set(a,n,o),Ju.max.set(l,h,c),Ju.getCenter(r),Ju.getSize(s).multiplyScalar(.5)}var OX=new Ge,RX=new gn,Vr=class extends iT{constructor(e,t){super(OX,RX),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?N1(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},jn=class{constructor(e){if(this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},jn.uuidContext===null)throw new Error("plz startContext");jn.uuidContext===jn.globalContext?this.uuid="_gid"+jn.uuidContext.nodeContextUuid++:this.uuid="_uid"+jn.uuidContext.nodeContextUuid++,this.type=e,this.name=""}static startContext(e){this.uuidContext===null||this.uuidContext===jn.globalContext?this.uuidContext=e:console.error("Can't start context twice")}static endContext(e){this.uuidContext!==e&&console.error("Can't end context twice"),this.uuidContext=null}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,a){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}},Vi=jn;Vi.globalContext={nodeContextUuid:0},Vi.uuidContext=jn.globalContext;var xS=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},LX=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Qr=new LX,Wt=class extends Vi{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=Re.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let a=e.getNodeData(i),n=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return a.name=a.name||super.build(e,t,i),a.name;if(!this.getLabel()&&(!this.getShared(e,n)||e.context.ignoreCache||a.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,n,t);{o=super.generate(e,t,i,a.output,r);let l=this.generate(e,n,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,n,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},es=class extends Wt{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,a){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,a):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,s,a,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,s,a,this.getLabel())),e.format(n.fragment.name,r,t))}},cr=class extends es{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof j?e:new j(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},fs=class extends es{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof M?e:new M(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},vr=class extends et{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},Ka=class extends es{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof vr?e:new vr(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},zX=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,bS=/[a-z_0-9]+/gi,De=class extends Wt{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let a,n=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;a=bS.exec(this.src);)l.push(a);for(let h=0;h<l.length;h++){let c=l[h],d=c[0],u=this.isMethod?!this.getInputByName(d):!0,p=d;if(this.keywords[d]||this.useKeywords&&u&&Qr.containsKeyword(d)){let f=this.keywords[d];if(!f){let g=Qr.getKeywordData(d);g.cache&&(f=e.keywords[d]),f=f||Qr.getKeyword(d,e),g.cache&&(e.keywords[d]=f)}p=f.build(e)}d!==p&&o[c.index+n-1]!=="."&&(o=o.substring(0,c.index+n)+p+o.substring(c.index+d.length+n),n+=p.length-d.length),this.getIncludeByName(p)===void 0&&Qr.contains(p)&&e.include(Qr.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=zX.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(bS);if(a){let n=0;for(;n<a.length;){let o=a[n++],l;o==="in"||o==="out"||o==="inout"?l=a[n++]:(l=o,o="");let h=a[n++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},BX=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,rT=class extends Wt{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||rT.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let a,n,o="",l=BX.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(n=l[1],a=l[2],o=l[3]):(a=this.src,n="f"),this.name=a,this.type=n,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},Ut=rT;Ut.PI="PI",Ut.PI2="PI2",Ut.RECIPROCAL_PI="RECIPROCAL_PI",Ut.RECIPROCAL_PI2="RECIPROCAL_PI2",Ut.LOG2="LOG2",Ut.EPSILON="EPSILON";var FX=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
  3081. )*?)}`,"gim"),UX=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),sT=class extends Wt{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,i,r,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=FX.exec(e);if(t){let i=t[2],r;for(;r=UX.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},k1=class extends Wt{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",r=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(r,this.getType(e),t)}};Qr.addKeyword("uv",function(){return new k1});Qr.addKeyword("uv2",function(){return new k1(1)});var sh=class extends Wt{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??sh.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case qs:return["Linear"];case gt:return["sRGB"];default:return[]}}generate(e,t){var n;let i=this.input.build(e,"v4"),r=this.getType(e),s=sh.Nodes[this.method],a=e.include(s);if(a===sh.LINEAR_TO_LINEAR)return e.format(i,r,t);if(((n=s.inputs)==null?void 0:n.length)===2){let o=this.factor.build(e,"f");return e.format(a+"( "+i+", "+o+" )",r,t)}else return e.format(a+"( "+i+" )",r,t)}fromEncoding(e){let t=sh.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=sh.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},ba=sh;ba.Nodes={LinearToLinear:new De(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
  3082. `)),sRGBToLinear:new De(["vec4 sRGBToLinear( in vec4 value ) {"," 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.w );","}"].join(`
  3083. `)),LinearTosRGB:new De(["vec4 LinearTosRGB( in vec4 value ) {"," 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.w );","}"].join(`
  3084. `))},ba.LINEAR_TO_LINEAR="LinearToLinear",ba.SRGB_TO_LINEAR="sRGBToLinear",ba.LINEAR_TO_SRGB="LinearTosRGB";var ii=class extends De{constructor(e="",t,i,r,s){super(e,s,r,i,t),this.nodeType="Expression"}},an=class extends es{constructor(e=new ci,t,i,r){super("v4",{shared:!0}),this.nodeType="Texture",this.value=e,this.uv=t??new k1,this.bias=i,this.project=r!==void 0?r:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){if(t==="sampler2D")return this.getTexture(e,t);let i=this.getTexture(e,t),r=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a,n;this.project?a="texture2DProj":a=s?"tex2DBias":"tex2D",s?n=a+"( "+i+", "+r+", "+s+" )":n=a+"( "+i+", "+r+" )";let o={include:e.isShader("vertex"),ignoreCache:!0},l=this.getType(e);return e.addContext(o),this.colorSpace=this.colorSpace??new ba(new ii("",l)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(n),n=this.colorSpace.build(e,l),e.removeContext(),e.format(n,l,t)}},Fe=class extends es{constructor(e){super("f"),this.nodeType="Float",this.value=e??0}generateReadonly(e,t,i,r,s,a){return e.format(this.value+(this.value%1?"":".0"),r,t)}},wS=class extends Wt{constructor(e,t){super(),this.inputs=[],this.nodeType="FunctionCall",this.value=e,this.inputs=t??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,i,r,s){r=this.getType(e);let a=this.value,n=a.build(e,t)+"( ",o=[];if(a.inputs){for(let l=0;l<a.inputs.length;l++){let h=a.inputs[l],c=this.inputs[l]||this.inputs[h.name];o.push(c.build(e,e.getTypeByFormat(h.type)))}n+=o.join(", ")+" )"}return e.format(n,r,t)}},aT=class extends Wt{constructor(e,t,i=aT.ADD){super(),this.nodeType="Operator",this.type=e.type,this.a=e,this.b=t,this.op=i}getType(e){let t=this.a.getType(e),i=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(i)>e.getTypeLength(t)?i:t}generate(e,t){let i=this.getType(e);this.type=i;let r=this.a.build(e,i),s=this.b.build(e,i);return e.format("( "+r+" "+this.op+" "+s+" )",i,t)}},Wr=aT;Wr.ADD="+",Wr.SUB="-",Wr.MUL="*",Wr.DIV="/";var Vt=class extends Wt{constructor(e,t=Vt.ABS,i,r){super(),this.nodeType="Math",this.a=e,typeof t!="string"?this.b=t:r=t,typeof i!="string"?this.c=i:r=i,this.method=r,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Vt.MIX:case Vt.CLAMP:case Vt.REFRACT:case Vt.SMOOTHSTEP:case Vt.FACEFORWARD:return 3;case Vt.MIN:case Vt.MAX:case Vt.MOD:case Vt.STEP:case Vt.REFLECT:case Vt.DISTANCE:case Vt.DOT:case Vt.CROSS:case Vt.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),i=this.b?e.getTypeLength(this.b.getType(e)):0,r=this.c?e.getTypeLength(this.c.getType(e)):0;return t>i&&t>r?this.a.getType(e):i>r?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Vt.LENGTH:case Vt.DISTANCE:case Vt.DOT:return"f";case Vt.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let i,r,s,a=this.a?e.getTypeLength(this.a.getType(e)):0,n=this.b?e.getTypeLength(this.b.getType(e)):0,o=this.c?e.getTypeLength(this.c.getType(e)):0,l=this.getInputType(e),h=this.getType(e);switch(this.type=h,this.method){case Vt.NEGATE:return e.format("( -"+this.a.build(e,l)+" )",l,t);case Vt.INVERT:return e.format("( 1.0 - "+this.a.build(e,l)+" )",l,t);case Vt.CROSS:i=this.a.build(e,"v3"),r=this.b.build(e,"v3");break;case Vt.STEP:i=this.a.build(e,a===1?"f":l),r=this.b.build(e,l);break;case Vt.MIN:case Vt.MAX:case Vt.MOD:i=this.a.build(e,l),r=this.b.build(e,n===1?"f":l);break;case Vt.REFRACT:i=this.a.build(e,l),r=this.b.build(e,l),s=this.c.build(e,"f");break;case Vt.MIX:i=this.a.build(e,l),r=this.b.build(e,l),s=this.c.build(e,o===1?"f":l);break;default:i=this.a.build(e,l),this.b&&(r=this.b.build(e,l)),this.c&&(s=this.c.build(e,l));break}let c=[];c.push(i),r&&c.push(r),s&&c.push(s);let d=this.getNumInputs(e);if(c.length!==d)throw Error(`Arguments not match used in "${this.method}". Require ${d}, currently ${c.length}.`);return e.format(this.method+"( "+c.join(", ")+" )",h,t)}},ft=Vt;ft.RAD="radians",ft.DEG="degrees",ft.EXP="exp",ft.EXP2="exp2",ft.LOG="log",ft.LOG2="log2",ft.SQRT="sqrt",ft.INV_SQRT="inversesqrt",ft.FLOOR="floor",ft.CEIL="ceil",ft.NORMALIZE="normalize",ft.FRACT="fract",ft.SATURATE="saturate",ft.SIN="sin",ft.COS="cos",ft.TAN="tan",ft.ASIN="asin",ft.ACOS="acos",ft.ARCTAN="atan",ft.ABS="abs",ft.SIGN="sign",ft.LENGTH="length",ft.NEGATE="negate",ft.INVERT="invert",ft.MIN="min",ft.MAX="max",ft.MOD="mod",ft.STEP="step",ft.REFLECT="reflect",ft.DISTANCE="distance",ft.DOT="dot",ft.CROSS="cross",ft.POW="pow",ft.MIX="mix",ft.CLAMP="clamp",ft.REFRACT="refract",ft.SMOOTHSTEP="smoothstep",ft.FACEFORWARD="faceforward";var Gc=class extends Wt{constructor(e,t,i){super("v4"),this.nodeType="TextureCubeUV",this.value=e,this.uv=t,this.bias=i}bilinearCubeUV(e,t,i,r){let s=new wS(Gc.Nodes.bilinearCubeUV,[t,i,r]);this.colorSpaceTL=this.colorSpaceTL??new ba(new ii("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new ba(new ii("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new ba(new ii("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new ba(new ii("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let a={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(a),this.colorSpaceTLExp=new ii(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new ii(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new ii(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new ii(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let n=new ii("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return n.keywords.cubeUV_TL=this.colorSpaceTLExp,n.keywords.cubeUV_TR=this.colorSpaceTRExp,n.keywords.cubeUV_BL=this.colorSpaceBLExp,n.keywords.cubeUV_BR=this.colorSpaceBRExp,n.keywords.cubeUV=s,n}generate(e,t){if(e.isShader("fragment")){let i=this.uv,r=this.bias||e.context.roughness,s=new wS(Gc.Nodes.roughnessToMip,[r]),a=new ft(s,Gc.Nodes.m0,Gc.Nodes.cubeUV_maxMipLevel,ft.CLAMP),n=new ft(a,ft.FLOOR),o=new ft(a,ft.FRACT),l=this.bilinearCubeUV(e,this.value,i,n),h=this.bilinearCubeUV(e,this.value,i,new Wr(n,new Fe(1).setReadonly(!0),Wr.ADD)),c=new ft(l,h,o,ft.MIX);return e.format(c.build(e),"v4",t)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}},iy=Gc;iy.Nodes=function(){let e=new sT(`struct TextureCubeUVData {
  3085. vec4 tl;
  3086. vec4 tr;
  3087. vec4 br;
  3088. vec4 bl;
  3089. vec2 f;
  3090. }`),t=new Ut("float cubeUV_maxMipLevel 8.0",!0),i=new Ut("float cubeUV_minMipLevel 4.0",!0),r=new Ut("float cubeUV_maxTileSize 256.0",!0),s=new Ut("float cubeUV_minTileSize 16.0",!0),a=new De(`float getFace(vec3 direction) {
  3091. vec3 absDirection = abs(direction);
  3092. float face = -1.0;
  3093. if (absDirection.x > absDirection.z) {
  3094. if (absDirection.x > absDirection.y)
  3095. face = direction.x > 0.0 ? 0.0 : 3.0;
  3096. else
  3097. face = direction.y > 0.0 ? 1.0 : 4.0;
  3098. } else {
  3099. if (absDirection.z > absDirection.y)
  3100. face = direction.z > 0.0 ? 2.0 : 5.0;
  3101. else
  3102. face = direction.y > 0.0 ? 1.0 : 4.0;
  3103. }
  3104. return face;
  3105. }`);a.useKeywords=!1;let n=new De(`vec2 getUV(vec3 direction, float face) {
  3106. vec2 uv;
  3107. if (face == 0.0) {
  3108. uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
  3109. } else if (face == 1.0) {
  3110. uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y
  3111. } else if (face == 2.0) {
  3112. uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z
  3113. } else if (face == 3.0) {
  3114. uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x
  3115. } else if (face == 4.0) {
  3116. uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y
  3117. } else {
  3118. uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
  3119. }
  3120. return 0.5 * (uv + 1.0);
  3121. }`);n.useKeywords=!1;let o=new De(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
  3122. float face = getFace(direction);
  3123. float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
  3124. mipInt = max(mipInt, cubeUV_minMipLevel);
  3125. float faceSize = exp2(mipInt);
  3126. float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);
  3127. vec2 uv = getUV(direction, face) * (faceSize - 1.0);
  3128. vec2 f = fract(uv);
  3129. uv += 0.5 - f;
  3130. if (face > 2.0) {
  3131. uv.y += faceSize;
  3132. face -= 3.0;
  3133. }
  3134. uv.x += face * faceSize;
  3135. if(mipInt < cubeUV_maxMipLevel){
  3136. uv.y += 2.0 * cubeUV_maxTileSize;
  3137. }
  3138. uv.y += filterInt * 2.0 * cubeUV_minTileSize;
  3139. uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);
  3140. uv *= texelSize;
  3141. vec4 tl = texture2D(envMap, uv);
  3142. uv.x += texelSize;
  3143. vec4 tr = texture2D(envMap, uv);
  3144. uv.y += texelSize;
  3145. vec4 br = texture2D(envMap, uv);
  3146. uv.x -= texelSize;
  3147. vec4 bl = texture2D(envMap, uv);
  3148. return TextureCubeUVData( tl, tr, br, bl, f );
  3149. }`,[e,a,n,t,i,r,s]);o.useKeywords=!1;let l=new Ut("float r0 1.0",!0),h=new Ut("float v0 0.339",!0),c=new Ut("float m0 -2.0",!0),d=new Ut("float r1 0.8",!0),u=new Ut("float v1 0.276",!0),p=new Ut("float m1 -1.0",!0),f=new Ut("float r4 0.4",!0),g=new Ut("float v4 0.046",!0),m=new Ut("float m4 2.0",!0),v=new Ut("float r5 0.305",!0),y=new Ut("float v5 0.016",!0),x=new Ut("float m5 3.0",!0),w=new Ut("float r6 0.21",!0),_=new Ut("float v6 0.0038",!0),b=new Ut("float m6 4.0",!0),A=[l,h,c,d,u,p,f,g,m,v,y,x,w,_,b],S=new De(`float roughnessToMip(float roughness) {
  3150. float mip = 0.0;
  3151. if (roughness >= r1) {
  3152. mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
  3153. } else if (roughness >= r4) {
  3154. mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;
  3155. } else if (roughness >= r5) {
  3156. mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;
  3157. } else if (roughness >= r6) {
  3158. mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;
  3159. } else {
  3160. mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
  3161. }
  3162. return mip;
  3163. }`,A);return{bilinearCubeUV:o,roughnessToMip:S,m0:c,cubeUV_maxMipLevel:t}}();var ah=class extends Wt{constructor(e){super("v3"),this.nodeType="Normal",this.scope=e??ah.VIEW}getShared(){return this.scope===ah.WORLD}build(e,t,i,r){let s=e.context[this.scope+"Normal"];return s?s.build(e,t,i,r):super.build(e,t,i)}generate(e,t,i,r,s){let a;switch(this.scope){case ah.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case ah.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case ah.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,this.getType(e),t)}},Zr=ah;Zr.LOCAL="local",Zr.WORLD="world",Zr.VIEW="view",Zr.NORMAL="normal";Qr.addKeyword("viewNormal",function(){return new Zr(Zr.VIEW)});Qr.addKeyword("localNormal",function(){return new Zr(Zr.NORMAL)});Qr.addKeyword("worldNormal",function(){return new Zr(Zr.WORLD)});var Ya=class extends Wt{constructor(e){super("v3"),this.nodeType="Position",this.scope=e??Ya.LOCAL}getType(){switch(this.scope){case Ya.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Ya.LOCAL:case Ya.WORLD:return!1}return!0}generate(e,t,i,r,s){let a;switch(this.scope){case Ya.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case Ya.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case Ya.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Ya.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,this.getType(),t)}},js=Ya;js.LOCAL="local",js.WORLD="world",js.VIEW="view",js.PROJECTION="projection";Qr.addKeyword("position",function(){return new js});Qr.addKeyword("worldPosition",function(){return new js(js.WORLD)});Qr.addKeyword("viewPosition",function(){return new js(js.VIEW)});var da=class extends Wt{constructor(e){super("v3"),this.nodeType="Reflect",this.scope=e??da.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case da.SPHERE:return"v2"}return this.type}generate(e,t){let i=this.getUnique(e);if(e.isShader("fragment")){let r;switch(this.scope){case da.VECTOR:{let s=new Zr(Zr.VIEW),a=e.context.roughness,n=s.build(e,"v3"),o=new js(js.VIEW).build(e,"v3"),l=a?a.build(e,"f"):void 0,h=`reflect( -normalize( ${o} ), ${n} )`;l&&(h=`normalize( mix( ${h}, ${n}, ${l} * ${l} ) )`);let c=`inverseTransformDirection( ${h}, viewMatrix )`;i?(e.addNodeCode(`vec3 reflectVec = ${c};`),r="reflectVec"):r=c;break}case da.CUBE:{let s=new da(da.VECTOR).build(e,"v3"),a="vec3( -"+s+".x, "+s+".yz )";i?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),r="reflectCubeVec"):r=a;break}case da.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new da(da.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";i?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),r="reflectSphereVec"):r=s;break}}return e.format(r,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}},Sh=da;Sh.CUBE="cube",Sh.SPHERE="sphere",Sh.VECTOR="vector";var NX=class extends Wt{constructor(e=new an,t,i){super("v4"),this.nodeType="TextureCube",this.value=e,this.radianceNode=new iy(this.value,t??new Sh(Sh.VECTOR),i),this.irradianceNode=new iy(this.value,new Zr(Zr.WORLD),new Fe(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}},kX=class extends es{constructor(e=new Gy,t,i){super("v4",{shared:!0}),this.nodeType="CubeTexture",this.value=e,this.uv=t??new Sh,this.bias=i}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){var l;if(t==="samplerCube")return this.getTexture(e,t);let i=this.getTexture(e,t),r=(l=this.uv)==null?void 0:l.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a;s?a="texCubeBias( "+i+", "+r+", "+s+" )":a="texCube( "+i+", "+r+" )";let n={include:e.isShader("vertex"),ignoreCache:!0},o=this.getType(e);return e.addContext(n),this.colorSpace=this.colorSpace??new ba(new ii("",o)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,o),e.removeContext(),e.format(a,o,t)}},VX=`
  3164. uniform int frameIndex;
  3165. uniform vec2 resolution;
  3166. uniform mat4 previousModelViewMatrix;
  3167. uniform mat4 previousProjectionMatrix;
  3168. varying vec4 vCurrentPosition;
  3169. varying vec4 vPreviousPosition;
  3170. `,jX=`
  3171. layout(location = 1) out vec4 gVelocity;
  3172. uniform int frameIndex;
  3173. uniform vec2 resolution;
  3174. varying vec4 vCurrentPosition;
  3175. varying vec4 vPreviousPosition;
  3176. const vec2 haltonSequence[16] = vec2[16](
  3177. vec2( 0.000000,-0.333334),
  3178. vec2(-0.500000, 0.333334),
  3179. vec2( 0.500000,-0.777778),
  3180. vec2(-0.750000,-0.111112),
  3181. vec2( 0.250000, 0.555556),
  3182. vec2(-0.250000,-0.555556),
  3183. vec2( 0.750000, 0.111112),
  3184. vec2(-0.875000, 0.777778),
  3185. vec2(0.125000, -0.925926),
  3186. vec2(-0.375000, -0.259260),
  3187. vec2(0.625000, 0.407408),
  3188. vec2(-0.625000, -0.703704),
  3189. vec2(0.375000, -0.037038),
  3190. vec2(-0.125000, 0.629630),
  3191. vec2(0.875000, -0.481482),
  3192. vec2(-0.937500, 0.185186));
  3193. vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {
  3194. const float goldenAngle = 2.399963f; // radians
  3195. float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));
  3196. float theta = float(sampleIndex) * goldenAngle + angle;
  3197. float sine = sin(theta);
  3198. float cosine = cos(theta);
  3199. return vec2(cosine, sine) * r;
  3200. }
  3201. // Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso
  3202. float getNoiseInterleavedGradient(vec2 screenPos) {
  3203. vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);
  3204. return fract(magic.z * fract(dot(screenPos, magic.xy)));
  3205. }
  3206. `,GX=`
  3207. // TODO: This could be generated CPU side and passed to the shader every frame
  3208. const vec2 haltonSequence[16] = vec2[16](
  3209. vec2( 0.000000,-0.333334),
  3210. vec2(-0.500000, 0.333334),
  3211. vec2( 0.500000,-0.777778),
  3212. vec2(-0.750000,-0.111112),
  3213. vec2( 0.250000, 0.555556),
  3214. vec2(-0.250000,-0.555556),
  3215. vec2( 0.750000, 0.111112),
  3216. vec2(-0.875000, 0.777778),
  3217. vec2(0.125000, -0.925926),
  3218. vec2(-0.375000, -0.259260),
  3219. vec2(0.625000, 0.407408),
  3220. vec2(-0.625000, -0.703704),
  3221. vec2(0.375000, -0.037038),
  3222. vec2(-0.125000, 0.629630),
  3223. vec2(0.875000, -0.481482),
  3224. vec2(-0.937500, 0.185186));
  3225. // TODO: Pass correct view size
  3226. vec2 offset = haltonSequence[frameIndex];
  3227. offset.x /= resolution.x;
  3228. offset.y /= resolution.y;
  3229. vec4 currentPosition = gl_Position;
  3230. vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);
  3231. // We want to calculate the velocity with unjittered positions
  3232. // so that things that are not moving get a velocity = 0
  3233. vCurrentPosition = currentPosition;
  3234. vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);
  3235. #ifdef OUTLINE_COMPENSATION
  3236. vPreviousPosition.xy += OUTLINE_COMPENSATION;
  3237. #endif
  3238. gl_Position = currentPositionJittered;
  3239. `,HX=`
  3240. vec2 oldPos = vPreviousPosition.xy;
  3241. oldPos /= vPreviousPosition.w;
  3242. oldPos.xy = (oldPos.xy+1.)/2.0;
  3243. vec2 newPos = vCurrentPosition.xy;
  3244. newPos /= vCurrentPosition.w;
  3245. newPos.xy = (newPos.xy+1.)/2.0;
  3246. vec2 velocity = (newPos - oldPos);
  3247. // Discard fully transparent pixels
  3248. if (gl_FragColor.a <= 0.0) discard;
  3249. gVelocity = vec4(velocity, 0.0, 1.0);
  3250. `,WX=`
  3251. layout(location = 1) out vec4 gVelocity;
  3252. `,qX=`
  3253. // Discard fully transparent pixels
  3254. if (gl_FragColor.a <= 0.0) discard;
  3255. gVelocity = vec4(0.0, 0.0, 0.0, 1.0);
  3256. `,_S=["x","y","z","w"],XX=["float","vec2","vec3","vec4"],YX={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},QX={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},nT=class{constructor(){this.includes={consts:{},functions:{},structs:{}},this.cache="",this.slot="",this.shader="",this.context={},this.needsJitter=!0,this.getIncludesCode=function(){function e(t,i){return t.deps.length-i.deps.length}return function(t,i){let r=this.getIncludes(t,i);if(!r)return"";let s="";r=r.sort(e);for(let a=0;a<r.length;a++)r[a].src&&(s+=r[a].src+`
  3257. `);return s}}(),this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
  3258. // NOTE: Include Spline's blending modes. This could be part of BlendNode
  3259. #define SPE_BLENDING_NORMAL 0
  3260. #define SPE_BLENDING_MULTIPLY 1
  3261. #define SPE_BLENDING_SCREEN 2
  3262. #define SPE_BLENDING_OVERLAY 3
  3263. vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {
  3264. return mix( a, b, alpha );
  3265. }
  3266. vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {
  3267. return mix( a, a * b, alpha );
  3268. }
  3269. vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {
  3270. vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );
  3271. return mix( a, tmp, alpha );
  3272. }
  3273. vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {
  3274. vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );
  3275. return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );
  3276. }
  3277. vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {
  3278. if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );
  3279. else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );
  3280. else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );
  3281. else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );
  3282. return vec3( 1.0 );
  3283. }
  3284. `,"#include <packing>","#include <common>"].join(`
  3285. `),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join(`
  3286. `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
  3287. accumAlpha += (1.0 - accumAlpha) * alpha;
  3288. }`,""].join(`
  3289. `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(e,t){this.addVertexParsCode(VX),this.addFragmentParsCode(jX),this.buildShader("vertex",e),this.buildShader("fragment",t);for(let i=0;i<this.requires.uv.length;i++)if(this.requires.uv[i]){let r=i>0?i+1:"";this.addVaryCode("varying vec2 vUv"+r+";"),i>0&&this.addVertexParsCode("attribute vec2 uv"+r+";"),this.addVertexFinalCode("vUv"+r+" = uv"+r+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode(`
  3290. #ifndef SHAPEBLEND
  3291. vObjectNormal = normal;
  3292. #else
  3293. vObjectNormal = objectNormal;
  3294. #endif
  3295. `)),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(GX),this.addFragmentFinalCode(HX)),this}buildShader(e,t){this.resultCode[e]=t.build(this.setShader(e),"v4")}setMaterial(e,t){return this.defines={},this}addFlow(e,t,i){return this.addSlot(e).addCache(t).addContext(i)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(e){return this.cache=e??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(e){return this.context=Object.assign({},this.context,e),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(e){return this.slot=e||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(e,t){this.fragmentVariables[e]===void 0&&(this.addFragmentCode(`${t} ${e};`),this.fragmentVariables[e]="")}addFragmentParsVariable(e,t){this.fragmentParsVariables[e]===void 0&&(this.addFragmentParsCode(`${t} ${e};`),this.fragmentParsVariables[e]="")}addVertexParsVariable(e,t){this.vertexParsVariables[e]===void 0&&(this.addVertexParsCode(`${t} ${e};`),this.vertexParsVariables[e]="")}addVertexCode(e){this.addCode(e,"vertex")}addFragmentCode(e){this.addCode(e,"fragment")}addCode(e,t){this.code[t??this.shader]+=e+`
  3296. `}addVertexNodeCode(e){this.addNodeCode(e,"vertex")}addFragmentNodeCode(e){this.addNodeCode(e,"fragment")}addNodeCode(e,t){this.nodeCode[t??this.shader]+=e+`
  3297. `}clearNodeCode(e){e=e??this.shader;let t=this.nodeCode[e];return this.nodeCode[e]="",t}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(e){this.addFinalCode(e,"vertex")}addFragmentFinalCode(e){this.addFinalCode(e,"fragment")}addFinalCode(e,t){this.finalCode[t??this.shader]+=e+`
  3298. `}addVertexParsCode(e){this.addParsCode(e,"vertex")}addFragmentParsCode(e){this.addParsCode(e,"fragment")}addParsCode(e,t){this.parsCode[t??this.shader]+=e+`
  3299. `}addVaryCode(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)}isCache(e){return this.caches.indexOf(e)!==-1}isSlot(e){return this.slots.indexOf(e)!==-1}define(e,t){this.defines[e]=t===void 0?1:t}require(e){this.requires[e]=!0}isDefined(e){return this.defines[e]!==void 0}getVar(e,t,i,r="varying",s="V",a=""){let n=this.getVars(r),o=n[e];if(!o){let l=n.length;o={name:i||"node"+s+l+(a?"_"+a:""),type:t},n.push(o),n[e]=o}return o}getTempVar(e,t,i,r){return this.getVar(e,t,i,this.shader,"T",r)}getAttribute(e,t){if(!this.attributes[e]){let i=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(i.name+" = "+e+";"),this.attributes[e]={varying:i,name:e,type:t}}return this.attributes[e]}getCode(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join(`
  3300. `)}getVarListCode(e,t){t=t??"";let i="";for(let r=0,s=e.length;r<s;++r){let a=e[r],n=a.type,o=a.name,l=a.size,h=this.getFormatByType(n);if(h===void 0)throw new Error("Node pars "+h+" not found.");h.includes("[]")?i+=t+" "+h.substring(0,h.length-2)+" "+o+`[${l}];
  3301. `:i+=t+" "+h+" "+o+`;
  3302. `}return i}getVars(e){return this.inputs.vars[e??this.shader]}getNodeData(e){let t=e instanceof Vi?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}}createUniform(e,t,i,r,s,a){if(t.includes("[]")){let n=this.inputs.arrayUniforms,o=n.list.length,l=new xS({type:t,size:i.size,name:r||"nodeUA"+o+(a?"_"+a:""),node:i,needsUpdate:s});return n.list.push(l),n[e].push(l),n[e][l.name]=l,this.uniforms[l.name]=l,l}else{let n=this.inputs.uniforms,o=n.list.length,l=new xS({type:t,name:r||"nodeU"+o+(a?"_"+a:""),node:i,needsUpdate:s});return n.list.push(l),n[e].push(l),n[e][l.name]=l,this.uniforms[l.name]=l,l}}createVertexUniform(e,t,i,r,s){return this.createUniform("vertex",e,t,i,r,s)}createFragmentUniform(e,t,i,r,s){return this.createUniform("fragment",e,t,i,r,s)}include(e,t,i){var a;let r;if(e=typeof e=="string"?Qr.get(e):e,this.context.include===!1)return e.name;e instanceof De?r=this.includes.functions:e instanceof Ut?r=this.includes.consts:e instanceof sT&&(r=this.includes.structs);let s=r[this.shader]=r[this.shader]||[];if(e){let n=s[e.name];if(n||(n=s[e.name]={node:e,deps:[]},s.push(n),n.src=e.build(this,"source")),e instanceof De&&t&&s[t.name]&&s[t.name].deps.indexOf(e)===-1&&(s[t.name].deps.push(e),(a=e.includes)==null?void 0:a.length)){let o=0;do this.include(e.includes[o++],t);while(o<e.includes.length)}return i&&(n.src=i),e.name}else throw new Error("Include not found.")}colorToVectorProperties(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(e){return e.replace(/c/g,"v3")}getIncludes(e,t){return this.includes[e][t||this.shader]}getConstructorFromLength(e){return XX[e-1]}isTypeMatrix(e){return/^m/.test(e)}getTypeLength(e){return e==="f"?1:parseInt(this.colorToVector(e).substr(1))}getTypeFromLength(e){return e===1?"f":"v"+e}findNode(...e){for(let t=0;t<arguments.length;t++){let i=e[t];if(i!=null&&i.isNode)return i}}resolve(...e){for(let t=0;t<arguments.length;t++){let i=e[t];if(i!==void 0){if(i.isNode)return i;if(i.isTexture)switch(i.mapping){case al:case nl:return new kX(i);case Rd:return new NX(new an(i));default:return new an(i)}else{if(i.isVector2)return new cr(i);if(i.isVector3)return new fs(i);if(i.isVector4)return new Ka(i)}}}}format(e,t,i){switch(this.colorToVector(i+" <- "+t)){case"f <- v2":return e+".x";case"f <- v3":return e+".x";case"f <- v4":return e+".x";case"f <- i":case"f <- b":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":return e+".xy";case"v2 <- v4":return e+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+e+" ) )";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+e+" ) )";case"i <- f":case"i <- b":return"int( "+e+" )";case"i <- v2":return"int( "+e+".x )";case"i <- v3":return"int( "+e+".x )";case"i <- v4":return"int( "+e+".x )";case"b <- f":return"( "+e+" != 0.0 )";case"b <- v2":return"( "+e+" != vec2( 0.0 ) )";case"b <- v3":return"( "+e+" != vec3( 0.0 ) )";case"b <- v4":return"( "+e+" != vec4( 0.0 ) )";case"b <- i":return"( "+e+" != 0 )"}return e}getTypeByFormat(e){return YX[e]||e}getFormatByType(e){return QX[e]||e}getUUID(e,t){return t=t!==void 0?t:!0,t&&this.cache&&(e=this.cache+"-"+e),e}getElementByIndex(e){return _S[e]}getIndexByElement(e){return _S.indexOf(e)}isShader(e){return this.shader===e}setShader(e){return this.shader=e,this}mergeDefines(e){for(let t in e)this.defines[t]=e[t];return this.defines}mergeUniform(e){for(let t in e)this.uniforms[t]=e[t];return this.uniforms}getTextureEncodingFromMap(e){let t;return e?e.isTexture&&(t=e.encoding):t=qs,t===qs&&this.context.gamma&&(t=gt),t}},gi=class extends es{constructor(e=0,t,i,r){super("c"),this.nodeType="Color",this.value=e instanceof vr?e:new vr(e||0,t,i,r)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,i,r,s,a){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i),o=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let l=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${l};`)}return o?this.generateReadonly(e,t,i,r,s,a):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,s,a,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,s,a,this.getLabel())),e.format(n.fragment.name,r,t))}generateReadonly(e,t,i,r,s,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",r,t)}},Yt=class extends es{constructor(e){super("i"),this.nodeType="Int",this.value=Math.floor(e??0)}generateReadonly(e,t,i,r,s,a){return e.format(this.value.toString(),r,t)}},Br=class extends es{constructor(e){super("b"),this.nodeType="Bool",this.value=e??!1}generateReadonly(e,t,i,r){return e.format(this.value?"true":"false",r,t)}},Bo=class extends es{constructor(e=1,t){super("f[]"),this.nodeType="FloatArray",this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}},V1=class extends es{},ZX=class extends V1{constructor(e){super("v3"),this.image=e,this._value=new M}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}},ry=class extends V1{constructor(e,t,i=1008,r=1006){super("t"),this.image=e,this.wrap=t,this.minFilter=i,this.magFilter=r}get value(){return this.image.getTexture(this.wrap,this.minFilter,this.magFilter)}},oT=class extends es{constructor(e){super("m3"),this.nodeType="Matrix3",this.value=e??new Di}generateReadonly(e,t,i,r,s,a){return e.format("mat3("+this.value.elements.join(", ")+")",r,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}},Pa=class extends es{constructor(e){super("m4"),this.nodeType="Matrix4",this.value=e??new we}generateReadonly(e,t,i,r,s,a){return e.format("mat4("+this.value.elements.join(", ")+")",r,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};function SS(e,t,i,r=0){e.setUvTransform(i[0],i[1],t[0],t[1],0,0,0).premultiply(new Di().makeRotation(r*Re.DEG2RAD))}var KX=class extends oT{constructor(e,t,i=0){super(new Di),this.repeat=e,this.offset=t,this.rotation=i,SS(this.value,e,t,i)}updateMatrix(){SS(this.value,this.repeat,this.offset,this.rotation)}},Fo=class extends es{constructor(e=1,t){super("v4[]"),this.nodeType="Vector4Array",this.size=e,this.value=Array.isArray(t)?t:t instanceof ct?new Array(e).fill(t):new Array(e).fill(new ct(0))}},AS=class extends Wt{constructor(e,t,i,r){super("v3"),this.nodeType="Blend",this.a=e,this.b=t,this.alpha=i,this.mode=r}generate(e,t){if(e.isShader("fragment")){let i=[];return i.push(this.a.build(e,"c")),i.push(this.b.build(e,"c")),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),e.format("spe_blend("+i.join(",")+")",this.getType(e),t)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},lT=class extends Wt{constructor(e,t){super("v3"),this.nodeType="CustomColor",this.color=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let i=e.include(lT.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let r=[];return r.push(this.color.build(e,"v3")),r.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},sy=lT;sy.Nodes=function(){return{customColor:new De(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
  3303. float lalpha = alpha * mask;
  3304. calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
  3305. accumAlpha += (1.0 - accumAlpha) * lalpha;
  3306. return color;
  3307. }`)}}();var hT=class extends Wt{constructor(e,t){super("v3"),this.nodeType="CustomNormal",this.cnormal=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let i=e.include(hT.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let r=[];return r.push(this.cnormal.build(e,"v3")),r.push("normal"),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},cT=hT;cT.Nodes=function(){return{customNormal:new De(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
  3308. vec3 normal = packNormalToRGB( norm ).rgb;
  3309. normal *= step( vec3(0.5), cnormal );
  3310. float lalpha = alpha * mask;
  3311. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  3312. accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
  3313. return normal;
  3314. }`)}}();var Hc=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h,c,d){super("v3"),this.nodeType="CustomTexture",this.texture=e,this.textureSize=t,this.crop=i,this.projection=r,this.axis=s,this.side=a,this.size=n,this.blending=o,this.mat=l,this.isMask=d,this.alpha=h,this.mode=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){e.require("position"),e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let i=`g${this.uuid.toString().replace(/-/g,"")}`,r;switch(this.projection.value){case 3:r=e.include(Hc.Nodes.cylindrical);break;case 2:r=e.include(Hc.Nodes.spherical);break;case 1:let a=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],n=["zy","xz","xy"][this.axis.value],o=new De(`
  3315. vec3 ${i}_planarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
  3316. vec2 projected = (1. + (position.${n})) / 2.;
  3317. vec2 uvs = ( mat * vec3( (projected * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
  3318. writeUv = uvs;
  3319. vec4 tmp = texture2D( tex, uvs );
  3320. vec3 col = tmp.rgb;
  3321. float lalpha = alpha * tmp.a;
  3322. ${this.side.value===2?"":`lalpha *= step(0.0, ${this.side.value===1?"-1.0 * ":""}dot(vObjectNormal, ${a}));`}
  3323. if ( crop > 0.5 ) {
  3324. if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
  3325. lalpha = 0.0;
  3326. }
  3327. }
  3328. lalpha *= mask;
  3329. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  3330. accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
  3331. return col;
  3332. }`);r=e.include(o);break;case 4:r=e.include(Hc.Nodes.triplanar);break;default:r=e.include(Hc.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let s=[];if(s.push("normal"),s.push(this.texture.generate(e,"t")),s.push(this.textureSize.build(e,"v2")),s.push(this.crop.build(e,"f")),s.push(this.mat.build(e,"mat3")),s.push(this.size.build(e,"v2")),s.push(this.blending.build(e,"f")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),this.projection.value===4){let a=`${i}_writeUvs`,n=a+"0",o=a+"1",l=a+"2",h=`${i}_triplanarWeights`;e.addFragmentVariable(n,"vec2"),e.addFragmentVariable(o,"vec2"),e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(h,"vec3"),s.push(n),s.push(o),s.push(l),s.push(h)}else{let a=`${i}_writeUvs`;e.addFragmentVariable(a,"vec2"),s.push(a)}return e.format(r+"("+s.join(",")+")",this.getType(e),t)}},j1=Hc;j1.Nodes=function(){let e=new De(`
  3333. vec3 cylindricalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
  3334. vec3 posN = normalize(position);
  3335. float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
  3336. float scaledHeight = position.y / (size.y * 0.5);
  3337. float v = (scaledHeight / 2.) + .5;
  3338. vec2 calculatedUv = vec2(u,v);
  3339. vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
  3340. writeUv = uvs;
  3341. vec2 df = fwidth(uvs);
  3342. if(df.x > 0.5) df.x = 0.;
  3343. #ifdef GL_EXT_shader_texture_lod
  3344. vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
  3345. #else
  3346. vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
  3347. #endif
  3348. vec3 col = tmp.rgb;
  3349. float lalpha = alpha * tmp.a;
  3350. if ( crop > 0.5 ) {
  3351. if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
  3352. lalpha = 0.0;
  3353. }
  3354. }
  3355. lalpha *= mask;
  3356. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  3357. accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
  3358. return col;
  3359. }
  3360. `),t=new De(`
  3361. vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
  3362. vec3 posN = normalize(vPosition);
  3363. float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
  3364. float v = 0.5 + asin(posN.y) / 3.1415;
  3365. vec2 calculatedUv = vec2(u,v);
  3366. vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
  3367. writeUv = uvs;
  3368. vec2 df = fwidth(uvs);
  3369. if(df.x > 0.5) df.x = 0.;
  3370. #ifdef GL_EXT_shader_texture_lod
  3371. vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
  3372. #else
  3373. vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
  3374. #endif
  3375. vec3 col = tmp.rgb;
  3376. float lalpha = alpha * tmp.a;
  3377. if ( crop > 0.5 ) {
  3378. if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
  3379. lalpha = 0.0;
  3380. }
  3381. }
  3382. lalpha *= mask;
  3383. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  3384. accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
  3385. return col;
  3386. }
  3387. `),i=new De(`vec3 uvTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUv) {
  3388. vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
  3389. writeUv = uvs;
  3390. vec4 tmp = texture2D( tex, uvs );
  3391. vec3 col = tmp.rgb;
  3392. float lalpha = alpha * tmp.a;
  3393. if ( crop > 0.5 ) {
  3394. if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
  3395. lalpha = 0.0;
  3396. }
  3397. }
  3398. lalpha *= mask;
  3399. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  3400. accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
  3401. return col;
  3402. }`),r=new De(`vec3 triplanarTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float blending, bool isMask, float mask, float alpha, int mode, out float calpha, out vec2 writeUvs0, out vec2 writeUvs1, out vec2 writeUvs2, out vec3 writeWeights) {
  3403. vec3 p = position;
  3404. vec2 uv0 = (1.0 + p.xy) / 2.0;
  3405. vec2 uv1 = (1.0 + p.zy) / 2.0;
  3406. vec2 uv2 = (1.0 + p.xz) / 2.0;
  3407. uv0 = (mat * vec3((uv0 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;
  3408. uv1 = (mat * vec3((uv1 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;
  3409. uv2 = (mat * vec3((uv2 * 2.0 - 1.0) / (size * 0.5), 1.0) / 2.0 + 0.5).xy;
  3410. // Range from 3 to 128 seems to be good
  3411. float exponent = (1.0 - blending) * 125.0 + 3.0;
  3412. vec3 n = vObjectNormal;
  3413. vec3 weights = abs(normalize(n));
  3414. weights = pow(weights, vec3(exponent));
  3415. weights /= dot(weights, vec3(1.0));
  3416. // Write out all sets of UVs that we generated
  3417. writeUvs0 = uv0;
  3418. writeUvs1 = uv1;
  3419. writeUvs2 = uv2;
  3420. writeWeights = weights;
  3421. // Derivatives for LOD
  3422. vec2 df0 = fwidth(uv0);
  3423. vec2 df1 = fwidth(uv1);
  3424. vec2 df2 = fwidth(uv2);
  3425. if (df0.x > 0.5) df0.x = 0.0;
  3426. if (df1.x > 0.5) df1.x = 0.0;
  3427. if (df2.x > 0.5) df2.x = 0.0;
  3428. #ifdef GL_EXT_shader_texture_lod
  3429. vec4 tmp =
  3430. texture2DLodEXT(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z +
  3431. texture2DLodEXT(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x +
  3432. texture2DLodEXT(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;
  3433. #else
  3434. vec4 tmp =
  3435. textureLod(tex, uv0, log2(max(df0.x, df0.y)*min(textureSize.x, textureSize.y))) * weights.z +
  3436. textureLod(tex, uv1, log2(max(df1.x, df1.y)*min(textureSize.x, textureSize.y))) * weights.x +
  3437. textureLod(tex, uv2, log2(max(df2.x, df2.y)*min(textureSize.x, textureSize.y))) * weights.y;
  3438. #endif
  3439. vec3 col = tmp.rgb;
  3440. float lalpha = alpha * tmp.a;
  3441. // Apply cropping across all 3 planes
  3442. if ( crop > 0.5 ) {
  3443. if ( uv0.x < 0.0 || uv0.x > 1.0 || uv0.y < 0.0 || uv0.y > 1.0 ) {
  3444. lalpha = 0.0;
  3445. }
  3446. if ( uv1.x < 0.0 || uv1.x > 1.0 || uv1.y < 0.0 || uv1.y > 1.0 ) {
  3447. lalpha = 0.0;
  3448. }
  3449. if ( uv2.x < 0.0 || uv2.x > 1.0 || uv2.y < 0.0 || uv2.y > 1.0 ) {
  3450. lalpha = 0.0;
  3451. }
  3452. }
  3453. lalpha *= mask;
  3454. calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
  3455. accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
  3456. return col;//n * 0.5 + 0.5;
  3457. }
  3458. `);return{cylindrical:e,spherical:t,uv:i,triplanar:r}}();var Wc=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h,c,d){super("v3"),this.nodeType="Depth",this.gradientType=e,this.smooth=t,this.near=i,this.far=r,this.isVector=s,this.isWorldSpace=a,this.origin=n,this.direction=o,this.colors=l,this.steps=h,this.isMask=d,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let i=`g${this.uuid.toString().replace(/-/g,"")}`,r=new De(`vec3 ${i}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${i}_MAX_COLORS], float steps[${i}_MAX_COLORS], bool isMask, float mask, float alpha, out float calpha) {
  3459. vec4 color = colors[0];
  3460. #ifdef ${i}_IS_VECTOR
  3461. #ifdef ${i}_LINEAR
  3462. #ifdef ${i}_WORLDSPACE
  3463. float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);
  3464. #else
  3465. float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);
  3466. #endif
  3467. #else
  3468. #ifdef ${i}_WORLDSPACE
  3469. float depth = vectorSphericalWorldSpaceDepth(origin, near, far);
  3470. #else
  3471. float depth = vectorSphericalObjectSpaceDepth(origin, near, far);
  3472. #endif
  3473. #endif
  3474. #else
  3475. float dist = length(vWPosition - cameraPosition);
  3476. float depth = ( dist - near ) / ( far - near );
  3477. #endif
  3478. float p;
  3479. #ifdef ${i}_SMOOTH
  3480. for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) {
  3481. p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
  3482. color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
  3483. }
  3484. #else
  3485. for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) {
  3486. p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);
  3487. color = mix(color, colors[i], p);
  3488. }
  3489. #endif
  3490. float lalpha = alpha * color.a * mask;
  3491. calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
  3492. accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
  3493. return color.rgb;
  3494. }`,[Wc.Nodes.vectorLinearWorldSpaceDepth,Wc.Nodes.vectorLinearObjectSpaceDepth,Wc.Nodes.vectorSphericalObjectSpaceDepth,Wc.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${i}_MAX_COLORS`,this.colors.value.length),this.smooth.value&&e.define(`${i}_SMOOTH`),this.isVector.value>.5&&e.define(`${i}_IS_VECTOR`),this.gradientType.value===0&&e.define(`${i}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${i}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let s=e.include(r),a=[];return a.push(this.near.build(e,"f")),a.push(this.far.build(e,"f")),a.push(this.origin.build(e,"v3")),a.push(this.direction.build(e,"v3")),a.push(this.colors.build(e,"v4[]")),a.push(this.steps.build(e,"f[]")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),e.format(s+"("+a.join(",")+")",this.getType(e),t)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},dT=Wc;dT.Nodes=function(){let e=new De(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
  3495. vec3 n = normalize(direction);
  3496. float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
  3497. return ( dist - near ) / ( far - near );
  3498. }`),t=new De(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
  3499. vec3 n = normalize(direction);
  3500. float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
  3501. return ( dist - near ) / ( far - near );
  3502. }`),i=new De(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
  3503. float dist = length(vWPosition - origin);
  3504. return ( dist - near ) / ( far - near );
  3505. }`),r=new De(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
  3506. float dist = length(position - origin);
  3507. return ( dist - near ) / ( far - near );
  3508. }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:i,vectorSphericalObjectSpaceDepth:r}}();var JX=class extends Wt{constructor(e,t,i,r,s,a,n,o){super("v3"),this.nodeType="Fresnel",this.color=e,this.bias=t,this.scale=i,this.intensity=r,this.factor=s,this.isMask=o,this.alpha=a,this.mode=n,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let i=new De(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
  3509. float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
  3510. float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;
  3511. calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
  3512. accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
  3513. return color;
  3514. }`),r=e.include(i),s=[];return s.push(this.color.build(e,"c")),s.push(this.bias.build(e,"f")),s.push(this.scale.build(e,"f")),s.push(this.intensity.build(e,"f")),s.push(this.factor.build(e,"f")),s.push(this.isMask.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.mode.build(e,"i")),s.push(this.calpha),e.format(r+"("+s.join(",")+")",this.getType(e),t)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},uT=class extends Wt{constructor(e,t,i,r,s,a,n,o,l){super("v3"),this.nodeType="Gradient",this.gradientType=e,this.smooth=t,this.colors=i,this.steps=r,this.offset=s,this.morph=a,this.angle=n,this.isMask=l,this.alpha=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(uT.Nodes.gradient),r=[];return r.push(this.gradientType.build(e,"i")),r.push(this.smooth.build(e,"b")),r.push(this.colors.build(e,"v4[]")),r.push(this.steps.build(e,"f[]")),r.push(this.offset.build(e,"v2")),r.push(this.morph.build(e,"v2")),r.push(this.angle.build(e,"f")),r.push(this.isMask.build(e,"b")),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},pT=uT;pT.Nodes=function(){return{gradient:new De(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {
  3515. vec4 color = colors[0];
  3516. vec2 m = morph / vUv.xy;
  3517. vec2 rot = vec2( 0.5 + m.x, m.y );
  3518. vec2 dt = vec2(
  3519. cos( angle ) * rot.x - sin( angle ) * rot.y,
  3520. sin( angle ) * rot.x + cos( angle ) * rot.y
  3521. );
  3522. vec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0;
  3523. float t = dot( pt, dt ) / dot( dt, dt );
  3524. if ( gradientType == 1 ) {
  3525. t = distance (
  3526. ( vUv + morph ) * 3.0,
  3527. ( vUv + offset ) + 1.0
  3528. ) + angle;
  3529. } else if ( gradientType == 2 ) {
  3530. float polar = atan(
  3531. vUv.x + morph.x - 0.5 + offset.x,
  3532. vUv.y + morph.y - 0.5 + offset.y
  3533. ) * -1.0;
  3534. t = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) );
  3535. }
  3536. float p;
  3537. if (smoothed) {
  3538. for ( int i = 1; i < GRAD_MAX; i++ ) {
  3539. p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
  3540. color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
  3541. }
  3542. } else {
  3543. for ( int i = 1; i < GRAD_MAX; i++ ) {
  3544. p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
  3545. color = mix(color, colors[i], p);
  3546. }
  3547. }
  3548. float lalpha = alpha * color.a * mask;
  3549. calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
  3550. accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
  3551. return color.xyz;
  3552. }`)}}();var fT=class extends Wt{constructor(e,t,i,r,s){super("v3"),this.nodeType="Matcap",this.texture=e,this.isMask=r,this.alpha=t,this.mode=i,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=s}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let i=e.include(fT.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let r=[];return r.push(this.texture.generate(e,"t")),r.push("normal"),r.push(this.isMask.build(e,"b")),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.mode.build(e,"i")),r.push(this.calpha),r.push(this.rotation.build(e,"f")),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},mT=fT;mT.Nodes=function(){return{matcap:new De(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {
  3553. vec3 viewDir = normalize( vViewPosition );
  3554. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3555. vec3 y = cross( viewDir, x );
  3556. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) );
  3557. uv = mat2( cos(rotation), sin(rotation), -sin(rotation), cos(rotation) ) * uv;
  3558. uv = uv * 0.495 + 0.5;
  3559. vec4 matcapColor = texture2D( matcapTex, uv );
  3560. float lalpha = alpha * mask;
  3561. calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
  3562. accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
  3563. return matcapColor.rgb;
  3564. }`)}}();var Xr=function(){let e=new De(`vec3 random3(vec3 c) {
  3565. float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
  3566. vec3 r;
  3567. r.z = fract(512.0*j);
  3568. j *= .125;
  3569. r.x = fract(512.0*j);
  3570. j *= .125;
  3571. r.y = fract(512.0*j);
  3572. return r-0.5;
  3573. }`),t=new De(`float simplexFast(vec3 p) {
  3574. vec3 s = floor(p + dot(p, vec3(F3)));
  3575. mediump vec3 x = p - s + dot(s, vec3(G3));
  3576. mediump vec3 hs = s;
  3577. mediump vec3 e = step(vec3(0.0), x - x.yzx);
  3578. mediump vec3 i1 = e*(1.0 - e.zxy);
  3579. mediump vec3 i2 = 1.0 - e.zxy*(1.0 - e);
  3580. mediump vec3 x1 = x - i1 + G3;
  3581. mediump vec3 x2 = x - i2 + 2.0*G3;
  3582. mediump vec3 x3 = x - 1.0 + 3.0*G3;
  3583. mediump vec4 w, d;
  3584. w.x = dot(x, x);
  3585. w.y = dot(x1, x1);
  3586. w.z = dot(x2, x2);
  3587. w.w = dot(x3, x3);
  3588. w = max(0.6 - w, 0.0);
  3589. d.x = dot(random3(hs), x);
  3590. d.y = dot(random3(hs + i1), x1);
  3591. d.z = dot(random3(hs + i2), x2);
  3592. d.w = dot(random3(hs + 1.0), x3);
  3593. w *= w;
  3594. w *= w;
  3595. d *= w;
  3596. return dot(d, vec4(52.0));
  3597. }`,[e]);t.keywords.F3=new Ut("float F3 0.3333333"),t.keywords.G3=new Ut("float G3 0.1666667");let i=new De(`float simplexPrecise(vec3 p) {
  3598. vec3 s = floor(p + dot(p, vec3(F3)));
  3599. vec3 x = p - s + dot(s, vec3(G3));
  3600. vec3 e = step(vec3(0.0), x - x.yzx);
  3601. vec3 i1 = e*(1.0 - e.zxy);
  3602. vec3 i2 = 1.0 - e.zxy*(1.0 - e);
  3603. vec3 x1 = x - i1 + G3;
  3604. vec3 x2 = x - i2 + 2.0*G3;
  3605. vec3 x3 = x - 1.0 + 3.0*G3;
  3606. vec4 w, d;
  3607. w.x = dot(x, x);
  3608. w.y = dot(x1, x1);
  3609. w.z = dot(x2, x2);
  3610. w.w = dot(x3, x3);
  3611. w = max(0.6 - w, 0.0);
  3612. d.x = dot(random3(s), x);
  3613. d.y = dot(random3(s + i1), x1);
  3614. d.z = dot(random3(s + i2), x2);
  3615. d.w = dot(random3(s + 1.0), x3);
  3616. w *= w;
  3617. w *= w;
  3618. d *= w;
  3619. return dot(d, vec4(52.0));
  3620. }`,[e]);i.keywords.F3=new Ut("float F3 0.3333333"),i.keywords.G3=new Ut("float G3 0.1666667");let r=new De(`float simplexFractal(vec3 m) {
  3621. mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
  3622. mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
  3623. mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
  3624. return 0.5333333 * simplexFast(m * rot1)
  3625. + 0.2666667 * simplexFast(2.0 * m * rot2)
  3626. + 0.1333333 * simplexFast(4.0 * m * rot3)
  3627. + 0.0666667 * simplexFast(8.0 * m);
  3628. }`,[t]),s=new De("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),a=new De("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),n=new De(`float simplexAshima(vec3 v) {
  3629. const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
  3630. const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
  3631. vec3 i = floor(v + dot(v, C.yyy) );
  3632. vec3 x0 = v - i + dot(i, C.xxx) ;
  3633. vec3 g = step(x0.yzx, x0.xyz);
  3634. vec3 l = 1.0 - g;
  3635. vec3 i1 = min( g.xyz, l.zxy );
  3636. vec3 i2 = max( g.xyz, l.zxy );
  3637. vec3 x1 = x0 - i1 + 1.0 * C.xxx;
  3638. vec3 x2 = x0 - i2 + 2.0 * C.xxx;
  3639. vec3 x3 = x0 - 1. + 3.0 * C.xxx;
  3640. i = mod(i, 289.0 );
  3641. vec4 p = permute( permute( permute(
  3642. i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
  3643. + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
  3644. + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
  3645. float n_ = 1.0/7.0; // N=7
  3646. vec3 ns = n_ * D.wyz - D.xzx;
  3647. vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N)
  3648. vec4 x_ = floor(j * ns.z);
  3649. vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
  3650. vec4 x = x_ *ns.x + ns.yyyy;
  3651. vec4 y = y_ *ns.x + ns.yyyy;
  3652. vec4 h = 1.0 - abs(x) - abs(y);
  3653. vec4 b0 = vec4( x.xy, y.xy );
  3654. vec4 b1 = vec4( x.zw, y.zw );
  3655. vec4 s0 = floor(b0)*2.0 + 1.0;
  3656. vec4 s1 = floor(b1)*2.0 + 1.0;
  3657. vec4 sh = -step(h, vec4(0.0));
  3658. vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
  3659. vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
  3660. vec3 p0 = vec3(a0.xy,h.x);
  3661. vec3 p1 = vec3(a0.zw,h.y);
  3662. vec3 p2 = vec3(a1.xy,h.z);
  3663. vec3 p3 = vec3(a1.zw,h.w);
  3664. vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
  3665. p0 *= norm.x;
  3666. p1 *= norm.y;
  3667. p2 *= norm.z;
  3668. p3 *= norm.w;
  3669. vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
  3670. m = m * m;
  3671. return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
  3672. dot(p2,x2), dot(p3,x3) ) );
  3673. }`,[s,a]),o=new De("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new De("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[o]),h=new De(`float noise(vec3 p){
  3674. vec3 a = floor(p);
  3675. vec3 d = p - a;
  3676. d = d * d * (3.0 - 2.0 * d);
  3677. vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);
  3678. vec4 k1 = perm(b.xyxy);
  3679. vec4 k2 = perm(k1.xyxy + b.zzww);
  3680. vec4 c = k2 + a.zzzz;
  3681. vec4 k3 = perm(c);
  3682. vec4 k4 = perm(c + 1.0);
  3683. vec4 o1 = fract(k3 * (1.0 / 41.0));
  3684. vec4 o2 = fract(k4 * (1.0 / 41.0));
  3685. vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
  3686. vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
  3687. return o4.y * d.y + o4.x * (1.0 - d.y);
  3688. }`,[l]),c=new De(`float fbm(vec3 x) {
  3689. float v = 0.0;
  3690. float a = 0.5;
  3691. vec3 shift = vec3(100);
  3692. for (int i = 0; i < NUM_OCTAVES; ++i) {
  3693. v += a * noise(x);
  3694. x = x * 2.0 + shift;
  3695. a *= 0.5;
  3696. }
  3697. return v;
  3698. }`,[h]);c.keywords.NUM_OCTAVES=new Ut("int NUM_OCTAVES 5");let d=new De("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),u=new De(`float perlin(vec3 P){
  3699. vec3 Pi0 = floor(P);
  3700. vec3 Pi1 = Pi0 + vec3(1.0);
  3701. Pi0 = mod(Pi0, 289.0);
  3702. Pi1 = mod(Pi1, 289.0);
  3703. vec3 Pf0 = fract(P);
  3704. vec3 Pf1 = Pf0 - vec3(1.0);
  3705. vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
  3706. vec4 iy = vec4(Pi0.yy, Pi1.yy);
  3707. vec4 iz0 = Pi0.zzzz;
  3708. vec4 iz1 = Pi1.zzzz;
  3709. vec4 ixy = permute(permute(ix) + iy);
  3710. vec4 ixy0 = permute(ixy + iz0);
  3711. vec4 ixy1 = permute(ixy + iz1);
  3712. vec4 gx0 = ixy0 / 7.0;
  3713. vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;
  3714. gx0 = fract(gx0);
  3715. vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
  3716. vec4 sz0 = step(gz0, vec4(0.0));
  3717. gx0 -= sz0 * (step(0.0, gx0) - 0.5);
  3718. gy0 -= sz0 * (step(0.0, gy0) - 0.5);
  3719. vec4 gx1 = ixy1 / 7.0;
  3720. vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;
  3721. gx1 = fract(gx1);
  3722. vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
  3723. vec4 sz1 = step(gz1, vec4(0.0));
  3724. gx1 -= sz1 * (step(0.0, gx1) - 0.5);
  3725. gy1 -= sz1 * (step(0.0, gy1) - 0.5);
  3726. vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
  3727. vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
  3728. vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
  3729. vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
  3730. vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
  3731. vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
  3732. vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
  3733. vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
  3734. vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
  3735. g000 *= norm0.x;
  3736. g010 *= norm0.y;
  3737. g100 *= norm0.z;
  3738. g110 *= norm0.w;
  3739. vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
  3740. g001 *= norm1.x;
  3741. g011 *= norm1.y;
  3742. g101 *= norm1.z;
  3743. g111 *= norm1.w;
  3744. float n000 = dot(g000, Pf0);
  3745. float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
  3746. float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
  3747. float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
  3748. float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
  3749. float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
  3750. float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
  3751. float n111 = dot(g111, Pf1);
  3752. vec3 fade_xyz = fade(Pf0);
  3753. vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
  3754. vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
  3755. float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
  3756. return 2.2 * n_xyz;
  3757. }`,[s,a,d]),p=new De(`float hashwithoutsine13(vec3 p3)
  3758. {
  3759. p3 = fract(p3 * .1031);
  3760. p3 += dot(p3, p3.yzx + 33.33);
  3761. return fract((p3.x + p3.y) * p3.z);
  3762. }`),f=new De(`vec3 hashwithoutsine33(vec3 p3)
  3763. {
  3764. p3 = fract(p3 * vec3(.1031, .1030, .0973));
  3765. p3 += dot(p3, p3.yxz+33.33);
  3766. return fract((p3.xxy + p3.yxx)*p3.zyx);
  3767. }`),g=new De(`float metric(in vec3 p)
  3768. {
  3769. // L2
  3770. return length(p);
  3771. // Chebyshev
  3772. // vec3 a = abs(p);
  3773. // return max(a.x, max(a.y, a.z));
  3774. }`),m=new De(`float smin( float a, float b, float k )
  3775. {
  3776. float h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (b - a) / k);
  3777. float correction = k * h * (1.0 - h);
  3778. return mix(b, a, h) - correction;
  3779. }`),v=new De(`float smax( float a, float b, float k )
  3780. {
  3781. float h = smoothstep(1.0, 0.0, 0.5 + 0.5 * (a - b) / k);
  3782. float correction = k * h * (1.0 - h);
  3783. return mix(a, b, h) + correction;
  3784. }`),y=new De(`float remap(float value, float input_min, float input_max, float output_min, float output_max) {
  3785. // Compute width of each interval
  3786. float input_width = input_max - input_min;
  3787. float output_width = output_max - output_min;
  3788. // Convert input range into a 0-1 range
  3789. float scaled = (value - input_min) / input_width;
  3790. // Convert the 0-1 range into a value in output range
  3791. return output_min + (scaled * output_width);
  3792. }`),x=new De(`float voronoi(in vec3 x, in int style, in float smoothness, in float seed, in int quality)
  3793. {
  3794. // Integer and fractional parts of this point's coordinates
  3795. ivec3 p = ivec3(floor(x));
  3796. vec3 f = fract(x);
  3797. // Different variables that we will use to construct noise:
  3798. //
  3799. // f1: distance to the closest feature point
  3800. // f2: distance to the second closest feature point
  3801. // e: distance to the closest edge (cell boundary)
  3802. //
  3803. // We also compute "smooth" versions of all of the above quantites, essentially
  3804. // replacing "hard" minimums with "smooth" minimums (described by IQ)
  3805. float f1_smooth = 8.0;
  3806. float f1 = 8.0;
  3807. float f2_smooth = 8.0;
  3808. float f2 = 8.0;
  3809. float e_smooth = 8.0;
  3810. float e = 8.0;
  3811. // Variables stored from closest cell
  3812. ivec3 mb;
  3813. vec3 mr;
  3814. int steps = quality;
  3815. for (int x = -steps; x <= steps; x++)
  3816. for (int y = -steps; y <= steps; y++)
  3817. for (int z = -steps; z <= steps; z++)
  3818. {
  3819. ivec3 b = ivec3(x, y, z);
  3820. vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;
  3821. float d = length(r);
  3822. f1_smooth = smin(d, f1_smooth, smoothness);
  3823. // Store un-smoothed distances too
  3824. if (d < f1)
  3825. {
  3826. f2 = f1;
  3827. f1 = d;
  3828. mb = ivec3(x, y, z);
  3829. mr = r;
  3830. }
  3831. else if (d < f2)
  3832. {
  3833. f2 = d;
  3834. }
  3835. }
  3836. // Second pass for edge distance
  3837. // skip for styles don't need
  3838. if (style != 0 && style != 5 && style != 7)
  3839. for (int x = -steps; x <= steps; x++)
  3840. for (int y = -steps; y <= steps; y++)
  3841. for (int z = -steps; z <= steps; z++)
  3842. {
  3843. // Start search at the cell that contains the closest point to "x" (found in 1st pass)
  3844. ivec3 b = mb + ivec3(x, y, z);
  3845. vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;
  3846. float d1 = dot(0.5 * (mr + r), (r - mr)); // IQ normalizes "r - mr" but that breaks things for the smooth version?
  3847. float d2 = dot(0.5 * (mr + r), normalize(r - mr));
  3848. e_smooth = smin(d1, e_smooth, smoothness);
  3849. e = min(e, d2);
  3850. // Also compute a smooth version of F2 in this pass
  3851. {
  3852. ivec3 b = ivec3(x, y, z);
  3853. if (b != mb)
  3854. {
  3855. vec3 r = vec3(b) + hashwithoutsine33(vec3(p + b) + seed) - f;
  3856. float d = length(r);
  3857. f2_smooth = smin(d, f2_smooth, smoothness);
  3858. }
  3859. }
  3860. }
  3861. // Different visualization modes
  3862. if (style == 0)
  3863. {
  3864. return f1_smooth;
  3865. }
  3866. if (style == 1)
  3867. {
  3868. return f2_smooth;
  3869. }
  3870. if (style == 2)
  3871. {
  3872. return f2_smooth - f1_smooth;
  3873. // "Pebbles" also cool
  3874. //return step(0.2, f2_smooth - f1_smooth);
  3875. }
  3876. if (style == 3)
  3877. {
  3878. // This one is really good for rock / stone effects
  3879. float a = f1;
  3880. float b = f2;
  3881. float k = 3.0;
  3882. float h = max(k - abs(a - b), 0.0) / k;
  3883. float final = min(a, b) - h * h * k * (1.0 / 4.0);
  3884. return final;
  3885. }
  3886. if (style == 4)
  3887. {
  3888. // Some random adjustments to make this style stand out more
  3889. return exp(5.0 * e_smooth);
  3890. }
  3891. if (style == 5)
  3892. {
  3893. return pow(f1_smooth, 3.0);
  3894. }
  3895. if (style == 6)
  3896. {
  3897. const float eps = 0.0125;
  3898. // Thicker lines as the user increases the smoothness slider
  3899. float thickness = smoothness * 0.25 + eps;
  3900. // Blurrier lines as the user increases the smoothness slider
  3901. float blur = pow(smoothness, 3.0) * 0.25 + eps;
  3902. return smoothstep(
  3903. thickness - thickness * blur,
  3904. thickness + thickness * blur,
  3905. e
  3906. );
  3907. }
  3908. if (style == 7)
  3909. {
  3910. return hashwithoutsine13(vec3(p + mb) + seed);
  3911. }
  3912. }
  3913. `,[p,f,g,m,v,y]);return{simplexFast:t,simplexPrecise:i,simplexFractal:r,simplexAshima:n,fbm:c,perlin:u,voronoi:x}}(),gT=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h,c,d,u,p,f,g,m,v,y){super("v3"),this.nodeType="Noise",this.scale=e,this.size=t,this.move=i,this.fA=r,this.fB=s,this.distortion=a,this.colorA=n,this.colorB=o,this.colorC=l,this.colorD=h,this.noiseType=d,this.voronoiStyle=p,this.highCut=f,this.lowCut=g,this.smoothness=m,this.seed=v,this.quality=y,this.isMask=u,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,i,r,s){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let a=["simplexFast","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseType.value],n=a=="voronoi"?`
  3914. float v = ${a}(st + move, voronoiStyle, smoothness, seed, quality);
  3915. // Apply clipping to colors
  3916. v = remap(v, lowCut, highCut, 0.0, 1.0);
  3917. v = smax(v, 0.0, smoothness * 0.25);
  3918. v = smin(v, 1.0, smoothness * 0.25);
  3919. // Note that the voronoi mode only uses colors "A" and "C" from the UI
  3920. vec4 color = mix(colorA, colorC, v);
  3921. `:`
  3922. vec3 q = vec3(${a}(st),
  3923. ${a}(st + vec3(1.0)),
  3924. ${a}(st + vec3(1.0)));
  3925. vec3 r = vec3(${a}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
  3926. ${a}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
  3927. ${a}(st * q));
  3928. float f = ${a}(st + r);
  3929. vec4 color;
  3930. color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
  3931. color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
  3932. color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));
  3933. `,o=new De(`vec3 ${a}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha)
  3934. {
  3935. // Prevent scale of zero
  3936. scale = max(abs(scale), 0.001);
  3937. vec3 st = position / size;
  3938. st /= scale;
  3939. ${n}
  3940. float lalpha = alpha * color.a * mask;
  3941. calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
  3942. accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
  3943. return clamp(color, 0.0, 1.0).rgb;
  3944. }`,[Xr.simplexFast,Xr.simplexFractal,Xr.simplexAshima,Xr.fbm,Xr.perlin,Xr.voronoi]),l=e.include(o),h=[];return h.push(this.scale.build(e,"f")),h.push(this.size.build(e,"v3")),h.push(this.move.build(e,"f")),h.push(this.fA.build(e,"v2")),h.push(this.fB.build(e,"v2")),h.push(this.distortion.build(e,"v2")),h.push(this.colorA.build(e,"v4")),h.push(this.colorB.build(e,"v4")),h.push(this.colorC.build(e,"v4")),h.push(this.colorD.build(e,"v4")),h.push(this.voronoiStyle.build(e,"i")),h.push(this.highCut.build(e,"f")),h.push(this.lowCut.build(e,"f")),h.push(this.smoothness.build(e,"f")),h.push(this.seed.build(e,"f")),h.push(this.quality.build(e,"i")),h.push(this.isMask.build(e,"b")),h.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),h.push(this.alpha.build(e,"f")),h.push(this.calpha),e.format(l+"("+h.join(",")+")",this.getType(e),t)}};gT.numOctaves=5;var vT=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h,c,d,u,p,f,g){super("v3"),this.nodeType="Outline",this.firstTime=!0,this.outlineColor=e,this.contourColor=t,this.outlineWidth=i,this.contourWidth=r,this.contourThreshold=s,this.outlineThreshold=a,this.contourFrequency=n,this.outlineSmoothing=o,this.contourDirection=l,this.positionalLines=h,this.compensation=c,this.resolution=d,this.normalMap=u,this.depthMap=p,this.pixelRatio=f,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let i=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${i}_offset`),this.firstTime){let r=this.outlineWidth.build(e,"f"),s=this.resolution.build(e,"v2"),a=this.compensation.build(e,"b"),n=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(r,"uniform float"),e.addVertexParsVariable(s,"uniform vec2"),e.addVertexParsVariable(a,"uniform bool"),e.addVertexParsVariable(n,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
  3945. vID = randomColor.r;
  3946. vec2 ${i}_offset = vec2(0.0);
  3947. if (${a}) {
  3948. vec4 ${i}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(transformed, 1.0));
  3949. // NOTE: For certain shapes, like spheres, we get incorrect extrusion when the
  3950. // normals face the camera directly. So we hackily fix this by offsetting the normal
  3951. // by a tiny amount.
  3952. vec3 ${i}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * extrudeNormal) + 0.0000001;
  3953. ${i}_offset = normalize(${i}_clipNormal.xy) / ${s} * (${r} / 2.0) * ${i}_clipPosition.w * 2.0 * ${n};
  3954. ${i}_clipPosition.xy += ${i}_offset;
  3955. // TODO(MAX): To handle multiple outline layers, we only want to extrude
  3956. // if this offset is the biggest of all the potential offsets
  3957. gl_Position = ${i}_clipPosition;
  3958. }
  3959. `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let r=e.include(vT.Nodes.outline),s=[];return s.push(this.outlineColor.build(e,"c")),s.push(this.contourColor.build(e,"c")),s.push(this.outlineWidth.build(e,"f")),s.push(this.contourWidth.build(e,"f")),s.push(this.contourThreshold.build(e,"f")),s.push(this.outlineThreshold.build(e,"f")),s.push(this.contourFrequency.build(e,"f")),s.push(this.outlineSmoothing.build(e,"f")),s.push(this.contourDirection.build(e,"v3")),s.push(this.positionalLines.build(e,"b")),s.push(this.resolution.build(e,"v2")),s.push(this.normalMap.getTexture(e,"t")),s.push(this.depthMap.getTexture(e,"t")),s.push(this.pixelRatio.build(e,"f")),s.push(this.compensation.build(e,"b")),s.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),s.push(this.alpha.build(e,"f")),s.push(this.calpha),this.firstTime=!this.firstTime,e.format(r+"("+s.join(",")+")",this.getType(e),t)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},yT=vT;yT.Nodes=function(){let e=new De(`
  3960. float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
  3961. {
  3962. vec2 halton = haltonSequence[frameIndex];
  3963. float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
  3964. float temporalAngle = temporalOffset * PI2;
  3965. vec2 texelSize = (vec2(1.0) / resolution);
  3966. vec2 offsetSize = texelSize * outlineWidth * pixelRatio;
  3967. vec2 uvSamples[9];
  3968. vec4 normalSamples[9];
  3969. uvSamples[0] = uv + vec2( -offsetSize.x, -offsetSize.y) + (vogelDiskSample(0, 9, temporalAngle) * texelSize);
  3970. uvSamples[1] = uv + vec2(0.0, -offsetSize.y) + (vogelDiskSample(1, 9, temporalAngle) * texelSize);
  3971. uvSamples[2] = uv + vec2( offsetSize.x, -offsetSize.y) + (vogelDiskSample(2, 9, temporalAngle) * texelSize);
  3972. uvSamples[3] = uv + vec2( -offsetSize.x, 0.0) + (vogelDiskSample(3, 9, temporalAngle) * texelSize);
  3973. uvSamples[4] = uv;
  3974. uvSamples[5] = uv + vec2( offsetSize.x, 0.0) + (vogelDiskSample(5, 9, temporalAngle) * texelSize);
  3975. uvSamples[6] = uv + vec2( -offsetSize.x, offsetSize.y) + (vogelDiskSample(6, 9, temporalAngle) * texelSize);
  3976. uvSamples[7] = uv + vec2(0.0, offsetSize.y) + (vogelDiskSample(7, 9, temporalAngle) * texelSize);
  3977. uvSamples[8] = uv + vec2( offsetSize.x, offsetSize.y) + (vogelDiskSample(8, 9, temporalAngle) * texelSize);
  3978. normalSamples[0] = texture2D(t, uvSamples[0]);
  3979. normalSamples[1] = texture2D(t, uvSamples[1]);
  3980. normalSamples[2] = texture2D(t, uvSamples[2]);
  3981. normalSamples[3] = texture2D(t, uvSamples[3]);
  3982. normalSamples[4] = texture2D(t, uvSamples[4]);
  3983. normalSamples[5] = texture2D(t, uvSamples[5]);
  3984. normalSamples[6] = texture2D(t, uvSamples[6]);
  3985. normalSamples[7] = texture2D(t, uvSamples[7]);
  3986. normalSamples[8] = texture2D(t, uvSamples[8]);
  3987. float depthBias = 0.0001;
  3988. // TODO(MAX): Can we somehow reduce the number of conditionals here with MATH?!
  3989. if (normalSamples[0].a != vID && normalSamples[0].a != 0.0) {
  3990. float depthAtSample = texture2D(d, uvSamples[0]).r + depthBias;
  3991. if (gl_FragCoord.z > depthAtSample) {
  3992. return 0.0;
  3993. }
  3994. }
  3995. if (normalSamples[1].a != vID && normalSamples[1].a != 0.0) {
  3996. float depthAtSample = texture2D(d, uvSamples[1]).r + depthBias;
  3997. if (gl_FragCoord.z > depthAtSample) {
  3998. return 0.0;
  3999. }
  4000. }
  4001. if (normalSamples[2].a != vID && normalSamples[2].a != 0.0) {
  4002. float depthAtSample = texture2D(d, uvSamples[2]).r + depthBias;
  4003. if (gl_FragCoord.z > depthAtSample) {
  4004. return 0.0;
  4005. }
  4006. }
  4007. if (normalSamples[3].a != vID && normalSamples[3].a != 0.0) {
  4008. float depthAtSample = texture2D(d, uvSamples[3]).r + depthBias;
  4009. if (gl_FragCoord.z > depthAtSample) {
  4010. return 0.0;
  4011. }
  4012. }
  4013. if (normalSamples[4].a != vID && normalSamples[4].a != 0.0) {
  4014. float depthAtSample = texture2D(d, uvSamples[4]).r + depthBias;
  4015. if (gl_FragCoord.z > depthAtSample) {
  4016. return 0.0;
  4017. }
  4018. }
  4019. if (normalSamples[5].a != vID && normalSamples[5].a != 0.0) {
  4020. float depthAtSample = texture2D(d, uvSamples[5]).r + depthBias;
  4021. if (gl_FragCoord.z > depthAtSample) {
  4022. return 0.0;
  4023. }
  4024. }
  4025. if (normalSamples[6].a != vID && normalSamples[6].a != 0.0) {
  4026. float depthAtSample = texture2D(d, uvSamples[6]).r + depthBias;
  4027. if (gl_FragCoord.z > depthAtSample) {
  4028. return 0.0;
  4029. }
  4030. }
  4031. if (normalSamples[7].a != vID && normalSamples[7].a != 0.0) {
  4032. float depthAtSample = texture2D(d, uvSamples[7]).r + depthBias;
  4033. if (gl_FragCoord.z > depthAtSample) {
  4034. return 0.0;
  4035. }
  4036. }
  4037. if (normalSamples[8].a != vID && normalSamples[8].a != 0.0) {
  4038. float depthAtSample = texture2D(d, uvSamples[8]).r + depthBias;
  4039. if (gl_FragCoord.z > depthAtSample) {
  4040. return 0.0;
  4041. }
  4042. }
  4043. vec3 sobel_edge_h = normalSamples[2].rgb + (2.0*normalSamples[5].rgb) + normalSamples[8].rgb - (normalSamples[0].rgb + (2.0*normalSamples[3].rgb) + normalSamples[6].rgb);
  4044. vec3 sobel_edge_v = normalSamples[0].rgb + (2.0*normalSamples[1].rgb) + normalSamples[2].rgb - (normalSamples[6].rgb + (2.0*normalSamples[7].rgb) + normalSamples[8].rgb);
  4045. float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));
  4046. return edgeNormal;
  4047. }
  4048. `);return{outline:new De(`vec3 outline(vec3 outlineColor, vec3 contourColor, float outlineWidth, float contourWidth, float outlineThreshold, float contourThreshold, float outlineSmoothing, float contourFrequency, vec3 contourDirection, bool positionalLines, vec2 resolution, sampler2D normalMap, sampler2D depthMap, float pixelRatio, bool compensation, float mask, float alpha, out float calpha) {
  4049. vec3 result = outlineColor;
  4050. float resultAlpha = 0.0;
  4051. vec3 N = normalize(vWNormal);
  4052. vec2 nuv = (gl_FragCoord.xy / resolution);
  4053. float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio);
  4054. resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample);
  4055. //resultAlpha = 1.0;
  4056. //result = vec3(sobelSample);
  4057. float t = 1.0 - contourThreshold;
  4058. if(positionalLines) {
  4059. vec3 NDir = position * contourDirection;
  4060. float NT = NDir.x + NDir.y + NDir.z;
  4061. float f = fract(NT * contourFrequency * 0.01);
  4062. float df = fwidth(NT * contourFrequency);
  4063. float g = smoothstep(df * (contourWidth * 0.01), df * (contourWidth * 0.01 * 2.0), f);
  4064. if (g < 1.0 && resultAlpha == 0.0) {
  4065. result = contourColor;
  4066. resultAlpha = 1.0;
  4067. }
  4068. }
  4069. else {
  4070. vec3 NDir = N * contourDirection;
  4071. float NT = NDir.x + NDir.y + NDir.z;
  4072. float df = fwidth(NT * contourThreshold);
  4073. float f = sin(NT * 1.0 * contourFrequency);
  4074. float g = smoothstep(0.0, df * contourWidth, 1.0 - f);
  4075. if (df > (t * 0.5) && g < 1.0 && resultAlpha == 0.0) {
  4076. result = contourColor;
  4077. resultAlpha = 1.0 - g;
  4078. }
  4079. }
  4080. float lalpha = alpha * resultAlpha * mask;
  4081. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  4082. accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
  4083. return result;
  4084. }`,[e])}}();var Qa=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h,c,d,u,p,f,g,m,v){super("v3"),this.nodeType="Pattern",this.style=e,this.projection=t,this.axis=i,this.blending=r,this.offset=s,this.colorA=a,this.colorB=n,this.frequency=o,this.size=l,this.variation=h,this.smoothness=c,this.zigzag=d,this.rotation=u,this.vertical=p,this.horizontal=f,this.sides=g,this.isMask=v,this.alpha=m,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let i;switch(this.style.value){case 0:i="circle";break;case 1:i="ring";break;case 2:i="polygon";break;case 3:i="xcross";break;case 4:i="diamond";break;case 5:i="checkerboard";break;case 6:i="line";break;case 7:i="wave";break;default:i="circle";break}let r=`g${this.uuid.toString().replace(/-/g,"")}`,s=new De(`float hashwithoutsine12(vec2 p)
  4085. {
  4086. vec3 p3 = fract(vec3(p.xyx) * .1031);
  4087. p3 += dot(p3, p3.yzx + 33.33);
  4088. return fract((p3.x + p3.y) * p3.z);
  4089. }`),a=new De(`vec2 rotate_uv(in vec2 uv, float a, bool repeat)
  4090. {
  4091. const float mid = 0.5;
  4092. float radians = a * (PI / 180.0);
  4093. vec2 rotated = vec2(
  4094. cos(radians) * (uv.x - mid) + sin(radians) * (uv.y - mid) + mid,
  4095. cos(radians) * (uv.y - mid) - sin(radians) * (uv.x - mid) + mid
  4096. );
  4097. return repeat ? fract(rotated): rotated;
  4098. }`),n="";if(this.projection.value===4){let c=this.style.value===2?`${i}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(uv0, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,d=this.style.value===2?`${i}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(uv1, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,u=this.style.value===2?`${i}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(uv2, frequency, size, variation, smoothness_remapped, zigzag, rotation)`;n=`
  4099. vec3 p = position;
  4100. float factor = 0.0125;
  4101. vec2 uv0 = fract(p.xy * factor);
  4102. vec2 uv1 = fract(p.zy * factor);
  4103. vec2 uv2 = fract(p.xz * factor);
  4104. uv0 = rotate_uv(uv0 + offset, rotation, true);
  4105. uv1 = rotate_uv(uv1 + offset, rotation, true);
  4106. uv2 = rotate_uv(uv2 + offset, rotation, true);
  4107. float d0 = ${c};
  4108. float d1 = ${d};
  4109. float d2 = ${u};
  4110. // Range from 3 to 128 seems to be good
  4111. float exponent = (1.0 - blending) * 125.0 + 3.0;
  4112. vec3 n = vObjectNormal;
  4113. vec3 weights = abs(normalize(n));
  4114. weights = pow(weights, vec3(exponent));
  4115. weights /= dot(weights, vec3(1.0));
  4116. d0 *= weights.z;
  4117. d1 *= weights.x;
  4118. d2 *= weights.y;
  4119. float draw = d0 + d1 + d2;
  4120. vec2 custom_uv = uv0 * weights.z + uv1 * weights.x + uv2 * weights.y;
  4121. `}else{let c=this.style.value===2?`${i}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation, sides)`:`${i}(custom_uv, frequency, size, variation, smoothness_remapped, zigzag, rotation)`,d="";this.axis.value===0?d=`float radius = length(p);
  4122. float theta = atan(p.y, p.z);
  4123. float phi = acos(p.x / radius);`:this.axis.value===1?d=`float radius = length(p);
  4124. float theta = atan(p.x, p.z);
  4125. float phi = acos(p.y / radius);`:(this.axis.value,d=`float radius = length(p);
  4126. float theta = atan(p.y, p.x);
  4127. float phi = acos(p.z / radius);`);let u="";switch(this.projection.value){case 0:u="custom_uv = vUv.st;";break;case 1:break;case 2:u=`
  4128. vec3 p = position;
  4129. ${d}
  4130. custom_uv = vec2(theta, phi);
  4131. custom_uv /= PI;
  4132. `;break}n=`
  4133. vec2 custom_uv;
  4134. ${u}
  4135. custom_uv += offset;
  4136. custom_uv = fract(custom_uv);
  4137. custom_uv = rotate_uv(custom_uv, rotation, true);
  4138. float draw = ${c};
  4139. `}let o=new De(`vec3 ${r}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) {
  4140. const float TWO_PI = PI * 2.0;
  4141. float smoothness_remapped = pow(smoothness, 5.0);
  4142. ${n}
  4143. // Construct final output color
  4144. vec4 color = mix(colorA, colorB, draw);
  4145. color.a = clamp(color.a, 0.0, 1.0);
  4146. // Apply cuts
  4147. color.a *=
  4148. step(vertical.x, custom_uv.y) *
  4149. step(custom_uv.y, vertical.y);
  4150. color.a *=
  4151. step(horizontal.x, abs(custom_uv.x)) *
  4152. step(abs(custom_uv.x), horizontal.y);
  4153. // Accumulate alpha
  4154. float lalpha = alpha * clamp(color.a, 0.0, 1.0) * mask;
  4155. calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
  4156. accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
  4157. return clamp(color, 0.0, 1.0).rgb;
  4158. }`,[a,s,Qa.DrawFunctions.circle,Qa.DrawFunctions.ring,Qa.DrawFunctions.polygon,Qa.DrawFunctions.cross,Qa.DrawFunctions.diamond,Qa.DrawFunctions.checkerboard,Qa.DrawFunctions.line,Qa.DrawFunctions.wave]),l=e.include(o),h=[];return h.push("normal"),h.push(this.blending.build(e,"f")),h.push(this.style.build(e,"i")),h.push(this.offset.build(e,"v2")),h.push(this.colorA.build(e,"v4")),h.push(this.colorB.build(e,"v4")),h.push(this.frequency.build(e,"v2")),h.push(this.size.build(e,"f")),h.push(this.variation.build(e,"f")),h.push(this.smoothness.build(e,"f")),h.push(this.zigzag.build(e,"f")),h.push(this.rotation.build(e,"f")),h.push(this.vertical.build(e,"v2")),h.push(this.horizontal.build(e,"v2")),h.push(this.sides.build(e,"i")),h.push(this.isMask.build(e,"b")),h.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),h.push(this.alpha.build(e,"f")),h.push(this.calpha),e.format(l+"("+h.join(",")+")",this.getType(e),t)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),t)}},xT=Qa;xT.DrawFunctions=function(){let e=new De(`float hashwithoutsine12(vec2 p) {
  4159. vec3 p3 = fract(vec3(p.xyx) * 0.1031);
  4160. p3 += dot(p3, p3.yzx + 33.33);
  4161. return fract((p3.x + p3.y) * p3.z);
  4162. }`),t=new De(`vec2 tile_and_center(in vec2 uv, in vec2 frequency, in float variation, in float zigzag, in float rotation) {
  4163. // Create tiles in UV-space
  4164. uv *= frequency;
  4165. // Integer coords
  4166. vec2 i = floor(uv);
  4167. // Offset every other row based on zigzag param, then compute fractional coords
  4168. float row_offset = mod(i.y, 2.0);
  4169. uv.x += row_offset * zigzag;
  4170. vec2 f = fract(uv);
  4171. // Rotate the tile itself:
  4172. // const float mid = 0.5;
  4173. // f = vec2(
  4174. // cos(rotation) * (f.x - mid) + sin(rotation) * (f.y - mid) + mid,
  4175. // cos(rotation) * (f.y - mid) - sin(rotation) * (f.x - mid) + mid
  4176. // );
  4177. // f = fract(f);
  4178. f = f * 2.0 - 1.0;
  4179. // Recompute integer coords after shifting - then, random value per tile
  4180. i = floor(uv);
  4181. float rand = (hashwithoutsine12(i) * 5.0 + 1.0);
  4182. float jitter = mix(1.0, rand, variation);
  4183. f *= jitter;
  4184. return f;
  4185. }`,[e]),i=new De(`float circle(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
  4186. vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
  4187. return smoothstep(
  4188. -smoothness,
  4189. smoothness,
  4190. length(f) - size
  4191. );
  4192. }`,[t]),r=new De(`float ring(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
  4193. vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
  4194. float d = length(f);
  4195. const float inner_width = 0.5;
  4196. float outer = smoothstep(-smoothness, smoothness, d - size);
  4197. float inner = smoothstep(-smoothness, smoothness, d - size * inner_width);
  4198. return outer + (1.0 - inner);
  4199. }`,[t]),s=new De(`float sdf_ngon(in vec2 p, in float r, in int n) {
  4200. float an = (PI * 2.0) / float(n);
  4201. float he = r * tan(0.5 * an);
  4202. // Rotate to first sector
  4203. p = -p.yx;
  4204. float bn = an * floor((atan(p.y, p.x) + 0.5 * an) / an);
  4205. vec2 cs = vec2(cos(bn), sin(bn));
  4206. p = mat2(cs.x, -cs.y, cs.y, cs.x)*p;
  4207. // Side of polygon
  4208. return length(p - vec2(r, clamp(p.y, -he, he))) * sign(p.x - r);
  4209. }
  4210. float polygon(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) {
  4211. vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
  4212. return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides));
  4213. }`,[t]),a=new De(`float sdf_cross(in vec2 p, in vec2 b, float r ) {
  4214. p = abs(p);
  4215. p = (p.y > p.x) ? p.yx : p.xy;
  4216. vec2 q = p - b;
  4217. float k = max(q.y, q.x);
  4218. vec2 w = (k > 0.0) ? q : vec2(b.y - p.x, -k);
  4219. return sign(k) * length(max(w, 0.0)) + r;
  4220. }
  4221. // Avoid namespace conflicts
  4222. float xcross(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
  4223. vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
  4224. return smoothstep(-smoothness, smoothness, sdf_cross(f, vec2(size, size * 0.25), smoothness));
  4225. }`,[t]),n=new De(`float ndot(vec2 a, vec2 b) {
  4226. return a.x*b.x - a.y*b.y;
  4227. }
  4228. float sdf_diamond(in vec2 p, in vec2 b) {
  4229. p = abs(p);
  4230. float h = clamp(ndot(b - 2.0 * p, b) / dot(b, b), -1.0, 1.0);
  4231. float d = length(p - 0.5 * b * vec2(1.0 - h, 1.0 + h));
  4232. return d * sign(p.x * b.y + p.y * b.x - b.x * b.y);
  4233. }
  4234. float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
  4235. vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
  4236. return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size)));
  4237. }`,[t]),o=new De(`float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
  4238. uv *= frequency;
  4239. vec2 i = floor(uv);
  4240. float offset = mod(i.y, 2.0);
  4241. uv.x += offset + zigzag * offset;
  4242. float x = floor(uv.x);
  4243. return mod(x, 2.0);
  4244. }`),l=new De(`float line(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
  4245. vec2 f = tile_and_center(uv, frequency, 0.0, zigzag, rotation);
  4246. // Different approach for variation param here
  4247. float row = floor(uv * frequency).y;
  4248. float rand = hashwithoutsine12(vec2(row));
  4249. float s = mix(size, size * rand, variation);
  4250. return smoothstep(
  4251. s - smoothness,
  4252. s + smoothness,
  4253. abs(f.y)
  4254. );
  4255. }`,[t]),h=new De(`// Uses bisection
  4256. float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) {
  4257. // Convert all data to a primitive cosine wave
  4258. p = c * (p - vec2(d, a));
  4259. const float TWO_PI = PI * 2.0;
  4260. // Reduce to principal half cycle
  4261. p.x = mod(p.x, TWO_PI);
  4262. if (p.x > PI) {
  4263. p.x = TWO_PI - p.x;
  4264. }
  4265. // Find zero of derivative (minimize distance)
  4266. float xa = 0.0;
  4267. float xb = TWO_PI;
  4268. // 24 bit precision
  4269. for (int i = 0; i < 24; i++) {
  4270. float x = 0.5 * (xa + xb);
  4271. float y = x - p.x + b * c * sin(x) * (p.y - b * c * cos(x));
  4272. if (y < 0.0) xa = x;
  4273. else xb = x;
  4274. }
  4275. float x = 0.5 * (xa + xb);
  4276. // Compute distance
  4277. vec2 q = vec2(x, b * c * cos(x));
  4278. return length(p - q) / c;
  4279. }
  4280. float wave(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
  4281. float repeat = frequency.x;
  4282. uv *= repeat;
  4283. vec2 i = floor(uv);
  4284. float row_offset = mod(i.y, 2.0);
  4285. uv.x += row_offset * zigzag;
  4286. vec2 f = vec2(uv.x, fract(uv.y));
  4287. // Generalized cosine: y(x) = a + b * cos(cx + d)
  4288. const float amplitude = 0.125;
  4289. float wave_frequency = frequency.y * 0.1;
  4290. float distance_estimate = udf_cos(f, 0.50, amplitude, wave_frequency * (2.0 * PI), 0.0);
  4291. // Different approach for variation param here
  4292. float rand = hashwithoutsine12(vec2(i.y));
  4293. float s = mix(size, size * rand, variation);
  4294. return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
  4295. }`);return{tileAndCenter:t,circle:i,ring:r,polygon:s,cross:a,diamond:n,checkerboard:o,line:l,wave:h}}();var bT=class extends Wt{constructor(e,t,i,r,s,a,n,o){super("v3"),this.nodeType="Rainbow",this.filmThickness=e,this.movement=t,this.wavelengths=i,this.noiseStrength=r,this.noiseScale=s,this.offset=a,this.isMask=o,this.alpha=n,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(bT.Nodes.rainbow),r=[];return r.push(this.filmThickness.build(e,"f")),r.push(this.movement.build(e,"f")),r.push(this.wavelengths.build(e,"v3")),r.push(this.noiseStrength.build(e,"f")),r.push(this.noiseScale.build(e,"f")),r.push(this.offset.build(e,"v3")),r.push(this.isMask.build(e,"b")),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},wT=bT;wT.Nodes=function(){let e=new De(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
  4296. float f = 0.0;
  4297. if (noiseStrength != 0.0) {
  4298. vec3 st = position / noiseScale;
  4299. float noise = simplexFast(1.6 * st + vec3(1.8, 1.5, 1.9) * simplexFast(st) + vec3(1.7, 9.2, 1.0));
  4300. f = noise * noiseStrength;
  4301. }
  4302. vec3 waves = wavelengths * vec3(1.0, 0.8, 0.6) + 1.0;
  4303. float angle = dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal));
  4304. mediump vec3 color = cos((((filmThickness + f) / waves) * angle) + movement);
  4305. return .5 + .5 * color;
  4306. }`,[Xr.simplexFast]);return{rainbow:new De(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {
  4307. mediump vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
  4308. float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
  4309. float lalpha = alpha * rainbowContribution * mask;
  4310. calpha = mix(lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0), lalpha, float(isMask));
  4311. accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
  4312. return res;
  4313. }`,[e])}}();var _T=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h){super("v3"),this.nodeType="Toon",this.positioning=e,this.colors=t,this.steps=i,this.source=r,this.isWorldSpace=s,this.noiseStrength=a,this.noiseScale=n,this.shadowColor=o,this.offset=l,this.alpha=h,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let i=e.include(_T.Nodes.toon),r=[];return r.push(this.positioning.build(e,"i")),r.push(this.colors.build(e,"v4[]")),r.push(this.steps.build(e,"f[]")),r.push(this.source.build(e,"v3")),r.push(this.isWorldSpace.build(e,"b")),r.push(this.noiseStrength.build(e,"f")),r.push(this.noiseScale.build(e,"f")),r.push(this.shadowColor.build(e,"v4")),r.push(this.offset.build(e,"v3")),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},ST=_T;ST.Nodes=function(){let e=new De(`float rand(float n) {
  4314. return fract(sin(n) * 43758.5453123);
  4315. }`),t=new De(`float hash1(float p) {
  4316. p = fract(p * 0.011);
  4317. p *= p + 7.5;
  4318. p *= p + p;
  4319. return fract(p);
  4320. }`),i=new De(`float valueNoise(vec3 x) {
  4321. const vec3 step = vec3(110, 241, 171);
  4322. vec3 i = floor(x);
  4323. vec3 f = fract(x);
  4324. // For performance, compute the base input to a 1D hash from the integer part of the argument and the
  4325. // incremental change to the 1D based on the 3D -> 1D wrapping
  4326. float n = dot(i, step);
  4327. vec3 u = f * f * (3.0 - 2.0 * f);
  4328. return mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x),
  4329. mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
  4330. mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),
  4331. mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
  4332. }`,[t]),r=new De(`vec3 hash3(vec3 x) {
  4333. x = vec3(dot(x,vec3(127.1, 311.7, 74.7)),
  4334. dot(x,vec3(269.5, 183.3, 246.1)),
  4335. dot(x,vec3(113.5, 271.9, 124.6)));
  4336. return fract(sin(x)*43758.5453123);
  4337. }`),s=new De(`vec3 voronoiNoise(in vec3 x)
  4338. {
  4339. vec3 p = floor(x);
  4340. vec3 f = fract(x);
  4341. float id = 0.0;
  4342. vec2 res = vec2(100.0);
  4343. for(int k=-1; k<=1; k++)
  4344. for(int j=-1; j<=1; j++)
  4345. for(int i=-1; i<=1; i++)
  4346. {
  4347. vec3 b = vec3(float(i), float(j), float(k));
  4348. // Comment out the "+ hash(p + b);" part below to get "square" cells
  4349. vec3 r = vec3(b) - f + hash3(p + b);
  4350. float d = dot(r, r);
  4351. if (d < res.x)
  4352. {
  4353. id = dot(p + b, vec3(1.0, 57.0, 113.0));
  4354. res = vec2(d, res.x);
  4355. }
  4356. else if (d < res.y)
  4357. {
  4358. res.y = d;
  4359. }
  4360. }
  4361. return vec3(sqrt(res), abs(id));
  4362. }
  4363. `,[r]);return{toon:new De(`vec3 toon(int positioning, vec4 colors[COLORS_MAX], float steps[COLORS_MAX], vec3 source, bool isWorldSpace, float noiseStrength, float noiseScale, vec4 shadowColor, vec3 offset, float mask, float alpha, out float calpha) {
  4364. float t = 0.0;
  4365. float shadow = 1.0;
  4366. if (positioning == 0) {
  4367. // Can't do this mode if lighting is "none"
  4368. #if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD))
  4369. // Algorithm from Chapter 10 of Graphics Shaders
  4370. const vec3 weights = vec3(0.2125, 0.7154, 0.0721);
  4371. vec3 lpos;
  4372. vec3 l;
  4373. float dproduct;
  4374. #if (NUM_POINT_LIGHTS > 0)
  4375. #if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0)
  4376. PointLightShadow pointLightShadow;
  4377. #endif
  4378. #pragma unroll_loop_start
  4379. for (int i = 0; i < NUM_POINT_LIGHTS; i++) {
  4380. // Light positions are in view-space for some reason?
  4381. lpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
  4382. l = normalize(lpos - worldPosition);
  4383. dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
  4384. // TODO: we want to use "intensity" but it isn't available in the shader code
  4385. //dproduct += dot(pointLights[UNROLLED_LOOP_INDEX].color, weights);
  4386. t = max(t, dproduct);
  4387. // Accumulate shadow contribution
  4388. #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS)
  4389. pointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX];
  4390. shadow *= getPointShadow(
  4391. pointShadowMap[UNROLLED_LOOP_INDEX],
  4392. pointLightShadow.shadowMapSize,
  4393. pointLightShadow.shadowBias,
  4394. pointLightShadow.shadowRadius,
  4395. vPointShadowCoord[UNROLLED_LOOP_INDEX],
  4396. pointLightShadow.shadowCameraNear,
  4397. pointLightShadow.shadowCameraFar);
  4398. #endif
  4399. }
  4400. #pragma unroll_loop_end
  4401. #endif
  4402. #if NUM_DIR_LIGHTS > 0
  4403. #if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0)
  4404. DirectionalLightShadow directionalLightShadow;
  4405. #endif
  4406. #pragma unroll_loop_start
  4407. for (int i = 0; i < NUM_DIR_LIGHTS; i++) {
  4408. // Use the direction vector for directional lights instead
  4409. l = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz;
  4410. dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
  4411. t = max(t, dproduct);
  4412. // Accumulate shadow contribution
  4413. #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS)
  4414. directionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX];
  4415. shadow *= getShadow(
  4416. UNROLLED_LOOP_INDEX,
  4417. directionalShadowMap[UNROLLED_LOOP_INDEX],
  4418. directionalLightShadow.shadowMapSize,
  4419. directionalLightShadow.shadowBias,
  4420. directionalLightShadow.shadowRadius,
  4421. vDirectionalShadowCoord[UNROLLED_LOOP_INDEX]);
  4422. #endif
  4423. }
  4424. #pragma unroll_loop_end
  4425. #endif
  4426. #if NUM_SPOT_LIGHTS > 0
  4427. #if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0)
  4428. SpotLightShadow spotLightShadow;
  4429. #endif
  4430. #pragma unroll_loop_start
  4431. for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {
  4432. lpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
  4433. l = normalize(lpos - worldPosition);
  4434. dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
  4435. t = max(t, dproduct);
  4436. // Accumulate shadow contribution
  4437. #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS)
  4438. spotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX];
  4439. shadow *= getShadow(
  4440. UNROLLED_LOOP_INDEX,
  4441. spotShadowMap[UNROLLED_LOOP_INDEX],
  4442. spotLightShadow.shadowMapSize,
  4443. spotLightShadow.shadowBias,
  4444. spotLightShadow.shadowRadius,
  4445. vSpotLightCoord[UNROLLED_LOOP_INDEX]);
  4446. #endif
  4447. }
  4448. #pragma unroll_loop_end
  4449. #endif
  4450. t = clamp(t, 0.0, 1.0);
  4451. #endif
  4452. } else if (positioning == 1) {
  4453. vec3 origin = mix(position, worldPosition, float(isWorldSpace));
  4454. vec3 direction = normalize(source - origin);
  4455. t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;
  4456. } else {
  4457. vec3 origin = worldPosition;
  4458. vec3 source = cameraPosition - offset;
  4459. vec3 direction = normalize(source - origin);
  4460. t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;
  4461. }
  4462. if (noiseStrength > 0.0) {
  4463. // Distort with noise
  4464. vec3 st = position / noiseScale;
  4465. // Voronoi "smooth" noise
  4466. float noise = 1.0 - voronoiNoise(st).x;
  4467. // Voronoi cellular noise
  4468. //float noise = 1.0 - rand(voronoiNoise(st).z);
  4469. // Position warp noise
  4470. // vec3 offset = vec3(
  4471. // simplexFast(st),
  4472. // simplexFast(st + vec3(111.1, 143.89, 217.19)),
  4473. // simplexFast(st + vec3(171.1, 247.89, 117.23))
  4474. // );
  4475. // st += offset;
  4476. // float noise = valueNoise(st);
  4477. t += noise * noiseStrength;
  4478. }
  4479. t = clamp(t, 0.0, 1.0);
  4480. // Compute ramp color
  4481. float p;
  4482. vec4 color = colors[0];
  4483. for (int i = 1; i < COLORS_MAX; i++) {
  4484. p = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0);
  4485. color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
  4486. }
  4487. // Incorporate custom shadow color
  4488. if (positioning == 0) {
  4489. vec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a);
  4490. color.rgb = mix(blendedShadow, color.rgb, shadow);
  4491. }
  4492. // Accumulate alpha as usual
  4493. float lalpha = alpha * color.a * mask;
  4494. calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
  4495. accumAlpha += (1.0 - accumAlpha) * lalpha;
  4496. return color.xyz;
  4497. }`,[Xr.simplexFast,e,i,s])}}();var $X=function(){return{textureBicubic:new De(`float w0( float a ) {
  4498. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  4499. }
  4500. float w1( float a ) {
  4501. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  4502. }
  4503. float w2( float a ){
  4504. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  4505. }
  4506. float w3( float a ) {
  4507. return ( 1.0 / 6.0 ) * ( a * a * a );
  4508. }
  4509. // g0 and g1 are the two amplitude functions
  4510. float g0( float a ) {
  4511. return w0( a ) + w1( a );
  4512. }
  4513. float g1( float a ) {
  4514. return w2( a ) + w3( a );
  4515. }
  4516. // h0 and h1 are the two offset functions
  4517. float h0( float a ) {
  4518. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  4519. }
  4520. float h1( float a ) {
  4521. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  4522. }
  4523. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  4524. uv = uv * texelSize.zw + 0.5;
  4525. vec2 iuv = floor( uv );
  4526. vec2 fuv = fract( uv );
  4527. float g0x = g0( fuv.x );
  4528. float g1x = g1( fuv.x );
  4529. float h0x = h0( fuv.x );
  4530. float h1x = h1( fuv.x );
  4531. float h0y = h0( fuv.y );
  4532. float h1y = h1( fuv.y );
  4533. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  4534. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  4535. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  4536. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  4537. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  4538. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  4539. }
  4540. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  4541. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  4542. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  4543. vec2 fLodSizeInv = 1.0 / fLodSize;
  4544. vec2 cLodSizeInv = 1.0 / cLodSize;
  4545. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  4546. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  4547. return mix( fSample, cSample, fract( lod ) );
  4548. }`)}}();function eY(e,t){return e>=t?new j(t/e,1):new j(1,e/t)}var AT=class extends Wt{constructor(e,t,i,r,s,a,n,o){super("v3"),this.nodeType="Transmission",this.thickness=e,this.ior=t,this.roughness=i,this.transmissionSamplerSize=r,this.transmissionSamplerMap=s,this.transmissionDepthMap=a,this.aspectRatio=n,this.alpha=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,st.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let i=e.include(AT.Nodes.transmission),r=[];return r.push(this.thickness.build(e,"f")),r.push(this.ior.build(e,"f")),r.push(this.roughness.build(e,"f")),r.push(this.transmissionSamplerSize.build(e,"v2")),r.push(this.transmissionSamplerMap.getTexture(e,"t")),r.push(this.transmissionDepthMap.getTexture(e,"t")),r.push(this.aspectRatio.build(e,"v2")),r.push("normal"),r.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},MT=AT;MT.Nodes=function(){let e=new De(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
  4549. // Slightly modified version of this:
  4550. // https://www.shadertoy.com/view/ltScRG
  4551. // Special case for blur == 0.0
  4552. if (lod == 0.0) {
  4553. #ifdef TEXTURE_LOD_EXT
  4554. return texture2DLodEXT( sp, U, 0.0).rgb;
  4555. #else
  4556. return textureLod( sp, U, 0.0).rgb;
  4557. #endif
  4558. }
  4559. vec2 texelSize = vec2(1.0) / resolution;
  4560. vec2 halton = haltonSequence[frameIndex];
  4561. float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
  4562. float temporalAngle = temporalOffset * PI2;
  4563. vec3 res = vec3(0.0);
  4564. vec2 uv = vec2(0.0);
  4565. vec2 offset = vec2(0.0);
  4566. vec2 vogelSample = vec2(0.0);
  4567. for (int i = 0; i < NUM_SAMPLES; i++) {
  4568. vogelSample = vogelDiskSample(i, NUM_SAMPLES, temporalAngle) * texelSize;
  4569. offset = vogelSample * scale * (lod * 10.0); // TODO: used to be hardcoded to 20
  4570. uv = U + offset;
  4571. float opaqueDepth = unpackRGBAToDepth(textureLod(dm, uv, lod));
  4572. if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) {
  4573. uv = unrefractedU;
  4574. lod = lod > 4.0 ? lod : lod / 2.0;
  4575. }
  4576. res += textureLod(sp, uv, lod).rgb;
  4577. }
  4578. return res / float(NUM_SAMPLES);
  4579. }`),t=new De(`vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
  4580. // Direction of refracted light.
  4581. vec3 refractionVector = refract( -v, n, 1.0 / ior );
  4582. // Compute rotation-independant scaling of the model matrix.
  4583. vec3 modelScale;
  4584. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  4585. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  4586. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  4587. // The thickness is specified in local space
  4588. return normalize( refractionVector ) * thickness * modelScale;
  4589. }`),i=new De(`float applyIorToRoughness( float roughness, float ior ) {
  4590. // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
  4591. // an IOR of 1.5 results in the default amount of microfacet refraction.
  4592. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  4593. }`),r=new De(`vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
  4594. // Threejs exports do not pass a depth map to this shader, so we have to fallback to the "Threejs method of blurring" - see
  4595. // also the code in convertTransmission.ts, which runs during export
  4596. #ifdef IS_THREEJS_EXPORT
  4597. float lod = log2(transmissionSamplerSize.x) * applyIorToRoughness(roughness / 5.0, ior);
  4598. return textureBicubic(transmissionSamplerMap, fragCoord.xy, lod).rgb;
  4599. #else
  4600. float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  4601. float lod = applyIorToRoughness(roughness, ior);
  4602. return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
  4603. #endif
  4604. }`,[$X.textureBicubic,i,e]),s=new De(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
  4605. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  4606. vec3 refractedRayExit = position + transmissionRay;
  4607. // Project refracted vector on the framebuffer, while mapping to normalized device coordinates.
  4608. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  4609. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  4610. refractionCoords += 1.0;
  4611. refractionCoords /= 2.0;
  4612. vec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 );
  4613. vec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w;
  4614. unrefractedCoords += 1.0;
  4615. unrefractedCoords /= 2.0;
  4616. // Sample framebuffer to get pixel the refracted ray hits.
  4617. return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
  4618. }`,[r,t]);return{transmission:new De(`vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) {
  4619. vec3 v = vec3(0.);
  4620. if (isOrthographic) {
  4621. v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4622. } else {
  4623. v = normalize(vWPosition - cameraPosition);
  4624. }
  4625. vec3 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio );
  4626. float lalpha = alpha * mask;
  4627. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  4628. accumAlpha += ( 1.0 - accumAlpha ) * alpha;
  4629. return transmission;
  4630. }`,[s])}}();var ay=(e=>(e.NOISE="noise",e.MAP="map",e))(ay||{}),ET=class extends Wt{constructor(e,t,i,r,s,a,n,o,l,h,c){super("v3"),this.displacementTypeIndex=new Yt(0),this.nodeType="VertexDisplacement",this.intensity=e,this.movementOrTexture=t,Object.values(ay)[this.displacementTypeIndex.value]==="map"&&(this.mat=new oT(this.movementOrTexture.value.matrix)),this.cropOrOffset=i,this.scale=h,this.noiseFunctionIndex=c,this.voronoiStyle=r,this.smoothness=s,this.seed=a,this.highCut=n,this.lowCut=o,this.quality=l}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let i,r=[];switch(r.push("displaced_position"),r.push("displaced_normal"),Object.values(ay)[this.displacementTypeIndex.value]){case"map":{i=e.include(ET.Nodes.map),r.push(this.movementOrTexture.getTexture(e,"t")),r.push("uv"),r.push(this.cropOrOffset.build(e,"f")),this.mat&&r.push(this.mat.build(e,"mat3"));break}case"noise":{let s=["simplexPrecise","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseFunctionIndex.value],a=new De(`vec3 orthogonal(vec3 v) {
  4631. return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
  4632. }`),n=s=="voronoi"?`
  4633. float v = ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
  4634. v = remap(v, lowCut, highCut, 0.0, 1.0);
  4635. v = smax(v, 0.0, smoothness * 0.25);
  4636. v = smin(v, 1.0, smoothness * 0.25);
  4637. return p + n * v * intensity;
  4638. `:`
  4639. return p + n * ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
  4640. `,o=new De(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality) {
  4641. ${n}
  4642. }`,[Xr.simplexPrecise,Xr.simplexFractal,Xr.simplexAshima,Xr.fbm,Xr.perlin,Xr.voronoi]),l=new De(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) {
  4643. vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
  4644. vec3 tangent1 = orthogonal(normal);
  4645. vec3 tangent2 = normalize(cross(normal, tangent1));
  4646. // TODO(Max): The distance to the neighbors was originally scaled by 0.1.
  4647. // This caused some small oval/circular visual artifacts in the lighting.
  4648. // For now, simply using neighbors further away betters the problem,
  4649. // but we should figure out the underlying cause when we have some time.
  4650. // Maybe its related to how we calculate the tangent and bitangent?
  4651. vec3 nearby1 = position + tangent1;
  4652. vec3 nearby2 = position + tangent2;
  4653. vec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
  4654. vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
  4655. displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
  4656. return displaced_position;
  4657. }`,[o,a]);i=e.include(l),r.push(this.scale.build(e,"f")),r.push(this.cropOrOffset.build(e,"v3")),r.push(this.movementOrTexture.build(e,"f")),r.push(this.voronoiStyle.build(e,"i")),r.push(this.smoothness.build(e,"f")),r.push(this.seed.build(e,"f")),r.push(this.highCut.build(e,"f")),r.push(this.lowCut.build(e,"f")),r.push(this.quality.build(e,"i"));break}}return r.push(this.intensity.build(e,"f")),r.push("displaced_normal"),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},CT=ET;CT.Nodes=function(){let e=new De(`vec3 orthogonal(vec3 v) {
  4658. return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
  4659. }`),t=new De(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
  4660. vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
  4661. vec4 tmp = texture2D(tex, uvs);
  4662. vec3 col = tmp.rgb;
  4663. if (crop > 0.5) {
  4664. if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
  4665. return 0.0;
  4666. }
  4667. }
  4668. return col.r;
  4669. }`);return{map:new De(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
  4670. vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;
  4671. vec3 tangent1 = normalize(orthogonal(normal));
  4672. vec3 tangent2 = normalize(cross(normal, tangent1));
  4673. vec3 nearby1 = position + tangent1 * 0.1;
  4674. vec3 nearby2 = position + tangent2 * 0.1;
  4675. vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
  4676. vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
  4677. displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
  4678. return displaced_position;
  4679. }`,[e,t])}}();var st={normalRenderTarget:new an,normalRenderTargetDepth:new an,transmissionRenderTarget:new an,aspectRatio:new cr,transmissionSize:new cr(2048,2048),transmissionRenderTargetDepth:new an,aoRenderTarget:new an,aoEnabled:new Br,pixelRatioNode:new Fe(1),resolution:new cr,penumbraSize:new Bo(5,.5),frameIndex:new Yt(0),transmissionLod:new Yt(2)};for(let e of Object.values(st))e.isRenderGlobal=!0;var TT={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.53/build/ui.wasm"},G1=class extends Vi{constructor(){super("basic"),this.nodeType="Basic",this.color=new gi(as),this.shadingAlpha=new Fe(1),this.shadingBlend=new Yt(0),this.previousModelViewMatrix=new Pa,this.previouseProjectionMatrix=new Pa}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({resolution:st.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Wh.merge([Pe.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
  4680. `));let r=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
  4681. #include <skinbase_vertex>
  4682. #include <skinnormal_vertex>
  4683. #if !defined( USE_LAYER_DISPLACE )
  4684. #include <defaultnormal_vertex>
  4685. #endif
  4686. vec3 displaced_position = position;
  4687. vec3 displaced_normal = normal;
  4688. #if defined( USE_LAYER_DISPLACE )
  4689. vec3 transformed;
  4690. vec3 transformedNormal;
  4691. #endif
  4692. `,"#include <normal_vertex>",`
  4693. #if !defined( USE_LAYER_DISPLACE )
  4694. #include <begin_vertex>
  4695. #endif /* !USE_LAYER_DISPLACE */
  4696. `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(`
  4697. `)}else{this.color===void 0&&(this.color=new gi(as)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let i=this.color.flow(e,"c",{slot:"color"}),r=this.alpha?this.alpha.flow(e,"f"):void 0,s=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,a=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=r!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
  4698. `));let n=["#include <normal_fragment_begin>",i.code];r&&n.push(r.code,"#ifdef ALPHATEST"," if ( "+r.result+" <= ALPHATEST ) discard;","#endif"),a?n.push(a.code,`vec3 outgoingLight = ${i.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${a.result}, 1.0, SPE_BLENDING_NORMAL);`):n.push(`vec3 finalColor = ${i.result};`);let o="1.0";this.mask&&(this.mask.analyze(e),o=`luminance(${this.mask.flow(e,"v3").result})`),r?n.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${r.result} * ${o} );`):n.push("gl_FragColor = vec4("+i.result+", 1.0 );"),s&&n.push(`gl_FragColor.a *= ${s.result};`),n.push("#include <fog_fragment>","#include <dithering_fragment>"),t=n.join(`
  4699. `)}return t}},tY=class extends Vi{constructor(){super("lambert"),this.nodeType="Lambert",this.color=new gi(as),this.emissive=new gi(0),this.emissiveIntensity=new Fe(1),this.previousModelViewMatrix=new Pa,this.previouseProjectionMatrix=new Pa,this.shadingAlpha=new Fe(1),this.shadingBlend=new Yt(0),this.occlusion=new Br(!0)}get category(){return"lambert"}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({resolution:st.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Wh.merge([Pe.fog,Pe.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
  4700. `));let r=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
  4701. #include <skinbase_vertex>
  4702. #include <skinnormal_vertex>
  4703. #ifndef USE_LAYER_DISPLACE
  4704. #include <defaultnormal_vertex>
  4705. #endif
  4706. vec3 displaced_position = position;
  4707. vec3 displaced_normal = objectNormal;
  4708. #ifdef USE_LAYER_DISPLACE
  4709. vec3 transformed;
  4710. vec3 transformedNormal;
  4711. #endif
  4712. `,"#include <normal_vertex>",`
  4713. #ifndef USE_LAYER_DISPLACE
  4714. #include <begin_vertex>
  4715. #endif
  4716. `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>",`
  4717. vec3 diffuse = vec3( 1.0 );
  4718. GeometricContext geometry;
  4719. geometry.position = mvPosition.xyz;
  4720. geometry.normal = normalize( transformedNormal );
  4721. geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
  4722. `),r.push(`
  4723. GeometricContext backGeometry;
  4724. backGeometry.position = geometry.position;
  4725. backGeometry.normal = -geometry.normal;
  4726. backGeometry.viewDir = geometry.viewDir;
  4727. vLightFront = vec3( 0.0 );
  4728. vIndirectFront = vec3( 0.0 );
  4729. #ifdef DOUBLE_SIDED
  4730. vLightBack = vec3( 0.0 );
  4731. vIndirectBack = vec3( 0.0 );
  4732. #endif
  4733. IncidentLight directLight;
  4734. float dotNL;
  4735. vec3 directLightColor_Diffuse;
  4736. vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
  4737. vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
  4738. #ifdef DOUBLE_SIDED
  4739. vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
  4740. vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
  4741. #endif
  4742. #if NUM_POINT_LIGHTS > 0
  4743. #pragma unroll_loop_start
  4744. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  4745. getPointLightInfo( pointLights[ i ], geometry, directLight );
  4746. dotNL = dot( geometry.normal, directLight.direction );
  4747. directLightColor_Diffuse = directLight.color;
  4748. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  4749. #ifdef DOUBLE_SIDED
  4750. vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
  4751. #endif
  4752. }
  4753. #pragma unroll_loop_end
  4754. #endif
  4755. #if NUM_SPOT_LIGHTS > 0
  4756. #pragma unroll_loop_start
  4757. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  4758. getSpotLightInfo( spotLights[ i ], geometry, directLight );
  4759. dotNL = dot( geometry.normal, directLight.direction );
  4760. directLightColor_Diffuse = directLight.color;
  4761. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  4762. #ifdef DOUBLE_SIDED
  4763. vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
  4764. #endif
  4765. }
  4766. #pragma unroll_loop_end
  4767. #endif
  4768. #if NUM_DIR_LIGHTS > 0
  4769. #pragma unroll_loop_start
  4770. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  4771. getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
  4772. dotNL = dot( geometry.normal, directLight.direction );
  4773. directLightColor_Diffuse = directLight.color;
  4774. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  4775. #ifdef DOUBLE_SIDED
  4776. vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
  4777. #endif
  4778. }
  4779. #pragma unroll_loop_end
  4780. #endif
  4781. #if NUM_HEMI_LIGHTS > 0
  4782. #pragma unroll_loop_start
  4783. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  4784. vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
  4785. #ifdef DOUBLE_SIDED
  4786. vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
  4787. #endif
  4788. }
  4789. #pragma unroll_loop_end
  4790. #endif
  4791. `," #include <shadowmap_vertex>"," #include <fog_vertex>"),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(`
  4792. `)}else{e.mergeUniform({penumbraSize:st.penumbraSize}),e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({aoMap:st.aoRenderTarget}),e.mergeUniform({aoEnabled:st.aoEnabled}),this.color===void 0&&(this.color=new gi(as)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),r=this.emissive.flow(e,"c",{slot:"emissive"}),s=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),a=this.occlusion.flow(e,"b",{slot:"occlusion"}),n=this.shadingAlpha.flow(e,"f"),o=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0,c=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode(["uniform float penumbraSize[5];","uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
  4793. `));let d=["#include <normal_fragment_begin>",`
  4794. // NOTE: gl_FrontFacing alternative using face normal estimation.
  4795. vec3 viewdx = dFdx(vViewPosition);
  4796. vec3 viewdy = dFdy(vViewPosition);
  4797. vec3 faceNormal = normalize(cross(viewdx, viewdy));
  4798. bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);
  4799. `,"#include <clipping_planes_fragment>"];d.push(i.code,"vec3 diffuseColor = "+i.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),h&&d.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),d.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),r&&d.push(r.code,"reflectedLight.directDiffuse += "+r.result+" * "+s.result+";"),d.push("vec3 ao = aoEnabled && "+a.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let u="1.0";this.mask&&(this.mask.analyze(e),u=`luminance(${this.mask.flow(e,"v3").result})`),d.push(`
  4800. if (outgoingLight != diffuseColor) {
  4801. float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
  4802. accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * ${u} * lightAccu;
  4803. outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result} * ${u}, ${o.result} );
  4804. outgoingLight *= ao;
  4805. }
  4806. `),l&&d.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),h?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),c&&d.push(`gl_FragColor.a *= ${c.result};`),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
  4807. `)}return t}},Vh=function(){let e=new De(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
  4808. // Gradient of UVs w.r.t. X coordinate (in screen-space)
  4809. vec2 dSTdx = dFdx(bumpMapUv);
  4810. // Gradient of UVs w.r.t. Y coordinate (in screen-space)
  4811. vec2 dSTdy = dFdy(bumpMapUv);
  4812. // Forward differencing
  4813. float Hll = bumpScale * luminance(texture(bumpMap, bumpMapUv).rgb);
  4814. float dBx = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdx).rgb) - Hll;
  4815. float dBy = bumpScale * luminance(texture(bumpMap, bumpMapUv + dSTdy).rgb) - Hll;
  4816. return vec2( dBx, dBy );
  4817. }`),t=new De(`vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4818. vec3 vSigmaX = dFdx( surf_pos.xyz );
  4819. vec3 vSigmaY = dFdy( surf_pos.xyz );
  4820. vec3 vN = surf_norm; // normalized
  4821. vN = normalize(vN);
  4822. vec3 R1 = cross( vSigmaY, vN );
  4823. vec3 R2 = cross( vN, vSigmaX );
  4824. R1 = normalize(R1);
  4825. R2 = normalize(R2);
  4826. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4827. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4828. return normalize( abs( fDet ) * vN - vGrad );
  4829. }`);return{dHdxy:e,perturbNormalArb:t}}(),iY=class extends Vi{constructor(){super("phong"),this.nodeType="Phong",this.color=new gi(as),this.specular=new gi(1118481),this.shininess=new Fe(30),this.previousModelViewMatrix=new Pa,this.previouseProjectionMatrix=new Pa,this.shadingAlpha=new Fe(1),this.shadingBlend=new Yt(0),this.occlusion=new Br(!0)}get category(){return"phong"}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({resolution:st.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Wh.merge([Pe.fog,Pe.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
  4830. `));let r=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
  4831. #include <skinbase_vertex>
  4832. #include <skinnormal_vertex>
  4833. #ifndef USE_LAYER_DISPLACE
  4834. #include <defaultnormal_vertex>
  4835. #endif
  4836. vec3 displaced_position = position;
  4837. vec3 displaced_normal = objectNormal;
  4838. #ifdef USE_LAYER_DISPLACE
  4839. vec3 transformed;
  4840. vec3 transformedNormal;
  4841. #endif
  4842. `,"#include <normal_vertex>",`
  4843. #ifndef USE_LAYER_DISPLACE
  4844. #include <begin_vertex>
  4845. #endif
  4846. `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(`
  4847. `)}else{e.mergeUniform({penumbraSize:st.penumbraSize}),e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({aoMap:st.aoRenderTarget}),e.mergeUniform({aoEnabled:st.aoEnabled}),this.color===void 0&&(this.color=new gi(as)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let i=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let r=this.color.flow(e,"c",{slot:"color"}),s=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),n=this.shadingAlpha.flow(e,"f"),o=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,h=this.alpha?this.alpha.flow(e,"f"):void 0,c=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=h!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;","uniform float penumbraSize[5];","uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
  4848. `));let d=["#include <normal_fragment_begin>",`
  4849. // NOTE: gl_FrontFacing alternative using face normal estimation.
  4850. vec3 viewdx = dFdx(vViewPosition);
  4851. vec3 viewdy = dFdy(vViewPosition);
  4852. vec3 faceNormal = normalize(cross(viewdx,viewdy));
  4853. if (dot(normal, faceNormal) < 0.0) {
  4854. normal *= -1.0;
  4855. }
  4856. `," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(Vh.dHdxy),e.include(Vh.perturbNormalArb);let p=this.bumpMap.texture.flow(e,"t"),f=this.bumpMap.flow(e,"v3"),g=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",m="";this.bumpMap.projection.value===4?m=`
  4857. vec3 bumpNormal = vec3(0.0);
  4858. {
  4859. vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
  4860. vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
  4861. vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
  4862. vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
  4863. vec2 grad0 = dHdxy(${p.result}, uv0, ${g});
  4864. vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
  4865. vec2 grad1 = dHdxy(${p.result}, uv1, ${g});
  4866. vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
  4867. vec2 grad2 = dHdxy(${p.result}, uv2, ${g});
  4868. vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
  4869. bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
  4870. bumpNormal = normalize(bumpNormal);
  4871. }
  4872. normal = bumpNormal;
  4873. `:m=`
  4874. vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
  4875. vec2 grad = dHdxy(${p.result}, bumpMapCachedUv, ${g});
  4876. normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
  4877. `,d.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
  4878. ${f.result};
  4879. ${m}
  4880. `)}d.push(r.code," vec3 diffuseColor = "+r.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",s.code," vec3 specular = "+s.result+";",a.code," float shininess = max( 0.0001, "+a.result+" );"," float specularStrength = 1.0;"),h&&d.push(h.code,"#ifdef ALPHATEST","if ( "+h.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 ao = aoEnabled && "+i.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let u="1.0";this.mask&&(this.mask.analyze(e),u=`luminance(${this.mask.flow(e,"v3").result})`),d.push(`
  4881. if (outgoingLight != diffuseColor) {
  4882. float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
  4883. accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * ${u} * lightAccu;
  4884. outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result} * ${u}, ${o.result} );
  4885. outgoingLight *= ao;
  4886. }
  4887. `),l&&d.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),h?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result});`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),c&&d.push(`gl_FragColor.a *= ${c.result};`),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
  4888. `)}return t}},rY=class extends Vi{constructor(){super("standard"),this.nodeType="Standard",this.color=new gi(as),this.roughness=new Fe(.3),this.metalness=new Fe(0),this.reflectivity=new Fe(.5),this.previousModelViewMatrix=new Pa,this.previouseProjectionMatrix=new Pa,this.shadingAlpha=new Fe(1),this.shadingBlend=new Yt(0),this.occlusion=new Br(!0)}get category(){return"physical"}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({resolution:st.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Wh.merge([Pe.fog,Pe.lights])),Pe.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
  4889. `));let r=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
  4890. #include <skinbase_vertex>
  4891. #include <skinnormal_vertex>
  4892. #if !defined( USE_LAYER_DISPLACE )
  4893. #include <defaultnormal_vertex>
  4894. #endif
  4895. vec3 displaced_position = position;
  4896. vec3 displaced_normal = objectNormal;
  4897. #if defined( USE_LAYER_DISPLACE )
  4898. vec3 transformed;
  4899. vec3 transformedNormal;
  4900. #endif
  4901. `,"#include <normal_vertex>",`
  4902. #if !defined( USE_LAYER_DISPLACE )
  4903. #include <begin_vertex>
  4904. #endif /* !USE_LAYER_DISPLACE */
  4905. `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(`
  4906. `)}else{e.mergeUniform({penumbraSize:st.penumbraSize}),e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({aoMap:st.aoRenderTarget}),e.mergeUniform({aoEnabled:st.aoEnabled});let i={gamma:!0};this.color===void 0&&(this.color=new gi(as)),this.color.analyze(e,{slot:"color",context:i}),this.roughness.analyze(e),this.metalness.analyze(e);let r=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let s=this.color.flow(e,"c",{slot:"color",context:i}),a=this.roughness.flow(e,"f"),n=this.metalness.flow(e,"f"),o=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),h=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,u=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","uniform float penumbraSize[5];","uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
  4907. `));let p=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
  4908. // NOTE: gl_FrontFacing alternative using face normal estimation.
  4909. vec3 viewdx = dFdx(vViewPosition);
  4910. vec3 viewdy = dFdy(vViewPosition);
  4911. vec3 faceNormal = normalize(cross(viewdx,viewdy));
  4912. if (dot(normal, faceNormal) < 0.0) {
  4913. normal *= -1.0;
  4914. }
  4915. `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(Vh.dHdxy),e.include(Vh.perturbNormalArb);let g=this.bumpMap.texture.flow(e,"t"),m=this.bumpMap.flow(e,"v3"),v=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",y="";this.bumpMap.projection.value===4?y=`
  4916. vec3 bumpNormal = vec3(0.0);
  4917. {
  4918. vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
  4919. vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
  4920. vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
  4921. vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
  4922. vec2 grad0 = dHdxy(${g.result}, uv0, ${v});
  4923. vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
  4924. vec2 grad1 = dHdxy(${g.result}, uv1, ${v});
  4925. vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
  4926. vec2 grad2 = dHdxy(${g.result}, uv2, ${v});
  4927. vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
  4928. bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
  4929. bumpNormal = normalize(bumpNormal);
  4930. }
  4931. normal = bumpNormal;
  4932. `:y=`
  4933. vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
  4934. vec2 grad = dHdxy(${g.result}, bumpMapCachedUv, ${v});
  4935. normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
  4936. `,p.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
  4937. ${m.result};
  4938. ${y}
  4939. `)}if(p.push(s.code," vec3 diffuseColor = "+s.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",n.code," float metalnessFactor = "+n.result+";"),this.roughnessMap){let g=this.roughnessMap.texture.flow(e,"t"),m=this.roughnessMap.flow(e,"v3"),v="";this.roughnessMap.projection.value===4?v=`
  4940. float roughnessChange = 1.0;
  4941. {
  4942. vec2 uv0 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
  4943. vec2 uv1 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
  4944. vec2 uv2 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
  4945. vec3 weights = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
  4946. float r0 = luminance(texture(${g.result}, uv0).rgb) * roughnessScale;
  4947. float r1 = luminance(texture(${g.result}, uv1).rgb) * roughnessScale;
  4948. float r2 = luminance(texture(${g.result}, uv2).rgb) * roughnessScale;
  4949. roughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y);
  4950. }
  4951. float roughnessFactor = roughnessChange * ${a.result};
  4952. `:v=`
  4953. vec2 roughnessMapCachedUv = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs;
  4954. vec4 vals = texture(${g.result}, roughnessMapCachedUv);
  4955. float roughnessFactor = luminance(vals.rgb) * ${a.result};
  4956. `,p.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
  4957. ${m.result};
  4958. const float roughnessScale = 1.0;
  4959. ${v}
  4960. `)}else p.push(a.code," float roughnessFactor = "+a.result+";");c&&p.push(c.code,"#ifdef ALPHATEST"," if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),p.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),p.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),u?p.push(u.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+u.result+" ) ), diffuseColor, metalnessFactor );"):p.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),p.push("#include <lights_fragment_begin>"),p.push("#include <lights_fragment_end>"),p.push("vec3 ao = aoEnabled && "+r.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),p.push(`
  4961. if (outgoingLight != diffuseColor) {
  4962. float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
  4963. accumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * ${f} * lightAccu;
  4964. outgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result} * ${f}, ${l.result} );
  4965. outgoingLight *= ao;
  4966. }
  4967. `),h&&p.push(h.code,`outgoingLight = spe_blend(outgoingLight, ${h.result}, 1.0, SPE_BLENDING_NORMAL);`),c?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&p.push(`gl_FragColor.a *= ${d.result};`),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=p.join(`
  4968. `)}return t}},sY=class extends Vi{constructor(){super("toon"),this.nodeType="Toon",this.color=new gi(as),this.specular=new gi(1118481),this.shininess=new Fe(30),this.previousModelViewMatrix=new Pa,this.previouseProjectionMatrix=new Pa,this.shadingAlpha=new Fe(1),this.shadingBlend=new Yt(0)}get category(){return"toon"}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({resolution:st.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Wh.merge([Pe.fog,Pe.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
  4969. `));let r=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
  4970. #include <skinbase_vertex>
  4971. #include <skinnormal_vertex>
  4972. #ifndef USE_LAYER_DISPLACE
  4973. #include <defaultnormal_vertex>
  4974. #endif
  4975. vec3 displaced_position = position;
  4976. vec3 displaced_normal = objectNormal;
  4977. #ifdef USE_LAYER_DISPLACE
  4978. vec3 transformed;
  4979. vec3 transformedNormal;
  4980. #endif
  4981. `,"#include <normal_vertex>",`
  4982. #ifndef USE_LAYER_DISPLACE
  4983. #include <begin_vertex>
  4984. #endif
  4985. `];i&&r.push(i.code,i.result?"displaced_position = "+i.result+";":""),r.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),r.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),r.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=r.join(`
  4986. `)}else{e.mergeUniform({penumbraSize:st.penumbraSize}),e.mergeUniform({frameIndex:st.frameIndex}),e.mergeUniform({aoMap:st.aoRenderTarget}),e.mergeUniform({aoEnabled:st.aoEnabled}),this.color===void 0&&(this.color=new gi(as)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),r=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),n=this.shadingBlend.flow(e,"i"),o=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,l=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=l!==void 0,e.addParsCode(["uniform float penumbraSize[5];","uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
  4987. varying vec3 vViewPosition;
  4988. struct ToonMaterial {
  4989. vec3 diffuseColor;
  4990. vec3 specularColor;
  4991. float specularShininess;
  4992. float specularStrength;
  4993. };
  4994. void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  4995. vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
  4996. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4997. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4998. }
  4999. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  5000. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5001. }
  5002. #define RE_Direct RE_Direct_Toon
  5003. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
  5004. #define Material_LightProbeLOD( material ) (0)
  5005. `,"#include <shadowmap_pars_fragment>","#include <bumpmap_pars_fragment>","#include <normalmap_pars_fragment>"].join(`
  5006. `));let c=["#include <normal_fragment_begin>",`
  5007. // NOTE: gl_FrontFacing alternative using face normal estimation.
  5008. vec3 viewdx = dFdx(vViewPosition);
  5009. vec3 viewdy = dFdy(vViewPosition);
  5010. vec3 faceNormal = normalize(cross(viewdx,viewdy));
  5011. if (dot(normal, faceNormal) < 0.0) {
  5012. normal *= -1.0;
  5013. }
  5014. `," ToonMaterial material;"];if(this.bumpMap){e.include(Vh.dHdxy),e.include(Vh.perturbNormalArb);let u=this.bumpMap.texture.flow(e,"t"),p=this.bumpMap.flow(e,"v3"),f=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",g="";this.bumpMap.projection.value===4?g=`
  5015. vec3 bumpNormal = vec3(0.0);
  5016. {
  5017. vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
  5018. vec2 uv1 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs1;
  5019. vec2 uv2 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs2;
  5020. vec3 weights = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_triplanarWeights;
  5021. vec2 grad0 = dHdxy(${u.result}, uv0, ${f});
  5022. vec3 n0 = perturbNormalArb(-vViewPosition, normal, grad0, faceDirection);
  5023. vec2 grad1 = dHdxy(${u.result}, uv1, ${f});
  5024. vec3 n1 = perturbNormalArb(-vViewPosition, normal, grad1, faceDirection);
  5025. vec2 grad2 = dHdxy(${u.result}, uv2, ${f});
  5026. vec3 n2 = perturbNormalArb(-vViewPosition, normal, grad2, faceDirection);
  5027. bumpNormal = n0 * weights.z + n1 * weights.x + n2 * weights.y;
  5028. bumpNormal = normalize(bumpNormal);
  5029. }
  5030. normal = bumpNormal;
  5031. `:g=`
  5032. vec2 bumpMapCachedUv = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs;
  5033. vec2 grad = dHdxy(${u.result}, bumpMapCachedUv, ${f});
  5034. normal = perturbNormalArb( - vViewPosition, normal, grad, faceDirection );
  5035. `,c.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
  5036. ${p.result};
  5037. ${g}
  5038. `)}c.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",r.code," vec3 specular = "+r.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),l&&c.push(l.code,"#ifdef ALPHATEST","if ( "+l.result+" <= ALPHATEST ) discard;","#endif"),c.push("material.diffuseColor = diffuseColor;"),c.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),c.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let d="1.0";this.mask&&(this.mask.analyze(e),d=`luminance(${this.mask.flow(e,"v3").result})`),c.push(`
  5039. if (outgoingLight != diffuseColor) {
  5040. float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
  5041. accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * ${d} * lightAccu;
  5042. outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result} * ${d}, ${n.result} );
  5043. }
  5044. `),o&&c.push(o.code,`outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`),l?c.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`):c.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h&&c.push(`gl_FragColor.a *= ${h.result};`),c.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=c.join(`
  5045. `)}return t}},aY=class{constructor(e=1e3*10){this.timeout=e,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.head.next=this.tail,this.tail.prev=this.head}log(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;)this.dispose(t.src,t.data),this.cache.delete(t.src),t=t.next,t.prev=this.head,this.head.next=t;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(e){var t;return(t=this.cache.get(e))==null?void 0:t.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}},nY=class extends aY{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}},Ng;function oY(e){return typeof e=="string"?e:(Ng||(Ng=new nY),Ng.load(e))}var lY=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},hY=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}},PT=class extends lY{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let s of Object.values(r))for(let a of Object.values(s))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(s=>{i.onloadend=a=>{var n;r=(n=a.target)==null?void 0:n.result,s(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=oY(e),this.img.onload=t,await new Promise(r=>{this.img.onload=()=>{t(),r(null)}})}getTexture(e,t=1008,i=1006){var s,a;let r=(a=(s=this._cache[e])==null?void 0:s[t])==null?void 0:a[i];if(r)return r;{let n;return this.isBuffer?n=this.img.texture:this.isVideo?n=new jF(this.img,void 0,e,e):n=new ci(this.img,void 0,e,e,i,t),this.loaded&&(n.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]===void 0&&(this._cache[e][t]={}),this._cache[e][t][i]=n,n}}setNeedsUpdate(e){for(let t of Object.values(this._cache))for(let i of Object.values(t))for(let r of Object.values(i))r&&(r.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[i,r]of Object.entries(t))for(let[s,a]of Object.entries(r))a==null||a.dispose(),this._cache[e]!==void 0&&this._cache[e][i]!==void 0&&(this._cache[e][i][s]=void 0)}dispose(){super.dispose(),this.disposeTextures()}},Yn=class extends PT{};function cY(e,t){var i=fY(t);return i.formatToParts?uY(i,e):pY(i,e)}var dY={year:0,month:1,day:2,hour:3,minute:4,second:5};function uY(e,t){try{for(var i=e.formatToParts(t),r=[],s=0;s<i.length;s++){var a=dY[i[s].type];a>=0&&(r[a]=parseInt(i[s].value,10))}return r}catch(n){if(n instanceof RangeError)return[NaN];throw n}}function pY(e,t){var i=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(i);return[r[3],r[1],r[2],r[4],r[5],r[6]]}var kg={};function fY(e){if(!kg[e]){var t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:"America/New_York",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),i=t==="06/25/2014, 00:00:00"||t==="‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00";kg[e]=i?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return kg[e]}function DT(e,t,i,r,s,a,n){var o=new Date(0);return o.setUTCFullYear(e,t,i),o.setUTCHours(r,s,a,n),o}var MS=36e5,mY=6e4,Vg={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function IT(e,t,i){var r,s;if(!e||(r=Vg.timezoneZ.exec(e),r))return 0;var a;if(r=Vg.timezoneHH.exec(e),r)return a=parseInt(r[1],10),ES(a)?-(a*MS):NaN;if(r=Vg.timezoneHHMM.exec(e),r){a=parseInt(r[1],10);var n=parseInt(r[2],10);return ES(a,n)?(s=Math.abs(a)*MS+n*mY,a>0?-s:s):NaN}if(yY(e)){t=new Date(t||Date.now());var o=i?t:gY(t),l=ny(o,e),h=i?l:vY(t,l,e);return-h}return NaN}function gY(e){return DT(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}function ny(e,t){var i=cY(e,t),r=DT(i[0],i[1]-1,i[2],i[3]%24,i[4],i[5],0).getTime(),s=e.getTime(),a=s%1e3;return s-=a>=0?a:1e3+a,r-s}function vY(e,t,i){var r=e.getTime(),s=r-t,a=ny(new Date(s),i);if(t===a)return t;s-=a-t;var n=ny(new Date(s),i);return a===n?a:Math.max(a,n)}function ES(e,t){return-23<=e&&e<=23&&(t==null||0<=t&&t<=59)}var CS={};function yY(e){if(CS[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),CS[e]=!0,!0}catch{return!1}}var xY=xo(DO(),1),TS=xo(IO(),1),bY=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,wY=bY,jg=36e5,PS=6e4,_Y=2,Fr={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:wY};function SY(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(e===null)return new Date(NaN);var i=t||{},r=i.additionalDigits==null?_Y:(0,xY.default)(i.additionalDigits);if(r!==2&&r!==1&&r!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]")return new Date(e.getTime());if(typeof e=="number"||Object.prototype.toString.call(e)==="[object Number]")return new Date(e);if(!(typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"))return new Date(NaN);var s=AY(e),a=MY(s.date,r),n=a.year,o=a.restDateString,l=EY(o,n);if(isNaN(l))return new Date(NaN);if(l){var h=l.getTime(),c=0,d;if(s.time&&(c=CY(s.time),isNaN(c)))return new Date(NaN);if(s.timeZone||i.timeZone){if(d=IT(s.timeZone||i.timeZone,new Date(h+c)),isNaN(d))return new Date(NaN)}else d=(0,TS.default)(new Date(h+c)),d=(0,TS.default)(new Date(h+c+d));return new Date(h+c+d)}else return new Date(NaN)}function AY(e){var t={},i=Fr.dateTimePattern.exec(e),r;if(i?(t.date=i[1],r=i[3]):(i=Fr.datePattern.exec(e),i?(t.date=i[1],r=i[2]):(t.date=null,r=e)),r){var s=Fr.timeZone.exec(r);s?(t.time=r.replace(s[1],""),t.timeZone=s[1].trim()):t.time=r}return t}function MY(e,t){var i=Fr.YYY[t],r=Fr.YYYYY[t],s;if(s=Fr.YYYY.exec(e)||r.exec(e),s){var a=s[1];return{year:parseInt(a,10),restDateString:e.slice(a.length)}}if(s=Fr.YY.exec(e)||i.exec(e),s){var n=s[1];return{year:parseInt(n,10)*100,restDateString:e.slice(n.length)}}return{year:null}}function EY(e,t){if(t===null)return null;var i,r,s,a;if(e.length===0)return r=new Date(0),r.setUTCFullYear(t),r;if(i=Fr.MM.exec(e),i)return r=new Date(0),s=parseInt(i[1],10)-1,IS(t,s)?(r.setUTCFullYear(t,s),r):new Date(NaN);if(i=Fr.DDD.exec(e),i){r=new Date(0);var n=parseInt(i[1],10);return DY(t,n)?(r.setUTCFullYear(t,0,n),r):new Date(NaN)}if(i=Fr.MMDD.exec(e),i){r=new Date(0),s=parseInt(i[1],10)-1;var o=parseInt(i[2],10);return IS(t,s,o)?(r.setUTCFullYear(t,s,o),r):new Date(NaN)}if(i=Fr.Www.exec(e),i)return a=parseInt(i[1],10)-1,OS(t,a)?DS(t,a):new Date(NaN);if(i=Fr.WwwD.exec(e),i){a=parseInt(i[1],10)-1;var l=parseInt(i[2],10)-1;return OS(t,a,l)?DS(t,a,l):new Date(NaN)}return null}function CY(e){var t,i,r;if(t=Fr.HH.exec(e),t)return i=parseFloat(t[1].replace(",",".")),Gg(i)?i%24*jg:NaN;if(t=Fr.HHMM.exec(e),t)return i=parseInt(t[1],10),r=parseFloat(t[2].replace(",",".")),Gg(i,r)?i%24*jg+r*PS:NaN;if(t=Fr.HHMMSS.exec(e),t){i=parseInt(t[1],10),r=parseInt(t[2],10);var s=parseFloat(t[3].replace(",","."));return Gg(i,r,s)?i%24*jg+r*PS+s*1e3:NaN}return null}function DS(e,t,i){t=t||0,i=i||0;var r=new Date(0);r.setUTCFullYear(e,0,4);var s=r.getUTCDay()||7,a=t*7+i+1-s;return r.setUTCDate(r.getUTCDate()+a),r}var TY=[31,28,31,30,31,30,31,31,30,31,30,31],PY=[31,29,31,30,31,30,31,31,30,31,30,31];function OT(e){return e%400===0||e%4===0&&e%100!==0}function IS(e,t,i){if(t<0||t>11)return!1;if(i!=null){if(i<1)return!1;var r=OT(e);if(r&&i>PY[t]||!r&&i>TY[t])return!1}return!0}function DY(e,t){if(t<1)return!1;var i=OT(e);return!(i&&t>366||!i&&t>365)}function OS(e,t,i){return!(t<0||t>52||i!=null&&(i<0||i>6))}function Gg(e,t,i){return!(e!=null&&(e<0||e>=25)||t!=null&&(t<0||t>=60)||i!=null&&(i<0||i>=60))}function IY(e,t,i){var r=SY(e,i),s=IT(t,r,!0),a=new Date(r.getTime()-s),n=new Date(0);return n.setFullYear(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()),n.setHours(a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()),n}function Nr(e,t){return t.color(e)}function RS(e=new Date,t){let i=t.format,r=e.getSeconds(),s=e;t&&t.timeZone!==null&&(s=IY(new Date,t.timeZone));let a=s.getHours(),n=s.getMinutes(),o;t.format12h24h==="12ampm"&&(o=a>=12?"PM":"AM");let l=a;t.format12h24h!=="24"&&(l=a%12,l===0&&(l=12));let h,c;switch(i){case"HH:mm:ss":h=[l,n,r];break;case"HH:mm":h=[l,n];break;case"HH":h=[l],o=void 0;break;case"mm":h=[n],o=void 0;break;case"ss":h=[r],o=void 0;break;case"year":c=s.getFullYear();break;case"month":c=s.getMonth()+1;break;case"dayOfYear":c=Math.floor((s.getTime()-new Date(s.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":c=s.getDate();break;case"secondOfDay":c=a*60*60+n*60+r;break;default:console.error("Unknown time format",i),c=0;break}return h!==void 0?{textValue:h,suffix:o}:c}function OY(e,t){switch(e.type){case"fresnel":return zY(e,t);case"gradient":return BY(e,t);case"depth":return FY(e,t);case"normal":return UY(e,t);case"noise":return NY(e,t);case"rainbow":return kY(e,t);case"toon":return VY(e,t);case"outline":return jY(e,t);case"transmission":return GY(e,t);case"color":return LY(e,t);case"pattern":return HY(e,t)}}function RY(e){return{type:e.type}}function Zs(e,t){let{alpha:i,mode:r,isMask:s}=e,a=typeof i=="string"?(Number(t.getVariable(i))??100)/100:i;return{...RY(e),alpha:a,mode:r,isMask:s}}function LY(e,t){return{...Zs(e,t),color:Nr(e.color,t)}}function zY(e,t){let{bias:i,scale:r,intensity:s,factor:a,color:n}=e;return{...Zs(e,t),color:Nr(n,t),bias:i,scale:r,intensity:s,factor:a}}function BY(e,t){let{gradientType:i,smooth:r,colors:s,steps:a,angle:n,offset:o,morph:l}=e;return{...Zs(e,t),gradientType:i,smooth:r,colors:s.map(h=>new ct(h[0],h[1],h[2],h[3])),num:s.length,steps:a,offset:new j(...o),morph:new j(...l),angle:n}}function FY(e,t){let{gradientType:i,near:r,far:s,isVector:a,isWorldSpace:n,origin:o,direction:l,colors:h,steps:c,smooth:d}=e;return{...Zs(e,t),gradientType:i,near:r,far:s,isVector:a,isWorldSpace:n,origin:new M(...o),direction:l?new M(...l):new M(1,0,0),colors:h.map(u=>u!==void 0?new ct(u[0],u[1],u[2],u[3]):new ct(0,0,0,0)),steps:c.slice(0,h.length),smooth:d}}function UY(e,t){let{cnormal:i}=e;return{...Zs(e,t),cnormal:new M(i[0],i[1],i[2])}}function NY(e,t){return{...Zs(e,t),scale:e.scale,move:e.move,fA:new j(...e.fA),fB:new j(...e.fB),size:new M(...e.size),distortion:new j(...e.distortion),colorA:Nr(e.colorA,t),colorB:Nr(e.colorB,t),colorC:Nr(e.colorC,t),colorD:Nr(e.colorD,t),noiseType:e.noiseType,voronoiStyle:e.voronoiStyle,highCut:e.highCut,lowCut:e.lowCut,smoothness:e.smoothness,seed:e.seed,quality:e.quality}}function kY(e,t){return{...Zs(e,t),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new M(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new M(...e.offset)}}function VY(e,t){return{...Zs(e,t),positioning:e.positioning,colors:e.colors.map(i=>new ct(i[0],i[1],i[2],i[3])),num:e.colors.length,steps:e.steps,source:new M(...e.source),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:Nr(e.shadowColor,t),offset:new M(...e.offset)}}function jY(e,t){return{...Zs(e,t),outlineColor:Nr(e.outlineColor,t),contourColor:Nr(e.contourColor,t),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:new M(...e.contourDirection),positionalLines:e.positionalLines,compensation:e.compensation}}function GY(e,t){return{...Zs(e,t),thickness:e.thickness,ior:e.ior,roughness:e.roughness}}function HY(e,t){return{...Zs(e,t),style:e.style,projection:e.projection,axis:e.axis,blending:e.blending,offset:new j(...e.offset),colorA:Nr(e.colorA,t),colorB:Nr(e.colorB,t),frequency:new j(...e.frequency),size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation,vertical:new j(...e.vertical),horizontal:new j(...e.horizontal),sides:e.sides}}var Of=class extends vr{},WY={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},qY={depth:["colors"]};function XY(e,t,i){var a,n;if(t==="isMask")return!0;let r=WY[e.type],s=qY[e.type];if(s!==void 0){let o=e.color;if(s.includes(t)){let l=(n=(a=o[t])==null?void 0:a.value)==null?void 0:n.length;if(l!==void 0&&l!==i.length)return!0}}return r!==void 0?r.includes(t):!1}function RT(e,t,i){let r=i.uniforms[`f${i.id}_texture`];if(!r)return!1;let s=!1,a=e;if("image"in a){let n=a.image,o=t.image(n),l=r;l.image instanceof Yn||l.image.deref(),l.image=o}if("video"in a){let n=a.video,o=t.video(n),l=r;l.image instanceof Yn||l.image.deref(),l.image=o}if("wrapping"in a){let n=r;n.wrap=a.wrapping}if("minFilter"in a){let n=r;n.minFilter=a.minFilter}if("magFilter"in a){let n=r;n.magFilter=a.magFilter}if("rotation"in a&&i.uniforms[`f${i.id}_rotation`])return i.uniforms[`f${i.id}_rotation`].value=(a.rotation??0)*Re.DEG2RAD,s;if("repeat"in a||"offset"in a||"rotation"in a){let n="mat",o=i.uniforms[`f${i.id}_${n}`];"repeat"in a&&(o.repeat=a.repeat),"offset"in a&&(o.offset=a.offset),"rotation"in a&&(o.rotation=a.rotation??0),o.updateMatrix()}return s}function YY(e,t,i,r){let s=!1;for(let[a,n]of Object.entries(e)){if(a==="bumpMap"||a==="roughnessMap"){s=!0;continue}if(!a||n===void 0)continue;if(zT(a,i,r,t)){a==="visible"&&i.type==="light"&&(s=!0);continue}i.visible=r.visible;let o=i.uniforms[`f${i.id}_${a}`];if(o&&!(o instanceof V1))switch(s=s||XY(i,a,n),o.constructor){case gi:if(typeof n=="string"){let l=t.getColor(n);l&&(o.value=l);break}else{let l=n;o.value instanceof Of?o.value=new vr(l.r,l.g,l.b,l.a):o.setRGBA(l);break}case Ka:if(typeof n=="string"){let l=t.getColor(n);l&&(o.value=l);break}else{let l=n;o.value instanceof Of?o.value=new vr(l.r,l.g,l.b,l.a):o.value.setRGBA(l.r,l.g,l.b,l.a);break}case cr:{let l=n;o.value.setX(l[0]),o.value.setY(l[1]);break}case fs:{let l=n;o.value.setX(l[0]),o.value.setY(l[1]),o.value.setZ(l[2]);break}case an:{RT(n,t,i);break}case Fo:{o.value=n.map(l=>new ct(...l));break}default:{o.value=n;break}}}return s}var dl=(e,t,i)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof e=="number"?e*100:e,i)??100)/100))??1,jd=class{constructor(e,t,i,r,s){this.id=e,this.uuid=t,this.data=i,this.uniforms={};for(let a in r)this.uniforms[`f${this.id}_${a}`]=r[a];for(let a in i)zT(a,this,i,s)}get type(){return this.data.type}static create(e,t,i,r){if(i.type==="light")return fa.createLightLayer(e,t,i,r);if(i.type==="texture"||i.type==="video"){let s=i.type==="texture"?r.uiBuffer(i.texture.image)??r.image(i.texture.image):r.video(i.texture.video),a=new ry(s,i.texture.wrapping,i.texture.minFilter??1008,i.texture.magFilter??1006),n=new ZX(s),o=new KX(i.texture.repeat,i.texture.offset,i.texture.rotation??0),l=new Fe(i.crop?1:0),h=new Yt(i.projection??0),c=new Yt(["x","y","z"].indexOf(i.axis)??0),d=new Yt(i.side??0),u=new cr(i.size?new j(i.size[0],i.size[1]):new j(100,100)),p=new Fe(i.blending??0),f=new Fe(dl(i.alpha,r)),g=new Yt(i.mode??0),m=new Br(i.isMask??!1),v=new j1(a,n,l,h,c,d,u,p,o,f,g,m),y=new ii(v.calpha,"f");return new ui(e,t,i,{texture:a,textureSize:n,crop:l,projection:h,axis:c,side:d,size:u,blending:p,mat:o,alpha:f,mode:g,isMask:m},v,g,y,m,r)}else if(i.type==="matcap"){let s=r.image(i.texture.image),a=new ry(s,i.texture.wrapping,i.texture.minFilter??1008,i.texture.magFilter??1006),n=new Fe(dl(i.alpha,r)),o=new Yt(i.mode??0),l=new Br(i.isMask??!1),h=new Fe((i.texture.rotation??0)*Re.DEG2RAD),c=new mT(a,n,o,l,h),d=new ii(c.calpha,"f");return new ui(e,t,i,{texture:a,alpha:n,mode:o,isMask:l,rotation:h},c,o,d,l,r)}else if(i.type==="displace")if(i.displacementType==="noise"){let s=new fs(new M(...i.offset)),a=new Fe(i.scale??10),n=new Fe(i.intensity??8),o=new Fe(i.movement??1),l=new Yt(i.noiseType??0),h=new Yt(i.voronoiStyle??0),c=new Fe(i.smoothness??.5),d=new Fe(i.seed??0),u=new Fe(i.highCut??1),p=new Fe(i.lowCut??0),f=new Yt(i.quality??1),g=new CT(n,o,s,h,c,d,u,p,f,a,l);return new LT(e,t,i,{offset:s,scale:a,intensity:n,movement:o,noiseType:l,voronoiStyle:h,smoothness:c,seed:d,highCut:u,lowCut:p,quality:f},g,r)}else throw new Error;else return KY(e,t,i,r)}updateByOp(e,t,i){let r=e;if(r.path[0]===void 0){if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props||"noiseType"in r.props?(i.scene.markNeedsUpdateRendererDirty(),!0):YY(r.props,i.shared,this,t)}else if(r.path[0]==="texture")return"texture"in t||"video"in t?RT(r.props,i.shared,this):!0;return!1}dispose(){if(QY(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof Yn||t.image.deref()}}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let i=`f${this.id}_${e}`;this.hasValueByKey(i)&&t!==void 0&&(this.uniforms[i].value=t)}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let i=this.getName(t);i&&e.push(i)}return e}},ui=class extends jd{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,l),this.params=r,this.color=s,this.mode=a,this.alpha=n,this.isMask=o}},LT=class extends jd{constructor(e,t,i,r,s,a){super(e,t,i,r,a),this.position=s}},fa=class extends jd{constructor(e,t,i,r,s,a){super(e,t,i,s,a),this.node=r}static createLightLayer(e,t,i,r){let s,a=new Fe(dl(i.alpha,r)),n=new Yt(i.mode),o=new Fe(i.bumpMapIntensity),l=new Fe(dl(i.alphaOverride,r)),h;if(!i.visible)s=new G1,h={};else if(i.category==="lambert"){s=new tY;let c=new gi(r.color(i.emissive)??0),d=new Br(i.occlusion??!0);h={emissive:c,occlusion:d},s.emissive=c,s.occlusion=d}else if(i.category==="toon"){s=new sY;let c=new Fe(i.shininess??30),d=new gi(r.color(i.specular)??1118481);h={shininess:c,specular:d},s.shininess=c,s.specular=d}else if(i.category==="physical"){s=new rY;let c=new Fe(i.roughness??.3),d=new Fe(i.metalness??0),u=new Fe(i.reflectivity??.5),p=new Br(i.occlusion??!0);h={roughness:c,metalness:d,reflectivity:u,occlusion:p},s.roughness=c,s.metalness=d,s.reflectivity=u,s.occlusion=p}else{s=new iY;let c=new Fe(i.shininess??30),d=new gi(i.specular!==void 0?r.color(i.specular)??1118481:1118481),u=new Br(i.occlusion??!0);h={shininess:c,specular:d,occlusion:u},s.shininess=c,s.specular=d,s.occlusion=u}return s.alpha=new Fe(1),s.shadingAlpha=a,s.shadingBlend=n,s.bumpMapIntensity=o,s.alphaOverride=l,h.alpha=s.shadingAlpha,h.mode=s.shadingBlend,h.bumpMapIntensity=s.bumpMapIntensity,h.alphaOverride=s.alphaOverride,new fa(e,t,i,s,h,r)}get category(){return this.node.category}};function QY(e){let t=e instanceof jd?e.type:e;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function hs(e){return{alpha:new Fe(e.alpha??1),mode:new Yt(e.mode??0),isMask:new Br(e.isMask??!1)}}function ZY(e,t,i,r,s){switch(e.type){case"color":{let a=new gi(r.color??as),n=hs(r),o=new sy(a,n.alpha),l=new ii(o.calpha,"f");return new ui(t,i,e,{color:a,...n},o,n.mode,l,n.isMask,s)}case"fresnel":{let a=new gi(r.color??16777215),n=new Fe(r.bias??.1),o=new Fe(r.scale??1),l=new Fe(r.intensity??2),h=new Fe(r.factor??1),c=hs(r),d=new JX(a,n,o,l,h,c.alpha,c.mode,c.isMask),u=new ii(d.calpha,"f");return new ui(t,i,e,{color:a,bias:n,scale:o,intensity:l,factor:h,...c},d,c.mode,u,c.isMask,s)}case"rainbow":{let a=new Fe(r.filmThickness??30),n=new Fe(r.movement??0),o=new fs(r.wavelengths??new M(0,0,0)),l=new Fe(r.noiseStrength??0),h=new Fe(r.noiseScale??1),c=new fs(r.offset??new M(0,0,0)),d=hs(r),u=new wT(a,n,o,l,h,c,d.alpha,d.isMask),p=new ii(u.calpha,"f");return new ui(t,i,e,{filmThickness:a,movement:n,wavelengths:o,noiseStrength:l,noiseScale:h,offset:c,...d},u,d.mode,p,d.isMask,s)}case"transmission":{let a=new Fe(r.thickness??10),n=new Fe(r.ior??1.5),o=new Fe(r.roughness??.5),l=st.transmissionSize,h=st.transmissionRenderTarget,c=st.transmissionRenderTargetDepth,d=window.innerWidth,u=window.innerHeight,p=d>=u?new cr(u/d,1):new cr(1,d/u),f=hs(r),g=new MT(a,n,o,l,h,c,p,f.alpha),m=new ii(g.calpha,"f");return new ui(t,i,e,{thickness:a,ior:n,roughness:o,aspectRatio:p,...f},g,f.mode,m,f.isMask,s)}case"toon":{let a=new Yt(r.positioning??0),n;r.colors?n=new Fo(r.colors.length,r.colors):(n=new Fo(10,new ct(0,0,0,1)),n.value[1]=new ct(1,1,1,1));let o;r.steps?o=new Bo(r.steps.length,r.steps):(o=new Bo(10,1),o.value[0]=0);let l=new fs(r.source??new M(0,0,0)),h=new Br(r.isWorldSpace??!0),c=new Fe(r.noiseStrength??0),d=new Fe(r.noiseScale??1),u=new Ka(r.shadowColor),p=new fs(r.offset??new M(0,0,0)),f=hs(r),g=new ST(a,n,o,l,h,c,d,u,p,f.alpha),m=new ii(g.calpha,"f");return new ui(t,i,e,{positioning:a,colors:n,steps:o,source:l,isWorldSpace:h,noiseStrength:c,noiseScale:d,shadowColor:u,offset:p,...f},g,f.mode,m,f.isMask,s)}case"outline":{let a=new gi(r.outlineColor??16777215),n=new gi(r.contourColor??16777215),o=new Fe(r.outlineWidth??.1),l=new Fe(r.contourWidth??.1),h=new Fe(r.outlineThreshold??.1),c=new Fe(r.contourThreshold??.1),d=new Fe(r.outlineSmoothing??.1),u=new Fe(r.contourFrequency??.1),p=new fs(r.contourDirection??new M(0,1,0)),f=new Br(r.positionalLines??!1),g=new Br(r.compensation??!0),m=st.normalRenderTarget,v=st.normalRenderTargetDepth,y=st.pixelRatioNode,x=st.resolution,w=hs(r),_=new yT(a,n,o,l,h,c,d,u,p,f,g,x,m,v,y,w.alpha),b=new ii(_.calpha,"f");return new ui(t,i,e,{outlineColor:a,contourColor:n,outlineWidth:o,contourWidth:l,outlineThreshold:h,contourThreshold:c,outlineSmoothing:d,contourFrequency:u,contourDirection:p,positionalLines:f,compensation:g,...w},_,w.mode,b,w.isMask,s)}case"depth":{let a=new Yt(r.gradientType??0),n=new Br(r.smooth??!1),o=new Fe(r.near??50),l=new Fe(r.far??200),h=new Fe(r.isVector??1),c=new Fe(r.isWorldSpace??0),d=new fs(r.origin??new M),u=new fs(r.direction??new M),p;r.colors?p=new Fo(r.colors.length,r.colors):(p=new Fo(2,new ct(0,0,0,1)),p.value[1]=new ct(1,1,1,1));let f;r.steps?f=new Bo(r.steps.length,r.steps):(f=new Bo(2,1),f.value[0]=0);let g=hs(r),m=new dT(a,n,o,l,h,c,d,u,p,f,g.alpha,g.isMask),v=new ii(m.calpha,"f");return new ui(t,i,e,{gradientType:a,smooth:n,near:o,far:l,isVector:h,isWorldSpace:c,origin:d,direction:u,colors:p,steps:f,...g},m,g.mode,v,g.isMask,s)}case"noise":{let a=new Fe(r.scale??1),n=new fs(r.size??new M(100,100,100)),o=new Fe(r.move??1),l=new cr(r.fA??new j(1.7,9.2)),h=new cr(r.fB??new j(8.3,2.8)),c=new cr(r.distortion??new j(1,1)),d=new Ka(r.colorA),u=new Ka(r.colorB),p=new Ka(r.colorC),f=new Ka(r.colorD),g=new Yt(r.noiseType??0),m=new Yt(r.voronoiStyle??0),v=new Fe(r.highCut??1),y=new Fe(r.lowCut??0),x=new Fe(r.smoothness??.5),w=new Fe(r.seed??.5),_=new Yt(r.quality??1),b=hs(r),A=new gT(a,n,o,l,h,c,d,u,p,f,b.alpha,g,b.isMask,m,v,y,x,w,_),S=new ii(A.calpha,"f");return new ui(t,i,e,{scale:a,size:n,move:o,fA:l,fB:h,distortion:c,colorA:d,colorB:u,colorC:p,colorD:f,noiseType:g,...b,voronoiStyle:m,highCut:v,lowCut:y,smoothness:x,seed:w,quality:_},A,b.mode,S,b.isMask,s)}case"normal":{let a=new fs(r.cnormal??new M(1,1,1)),n=hs(r),o=new cT(a,n.alpha),l=new ii(o.calpha,"f");return new ui(t,i,e,{cnormal:a,...n},o,n.mode,l,n.isMask,s)}case"gradient":{let a=new Yt(r.gradientType??0),n=new Br(r.smooth??!1),o;r.colors?o=new Fo(r.colors.length,r.colors):(o=new Fo(10,new ct(0,0,0,1)),o.value[1]=new ct(1,1,1,1));let l;r.steps?l=new Bo(r.steps.length,r.steps):(l=new Bo(10,1),l.value[0]=0);let h=new cr(r.offset??new j(0,0)),c=new cr(r.morph??new j(0,0)),d=new Fe(r.angle??0),u=hs(r),p=new pT(a,n,o,l,h,c,d,u.alpha,u.isMask),f=new ii(p.calpha,"f");return new ui(t,i,e,{gradientType:a,smooth:n,colors:o,steps:l,offset:h,morph:c,angle:d,...u},p,u.mode,f,u.isMask,s)}case"pattern":{let a=new Yt(r.style??0),n=new Yt(r.projection??0),o=new Yt(["x","y","z"].indexOf(r.axis)??0),l=new Fe(r.blending??0),h=new cr(r.offset??new j(0,0)),c=new Ka(r.colorA),d=new Ka(r.colorB),u=new cr(r.frequency??new j(10,10)),p=new Fe(r.size??.5),f=new Fe(r.variation??0),g=new Fe(r.smoothness??.5),m=new Fe(r.zigzag??0),v=new Fe(r.rotation??0),y=new cr(r.vertical??new j(0,1)),x=new cr(r.horizontal??new j(0,1)),w=new Yt(r.sides??6),_=hs(r),b=new xT(a,n,o,l,h,c,d,u,p,f,g,m,v,y,x,w,_.alpha,_.isMask),A=new ii(b.calpha,"f");return new ui(t,i,e,{style:a,projection:n,axis:o,blending:l,offset:h,colorA:c,colorB:d,frequency:u,size:p,variation:f,smoothness:g,zigzag:m,rotation:v,vertical:y,horizontal:x,sides:w,..._},b,_.mode,A,_.isMask,s)}default:{let a=new gi(1,0,0,1),n=hs(r),o=new sy(a,n.alpha),l=new ii(o.calpha,"f");return new ui(t,i,e,{color:a,...n},o,n.mode,l,n.isMask,s)}}}function KY(e,t,i,r){let s=OY(i,r);return ZY(i,e,t,s,r)}function zT(e,t,i,r){if(i.type==="displace"&&(e==="intensity"||e==="visible")){let s=t.uniforms[`f${t.id}_intensity`];return s?(s.value=i.intensity*(i.visible?1:0),s):void 0}if(i.type!=="displace"&&(e==="alpha"||e==="visible")){let s=t.uniforms[`f${t.id}_alpha`];if(!s)return;if(s.value=dl(i.alpha,r)*(i.visible?1:0),i.type==="outline"&&e==="visible"){let a=t.uniforms[`f${t.id}_compensation`];a&&(a.value=i.compensation&&i.visible)}return s}}function ph(e,t){let i=0,r=e.layers.find(s=>s.data.type==="light");if(r){let s=r.data,a=Number(t.getVariable(s.alphaOverride));if((typeof s.alphaOverride=="string"?a/100:s.alphaOverride)<1)return!0}for(let s of e.layers){if(s.data.type!=="displace"&&s.data.isMask)return!0;if(s.data.type!=="displace"&&"alpha"in s.data&&s.data.type!=="light"&&s.data.type!=="fresnel"&&s.data.type!=="texture"&&s.data.type!=="matcap"&&s.data.type!=="rainbow"&&s.data.type!=="outline"&&s.data.type!=="pattern"){let a=s.data.visible?s.data.alpha:0;if(typeof a=="string"&&(a=Math.max(0,Math.min(1,Number(t.getVariable(a)??100)/100))),a===1&&s.data.type==="depth"||s.data.type==="gradient"){for(let n of s.data.colors)if(n[3]<1){a=n[3];break}}else if(a===1&&s.data.type==="noise"){let n=t.color(s.data.colorA).a,o=t.color(s.data.colorB).a,l=t.color(s.data.colorC).a,h=t.color(s.data.colorD).a,c=Math.min(n,Math.min(o,Math.min(l,h)));c<1&&(a=c)}i+=(1-i)*a}}return i<1}var uo=class extends Dt{constructor(){super(void 0),this.flatShading=!1,this.needsJitter=!0,this.shadersPatchedForShapeBlend=!1,this.nodeContextUuid=0,this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},JY=class extends uo{constructor(e,t,i,r){super(),this.flatShading=e,this.side=t,this.wireframe=i,this.root=r}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,i,r){return this.root.getFlavor(e,t,i,r)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,i){this.root.updateByOp(e,t,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},H1=class extends uo{constructor(e,t,i=!0){super(),this.data=e,this.allowVariableSaves=i,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.updaters=[],this.needsJitter=t.shared.needsJitter,Vi.startContext(this),this.reset0(e,t),Vi.endContext(this)}get nodeMaterial(){return this}getFlavor(e,t,i,r){let s=i?6:(e?3:0)+t;if(s+=(((r==null?void 0:r.resolutionLevel)??0)-(r!=null&&r.useChildrenColors?4:0))*7,s===0)return this;this.flavors===void 0&&(this.flavors=[]),s-=1;let a=this.flavors[s];return a===void 0&&(a=new JY(e,t,i,this),a.needsJitter=this.needsJitter,this.flavors[s]=a,a.flatShading=e,a.side=t,a.updateAfterBuild(),r&&(a.defines.SHAPEBLEND=r.resolutionLevel,a.defines.SHAPEBLEND_C=r.useChildrenColors?1:0)),a}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){var e;return((e=this.lightLayer.getNode("occlusion"))==null?void 0:e.value)??!1}reset(e,t,i=!1){Vi.startContext(this),(this.data!==e||i)&&this.reset0(e,t),Vi.endContext(this)}reset0(e,t){this.data=e;let i=e.layers??ir.defaultTwoLayerData("phong").layers;try{this.layers=i.map(r=>jd.create(this.layerIdGen++,r.id,r.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.transparent=ph(e,t.shared),this.saveVariableLocations(t)}onVariableUpdate(e,t,i){if(e[0]==="alphaOverride")this.transparent=ph(this.data,i.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if(e[0]==="layer"){let r=e[1],s=e[2];if(r&&s){let a=this.layers.find(n=>n.uuid===r);a!=null&&a.hasValue(s)&&(s==="alpha"?(this.transparent=ph(this.data,i.shared),a.setValue(s,Math.max(0,Math.min(Number(t)/100,1)))):a.setValue(s,t))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers.find(i=>i.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(i=>{"alpha"in i.data&&typeof i.data.alpha=="string"&&e.shared.getVariable(i.data.alpha,["material",this.uuid,"layer",i.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(t=>t instanceof fa),this.lightLayer===void 0&&(this.lightLayer=new fa(0,"",{...Ji.defaultData("light","phong"),visible:!1},new G1,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(s=>s instanceof fa);if(!e)return;let t=e.data,i=t.bumpMap,r=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let s=0;s<this.layers.length;++s){let a=this.layers[s];a instanceof ui&&a.color instanceof j1&&(a.uuid===i&&(e.node.bumpMap=a.color),a.uuid===r&&(e.node.roughnessMap=a.color))}}updateByOp(e,t,i){if(Vi.startContext(this),t!==void 0?this.data=t:t=this.data,this.transparent=ph(t,i.shared),e.path[0]==="layers"){let r=i.shared,s=e.path[1];if(s===void 0)i.scene.markNeedsUpdateRendererDirty(),this.reset0(t,i);else{e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let a=this.layers.find(n=>n.uuid===s);if(a){let n=t.layers.data(s),o;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?o={...e.props,alpha:dl(e.props.alpha,r,["material",this.uuid,"layer",s,"alpha"])}:o={...e.props,alphaOverride:dl(e.props.alphaOverride,r,["material",this.uuid,"alphaOverride"])}),a.updateByOp({...e,...o?{props:o}:{},path:e.path.slice(2)},n,i)&&this.reset0(t,i)}}}else this.reset0(t,i);Vi.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof ui?t.color.mask=void 0:t instanceof fa&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof ui&&t.isMask.value&&t.data.visible&&e>0){let i=e-1,r=this.layers[i];r instanceof fa?r.node.mask=new Wr(t.color,t.alpha,Wr.MUL):r instanceof ui&&(r.isMask.value||(r.color.mask=new Wr(t.color,t.alpha,Wr.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof ui),t=this.layers.findIndex(i=>i instanceof fa);if(e!==-1&&e<t){let i=this.layers[e].color;for(let r=e+1;r<t;++r){let s=this.layers[r];if(s instanceof ui){if(s.isMask.value)continue;i=new AS(i,s.color,s.alpha,s.mode)}}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new ii("outgoingLight","f"),t=this.layers.findIndex(i=>i instanceof fa);if(this.layers.length>t+1){for(let i=t+1;i<this.layers.length;++i){let r=this.layers[i];if(r instanceof ui){if(r.isMask.value)continue;e=new AS(e,r.color,r.alpha,r.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof LT);if(e.length>0){let t=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(t=new Wr(t,e[i].position,Wr.ADD),t=new Wr(t,new Fe(.5).setReadonly(!0),Wr.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let i=(r,s,a)=>Math.min(Math.max(r,s),a);for(let r of this.layers)if(r.type==="displace"){let s=i(r.uniforms[`f${r.id}_intensity`].value,e,t);r.uniforms[`f${r.id}_intensity`].value=s}}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new nT;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof ui){let t=e.params.texture;if(t instanceof ry&&!t.image.loaded)return!1}return!0}};Object.defineProperties(uo.prototype,{properties:{get:function(){return this.fragment.properties}}});var oy=class extends H1{constructor(e,t,i){super(e,t,!1),this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(t)}},LS=new Map;function $Y(e){if(typeof e=="string")return e;let t=LS.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},LS.set(e,t)),t.url}var BT,eQ=new Promise(e=>{BT=e}),zS=!1,$u;function tQ(){if(zS)return;if($u)return $u;async function e(){await vo(()=>import("./howler-BzJY10nd.js").then(t=>t.h),__vite__mapDeps([0,1])),BT(window!==void 0?window:global),zS=!0}return $u=e(),$u}var FT;eQ.then(e=>FT=e);function BS(e,t){e.forEach(i=>{"dragDropActions"in i.data?(t.push(...i.data.dragDropActions.drag),t.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(t.push(...i.data.inActions),t.push(...i.data.outActions)):"gameActions"in i.data?(t.push(...i.data.gameActions.idle),t.push(...i.data.gameActions.move),t.push(...i.data.gameActions.jump),t.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(r=>{t.push(...r.data.actions)}):"actions"in i.data&&(t.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(t.push(...r.data.ifActions),t.push(...r.data.elseActions))}))})}function iQ(e){let t=!1,i=[];return e.scene.objects.traverse((r,s)=>{if(s.type==="Page"&&s.uiScene!==void 0&&s.uiScene.objects.traverse((a,n)=>{if(n.events===void 0||Array.isArray(n.events)===!1)return!0;BS(n.events,i),t=t||i.some(o=>o.data.type==="Audio")}),s.events===void 0||Array.isArray(s.events)===!1)return!0;BS(s.events,i),t=t||i.some(a=>a.data.type==="Audio")}),t}var qc=class{constructor({src:e,volume:t,delay:i,loop:r}){this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let s;typeof e=="string"?s={src:e}:s={src:$Y(e),format:"wav"},this.sound=new FT.Howl(s),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}},rQ=class{constructor(){this.type="ShapePath",this.color=new et,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Wp,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){var i;return(i=this.currentPath)==null||i.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){var s;return(s=this.currentPath)==null||s.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,a){var n;return(n=this.currentPath)==null||n.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){var t;return(t=this.currentPath)==null||t.splineThru(e),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function i(p,f,g,m){let v=p.x,y=f.x,x=g.x,w=m.x,_=p.y,b=f.y,A=g.y,S=m.y,E=(w-x)*(_-A)-(S-A)*(v-x),C=(y-v)*(_-A)-(b-_)*(v-x),T=(S-A)*(y-v)-(w-x)*(b-_),D=E/T,O=C/T;if(T===0&&E!==0||D<=0||D>=1||O<0||O>1)return null;if(E===0&&T===0){for(let P=0;P<2;P++)if(r(P===0?g:m,p,f),t.loc===e.ORIGIN){let U=P===0?g:m;return{x:U.x,y:U.y,t:t.t}}else if(t.loc===e.BETWEEN){let U=+(v+t.t*(y-v)).toPrecision(10),W=+(_+t.t*(b-_)).toPrecision(10);return{x:U,y:W,t:t.t}}return null}else{for(let W=0;W<2;W++)if(r(W===0?g:m,p,f),t.loc===e.ORIGIN){let k=W===0?g:m;return{x:k.x,y:k.y,t:t.t}}let P=+(v+D*(y-v)).toPrecision(10),U=+(_+D*(b-_)).toPrecision(10);return{x:P,y:U,t:D}}}function r(p,f,g){let m=g.x-f.x,v=g.y-f.y,y=p.x-f.x,x=p.y-f.y,w=m*x-y*v;if(p.x===f.x&&p.y===f.y){t.loc=e.ORIGIN,t.t=0;return}if(p.x===g.x&&p.y===g.y){t.loc=e.DESTINATION,t.t=1;return}if(w<-Number.EPSILON){t.loc=e.LEFT;return}if(w>Number.EPSILON){t.loc=e.RIGHT;return}if(m*y<0||v*x<0){t.loc=e.BEHIND;return}if(Math.sqrt(m*m+v*v)<Math.sqrt(y*y+x*x)){t.loc=e.BEYOND;return}let _;m!==0?_=y/m:_=x/v,t.loc=e.BETWEEN,t.t=_}function s(p,f){let g=[],m=[];for(let v=1;v<p.length;v++){let y=p[v-1],x=p[v];for(let w=1;w<f.length;w++){let _=f[w-1],b=f[w],A=i(y,x,_,b);A!==null&&g.find(S=>S.t<=A.t+Number.EPSILON&&S.t>=A.t-Number.EPSILON)===void 0&&(g.push(A),m.push(new j(A.x,A.y)))}}return m}function a(p,f,g){let m=new j;f.getCenter(m);let v=[];return g.forEach(y=>{y.boundingBox.containsPoint(m)&&s(p,y.points).forEach(x=>{v.push({identifier:y.identifier,isCW:y.isCW,point:x})})}),v.sort((y,x)=>y.point.x-x.point.x),v}function n(p,f,g,m,v){(v==null||v==="")&&(v="nonzero");let y=new j;p.boundingBox.getCenter(y);let x=[new j(g,y.y),new j(m,y.y)],w=a(x,p.boundingBox,f);w.sort((C,T)=>C.point.x-T.point.x);let _=[],b=[];w.forEach(C=>{C.identifier===p.identifier?_.push(C):b.push(C)});let A=_[0].point.x,S=[],E=0;for(;E<b.length&&b[E].point.x<A;)S.length>0&&S[S.length-1]===b[E].identifier?S.pop():S.push(b[E].identifier),E++;if(S.push(p.identifier),v==="evenodd"){let C=S.length%2===0,T=S[S.length-2];return{identifier:p.identifier,isHole:C,for:T}}else if(v==="nonzero"){let C=!0,T=null,D=null;for(let O=0;O<S.length;O++){let P=S[O];f[P]&&(C?(D=f[P].isCW,C=!1,T=P):D!==f[P].isCW&&(D=f[P].isCW,C=!0))}return{identifier:p.identifier,isHole:C,for:T}}else console.warn('fill-rule: "'+v+'" is currently not implemented.')}let o=0,l=999999999,h=-999999999,c=[];this.subPaths.forEach(p=>{let f=p.getPoints(),g=-999999999,m=999999999,v=-999999999,y=999999999;for(let x=0;x<f.length;x++){let w=f[x];w.y>g&&(g=w.y),w.y<m&&(m=w.y),w.x>v&&(v=w.x),w.x<y&&(y=w.x)}h<=v&&(h=v+1),l>=y&&(l=y-1),f.length&&c.push({curves:p.curves,points:f,isCW:DM.isClockWise(f),identifier:o++,boundingBox:new t1(new j(y,m),new j(v,g))})});let d=c.map(p=>{var f;return n(p,c,l,h,(f=this.userData)==null?void 0:f.style.fillRule)}),u=[];return c.forEach(p=>{let f=d[p.identifier];if(f&&!f.isHole){let g=new qp;g.curves=p.curves,d.filter(m=>(m==null?void 0:m.isHole)&&m.for===p.identifier).forEach(m=>{if(m){let v=c[m.identifier],y=new Wp;y.curves=v.curves,g.holes.push(y)}}),u.push(g)}}),u}},UT=!1,NT,FS=new Promise(e=>{NT=e}),US=!1,ep;function sQ(){if(UT=!0,US)return;if(ep)return ep;async function e(){let t=await vo(()=>import("./opentype-QeDitGAm.js"),__vite__mapDeps([]));NT(t),US=!0}return ep=e(),ep}var aQ=class{async load(e,t,i=()=>{}){let{load:r}=await FS;r(e,(s,a)=>{s||!a?i(s??"Something went wrong"):t(a)})}async parse(e){let{parse:t,Bidi:i}=await FS;try{let r=t(e),s=new i,a=n=>r.charToGlyphIndex(n.char);return s.registerModifier("glyphIndex",null,a),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};async function nQ(e){return await(await fetch(e)).arrayBuffer()}var oQ=new aQ;async function NS(e){let t,i,r=!1;if(e.url?(t=await nQ(e.url),i=e.url,r=e.url.startsWith("/")):e.data&&(t=e.data.buffer.slice(e.data.byteOffset,e.data.byteOffset+e.data.byteLength)),t)if(UT){let s=await oQ.parse(t);if(s)return{font:s.font,url:i,intercepted:r,arr:t,bidi:s.bidi}}else return{font:void 0,url:i,intercepted:r,arr:t,bidi:null}}function lQ(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}var hQ=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=NS(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=NS(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let s=r.tokenizer.tokens,a=[],n=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let h=i[l].index,c=String.fromCharCode(i[l].unicode),d=s[n];if(lQ(h,d)||o)a.push({char:c,index:h,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),n++;else{let u=d.char,p="",f=[d.state.glyphIndex],g=[],m=!1;for(;!m;)n++,p=t.charAt(n),u+=p,f.push(e.charToGlyphIndex(p)),g=e.stringToGlyphs(u),g.length===1&&g[0].index===h&&(m=!0),n>t.length&&(m=!0);a.push({char:c,index:h,replacements:f,replacementChars:Array.from(u)}),n++}}return a}generateShapes(e,t,i){var v;if(!this._isLoaded)return;let r=this.font,s=t.fontSize/this.unitsPerEm,a=t.fontSize*t.lineHeight,n=e.map(y=>this.getTextWidth(y,t)),o=typeof t.width=="string"?Number(i.getVariable(t.width)):t.width,l=typeof t.height=="string"?Number(i.getVariable(t.height)):t.height,h=this.getCharWidth(`
  5046. `,t),c=t.horizontalAlign===1?h:0,d=this.getLineInitialOffsetX(n[0],o,t.horizontalAlign,e[0],h),u=this.getLineInitialOffsetY(a,e.length,l,s,t.verticalAlign),p=[],f=e.map(y=>[]),g=e.map(y=>[]);for(let y=0;y<e.length;y++){let x=e[y],w={features:{liga:!0},letterSpacing:t.letterSpacing},_=[];try{_=r.stringToGlyphs(x,w)}catch(C){console.warn(C)}d=this.getLineInitialOffsetX(n[y],o,t.horizontalAlign,x,h);let b=[];try{b=this.reverseLigaturesTable(r,x,_)}catch(C){console.warn(C)}let A=this.computeSpaceWidthForLine(e,y,t,i),S=0,E=_[0];E&&t.horizontalAlign===2&&E.leftSideBearing!==void 0&&(d-=E.leftSideBearing*s),(v=this.font)==null||v.forEachGlyph(x,d,u,t.fontSize,w,(C,T,D,O,P)=>{let U=C.index===0?`
  5047. `:C.unicode?String.fromCharCode(C.unicode):void 0,W=b[S],k=0;if(U===`
  5048. `)k=c;else if(U===" ")k=A;else{let F=this.createPath(C,s,T,D,t);F&&(k=F.offsetX,p.push(F.path))}if(W.replacements.length===1)g[y].push([T,D]),f[y].push(k);else{let F=W.replacements.map(q=>(r.glyphs.get(q).advanceWidth??0)*s),Z=F.reduce((q,$)=>q+=$,0),X=F.map(q=>q/Z),G=T;for(let q=0;q<X.length;q++){let $=k*X[q];g[y].push([G,D]),f[y].push($),G+=$}}S++}),u-=a}let m=[];for(let y=0,x=p.length;y<x;y++)m.push(...p[y].toShapes());return{shapes:m,charWidths:f,lineWidths:n,charCoords:g}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){var e;return((e=this.font)==null?void 0:e.ascender)??0}get descender(){var e;return((e=this.font)==null?void 0:e.descender)??0}get familyName(){var e;return((e=this.font)==null?void 0:e.names.fontFamily)??""}get subfamilyName(){var e;return((e=this.font)==null?void 0:e.names.fontSubfamily)??""}get unitsPerEm(){var e;return((e=this.font)==null?void 0:e.unitsPerEm)??1}getLineInitialOffsetX(e,t,i,r,s){return(i===3||i===2)&&r.indexOf(`
  5049. `)>=0&&(e-=s),i===3?t*.5-e*.5:i===2?t-e:0}getLineInitialOffsetY(e,t,i,r,s){let a=t*e,n=Math.abs(this.ascender-this.descender)*r,o=e-n,l=-this.ascender*r-o/2;return s===3?-(i-a-l):s===2?-(i*.5-a*.5-l):l}createPath(e,t,i,r,s){var l;let a=e.getPath(i,-r,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!a){console.error('THREE.Font: character "'+e+'" does not exists in font family '+this.familyName+".");return}let n=new rQ,o=(e.advanceWidth??1)*t;if(e)for(let h of a.commands){let c=(l=n.currentPath)==null?void 0:l.currentPoint;if(!(c&&h.type!=="Z"&&c.x===h.x&&-c.y===h.y))switch(h.type){case"M":n.moveTo(h.x,-h.y);break;case"L":n.lineTo(h.x,-h.y);break;case"Q":n.quadraticCurveTo(h.x1,-h.y1,h.x,-h.y);break;case"C":n.bezierCurveTo(h.x1,-h.y1,h.x2,-h.y2,h.x,-h.y);break}}return n.subPaths.forEach(h=>{let c=cQ(h.curves);c!==void 0&&h.currentPoint.distanceTo(c)>0&&h.lineTo(c.x,c.y)}),{offsetX:o,path:n}}getCharWidth(e,t){var i;return((i=this.font)==null?void 0:i.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing}))??0}getTextWidth(e,t){var i;return((i=this.font)==null?void 0:i.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing}))??0}computeSpaceWidthForLine(e,t,i,r){let s=this.getCharWidth(" ",i),a=e[t];if(a){let n=this.countSpaces(a.trimEnd());if(i.horizontalAlign===4&&t<e.length-1&&n){let o=typeof i.width=="string"?Number(r.getVariable(i.width)):i.width,l=this.getTextWidth(a,i);return(o-(l-n*s))/n}}return s}countSpaces(e){return(e.match(/ /g)||[]).length}};function cQ(e){if(e.length){let t=e[0];if(t instanceof Hs)return t.v1;if(t instanceof Vs||t instanceof ho)return t.v0}}var dQ=class{constructor(){this.objects=new Map,this.unreachable=new Set}getCached(e){return this.objects.get(e)}get size(){return this.objects.size}get(e,t,i){let r=this.objects.get(e);return r===void 0?(r=this.createObject(e,t,i),this.objects.set(e,r)):r.isShared=!0,r}forceDelete(e){let t=this.objects.get(e);t&&(this.disposeObject(t),this.objects.delete(e))}mutateIfUnique(e,t){let i=this.objects.get(e);if(i&&i.isShared!==!0)return this.objects.delete(e),this.objects.set(t,i),i}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(e,t){let i=this.objects.get(e);t===i&&this.unreachable.delete(e)}endGc(){this.unreachable.forEach(e=>{this.disposeObject(this.objects.get(e)),this.objects.delete(e)}),this.unreachable.clear()}dispose(){this.objects.forEach(e=>{this.disposeObject(e)}),this.objects.clear()}},kS=class extends dQ{constructor(e){super(),this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t,i){let r=Dd(e,t,this.flatShading,i);return r.computeBoundingSphere(),r}},uQ={markNeedsUpdateRendererDirty:()=>{}},Dp=1e3,VS=512*Dp;function pQ(e,t){let i=typeof e;return!!((t==="string"||t==="number")&&i===t||t==="boolean"&&(e==="true"||e==="false"||e===!0||e===!1)||t==="image"&&i==="string"&&e.startsWith("http"))}var fQ="https://hooks.spline.design",mQ=`${fQ}/events?hashFile=`,gQ=class{constructor(e,t){this.id=e,this.userWebhook=t,this.result=void 0,this._connected=!1,this.emitter=dm(),this.reconnectWaitFor=Dp,this._onError=i=>{var r,s,a;(r=this.eventSource)==null||r.removeEventListener("message",this._onMessage),(s=this.eventSource)==null||s.removeEventListener("error",this._onError),(a=this.eventSource)==null||a.removeEventListener("open",this._onConnected),this._scheduleReconnect()},this._onConnected=i=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Dp,this._connected=!0},this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Dp,this._connected=!1},this._onMessage=i=>{let r=i.data,s;try{s=JSON.parse(r)}catch(a){console.error("Error parsing webhook message",a)}if(s){let a=!1;this.userWebhook.parametersSchemas.forEach(({data:n})=>{s[n.name]!==void 0&&pQ(s[n.name],n.type)&&(this.result===void 0&&(this.result={}),this.result[n.name]=s[n.name],a=!0)}),a&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource(mQ+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){var e,t,i,r;(e=this.eventSource)==null||e.removeEventListener("message",this._onMessage),(t=this.eventSource)==null||t.removeEventListener("error",this._onError),(i=this.eventSource)==null||i.removeEventListener("open",this._onConnected),(r=this.eventSource)==null||r.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>VS&&(this.reconnectWaitFor=VS),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(e){this.userWebhook=e}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(e=>e.data.name)}getParameterValue(e){var t;if(this.getParametersKeys().includes(e)){if(this.result)return(t=this.result)==null?void 0:t[e];for(let i of this.userWebhook.parametersSchemas)if(i.data.name===e)return L0.defaultParameterValueByType(i.data.type)}}},jS=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],vQ=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],lo=[],W1=[];for(let e=1;e<=8;e++)for(let t=0;t<jS.length;t++){let i=jS[t];lo.push(i/Math.pow(2,8-e)),W1.push(vQ[t]+e)}var Rf=[32,2e3],GS=lo.filter((e,t)=>lo[t]>Rf[0]&&lo[t]<Rf[1]),yQ=W1.filter((e,t)=>lo[t]>Rf[0]&&lo[t]<Rf[1]),xQ=class{static getFrequencies(e,t,i,r="frequency",s=-100,a=-30){i||(i=new Float32Array(e.frequencyBinCount),e.getFloatFrequencyData(i));let n=t/2,o=1/i.length*n,l,h,c;if(r==="music"||r==="voice"){let u=r==="voice"?GS:lo,p=Array(u.length).fill(s);for(let f=0;f<i.length;f++){let g=f*o,m=i[f];for(let v=u.length-1;v>=0;v--)if(g>u[v]){p[v]=Math.max(p[v],m);break}}l=p,h=r==="voice"?GS:lo,c=r==="voice"?yQ:W1}else l=Array.from(i),h=l.map((u,p)=>o*p),c=h.map(u=>`${u.toFixed(2)} Hz`);let d=l.map(u=>Math.max(0,Math.min((u-s)/(a-s),1)));return{values:new Float32Array(d),frequencies:h,labels:c}}},bQ="gpt-4o-realtime-preview-2024-12-17",wQ=()=>"https://relayserver.spline.design/";async function _Q(e){try{return(await(await fetch(wQ()+"session?uuidfile="+e)).json()).token}catch(t){console.error("Token generation error:",t)}}var SQ=class{constructor(e){this.value=0,this.frequencies=new Float32Array(0);let t=new AudioContext;this.source=t.createMediaStreamSource(e),this.analyser=t.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(e=-100,t=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return xQ.getFrequencies(this.analyser,44100,void 0,"voice",e,t)}update(){let e=this.getFrequencies(),t=e.values.reduce((i,r)=>i+r,0)/e.values.length;this.value=t,this.frequencies=e.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},HS=class{constructor(e,t,i){this.data=e,this.id=t,this.shared=i,this.emitter=dm(),this.rafId=0,this.voice=0,this.frequencies=new Float32Array([0]),this.events=[],this.isConnected=!1,this.isToolsAdded=!1,this.tools=[],this.onMessage=r=>{var a;let s=JSON.parse(r.data);if(this.appendEvent(s),s.type==="session.created"&&this.onSessionCreated(),s.type==="response.done"&&((a=s.response)==null?void 0:a.output)){for(let n of s.response.output)if(n.type==="function_call")for(let[o,l]of this.tools)n.name===o.name&&(l(JSON.parse(n.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))}},this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()},this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})},this.animate=()=>{if(this.rafId=requestAnimationFrame(this.animate),this.isConnected&&this.analyser){this.analyser.update();let r=this.analyser.value,s=this.analyser.frequencies;this.voice=r,this.frequencies=s,this.emitter.emit("voice",{value:r,frequencies:s})}}}update(e){this.data=e}setColorByName(e,t){let i=this.shared.getColorByName(e);if(i){let{id:r}=i,{r:s,g:a,b:n}=Yq.hexStringToRgb(t)??{r:0,g:0,b:0};this.shared.updateColor(r,{r:s/255,g:a/255,b:n/255})}}async connect(){if(this.isConnected)return;let e=await _Q(this.data.integration.hash);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=s=>{let a=s.streams[0];this.audioElement.srcObject=a,this.analyser=new SQ(a)};let t=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(t.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let i=await this.pc.createOffer();await this.pc.setLocalDescription(i);let r={type:"answer",sdp:await(await fetch(`https://api.openai.com/v1/realtime?model=${bQ}`,{method:"POST",body:i.sdp,headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(r),this.animate()}appendEvent(e){this.events=[e,...this.events]}sendClientEvent(e){this.dc?(e.event_id=e.event_id||crypto.randomUUID(),this.dc.send(JSON.stringify(e)),this.appendEvent(e)):console.error("Failed to send message - no data channel available",e)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:s})=>{this.setColorByName("Voice Assistant Color",s)});let e=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${e}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:s,value:a})=>{let n=this.shared.getVariableByName(s);if(n){let o=this.shared.getVariable(n.id),l;typeof o=="number"?l=parseFloat(a):typeof o=="boolean"?l=a.toLowerCase()==="true":l={textValue:a},this.shared.updateVariable(n.id,l)}});let t=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${t}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:s,value:a})=>{this.setColorByName(s,a)});let i=this.shared.scene,r=[];i.traverseEntity(s=>{s.data.events.forEach(a=>{if(a.data.type==="AIAssistantTrigger"){let{description:n}=a.data;r.push(n)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(r)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:s,direction:a})=>{this.emitter.emit("trigger_event",{description:s,direction:a})}),this.sendClientEvent({type:"session.update",session:{tools:this.tools.map(([s])=>s)}})}registerTool(e,t){this.tools.push([e,t])}disconnect(){var e,t,i,r,s,a;cancelAnimationFrame(this.rafId),(e=this.analyser)==null||e.disconnect(),this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,(t=this.dc)==null||t.removeEventListener("message",this.onMessage),(i=this.dc)==null||i.removeEventListener("open",this.onOpen),(r=this.dc)==null||r.close(),(s=this.pc)==null||s.getSenders().forEach(n=>{n.track&&n.track.stop()}),(a=this.pc)==null||a.close(),this.pc=void 0}computeAnalysisForListenerEvent(e){if(e.analysis==="range"){let t=this.frequencies.slice(...e.analysisRange);return t.reduce((i,r)=>i+r,0)/t.length}return e.analysis==="single"?this.frequencies[e.analysisSingle]:this.voice}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}};function ly(e){return"variable_"+e}var AQ=class extends hY{constructor(e){super(),this.shared=e}create(e){return new PT(e,this.shared)}},q1=class{constructor(e,t={},i=!0,r=!1){if(this.data=e,this.needsJitter=i,this.enableLocalStorageForPersistentVariables=r,this.geometryCache=new kS(!0),this.geometryCache2=new kS(!1),this.imageHolderCache=new AQ(this),this.thisContext={scene:uQ,shared:this},this.deletedMaterial=new oy(ir.defaultTwoLayerData("phong"),this.thisContext,""),this.deletedImage=new Yn(B0.emptyImage,this),this.deletedVideo=new Yn(ff.defaultVideo,this),this.materials={},this.images={},this.uiBuffers={},this.videos={},this.colors={},this.audios={},this.particles={},this.fonts={},this.variables={},this.userAPIs={},this.userWebhooks={},this.mouseProperty=null,this.raycastProperty=null,this.requestRender=()=>{this._requestRender&&this._requestRender()},t.images)for(let[s,a]of Object.entries(t.images))this.addImage(s,a);if(t.videos)for(let[s,a]of Object.entries(t.videos))this.addVideo(s,a);if(t.audios)for(let[s,a]of Object.entries(t.audios))this.addAudio(s,a);if(t.particles)for(let[s,a]of Object.entries(t.particles))this.addParticle(s,a);this.reset(e)}setRequestRender(e){this._requestRender=e}getImageLoadPromises(){return Object.values(this.images).map(e=>e.loadPromise)}setEntityOpContext(e){this.entityOpContext=e}reset(e,t=!1,i=!1){this.data=e,this.resetLib(e.lib);for(let{id:r,data:s}of e.variables)this.addVariableHolder(r,s),t&&this.updateVariableHolder(r,s);for(let[r,s]of Object.entries(e.userAPIs))this.addUserAPI(r,s);for(let[r,s]of Object.entries(e.userWebhooks))this.addUserWebhook(r,s);if(!i){for(let[r,s]of Object.entries(e.images))this.addImage(r,s);for(let[r,s]of Object.entries(e.videos))this.addVideo(r,s)}for(let[r,s]of Object.entries(e.colors))this.addColor(r,s);for(let[r,s]of Object.entries(e.materials))this.addMaterial(r,s);for(let[r,s]of Object.entries(e.audios))this.addAudio(r,s);for(let[r,s]of Object.entries(e.particles))this.addParticle(r,s);for(let[r,s]of Object.entries(e.fonts))this.addFont(r,s)}addMaterial(e,t){if(this.materials[e]){let i=this.materials[e];i.reset(t,this.thisContext),i.dispose()}else{let i=new oy(t,this.thisContext,e);this.materials[e]=i}}deleteMaterial(e){this.materials[e]&&(this.materials[e].nodeMaterialDispose(),delete this.materials[e])}getMaterial(e){return this.materials[e]}getMaterialOrDeletedPlaceholder(e){return this.materials[e]??this.deletedMaterial}material(e){return typeof e=="string"?this.getMaterialOrDeletedPlaceholder(e):e==null?(console.error("material is undefined or null"),this.deletedMaterial):new H1(e,this.thisContext)}getMaterials(){return this.materials}addImage(e,t){return this.images[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[e].updateSrc(t.data),!0):(this.images[e]=new Yn(t,this),!1)}deleteImage(e){let t=this.images[e];t&&(t.dispose(),delete this.images[e])}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]??this.deletedImage}image(e){return typeof e=="string"?this.getImage(e):this.imageHolderCache.load(e)}addUIBuffer(e,t){return this.uiBuffers[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[e].updateSrc(t),!0):(this.uiBuffers[e]=new Yn(t,this),!1)}uiBuffer(e){return this.uiBuffers[e]}addVideo(e,t){return this.videos[e]?(this.videos[e].updateSrc(t.data),!0):(this.videos[e]=new Yn(t,this),!1)}deleteVideo(e){let t=this.videos[e];t&&(t.dispose(),delete this.videos[e])}getVideo(e){return this.videos[e]??this.deletedVideo}video(e){return typeof e=="string"?this.getVideo(e):this.imageHolderCache.load(e)}addColor(e,t){return this.colors[e]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new Of(t.r,t.g,t.b,t.a):this.colors[e]=new Of(t.r,t.g,t.b,1),!1)}updateColor(e,t){if(this.colors[e]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let i=this.colors[e];return this.colors[e].r=t.r??i.r,this.colors[e].g=t.g??i.g,this.colors[e].b=t.b??i.b,this.colors[e].a=t.a??i.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}getColorNames(){return Object.values(this.data.colors).map(e=>e.name)}getColorByName(e){for(let t in this.data.colors)if(this.data.colors[t].name===e)return{color:this.colors[t],id:t}}color(e){let t;if(typeof e=="string"){let i=this.getColor(e);i?t=i:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new vr(0,0,0,0))}else return"a"in e?new vr(e.r,e.g,e.b,e.a):new vr(e.r,e.g,e.b,1);return t}addAudio(e,t){this.audios[e]=t}getAudio(e){let t=this.audios[e];if(t instanceof qc)return t;{let i=new qc({src:t.data});return this.audios[e]=i,i}}addParticle(e,t){this.particles[e]=t}getParticle(e){return this.particles[e]}deleteParticle(e){this.particles[e]&&delete this.particles[e]}deleteAudio(e){let t=this.audios[e];t&&(t instanceof qc&&t.dispose(),delete this.audios[e])}addFont(e,t){this.fonts[e]=new hQ(t),this.fonts[e].loadingPromise.then(()=>this.requestRender())}getFont(e){return this.fonts[e]}deleteFont(e){this.fonts[e]&&delete this.fonts[e]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof qc&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(e,t){if(this.variables[e]===void 0){let i=t.value;if(this.enableLocalStorageForPersistentVariables&&t.persistent){let r=localStorage.getItem(ly(e));i=r!==null?JSON.parse(r):t.value}return this.variables[e]={value:i,locations:[],persistent:t.persistent},"dynamicVariableType"in t&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0),!0}return this.variables[e].value=t.value,!1}resetDynamicVariablePlayState(){for(let e in this.variables)this.variables[e].dynamicVariablePlayState!==void 0&&(this.variables[e].dynamicVariablePlayState="Playing",this.variables[e].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(e,t){this.updateVariable(e,t.value)}updateVariable(e,t){if(this.variables[e]===void 0)return!1;this.variables[e].value=t,this.enableLocalStorageForPersistentVariables&&this.variables[e].persistent&&localStorage.setItem(ly(e),JSON.stringify(t));let i=t;for(;typeof i=="string";)i=this.variables[i].value;let r=this.entityOpContext.scene;for(let s=this.variables[e].locations.length-1;s>=0;s--){let a=this.variables[e].locations[s];if(a[0]==="material"){let n=a[1],o=i,l={scene:r,shared:this},h=a.slice(2);r.traverseMaterial(d=>{let u=d.root??d;u.uuid===n&&u.onVariableUpdate(h,o,l)});let c=this.materials[n];c&&c.onVariableUpdate(h,o,l)}else{let n=r.find(a[0]);if(n===void 0){this.variables[e].locations.splice(s,1);continue}if(a[1]!=="geometry"&&a[1]!=="particles"){for(let o=1;o<a.length-1;o++)n=n[a[o]];a[1]==="rotation"?n[a[a.length-1]]=i*Re.DEG2RAD:n[a[a.length-1]]=i}if(n=r.find(a[0]),n.type==="ParticleEmitter"&&n.updateVariableState(i,a),Tt.is(n))if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")n.onVariableUpdate();else if(a[1]==="geometry"){let o=n;n.component&&(o=n.component);let l=o.dataPatched;o.chooseGeoemtryCache(this).forceDelete(l.geometry),o.createGeometryDelayed(this.entityOpContext),o.onVariableUpdate(!0),o.invalidateDownstreamBooleanData(),o.instances.forEach(h=>{let c=h.dataPatched;h.chooseGeoemtryCache(this).forceDelete(c.geometry),h.createGeometryDelayed(this.entityOpContext),h.onVariableUpdate(!0),h.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&n.updateMorphInfluences(a[2],i)}}return this.requestRender(),!0}deleteVariable(e){this.variables[e]&&delete this.variables[e]}getVariable(e,t){var i,r,s;if(Array.isArray(e)){if(e[0]==="mouse")return((i=this.mouseProperty)==null?void 0:i[e[1]])??0;if(e[0]==="raycast")return((r=this.raycastProperty)==null?void 0:r[e[1]])??0;let a=this.entityOpContext.scene.find(e[0]);if(e[1]==="width"||e[1]==="height"||e[1]==="depth")return a.geometry.userData.parameters[e[1]];for(let n=1;n<e.length;n++)a=a[e[n]];return e[1]==="rotation"&&(a*=Re.RAD2DEG),a}for(let a in this.variables){if(t===void 0)break;let n=this.variables[a],o=(s=n.locations)==null?void 0:s.findIndex(l=>Gi.equal(l,t));o!==void 0&&o!==-1&&n.locations.splice(o,1)}if(typeof e=="string"){let a=e,n=e;do{if(n=a,this.variables[a]===void 0)break;let o=this.variables[a].value;t&&this.variables[n]!==void 0&&this.variables[n].locations.push(t),a=o}while(typeof a=="string");return a}else return e}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(e=>e.data.name)}getVariableByName(e){for(let t of this.data.variables)if(t.data.name===e)return{variable:t.data,id:t.id}}getDynamicVariablePlayState(e){var t;return(t=this.variables[e])==null?void 0:t.dynamicVariablePlayState}setDynamicVariablePlayState(e,t){this.variables[e]!==void 0&&(this.variables[e].dynamicVariablePlayState=t)}getDynamicVariableToggleIsForward(e){var t;return(t=this.variables[e])==null?void 0:t.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(e,t){this.variables[e]!==void 0&&(this.variables[e].dynamicVariableToggleIsForward=t)}resetLib(e){for(let[t,i]of Object.entries(e.images))this.addImage(t,i.asset);for(let[t,i]of Object.entries(e.audios))this.addAudio(t,i.asset);for(let[t,i]of Object.entries(e.particles))this.addParticle(t,i.asset);for(let[t,i]of Object.entries(e.colors))this.addColor(t,i.asset);for(let[t,i]of Object.entries(e.fonts))this.addFont(t,i.asset);for(let[t,i]of Object.entries(e.materials))this.addMaterial(t,i.asset);for(let[t,i]of Object.entries(e.videos))this.addVideo(t,i.asset);for(let[t,i]of Object.entries(e.variables))this.addVariableHolder(t,i.asset)}updateLibByOp(e,t){e.path[0]==="images"?e.path.length===1&&e.type===1?this.addImage(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteImage(e.id):e.path[0]==="videos"?e.path.length===1&&e.type===1?this.addVideo(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteVideo(e.id):e.path[0]==="audios"?e.path.length===1&&e.type===1?this.addAudio(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteAudio(e.id):e.path[0]==="particles"?e.path.length===1&&e.type===1?this.addParticle(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteParticle(e.id):e.path[0]==="colors"?e.path.length===1&&e.type===1?this.addColor(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteColor(e.id):e.path[0]==="materials"?e.path.length===1&&e.type===1?this.addMaterial(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteMaterial(e.id):e.path[0]==="fonts"?e.path.length===1&&e.type===1?this.addFont(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteFont(e.id):e.path[0]==="variables"?e.path.length===1&&e.type===1?this.addVariableHolder(e.id,e.data.asset):e.path.length===1&&e.type===2&&this.deleteVariable(e.id):e.path[0]==="components"&&t.updateByLibOp(e,this)}updateByOp(e,t,i){var r;if(this.data=t,e.path[0]==="images")e.path.length===2&&e.type===0?e.props.data&&this.getImage(e.path[1]).updateSrc(e.props.data):e.path.length===1&&e.type===1?this.addImage(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteImage(e.id);else if(e.path[0]==="videos")e.path.length===2&&e.type===0?e.props.data&&this.getVideo(e.path[1]).updateSrc(e.props.data):e.path.length===1&&e.type===1?this.addVideo(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteVideo(e.id);else if(e.path[0]==="audios")e.path.length===2&&e.type===0?e.props.data&&this.addAudio(e.path[1],t.audios[e.path[1]]):e.path.length===1&&e.type===1?this.addAudio(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteAudio(e.id);else if(e.path[0]==="particles")e.path.length===2&&e.type===0?e.props.data&&this.addParticle(e.path[1],t.particles[e.path[1]]):e.path.length===1&&e.type===1?this.addParticle(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteParticle(e.id);else if(e.path[0]==="colors")e.path.length===2&&e.type===0?this.updateColor(e.path[1],e.props):e.path.length===1&&e.type===1?this.addColor(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteColor(e.id);else if(e.path[0]==="materials")e.path.length===1&&e.type===1?this.addMaterial(e.id,e.data):e.path.length===1&&e.type===2?this.deleteMaterial(e.id):e.path.length>1&&this.getMaterial(e.path[1]).updateByOp(tr.drop(e,2),t.materials[e.path[1]],{shared:this,scene:i});else if(e.path[0]==="fonts")e.path.length===2&&e.type===0?this.updateFont(e.path[1],e,i):e.path.length===1&&e.type===1?this.addFont(e.id,e.data):e.path.length===1&&e.type===2&&this.deleteFont(e.id);else if(e.path[0]==="variables")e.path.length===2&&e.type===0?"value"in e.props?this.updateVariable(e.path[1],e.props.value):"persistent"in e.props&&(this.variables[e.path[1]].persistent=e.props.persistent):e.path.length===1&&e.type===4?this.addVariableHolder(e.id,e.data):e.path.length===1&&e.type===5&&this.deleteVariable(e.id);else if(e.path[0]==="userAPIs"){if(e.path.length===1&&e.type===1)this.addUserAPI(e.id,e.data);else if(e.path.length===1&&e.type===2)this.deleteUserAPI(e.id);else if(typeof e.path[1]=="string"){let s=t.userAPIs[e.path[1]];if(s){let a=e.type===0&&e.props.debounce===void 0,n=this.getUserAPI(e.path[1]);n instanceof HS?n.update(s):n==null||n.update(s,this,a)}}}else if(e.path[0]==="userWebhooks"){if(e.path.length===1&&e.type===1)this.addUserWebhook(e.id,e.data);else if(e.path.length===1&&e.type===2)this.deleteUserWebhook(e.id);else if(typeof e.path[1]=="string"){let s=t.userWebhooks[e.path[1]];s&&((r=this.getUserWebhook(e.path[1]))==null||r.update(s))}}else e.path[0]==="lib"&&this.updateLibByOp(tr.drop(e,1),i)}updateFont(e,t,i){if(t.props.url){let r=this.getFont(e),s={...this.data.fonts[e],url:t.props.url};r.update(s),r.loadingPromise.then(()=>this.requestRender()),i.updateFont(e,this)}}addUserAPI(e,t){var i,r;return this.userAPIs[e]?(this.userAPIs[e].update(t,this),!0):((i=this.openAIRealtime)==null?void 0:i.id)===e?(this.openAIRealtime.update(t),!0):((r=t.integration)==null?void 0:r.type)==="VoiceAssistant"?(this.openAIRealtime=new HS(t,e,this),!1):(this.userAPIs[e]=new qC(e,t,this),!1)}getUserAPI(e){var t;return((t=this.openAIRealtime)==null?void 0:t.id)===e?this.openAIRealtime:this.userAPIs[e]}getUserAPIs(){return this.userAPIs}deleteUserAPI(e){let t=this.userAPIs[e];t&&(t.dispose(),delete this.userAPIs[e])}addUserWebhook(e,t){return this.userWebhooks[e]?(this.userWebhooks[e].update(t),!0):(this.userWebhooks[e]=new gQ(e,t),!1)}getUserWebhook(e){return this.userWebhooks[e]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(e){let t=this.userWebhooks[e];t&&(t.dispose(),delete this.userWebhooks[e])}get scene(){return this.entityOpContext.scene}};new q1(vs.emptyData());var xl=class extends Vr{updateByPatchedOp(e,t,i){if(super.updateByPatchedOp(e,t,i),L8(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[r,s]of Object.entries(e.props)){let a=i.shared.material(s);this.material[Number(r)]=a}else if(Qt(e.path,["material"])&&this.material instanceof uo)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(tr.drop(e,1),t.material,i);else if(Qt(e.path,["materials","*"])&&Array.isArray(this.material)){let r=e.path[1];if("materials"in t&&r<this.material.length){let s=t.materials[r];typeof s!="string"&&this.material[r].updateByOp(tr.drop(e,2),s,i)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,t){var s,a;super.updateState(e,t),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let i=this.dataPatched;this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.shapeBlendNode&&this.layers.set(9);let r;if(this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(r={resolutionLevel:this.dataPatched.geometry.resolutionLevel,useChildrenColors:this.dataPatched.geometry.useChildrenColors}),((s=e.geometry)==null?void 0:s.type)!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=t.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe,r),t.scene.markNeedsUpdateRendererDirty()),(((a=e.geometry)==null?void 0:a.type)==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(n=>t.shared.material(n).getFlavor(i.flatShading,i.side,i.wireframe)),t.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[t.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe)],t.scene.markNeedsUpdateRendererDirty())),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let n=0;n<this.material.length;n++)this.material[n]=this.material[n].getFlavor(i.flatShading,i.side,i.wireframe);else this.material=this.material.getFlavor(i.flatShading,i.side,i.wireframe,r)}disposeMaterial(){this.material&&BE(this.material).forEach(e=>{e instanceof uo&&(e instanceof oy||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}},WS=new M,qS=new ct,XS=new ct,MQ=new M,YS=new we,Ii=class extends xl{constructor(e,t,i){super(e,t),this.data=t,this.isSkinnedMesh=!1,this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.bindMode=t.bindMode,this.bindMatrix=new we().fromArray(t.bindMatrix),this.bindMatrixInverse=new we)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Ge&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof q1){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=t.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return vf.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return vf.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),Qt(e.path,["geometry"])&&this.updateByPatchedOpGeometry(tr.drop(e,1),t.geometry,i)}removeInteractionGeometry(e){var t;(t=this.localGeometry)==null||t.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,t){var r;this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let s=e;if(this.localGeometry===void 0){let h={...this.data.geometry,...s};this.localGeometry=Dd(h,t,this.data.flatShading,this)}let a,n,o;s.scaleBaked?[a,n,o]=s.scaleBaked:{width:a,height:n,depth:o}=s;let l=this.localGeometry.userData;l.sxPrev!==void 0&&ty(this.localGeometry.attributes,a/l.sxPrev,n/l.syPrev,o/l.szPrev),l.sxPrev=a,l.syPrev=n,l.szPrev=o}else{let s={...this.data.geometry,...e};(r=this.localGeometry)==null||r.dispose(),this.localGeometry=Dd(s,t,this.data.flatShading,this)}}refreshAttachedClonersInteractions(){for(let e of this.attachedSurfaceCloners)e.update()}refreshAttachedCloners(e){for(let t of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(t.object)}refreshAttachedPaths(e){for(let t of this.attachedPaths)e.scene.addPendingCommand(()=>t.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,t,i){var s;let r=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof zr&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,t)===this.geometryCreateDeleyed&&(r=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t,e.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),r||((s=i.scene)==null||s.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,t){this.createGeometryDelayed(t)}updateState(e,t){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,t);let i=e.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:r,value:s}}of i)this.updateMorphInfluences(r,t.shared.getVariable(s,[this.uuid,"morphTargetInfluences",r]))}super.updateState(e,t)}updateMorphInfluences(e,t){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[e];i!==void 0&&(this.morphTargetInfluences[i]=t)}updateGeometryGroupsIfNeeded(){var e;Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(((e=this.geometry.getIndex())==null?void 0:e.count)??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,t){let i=this.geometry.userData.parameters;this.is2DType?e.set(0,0,i.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),t.set(i.width,i.height,i.depth??0).multiplyScalar(.5)):i.centerOffset?e.fromArray(i.centerOffset):e.setScalar(0),t.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,t){this.skeleton=e,this.isSkinnedMesh=!0,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let t=new ct,i=this.geometry.attributes.skinWeight;for(let r=0,s=i.count;r<s;r++){t.fromBufferAttribute(i,r);let a=1/t.manhattanLength();a!==1/0?t.multiplyScalar(a):t.set(1,0,0,0),i.setXYZW(r,t.x,t.y,t.z,t.w)}}boneTransform(e,t){let i=this.skeleton;if(i===void 0)return;let r=this.geometry;qS.fromBufferAttribute(r.attributes.skinIndex,e),XS.fromBufferAttribute(r.attributes.skinWeight,e),WS.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let a=XS.getComponent(s);if(a!==0){let n=qS.getComponent(s);YS.multiplyMatrices(i.bones[n].matrixWorld,i.boneInverses[n]),t.addScaledVector(MQ.copy(WS).applyMatrix4(YS),a)}}return t.applyMatrix4(this.bindMatrixInverse)}};function EQ(e){var n,o;if(e.geometry.attributes.extrudeNormal||!e.geometry.attributes.position||!e.geometry.attributes.normal)return;let t=new Map,i=e.geometry.attributes,r=i.position.array,s=i.normal.array,a=new Float32Array(r.length);for(let l=0;l<r.length;l+=3){let h=`${r[l]}_${r[l+1]}_${r[l+2]}`,c=new M(s[l],s[l+1],s[l+2]);t.has(h)?(n=t.get(h))==null||n.normals.push(c):t.set(h,{normals:[c],result:new M})}t.forEach((l,h)=>{for(let c of l.normals)l.result.add(c);l.result.divideScalar(l.normals.length)});for(let l=0;l<r.length;l+=3){let h=`${r[l]}_${r[l+1]}_${r[l+2]}`,c=(o=t.get(h))==null?void 0:o.result;c&&(a[l]=c.x,a[l+1]=c.y,a[l+2]=c.z)}e.geometry.setAttribute("extrudeNormal",new Ie(a,3))}function CQ(e){if(e.geometry.attributes.extrudeNormals||!e.geometry.attributes.position)return;let t=e.geometry.attributes.position.array,i=new Float32Array(t.length),r=new M;for(let s=0;s<t.length;s+=3)r.set(t[s],t[s+1],t[s+2]).normalize(),i[s]=r.x,i[s+1]=r.y,i[s+2]=r.z;e.geometry.setAttribute("extrudeNormal",new Ie(i,3))}function X1(e){if(Array.isArray(e.material)){for(let t of e.material)if(t.getLayersOfType("outline").length===0)return}else if(!(e.material instanceof uo)||e.material.getLayersOfType("outline").length===0)return;e instanceof Ii&&e.is2DAndNoDepth?CQ(e):EQ(e)}function Y1(e){if(!e.geometry.attributes.position)return;let t=e.geometry.attributes.position.array,i=new Float32Array(t.length),r=parseInt(e.uuid.replace(/\D/g,"")),s=[Re.seededRandom(r),Re.seededRandom(r+1e4),Re.seededRandom(r+2e4)];for(let a=0;a<t.length;a++)i[a]=s[a%3];e.geometry.setAttribute("randomColor",new tt(i,3))}var sa=new Si,Ec=new M;function TQ(e){let t=!1;return e.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Id=class extends Ii{constructor(e,t,i){super(e,t,i),this.data=t,this.hiddenMatrixOld=new we,this.smoothShading=!0,this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,t){let i=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),t.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}createGeometryByControls(e){var a,n,o;if(this.skipReactionUpdate===!0)return;let t=(a=this.localGeometry)==null?void 0:a.uuid,{originalGeometry:i,subdividedGeometry:r,subdivPointer:s}=zr.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=s,i!==void 0&&((n=this.originalGeometry)==null||n.dispose(),this.originalGeometry=i),r!==void 0&&((o=this.subdividedGeometry)==null||o.dispose(),this.subdividedGeometry=r??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,X1(this),Y1(this),this.calcBoundingBox(),t&&(this.localGeometry.uuid=t)}updateState(e,t){if(super.updateState(e,t),e.flatShading!==void 0){let i=this.material;this.material=Array.isArray(i)?i.map(r=>r.getFlavor(!1,r.side,r.wireframe)):i.getFlavor(!1,i.side,i.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(t)}}updateMesh(e=!1){zr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&zr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=zr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=zr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,t){let i=this.localGeometry;this.localGeometry=this.originalGeometryNew,Vr.prototype.raycast.call(this,e,t),this.localGeometry=i}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new $r,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;sa.setFromBufferAttribute(t),sa.getCenter(i),e.boundingSphere.radius=i.distanceTo(sa.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),sa.getSize(Ec),this.hasNonUniformScale&&Ec.divide(this.scale);let r={width:Ec.x,height:Ec.y,depth:Ec.z};return this.geometry.userData.parameters=r,r}updateBoundingSphere(e){let t=this.originalGeometry;sa.min.set(e[0],e[2],e[4]),sa.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(sa.min.applyMatrix4(this.shearScaleInv),sa.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new $r);let i=t.boundingSphere.center;sa.getCenter(i),t.boundingSphere.radius=i.distanceTo(sa.max)}freeSubdivPointer(){var e,t;this.subdivPointer&&(zr.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,(e=this.originalGeometry)==null||e.dispose(),(t=this.subdividedGeometry)==null||t.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,t,i){super.updateByPatchedOpGeometry(e,t,i),this.localGeometry&&this.createGeometryByControls(t)}},QS=-1,PQ=1,DQ={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},IQ={polygon_center:0,edge:1,vertex:2},tp=(e,t)=>(i,r)=>!t||i===0||e===0?0:e*r/100,mt=(e,t)=>{let i=Math.abs(t),r=i*-1;return(e-QS)*(i-r)/(PQ-QS)+r},OQ=new M,ip=new M,RQ=new M,LQ=new M;function Ah(e,t){let i=RQ.fromArray(e),r=LQ.fromArray(t);ip.copy(r).sub(i);let s=ip.length();return ip.normalize().multiplyScalar(s*.5),OQ.copy(i).add(ip).toArray()}var ys=new pr,rp=new M,Lf=new M,Vo=new M;function zQ(e){let t=[];for(let i=0;i<=e.index.count;i++)if(rp.fromArray(e.index.array,i*3),ys.setFromAttributeAndIndices(e.attributes.position,rp.x,rp.y,rp.z),ys.getNormal(Lf),ys.getMidpoint(Vo),!(isNaN(Vo.x)||isNaN(Vo.y)||isNaN(Vo.z))){let{a:r,b:s,c:a}=ys,n=r.toArray(),o=s.toArray(),l=a.toArray(),h=r.distanceTo(s),c=s.distanceTo(a),d=a.distanceTo(r),u=Ah(n,o),p=Ah(o,l),f=Ah(l,n),g=[h,c,d],m=Math.max(...g),v=g.filter(w=>Math.round(w)===Math.round(m)).length>1,y=[],x=ys.getMidpoint(Vo).toArray();m===h&&!v&&(y=[p,f,f],x=u),m===c&&!v&&(y=[u,f,f],x=p),m===d&&!v&&(y=[u,p,p],x=f),v&&(y=[u,p,f]),t.push({vertices:[n,o,l],faceCenters:y,midpoint:x,norm:ys.getNormal(Lf).toArray()})}return t}function BQ(e){let t=[],{position:i}=e.attributes;for(let r=0;r<i.count;r++){ys.setFromAttributeAndIndices(i,r*3,r*3+1,r*3+2),ys.getNormal(Lf),ys.getMidpoint(Vo);let s=ys.a.toArray(),a=ys.b.toArray(),n=ys.c.toArray();t.push({vertices:[s,a,n],faceCenters:[Ah(s,a),Ah(a,n),Ah(n,s)],midpoint:Vo.toArray(),norm:Lf.toArray()})}return t}var FQ=4,UQ=.5,Hg=e=>.5*(1-Math.cos(e*Math.PI)),NQ=class{constructor(){this.perlin=new Array(4096)}noise(e,t=0,i=0){if(this.perlin==null){this.perlin=new Array(4096);for(let m=0;m<4096;m++)this.perlin[m]=Math.random()}e<0&&(e=-e),t<0&&(t=-t),i<0&&(i=-i);let r=Math.floor(e),s=Math.floor(t),a=Math.floor(i),n=e-r,o=t-s,l=i-a,h,c,d=0,u=.5,p,f,g;for(let m=0;m<FQ;m++){let v=r+(s<<4)+(a<<8);h=Hg(n),c=Hg(o),p=this.perlin[v&4095],p+=h*(this.perlin[v+1&4095]-p),f=this.perlin[v+16&4095],f+=h*(this.perlin[v+16+1&4095]-f),p+=c*(f-p),v+=256,f=this.perlin[v&4095],f+=h*(this.perlin[v+1&4095]-f),g=this.perlin[v+16&4095],g+=h*(this.perlin[v+16+1&4095]-g),f+=c*(g-f),p+=Hg(l)*(f-p),d+=p*u,u*=UQ,r<<=1,n*=2,s<<=1,o*=2,a<<=1,l*=2,n>=1&&(r++,n--),o>=1&&(s++,o--),l>=1&&(a++,l--)}return d}noiseSeed(e){let t=(()=>{let i,r;return{setSeed(s){r=i=(s??Math.random()*4294967296)>>>0},getSeed(){return i},rand(){return r=(1664525*r+1013904223)%4294967296,r/4294967296}}})();t.setSeed(e),this.perlin=new Array(4096);for(let i=0;i<4096;i++)this.perlin[i]=t.rand()}},kQ=NQ,ZS=new M,KS=new we,JS=new Hh;function $S(e){let t=!1;return e.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(t=!0)}),t}var Q1=class extends Ii{constructor(e,t,i){super(e,t,i),this.data=t}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){var t;let e=this.dataPatched;return((t=this.font)==null?void 0:t.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,e.geometry.height,this.fontScale,e.geometry.verticalAlign))??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){var e;return(((e=this.font)==null?void 0:e.ascender)??1)*this.fontScale}get descender(){var e;return(((e=this.font)==null?void 0:e.descender)??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,t){let{matrixWorld:i}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(KS.copy(i).invert(),JS.copy(e.ray).applyMatrix4(KS),JS.intersectBox(this.singleBBox,ZS))){let r=ZS.applyMatrix4(i),s=e.ray.origin.distanceTo(r);t.push({distance:s,point:r.clone(),object:this})}}},Or=1e-4,aa,kT,VT,jT,eA=new M,tA=new M;KC.then(e=>{aa=e,kT=[aa.get_face_center,aa.get_edge_midpoint,aa.get_vertex_position],VT=[aa.get_face_normal,aa.get_edge_normal,aa.get_vertex_normal],jT=[aa.face_count,aa.edge_count,aa.vertex_count]});var VQ=new we,jQ=new we,Rn=new M,sp=new M,Cc=new M,Wg=new M,GQ=new M,HQ=new M,WQ=class{constructor(e,t){this.data=e,this.is3D=t,this.perlin=new kQ,e.noiseType==="perlin"?(this.perlin.noiseSeed(e.seed),t?this.noise=(i,r,s)=>this.perlin.noise(i,r,s):this.noise=i=>this.perlin.noise(i)):t?this.noise=x7((0,q0.default)(e.seed)):this.noise=y7((0,q0.default)(e.seed))}},bs=class extends D1(kt){constructor(e,t){super(),this.parameters=t,this.objectForSample=void 0,this._pendingMediaLoad=!1,this.random=null,this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let t of this.children)t instanceof gr&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof gr&&t.object===e&&(t.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let t;if(e!==void 0?t=e:t=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"){if(!this.parameters.toObject.object)t=0;else if(e===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.parameters.type==="toObject"&&this.objectForSample){let i=this.children;if(i.length===t)return;if(i.length<t)for(let r=0,s=t-i.length;r<s;++r){let a=new gr(this.object);a.expand(),this.add(a)}else for(let r=0,s=i.length-t;r<s;++r)this.remove(i[r])}else{if(this.children.length===t)return;if(this.children.length<t)for(let i=0,r=t-this.children.length;i<r;++i){let s=new gr(this.object);s.expand(),this.add(s)}else for(let i=0,r=this.children.length-t;i<r;++i)this.remove(this.children[i])}}getRandom(e,t=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.is3D!==t)&&(this.random=new WQ(e,t)),this.random}_updateRadial(e){let t=e.radial,i=t.start*Re.DEG2RAD,r=t.end*Re.DEG2RAD,s=i-r,a=new ji(t.rotation[0],t.rotation[1],t.rotation[2]),n;switch(t.axis){case"z":n=new M(0,0,1);break;case"y":n=new M(0,1,0);break;default:case"x":n=new M(1,0,0);break}let o=e.randomnessObject??Kn.defaultData([1,1,1]).randomnessObject,l=this.getRandom(o),h=tp(o.strength,this.parameters.randomness);for(let[c,d]of this.children.entries()){let u=c*(o.freqScale/10)+o.movement,p=l.noise(u,u,u),f=c+1;d.scale.x=t.scale[0]+h(f,mt(p,o.scale[0]))||Or,d.scale.y=t.scale[1]+h(f,mt(p,o.scale[1]))||Or,d.scale.z=t.scale[2]+h(f,mt(p,o.scale[2]))||Or,d.position.setScalar(0);let g=s/e.count*c-i;switch(t.axis){case"x":d.rotation.set(0,g,0);break;case"y":d.rotation.set(0,0,g);break;case"z":d.rotation.set(g,0,0);break}d.translateOnAxis(n,t.radius),d.position.x+=t.position[0]+h(f,mt(p,o.position[0])),d.position.y+=t.position[1]+h(f,mt(p,o.position[1])),d.position.z+=t.position[2]+h(f,mt(p,o.position[2]));let m=h(f,mt(p,o.rotation[0])),v=h(f,mt(p,o.rotation[1])),y=h(f,mt(p,o.rotation[2]));t.alignment===!0?(d.rotation.x+=a.x+m,d.rotation.y+=a.y+v,d.rotation.z+=a.z+y):d.rotation.set(a.x+m,a.y+v,a.z+y)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,i=new ji(t.rotation[0],t.rotation[1],t.rotation[2]),r=e.randomnessObject??Kn.defaultData([1,1,1]).randomnessObject,s=this.getRandom(r),a=tp(r.strength,this.parameters.randomness);for(let[n,o]of this.children.entries()){let l=n*(r.freqScale/10)+r.movement,h=s.noise(l,l,l),c=n+1,d=a(c,mt(h,r.rotation[0])),u=a(c,mt(h,r.rotation[1])),p=a(c,mt(h,r.rotation[2]));o.scale.x=1+(t.scale[0]-1)*n+a(c,mt(h,r.scale[0]))||Or,o.scale.y=1+(t.scale[1]-1)*n+a(c,mt(h,r.scale[1]))||Or,o.scale.z=1+(t.scale[2]-1)*n+a(c,mt(h,r.scale[2]))||Or,o.rotation.x=i.x*n+d,o.rotation.y=i.y*n+u,o.rotation.z=i.z*n+p,o.position.x=t.position[0]*n+a(c,mt(h,r.position[0])),o.position.y=t.position[1]*n+a(c,mt(h,r.position[1])),o.position.z=t.position[2]*n+a(c,mt(h,r.position[2]))}}_updateGrid(e){let t=0,i=e.grid,r=e.randomnessObject??Kn.defaultData([1,1,1]).randomnessObject,s=this.getRandom(r,!0),a=tp(r.strength,this.parameters.randomness);if(i.useCenter===!0){let n={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new M(i.size[0]*(i.count[0]-n.x)*.5,i.size[1]*(i.count[1]-n.y)*.5,i.size[2]*(i.count[2]-n.z)*.5);for(let l=0;l<i.count[0];l++)for(let h=0;h<i.count[1];h++)for(let c=0;c<i.count[2];c++){let d=s.noise((l+1)*(r.freqScale/10)+r.movement,(h+1)*(r.freqScale/10)+r.movement,(c+1)*(r.freqScale/10)+r.movement),u=this.children[t++];u.scale.x=1+a(t,mt(d,r.scale[0]))||Or,u.scale.y=1+a(t,mt(d,r.scale[1]))||Or,u.scale.z=1+a(t,mt(d,r.scale[2]))||Or;let p=a(t,mt(d,r.rotation[0])),f=a(t,mt(d,r.rotation[1])),g=a(t,mt(d,r.rotation[2]));u.rotation.set(p,f,g),u.position.x=i.size[0]*l-o.x+a(t,mt(d,r.position[0])),u.position.y=i.size[1]*h-o.y+a(t,mt(d,r.position[1])),u.position.z=i.size[2]*c-o.z+a(t,mt(d,r.position[2]))}}else for(let n=0;n<i.count[0];n++)for(let o=0;o<i.count[1];o++)for(let l=0;l<i.count[2];l++){let h=s.noise((n+1)*(r.freqScale/10)+r.movement,(o+1)*(r.freqScale/10)+r.movement,(l+1)*(r.freqScale/10)+r.movement),c=this.children[t++];c.scale.x=1+a(t,mt(h,r.scale[0]))||Or,c.scale.y=1+a(t,mt(h,r.scale[1]))||Or,c.scale.z=1+a(t,mt(h,r.scale[2]))||Or;let d=a(t,mt(h,r.rotation[0])),u=a(t,mt(h,r.rotation[1])),p=a(t,mt(h,r.rotation[2]));c.rotation.set(d,u,p),c.position.x=i.size[0]*n+a(t,mt(h,r.position[0])),c.position.y=-i.size[1]*o+a(t,mt(h,r.position[1])),c.position.z=-i.size[2]*l+a(t,mt(h,r.position[2]))}}_updateToObject(e){var c;if(e.type!=="toObject")throw new Error;let{toObject:t}=e,i=new ji(t.rotation[0],t.rotation[1],t.rotation[2]),r=e.randomnessObject??Kn.defaultData([1,1,1]).randomnessObject,s=this.getRandom(r),a=tp(r.strength,this.parameters.randomness);if(!t.object){for(let[,d]of this.children.entries())d.position.set(0,0,0),d.scale.setScalar(1),d.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof Q1)if(!((c=this.objectForSample.font)!=null&&c.isLoaded)||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let n=this.getSubdivData();if(n.length>0){let d=Math.round(n.length*t.count/100);this._updateCount(d)}else{let d=this.objectForSample.geometry.getAttribute("position");if(!d||isNaN(d.count)||d.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let o=new b7(this.objectForSample).build(),l=DQ[t.axis],h=this.children;o.setRandomGenerator((0,q0.default)(this.object.uuid+t.seed));for(let[d,u]of h.entries()){let p=d*(r.freqScale/10)+r.movement,f=s.noise(p,p,p),g=d+1,m=a(g,mt(f,r.rotation[0])),v=a(g,mt(f,r.rotation[1])),y=a(g,mt(f,r.rotation[2]));t.spreadType==="random"?o.sample(Cc,Wg):(n.length&&(Cc.fromArray(n[d].pos),Wg.fromArray(n[d].norm)),this.objectForSample instanceof Id&&Cc.applyMatrix4(VQ.copy(this.objectForSample.matrixWorld).invert())),Cc.applyMatrix4(this.object.hiddenMatrix.clone().invert()),u.position.copy(Cc),Rn.fromArray(l);let x=t.align==="normal"?Wg:this.object.getWorldDirection(HQ),w=sp.fromArray(t.position);sp.x+=a(g,mt(f,r.position[0])),sp.y+=a(g,mt(f,r.position[1])),sp.z+=a(g,mt(f,r.position[2]));let _=Math.acos(x.dot(Rn)),b=GQ.crossVectors(Rn,x).normalize(),A=jQ.makeRotationAxis(b,_),S=x.clone().cross(this.object.up).normalize(),E=S.clone().cross(x).normalize(),C=new we().makeBasis(S,x,E),T=new M(Rn.y,Rn.z,Rn.x).normalize(),D=T.clone().cross(Rn).normalize(),O=new we().makeBasis(T,Rn,D).invert(),P=new we().multiplyMatrices(C,O);u.rotation.setFromRotationMatrix(P),w.applyMatrix4(A),u.position.add(w),u.rotation.x=u.rotation.x+i.x+m,u.rotation.y=u.rotation.y+i.y+v,u.rotation.z=u.rotation.z+i.z+y,u.scale.setScalar(1),u.scale.x=u.scale.x+t.scale[0]+a(g,mt(f,r.scale[0]))||Or,u.scale.y=u.scale.y+t.scale[1]+a(g,mt(f,r.scale[1]))||Or,u.scale.z=u.scale.z+t.scale[2]+a(g,mt(f,r.scale[2]))||Or,u.scale.multiply(this.object.scale),u.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType,t=new Map,i=(s,a)=>{let n=Math.round(s[0]*1e4)+"_"+Math.round(s[1]*1e4)+"_"+Math.round(s[2]*1e4),o=t.get(n);o?(o.pos[0]+=s[0],o.pos[1]+=s[1],o.pos[2]+=s[2],o.norm[0]+=a[0],o.norm[1]+=a[1],o.norm[2]+=a[2],o.count+=1):t.set(n,{pos:[...s],norm:[...a],count:1})};if(e==="random")return[];if(this.objectForSample instanceof Id){let s=this.objectForSample,a=IQ[e],n=jT[a],o=kT[a],l=VT[a],h=n(s.subdivPointerNew);for(let c=0;c<=h-1;c++){let d=o(s.subdivPointerNew,c),u=l(s.subdivPointerNew,c);eA.fromArray(d).applyMatrix4(s.matrixWorld),tA.fromArray(u),i(eA.toArray(),tA.toArray())}}else(this.objectForSample.geometry.index?zQ(this.objectForSample.geometry):BQ(this.objectForSample.geometry)).forEach((s,a)=>{e==="polygon_center"&&i(s.midpoint,s.norm),e==="vertex"&&(i(s.vertices[0],s.norm),i(s.vertices[1],s.norm),i(s.vertices[2],s.norm)),e==="edge"&&(i(s.faceCenters[0],s.norm),i(s.faceCenters[1],s.norm),i(s.faceCenters[2],s.norm))});let r=Array.from(t.values());for(let s of r)s.pos[0]/=s.count,s.pos[1]/=s.count,s.pos[2]/=s.count,s.norm[0]/=s.count,s.norm[1]/=s.count,s.norm[2]/=s.count;return r}updateState(e,t){var i;if(this.parameters=rm(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),(i=this.object.parent)==null||i.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let r=t.find(this.parameters.toObject.object);r instanceof Vr?this.objectForSample=r:this.objectForSample=void 0,this.matrix=new we,this.hiddenMatrix=new we,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,r&&r.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}},Gd=e=>{var t;return t=class extends e{},t.geometryHelper=new Xs(30,30,30),t},ap=new Hh,qg=new $r,iA=new we,Hd=(e,t,i,r,s=!1,a=e)=>{let n=t,o=a.matrixWorld;if(n.boundingSphere===null&&n.computeBoundingSphere(),qg.copy(n.boundingSphere),qg.applyMatrix4(o),i.ray.intersectsSphere(qg)===!1||(iA.copy(o).invert(),ap.copy(i.ray).applyMatrix4(iA),n.boundingBox!==null&&ap.intersectsBox(n.boundingBox)===!1))return;let l,h,c,d,u=n.index,p=n.attributes.position,f=n.drawRange,g,m;if(s===!1){let y=Math.max(0,f.start),x=Math.min(u.count,f.start+f.count);for(g=y,m=x;g<m;g+=3)if(h=u.getX(g),c=u.getX(g+1),d=u.getX(g+2),l=v(e,i,ap,p,h,c,d),l){l.faceIndex=Math.floor(g/3),r.push(l);return}}else{let y=n.attributes.position,x=new M,w=new M,_=new M,b=new M,A=2,S=1/((a.scale.x+a.scale.y+a.scale.z)/3),E=S*S,C=Math.max(0,f.start),T=Math.min(y.count,f.start+f.count);for(let D=C,O=T-1;D<O;D+=A){if(x.fromBufferAttribute(y,D),w.fromBufferAttribute(y,D+1),ap.distanceSqToSegment(x,w,b,_)>E)continue;b.applyMatrix4(a.matrixWorld);let P=i.ray.origin.distanceTo(b);P<i.near||P>i.far||r.push({distance:P,point:_.clone().applyMatrix4(a.matrixWorld),object:e})}}function v(y,x,w,_,b,A,S){let E=new M,C=new M,T=new M,D=new M,O=new M;if(E.fromBufferAttribute(_,b),C.fromBufferAttribute(_,A),T.fromBufferAttribute(_,S),w.intersectTriangle(E,C,T,!1,D)===null)return null;O.copy(D),O.applyMatrix4(y.matrixWorld);let P=x.ray.origin.distanceTo(O);return P<x.near||P>x.far?null:{faceIndex:1,distance:P,point:O.clone(),object:y}}},np=new M,cs=new bo,qQ=class extends zd{constructor(e){let t=new Ge,i=new wo({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={},n=new et(15711266),o=new et(15711266),l=new et(2857471);h("n1","n2",n),h("n2","n4",n),h("n4","n3",n),h("n3","n1",n),h("f1","f2",n),h("f2","f4",n),h("f4","f3",n),h("f3","f1",n),h("n1","f1",n),h("n2","f2",n),h("n3","f3",n),h("n4","f4",n),h("p","n1",o),h("p","n2",o),h("p","n3",o),h("p","n4",o),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l);function h(d,u,p){c(d,p),c(u,p)}function c(d,u){r.push(0,0,0),s.push(u.r,u.g,u.b),a[d]===void 0&&(a[d]=[]),a[d].push(r.length/3-1)}t.setAttribute("position",new Ie(r,3)),t.setAttribute("color",new Ie(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let e=this.geometry,t=this.pointMap;cs.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,r=1,s=.8;Os("n1",t,e,cs,-i,-r,s),Os("n2",t,e,cs,i,-r,s),Os("n3",t,e,cs,-i,r,s),Os("n4",t,e,cs,i,r,s);let a=s;Os("f1",t,e,cs,-i,-r,a),Os("f2",t,e,cs,i,-r,a),Os("f3",t,e,cs,-i,r,a),Os("f4",t,e,cs,i,r,a);let n=a,o=.5;Os("u1",t,e,cs,i*.7*o,r*1.1,n),Os("u2",t,e,cs,-i*.7*o,r*1.1,n),Os("u3",t,e,cs,0,r*(1.1+.9*o),n),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Os(e,t,i,r,s,a,n){np.set(s,a,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,c=o.length;h<c;h++)l.setXYZ(o[h],np.x,np.y,np.z)}}var XQ=class extends Gd(qQ){constructor(e){super(e),this.object=e,this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){Hd(this.object,this.geometry,e,t,!0)}},hy;(e=>e.is=t=>"objectHelper"in t)(hy||(hy={}));var ac=(e,t)=>class extends I1(e){constructor(){super(...arguments),this.objectHelper=new t(this),this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(i,r){this.objectHelper.raycast(i,r)}showGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof Kp&&(r.visible=!0)}}updateEntityBoxSize(i,r){this.objectHelper.visible&&this.geometryHelper instanceof Xs?(i.setScalar(0),r.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,r)}hideGizmos(){for(let i in this.gizmos){let r=this.gizmos[i];r instanceof Kp&&(r.visible=!1)}}},op=790,Wl=new M,Xg=new M,Yg=new lt,Qg=new M,Tc=new M,Zg=new M,Mr=class extends ac(bo,XQ){constructor(e="",t={...Sd.defaultData,name:""}){super(),this._cameraType="OrthographicCamera",this.targetOffset=Lh.DefaultTargetOffset,this.isUpVectorFlipped=!1,this.angleOffsetFromUp=0,this.wasMovedByUser=!1,this.wasMovedBySwitchCameraAction=!1,this.super_Entity(e,t),this.previousProjectionMatrix=new we,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,r=this.height;this.orthoCamera=new Xf(i*-.5,i*.5,r*.5,r*-.5,-5e4,1e4),this.perspCamera=new _r(45,i/r,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,t,i){typeof e=="number"&&(e=new M(e,t,i)),super.lookAt(e),this.getWorldPosition(Wl),this.targetOffset=Wl.distanceTo(e)}getTarget(e=new M){return this.getWorldDirection(Xg),this.getWorldPosition(Wl),Xg.multiplyScalar(this.targetOffset),e.copy(Wl).add(Xg),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Wl),Wl.distanceTo(e)}updateUp(){this.getWorldQuaternion(Yg),Qg.set(0,0,1).applyQuaternion(Yg),Tc.copy(kt.DEFAULT_UP),this.isUpVectorFlipped&&Tc.negate(),Tc.applyQuaternion(Yg),Zg.copy(kt.DEFAULT_UP).projectOnPlane(Qg),this.angleOffsetFromUp=Zg.angleTo(Tc),this.angleOffsetFromUp*=Zg.cross(Tc).dot(Qg)>=0?1:-1}updateTransformState(e,t){let i=super.updateTransformState(e,t);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(e){let t=e.getWorldPosition(new M),i=e.getWorldDirection(new M).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let t=this.getWorldDirection(new M).multiplyScalar(this.targetOffset);return{position:e.clone().sub(t),target:e}}getViewToObject(e){let t=new M;return e.getWorldPosition(t),this.getViewToTarget(t)}setViewplaneSize(e,t,i=!1){if(this.aspect=e/t,i){let r=e>t?this.aspect:1,s=e>t?1:this.aspect;this.left=-op*.5*r,this.right=op*.5*r,this.top=op*.5*(1/s),this.bottom=-op*.5*(1/s)}else this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,i,r,s,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,i,r,s,a):this.orthoCamera.setViewOffset(e,t,i,r,s,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return $v(t,e)}updateCameraSubtype(e,t){let i=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(i,t.zoom),t.near!==void 0&&this.setNear(i,t.near),t.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},ql=new we,YQ=new we;function rA(e){let t=!1;return e.scene.objects.traverse((i,r)=>{var s;((s=r.geometry)==null?void 0:s.type)==="BooleanGeometry"&&(t=!0)}),t}var ul=class extends xl{constructor(e,t,i){super(e,t),this.data=t,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry=new Ge,this.onAfterRender=(r,s,a,n,o,l)=>{super.onAfterRender(r,s,a,n,o,l),this.recomputeBoolean()},this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,t=!0){var r;if(this.booleanMeshSetAddress!==-1&&!e)return;for(let s=0;s<this.children.length;s++){let a=this.children[s];a instanceof ul&&a.dataPatched.visible===!0&&a.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let s=0;s<this.children.length;s++){let a=this.children[s];if(a instanceof Vr&&a.dataPatched.visible===!0&&((r=a.geometry.attributes.position)==null?void 0:r.count)>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){ql.multiplyMatrices(a.hiddenMatrix,a.matrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=Za.getMeshSet(a.geometry,e===!0,t)),a.booleanMeshSetAddress===-1)return;Za.transformMeshSet(a.booleanMeshSetAddress,ql),a.booleanMatrixInvOld.copy(ql).invert(),a.booleanWasTransformed=!1}else a instanceof ul&&a.needsTransformForDownstream===!0?(Za.transformMeshSet(a.booleanMeshSetAddress,ql),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Za.transformMeshSet(a.booleanMeshSetAddress,YQ.multiplyMatrices(ql,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(ql).invert(),a.booleanWasTransformed=!1)}catch(n){console.error(n),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}Za.hasOpenEdges(a.booleanMeshSetAddress)===!1||s===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.booleanOperationDidFail=!1):a.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new Ie([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Za.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new Ge,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=Za.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(s){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(s)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,X1(this),Y1(this)}dispose(){super.dispose(),this.geometry.dispose()}},zf;(e=>{function t(i){return Tt.is(i)&&i instanceof Ud}e.is=t})(zf||(zf={}));var Z1=(e,t)=>class extends ac(e,t){updateState_Light(i,r){this.updateState_Entity(i,r),i.color!==void 0&&(this.color=r.shared.color(i.color)),i.intensity!==void 0&&(this.intensity=i.intensity),i.depth!==void 0&&(this.shadow.camera.far=i.depth,this.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows)}},Ns=e=>e instanceof Vr,un=e=>e!==null&&e instanceof ul,QQ=e=>e instanceof Mr,ZQ=e=>zf.is(e),cy=e=>hy.is(e),KQ=new M(1,1,1),sA=new M,JQ=new M,aA=new lt,Wd=class extends Gd($U){constructor(e,t=15){super(t),this.object=e,this.dummy=new hn,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,t){Hd(this.object,Wd.geometryHelper,e,t,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(sA,aA,JQ),this.matrix.compose(sA,aA,KQ),super.updateMatrixWorld(e)}updateWorldMatrix(e,t){}},Mh=class extends ac(hn,Wd){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update()}updateState(e,t){this.updateState_Entity(e,t),"buffer"in e&&Object.keys(e).length===1&&t.scene.reloadSplats()}},id=class extends ac(hn,Wd){constructor(e,t,i){super(),this.super_Entity(e,t),this.context=i,this.objectHelper.update()}updateState(e,t){this.updateState_Entity(e,t)}},GT={RED:0,GREEN:1,BLUE:2,ALPHA:3},qd="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",$Q=`#ifdef FRAMEBUFFER_PRECISION_HIGH
  5050. uniform mediump sampler2D inputBuffer;
  5051. #else
  5052. uniform lowp sampler2D inputBuffer;
  5053. #endif
  5054. uniform lowp sampler2D cocBuffer;uniform vec2 texelSize;uniform float scale;uniform vec4 kernel64[32];varying vec2 vUv;void main(){
  5055. #ifdef FOREGROUND
  5056. vec2 CoCNearFar=texture2D(cocBuffer,vUv).rg;float CoC=CoCNearFar.r*scale;
  5057. #else
  5058. float CoC=texture2D(cocBuffer,vUv).g*scale;
  5059. #endif
  5060. if(CoC==0.0){gl_FragColor=texture2D(inputBuffer,vUv);}else{
  5061. #ifdef FOREGROUND
  5062. vec2 step=texelSize*max(CoC,CoCNearFar.g*scale);
  5063. #else
  5064. vec2 step=texelSize*CoC;
  5065. #endif
  5066. vec4 acc=vec4(0.0);for(int i=0;i<32;++i){vec4 kernel=kernel64[i];vec2 uv=step*kernel.xy+vUv;acc+=texture2D(inputBuffer,uv);uv=step*kernel.zw+vUv;acc+=texture2D(inputBuffer,uv);}gl_FragColor=acc/64.0;}}`,lp=class extends Dt{constructor(e=!1,t=!1){super({name:"BokehMaterial",defines:{PASS:e?"2":"1"},uniforms:{kernel64:new ye(null),kernel16:new ye(null),inputBuffer:new ye(null),cocBuffer:new ye(null),texelSize:new ye(new j),scale:new ye(1)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:$Q,vertexShader:qd}),this.toneMapped=!1,t&&(this.defines.FOREGROUND="1"),this.generateKernel()}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}set cocBuffer(e){this.uniforms.cocBuffer.value=e}setCoCBuffer(e){this.uniforms.cocBuffer.value=e}get scale(){return this.uniforms.scale.value}set scale(e){this.uniforms.scale.value=e}getScale(e){return this.uniforms.scale.value=e}setScale(e){this.uniforms.scale.value=e}generateKernel(){let e=2.39996323,t=new Float32Array(128),i=new Float32Array(32),r=0,s=0;for(let o=0;o<80;++o){let l=o*e,h=Math.sqrt(o)/Math.sqrt(80),c=h*Math.cos(l),d=h*Math.sin(l);o%5===0?(i[s++]=c,i[s++]=d):(t[r++]=c,t[r++]=d)}let a=[],n=[];for(let o=0;o<128;)a.push(new ct(t[o++],t[o++],t[o++],t[o++]));for(let o=0;o<32;)n.push(new ct(i[o++],i[o++],i[o++],i[o++]));this.uniforms.kernel64.value=a,this.uniforms.kernel16.value=n}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t)}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}};function nA(e,t,i){return e*(t-i)-t}function dy(e,t,i){return Math.min(Math.max((e+t)/(t-i),0),1)}var eZ=`#include <common>
  5067. #include <packing>
  5068. #ifdef GL_FRAGMENT_PRECISION_HIGH
  5069. uniform highp sampler2D depthBuffer;
  5070. #else
  5071. uniform mediump sampler2D depthBuffer;
  5072. #endif
  5073. uniform float focusDistance;uniform float focusRange;uniform float cameraNear;uniform float cameraFar;varying vec2 vUv;float readDepth(const in vec2 uv){
  5074. #if DEPTH_PACKING == 3201
  5075. return unpackRGBAToDepth(texture2D(depthBuffer,uv));
  5076. #else
  5077. return texture2D(depthBuffer,uv).r;
  5078. #endif
  5079. }void main(){float depth=readDepth(vUv);
  5080. #ifdef PERSPECTIVE_CAMERA
  5081. float viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar);
  5082. #else
  5083. float linearDepth=depth;
  5084. #endif
  5085. float signedDistance=linearDepth-focusDistance;float magnitude=smoothstep(0.0,focusRange,abs(signedDistance));gl_FragColor.rg=magnitude*vec2(step(signedDistance,0.0),step(0.0,signedDistance));}`,tZ=class extends Dt{constructor(e){super({name:"CircleOfConfusionMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new ye(null),focusDistance:new ye(0),focusRange:new ye(0),cameraNear:new ye(.3),cameraFar:new ye(1e3)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:eZ,vertexShader:qd}),this.toneMapped=!1,this.uniforms.focalLength=this.uniforms.focusRange,this.adoptCameraSettings(e)}get near(){return this.uniforms.cameraNear.value}get far(){return this.uniforms.cameraFar.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=_n){this.depthBuffer=e,this.depthPacking=t}get focusDistance(){return this.uniforms.focusDistance.value}set focusDistance(e){this.uniforms.focusDistance.value=e}get worldFocusDistance(){return-nA(this.focusDistance,this.near,this.far)}set worldFocusDistance(e){this.focusDistance=dy(-e,this.near,this.far)}getFocusDistance(e){this.uniforms.focusDistance.value=e}setFocusDistance(e){this.uniforms.focusDistance.value=e}get focalLength(){return this.focusRange}set focalLength(e){this.focusRange=e}get focusRange(){return this.uniforms.focusRange.value}set focusRange(e){this.uniforms.focusRange.value=e}get worldFocusRange(){return-nA(this.focusRange,this.near,this.far)}set worldFocusRange(e){this.focusRange=dy(-e,this.near,this.far)}getFocalLength(e){return this.focusRange}setFocalLength(e){this.focusRange=e}adoptCameraSettings(e){e&&(this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far,e instanceof _r?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},iZ=`#include <common>
  5086. #include <dithering_pars_fragment>
  5087. #ifdef FRAMEBUFFER_PRECISION_HIGH
  5088. uniform mediump sampler2D inputBuffer;
  5089. #else
  5090. uniform lowp sampler2D inputBuffer;
  5091. #endif
  5092. varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25;
  5093. #include <encodings_fragment>
  5094. #include <dithering_fragment>
  5095. }`,rZ="uniform vec2 texelSize;uniform vec2 halfTexelSize;uniform float kernel;uniform float scale;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vec2 dUv=(texelSize*vec2(kernel)+halfTexelSize)*scale;vUv0=vec2(uv.x-dUv.x,uv.y+dUv.y);vUv1=vec2(uv.x+dUv.x,uv.y+dUv.y);vUv2=vec2(uv.x+dUv.x,uv.y-dUv.y);vUv3=vec2(uv.x-dUv.x,uv.y-dUv.y);gl_Position=vec4(position.xy,1.0,1.0);}",oA=class extends Dt{constructor(e=new j){super({name:"KawaseBlurMaterial",uniforms:{inputBuffer:new ye(null),texelSize:new ye(new j),halfTexelSize:new ye(new j),kernel:new ye(0),scale:new ye(1)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:iZ,vertexShader:rZ}),this.toneMapped=!1,this.setTexelSize(e.x,e.y)}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.inputBuffer=e}get scale(){return this.uniforms.scale.value}set scale(e){this.uniforms.scale.value=e}getScale(){return this.uniforms.scale.value}setScale(e){this.uniforms.scale.value=e}getKernel(){return null}get kernel(){return this.uniforms.kernel.value}set kernel(e){this.uniforms.kernel.value=e}setKernel(e){this.kernel=e}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t),this.uniforms.halfTexelSize.value.set(e,t).multiplyScalar(.5)}setSize(e,t){let i=this.uniforms;i.texelSize.value.set(1/e,1/t),i.halfTexelSize.value.copy(i.texelSize.value).multiplyScalar(.5)}},sZ=`#ifdef FRAMEBUFFER_PRECISION_HIGH
  5096. uniform mediump sampler2D inputBuffer;
  5097. #else
  5098. uniform lowp sampler2D inputBuffer;
  5099. #endif
  5100. uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel;
  5101. #include <encodings_fragment>
  5102. }`,aZ=class extends Dt{constructor(){super({name:"CopyMaterial",uniforms:{inputBuffer:new ye(null),opacity:new ye(1)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:sZ,vertexShader:qd}),this.toneMapped=!1}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}getOpacity(e){return this.uniforms.opacity.value}setOpacity(e){this.uniforms.opacity.value=e}},nZ=`varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;
  5103. #if THREE_REVISION < 143
  5104. #define luminance(v) linearToRelativeLuminance(v)
  5105. #endif
  5106. #if EDGE_DETECTION_MODE != 0
  5107. varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;
  5108. #endif
  5109. #if EDGE_DETECTION_MODE == 1
  5110. #include <common>
  5111. #endif
  5112. #if EDGE_DETECTION_MODE == 0 || PREDICATION_MODE == 1
  5113. #ifdef GL_FRAGMENT_PRECISION_HIGH
  5114. uniform highp sampler2D depthBuffer;
  5115. #else
  5116. uniform mediump sampler2D depthBuffer;
  5117. #endif
  5118. float readDepth(const in vec2 uv){
  5119. #if DEPTH_PACKING == 3201
  5120. return unpackRGBAToDepth(texture2D(depthBuffer,uv));
  5121. #else
  5122. return texture2D(depthBuffer,uv).r;
  5123. #endif
  5124. }vec3 gatherNeighbors(){float p=readDepth(vUv);float pLeft=readDepth(vUv0);float pTop=readDepth(vUv1);return vec3(p,pLeft,pTop);}
  5125. #elif PREDICATION_MODE == 2
  5126. uniform sampler2D predicationBuffer;vec3 gatherNeighbors(){float p=texture2D(predicationBuffer,vUv).r;float pLeft=texture2D(predicationBuffer,vUv0).r;float pTop=texture2D(predicationBuffer,vUv1).r;return vec3(p,pLeft,pTop);}
  5127. #endif
  5128. #if PREDICATION_MODE != 0
  5129. vec2 calculatePredicatedThreshold(){vec3 neighbours=gatherNeighbors();vec2 delta=abs(neighbours.xx-neighbours.yz);vec2 edges=step(PREDICATION_THRESHOLD,delta);return PREDICATION_SCALE*EDGE_THRESHOLD*(1.0-PREDICATION_STRENGTH*edges);}
  5130. #endif
  5131. #if EDGE_DETECTION_MODE != 0
  5132. uniform sampler2D inputBuffer;
  5133. #endif
  5134. void main(){
  5135. #if EDGE_DETECTION_MODE == 0
  5136. const vec2 threshold=vec2(DEPTH_THRESHOLD);
  5137. #elif PREDICATION_MODE != 0
  5138. vec2 threshold=calculatePredicatedThreshold();
  5139. #else
  5140. const vec2 threshold=vec2(EDGE_THRESHOLD);
  5141. #endif
  5142. #if EDGE_DETECTION_MODE == 0
  5143. vec3 neighbors=gatherNeighbors();vec2 delta=abs(neighbors.xx-vec2(neighbors.y,neighbors.z));vec2 edges=step(threshold,delta);if(dot(edges,vec2(1.0))==0.0){discard;}gl_FragColor=vec4(edges,0.0,1.0);
  5144. #elif EDGE_DETECTION_MODE == 1
  5145. float l=luminance(texture2D(inputBuffer,vUv).rgb);float lLeft=luminance(texture2D(inputBuffer,vUv0).rgb);float lTop=luminance(texture2D(inputBuffer,vUv1).rgb);vec4 delta;delta.xy=abs(l-vec2(lLeft,lTop));vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}float lRight=luminance(texture2D(inputBuffer,vUv2).rgb);float lBottom=luminance(texture2D(inputBuffer,vUv3).rgb);delta.zw=abs(l-vec2(lRight,lBottom));vec2 maxDelta=max(delta.xy,delta.zw);float lLeftLeft=luminance(texture2D(inputBuffer,vUv4).rgb);float lTopTop=luminance(texture2D(inputBuffer,vUv5).rgb);delta.zw=abs(vec2(lLeft,lTop)-vec2(lLeftLeft,lTopTop));maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges.xy*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0);
  5146. #elif EDGE_DETECTION_MODE == 2
  5147. vec4 delta;vec3 c=texture2D(inputBuffer,vUv).rgb;vec3 cLeft=texture2D(inputBuffer,vUv0).rgb;vec3 t=abs(c-cLeft);delta.x=max(max(t.r,t.g),t.b);vec3 cTop=texture2D(inputBuffer,vUv1).rgb;t=abs(c-cTop);delta.y=max(max(t.r,t.g),t.b);vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}vec3 cRight=texture2D(inputBuffer,vUv2).rgb;t=abs(c-cRight);delta.z=max(max(t.r,t.g),t.b);vec3 cBottom=texture2D(inputBuffer,vUv3).rgb;t=abs(c-cBottom);delta.w=max(max(t.r,t.g),t.b);vec2 maxDelta=max(delta.xy,delta.zw);vec3 cLeftLeft=texture2D(inputBuffer,vUv4).rgb;t=abs(c-cLeftLeft);delta.z=max(max(t.r,t.g),t.b);vec3 cTopTop=texture2D(inputBuffer,vUv5).rgb;t=abs(c-cTopTop);delta.w=max(max(t.r,t.g),t.b);maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0);
  5148. #endif
  5149. }`,oZ=`uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;
  5150. #if EDGE_DETECTION_MODE != 0
  5151. varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;
  5152. #endif
  5153. void main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,0.0);vUv1=vUv+texelSize*vec2(0.0,-1.0);
  5154. #if EDGE_DETECTION_MODE != 0
  5155. vUv2=vUv+texelSize*vec2(1.0,0.0);vUv3=vUv+texelSize*vec2(0.0,1.0);vUv4=vUv+texelSize*vec2(-2.0,0.0);vUv5=vUv+texelSize*vec2(0.0,-2.0);
  5156. #endif
  5157. gl_Position=vec4(position.xy,1.0,1.0);}`,pm={DEPTH:0,LUMA:1,COLOR:2},lZ={DISABLED:0,DEPTH:1,CUSTOM:2},hZ=class extends Dt{constructor(e=new j,t=pm.COLOR){super({name:"EdgeDetectionMaterial",defines:{THREE_REVISION:Gh.replace(/\D+/g,""),LOCAL_CONTRAST_ADAPTATION_FACTOR:"2.0",EDGE_THRESHOLD:"0.1",DEPTH_THRESHOLD:"0.01",PREDICATION_MODE:"0",PREDICATION_THRESHOLD:"0.01",PREDICATION_SCALE:"2.0",PREDICATION_STRENGTH:"1.0",DEPTH_PACKING:"0"},uniforms:{inputBuffer:new ye(null),depthBuffer:new ye(null),predicationBuffer:new ye(null),texelSize:new ye(e)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:nZ,vertexShader:oZ}),this.toneMapped=!1,this.edgeDetectionMode=t}set depthBuffer(e){this.uniforms.depthBuffer.value=e}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=_n){this.depthBuffer=e,this.depthPacking=t}get edgeDetectionMode(){return Number(this.defines.EDGE_DETECTION_MODE)}set edgeDetectionMode(e){this.defines.EDGE_DETECTION_MODE=e.toFixed(0),this.needsUpdate=!0}getEdgeDetectionMode(){return this.edgeDetectionMode}setEdgeDetectionMode(e){this.edgeDetectionMode=e}get localContrastAdaptationFactor(){return Number(this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR)}set localContrastAdaptationFactor(e){this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR=e.toFixed("6"),this.needsUpdate=!0}getLocalContrastAdaptationFactor(){return this.localContrastAdaptationFactor}setLocalContrastAdaptationFactor(e){this.localContrastAdaptationFactor=e}get edgeDetectionThreshold(){return Number(this.defines.EDGE_THRESHOLD)}set edgeDetectionThreshold(e){this.defines.EDGE_THRESHOLD=e.toFixed("6"),this.defines.DEPTH_THRESHOLD=(e*.1).toFixed("6"),this.needsUpdate=!0}getEdgeDetectionThreshold(){return this.edgeDetectionThreshold}setEdgeDetectionThreshold(e){this.edgeDetectionThreshold=e}get predicationMode(){return Number(this.defines.PREDICATION_MODE)}set predicationMode(e){this.defines.PREDICATION_MODE=e.toFixed(0),this.needsUpdate=!0}getPredicationMode(){return this.predicationMode}setPredicationMode(e){this.predicationMode=e}set predicationBuffer(e){this.uniforms.predicationBuffer.value=e}setPredicationBuffer(e){this.uniforms.predicationBuffer.value=e}get predicationThreshold(){return Number(this.defines.PREDICATION_THRESHOLD)}set predicationThreshold(e){this.defines.PREDICATION_THRESHOLD=e.toFixed("6"),this.needsUpdate=!0}getPredicationThreshold(){return this.predicationThreshold}setPredicationThreshold(e){this.predicationThreshold=e}get predicationScale(){return Number(this.defines.PREDICATION_SCALE)}set predicationScale(e){this.defines.PREDICATION_SCALE=e.toFixed("6"),this.needsUpdate=!0}getPredicationScale(){return this.predicationScale}setPredicationScale(e){this.predicationScale=e}get predicationStrength(){return Number(this.defines.PREDICATION_STRENGTH)}set predicationStrength(e){this.defines.PREDICATION_STRENGTH=e.toFixed("6"),this.needsUpdate=!0}getPredicationStrength(){return this.predicationStrength}setPredicationStrength(e){this.predicationStrength=e}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}},cZ=`#include <common>
  5158. #include <packing>
  5159. #include <dithering_pars_fragment>
  5160. #define packFloatToRGBA(v) packDepthToRGBA(v)
  5161. #define unpackRGBAToFloat(v) unpackRGBAToDepth(v)
  5162. #ifdef FRAMEBUFFER_PRECISION_HIGH
  5163. uniform mediump sampler2D inputBuffer;
  5164. #else
  5165. uniform lowp sampler2D inputBuffer;
  5166. #endif
  5167. #ifdef GL_FRAGMENT_PRECISION_HIGH
  5168. uniform highp sampler2D depthBuffer;
  5169. #else
  5170. uniform mediump sampler2D depthBuffer;
  5171. #endif
  5172. uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;
  5173. #if THREE_REVISION < 143
  5174. #define luminance(v) linearToRelativeLuminance(v)
  5175. #endif
  5176. #if THREE_REVISION >= 137
  5177. vec4 sRGBToLinear(const in vec4 value){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);}
  5178. #endif
  5179. float readDepth(const in vec2 uv){
  5180. #if DEPTH_PACKING == 3201
  5181. return unpackRGBAToDepth(texture2D(depthBuffer,uv));
  5182. #else
  5183. return texture2D(depthBuffer,uv).r;
  5184. #endif
  5185. }float getViewZ(const in float depth){
  5186. #ifdef PERSPECTIVE_CAMERA
  5187. return perspectiveDepthToViewZ(depth,cameraNear,cameraFar);
  5188. #else
  5189. return orthographicDepthToViewZ(depth,cameraNear,cameraFar);
  5190. #endif
  5191. }FRAGMENT_HEADvoid main(){FRAGMENT_MAIN_UVvec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGEgl_FragColor=color0;
  5192. #ifdef ENCODE_OUTPUT
  5193. #include <encodings_fragment>
  5194. #endif
  5195. #include <dithering_fragment>
  5196. }`,dZ="uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEADvoid main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORTgl_Position=vec4(position.xy,1.0,1.0);}",Rs={FRAGMENT_HEAD:"FRAGMENT_HEAD",FRAGMENT_MAIN_UV:"FRAGMENT_MAIN_UV",FRAGMENT_MAIN_IMAGE:"FRAGMENT_MAIN_IMAGE",VERTEX_HEAD:"VERTEX_HEAD",VERTEX_MAIN_SUPPORT:"VERTEX_MAIN_SUPPORT"},uy=class extends Dt{constructor(e,t,i,r,s=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:Gh.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new ye(null),depthBuffer:new ye(null),resolution:new ye(new j),texelSize:new ye(new j),cameraNear:new ye(.3),cameraFar:new ye(1e3),aspect:new ye(1),time:new ye(0)},blending:Oi,depthWrite:!1,depthTest:!1,dithering:s}),this.toneMapped=!1,e&&this.setShaderParts(e),t&&this.setDefines(t),i&&this.setUniforms(i),this.adoptCameraSettings(r)}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setDepthBuffer(e,t=_n){this.depthBuffer=e,this.depthPacking=t}setShaderParts(e){return this.fragmentShader=cZ.replace(Rs.FRAGMENT_HEAD,e.get(Rs.FRAGMENT_HEAD)).replace(Rs.FRAGMENT_MAIN_UV,e.get(Rs.FRAGMENT_MAIN_UV)).replace(Rs.FRAGMENT_MAIN_IMAGE,e.get(Rs.FRAGMENT_MAIN_IMAGE)),this.vertexShader=dZ.replace(Rs.VERTEX_HEAD,e.get(Rs.VERTEX_HEAD)).replace(Rs.VERTEX_MAIN_SUPPORT,e.get(Rs.VERTEX_MAIN_SUPPORT)),this.needsUpdate=!0,this}setDefines(e){for(let t of e.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(e){for(let t of e.entries())this.uniforms[t[0]]=t[1];return this}setExtensions(e){this.extensions={};for(let t of e)this.extensions[t]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(e){this.encodeOutput!==e&&(e?this.defines.ENCODE_OUTPUT="1":delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(e){return this.encodeOutput}setOutputEncodingEnabled(e){this.encodeOutput=e}get time(){return this.uniforms.time.value}set time(e){this.uniforms.time.value=e}setDeltaTime(e){this.uniforms.time.value+=e}adoptCameraSettings(e){e&&(this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far,e instanceof _r?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){let i=this.uniforms;i.resolution.value.set(e,t),i.texelSize.value.set(1/e,1/t),i.aspect.value=e/t}static get Section(){return Rs}},uZ=`#include <common>
  5197. #if THREE_REVISION < 143
  5198. #define luminance(v) linearToRelativeLuminance(v)
  5199. #endif
  5200. #ifdef FRAMEBUFFER_PRECISION_HIGH
  5201. uniform mediump sampler2D inputBuffer;
  5202. #else
  5203. uniform lowp sampler2D inputBuffer;
  5204. #endif
  5205. #ifdef RANGE
  5206. uniform vec2 range;
  5207. #elif defined(THRESHOLD)
  5208. uniform float threshold;uniform float smoothing;
  5209. #endif
  5210. varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb);
  5211. #ifdef RANGE
  5212. float low=step(range.x,l);float high=step(l,range.y);l*=low*high;
  5213. #elif defined(THRESHOLD)
  5214. l=smoothstep(threshold,threshold+smoothing,l);
  5215. #endif
  5216. #ifdef COLOR
  5217. gl_FragColor=vec4(texel.rgb*l,l);
  5218. #else
  5219. gl_FragColor=vec4(l);
  5220. #endif
  5221. }`,pZ=class extends Dt{constructor(e=!1,t=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:Gh.replace(/\D+/g,"")},uniforms:{inputBuffer:new ye(null),threshold:new ye(0),smoothing:new ye(1),range:new ye(null)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:uZ,vertexShader:qd}),this.toneMapped=!1,this.colorOutput=e,this.luminanceRange=t}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get threshold(){return this.uniforms.threshold.value}set threshold(e){this.smoothing>0||e>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.threshold.value=e}getThreshold(){return this.threshold}setThreshold(e){this.threshold=e}get smoothing(){return this.uniforms.smoothing.value}set smoothing(e){this.threshold>0||e>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.smoothing.value=e}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(e){this.smoothing=e}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(e){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(e){e?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(e){return this.colorOutput}setColorOutputEnabled(e){this.colorOutput=e}get useRange(){return this.luminanceRange!==null}set useRange(e){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(e){e!==null?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=e,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(e){this.luminanceRange=e}},fZ=`#ifdef FRAMEBUFFER_PRECISION_HIGH
  5222. uniform mediump sampler2D inputBuffer;
  5223. #else
  5224. uniform lowp sampler2D inputBuffer;
  5225. #endif
  5226. #ifdef MASK_PRECISION_HIGH
  5227. uniform mediump sampler2D maskTexture;
  5228. #else
  5229. uniform lowp sampler2D maskTexture;
  5230. #endif
  5231. #if MASK_FUNCTION != 0
  5232. uniform float strength;
  5233. #endif
  5234. varying vec2 vUv;void main(){
  5235. #if COLOR_CHANNEL == 0
  5236. float mask=texture2D(maskTexture,vUv).r;
  5237. #elif COLOR_CHANNEL == 1
  5238. float mask=texture2D(maskTexture,vUv).g;
  5239. #elif COLOR_CHANNEL == 2
  5240. float mask=texture2D(maskTexture,vUv).b;
  5241. #else
  5242. float mask=texture2D(maskTexture,vUv).a;
  5243. #endif
  5244. #if MASK_FUNCTION == 0
  5245. #ifdef INVERTED
  5246. mask=step(mask,0.0);
  5247. #else
  5248. mask=1.0-step(mask,0.0);
  5249. #endif
  5250. #else
  5251. mask=clamp(mask*strength,0.0,1.0);
  5252. #ifdef INVERTED
  5253. mask=1.0-mask;
  5254. #endif
  5255. #endif
  5256. #if MASK_FUNCTION == 2
  5257. gl_FragColor=vec4(mask*texture2D(inputBuffer,vUv).rgb,mask);
  5258. #else
  5259. gl_FragColor=mask*texture2D(inputBuffer,vUv);
  5260. #endif
  5261. }`,HT={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2},mZ=class extends Dt{constructor(e=null){super({name:"MaskMaterial",uniforms:{maskTexture:new ye(e),inputBuffer:new ye(null),strength:new ye(1)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:fZ,vertexShader:qd}),this.toneMapped=!1,this.setColorChannel(GT.RED),this.setMaskFunction(HT.DISCARD)}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}set maskTexture(e){this.uniforms.maskTexture.value=e,delete this.defines.MASK_PRECISION_HIGH,e.type!==Er&&(this.defines.MASK_PRECISION_HIGH="1"),this.needsUpdate=!0}setMaskTexture(e){this.maskTexture=e}set colorChannel(e){this.defines.COLOR_CHANNEL=e.toFixed(0),this.needsUpdate=!0}setColorChannel(e){this.colorChannel=e}set maskFunction(e){this.defines.MASK_FUNCTION=e.toFixed(0),this.needsUpdate=!0}setMaskFunction(e){this.maskFunction=e}get inverted(){return this.defines.INVERTED!==void 0}set inverted(e){this.inverted&&!e?delete this.defines.INVERTED:e&&(this.defines.INVERTED="1"),this.needsUpdate=!0}isInverted(){return this.inverted}setInverted(e){this.inverted=e}get strength(){return this.uniforms.strength.value}set strength(e){this.uniforms.strength.value=e}getStrength(){return this.strength}setStrength(e){this.strength=e}},gZ=`#define sampleLevelZeroOffset(t, coord, offset) texture2D(t, coord + offset * texelSize)
  5262. #if __VERSION__ < 300
  5263. #define round(v) floor(v + 0.5)
  5264. #endif
  5265. #ifdef FRAMEBUFFER_PRECISION_HIGH
  5266. uniform mediump sampler2D inputBuffer;
  5267. #else
  5268. uniform lowp sampler2D inputBuffer;
  5269. #endif
  5270. uniform lowp sampler2D areaTexture;uniform lowp sampler2D searchTexture;uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}vec2 decodeDiagBilinearAccess(in vec2 e){e.r=e.r*abs(5.0*e.r-5.0*0.75);return round(e);}vec4 decodeDiagBilinearAccess(in vec4 e){e.rb=e.rb*abs(5.0*e.rb-5.0*0.75);return round(e);}vec2 searchDiag1(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);vec3 t=vec3(texelSize,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(coord.z<float(MAX_SEARCH_STEPS_DIAG_INT-1)&&coord.w>0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 searchDiag2(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);coord.x+=0.25*texelSize.x;vec3 t=vec3(texelSize,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(coord.z<float(MAX_SEARCH_STEPS_DIAG_INT-1)&&coord.w>0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;e=decodeDiagBilinearAccess(e);coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 areaDiag(const in vec2 dist,const in vec2 e,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE_DIAG,AREATEX_MAX_DISTANCE_DIAG)*e+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.x+=0.5;texCoord.y+=AREATEX_SUBTEX_SIZE*offset;return texture2D(areaTexture,texCoord).rg;}vec2 calculateDiagWeights(const in vec2 texCoord,const in vec2 e,const in vec4 subsampleIndices){vec2 weights=vec2(0.0);vec4 d;vec2 end;if(e.r>0.0){d.xz=searchDiag1(texCoord,vec2(-1.0,1.0),end);d.x+=float(end.y>0.9);}else{d.xz=vec2(0.0);}d.yw=searchDiag1(texCoord,vec2(1.0,-1.0),end);if(d.x+d.y>2.0){vec4 coords=vec4(-d.x+0.25,d.x,d.y,-d.y-0.25)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.xy=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).rg;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).rg;c.yxwz=decodeDiagBilinearAccess(c.xyzw);vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.z);}d.xz=searchDiag2(texCoord,vec2(-1.0,-1.0),end);if(sampleLevelZeroOffset(inputBuffer,texCoord,vec2(1,0)).r>0.0){d.yw=searchDiag2(texCoord,vec2(1.0),end);d.y+=float(end.y>0.9);}else{d.yw=vec2(0.0);}if(d.x+d.y>2.0){vec4 coords=vec4(-d.x,-d.x,d.y,d.y)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.x=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).g;c.y=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(0,-1)).r;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).gr;vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.w).gr;}return weights;}float searchLength(const in vec2 e,const in float offset){vec2 scale=SEARCHTEX_SIZE*vec2(0.5,-1.0);vec2 bias=SEARCHTEX_SIZE*vec2(offset,1.0);scale+=vec2(-1.0,1.0);bias+=vec2(0.5,-0.5);scale*=1.0/SEARCHTEX_PACKED_SIZE;bias*=1.0/SEARCHTEX_PACKED_SIZE;return texture2D(searchTexture,scale*e+bias).r;}float searchXLeft(in vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.x>end&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(-2.0,0.0)*texelSize+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.0)+3.25;return texelSize.x*offset+texCoord.x;}float searchXRight(vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.x<end&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(2.0,0.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.5)+3.25;return-texelSize.x*offset+texCoord.x;}float searchYUp(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.y>end&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=-vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.0)+3.25;return texelSize.y*offset+texCoord.y;}float searchYDown(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;i++){if(!(texCoord.y<end&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.5)+3.25;return-texelSize.y*offset+texCoord.y;}vec2 area(const in vec2 dist,const in float e1,const in float e2,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE)*round(4.0*vec2(e1,e2))+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.y=AREATEX_SUBTEX_SIZE*offset+texCoord.y;return texture2D(areaTexture,texCoord).rg;}void detectHorizontalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){
  5271. #if !defined(DISABLE_CORNER_DETECTION)
  5272. vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,1)).r;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).r;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,-2)).r;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,-2)).r;weights*=clamp(factor,0.0,1.0);
  5273. #endif
  5274. }void detectVerticalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){
  5275. #if !defined(DISABLE_CORNER_DETECTION)
  5276. vec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(1,0)).g;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).g;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(-2,0)).g;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(-2,1)).g;weights*=clamp(factor,0.0,1.0);
  5277. #endif
  5278. }void main(){vec4 weights=vec4(0.0);vec4 subsampleIndices=vec4(0.0);vec2 e=texture2D(inputBuffer,vUv).rg;if(e.g>0.0){
  5279. #if !defined(DISABLE_DIAG_DETECTION)
  5280. weights.rg=calculateDiagWeights(vUv,e,subsampleIndices);if(weights.r==-weights.g){
  5281. #endif
  5282. vec2 d;vec3 coords;coords.x=searchXLeft(vOffset[0].xy,vOffset[2].x);coords.y=vOffset[1].y;d.x=coords.x;float e1=texture2D(inputBuffer,coords.xy).r;coords.z=searchXRight(vOffset[0].zw,vOffset[2].y);d.y=coords.z;d=round(resolution.xx*d+-vPixCoord.xx);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.zy,vec2(1,0)).r;weights.rg=area(sqrtD,e1,e2,subsampleIndices.y);coords.y=vUv.y;detectHorizontalCornerPattern(weights.rg,coords.xyzy,d);
  5283. #if !defined(DISABLE_DIAG_DETECTION)
  5284. }else{e.r=0.0;}
  5285. #endif
  5286. }if(e.r>0.0){vec2 d;vec3 coords;coords.y=searchYUp(vOffset[1].xy,vOffset[2].z);coords.x=vOffset[0].x;d.x=coords.y;float e1=texture2D(inputBuffer,coords.xy).g;coords.z=searchYDown(vOffset[1].zw,vOffset[2].w);d.y=coords.z;d=round(resolution.yy*d-vPixCoord.yy);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.xz,vec2(0,1)).g;weights.ba=area(sqrtD,e1,e2,subsampleIndices.x);coords.x=vUv.x;detectVerticalCornerPattern(weights.ba,coords.xyxz,d);}gl_FragColor=weights;}`,vZ="uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void main(){vUv=position.xy*0.5+0.5;vPixCoord=vUv*resolution;vOffset[0]=vUv.xyxy+texelSize.xyxy*vec4(-0.25,-0.125,1.25,-0.125);vOffset[1]=vUv.xyxy+texelSize.xyxy*vec4(-0.125,-0.25,-0.125,1.25);vOffset[2]=vec4(vOffset[0].xz,vOffset[1].yw)+vec4(-2.0,2.0,-2.0,2.0)*texelSize.xxyy*MAX_SEARCH_STEPS_FLOAT;gl_Position=vec4(position.xy,1.0,1.0);}",yZ=class extends Dt{constructor(e=new j,t=new j){super({name:"SMAAWeightsMaterial",defines:{MAX_SEARCH_STEPS_INT:"16",MAX_SEARCH_STEPS_FLOAT:"16.0",MAX_SEARCH_STEPS_DIAG_INT:"8",MAX_SEARCH_STEPS_DIAG_FLOAT:"8.0",CORNER_ROUNDING:"25",CORNER_ROUNDING_NORM:"0.25",AREATEX_MAX_DISTANCE:"16.0",AREATEX_MAX_DISTANCE_DIAG:"20.0",AREATEX_PIXEL_SIZE:"(1.0 / vec2(160.0, 560.0))",AREATEX_SUBTEX_SIZE:"(1.0 / 7.0)",SEARCHTEX_SIZE:"vec2(66.0, 33.0)",SEARCHTEX_PACKED_SIZE:"vec2(64.0, 16.0)"},uniforms:{inputBuffer:new ye(null),searchTexture:new ye(null),areaTexture:new ye(null),resolution:new ye(t),texelSize:new ye(e)},blending:Oi,depthWrite:!1,depthTest:!1,fragmentShader:gZ,vertexShader:vZ}),this.toneMapped=!1}set inputBuffer(e){this.uniforms.inputBuffer.value=e}setInputBuffer(e){this.uniforms.inputBuffer.value=e}get searchTexture(){return this.uniforms.searchTexture.value}set searchTexture(e){this.uniforms.searchTexture.value=e}get areaTexture(){return this.uniforms.areaTexture.value}set areaTexture(e){this.uniforms.areaTexture.value=e}setLookupTextures(e,t){this.searchTexture=e,this.areaTexture=t}get orthogonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_INT)}set orthogonalSearchSteps(e){let t=Math.min(Math.max(e,0),112);this.defines.MAX_SEARCH_STEPS_INT=t.toFixed("0"),this.defines.MAX_SEARCH_STEPS_FLOAT=t.toFixed("1"),this.needsUpdate=!0}setOrthogonalSearchSteps(e){this.orthogonalSearchSteps=e}get diagonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_DIAG_INT)}set diagonalSearchSteps(e){let t=Math.min(Math.max(e,0),20);this.defines.MAX_SEARCH_STEPS_DIAG_INT=t.toFixed("0"),this.defines.MAX_SEARCH_STEPS_DIAG_FLOAT=t.toFixed("1"),this.needsUpdate=!0}setDiagonalSearchSteps(e){this.diagonalSearchSteps=e}get diagonalDetection(){return this.defines.DISABLE_DIAG_DETECTION===void 0}set diagonalDetection(e){e?delete this.defines.DISABLE_DIAG_DETECTION:this.defines.DISABLE_DIAG_DETECTION="1",this.needsUpdate=!0}isDiagonalDetectionEnabled(){return this.diagonalDetection}setDiagonalDetectionEnabled(e){this.diagonalDetection=e}get cornerRounding(){return Number(this.defines.CORNER_ROUNDING)}set cornerRounding(e){let t=Math.min(Math.max(e,0),100);this.defines.CORNER_ROUNDING=t.toFixed("4"),this.defines.CORNER_ROUNDING_NORM=(t/100).toFixed("4"),this.needsUpdate=!0}setCornerRounding(e){this.cornerRounding=e}get cornerDetection(){return this.defines.DISABLE_CORNER_DETECTION===void 0}set cornerDetection(e){e?delete this.defines.DISABLE_CORNER_DETECTION:this.defines.DISABLE_CORNER_DETECTION="1",this.needsUpdate=!0}isCornerRoundingEnabled(){return this.cornerDetection}setCornerRoundingEnabled(e){this.cornerDetection=e}setSize(e,t){let i=this.uniforms;i.texelSize.value.set(1/e,1/t),i.resolution.value.set(e,t)}},xZ=new bo,Ln=null;function bZ(){if(Ln===null){let e=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),t=new Float32Array([0,0,2,0,0,2]);Ln=new Ge,Ln.setAttribute!==void 0?(Ln.setAttribute("position",new tt(e,3)),Ln.setAttribute("uv",new tt(t,2))):(Ln.addAttribute("position",new tt(e,3)),Ln.addAttribute("uv",new tt(t,2)))}return Ln}var jr=class{constructor(e="Pass",t=new Jr,i=xZ){this.name=e,this.renderer=null,this.scene=t,this.camera=i,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(e){if(this.rtt===e){let t=this.getFullscreenMaterial();t!==null&&(t.needsUpdate=!0),this.rtt=!e}}setRenderer(e){this.renderer=e}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(e){let t=this.screen;t!==null?t.material=e:(t=new Jt(bZ(),e),t.frustumCulled=!1,this.scene===null&&(this.scene=new Jr),this.scene.add(t),this.screen=t)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e,t=_n){}render(e,t,i,r,s){throw new Error("Render method not implemented!")}setSize(e,t){}initialize(e,t,i){}dispose(){for(let e of Object.keys(this)){let t=this[e];if(t!==null&&typeof t=="object"&&typeof t.dispose=="function"){if(t instanceof Jr||t===this.renderer)continue;this[e].dispose()}}}},py=class extends jr{constructor(e,t=!0){super("CopyPass"),this.fullscreenMaterial=new aZ,this.needsSwap=!1,this.renderTarget=e,e===void 0&&(this.renderTarget=new Pt(1,1,{minFilter:xt,magFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=t}get resize(){return this.autoResize}set resize(e){this.autoResize=e}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(e){this.autoResize=e}render(e,t,i,r,s){this.fullscreenMaterial.inputBuffer=t.texture,e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){this.autoResize&&this.renderTarget.setSize(e,t)}initialize(e,t,i){i!==void 0&&(this.renderTarget.texture.type=i,i!==Er?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":e.outputEncoding===gt&&(this.renderTarget.texture.encoding=gt))}},wZ=class extends jr{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(e,t,i,r,s){let a=e.state.buffers.stencil;a.setLocked(!1),a.setTest(!1)}},Kg=new et,K1=class extends jr{constructor(e=!0,t=!0,i=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=e,this.depth=t,this.stencil=i,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(e,t,i){this.color=e,this.depth=t,this.stencil=i}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(e){this.overrideClearColor=e}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(e){this.overrideClearAlpha=e}render(e,t,i,r,s){let a=this.overrideClearColor,n=this.overrideClearAlpha,o=e.getClearAlpha(),l=a!==null,h=n>=0;l?(Kg.copy(e.getClearColor(Kg)),e.setClearColor(a,h?n:o)):h&&e.setClearAlpha(n),e.setRenderTarget(this.renderToScreen?null:t),e.clear(this.color,this.depth,this.stencil),l?e.setClearColor(Kg,o):h&&e.setClearAlpha(o)}},zn=-1,Kr=class extends yr{constructor(e,t=zn,i=zn,r=1){super(),this.resizable=e,this.base=new j(1,1),this.preferred=new j(t,i),this.target=this.preferred,this.s=r}get width(){let{base:e,preferred:t,scale:i}=this,r;return t.width!==zn?r=t.width:t.height!==zn?r=Math.round(t.height*(e.width/Math.max(e.height,1))):r=Math.round(e.width*i),r}set width(e){this.preferredWidth=e}get height(){let{base:e,preferred:t,scale:i}=this,r;return t.height!==zn?r=t.height:t.width!==zn?r=Math.round(t.width/Math.max(e.width/Math.max(e.height,1),1)):r=Math.round(e.height*i),r}set height(e){this.preferredHeight=e}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(e){this.s!==e&&(this.s=e,this.preferred.setScalar(zn),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getScale(){return this.scale}setScale(e){this.scale=e}get baseWidth(){return this.base.width}set baseWidth(e){this.base.width!==e&&(this.base.width=e,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseWidth(){return this.base.width}setBaseWidth(e){this.base.width!==e&&(this.base.width=e,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get baseHeight(){return this.base.height}set baseHeight(e){this.base.height!==e&&(this.base.height=e,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(e){this.baseHeight=e}setBaseSize(e,t){(this.base.width!==e||this.base.height!==t)&&(this.base.set(e,t),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get preferredWidth(){return this.preferred.width}set preferredWidth(e){this.preferred.width!==e&&(this.preferred.width=e,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(e){this.preferredWidth=e}get preferredHeight(){return this.preferred.height}set preferredHeight(e){this.preferred.height!==e&&(this.preferred.height=e,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(e){this.preferredHeight=e}setPreferredSize(e,t){(this.preferred.width!==e||this.preferred.height!==t)&&(this.preferred.set(e,t),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}copy(e){this.base.set(e.getBaseWidth(),e.getBaseHeight()),this.preferred.set(e.getPreferredWidth(),e.getPreferredHeight()),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height)}static get AUTO_SIZE(){return zn}},Jg=!1,lA=class{constructor(e=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(e),this.meshCount=0,this.replaceMaterial=t=>{if(t.isMesh){let i;if(t.material.flatShading)switch(t.material.side){case Ar:i=this.materialsFlatShadedDoubleSide;break;case rr:i=this.materialsFlatShadedBackSide;break;default:i=this.materialsFlatShaded;break}else switch(t.material.side){case Ar:i=this.materialsDoubleSide;break;case rr:i=this.materialsBackSide;break;default:i=this.materials;break}this.originalMaterials.set(t,t.material),t.isSkinnedMesh?t.material=i[2]:t.isInstancedMesh?t.material=i[1]:t.material=i[0],++this.meshCount}}}setMaterial(e){if(this.disposeMaterials(),this.material=e,e!==null){let t=this.materials=[e.clone(),e.clone(),e.clone()];for(let i of t)i.uniforms=Object.assign({},e.uniforms),i.side=Ws;t[2].skinning=!0,this.materialsBackSide=t.map(i=>{let r=i.clone();return r.uniforms=Object.assign({},e.uniforms),r.side=rr,r}),this.materialsDoubleSide=t.map(i=>{let r=i.clone();return r.uniforms=Object.assign({},e.uniforms),r.side=Ar,r}),this.materialsFlatShaded=t.map(i=>{let r=i.clone();return r.uniforms=Object.assign({},e.uniforms),r.flatShading=!0,r}),this.materialsFlatShadedBackSide=t.map(i=>{let r=i.clone();return r.uniforms=Object.assign({},e.uniforms),r.flatShading=!0,r.side=rr,r}),this.materialsFlatShadedDoubleSide=t.map(i=>{let r=i.clone();return r.uniforms=Object.assign({},e.uniforms),r.flatShading=!0,r.side=Ar,r})}}render(e,t,i){let r=e.shadowMap.enabled;if(e.shadowMap.enabled=!1,Jg){let s=this.originalMaterials;this.meshCount=0,t.traverse(this.replaceMaterial),e.render(t,i);for(let a of s)a[0].material=a[1];this.meshCount!==s.size&&s.clear()}else{let s=t.overrideMaterial;t.overrideMaterial=this.material,e.render(t,i),t.overrideMaterial=s}e.shadowMap.enabled=r}disposeMaterials(){if(this.material!==null){let e=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let t of e)t.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return Jg}static set workaroundEnabled(e){Jg=e}},_Z=class extends jr{constructor(e,t,i=null){super("RenderPass",e,t),this.needsSwap=!1,this.clearPass=new K1,this.overrideMaterialManager=i===null?null:new lA(i),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}get renderToScreen(){return super.renderToScreen}set renderToScreen(e){super.renderToScreen=e,this.clearPass.renderToScreen=e}get overrideMaterial(){let e=this.overrideMaterialManager;return e!==null?e.material:null}set overrideMaterial(e){let t=this.overrideMaterialManager;e!==null?t!==null?t.setMaterial(e):this.overrideMaterialManager=new lA(e):t!==null&&(t.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(e){this.overrideMaterial=e}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getSelection(){return this.selection}setSelection(e){this.selection=e}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(e){this.ignoreBackground=e}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(e){this.skipShadowMapUpdate=e}getClearPass(){return this.clearPass}render(e,t,i,r,s){let a=this.scene,n=this.camera,o=this.selection,l=n.layers.mask,h=a.background,c=e.shadowMap.autoUpdate,d=this.renderToScreen?null:t;o!==null&&n.layers.set(o.getLayer()),this.skipShadowMapUpdate&&(e.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(a.background=null),this.clearPass.enabled&&this.clearPass.render(e,t),e.setRenderTarget(d),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(e,a,n):e.render(a,n),n.layers.mask=l,a.background=h,e.shadowMap.autoUpdate=c}},hA=class extends jr{constructor(e,t,{resolutionScale:i=1,width:r=Kr.AUTO_SIZE,height:s=Kr.AUTO_SIZE,renderTarget:a}={}){super("DepthPass"),this.needsSwap=!1,this.renderPass=new _Z(e,t,new xM({depthPacking:sM}));let n=this.renderPass;n.skipShadowMapUpdate=!0,n.ignoreBackground=!0;let o=n.getClearPass();o.overrideClearColor=new et(16777215),o.overrideClearAlpha=1,this.renderTarget=a,this.renderTarget===void 0&&(this.renderTarget=new Pt(1,1,{minFilter:_t,magFilter:_t,stencilBuffer:!1}),this.renderTarget.texture.name="DepthPass.Target");let l=this.resolution=new Kr(this,r,s,i);l.addEventListener("change",h=>this.setSize(l.baseWidth,l.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}render(e,t,i,r,s){let a=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,a)}setSize(e,t){let i=this.resolution;i.setBaseSize(e,t),this.renderTarget.setSize(i.width,i.height)}},Ot={SKIP:0,ADD:1,ALPHA:2,AVERAGE:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,EXCLUSION:8,LIGHTEN:9,MULTIPLY:10,DIVIDE:11,NEGATION:12,NORMAL:13,OVERLAY:14,REFLECT:15,SCREEN:16,SOFT_LIGHT:17,SUBTRACT:18},SZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x+y,1.0)*opacity+x*(1.0-opacity);}",AZ="vec3 blend(const in vec3 x,const in vec3 y,const in float opacity){return y*opacity+x*(1.0-opacity);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){float a=min(y.a,opacity);return vec4(blend(x.rgb,y.rgb,a),max(x.a,a));}",MZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}",EZ="float blend(const in float x,const in float y){return(y==0.0)?y:max(1.0-(1.0-x)/y,0.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",CZ="float blend(const in float x,const in float y){return(y==1.0)?y:min(x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",TZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}",PZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}",DZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y-2.0*x*y)*opacity+x*(1.0-opacity);}",IZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}",OZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}",RZ="float blend(const in float x,const in float y){return(y>0.0)?min(x/y,1.0):1.0;}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",LZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-abs(1.0-x-y))*opacity+x*(1.0-opacity);}",zZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}",BZ="float blend(const in float x,const in float y){return(x<0.5)?(2.0*x*y):(1.0-2.0*(1.0-x)*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",FZ="float blend(const in float x,const in float y){return(y==1.0)?y:min(x*x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",UZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-(1.0-x)*(1.0-y))*opacity+x*(1.0-opacity);}",NZ="float blend(const in float x,const in float y){return(y<0.5)?(2.0*x*y+x*x*(1.0-2.0*y)):(sqrt(x)*(2.0*y-1.0)+2.0*x*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",kZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x+y-1.0,0.0)*opacity+x*(1.0-opacity);}",VZ=new Map([[Ot.SKIP,null],[Ot.ADD,SZ],[Ot.ALPHA,AZ],[Ot.AVERAGE,MZ],[Ot.COLOR_BURN,EZ],[Ot.COLOR_DODGE,CZ],[Ot.DARKEN,TZ],[Ot.DIFFERENCE,PZ],[Ot.EXCLUSION,DZ],[Ot.LIGHTEN,IZ],[Ot.MULTIPLY,OZ],[Ot.DIVIDE,RZ],[Ot.NEGATION,LZ],[Ot.NORMAL,zZ],[Ot.OVERLAY,BZ],[Ot.REFLECT,FZ],[Ot.SCREEN,UZ],[Ot.SOFT_LIGHT,NZ],[Ot.SUBTRACT,kZ]]),jZ=class extends yr{constructor(e,t=1){super(),this.f=e,this.opacity=new ye(t)}getOpacity(){return this.opacity.value}setOpacity(e){this.opacity.value=e}get blendFunction(){return this.f}set blendFunction(e){this.f=e,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(e){this.blendFunction=e}getShaderCode(){return VZ.get(this.blendFunction)}},Aa={NONE:0,DEPTH:1,CONVOLUTION:2},Oa=class extends yr{constructor(e,t,{attributes:i=Aa.NONE,blendFunction:r=Ot.SCREEN,defines:s=new Map,uniforms:a=new Map,extensions:n=null,vertexShader:o=null}={}){super(),this.name=e,this.renderer=null,this.attributes=i,this.fragmentShader=t,this.vertexShader=o,this.defines=s,this.uniforms=a,this.extensions=n,this.blendMode=new jZ(r),this.blendMode.addEventListener("change",l=>this.setChanged())}getName(){return this.name}setRenderer(e){this.renderer=e}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(e){this.fragmentShader=e,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(e){this.vertexShader=e,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(e,t=_n){}update(e,t,i){}setSize(e,t){}initialize(e,t,i){}dispose(){for(let e of Object.keys(this)){let t=this[e];if(t!==null&&typeof t=="object"&&typeof t.dispose=="function"){if(t instanceof Jr||t===this.renderer)continue;this[e].dispose()}}}};function cA(e,t,i){for(let r of t){let s="$1"+e+r.charAt(0).toUpperCase()+r.slice(1),a=new RegExp("([^\\.])(\\b"+r+"\\b)","g");for(let n of i.entries())n[1]!==null&&i.set(n[0],n[1].replace(a,s))}}function GZ(e,t,i,r,s,a,n){let o=new Map([["fragment",t.getFragmentShader()],["vertex",t.getVertexShader()]]),l=o.get("fragment")!==void 0&&/mainImage/.test(o.get("fragment")),h=o.get("fragment")!==void 0&&/mainUv/.test(o.get("fragment")),c=[],d=[],u=!1,p=!1;if(o.get("fragment")===void 0)console.error("Missing fragment shader",t);else if(h&&n&Aa.CONVOLUTION)console.error("Effects that transform UV coordinates are incompatible with convolution effects",t);else if(!l&&!h)console.error("The fragment shader contains neither a mainImage nor a mainUv function",t);else{let f=/(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g,g=uy.Section;if(h){let v=` ${e}MainUv(UV);
  5287. `;i.set(g.FRAGMENT_MAIN_UV,i.get(g.FRAGMENT_MAIN_UV)+v),u=!0}if(o.get("vertex")!==null&&/mainSupport/.test(o.get("vertex"))){let v=` ${e}MainSupport(`;v+=/mainSupport *\([\w\s]*?uv\s*?\)/.test(o.get("vertex"))?`vUv);
  5288. `:`);
  5289. `,i.set(g.VERTEX_MAIN_SUPPORT,i.get(g.VERTEX_MAIN_SUPPORT)+v),c=c.concat([...o.get("vertex").matchAll(/(?:varying\s+\w+\s+(\w*))/g)].map(y=>y[1])),d=d.concat(c).concat([...o.get("vertex").matchAll(f)].map(y=>y[1]))}d=d.concat([...o.get("fragment").matchAll(f)].map(v=>v[1])),d=d.concat([...t.defines.keys()].map(v=>v.replace(/\([\w\s,]*\)/g,""))),d=d.concat([...t.uniforms.keys()]),t.uniforms.forEach((v,y)=>a.set(e+y.charAt(0).toUpperCase()+y.slice(1),v)),t.defines.forEach((v,y)=>s.set(e+y.charAt(0).toUpperCase()+y.slice(1),v)),cA(e,d,s),cA(e,d,o);let m=t.blendMode;if(r.set(m.blendFunction,m),l){let v=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/,y=`${e}MainImage(color0, UV, `;n&Aa.DEPTH&&v.test(o.get("fragment"))&&(y+="depth, ",p=!0),y+=`color1);
  5290. `;let x=e+"BlendOpacity";a.set(x,m.opacity),y+=`color0 = blend${m.blendFunction}(color0, color1, ${x});
  5291. `,i.set(g.FRAGMENT_MAIN_IMAGE,i.get(g.FRAGMENT_MAIN_IMAGE)+y),y=`uniform float ${x};
  5292. `,i.set(g.FRAGMENT_HEAD,i.get(g.FRAGMENT_HEAD)+y)}i.set(g.FRAGMENT_HEAD,i.get(g.FRAGMENT_HEAD)+o.get("fragment")+`
  5293. `),o.get("vertex")!==null&&i.set(g.VERTEX_HEAD,i.get(g.VERTEX_HEAD)+o.get("vertex")+`
  5294. `)}return{varyings:c,transformedUv:u,readDepth:p}}var Bf=class extends jr{constructor(e,...t){super("EffectPass"),this.fullscreenMaterial=new uy(null,null,null,e),this.effects=t.sort((i,r)=>r.attributes-i.attributes),this.skipRendering=!1,this.uniformCount=0,this.varyingCount=0,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(e){this.fullscreenMaterial.encodeOutput=e}get dithering(){return this.fullscreenMaterial.dithering}set dithering(e){let t=this.fullscreenMaterial;t.dithering=e,t.needsUpdate=!0}verifyResources(){let e=this.renderer.capabilities,t=Math.min(e.maxFragmentUniforms,e.maxVertexUniforms);this.uniformCount>t&&console.warn("The current rendering context doesn't support more than "+t+" uniforms, but "+this.uniformCount+" were defined"),t=e.maxVaryings,this.varyingCount>t&&console.warn("The current rendering context doesn't support more than "+t+" varyings, but "+this.varyingCount+" were defined")}updateMaterial(){let e=uy.Section,t=new Map([[e.FRAGMENT_HEAD,""],[e.FRAGMENT_MAIN_UV,""],[e.FRAGMENT_MAIN_IMAGE,""],[e.VERTEX_HEAD,""],[e.VERTEX_MAIN_SUPPORT,""]]),i=new Map,r=new Map,s=new Map,a=new Set,n=0,o=0,l=0,h=!1,c=!1;for(let u of this.effects)if(u.blendMode.blendFunction===Ot.SKIP)l|=u.getAttributes()&Aa.DEPTH;else if(l&u.getAttributes()&Aa.CONVOLUTION)console.error("Convolution effects cannot be merged",u);else{l|=u.getAttributes();let p="e"+n++,f=GZ(p,u,t,i,r,s,l);if(o+=f.varyings.length,h=h||f.transformedUv,c=c||f.readDepth,u.extensions!==null)for(let g of u.extensions)a.add(g)}let d=/\bblend\b/g;for(let u of i.values()){let p=u.getShaderCode().replace(d,`blend${u.blendFunction}`);t.set(e.FRAGMENT_HEAD,t.get(e.FRAGMENT_HEAD)+p+`
  5295. `)}l&Aa.DEPTH?(c&&t.set(e.FRAGMENT_MAIN_IMAGE,`float depth = readDepth(UV);
  5296. `+t.get(e.FRAGMENT_MAIN_IMAGE)),this.needsDepthTexture=this.getDepthTexture()===null):this.needsDepthTexture=!1,h?(t.set(e.FRAGMENT_MAIN_UV,`vec2 transformedUv = vUv;
  5297. `+t.get(e.FRAGMENT_MAIN_UV)),r.set("UV","transformedUv")):r.set("UV","vUv"),t.forEach((u,p,f)=>f.set(p,u.trim().replace(/^#/,`
  5298. #`))),this.uniformCount=s.size,this.varyingCount=o,this.skipRendering=n===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderParts(t).setExtensions(a).setUniforms(s).setDefines(r)}recompile(){this.updateMaterial(),this.verifyResources()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(e,t=_n){this.fullscreenMaterial.depthBuffer=e,this.fullscreenMaterial.depthPacking=t;for(let i of this.effects)i.setDepthTexture(e,t)}render(e,t,i,r,s){for(let a of this.effects)a.update(e,t,r);if(!this.skipRendering||this.renderToScreen){let a=this.fullscreenMaterial;a.inputBuffer=t.texture,a.time+=r,e.setRenderTarget(this.renderToScreen?null:i),e.render(this.scene,this.camera)}}setSize(e,t){this.fullscreenMaterial.setSize(e,t);for(let i of this.effects)i.setSize(e,t)}initialize(e,t,i){this.renderer=e;for(let r of this.effects)r.initialize(e,t,i),r.addEventListener("change",s=>this.handleEvent(s));this.updateMaterial(),this.verifyResources(),i!==void 0&&i!==Er&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(let e of this.effects)e.dispose()}handleEvent(e){switch(e.type){case"change":this.recompile();break}}},HZ=[new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10])],J1=class extends jr{constructor({resolutionScale:e=.5,width:t=Kr.AUTO_SIZE,height:i=Kr.AUTO_SIZE,kernelSize:r=fm.LARGE}={}){super("KawaseBlurPass"),this.renderTargetA=new Pt(1,1,{minFilter:xt,magFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";let s=this.resolution=new Kr(this,t,i,e);s.addEventListener("change",a=>this.setSize(s.baseWidth,s.baseHeight)),this.blurMaterial=new oA,this.ditheredBlurMaterial=new oA,this.ditheredBlurMaterial.uniforms.scale=this.blurMaterial.uniforms.scale,this.ditheredBlurMaterial.dithering=!0,this.dithering=!1,this.kernelSize=r}getResolution(){return this.resolution}get width(){return this.resolution.width}set width(e){this.resolution.preferredWidth=e}get height(){return this.resolution.height}set height(e){this.resolution.preferredHeight=e}get scale(){return this.blurMaterial.scale}set scale(e){this.blurMaterial.scale=e}getScale(){return this.blurMaterial.scale}setScale(e){this.blurMaterial.scale=e}getKernelSize(){return this.kernelSize}setKernelSize(e){this.kernelSize=e}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}render(e,t,i,r,s){let a=this.scene,n=this.camera,o=this.renderTargetA,l=this.renderTargetB,h=HZ[this.kernelSize],c=this.blurMaterial,d=t,u,p;for(this.fullscreenMaterial=c,u=0,p=h.length-1;u<p;++u){let f=u&1?l:o;c.kernel=h[u],c.inputBuffer=d.texture,e.setRenderTarget(f),e.render(a,n),d=f}this.dithering&&(c=this.ditheredBlurMaterial,this.fullscreenMaterial=c),c.kernel=h[u],c.inputBuffer=d.texture,e.setRenderTarget(this.renderToScreen?null:i),e.render(a,n)}setSize(e,t){let i=this.resolution;i.setBaseSize(e,t);let r=i.width,s=i.height;this.renderTargetA.setSize(r,s),this.renderTargetB.setSize(r,s),this.blurMaterial.setSize(r,s),this.ditheredBlurMaterial.setSize(r,s)}initialize(e,t,i){i!==void 0&&(this.renderTargetA.texture.type=i,this.renderTargetB.texture.type=i,i!==Er?(this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1",this.ditheredBlurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1"):e.outputEncoding===gt&&(this.renderTargetA.texture.encoding=gt,this.renderTargetB.texture.encoding=gt))}static get AUTO_SIZE(){return Kr.AUTO_SIZE}},WZ=class extends jr{constructor({width:e=Kr.AUTO_SIZE,height:t=Kr.AUTO_SIZE,renderTarget:i,luminanceRange:r,colorOutput:s}={}){super("LuminancePass"),this.fullscreenMaterial=new pZ(s,r),this.needsSwap=!1,this.renderTarget=i,this.renderTarget===void 0&&(this.renderTarget=new Pt(1,1,{minFilter:xt,magFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target",this.renderTarget.texture.generateMipmaps=!1);let a=this.resolution=new Kr(this,e,t);a.addEventListener("change",n=>this.setSize(a.baseWidth,a.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(e,t,i,r,s){let a=this.fullscreenMaterial;a.inputBuffer=t.texture,e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){let i=this.resolution;i.setBaseSize(e,t),this.renderTarget.setSize(i.width,i.height)}initialize(e,t,i){i!==void 0&&i!==Er&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},qZ=class extends jr{constructor(e,t){super("MaskPass",e,t),this.needsSwap=!1,this.clearPass=new K1(!1,!1,!0),this.inverse=!1}get inverted(){return this.inverse}set inverted(e){this.inverse=e}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(e){this.inverted=e}render(e,t,i,r,s){let a=e.getContext(),n=e.state.buffers,o=this.scene,l=this.camera,h=this.clearPass,c=this.inverted?0:1,d=1-c;n.color.setMask(!1),n.depth.setMask(!1),n.color.setLocked(!0),n.depth.setLocked(!0),n.stencil.setTest(!0),n.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),n.stencil.setFunc(a.ALWAYS,c,4294967295),n.stencil.setClear(d),n.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?h.render(e,null):(h.render(e,t),h.render(e,i))),this.renderToScreen?(e.setRenderTarget(null),e.render(o,l)):(e.setRenderTarget(t),e.render(o,l),e.setRenderTarget(i),e.render(o,l)),n.color.setLocked(!1),n.depth.setLocked(!1),n.stencil.setLocked(!1),n.stencil.setFunc(a.EQUAL,1,4294967295),n.stencil.setOp(a.KEEP,a.KEEP,a.KEEP),n.stencil.setLocked(!0)}},xs=class extends jr{constructor(e,t="inputBuffer"){super("ShaderPass"),this.fullscreenMaterial=e,this.inputBufferUniform=null,this.setInput(t)}setInput(e){if(this.inputBufferUniform=null,this.fullscreenMaterial!==null){let t=this.fullscreenMaterial.uniforms;t!==void 0&&t[e]!==void 0&&(this.inputBufferUniform=t[e])}}render(e,t,i,r,s){this.inputBufferUniform!==null&&t!==null&&(this.inputBufferUniform.value=t.texture),e.setRenderTarget(this.renderToScreen?null:i),e.render(this.scene,this.camera)}initialize(e,t,i){i!==void 0&&i!==Er&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},$g=1/1e3,XZ=1e3,YZ=class{constructor(){this.previousTime=0,this.currentTime=0,this.delta=0,this.fixedDelta=1e3/60,this.elapsed=0,this.timescale=1,this.fixedDeltaEnabled=!1,this.autoReset=!1}setFixedDeltaEnabled(e){return this.fixedDeltaEnabled=e,this}isAutoResetEnabled(e){return this.autoReset}setAutoResetEnabled(e){return typeof document<"u"&&document.hidden!==void 0&&(e?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this.autoReset=e),this}getDelta(){return this.delta*$g}getFixedDelta(){return this.fixedDelta*$g}setFixedDelta(e){return this.fixedDelta=e*XZ,this}getElapsed(){return this.elapsed*$g}getTimescale(){return this.timescale}setTimescale(e){return this.timescale=e,this}update(e){return this.fixedDeltaEnabled?this.delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=e!==void 0?e:performance.now(),this.delta=this.currentTime-this.previousTime),this.delta*=this.timescale,this.elapsed+=this.delta,this}reset(){return this.delta=0,this.elapsed=0,this.currentTime=performance.now(),this}handleEvent(e){document.hidden||(this.currentTime=performance.now())}dispose(){this.setAutoResetEnabled(!1)}},fm={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5},QZ=`#ifdef FRAMEBUFFER_PRECISION_HIGH
  5299. uniform mediump sampler2D map;
  5300. #else
  5301. uniform lowp sampler2D map;
  5302. #endif
  5303. uniform float intensity;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=clamp(texture2D(map,uv)*intensity,0.0,1.0);}`,ZZ=class extends Oa{constructor({blendFunction:e=Ot.SCREEN,luminanceThreshold:t=.9,luminanceSmoothing:i=.025,resolutionScale:r=.5,intensity:s=1,width:a=Kr.AUTO_SIZE,height:n=Kr.AUTO_SIZE,kernelSize:o=fm.LARGE}={}){super("BloomEffect",QZ,{blendFunction:e,uniforms:new Map([["map",new ye(null)],["intensity",new ye(s)]])}),this.renderTarget=new Pt(1,1,{minFilter:xt,magFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="Bloom.Target",this.renderTarget.texture.generateMipmaps=!1,this.uniforms.get("map").value=this.renderTarget.texture,this.luminancePass=new WZ({renderTarget:this.renderTarget,colorOutput:!0}),this.luminanceMaterial.threshold=t,this.luminanceMaterial.smoothingFactor=i,this.blurPass=new J1({resolutionScale:r,width:a,height:n,kernelSize:o});let l=this.blurPass.getResolution();l.addEventListener("change",h=>this.setSize(l.baseWidth,l.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}get resolution(){return this.blurPass.resolution}getResolution(){return this.blurPass.resolution}getBlurPass(){return this.blurPass}getLuminancePass(){return this.luminancePass}get luminanceMaterial(){return this.luminancePass.fullscreenMaterial}getLuminanceMaterial(){return this.luminancePass.fullscreenMaterial}get width(){return this.resolution.width}set width(e){this.resolution.preferredWidth=e}get height(){return this.resolution.height}set height(e){this.resolution.preferredHeight=e}get dithering(){return this.blurPass.dithering}set dithering(e){this.blurPass.dithering=e}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(e){this.blurPass.kernelSize=e}get distinction(){return console.warn(this.name,"distinction was removed"),1}set distinction(e){console.warn(this.name,"distinction was removed")}get intensity(){return this.uniforms.get("intensity").value}set intensity(e){this.uniforms.get("intensity").value=e}getIntensity(){return this.intensity}setIntensity(e){this.intensity=e}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}update(e,t,i){let r=this.renderTarget;this.luminancePass.enabled?(this.luminancePass.render(e,t,r),this.blurPass.render(e,r,r)):this.blurPass.render(e,t,r)}setSize(e,t){let i=this.resolution;i.setBaseSize(e,t),this.renderTarget.setSize(i.width,i.height),this.luminancePass.resolution.copy(i)}initialize(e,t,i){this.blurPass.initialize(e,t,i),i!==void 0&&(this.renderTarget.texture.type=i,e.outputEncoding===gt&&(this.renderTarget.texture.encoding=gt))}},KZ="uniform float brightness;uniform float contrast;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=inputColor.rgb+vec3(brightness-0.5);if(contrast>0.0){color/=vec3(1.0-contrast);}else{color*=vec3(1.0+contrast);}outputColor=vec4(min(color+vec3(0.5),1.0),inputColor.a);}",JZ=class extends Oa{constructor({blendFunction:e=Ot.NORMAL,brightness:t=0,contrast:i=0}={}){super("BrightnessContrastEffect",KZ,{blendFunction:e,uniforms:new Map([["brightness",new ye(t)],["contrast",new ye(i)]])})}get brightness(){return this.uniforms.get("brightness").value}set brightness(e){this.uniforms.get("brightness").value=e}getBrightness(e){return this.brightness}setBrightness(e){this.brightness=e}get contrast(){return this.uniforms.get("contrast").value}set contrast(e){this.uniforms.get("contrast").value=e}getContrast(e){return this.contrast}setContrast(e){this.contrast=e}},$Z="void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=vec4(vec3(average(inputColor.rgb)),inputColor.a);}",eK=class extends Oa{constructor(e=Ot.NORMAL){super("ColorAverageEffect",$Z,{blendFunction:e})}},tK="varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec2 ra=texture2D(inputBuffer,vUvR).ra;vec2 ba=texture2D(inputBuffer,vUvB).ba;outputColor=vec4(ra.x,inputColor.g,ba.x,max(max(ra.y,ba.y),inputColor.a));}",iK="uniform vec2 offset;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vec2 shift=offset*vec2(1.0,aspect);vUvR=uv+shift;vUvB=uv-shift;}",rK=class extends Oa{constructor({blendFunction:e=Ot.NORMAL,offset:t=new j(.001,5e-4)}={}){super("ChromaticAberrationEffect",tK,{vertexShader:iK,blendFunction:e,attributes:Aa.CONVOLUTION,uniforms:new Map([["offset",new ye(t)]])})}get offset(){return this.uniforms.get("offset").value}set offset(e){this.uniforms.get("offset").value=e}getOffset(){return this.offset}setOffset(e){this.offset=e}},sK=`#ifdef FRAMEBUFFER_PRECISION_HIGH
  5304. uniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuffer;
  5305. #else
  5306. uniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer;
  5307. #endif
  5308. uniform lowp sampler2D nearCoCBuffer;uniform float scale;void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){vec4 colorNear=texture2D(nearColorBuffer,uv);vec4 colorFar=texture2D(farColorBuffer,uv);float CoCNear=texture2D(nearCoCBuffer,uv).r;CoCNear=min(CoCNear*scale,1.0);vec4 result=inputColor*(1.0-colorFar.a)+colorFar;result=mix(result,colorNear,CoCNear);outputColor=result;}`,aK=class extends Oa{constructor(e,{blendFunction:t=Ot.NORMAL,worldFocusDistance:i,worldFocusRange:r,focusDistance:s=0,focalLength:a=.1,focusRange:n=a,bokehScale:o=1,width:l=Kr.AUTO_SIZE,height:h=Kr.AUTO_SIZE}={}){super("DepthOfFieldEffect",sK,{blendFunction:t,attributes:Aa.DEPTH,uniforms:new Map([["nearColorBuffer",new ye(null)],["farColorBuffer",new ye(null)],["nearCoCBuffer",new ye(null)],["scale",new ye(1)]])}),this.camera=e,this.renderTarget=new Pt(1,1,{minFilter:xt,magFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="DoF.Intermediate",this.renderTarget.texture.generateMipmaps=!1,this.renderTargetMasked=this.renderTarget.clone(),this.renderTargetMasked.texture.name="DoF.Masked.Far",this.renderTargetNear=this.renderTarget.clone(),this.renderTargetNear.texture.name="DoF.Bokeh.Near",this.uniforms.get("nearColorBuffer").value=this.renderTargetNear.texture,this.renderTargetFar=this.renderTarget.clone(),this.renderTargetFar.texture.name="DoF.Bokeh.Far",this.uniforms.get("farColorBuffer").value=this.renderTargetFar.texture,this.renderTargetCoC=this.renderTarget.clone(),this.renderTargetCoC.texture.name="DoF.CoC",this.renderTargetCoCBlurred=this.renderTargetCoC.clone(),this.renderTargetCoCBlurred.texture.name="DoF.CoC.Blurred",this.uniforms.get("nearCoCBuffer").value=this.renderTargetCoCBlurred.texture,this.cocPass=new xs(new tZ(e));let c=this.cocMaterial;c.focusDistance=s,c.focusRange=n,i!==void 0&&(c.worldFocusDistance=i),r!==void 0&&(c.worldFocusRange=r),this.blurPass=new J1({kernelSize:fm.MEDIUM,width:l,height:h});let d=this.blurPass.getResolution();d.addEventListener("change",p=>this.setSize(d.getBaseWidth(),d.getBaseHeight())),this.maskPass=new xs(new mZ(this.renderTargetCoC.texture));let u=this.maskPass.fullscreenMaterial;u.maskFunction=HT.MULTIPLY,u.colorChannel=GT.GREEN,this.bokehNearBasePass=new xs(new lp(!1,!0)),this.bokehNearBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehNearFillPass=new xs(new lp(!0,!0)),this.bokehNearFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehFarBasePass=new xs(new lp(!1,!1)),this.bokehFarBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.bokehFarFillPass=new xs(new lp(!0,!1)),this.bokehFarFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.target=null,this.bokehScale=o}get cocTexture(){return this.renderTargetCoC.texture}get cocMaterial(){return this.cocPass.fullscreenMaterial}get circleOfConfusionMaterial(){return this.cocMaterial}getCircleOfConfusionMaterial(){return this.circleOfConfusionMaterial}getBlurPass(){return this.blurPass}get resolution(){return this.blurPass.getResolution()}getResolution(){return this.blurPass.getResolution()}get bokehScale(){return this.uniforms.get("scale").value}set bokehScale(e){let t=[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];for(let i of t)i.fullscreenMaterial.setScale(e);this.maskPass.fullscreenMaterial.setStrength(e),this.uniforms.get("scale").value=e}getBokehScale(){return this.bokehScale}setBokehScale(e){this.bokehScale=e}getTarget(){return this.target}setTarget(e){this.target=e}calculateFocusDistance(e){let t=this.camera,i=t.position.distanceTo(e);return dy(-i,t.near,t.far)}setDepthTexture(e,t=_n){this.circleOfConfusionMaterial.depthBuffer=e,this.circleOfConfusionMaterial.depthPacking=t}update(e,t,i){let r=this.renderTarget,s=this.renderTargetCoC,a=this.renderTargetCoCBlurred,n=this.renderTargetMasked;if(this.target!==null){let o=this.calculateFocusDistance(this.target);this.circleOfConfusionMaterial.focusDistance=o}this.cocPass.render(e,null,s),this.blurPass.render(e,s,a),this.maskPass.render(e,t,n),this.bokehFarBasePass.render(e,n,r),this.bokehFarFillPass.render(e,r,this.renderTargetFar),this.bokehNearBasePass.render(e,t,r),this.bokehNearFillPass.render(e,r,this.renderTargetNear)}setSize(e,t){let i=this.resolution;i.setBaseSize(e,t);let r=i.width,s=i.height,a=[this.cocPass,this.blurPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];a.push(this.renderTargetCoC,this.renderTargetMasked),a.forEach(n=>n.setSize(e,t)),a=[this.renderTarget,this.renderTargetNear,this.renderTargetFar,this.renderTargetCoCBlurred],a.forEach(n=>n.setSize(r,s)),[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(n=>n.fullscreenMaterial.setSize(r,s))}initialize(e,t,i){[this.cocPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(r=>r.initialize(e,t,i)),this.blurPass.initialize(e,t,Er),i!==void 0&&(this.renderTarget.texture.type=i,this.renderTargetNear.texture.type=i,this.renderTargetFar.texture.type=i,this.renderTargetMasked.texture.type=i,e.outputEncoding===gt&&(this.renderTarget.texture.encoding=gt,this.renderTargetNear.texture.encoding=gt,this.renderTargetFar.texture.encoding=gt,this.renderTargetMasked.texture.encoding=gt))}};new M;new we;var nK="uniform vec3 hue;uniform float saturation;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(dot(inputColor.rgb,hue.xyz),dot(inputColor.rgb,hue.zxy),dot(inputColor.rgb,hue.yzx));float average=(color.r+color.g+color.b)/3.0;vec3 diff=average-color;if(saturation>0.0){color+=diff*(1.0-1.0/(1.001-saturation));}else{color+=diff*-saturation;}outputColor=vec4(min(color,1.0),inputColor.a);}",oK=class extends Oa{constructor({blendFunction:e=Ot.NORMAL,hue:t=0,saturation:i=0}={}){super("HueSaturationEffect",nK,{blendFunction:e,uniforms:new Map([["hue",new ye(new M)],["saturation",new ye(i)]])}),this.hue=t}get saturation(){return this.uniforms.get("saturation").value}set saturation(e){this.uniforms.get("saturation").value=e}getSaturation(){return this.saturation}setSaturation(e){this.saturation=e}get hue(){let e=this.uniforms.get("hue").value;return Math.acos((e.x*3-1)/2)}set hue(e){let t=Math.sin(e),i=Math.cos(e);this.uniforms.get("hue").value.set((2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3)}getHue(){return this.hue}setHue(e){this.hue=e}};new et;var lK=`void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*time));
  5309. #ifdef PREMULTIPLY
  5310. outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a);
  5311. #else
  5312. outputColor=vec4(noise,inputColor.a);
  5313. #endif
  5314. }`,hK=class extends Oa{constructor({blendFunction:e=Ot.SCREEN,premultiply:t=!1}={}){super("NoiseEffect",lK,{blendFunction:e}),this.premultiply=t}get premultiply(){return this.defines.has("PREMULTIPLY")}set premultiply(e){this.premultiply!==e&&(e?this.defines.set("PREMULTIPLY","1"):this.defines.delete("PREMULTIPLY"),this.setChanged())}isPremultiplied(){return this.premultiply}setPremultiplied(e){this.premultiply=e}},cK="uniform bool active;uniform vec2 d;void mainUv(inout vec2 uv){if(active){uv=vec2(d.x*(floor(uv.x/d.x)+0.5),d.y*(floor(uv.y/d.y)+0.5));}}",dK=class extends Oa{constructor(e=30){super("PixelationEffect",cK,{uniforms:new Map([["active",new ye(!1)],["d",new ye(new j)]])}),this.resolution=new j,this.d=0,this.granularity=e}get granularity(){return this.d}set granularity(e){let t=Math.floor(e);t%2>0&&(t+=1),this.d=t,this.uniforms.get("active").value=t>0,this.setSize(this.resolution.width,this.resolution.height)}getGranularity(){return this.granularity}setGranularity(e){this.granularity=e}setSize(e,t){this.resolution.set(e,t),this.uniforms.get("d").value.setScalar(this.d).divide(this.resolution)}};new M;new M;var dA="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC",uA="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAYAAAABNmBHAAAgAElEQVR4Xuy9CbhlV1ktOvbpq09DkiIkUBI6kxASIH0DlAQiIK1wRfSJTx+i4JX7vKIigs8HXpXvqVcvrcC9agQ7IDTSSWgqCQQliDRBJKkkhDSkqVPNqVOnP+8b//rH3P+eZ+199tlznVTlvVrft7+1T7OaueZY42/m37QALKNk2wHg1pITlB17mC+Pp11W3X/LHyT32vhg48/5SOv+PnwpsHA70JoGlueB1iKApeqzvOzn44GatTB76Xzhd7suBR7+WWADgDEAwwCG/L54b/poDLrHuvvm70Z2Avhsc+PVcxscBU8F8C8ADg5+ipIjD/PlGwfgju8B924E5seARUfLsiNmqQW0IjL8+7L2NYD/7COBzfcCm+aB8SVgdAkYIRCXKyDax4EdAanL5PuNPllNvXDlAHwFgP8AcC2AhRIoDXbsYb48dl5WkVFTE3LGDcC9m4CZCWBuFFgeAZaGAYJQQCRqDHT+McJrVb8zwATUXH02MHYfMHEIGFsAxgjApQqACYQORjtd/B7Axt/z79sC0+cMPgjjlwPwVwHcA+DfAHzTxcVgWBroqMN8+cYBeM71wH0TwKExYHYUWCIAHYRLTlkCYgcIBcAgU/n3qy8GRu4HRgnAOWBkERhddPAJhGJDBxkvw7cqimr+zFM/ZLnZF64cgL8BYD+AWwB8x/dlWuWagHiYL984AJ/0RWBy1AE4AizyM1yxYAcTigW55xMbAkxEiwEdkJ/ZCQxPAiOHgBECcKEC4TBZcKkSv+mTieNcNPNC26mLNsj45QD8LQDTAO4GcJt/7iw2bfoG4WG+vAGwm9ExiEg69zpg/wgwPQLMjgALzn4E4aIzoJjQ9g4024uygkj+pyuAoX0VAIfngOH5NgCHMhAm8Sv2y3XDZeBhNIp8OzJE8OsBzAKYBHAXgDt8/4O+MVT0j4f58o0D8Pxrgf3DwMwIMEPQEYRkNwfgsuuDZLskip0No0gWMD/9HGDoADAkAC4Aw/wsAgZAgs2Z0ABI0GU6IVmKv+f28KDnHxkA/G0A8y6G73N9kOCjXnh/Ebb6OvgwX75xAF5wLTA1VIHPADgMLDj4yIA5AAm6aCUnv4oz46eeDwxNAUMzwJAz4BABSNDFTwSfg7DDKHE23MG5PqIY8A1u/dINs9dBdy8AgnGPM2NfUBrsnw7z5RsH4IXXAAcJviFgluAbygBINnSLWOAjGxJ4pgOKDV0v/OSLKp8iGXBovhLBBOCQM2ACoTOhnYrAdItYbCij5JFzRyIAqRccAnDAQUjg6UNQ7hsMXP0cRQAexss3DsCLCECCLwCQzMcPwUi2MwAScAKbfnY/YRLFQ8DHX+IAJAMSfDkAF13kLvleIjhjQQHxUVS3jjgGpKeeNzYVQEjgUS8k+PghONdhIwAP4+XXBYCHKIJbwJyDTgaIAdCBJx3Q2M8tYAHP9m4df/ylQOsQ0JqtRLCx30K1wtLBggScQOgsKBGcWHAJeOwRC0BSM1mQIKRbhh+Bj98JQP6t4U0APEyXXxcAEnxkQAFwoVUxID9kvQg+c1C7vidRbIDkc24B//hTQGumDcCWA5DgMxASdNIFBUI5pCML8v8API5zfEQx4BudgqiczviSnJhQwCP4BMCGl+wO8+U7AJi/W4O4YS6+pmK/2ciADsAOBhTIIiAJnPB7AvNjP+0AnANaYkAHX2JBAc+tYaJXOqBZv24Vc386XW5dtkHGW+4HFAJonpOe+YYQZAShgKjv3PNvPQaxVoI8zJdfFwASfPzMUwS3Kt1v0UFIlos6oDFdAGFcliMAP/ryAEAGNwQRnDOgLbdlIEwrIs6AZ/QgkMMHQF6ZAKQcJAsSYPwIeAIk9wJgoPK1gi7+PwF4GC/fOAAvIQPSs0URTPBJ/Pp3GSEGRHfBCIQ0xowBtUbcAj7ys5X4Jfu1HIAGQrIgQRXEsAFQIORDFhiDY/rMHmrU4QUgR08AkgUjCAW6CD6CkwBsAIQC4GG6fPMA3OXiNzCg2I9gNCMksmAAoemDzoimFwL48M85AKkiuQVMAAp8CYRRDAt8GQiJ67N6GJODAXAHlsGguscA2AJg1IPGYmxOpBxFWkRN9LsATgIwXnNs/v/5z/9XCf8BO3YAtxbc/46/KDt+5+ea1Yku2VUxHz/z0v24FwMGK1gWsK2OUUxHHdCBeRUB6OxHABr4ZICIBd0QWSF+XRdMTAjgCdTrG9cBNwE4F8CpDkICyYLGsuhFt6zs+gISwUen8zEAjgMw4cfx2H6O/90yAFo84Cbg4ID3/9TfLTt+5+ebnRABkODjx0SwPi5ec/FrYpmqSAxM8Dn60CsqAFI6GfhqAMiDE/gokmvEr0C4PgDkBQm40wE8zMFEUDKEVoxIMLl/KS73mE7H9d+vcKHQQcjwW0Yu9nP8m8sAmOIBuWY6wP2/4s0ezjjg8TuvaR6ABJ70vxUApGrm7EbGE+i472BAB+WHfqHS/eoAaEwY2E9+wLSXTqhI7CXgnB6LCoOJ4BiST+hTnG0HcCwAglCx3ARoZEVFXnBPp/O/A/hXACc7CPs9/i1lAOyIB+RDX+P9/+pbQjjjAMfv/PL6AFDs1wFAgs/9fgKfgdE/ZEpuiQlbwAde6QAMBgiRmsSwA9BY0JfjovGRDBMH4TlcXGhcBOc6HkF0gjPhZgchxTLZMAci/04W/B6Ab3t09EPXcPyflgFwRTwgJ2MN9/8bf5qFM67x+B/aW4XQz42FeL0YrRyikztUFw0704mf9kXgxhOAqc3AAsPyRxxQCs/PdXOFY0W1KHy3QIUGtx+6vdnx1vsB+dsTncm2AogglFgVEAlUWrOMB2RyEmMCGQ/Y7/HvKns6tfGAnJQ+r/9b76oJZ1zD8WdyQjYBh8aBhVEHjELouQ8ukQ7VRSCJAALwkr+sALhnGzDD3JAJYJHg9uhoi4bx8ytkWUtvHT/7+Zc4dw1uZ3612fH2dkQf7yxIEEockwkJQn4IQoq8unhAhmPRKKFx0uv4K8ueTs94wD7u//VX9ghn7OP4c+4G7h8HpseB+dF2AKlFLwuAIZ8jD6NPrOhAffmfA9/ZBuzZCkyRWSeqBCWyoYGQ5yQrBpDbum/ME1HoPo0XEkSD2zlfbna8q6+EUJcTCxKEtHL5EQjP6BEPyIgYAZBvYt3xHyx7OqvGA65y/7/9wVXCGVc5/sl7qxD66dEqiYgRzAqhN1A4CBNAAlDyAFI+iZ9/N3DLJuC+jcDUBmCWyUnOrmTYCMIOkNclLg0B8/RsNLg9+UvNjnd1APLmmQpFHyEBROuWACQT8nN+H/GAvY7/VNnT6SsesMf13/CpahGnZzhjj+PPmwX2MYdDIfQexWyBAwEUOQDrRDN/98p3A7dvAO6fAA5sqHJDBEAyoUVGkwEd6HR12XU4kwzfl6fCXTZzjy57vvnR513X7Hj7AyDvggAUi9EyFgiZqNxPQF6345nOWbD1HQ/Y5fpvuLa/2+82/vNHgAPDFQDnhoF5j2C2qBWCI8bw1eRw5CL5l94L3DEOTI4DB8Y9OWmsEu/zBJ3rgsaybqBob/7A4C7jtWcooRrczr+u2fH2D0AOQgAUCxKEP7aGgLy64+m6KdjWFA9Yc/03/Osa4glrjr+AupqHz1sEs0cxG0BC9HIePLoit9eNkVf9L+DuUWByDJgaq4ybGYLPAWgiXmLedUE7dwC7saL7CqfPKXi4NYdaykCD410bAHlDEsNiwZ9wAPYbkJcfz6T2gm3N8YDZ9d/wHxUA+739fPwXPrSKYGb+BuP3jAFDElFH9HIWwbzCIGkBr/or4J4RYO8oMOW6ZVcAuvi1Cgoha04BCwT5gfMKHm7NoRde2+x41w5A3hQZkADk5+cGiAeMx3+/7AENFA8Yrv/G71cAXFM4Yzj+otOAaQLQA0gZxaIIZtMDFTigKJV8H9Iq6aZ59ZXAvSPAvpEKgBTtBODcSCWCZeRYtpzrmLyeGNCAyFl1v+Hei8qeb370Rdc2O97BAMi7EgB/2QG41nhAHU9LuWAbOB7Qr//GPRUA13r7Gv9FZwIMoVcEswEwfDoimEP0shKKtIphaZQAXv1+YM+wA3DEdcvRKkGJADQQEsQuhi1Tjt95vBsh5nx2IO59SsHDrTmUOStNjndwAAqEry0IyCMICkOyiuIBNwBvPFQQT7gBuPjc9oRYAIHyOEL4vIFEYVNaOou5vCGE/tV/A0wOVcnpzI47NOri3QFIBpSeaSDUdYLOSWvYImSGgftpJDa4MWJbAGxivGUA5MAOc0Be6eVLj7/4Mk+hzCOYPYpZDBiNkLh+G/M3yFyv/ltgL3W3YQfgcFUhgRY2PwY+Z7/EhAR1SFyXCOb57r28QfQBsJQBMn5D4y0HYLPje9Cd7RIC0PM3EiMofF4gVCBp1P840ix/gyz56r+vAMjk9Gl375iB4+CzveuZdLkkEPJ8ZEfX/6R73vOjzT5Si9hucLxHAVg4PwJgRwh9CKOXK8YA4ZEqKZXSQWh5P+5AftXfA/uGKvYjCKn72cctbFrZNECka5L5CPwIPtMH3TVz17MLB5gdLgA2Nd6jACycHwLQxFEUSR5ASvARDB0h9AQb9bXIgCGk6lUfAPYTgEPAITKgg1BObk58srTJgG58WMkWMaAbQQT1nc8rHGANAJsc71EAFs4PAagQestgC1lsBJ4BMCSOK6dDUcwqqaFiQr/0QeAAAdjy+jBiQQeeMSBZT3nCPUDIa9z+/MIB1gCwyfEeBWDh/BCAeQSzgkjFfGLBBD5nxQ4DxN0wv3hVxX5TBGDwL5obxvVA5YqYL5BeMLd66YYxJpRB0gK+96LCAdYAsMnxHgVg4fwIgMrhUPKQ2C+Bz0PmBTqBMQehAbDlIjj4F80KJguSVZ0FuXpjoCOgXawLjALhbT9eOMAuAGxqvEcBWDg/l1IE05Ed0ygZnyHdz0VwCqEPIfNyx0QQvvLDFQCp+8nfZk5und8tXwIgWcHSNX0N2CJmnAl3v6RwgNnhl17T7HiPArBwfghAS7mV/hey2JS9FvM3BLpUUi1YwDRMXvkRYJoAlAh2l0dcZ04s6JUTDIjyBcrl4yDc/dLCAdYAsMnxHgVg4fxwKVwJgGEJNmWtxpQMpX9on2eRhVA+O56AjMfnP+e3Xvf3NwG4xIPTleiY55bpGh6UbafNU0l0z0p+5Jh5HqYJ6b51nP6XP8cx12XNHQVgIQB/bFPVg2OC7Q+WgVFWng/FvtWLI06uWh5oguKEcXVS/9sEAF//VGD7t4ETDgJbF4CNi8CGZWBs2fPL/H6Vwp2KEtVk4fJ+v/EIYPN9wKa5qu+IncfPwXHVZe/aOL3EbwS7xv8A1rQvnO0j8PArTgTGZ4BxFv9mIxhOCGsv+0OPYDRghcLfkWkEuq0+G00x4OtfDGz+d2DbHmDLjL8si8AYP/7CGIAiEEMTG92zXqSbH+d9R2aA0XnvO+JjthiIrOVDHHPOkBrzUQAWAPsZp3oPDpa/Xag6EVkLBK+5rAnJC3/nYk/APD704WiEAV8OTHwX2LQH2DgFbJgFNrBhjd8r79deGoEwsllgNBOzy8CdjweG9wBj08AIAci2D6HafmyAk4/Z7SJ72hGYRwFYAMDLTwOGp4FRFgD3HhzqRGQiyeurqOdG6r0Rm8IEZjzRlkiqCWoEgK8Axm4BJu4HJhyAbFhDxmbDGnZO4j0SgLGDkpibgEq66TJw/1nA0F5gdLpq+zDqFfd5LMeWqu5HNST0uJOIllg+qgMWgI+HPv0xwLA3gWHpW2sC441gCECbmKziaGrnUdMO4aHeh6MxAP4SMHI7ML4HGD8AjHvHJGNAgpDgY/ck3stipRemvVhc+uASMPUEYGh/9dIRgGx8Y+MNbR/00uVtH0wEx94j/v0oAxaA8Ed+GBieAYZZg5kADC0QWGOFzGJlcGPzl1BxNLXD8sk4xftwNAbA/wwM3wGMUmxOOQBnHXzetIYvibonmSiuYTNjriVg7glAiwBk0fNZH6+PmX9P6kfNmCXGpftJ7TgKwBIAnln14BAAYxMYm5C6RjCyCoOyr0qkD/c+HI0B8DXA8N3AyCQwesD1VQKH7EcASm1Q+y4CkN9pUKiVF5nLvy+fBbTUd8QBaH1HvNBROiZvfsNnrF4kcvPwpdsBLBeU18Nf7AB23Dp4ecHC8oBgUlJJecLS+7+WOpE3gbE+HKw+yoevCYkMGKqPJrdEKARutaFYRs1fiEZ0wP8CDN8LDO8FRqYq3W10pgKgfYLaYCzootgA6KXaTA90y374TKB1sBozy77xHFZ536utRgAmEaw6g5kUSFZwSXnA330qsOlfgHMPDlZesLA8IOjoLypPWHj/11EnCiVwkz7kAExtsGraYUWdSDX5TmsagL8KDBGA7Bd30JsW0oWivnEOQNP7yGTSBR101AlZSUtGyfgZDkCWY1HnJdcBVe6325hTvelg2CQjZNDygG/2An0j1wKnL6y9vGBheUC8prQ8YeH9X39OVQSc7Mc6fCaKvAeHdCIVf4yMYCynTpX+nb97NJmlSQb8r8DQHm9YOFUZTKOzoXGhs6AxF0HIexcLBvWBuiHN8s2ne98R3qc6L4Vyb2oBVjfm9MIFHbjDCh6kPOBbQoG+oW8CO5bWVl6wsDwgfr20PGHh/X/1iaEIuDcCTIW/1Q4rFv8OnYiW3c+W2iKwUjKbyjQNwL1uuR6sAEgDgq1brXOmV81PxhNB6DUDBSYzQJwFtz623XcktX1Q1VWKaTF/zZhVazBVYA1tX5MazsGvobwe/jQr0Ne6BTh5uf/ygoXlAfG60vKEhff/rSe1i4DnTWDUACY1guFTDqLYdCBvf6DJYSMYATBfOx1kLfj1v1axH10nQ3Sd0GUkBnTfpemtBJgseIKQAHLQcVxa2TnuMW0Aqui5es8xBIegVdVVE8VhzHnLh65WMB9An+X18K6aAn2tO4ETl6vqbKuVFywsDwhevqg8YeH93/Rk70JE90nowxZbIJjvS3WYNSGUwGHJTpPxwwcbBuBrgRYBeKACn7VtpdUu/c0NJxO9BIxcKu4TTODzbkonPLoaL0vyUQRb2y8HsL1ckfWzMeuFi40Qezqi+yiPhyt7FOjr6/gCFwgP7Xb5vssTFt7/nQRg6MGRWmDRoeyTlpgw68GRTwgZgo1gGmXAX6/8dtaylSKY/koyID9BhzML3q1gAos2AcOrZYSoq/pJp1VtODRm9Z3LS/7WjVkvXOzEtOpKyGrlAT+4SoG+VY8vBGCvy/dVnrDw/vee65NBJiAjBIVcAJQjOm+DkCZEeiGAMw6sAwDZsJrAdhFM9rPGhd4904Co5oVuCZPV6kD40Ec6+9W8dBTBsfdc3nkpvnB82fp2RPcs79dHgb51LA9ofsDV6vut5/3PnxcAmLVBiDqgevDaJLkYrpuQxzcNwN8AWgIgRbB8loEBzXDwl4cGiDGft58SCOWGedgjvOJ+bPvgRkiuA+ZjzhnQQOiFNVbloa7l/fos0LdO5QENgEXlCfs8Qbf7HyMA3QVjYihYhLENgjX9y/qwxQmRU/asfd0ZcLU2CHVGyusJQLKfVi98CS12T5f7iECkHpsMkAhCF8+nshWH2I/jXsOYO144GV/9ApAIrS3vt4YCfetQHtAA2G+/4PW4/2PPbzMgmUMi2NoeSCRxIt2/FvuxWURIWCXg357gfTjEDNIHnTRXRCpH5ugKwGl3HpMBXQc0v6WLYVm/5limj04rG762K2uYY9jBkr9+rI03NL5ZbczS/dJ+LQyoga4o77fGAn0NlwdMAOy3vl/T938KAcj121z8Bn+Y9eWQJRz8Y6kNagDh2ey5EvxjxQD8TWdAuneCCO4An1vw5vdzQMmdktwq7pLZQR+dM34+ZumAxvY1Y04uqOAJ6FsExzeto7zfAAX6GiwPaLWR1lrfr8n7f/Rl3QGzmsis+/uO71V9OFgP2gpPhgr7TGRqRUT6dyvr4aIs/pm/2zVUNbBSv6G8e5pEv0Cvec7Po7+bTtjlBRlkvAMBkDeQyvsNWKCvofKACYBrre/X1P0/oWEAnnFD1YdjhtXxR73mX10FfCHHE9pVWcGAI/S0gKsfA2y+twrFZw6Hxf/F0Pk8Ri/kpGSnMuDx5T0iACgQHioo0NdAecBUHW6QdsV2/cL7v/Cyqr5gnc42CCOcfX1VIZ/V8We9IDmTzVXwPDJiXuKXPxtDBma8+lzP4WAgKkPxCUAPE4v5GzEuMX0PYJPLhB6FJsc7MAMmkVxaYC/K9gG+F1++8AQ7Gwbgk78I7GFpXgIwFiRXOwaJZPUbiR0yCUDRk+cHf+YpwMj9HgfI8ClGPyvsSiH0WSKRuYlitLb/zHM/JOSs5C/YIC9cMQDZr/dwxgOW9gtGYUBi0wA8l304vDQvAchilFbpIBQhZ7Ejq6ZQ0/Yhil8y4j89Axie9DAsD6FX9HOK3QtROTFkviN83kG4felIY8DCeLrSeMDSfsEovAECUFsTjHD+tcB+tkFgcXKvBRir7qtFl9owmO4Xy/1G3bAFfPrZHorFNWBFwHjQAFctIghj2kBarw06If/+MM9ZqTN6DgsDojCerjQesLRfMApvoGkAWh8Ob/tgAPSKWCp8ngNQtadjmTdltvNvn3peFYhgQQgh+iUmEaUAUoXM1yRLmWuFLaE9Z+XIAWBhPF1pPGBpv2AU3kDTALzwmqo6qtVh9kJErAudABia38TC5wJgS2xIhAwBn3yhByL4EhzXfRXxYsDTJ4IvrNN2JFMxZcBzVo4cABbG05XGA5b2C0bhDTQNQLZBYH1AVsQSAAU+imI1obHyblnjG/kJk3U8BHz8xVUQAhnQIl5CyNgKAGp5LKSSCoAySh5Jj79vTagcxUaIBeRNe79g9gq+DXig4wGzy+PONfT7RWFA4noAkGXZVAhcBckJQgNgrLiaNb3paIDo1vHHX+oA9LQBi4DxJcOUPJUnTgU2NJUyROs8irGARxQAC+PpCtsFd40H/AEf0gMQkLgeACT41PiGoLOKqyrJq3K/Ya9mNyr5FusN/uPLPIeDa8Bc+w3rtyl4VFHaMZc3i9RWBM9jjzgAFsbTFbYLRmm/YBTeQNMAtD4cBKDXBTQGdAB2MGBo8SCLmEuS1AFVAJ3A/NhPt0PoCcA8bSDG76XI7aySg6JYuGfKwJHFgH0E5B3ueMCe/Y4L+xVHAOZ+9EHcEgQgwbeiEYx6jwTdz4qfu7EhEJqxGqruf/RnHIAEnxgwBM0aC8aUAYWNBRCmoIll4HTqO122QcZbrgMWxtMVtgvuOx6wa7/jwhtoGoDWh4MBJ16WN4lfr8AqI0TVV1O1fa9BbQzovkAy4Ed+NgCQUSxZCFWvCOaOFREXyUwZOPIA2GdA3uGOB6wPaOz+QPv5S+MA3OXiN9aclghW+d3IgupBF2pPqxcxGenDPxfSRh2ASiKKiVP2PaZScvAKoA0VDc6cOlIB2GdA3uGOB1zR77iwX/F6AFB9ONSOQW0frA50sILVcckWJyIDSgwPAVcJgFbYuZ3FJvAlEHbJ3IsgJLGedeBIA+AAAXmHOx6wo99xYb/i9QKg2iAIfDJEJHqj4SExbEty0gkdhB/6P9oZbBZIGiKYVb9GKaN50lRHBLOvhDxh/5EKwDUG5B3ueMB2QGM/grb7/6wHAPNGMAY+GSGUjC52VX2f2CD4+HO0gqkZfegXKgBaHkcWtS0AWii9xG1ImrLlN5XR8L8fmQD05BVrmEENmpYSP9QX+KHiqj2/82+HqqDWwnbBRfGATdzAegGwru2DpRq7Mzq2fpAf0Nq0Rl2wBXzglZ4yUAPAmDSVWDBPHQjLcgTqOZ6zUvdKHh4ruDCerox/Dnu7YqwXAC1NI/QcEQuK6WK/kdgCTGC0PYAP/KIDMBgglq+hIkrOfsaCviLSofcJgJ5AdM7kkSaCj/HqQKVIGvD4swF8bcBjmzjsaQ2H5D/6acBd9wALB4DFWWB5AVherMp4GKIYEOp7+26UF0aSfT/xYuDG7wDjrIpAERytXf2vajj7ueryQXSFl10K/ON3gIWDwCLvjfGB8Z54O+Ee4ve6513uB2R1yzsqC+twbC8HcNVhfAeaBuDP/TvwtS3A/ePAIfYFVlPq2HHTuyulZCTlhbjhETF5yxTQGgPGhoHhIWC4VSXGD3n0tLkMHXHxu+YyB+MlPwDuZs5K6FlsbCzdVO9DuKfkHM8AEkP7B8fOkwDcD+B7np42+JkGOvKdAL4E4K8P0zvQdET0b14D3DgB3D0B7B8HZka9WzrD88N6sFm+YcUjrn7E1ZDvMtF9DBgeAYaHgSGB0PNHCD4BLwLRsByAyX/ij0/dDUxuqlIG5hix7eFhvLcOVUAtyPSydAFmOQNe6EYGV/9ZESiKgIEgtbaD/gHALQC4ovY5r5KwtjOU/XfTAHzzLuCmIeDuMWDvKHBwpMoN0WQzNtAaYSs0K4ZlOSAjGG9kPjCBRwZ0ABKEBJexYAZEAU3A7Oi1BeDym4EDnjQ1TwCGWMW8MXcKks0YOyZNlQOQjcgYIUHllEzYQ0ktm+r6oz8G4F4AXwXwRd8/kO9A0wB8y65KmPxgGJgcqYJTKYpTv2CCzyddQJRDOjKivn+Deh8BF8BnwBtaCUA+YYEyAU8h+c6Az9gNHHRmrgOgmDA3jHQ+iWupCeUAvNSrA9HNwqx+muk9nJVNg/CTfrmbAPwbgK8D+PcHkIibjob5o13A3XypWsAkG1cPA9PDFQDZM1id0i1KxsWfOrKnAFXlifCFFMMRcASigOcs2MGAIfE9iWXplS6On7UbmPaUUTXQrgsVMzcRj5Folg2V5ayUA5BWYKwOxKUafnosWjcJwk+7W5F2EKvlE3xcXaNYfiCYsGkA/smuqug6hcleAnAImPbO6YwRpMgjCAVAm/yQmKTv5hNsAf/i7SyNBSl2a8Qv/4/M1yF+BZSYlNQCnnVrpbC+mToAACAASURBVJcaI7sOSEY2NpaDXLqpR+vE/OVksDgImgGgghHoYJbTWc7oJtFWc65/cg2AYvh2ALsB3AzgVv95nS/f4QdsIkT9T3cBrGtITWZfC5hqtQHInsEGQn3UDDvEDEY/ICf7SxMOrAg8T+c00JGkvHGd2DABUYZIAONzCUDppCFhSukCBsLQrFtZe/IixYQpSyEoJoqnuPWrVRAubQh83HNlZB23z7j1ywmj6CIIqUPxw2Xeu9bx2jx10wz4Z7sqTYZaDD8EIDuoE3hMVEphWg66JIp90k0sBxBcy+iPIIaT1RtEsHS/yIAqw+VSNPWQfe5tlVEk8auXgVa5BUsEJuT5uoliAbE5AGotmIAjCPnR9xDG3TQernYAUupTdBGEFMf83OkApHG+XlvTAPwfuyrgSZOhas3u6cwTsUBVn2gTwyFMi8wjHZAA1M9fYGHDULJD1m8Cpa8fRxDad+l+Ykf/3XNvd11U+qiL39SxXevSsshdDFvgbI1O2AwAtRZMZzTBRuDFjxe1Xg8QEIB8yyj5yYIUxfQIkfkIRnmHCM712JoG4FsdgHHp3ACoMH2G6jM4lWzoQarSvwQ6MSB/vporVaFkh+mCLlpVR8Z+dqDZLoDOpHSiQeAFDkBjPrlgCHgCUaFifg67H/9uYjn4Ai1vpTERTAASBaoQJBAKeNqHlL6mwPDZYAOROag/EYRkPX34MwHIvzW9rQcA+TLpI22G7EcQKlJGsYIJhC6ClUMiXfBTbFUQAej6nPS/OuAl9pOOqIc2BLzg++3VmWgIEUz82cRuCAtLIHQQm0gO52uOAb22sC3JEWgRfPpZf2sQBQIgLydPEIFGwPEj8MlF2bSbsulghLftqsCXq9HGgHysznrGgi5qzTUTFH8FLhAUn3hIJwCN0HLncw37qaF2zoYvuKNivmQIuUNc7GvWt6sHNs26twA6vhyq8NEMAHlyntFrDCcQehyaPTl+FwAbXDcmAKMRThakEk8Q8kPg8SPL0qzLBl+A9QCgR6uZGs3vfHz8TtBZvkgGQrEPBVAUg2Sij50QAOjiVKI3saADJRm7dSLYWfSFDkCem/dhZeMy9pPY5QvSDYQyUJoDIK8qMezh3wY6fSL49PcGgCAA8pScJLIgAUYQEmz8RPA17StvGoBv39W24eREiBoNQSgWNI1HBkdgxJSw1AI+dFIbgOYmkjimQ1r6XXC3rAbCHycAgytohf8vsB/r2KRaRq7zpZ+D37HMX0s3DDcCUGLYaw53MJ4YUODzusqlGCQAOQCejuxA8UULUkxIwAmMAp8Wa3qkN/R9W+sBwOhIEPjk5SLr8HeKFbTQfb77csPIMHGl/4MPbReslPhNe4+MiTpi9AFGV4nI7MfvagNQLh/pfrYnDAS8aJQ42A2w4em2cAyWQUuJVQTGWLs1uL7DG9J1RjhA+jvYk4t3KXeMqijpzrud4At9z3XtP16yGfjKZmCGooYh1tZzvv8xXPFl4PoJYC97k9FlwZWD+Azi/deMZWeP13eQCGEyoERudChIjbb3mJYwH7V0QIKuCwj/gfMj0asn2I0FXRSHXfL/iRkNgLyeVj8ccMY//J1fyxzTAXT2+xoQViKYD/1hDqLxPiYxTgSvQrphphG97tz4Slqafnj7uk1kIQDZrvWTw8B3jwEW+RLxPgSiCERdPwPR7+wCPg/gulFgfruDkOMQkFc5x84e708JAMmCuRNBXi4TIg5CGRzGiBGE/D4E/C2r2vcAYJoify62i0aJSMhB+2IHoNwu0fkcjQ85pu3ack5nIBREqneYFyWLkAXIJHESe00Cyx5QyeL6F/tyEcDcrOW2n7fX8df0mME+/vQ/PQjhoy3gzo3AISYf80MQaQx1peH9wb7v2mrtmCBkIMMejp3jIJD1MsaxaMZ8v5N/67INAsB3BAYU4JL4DSo1J15AFPAEwuQHZJzkKfUAtOHLJSOQRWndBYQvCQA01cfnNopfsaCJaD2baBn79QjSTiOEP1EcawIpkq2kegBTNgHWEpOKF8Uwq2NRFPM4AqCf46/rA2U9/uVDvurB01zvAJpiiwOl3fEeciCGF+Ij11f+QkbSfMPfIzqw57mEFZ9Dl3Ps5HXWAYByHJAJKV7N+s0cCQQhwSlfm4lGZ0KB8C/rABgZUS6ZHITBSEhCowUYAAksF7cStWREyxRwtuPpOlgw+5s9sq6OaIJIIlUgEhA1edoTgHxa9HVw5jibZNF+j/9yGQA/7pbujZ4bwv2+cWB6tFo0NzYnkxFA+cvEAo43VBoEo2e+48EMXEOmD9F6xhCE8RwZEJ80VblKvDlmzwicfqy93/o+8K8TwB2jVSgW138FrJQTXBNlnJgmrjZwanow9CBP/rL9wF0jwAGWDtFyoN9PHutnIHT05mPXz93dMGQAPniJsjiBXiTbxDZFMF9NLUPQxKR5qezz1Y6/YZDH0D6GkdAkYJIvRalAdHAMmPZoYhb6NhDWvEyf/ma737CXN7R1ZC7hUbPgcFgqt/ZZjADnM1xqEVhYBpb4CUk5UsL7jQvj///5buDrLeCOEeD+YQchYwG9VIfyg1NaZszFiCH6DkRGLze5/dgk8IMWcMCjdCiCzR8od1B8OTwvJM8JEShFut1fzMhi+eRJr6LI7hYP2M/xVLwKNoZjUTwRMAQQmYyhWGQxsSADOflZ4kukj7PhZ75bETjBpkAGahMkcrGgwhsXeCyBHBj1wmOBQwvAwqKzoFeRV8ZaerjKYAuirmPY/o9X7q5Cyr7fAvYMAftCPGAEoYlBiVtFwLjtp2U4irj7yOANbi+crHyrfCbTquJV44O0F1FrwQGIMZFqdQDyP/gGSZ8TC0ZRRsOlVzzgasd/u+zpMByLehAfCgMQCDyGZJHFCCgLZ2f8mgI5qauEcVx9e5vACTgCTwEMWr5TdIpWKJb5MvrnoocDswvAPAG4VLGg6UKeqmi4iuDz4er30oX0FP7u5moMvIf7W8B+jwlUNAzFnlZCIhvGFRCeWzrgXSSIBreXTFZSgVLHAp4UHOFuociEEsn2PJwl/XEk0dzfSojeerFg1IOo5BKAveIBex1P67lgUzgWQaJwLAKRH04i14ItgDKEtGsRnWx49b2Vkk9wUefTGrKCF7R0JxZMqxN8cmPAxWcAcxGABKEAKPA5u9lEaAbCmKMI+sDN1X3z+ro24wEZFc0VEE64ABgT180PF9ZdBcDb6JpqcPtPk+1ACbmKjJnllwyuILunEAWjZHkBsrsRUnfD0qEiC5IJfyisgMhzWhcP2O14Ro4WbASgAMQJ48SJwchmBCDFa8qpyBbSP7OvU4PQ0p2W7+LSnSJUFOrI4V7w5IoBTQQTfJ6oTSYk2mQcpGRyH2syGjIF6EM3V/fM++C1CfwUExhCsmzCaQT43lZC3e1hBpEHh36XEqrB7Scmq5dV0XZxmV8WuDFzAF9iwhow9seAGoBcGtKjqAc+1l9rLb/1igesO55ysmCrC8ei6IxRMAKTWNBi6Xw98xNTFUi0jEcmpYgRAPhddpVi9OIEPP5cYD4CcLkCooHPwaW9kV+iwWrQHT8uA1fd3F7DFvgUHUP2k8jTiogAqLoxFpDgbMj9jXSuN7i9dLIdaxzBp5XVBMIMgFEnFAPKT9qPd6A9BIGI7MfPmf4U+40HzI8nWgq2PBxL4FEkjKJixGRRFyQQPzzd1iAUzCAQas1YOmAEoFjwkecDC/PAwhKw6CxIkCXwOdVJLxTobMjBdyIgfvimNvNJ7Evf4jWtdnRYD1YNGVuG93VWuWs4Jf+mlZCCZxwP/cnJ6mXVKk2+tK8lQQVHRTGc64SDAZB3Ey3JcxyACkToJx4wHl+YwqloGDICmYmTFgMQFBET8yyYzyAG/AfWX8mCGQg0BTRoHwt9KVaPE/HQ890AIfgWK+CRAaMRYnVdxHbhdY8Wslw1V93UDsmPIj9GxgiAioRRMIJNvoti+SW/Ikd0gwAU8+XxJcbGITJPDvI6XdCFREFSknTB83xka40H1PGF9dnycCxFwygkK0bASJQSVAbAYeD98xUAe5U3jKIwBosSgNsuABYogl3/IwgFPrOIg1Xc4ZrpAsSrvruykl2ucykapkMMh4CExD5DwJfWAYAxwk4MKPAJgOIjGSEGwuCakRhemw6Yv0UUwRf7L00L9pnsNx6Qx4feY4O8pDEcixOjsoTKKpMYjSFYYjOC8Eq3Wnnr0YYS+0Tmi2HysrPGLqwASNYzBnT2Mz2QD91laxLB0gs12GAh81cf/o/OcHyJ+qj0S/zxnhUZbSyYWaL8+Rq2S29wowiWkJPan4MvgrDDGAlRe7KIywDIgR3meEDWg9HbJgApNTkXo8o0i7oVgxnEgFr8F7jEdnU5GvqfJQKQKyEOPlsNIQvyvupAGHS/Okv4qv9oh+PHxMLk8ggBCRxvAmEN+AiEzz2iQfQBeNmkh4K52hJBKOaNe/FSLobLRXCz43rQnu2yi9oMSMDxs2jo8303ERz1wsCGZECF4kd3DwEYYwJjhoNlQrgIjlYodbBPrwMAZfEmyzcIv27gs6XDzC/IR1DOgA9a6DRz4wZAsZ+LYXvQYsHoD4ziOFklna6YD3+nnU6dZ7bGDAcBUImIAmEUw/zbJ1i/scGNDJiLXmle3RhQ+l/aq57gUQCWzwwBKPeLsZ/LFrGg/ShRXAe64Ajkv30kALAjF8R11Dy3K7KRwJcsUTaqWScARou3w/INVnCH+A36n8RvM3nB5XP4oD6DATBYwGb5ajlOLOh6X8JaBKRG77+7ygGYp1bn+V25/01AzBnwQ1ypanD7KWfA1QDYC3zJIj7KgOUzc9nFbetX/r+O5biwNhyX5uSEDr5o0xsJwLp8/m4A7GaJUv/j3/5+HQFYJ3oFPPkho/hNeqBcMkcB2BAA6XrxmMBkfFAci/m0JpwzXw0TXvXtzrz+PKc/Ml/ugzM9MDqCAbz/keVjjGcQA/YLvjoguo1mRslRI6RwfsiA5nqhL5D6nscF8gfTdfxpS+/hLzvWfzMQCoB1Fq/8b3VWaPIDZqsRV64DALsZHVHs1gEvsqFAeBSApQC8pHK90Oql4UEAyvCwNeGcBXNLOPMLftgZsI75ouUr9ousp2TEyIJ/sU4AzC1e+WIFshyAHPZREVwItrrD3wGAhibTYBhxVpe/xePyrNBuWaoNp3DgFwC81O+RAepK/a5Lfe51jxr7JwA83nPXYgq1asl0yX5N48+f4VEGLATlK1vAo5YB1gBSRmsM+NFE57lcfPD5pPFWCJImtyvGgGfOAacBYO59zFglgHgPefZsXV6/gPXBYeC0RVgyJNOGYuJjPka9eHWgjL9bWzhWk0/n/wPn+k8bgFNmgYcsVflZnBRmIShtJM/m7JGibGBoOIIez9wKPP4AcNpylfbNlGfdI+9NjBjz8JVzppckZuJ+dBw4aQ44drk6j1LIY9JkPD7P4s2lwVEGLHwJnncscNIh4Nh5YMsSsHm5ndOu1BGFThJ8/K6JrZtoslST2+XHA6ftB05ZAE5crgAups5TfaL6EF+UyIif3gAcOwtsXep82eIYY9JkXpMgMp/AeZQBC2b8OduBYw8C2+aALQvARgJwGZhY7swEzbNa88IRvAVO1qkF91J36DNOBE7eD2yfB45fqphLnevzdGeBKBfL8UX5/CZgyyyweRHYsFwxYHzRNK6oetSBMDLjUQAWTPqPngpsnQK2zgKbCMAlYMMSME4ALrcnR6JYQIwsoUnjpDRstOLy7cBJB4CHUGwuAtuW2nUDVH1EFUhycSwWjGD64mZg0xywcaECoI0z5P3X5P6nWlHdgHgUgAUAfOYOYMtBYNMssHEe2LgITBCADkIzSJZXpCOnIg25uPrhgnupO/TyhwLHHwSOmwW2LVSik2pCrDsQskzNIBGIpBdGI+VfNgMb5oENCxX4yPRjPj4xaJ0+WGeEHRXBDUz2Mx4FbDoIbJypADixUAFwzAFI8KUJChMV2SUaAGc1cE/xFJef3FYRti64nkqWDrqqEhbrsm5zvZCdPCd8nHzJOLZuABRz9hTHZwPL7LnLnoNMIY2VyaKcjtZLHOAbNgNPngKe4BacfGF1pnydD+hphQ/8XV5UiEueLGnDN1tWXj/3/4cTwAUzwGPcRcFJiDpPt3FLmf5vjwE2HAQ2zPrEzDv7OQg5OSM+ScYQy5Xbo8465u/ZfLTJ7fKHAdumKxVh8wKwealSE6inEoSy2MWCdbUHIghv3AqMzwHji9VLZuDzD8cXxxWZs5c7apmW0fMBnIHKn5X7d6I5npvRz94O7LgXuGIReJSb+Xl1tzqflybwRwqf9i97BQRWomWJQ7oZVFtJoqDX/b/oGODsvcBTATB9gsfGqmzdjtVz+G+PAyamgYmZCoDjFE2anCVg1CeJwOMnTRB/DmUINVkkgia3y08BtkwDW+YqAFJFMD1VAAw6XG61R31O9/fdrcDYPDDmY0zjc1UjivBuAMx1QdMB+WAYXU8dhEU16dOSkppbcHFSrng8MHwnsGMPcN5ypURHp2xMIa7zDz2z8Gn/kVe0YomO0wEwBYKujL7v/zHA6C3AxfOVh58g5AsZxx4fZM7sf3h6BcDxWWeGBZ+cMEFiwGEHHRnDzun7ONHs/djkRgBunql0VDOSHIDU3cxSD4aEajhFXS4H4S1bgVGN0V8we7E0Fh9jVDG6Obr1LJMRwn+kOCaTEYT0dsfqZHXl/p7PrLi9wIY7gO0H2yAgCAWCWCowKrYE8nMLn/a7PQn9X7zIJPPkCcK+758y7x7guNsB6l98gZjLLYet3Ay5n0sv4R+fCYxPA2MOwLEAQLIDPyP8uBg2cRYmzFweAYilKkn+OC8/Fdh0CNhEA4nGA40kd6FES13WLO8v1qHKAfh9B+DoYjU2Ak/js/8NAIwg7OUb7LCC+WAfB4CpBJoIiTRNRmS1l13kqWh3Adv2A8cdqqp1MB+aIOSxWv6pq5D2kkIAvt8rF7BLJksN/jMqfa7v+7/Ak4B3A6ceqpasKMq5akAmlLWY37t8ZW97PDB2qALg2BxgAFwANEGcnI5JcrDZRPlkaXL4u1KJUAfAjbTQ59x6dSvdLPXAgGYshZWR6JIRaXB/NwFI8C1WwLMXzMeSwLfcXuKrA2G+wrLCDcN/IIg4ERRn0qvyySAQX6mG1XuA4fuAbTOVwktRRr2MLCoQyvEZ/UY/WwjAj3jtFJZkU79g1ghkgEBf98+0Umb/3A2M3lkBl/fOcdMok2EjkZyv8773LAfgHDDKjwNwxEUw9yailpwdxBAEYhBbAuGzG3aKkQEJwAkCkOCjlb7Y6SYyf2UwlAS+vKYnAXjfNmDEX7DEfA5CjUcsnzvbu1nDtUMmCDkRZEEyGdlAk6G6lQTSa6m0MP6HuY73AxNTlcJLZ6WOJYC5/CNxLpHMgdKIKNl69Qvu6/75AjHOiTU87gKOOViJb748BKCWrnK/maTA+58AjM0Ao7PA6Lx/xBAupoYDC9okBRAmPdBZ47lNA/DhwMRsxX7mPgl+SrmK5EaRNRslXFQ9CKB9DkADn79cZtkHFkysJ103eBbqlh97DpmTQTYgk9VNxu+xYbXKU3lhFoJPOgdFGY+lPkgQxokkgF9Xgj4AvfoFs84eX4Ke9x9fIC+tRfDxvvniif358sSir2LCj5wNjBKAc8CIi2AxxLCzIAGY9L7AhGIKgpATw4l8wToB0JjPrfTkp+SLQbHrOqm5jNyajS6VCMIpApDAWwQ4LrGgXqzIfnq5cv0vN0ZXHTInME5GBNLb1DGdOYQsI7AfGKFjlgqve8wJwG4T+fuFAFytXzCLb+VgWnH/fIGYfc46Hs7iHC8ZkPcdXx4VfVXJw8+cA4wIgM6AHSLKWZCTESfLfg7WsIyRF3ckiRQ+HACXkwHptyP4KHrpJvKVGnOhRF9eBF9wE0mUEogz2wC+WGI/vVxiQQIxAs9+rmHA6E1YFYB8DJwQMZl0OrLZ++i7sfT8zroYHLS9df4RACWKxSZvLXzG/fQLZqk2gqn2/vUCUQ9UZaM9wDaPeSPrC4A5C1KV+NITKwCS/SiCR/jRBDlLmP7nHynsxno1IPwJSyRpbiMADXzuPDYfZfBTEoAmcuVQdiaW0zwXwQsCYDYmMaDA1wG8TBSvaoR0G77EcGSET6hjOvVApfRPAUN0zjr45JzVcSqiTxD+VeGzXku/4Nr7JwDJOkxFIwt6j6+RqUrlkO4bXzp1gCAAv04AzgLDDsBhKugLFUvQUhTwCEKbnKCw14HwJ9cDgGQ9WegRgDI8XEcVEDvAl7lVlglAgi+I4CR+Zf1mLGgMmDFhBGFfDCicRJFERviSABjLS7FC0MFKMU+07wOPE0kGvaoQgGvtF9z1/iODkwn3VWoEXxres5ib9xx1wZufBAwLgAQexbAD0JiQwJOuJBA68/H3Zhk6+3CifqqwWNMKN8wjKgbk6gWJgC+FMaBb5vJVmsUbV2vCqo3cRWZcCIACoax53+ulkqNd7iqOcU1WcC9cxEm5kQBUdZ+sTnSL/jEtTWngi21jhJNJBivZBukXvOL+yYBkcOqxKjJ4AGgxzMrBVwdAMmHrZOAYF2l6y/mwV6xD17zmWo6MbRyeWtOHwxJ91IIhr6rqZS70DPPLXDVUrfBwzHKr1EUp6/h0T/6L/GcCqslt4IhoTcwdAqDSs7I60WQH6R329pHuFyuXDJmEjuOSbdB+wSvuP5bGUjmsA5XoUvcvBXKKAQnApUdXwah0b8jXR2YzJTsC0ZHB33FL+2yiX3h/1YeD1fFZGT81g/H6yqkVa9YEpqMhTADle8erHA6t7Mh6j4ZBXdBGjFyO4CSIm9wGBiBvgqxwIAJQlXIyEJLyI/i0SkAG/FbhaEr6BXfcv+5dLKhCg4z1C1HEBJ8+BODQGZXfk/quAZC6ketAZEQCTWAU8PIJt0fgwHzZvVWNaKqi7JLOmtDWFy42g1FxH/XfqGkII0C+a0tnDkfsGxQjn3VPsk7tXmuy+Xp0JhtoJosAaFcUAJUYKiYJxcqHqKAH9rPlG2cMrmCUbMX9guMLpGTcCMKDlZGhMK8IPnPIn1X5PA2AwegwEEYmDGBMjOI5whGQP3NPBT7VJlRNaKvF4t2IWHbDErtDlSk1p4lJ7/zd246tglGZryIfrFhQ7pU8WCAX0ZENG+57U14Z4YrCeLrSxXdev6TfLwrbxT7znMrfKQXfHLQCnyvmRIv0Q3430ezMmL98P393G3wqz6am1NYzzoGn+svqRmTAU2citctqAX/2EI8F9ACEmLHXLZGoFxtSl2xyK2bAYwrj6Xr12+1noL/jUTCD9vvFrn6u0v1/nvGkaoVBAQi0eummMAuXQHMWJAA7gCixG8U0gFfcXdlBKk4Z6zELgAJfZEKrxpC1xOIl/+Sk7jkcdYlSco90y9+gK6vJrRiADD0piad7RuFo3udNCgft94vCdrGXn+tujgV3QAcHLcFnroelivHkchEL8ue0uQ74S3eubAITS3IQhKkMRjBMokgWG3L//2z3VSnP4VDgQWxUEEUxAZFHL0eR3HDfm3IRbDHkBfF0zy4EIKNhSvr9goGEBdvTz/MIYQLQdVsTwRTFDj5jQmdArRDYJQNDSs961R3tPhx5NXoVgoxleHnarjohgLec3D2HI492yQNvIwvqO9fJm9zKGbAwnu6FhaP5pFuMg/b7tTbpBdvTz68cz/zI8azVj8iAHTqgmFHXDUB89R2dtaC7tUGw4kDOgFb0R2wYRDGZ8g9O8aU4XwPOczhiwGlMjqqLWiFYGu570wADFsbTvaxg8nkow7E8nM/atfKzln6/1mS4YHv6BQ4+Z0BbqHcd0NwwYbVD3+1yWhXJxPBrbq8AqE/XApSqAxiBV2MZ/54DMOZwKE00rnDUWcR5KiV/brjtSAMALIyn+/mCyeehjIYp6fdrvVELth8RAClyHXxmhPi6r1m8FM0ucgk8+y4RHC1kAK/5XgW+2hZYofafWcPq1B5AqDqEYsQ3nepR2gqhV2yiol1COkD0C+aOaoGx4aL7DQCwMJ7uVwomn4fm7VrX2u/XAlELth+5sHPtN+l/Ap6sX2dCsZ/phZkIJgv9l++1wbcq+2WFv2NXIjNKAPzuw7MUAV8DTuynFIEsQy83RgTAhiv+NgBABaQOGE/3mwWTLwAqHnaQfr9GnwUbARgDNBUlkpzQboyYCyYDYdILdf0l4NduW9kGoa4geNdazLElKoA3Prx7DofiETtC6XvE7hGEzJlpcis3Qgrj6d5UOJoYDcMglrX2+y0NPtl5UZUjkfx/Hqbecoe0OZzdF1gHQrln9Bhee4s3f3Zxm4MvAk9VSFdUIw0i+Q2PaBtISiBSSFgCYMjMW00MP7pwvvLDmwFgQTzdHxcOSGvBg/b7ZRZByWYAlOERluKM3Ra9CKWc0q73dTBhMFT4ZwIw9l5Lrpes+HjeBiGCUOKXeuBvPcKTiEIOR0f+RhDBMYi0Lhea4GTaa5NbOQAVDzhgPB1La5RssV3rIP1+7yy5OAADoAchEHBkFbKfGRpiweAPtMs5IFNokyOGk/7rAYC9OhBFwNXVY1at5tftCBHaWVS2AJdEcEinrDNC+Lumiyc1B8AB4+muLARAXTDCWvr93lR4/Z0Xt6ODFQkj8WtumEwHTKDLQejAfN3uds/dfjoQdatGLxb8jQBAYz6/boxiFgAVudzNIc2/s3xLk1szAORoB4yn+2DhaATAGJCtbpkCYq9+v4V+aBgAQ4i66XtaC85YkDog/zdZvzUgfN1N7a633Xqv6fe9msDIHfNaB6Ay2JRE1AHAEDIfI5nzZCLeN4Nbm9yaA+CA8XSsul6yqV0rJ2WQfr+splCyCYBR/HJyKX4phs0PKBZ0lqOYTpvniAiUAmAd+HKjo1cvDjHgr+3wPJQsVCymUZrPMuRsRBDG4AQCsunyJtFGHwAAIABJREFUcc0BUJlxQoH62q8ST8cggpKNAFRGwCD9fkuvbwAkyGgJE3C+Nz1P1q9/T3F1EZBxvZh50s6AEYC5yyUHXt5/Q8zI5/KrAmAIkkipkyGPYwXz1aRT8v5ZO6jJrRyAvKOvNXlLazsXs9bo/ztc29Pohgotp5J49Rcj/pzfIwGS//3OM4CNd1dpntQpFUmjEH4LYIgnyn/OLjL8FeDGhwJbNgFjI8DIEDA8BAy1PFK7FSKf43cNKrvHx+8C/vmxwMgmYHgEaA35J0StpvvzL/nP8RbLAfhyT207TChgDRiu/ZL9DsfWNABvYzbhCDBKoBAk/pEobGWTqp819hzQ1/0k0PoaMDEJbJjxVZFgDad0SaUO5LksWVj+XScDmw5UEUDJ6U4d0nVbC91S3ovfVHp5al64cgC+k7mZAP768KCA0WD3A/ieLz090CDceVmlAuhBljLgrfcAw6PAyDAwPFwBkCAbItM4a/FiNtERjBl76W9ffD2AbwJDdwFj+6syImRXrd5Y2FjIYcnzWPLEqnsfC0zsr6qBMQmfIDR/pyJ6xMhKyMrSDiKD2xja6TADTt0/AGAs1KcAUCFrOLF6tbtiRVFavT/wuMCa7MfVTlH098YBeBcwNAIMEYAUlS4uBULOmK3LCnwOPANlEIOSoF9+C4DvVoWXhvdWZVOYqWgi3vOXDUQhgieB0EElViMYJ08HxqeqnG8D4IIDkAzo51DKQQJvBKUmKACzbM4+5hUivwrgiwC4LzvjmgCh6nBcgiMTcv9Abo0D8E6g5eCjfpUA6AxoQIzgi8ALmWwC4z//DxcPPwBak8DQFDB8yJPpPZHeGCyC0KN5DFCByfh9/+OAsekKgEzCTwD047X0SCPM1IYQjCv2E/MJoGVwUUQoPboq0MdqkWVn7RtDDMahB4g+P6qhXFpjVtkDtRGA2nKjos7IyOyHFUbIrXe0FXsTuzIYfNb4O2M3ATGIYQOmPn6hG6gi3eUkQQAeAIYOAUOzALMVh2pAlESqGFBAXAYOMQVjxll03iO/yYKRAT0FQXkwZkjp1pz51LO2XAT3KtD3AIAwj4Wg05kfiuUHYlsXAJLVnP0INLM0OYFx78AzcRySeTsw2AJueI+Dj2Fne4EWKz5MA0MzDkCCkAByUWqsJzarEanzj2zXwjEGFHuGY+pYsMojzZL1G9EBexXou339IRBrC3lJGmNDuSHX+w7WC4Cm6wWxm8DngLTImgC8pBcGBuTXf/1fXnyTugnFwxTQOgi0CECyIFlsvvJfEnh0mhsYI/s5uxFYi1xZof7oOqSAawwYjRGBzYGXbtWXaCIrlvHUagX6SP/ruMVYCEbEqECXAMjfree2HgA0ESur1/0vtnNwGSsG0RsZME20/+/XWH6Mugk/yngPAGy5GDYALjiIHIgRUIrsZjM7Ax+BSx1S4pfffQVIep8dL7dMDsTGjJB+CvQxTHmdtrw4l0CovFruC2NOe975egDQsCXRK/eK634JhBK90q2C7I1i+Gt0jxF40k1cPJAB7UP2m3MGJAAFQrGei9iUTH9yBUDTHfU3B5+BOIKQ43BWtNtPcWIOzEZE8FoK9K0DCGNxLi3FqaKA9gTgeoFwPQAoI0OulWT11oEwiFz7cwbErzNxWtEYBB+VY76Vh4DWrH8IOoGQ7Ocg1CqMRLPltmxvs1/SHaP4dcAJePYyyUCRIzrTB8tE8FoL9DUMwl61kQQ87Rmy2PS2rgB0a1ci18RudEJH57OsY02y/+83/sZdBKr4FXQTApBvprGgQCg9UEAM+h9F6ugJDkC3gJPBEvRGrYoYCBX9IxEcS5K4i6cZAHIw8oXQ4mLBb35YH5d7OekadtTV1UZSjaEIPH4nQzYNwgjAHNwDuWGYpZc7lzPfX1cQur5oBorfzDf+zi0yVTuSkuxBI2Q+PhQDIUEnMLo1TBCZLufGw/ixbQa0KB8CTODjPohdY78IQmfDjmW7Yo/doAX6GqIiAtDHaYswSmeMubV81kp11L6hy2PdAcgblfslOKC1IiKRmyRxZgV/8++DS8BFrxXi5Hd/U6MeSKdqEsEKhpBRsgRMbAtuG4KU/+9ry5brzP/lPVMv1EPOQegharrVcgZUhVHFxNPcp9VFtlOWkL437C0WABWypFRGsV0sb5Hn2zYBwvUGoKl10v1knDgo0y7XA8Pfv0UACnjaK33Co9gJQAOe64FkNvtZAHQdjz9v2Nz2GSa3jYej2W3KGuZ9ixGdIVSoKT13B2s5AHkGheST6qn0erHv5AIgAAU+LVfw/wq3CEAV7clBKDDGZG9/5oVXx/oyYARczcqH5GyH8eFplTawFvAtrtXLGpNrQDGbejupB3omlIHQGc/ErzOcGSRs8zrhAbbuL1Tco/JfbLlNwHOmi2kIcs3owbdwNpYtynDQhsFcgvuG9/YapGFvYX22zZcAU0/GwA2LJ/4AmGF9mwEbBu98Y3cMF+uAGQCj2HVp3BbPuo3IlqxAy5wHAq4OfARmEBXGfNIBa0BIsG0ecwC67merHgRpZLwocrWaovuTxew/V0txJQ2DWeae3WAGbdhb2DB4+wRw7w5g8Qpv88liyGtoWHzMi4C9fAEHbBi8kwUKu2xNAdBxaGBLbJdZux1LwAGECYAEm6wyfpelJrEgFnRDxESwgyUxIUsVMwjVy5AYO0bG89Auu1/5BF38KqjBHlUAYXsteNCGwTeWNuwtk4JMkrlzGNizA1hm69g1Nix+zDOBW0aBeRZZGqBh8M4emfWNADDT+zqMjQyESdQFHfDbZECCLRgdHeCTe8CBaKJY1rDnBRCIAuGW4TYAZeFG8ZuMkGiQ1IEwGCJtHZBmy1obBsvVMnDD3jIAerti3LEBOMjGcOpa3WfD4ic9t6oveDtLfw7QMHjnH6wPAybW6yaG4+8D4HIQfvtDIVtLejpBFsVvUI7NIBHw3DUjRzL3rDVtsYPOkAScuX3coNDynT2VYJCkn+PjqvUD8hVbS8NgjphGxcANe8sAGNoVY/824BCBtIaGxRe8pLKZdpMkTvXiJ2toGHzSNHDPScAyq3er4qPyGaNc7JCRXWLT2TjwGmCOeQashq6+qSpZmp8vojQpheF58ncdZVjLnjWPHr4VWKTKxrHGUqq97qXu3jp0wPy+eEC/DYNZsZAO6IEb9pY9lNCuGPcNV830ZmkM9dmw+OKfbdcXvJMPdY0Ng0/7GnDXKcDMccBS7MwdKz8KCAKQIgY0MWGCtr4TOHAasMwOkTqf6unyuLykfd254nkb7qsw/iVg7jhgmSX31Vpd9yRHeLx+zRhjEGRbB6wDYT8NdymyubzDzCCGfpMJWfSRYfr9HP/aMgBm7YoxNQHMbQHm+ID6aFh8yS93tAvGQb7da2gYfPoXgbtPAqaPA+a3AEubgGU1RM6B060fgkRoCzj+TcD+04CFE4BldZdRc4/YxlxgjJMewSiwN1zWfsOngdljq3EmY08vm5i/7j5yIMqpvupKyGoNg9lngYosl9wY/0dZdrMzYl8Ne8sAWNOu2MA3zw/F2CoNiy99XbvftrcLriz6PhsGn3U9cM9xMODObQYWCMANwPJ49UliuW6SaqqBn/gGYP8pwPyJwNIxwDK76ahDeN6uXYCuYyABkEza4LbpY5WEWdSLxjF26/dQB0SJ6r4ByAN6NQxmkWcqrnQ00x1DEDJFjR8CcNWGvWVPp6ZdMQ6OVOCb3wAscPJ6NCy+7PerkP5Q3tBY1PrT9tEw+JwbgPu2AlNbgVkCcCOwtAFYcgAuiwWlM/XqDjMEbP9t4MB2YO54YJFMo/5gHIcALV1TRZ17FXOhPtvgtvkqf9H4kvHDlyKK4l6VzvVSBF22uwjOb7pbw+CfcwBSkyeFEHAUx/yw9JTyEbo27C17Ol3aFWNuAlgIn9QxO2tYfNlbK6MvaxeMRYquvL9rTcPgJ30TuH8LcHAzMOugX3QALo21WXBZLEHwRF1OgHS2eOgbgIPHA7PHAezNu7QFWFZ7JnXJ5rnqxHEulvlzwyVNN3+wern5Yovl7SXLGwvn4riLWO4fgMRJXcPd/+pmOymELEhRzBxJAo9gVL4kwVnbsLccgHEpWi3epocCAMeBRU5eTcPiy/6qtl0wpvhA+2gYfO7NwOQm4OBGYGaDs+5ExYDGgqP+ccAkINaVpB8GTv4d4OBxwNw2YGFrxYCmV0YxLNYheCXau7EhV3ga3Lb8g4+R45uoGLADgHWqhsBXA8K1AZADyRvuvtkBSArh+i9DsQhCOtf0UUgW/7aiYW/Z0+nRrhizoxXwFhyAi5y4rGHxU66qAFhT3rDSIVdpGHzencDejcDBDcDsBDBP1uX1CMJRwFiQIBzxieL3KIY1YW5MPOxNwLRb8gs0aghAss1GZ1O+SFHsdRPt0i/PLHu++dFb/x4mXfhcbWxhfCtYMFr/uWvKxfDaAcg7ipPCvFOVpuo3HrCjYW/ZA+rRrti6TS6MVQ+L4NPH2nx698GnXF0BsKa8Iab4dFZpGHz+JLBvApieqAA4J8CPOQuOBBAOV0CUYbIskRkAecrvAdNbXc/aDCxSpyT4CEIyTgRgneiLIp3nP6fs+a4A4N8B8/48CUC+ZGJA29fpuLmxJW+5h5kNFg2jiWHSi0r0Uv4pCoZsxw8DUfnhd4Vk0XGdGvaWPaBV2hVjdjgA0BlpkQ/K9bmn/HOVqtClvKEBqlfD4AtmgP3jDsBxB6DA7tdbcvYzJvQJkii2n4NOeMpbgJktbYPGACiF3wFoEx1ZMNe/4jnPLXu+KwD4t/5SO/iMBcXuesHylyACMBPDgzGg7opM8mEHIGdwrfGA1rC37AH10a64Yr4APvvOSdwEPOVbKxu+K2pdKRTmdI3dqkPPVgbSTBGAY8AsATjWniBdx0QxJylOFCcr6HBiw1P/CDgU3EgEIMW52M8YkLolQRddIN1AyKWiBretf9MJQN6HsaCPxe4rvgDdHOcOxDIAcmDFDXvLnk4f7Yqt63gEIB/Yoj+4p9xaAbBHeUPM8qF2aRh84QQwNQYcGgdmx4C50WqCFngNsgSvQ+Dxu4MuiawhwIAXVk1O+e/A7CZgThY1dcno1nHL2oDIyZULpBsAFTBZ9pjT0QQgn2V6ufRicS8QRgbs5ZYpEsENDejBfpoLrwAOjgIzZMBRZ0AHoUC+SOA56xJwNlEyTFw5FxBPeWvlzpnbANCdQ1eSGTRybMuydgMggVBsKmtYoC6Mt8znZxsZMLzAxoAOvsh+ydDqtXx4FIDl8L/omQ7A0QqA82S/ERdTI22mNfaTuBIIxR4BhKe+y61punQC+MytI/Zz/c9EuvyBeetLAfGZ5WOMZ9j2/gqABB1fMLsHAVBqhfTcyH5d9MByEdzs+B50Z7voGZX+NzNSsd8cwUcG5ASRKYbdHRNYwhhDIHRgGmO0gFP+HJh15jOXjnyKblVT5Cbfoq+yJOszF8P8+VnNPlICkMAzds/YLxlYznrJwIpO6egTPMqA5ZNDAB6iCCYAyYBcBqTRQ0e4630SxZyQJQIvMJ8mSeLrYe+p/GzGfnTpEIBy6US/out+K1wg+brs88rHmDOgAVCMnrEfxxMte1Mt6j7u9zzKgIXzczEBOJIB0BnCJoqgIfDEhM58SWzJEPGJe9hfVH42un/Mfxl9bgSiBySIBWnAJBDGEDAB8QWFA8wO3/a+wH4+rg4RLPYLul8tCI8CsJmJMQAOuwFC9qMI9g9Z0CxhZz65K0wfFBPqu7PEyVdWAOTHVlTcpxhXHZLz1w0ZA6EDLhkCskRf0sw4dRYC0PQ/vVSRAYPo7QCdj7GqVOSMeBSAzUzMxZcDMwLgcKX/zbv45SQlHXDIgagJc+bjZBqAWhUoH/Y+B2D0J7rFa6LYDRmzomsAaOeKqxEvbWacHQB08JkRIteSXiSBLYJOLB+X4xrzAzY7vgfd2S4RAKkDDgPzNEAIxMASSWF38WsgkuXLyXTRSRCe/DduSZMBMwe6ObTd8JBj24Aot07uDObPP9XsIzUGFPs5+JJ/M6oT4buxHv9X7BeY8KgOWDg/Z58GTC9Xq5FxTXOw9c3Cm6k5fPcjgbHbgAlvVG2tH1T3Oavoq6BlniZ+12n5u/2sDbOvasqoFg8x2Lnbcd1GdhSAhXN+7qMrAC4sA8sORJ6yHwD28z+Ft4fdv8UyqUDrDmCEBcpZ39kLS6aq9l4D2rLb/KYsFTPWdfbvh86vQu2s1K/K+zIjTsXIVQ9a59Egs4Y6sZfIA/EcSp/jEXv8BWcAhxaA+SVgSQAkGAMICcwVlNLlqTc9Gbv/HAA7MrL4+f1VlXwrUq7SvCoyGcrrWpGhuur2fNGYwM8YT67hT3s1LaZvqn5MLM0bzmHMmIFSgdFNj/mIBct63NhFZwEzDsBFgpDPeanNgATfCtGsX9TIKwNrg9tuVkhlng7TI/YArX1VkXKrEe1l2SynN1RCsFJsqnQv3UIMxhwIRjU5AGN9QUteVz3BUAvahuNgjC3HxLAND7nBp/cgONXF5wCz8xUDGgCjKPbvevlzcKUHH2ag6cnYzepYBB9Zi2FxDJdjoXJv1WDFiLJ6MKqKZUzoQFTfj2HmwTKcTpVWvcxHKm6kKgoORAEvVclPD6NdzLXpMT8IYNPcLV7yJGB2AVhYrAC4SNA5AxKM9ryDPE5fs6eeVKWGZ2M3S3MQfEyJUKV8L1ZpJXpVJ9pLilmlAxWkVJHKwIhjjD9TtVXVm1HdOy/pJiaMFRWM+bo0rWl4yM1N7oPhTJecC8wRgAttBjQWdBBGESwgSiV0Pb9DRgu0TY19N+M1mRKh8niqFx3rRDsLqjgl9yaGXT80vcL1wnE252PAZCzAHQCoiqoW3yYWFIt664fUpKaREr1NPakH6XkuOQ+YDwy4FMSwgU8GSRSz0UJx3Vx/5vFNbrs/EiLRY+v4ACITww6iJEodQKwBIyBRv9vwhKzUW6z66TUGEwhDS3ezqusAyNxnJn8xa1KRPSFts9YfFB/QDZcAm78CnDBT5U8rCqjfc3yh8Gn/hGd/MsKf1+QzYJ4891Jye13iy1cAE9cDJ+6FpYrEkidxDN3OtXR+FwBGMezoMmxJLOumAuD4J4rxJrfdH/XCoLGFVKiUbw+LAPQqWWaMMLrd6/+JycSIm85w9lOpt1j1MwAwFTiqAWEUxeYH5ENn/jInUVHeMXQ/f/jRePvCa4DhTwLHfBc4frGqqaNJzLPw6iZxV+HTplFGvZrXZT45N39+HW3TujlZv8D6fp8HRq8Dts9XIOR5YtakgBgdrrrt5Qsq8Ssd0BhQ4HMwmVitAWHAY/LbLDQNQDaTVJ8Q6W4qVB51OOqDZDPVB3TLOBepW5jmqaLbec3jGgBGMSxvvemDYkQ9GoKF1ShUCSKCqBeQrvmfVZPC1keBjXcCmw911tTJ8q5XgOLaQgA+x/OdWA2EGZ98gbjleTHdQHQN+2iwls3nK3/Zhj3VeQhovYzdxmArSwQgDRA3QiSCJUrTnjfl4KozRCSCCeYmt90EoJJbVCk/1+FiCwFZxLk4dRfLFia6x8LbYkD9v9cXtLG6+O4AYQRfrgPygVIcqyhTXcWFOJH8fh3rz7EKwnUArq8mcGwK2MCC1i7WY7Zenh56feHT/jE3yliE4TZncd636gPFCKWavGhcRx2J+cvs9MlSw0Ty3cCm+c7n0G0MExdW4BMIbTXE9UCynvyCCX+Ovm4gbByA/xisVgJPpXrzLj4EoRJjJIZrWHArS9iprK+KcefgiyB0XVKGjOmCmW9xhRVMUSyRFnNeFGEdI2q+/HFXclkp9WsAbgTG9wGj08CI64WxRk/OTDcUAvBHXSLQxcVCDMQSWbzv+1e7WVbz+k5w2tJtsbcCYV6WJY7hmAsDA7r1Sz3OgOgoM+KTOJbcjSI5yGIaNE1uuwlAAU/MF+tF5/0sIghVLdVdM2S0bSzHx2Mi+FTxXf8X925NC4BycK8QwfmgVX1LlcFiykEMcL2BndJJ7aQfijKfxLGDwAhByM7aC5U4qwPzNwufNnNuOH4VZaCPlPo2AahqFqoPVFc14ga2m+WEEL0cAz9kdPrOmMu8r1o/rTsXz7f9oswFs+jO6LAqkvC3Ggg5Fg6mwW03CUI6X12h8lyfcz3QHqr3DIl64DbqaQKc9mI87QXACD6vpJqY0EVxz2CEyCI5eMSGX2e7VtI5J4yTRyZhscrvt1nQuivOAaNLlYESwcySgiVbr37Bfd0/u31yEgg2FVaiPCeVOguqAfGov0iR0R9JABJ0bnwk9nMxw+fOh55EbgRhzozrBUA1polN9CLwok5HEEUQBjFMQB7D+j656PW+IrJ8O/bBCo4sGFdGejqiyYCx3mKe9/JtTiBvmI5OFiTisg9LtJFF7gZGDrUbHKs79+hyu5hSaUvh1foFr3r/6vZJCiXgCDwVVFJ7MVmRLsrGltuFCc68yFdACMDAflwR4QM3HPoKgIExt4gz42SuaQb8hBOE2oZmlu+KFlKR3QSssMJxDPWbbjpfLoJrxG8CYT8MKGZSVTCxYFTIb84nkCxCIPLDiby30gXFghaF4c2ReR466Uu2fvoFr3r/fKAEFxvpqMcd9yonIrkuK5LLV7MVCM+/uDJCyIC2J8a0z1iwqyESgMl15Sa33QKgmtPEBnp11mwuXgO70Ud4DHWzfgDYC3zBEOk7HlA6XKyHQzb8HgGoCSQLqsxorIy1Bxie7Wx0rFaf+wr9Xv32C+56/7HbJ5VHtRYT+GJrsehHcya57PyKAQk6+vBkBZPpjPEExlwU59awg3C24W6KBsC6tqHR+MidyVG3i3rdAnAsH2T093XT+zLr197MTA80h3SfsZP2UqpCrPQ46oF317VrpeiKXTJ9MhMLkgGdCacKG/mupV9w1/vnwyGgCDCKWzJe3lqsyzLWZWe6/kc/oKzgKH4jC7oolhdC4jiuzM0WPo+cPQ2AsX1obFCTO5Jzn566PwbReiwnfTWjI4KvDoh1juh+aT+WKSYD3i8Aql2rJk+VsVQly5kkddv2FvHT61icqO7Fr71/IkLNXOi0FQjV0046oBy6wZ922Q95ICqDEaL4XWw3COcf9Mw73DFB9AqE6wZAAS8XuzGQIDKf+oVkqxt00ttAc+YT0PJ9qRFSB8xoye5Xu1ZVeCSgCLbYLVNswoncHxoeLwCzBGjBNki/4BX3z9lXgUCyIIGmhova83cRgO5Te9yLgP3MfmsBS8xs8/U67ePQOqy9umBUruDchqo8sHSd3PMfT5ifo+ack8eFHI6QEcnT5GvdOnVdXof+ptJ+BVPWceiaRHA8Us/nkACo8mzqlqmWrbFDppT5A5UIZm7CPA2Vgm3QfsEd909kKIqB1qJAKCBG8ZstZz3xHOAAiwmpDIdng1maZQAkZzsHZ537YfQrwNyxoQ+HakrnS0h1mUA1C96TdJTmORyhC3oeqdwROi+GDhkFI6bYNrcNDEDeAkXwQizPRpmnIs3OdqZPSaRFUcbchHlgie6agq2kX7Dd/+d8lUJVXuUzk8ERmS+2vfd4uvN2VOV5rSwb0y3JhgIh9wJeN3YMQCIgR78Q+nDEVYBYZUrUpbXFnM7COSdf7N4IPvtDnT2BY/h8Chh10MXQeYGS+7GGjaQiABpuNIFiECnzdWJMIUHcazLptC7YivsF8/7FgLFMqpiQL5TuNbKfA/DC46rqqAbAwIKWK+timRUBEiNGsOQsyQm+Gpjd4n046hbT84KPuYjOmHHyp92gcgDS2OoIuVIeh/xyUkaVwyEWdLrewHE3uBUDcKIwnq40HpDXL+n3CzbaKdguel5VnFJl2awaghLQBTzteZ0cjLq2A2n0M6EPh2pC57Wg41poLzZsAZNso0Hw6eVR/J8bF9YjWGmVCpGKwQLBRCcrbiSxNLgVAxCF8XSl8YDHHFPW7xeFBRwv/rGqOKUBkODzqgdWPYAM53vTASMQu4Bx9J+69OHIF+N71F1O1gUB+AsBfFqKC+4Wi4BWX+CYgOTAU36wdMVNVKka3MoBWBhPxyiuko3xkSX9fvGMkqsDlzzHC1N6SQ4DoINOe7KelWWTheziObeKCdARApD1AdVnRH048gKUAmAEYi6Oh4DJV4VoGDWqjq4XLbO5o1jBoimEPhPJmwu9FvnTLgdgYTwd2wyXbMyRKen3i2eXXB245FlVYUpVxUpGiLtmGBlrTEhVUwV8dEkVKAq3MHJ1uzRbRx+OOgDWFX6MsXJU/36lJoEoA2AKvw8+uwTEDIBbStdOs8ddDsDCeDom7ZdszBIs6fcL9ror2C75US9IxJJsEsHdGFBil4yYuUwknofJgF4XcEUfjrz+X7fKo4EJJ//PkMORO6FrVjQMeL5kJhZMMXzLwNZCt1nzDFgYT8cQwpLt4hDON0i/X7ys5OrAJVe0S/ISgFY7j9ZvnQ7I3+lyqpYaL98CWp/N+nDkZdhi6bW8An1kP3fRTLKVWlwF6RZCH2L4zDDR0k1IqeTNb2OQSYNbOQMWxtMxeqtkY6I+ny9VEz6btfb7xc+XXB249AoXv85+tIBVgJJ6n4lf6oV+mfjdDJNMH0wAVFX90GMk1f5TxlS3Fggh92DyN0IORy5665KIfCktsl+K3VsGtpVOWOMiuDCerlSnjQ2rB+n3C+pIBdulz8wqonrNPLKgwKaC5B3s53qhXVq6oDNg6sOhqvqhEr3V2VNLBjmnSSNdrOLJ1zkAu6VPRjFcFz4fXDJ8i45hG94Gt3IGjOFYA8TTlQZ/qGH1oP1+8ZtlT1MAtHK8mQg25zOZUSCLIliWcbw8wfW5Ln04ssqnHX04euiCk6/3de66MPpuAQVZAEFkw2MKFw6a1wEL4+lSBvmAOMhD8vkOkFX77feLNw14YT/ssmc4A6oOdHBEkwXlgjH2k4Nal6wB4fIuX9LzZjAmorNeHMo5Tc0OewHwDTUh9HXxfGJsYkAbAAAgAElEQVS/uvCpoAcew6zBBrdyBlQwwoDxdLZWXLDFkHyF8xGE/fb7xR8XXByAAVC1oB18HQYIT+8uGfP75SCUs1o64he8v4j6cIQ+IqkPhxrBCHjdjBH6AblQkAeY1ondukSiELmsUPpjbyp7XuvDgAXxdNZVvWCLIfmKg6Bbhrjup98v3lVwcQLw8gqA5v9zC9jErutltg8gMxDWWMBaMVkmANWFyEV6R0uH2I1IzW7ypbkQOTP5f2ch9KsFkwp0kQlDAOmxzHpscGuGAQvi6VD4RgmAg/b7xZVlT5MATNXwqQc6KGwf2U2uGV2uzg3D4ua7fDnPwZcKgIdq9GaIBPZb0YdD7hgyIFWMXiH0eQ5vXS5HcMkc++9lz2t9GLAgns7KxxZsCkgdtN8vWD+vYDMAUpcja7lOR9eLVcIP4tcuob/3AOHCdW02VTX62ApB4Mv1v24gnPy9HiH03fJ366KYHYTHsgBBg1s5AxbG0+HLZaOp65i+ln6/YM5EwdYBwGj1cmUkE7+8THLNdAHhwrUOXtcrO/pwhF4cct2oN68BMDCfmsJM/n6PEPoYPp8bH3kCkbtjji2tJJA962YAWBBPZ0WBCrbYsFoOf9pDAiENk179fkuvf9nTXewKcBSjsn7ldonWbgQpx+26otaLIwAlfi2QQSJY3Yjy5i9dmsFM/oEDMM/Z7Uf0RiYUA7J+ToNbOQC3e0WBBm9qLad6HICG1ZK1XB5PoxnuOOIcxSXe/Of8xHV/P+FpwN47gKUpYHmuSve0pKZgCKSq5wqniWE1WZz/xouBm74KTMwBI17lVBXwtWSs+8/vL45Ff3vhpcAnvwos8d48DZX3M2hx9XIAnu0IIO0chu35AOgLL0yuG/jOmwbg028G/mNz1YWdETbm4I5BrFlov+EtD2wIo7l+Atg8D2xY7iw3V5diEqO54mnj6XdMAYcU+6gon7A3NSO2qFjlyZYDkAX6uD5Iam44YaUfVNDNxaJcLIPXcGGpfi6PnZdVD1wPspQBX/wl4OaNwN6Jqg+xwrxslcVFuYJblehkcYYZGPS3L20BxueBcS8nwg5H5kZkx6TQSbXFZcCQKadx5Cz5mPurAFxrRaa17pAR2PFC+ElSHKQ/0QjQcgCyGyM9v3SnsDBRJgL6msWCf6IfWeUJac8UFlpY8500DcCfvgb43hiwZwyYVhd2D/VSrKGAmIDnBkiafEcN9cprHgKMzgNjS1V7rRjRlceyrqif6KAkMgXIM+6tAnDl+zSL36O9+U8p9jGHQo285/2XA/AnXeNnKAorDXH/AILwbSvLEz6Ql2+cAf/3XcCdw8DkKHBwpOpFbE2wadzIdyh3jjNQirYWEwYq+/zJwMh8pf+xKNSwM6DZMmzNRRbM2K+2Ii6TlFrAWfd5V3i/F7IgT2LBF5LbIdkqxLPWvtzlAGQ3RpU3Y7AiixMxLOUB2t7pKQ8M0qCTnp8HkojJgNqaMEJesQv4AR3Iw8DB4QqAs+6SWRiqgJgY0HVDAdBA4Ba4xN7ndlSFAAjAYX4IPO5dBDMAdS2i+Jx7XTf1eEdTDfgAQnR34p/wQkRmjNAoByDT/ugFphXAmjAEn8qaPQAgZCs0lSckCNmVigEbFMsPBBE3DcBX7gLuawH7hoAD7EM8DMw48AhATrjtQwiXoqkTEwWd7LOneXNCbz6Tiq/TInb2M8ZzIFrTQbGiy92oGz7pXl/7jvdAJnb2470IbB3T77Sai+hyAP5voTqW6sKwFAc/TAdc5+3dvcsTrvPVYSK4SQb8xV3+6IaAqSHg0FDVh3iOIFTIFxtit9orL5Z/LD1Q4s+B8OnHVuXwhhdd5DoLGsgCCJ04q66X/Ju/vSaeAxDPvbdtmdtKDV90gVEPIl/xySkviOhmAEjrlzSkwj40SlQZYZ39I+8JBMx8mZryhOsKwqYB+KpdVSDFvhYwPVR9BD7uyX4SwRS59nNI+bRck/DzJ05v12M0nY8fAk8iWL5BB5qASPGRCi8EVjzv3mqpkC9ACrrwhKukB67GhpqRRowQMqCiYbj8oOoHeUWpdYIBAUj8c8WjrjyhNIJ1unzjDPjqXdUjJAAP8TMEzLYq9uOHICQALe/EwWe+QgddAqCzzD8+vgIgg0qp+5nYjaDzCgjmnCYone0klqP4JSgvvK+6LoFPoFMlkPGh+0rPWta4RHTNJJQz4M8EAGoNTPVU8opS64CC9zoAWTFChcq7lCdch6s3L4J/2QFIEBKA1P9mHIBmhPh3Ai354RyAAmWsR/PRs6vOR8Z8FMPS97yxtIlYgVB/I7jC0rIKSfLXF1EEB+BFFjQ3jCLA49OWsRTTEPzvzQEwry7VrZ5KwzAQAPssT9jw1dcHgCrORQCS/bgn+1HsCYQSveaHkzvGv1scgU/6R55Y1YIxhvOm1EZekQWl8wVDxJgwc88QiJc6AKX/meHDawX9z16M/Em7bO8Q08GBP/jEkAEVjMBoAFWXUjRA3KtNwOBXW3EkAZhrALktpC6lKtTV4OU7RHB+3kHWgv/zrnYZl2kCkF4uF8MGQGc+MqEYUCA0n1tkwxbw4ScHAHr71Q7W4++c8czwcBAmHVB/c7Bcek9b3FuwbdD/kjGWgzJjQ3thGmVA3jhfOyU+RxB6FamOFp8NrhsTgLy8Cpzm5QlVptAU+6CiNgXCaIQ0BcDYV8b0P4pi30vfIxD5+w72C9aliegW8MHzqrmh/meuFhYi0pKbs6D9fsh/n1XFMrYMbPgUByCZz6J+uEknDA9AornWFRb01WZEsACoHhOqyC7wdetT0QAK2KqOb5MCUvPyhLE0oQxzqaYNXL5xBvyVXe12vByLADjXAvgxBvSPGFGMIjCmJbEW8HfntxtQmxT0cmxp9UPAdKAZ1upA6EB7qgDo6oCUxXRtPVSpAwJpnUhuxAqWCCYK1MBExZljY5S8SYr+pxAFAuBayhNG26jw8usCQLX0SAAkwwcAEngyQizaXoziIli+Oe7/9kJvNk1LmBMe9ECO3XRB7aPeF0EYHNVPdT8gj016YBcWtBfBVYJuz7mF7VgGY/pO8f5WdQ1/7U67nIKNS7j0wIbDPFZsyNHHY7od/xdlEHj8CcC3TgCWHgGAPSxiSdt4312u/8SPAl8/Dlh4pDeZW2PD4J1c9+uyDaIDkgEJQKnTfG/N8nUAmu5HUnMW5ARbPfEuIHy/ACjRK7FL5pOR4RaxgTHofKl8r/S1ZWBnAGDKefbn3AFIPRPXB7sFiVQimKVgGdl5ooNwLQ1/1U+DQGSXQ9r5Evy1q9rZbP1lGQDZsPpzI8APHgXgod7qUx11YtBbFzC+/C+BL7SAWwhgdoLkONSLqy5oLogYft3ZI1F7EAC+phsAnekokhP4HIzml/PvthQWmPB9LJ7jxkcSr14jWj4/0wFlgJD5eoDw6fe4DzAYPHokWhHJZ3TFSkn4h7YOSOBwEtiMTv1aY0uktFYTmI2/43EMQmCuAJmUE0gmVD8EFdPpdnxhVhqzDr8F4NMtYM9Jfg98EVTeNu9Q2OFZBX7vr9vtgm/lcezczZ61ZNN8DCvilYCdPXqNDQpAlfGTKm0M6AA0PTAyoMSx64cRfPQHXsniOTI+fEWDFGp+Qb9BeySRBV2kpl0QxxGAlHDmkI56X6z+EP7UDYSdRgh/IouwIZ36lHabBE0GJ0r10Rgb/xA/tt/j/6aMAf+7R4CxzuBXWRGULwBfIrY6UNfpvLae7n0I+LO/reoLMqiVMbW38oUhkNkQIzZO7tIweGePcmWlAFTjAYHPVGwXxWoLYblEDkLuTT8MDPhXLJ4jALpaJB+ggU6xfgJknT7IKXIQXh4Y0FZCog+wxiUTwSkXUbSMV1rB/A31OXWuFpPUda/mRHKi1e6U+hA7Zq7l+A+UAfDtHg/LrptkQpZ727cRWOL9542Pa3rOvuOqagUltgtmJM08j4/PILbIDKz6w5PAHsbraTnMGdZWIwIzxIfeK0rn578J3LAVuH8CODRahV/FFQ/1IumIvXP1QudNfyNT8oVqcHviPcBd48A0g2RDuoDqHdb2SalZAdG9dnfDkAE0gXnH5ijWCDbKCq5/MRiV0QD8HgHQ63jG0hdsLGxA3x9Bw1Asli7hO3BwApgng/Gjvq01IHrXJ7q3Cz7E++YziF2rs1ZLZ+8H9jJsSoECWXj6igmR87aLgfbGq4GvbgLu2gjsHwdmCEIPSI1h+SkCRjpfUC3iNWcpoRrcnrYbuGsUOMBo7QBCxSTG/igxVcBIVGPWM1h1JYQPnyKNExGZMDIJ9b66eEBGxPDY1Y5nv+GCjfGAxD+DDpiawphABWZPjwNzNLAEIH4XCH0M7/5c93bBfI8Yk2cgVAdvdT10ifDkBWC/r9lGH51NhIsnsWHOfPmEUKT94WeAG8eAO8aAfWPAwVEHISNQlKQUglJjJExqC+H6Nq93kOpUg9szbwLuHa66QzFWkaFieXxi6hgVHOMCYGRuJ+5V4jYJIDKI9KlsAvFDq8QDrnb8NWVPh9EwdFkQ79TlSMIsN0Mi5s9MoOGno4U6f3YAvefL7Y7rvdoFLxOANSA8f7xSgWmd0kCQbmZ6mTLEnJ0UqWLhUkxlrBn6n3wWuGkYuGukCsufGq2iojnRFpafsU7MDxErJuZhYCsJosHtWTcBe1oeq+hxigJgXBrMmTBPnJKLrr+VED54ibHYvZos8sO+DNcrHrDX8YVVyglAKud0LtMjFPtNMz6QLDY7VomLJd671AEH4Xu+3g7nWq28ISvX58/hguOBg8vtFQvV/hEzxfqOevuTfpjri8vAWz8L3NYCfjBc6ZYHmBcitnFd06pxyb8W4gPlgonBqffTtdTg9pybqiVNBssyUsdUD7eGO9amnf3sXtxQipl7Wg/sD4A8AwHIyZMYky50Tp/xgN2OL8y051qw2hXzwRCEdT2nmck1RxHG+w5jeO9NFQBpR6ldMIMXlFWgVndqF2dVFsJzuOgRwMElB6DcI6rznemD0RnbwQiSRS3g7Z+tVIl7PC9kahiYZm6IizuLigliT/VoUog+p8P9l3wJ7qGEanB77k3VczroUToWLCsABud4ypaLCUoxf9i/9w9ADiICULrQRWuIB6w7nuZrwaZwLBGwClSqSyz3AhHbaRGEFGOmC44D72UVgjW2C2Z4lIF4ArjodODQcqUGqAxfcpG4mJVuVqcL5tbs2z/veV0tYK/nhTAqesYNHdO5PCJZos+WuzxHJIViuXFyJxupNLg976ZK2lizUKodilGUgzyGhokF8yw5Mf+qRkjdjfuDtwkkm7DTkNaBaQ2ox1q3eMD8+B6O3H6em8Kx1Ccx9ptWl9iYIUAAWrI3I3nHgPdOtsO5eOuxXXBdj0V1vOL/so3Cxef60tlSpYwveKf0pAu6ohfdJ8k4CUqgvr5jV6VGTBKALeCAh+VbZLTnh5gu6D44A6H8cVlkNK95O1WkBrfn31R5HSy+JCwPplAxRegE/2T+AloGncNmbQyogUQx/KwB4gHj8YWNTwRAOW0FIIIndoqNkTAxz/bd09XDGLBdMM6/pLKi5whAX60gCK2ujxzEAqGL2pQ1Jis5AJEAFHvTujYAKjRf+SEugm1d2COQLU/DAwQ44caEw8AtZzSIPgAvuKkdrWMM6M7xCMBoiBn4YpCE2NCfxWAA5MEuwvCCEICwlnhAHV+YORfDsWJGgPpMKwg1b9QpFnzHbD2BK2JGul9s8KkYW17vLALQRTCBpzXZpS4gtCXXMAkduuAy8E7PijPWprXJ5CR38ygw1fJDohh2BlRAgq2OeN7uTWc1D0AFNtmL54ESBsCaJcLkDajxj5ZXRiCIGA0waDwgjy8sk5+HY+X9ppUbJSCp6TnFCMXwny1WAFQ8rUAc2wUrRL6mXTAefWnFfnz3FpbagQKLAqAzoZjAKkkpXkNO5GCEvOMLFXOnnC4xIKOjnQGNdWSM+GqHQGd7JSsxUf+JzQLwhTdV4je1nQvr1MkPGtlf9yP2Dy+gAqZ6rQytfvdHSDxgLwBF8AmAYjHWluEDiKGMiqOVvtejXTBOuRSYJwDJAARgZAGWL9Nk+IM3SzgTydE4eec1nZHbtDaNAf1Dpd/SMx2END6kD0oXtFhBXmcY+OY6AFChnKnzl7NfdMR3qCAae2B+VVMYXASvDs3/X/zHJZcB84vuiqABEo0QPnhnwqQLyRURmZBPytnwHde0M1vN2lR6picoKULaxHDIEdHkW2iWg4/7b5zb7DSQAVd0/griV2JYojfpwRGEYsGBrOBmx/OgP5sAKANkcbFzNWTRnX/GSGImMYH/LYlk+gGvdT+bW+SWH+Ig1GqL5QeTtR2EYj5LVHfjw/ZDwL8yJ6TB7UU3VVoTjTYxYDK+Ivv7dzNAZIxpZSiU8jjKgIWTcykZkBawDBBnQdMr5QeTKI5iWCB09AmEb7+ucnOQ/aTPWn6wuzyS4u+R0Ob6CUGqJpIDA97AdqINbgRgBJ69CG4Jp6q/ckjXqB/RKla4WpkO2ODgHoynigA0JiLwaNiEt95YQKJ4FRC+7brKzRH9jZbN6iJYuSHm9I5iOAOhHNJfZkh+gxsBKPbLu3+JgaWDdojhMO5kkDWSlNTg4B6MpyIAjf3IggJgMD4MCARjFMU9QCgAykhSKnUCYHB9JB0wy5aTRUxmup4h+Q1uAmDs+hpXgFLnB6ULONOn5xACNJqxghsc3IPxVBGAiQG9aLeilWUJW1FvVXEN0TKp1C6At19TMSCBpz1dHtT/JH7N9yaxp6QkF73KBxYIr10nAMproB44qQGTj6sjUrtOFPtLeFQHLES9AdDFrq1E6M13MaxVCTNAXNFThIylLcor40zxtgDAPKuVwDMrOKw+SBTbtR2MND7sZwC7Qvm4wqHa4T/uIrhb+7n0EgbQdTijoyg+agWXT8llDsAFWr/B8qP1K7bT0pvtVwHhW6+t2C/m8svvZlawi2CKe37nhFtapkDnILRqBQA+v04AjMyn79EIkXO/DnzyCBwVweX4wxs9B4rRZgyPVFqykgDd+5JSpBU5r0vHyHz+jsc3ub0KABsZMCyQgeExKyFPVIz3lmcM6OfPAGCADYPE67Jfs6h7G0o+xvi7oyK4cLZfOgpsXwC2Lq9MwuuVERonKn4nSJrcXnQKcM7dwMMXgYcsVxkSebJgzOWPqdB1ad2f3gpsnwK2LXWeR9m3danUIV1lBSCPArBwtp+7DThuBti6UDWDmWA/DvXk8LRptfPtNUlihYZTOPCi04GH3wFsnwGOW6iAs5n3GeJJ+KLoE+9VDClQ8R6vOQHYegDYwuY3S6H/iJ8jb11ck0q9Qhoc9QMWgPBZJwFbpoFN88DGRWBiqQIgWyJY3lPozaGJ1KTEPh36zpTkJrcXPRE44S7g+Cng2DlgyyKwaclfFoIwvCwx9Zn3Q1DmIPx/2/sSaMuusszvjfXq1ZRUElJkKsBEGQyYhJCBSkUqAW1tsBdpuxEVaBzowXZqe1g90G2LotjQdmMjKqtBxQERdAWUAkUlZNBGkQRNyIAEMAkxpFKpqjfUG3t9//m/c/+737njPq9uVeqcte66b7jnnn32/s6///3v//++Tz0dmD0KzC4DM6vAFpd/0L3Gh6yTDgnvLwKzAWDGiH/ThcC2OWDrErB1pRgQisIQhAa+AED+HEEY6uNLyrRnZLSl6tSbrgLOeBQ44yiw8ziwfaV4UGbdegmA5QMTLFlqsfn7XecDW+eAmePAltXiXnkuZSBkRcm4UGXtU2uo3xsAZgz6y54JzMwDWzkgBOAqMMVBCSAUObh8QuN/CiTgcWAuyWhL1amvvBbY+VgxbW477paa7gIBqCnUrbUBiQuhAKDUot13IbBlDtiyBEyvtO5VDxvvVfxW/JkWNFrCeK8NAGsY7BsvKQC4hQCkJNaKy2LRIsg6SJ3IQSe1onKKC2CsOYMeN+0Dtj0ObDsGbFsEZmWp5S74g2Ir2uA22BScAJGA+dJFwPQ8ML0ETAUAkgDTPq9zdK/+sMWpPF19NxYwA4g3PtsHxAE4SQC6FdSgmGWRRIJLZJll8EGKjHiX1jwaN10HzD4BbD0GzC4WrsKMW2pNobZoCu6CLCDfCTqzgg6sr+wFphaAKQfgZHKvpRSYg7HN5XCL2AbAZwPrZGaj6ippXhgn0kqmU1woxnHedg5AATuWHig2FE1uVRwoxoX+Wcbg89S3AqCKPONcCi8oPtVP+9++G3j+oSK2xRBFDElUxbTS+3nvc4FpDsjxllXQoJg8FgdCQoGJJTTicLcQ6vPL6wbg9cDM4cJv27oAzFA5ky9/UOSvmg8oP86n0dICBn25JwjARWDSAUgBHN6vfdbv10AbARh8X91vDM2ss+NvAECKPVLCsHoyUgRqrlbnRwB933OBc+4DXrIC0IEmiLnE75di8HsyAcjzWUVGUi6uICMpVwwJVMXdeOk3XAxc+Hng+vV2esAYw+sWoP31r3eLcLwQBeQUrEHh4Jo2h4vDmJPuAyMLGAeEn7uqbgB+I7DlSWBGCwe31Gb9aL20kGDb/EGRxY6WTz8f2wtM8l4pgL1SgM8esHCvsuylME4nn9cfQLtldg6TZ0kUKorAfij23vAPCmqp3fcCl60XFINid1PlZrf41/dnApB6wSQjutUfIDJR8CGIQOwWEH7DywpKrWc8CFzqRLHkVYrB2jS2FQH5vkuBycXCAlIUUAAkCM2iRBA6+ARCe7DjYmQduLYTleiQ/XTTS4DpI+6nLhZW2nzVCEBaMLd+soIGqjD1ampdugiYWCpeBKA9bBJC9ActAk8LES26SqsftInLZ44dQif4Igdhym5WLrPDyuYH/7HTCNwDnPko8LXrBccjQaioe6BiKad3+QY/MGTH6rS3OBvCnQDuAIyqhiDkQ9RX+29yE3on8IwjxQPI8zkTiApGU3oVkD/4fGDieAuAdMw5MFQjEgg1DYsUku+a3uI0TGBfV7PotwHwaOEmbHEATvuDIutni6UAQoFRIFRYhfe/dhEw7tbe9Of0Si1g8HkrwRcevDajz07gIJ7n05rYyWIpb4ya/7vv8PRdFpj/LXDmkQLAnA4jCCOlTBRN/rFMAJKgkkVHpGUjySSBSFeg7/azqk8EgbSEq8UDRACLKDXSyaQ7Br//DcA4LSCtwnKhTEkQcmAIQhtM+Uaajl0uS9NatITXWzpzfcdNB4DpY+6nBgDaCtanYLN6fCj4u1ay0QIqtML/EYC61wSA9tAJeP6eWsAoDysFpg1eB0HIQRCIIkVeCqQf/05P3WCB+UPA+CPAzvmCaFWDKEuYcl1yMN+Y2dckqGTeHPEvvWDSNhOAfbefX0A6rS8CUw8X9066bFIfdqMHJID++DJgLACQumyc3gyAEYRRKFCLD1eu5ODLF6QvXedx0w3A1BwwxdAJLTXjd8seQnGrZ9bPFxLyA7WIKON63tYtCQBN/sv9QPm6BkLp0vl9t/m6ietR6fbyBA4gnXtORwRRpNnTtPpW6gWLH83lKqcOFTEnDiKtoHwy8RNFhrefyeztbnrBfbWfgttsP+kIyO32ELD1cHHvInrlvWs6TsnB7qAUlg/suFtAWkE55zYQ0QpqcALoNCXTEt7A3KoaDwGQfqoAOEUBa7fUbKctltwCajVbxvSiyvoasM0BaBKwwdKb9fN7NfcqBWGiSWykWXER0umeacUEonQgCKRfIgDFjya5yq8Wfsfs8dYgiuMxgpAg/vnMzu6mF0z6Zj5APdvPQec0TEosnvQosGOhaLuIYvnwEYSithE52F1XFAA0p5yigD4otCqygFKnpHUpLYP0OcKURYv6Mj4MNR433QhM0gL6QongawOg+6rl9CswKoSkEIxPyTsuAPigCYBmAXVfYcVf+n0SRYw6dP1YwNgHsgSajiJP429RrpWOM6cxDiJB6NINM4w7LbUGMQUwB/M9mZ3dSy+YVG0EoBiDBST5ddZ+PkCsAiIlQZDa3LVatJ0WXG2PbL98AB+4omB3oP/HgTUhmGgBfRqWf2TTrUSjExDSP/qWzQDgfAFAWyzR8rkFtDAKX75jo6nUguZxZ8NByHbvvqBQ36T1swcsBaBAGGRg40Ir+rt9WUDhQ5ZAU7Es2e9LLzglqHRxNkbeuW+oQRRls5jaMjnK0a9ecNf2R4LAwO829kQB3LTtEYQPUwzQAWgW0AGo8AQH0ljp/V17pm0KRcEifGuNOnocO1rACQbKPXhs8TtNwVr5uh+n6Zf3wDgu29g2FdMtOc8B6PdpFj08ZFrplw+ZA5FTvAQQ0/BT36FPDkRqBT9Jag7xYlQItY0f88j78sZzCcKPZlrAQfSCK9uvB4h577SCotUiEJ8opq8IQFl/PUBPEoBLxbRE62LSqG4dFB8r5bHcOtiOQSqT5T7RKzYDgJx+BUCCTxZQCwhaQc9oKcEnEBKknj5FsJ1LAPo9xoWWPWDy+6IIoqbeaO0VA+zHB0zxIQDKkn1GgtXiRxMIAx0Vn0Db+lkuFjLRCt5WEwD71Qvu2H5OfekD5FaciQay/GIbFgBXriwAyGmJADR1ck3DwTE3TQ4B0LetzBJErTYAr2BBSI3HTS8tLKBZPo/fWQDZp197Z3scjGb5BDp/L3+njMweB6B83Gj9wj3atOsPWin9WgXCFlVO/3ctf4iD8XkBkH5USlAZlNPZAQqARr5vxu1yjmH0givbX0UQKI63o0Wun/xHuR8E4VnPK5JQLd4VNttTBvK2uoiKOUf/f+GjwMNBh0NMV6J0c0NpcRv7mrYv3kh8/uHxYp+bVpwLp3R7sts2YzouSq3KGa+q7+x7Co4nazAerRKsVlV1QitF59dyyFZaYY0HMu9mWL3gtvZXMbymBIFMZ1ov2h0B+LTLisxgW+Eq5uU92iZ72ud9vvR+4JFp4NjkRh2ONi0OB1/UBCkvEYRhfuNs4OmhhiPKnFQlx6aAjMnSXJUAACAASURBVPjmz1w41nnwO4cCIBvBwZgTAOUHRq3gyDExD4zRGVYEnpm5LqmQc0M5esFt7acFl0SlHiBxuTkYxxdaihUC4QVXFu5FCUD5QtJl85sjGA0ziQxqeu/fem+hw0F2fLLQGxFlYMRvo7v1WmIVtpt1DFkXvOR7LwJ2HSkyoZmEypoVVe8p7b6qEMnidGG/Vl/L2aPOIwuA1pAIQE3DAmFa4j9f7CPaFpCHKujr5xzZesGdHqAqKz5X+FLRAl58le+jui+kTBALMcgZ73CDBkpN2/7+bfcWOhwUyCEAjQTcAVhKdjkPc2RajewKyu/n1//qJcA2uhBMRGXQOcn9U6JIOjXHQqSYOsVoQp1HNgAvz8yny80H5PVz9H6RqVd849WtXQ/zA0Ow2ayGLJ474L0G79vvbulwkJi8BGCg4S01SKqofoNvSIC+5zkhFUupV8rUTpJN06KpaBkFQm5M1HlkA3AyM5/u9Zl38zrk6f0iU6/4hmscgK5ISUtCTowyDqb7UxwsqFJW3fo/vbuIBJEZ1YRgyHwQKNi0KEl1OKTCZJdxtPDn//v8ooaDaVgqFyiTD2IKfcjZS4Fo+7g+HXOPv84jG4DIzKfLzQf8KVfI/FNKrQ6h94tfz+vOA9cGAAbrpylY2SDlVTTt+uCnV3/V3a7DQQAysJAwobZJgUXi78Qayhd812WeiOAZzEyUiAkHMeu5BF5FwZQAWLPwknkLQy9CrPMy8+lIHZFzvN3T+YbV+8X7c64OHHix74V6zIxB+RJ0wQ+UU992tYoFy3fcXcTDxQkoPsCUhFIczKVCegSg5B8A/PILN9ZwxBSxtiKiUAOi7JW0dLTustF8AGbm0/1o3vjjnSGdj+lYlGwdRO8XN+c1wABIoHk6k61yuSCJITq3jDY9Vx0BqK++uwAfX6JkI/hME0SC1EGguiQ+isqcQRLrF6/0jO2w+6FMnZhyZYsQ1W50qOHgPX1NXndtODsfgMwHzMin+0+ZN0S9YOllMzWfLwKQSS396P3iY3kNOLDPM1y065H4gOW3p4uTDkB8zWdb7FgbdDhEgJkCUDRvogTmd/vPv3BVAUBuvylNzAAYi4hisVQnEHoIqWblrxqm4Mx8ujfljT+YjsWBYgIOc0oJPsq1slCpH71fKybJOEoAuuVTRSCnYlmU6P/Z4iSJEcbLv+Yu9/1EAh7JKEXDKxq4ChUiKymRbwjgHdcUWTARgLYXHSr2LOU+BV7MVwzxwOfkOWybYAGZD5iRT0edjpxD6VhcOQ6j94tP51wdOHBdMeXa9OqWRcmWXA1XLUIUH6zyCwlAs3z+YBkfs1u+VIejJEF3ckrjI9T0y/aMA2+/tgAg08VURKT8vbKMUgAMIGzzAcOi5HknHQAz8+l+MW/829KxhtH7tTz+jIMAJPCYMULAWd6fvi+EY9ouoZBM/Kx/4LUBgFLgNC5o16FrE8JJVJgkiFhaQQBv3+dVbMrWVsC8UxFRkjjaVsW2DtRdOJ/vAyohVYK7A+bTvTdj8HlqTMcaRu/XxHkzjgNkIOWuDr8jnYYDKDutgpUhra0uAlAyCCUAK8BXcjBXgLCk/h0D/hcByDxFAdAzoFUqUBYRJTUcMWdPP7ONL6i5bLQeALJRQ+bT/W7G4AuAOXq/lsGdcRgAY+glLkYclJVTsa6ptCX3uQjAKINQstFrAZKIwWxQIhIJuovB/Nx+r2LzFCwlj8Y0evl/MYk0kieVtcvrwGUnHQCVjjVkPl3mItQsIPuElx9G79dOzDgMgGkAWlNyBJn8xKprBRC+zgEo4LWRgcdVcOCjjlNvmx84DrzNAahaFZWLygKWxUNibIhTcPD9BMLLa65bzreAMSGVoXvJ/Cgh1WUfO+XTZS5CDYDs9GH1fnOrIDcAkABTTDCCLYK0Cwi/586WcKJUiEpC8CCBYDsiiSplqUIUmOjf+o2tIiKVUJbgU5uSWl4DWwX4+PcXnrQATBNS+8yny1yEopdcay+930y5YhgAg+9n2OoUeI5TdQer+32fdhmGoOBZanBo+g1yEKU4dYgFSvqB//vZBIBt9RshkTbW8ZZZ2hUgvDL3iU3uux4LSBM0ZD7dPRnTH08VAIfV+2XAOucQAMuVcKfFSD/+IAABsEoGwYAoHZIKEEYxRIHwLS8pUuhjFVs6/ZZhIVWyxVKBBIRXnbQATBNS+8ynI4tBzkEACv+chlUVIKE/5cRGsWmlKfIzudc3APLQSlg3E2OCyVRc1kpU3DgBmKoQsWtlBcswjPu+nfTYtBL+GQdgOf16GCZW6pXlBCqWSgqJypoOAFfXXDifbwFJLvi5HAjlnUsiIe6AjOp4iQNQHRlT2PlgJCUbbc2s+v/hFwFb/q7gm6HlYpBbmTV2sscQyy/qFBj2v0/cAdz/HGD7NDA1AUyOOU+1CwWOewNjKj6/O03F1/WuugW4/XJgfBoYmwDGdH7IxB5kLPIB+I8AfNwZgga5ck2fJbEm8V9zNWPfrasbgMuPAcuseJ8Exsb9FdBhA+7gaQNKB6TfcgCYug+YJT+g89aoBDMmIMScP12uTKj13uDv8zsKig/uJ1uQOsnojm3qB5P5ACRBH3OhPuzzRN9DV88HqQLEWPJnvTy5nm/t/1s4BcuSpRZtGAu4fi+wtBVYEyccrYwn6hF8/FkJp9bKxAKVFsn/d8urgbHPA9NPOEOWl4+2cfoFHhfVrJTZPKHSj5daOtup6JyCpPx8rHWRVQ7WOlrYCMx8AHIzlxkALPD9c0VB+x/A3E/+E2fUYHXdF7KTGwdvTd0AHP9r4PgWYG0KWBdfsBdsMPfPrKKsoL9XAVLAvO2fFylCE4cKliyrDVZNcGS1CqEYhWFiAZV+XntaURdTLmpCEbpchTYLqi6NrkMCzLzt5Xc4HwyJmmkJ+Z73jQOh4NWeDUZiK1K08f0EXt7CMHVawIk7gaVpYJUA9LI1Ao8bzKX1cytoFtFfpdCIWz7rgzHgth8u0oPGDwETc8CEMySUzFaikgtlpW1Ta8JqNba7lVljSRgW+Q6ZP/57WQvj6fydBjXfAjKbgEvMLwWCvhNoipgNpnQshlS4IGFWzIk6ylWwAz93ETLxGWB5ClidLABoIOS7pmGfG+33YAG5mND0G8F4678vkiPJczNOAC4UyQm2N8w94kirFlfIAl7i402d6dbPWWAtrsjOFiuCvAJZOQE0pHTFsckHYDeCvhNgipQNxoAz8/8IPr5nbvH2jd+6AThJAE4AqwTdZKEBLDoDgU4+YVkPHIBoPwareOt/BkDexsMFAFnbzNJYm0IDnVwbt4uyur1kwL7Tp+iZM/08WT9Rc7DHUmuYTr/x+6o4ovvu9fjBbgR9JyA+omwwxvZI5ULg6ZW7y9FPf9QNwKm/CgCcKABovh8ByVy/UCtJq2f+X1yYJPGU27lIZLbuEWDsWBHesZeDz4iURLUWa1TE47LqK12fZmd3OXidFctqm92KatVs1jAEsNv6sdymaa2g8+xUL4I+Pn2beCgbLGWHI/h8G3oTr45iK86POlbBU9yKI/AcfLR+ouQwH9BfmmbLlTHboOnZ/T9+5vaf8FUaAThXsFOQ45mUcgZCWTAxe0UQ+urYMO1/37GtxQmoLCBtRSp30LrDp2SFdzYMgk/R+VNwvwR9mwQDsaspGSfJgYDYNTbp8psCQFJxEIBkQjDrxt8dXCUIY+COH5MVFPi8SOn2n/QYLZ9Gp0cxANIP5IvAkzVzxivRydnKNzBa8fddM84b6AFyAriMF2pajk9kYIeoClXmA3AQgr5NQEHMBqMVFMNaIOayNRL/vhlH3RZwmhbQQUcAasrVVGz4EtjCu/3dfb/ID3PbT7uKAZ/MhcIC0vqRTo4W0IBIEAmEtFwCYqjW03bcmdwBYeoWgetUbrR8snrloiR2drpACf+rD4D9EvTVjIJu7HBV+781X752Czj9lwUZkTEgcPoNPp5Nv4oBRhCG6dd+1DkMz1JIhR1BAHJ7zwqO3fIRRM5tmDK5CoQKsSgOeBYBKFZULTqcB9r6Ni5KYmd3WKDUA0BlhNLM8EbT1QBXBU72aI5ZjUcVOxz7WLkQ8d37vsart/uA6RcPsxNSAtAXHDYNC1AEpf9s01kKwuBwGU7HgVt/1jtD1e60fgQigSe/j5bQp+KYpGB+H62jT7P8/ZypBIC8Dhcx8eY9wF015abhmnoAyJ5WSrKeNgKO9SHxnT/LSasJBim5lRjWBEIVeROInKL1qunybRawLgASdEy74qjaNNzJCgqEEYzBGvK0297mAFSHEIB6ebKDgc8J1ksmV8t29f1en6L5v6cxIK5iK6Xne/5jCTiFcTqVn/r/tWDPWwXnEPTVgIKUHU7ljASawKefIwDpMdRxRB+wFgD+RREDJABpwSzz2c0LfxczVjkVKwaYgtBBezu3SvX08d39P5uO3QKahXMQciourZRAGKZWar/YZ1xXRPe8wQr2AUK7TvbOVTZBXx4MBECRnConUBSFEXT6mf/TK+/qmzAF/0UBOPqBZYF52HrTFCw2LH5G8UCzJEko5nZqmRnPh/uCXmpnVpDTsIPPwKApOaSA2QLDLSHf97iPx0tpISLfz7bl4iFfsUsnj+HZWEeOYDCDnDmCvZkEgedcCjxGseIhBYt3vx049HwMLRh8gA9gh2MoH9ABqKJzxf0McO7XlSAU4HzhYYFq+5D7hwBu/98OQLlIBCKnW39SlXNY+nqeiq2dkQg+gnGPb9/ZpT0lq6MV5D96gLCwgDmCwbdnCvZmCgY/dxy47xxg5SWuUjigYPHFbwA+fyGwfr2rXrMvPB+vp3L3GHCgi9JOHQCkRVPppeUBigXLFymyejYTB4YsgfA20ofRAlYB0FfAlvQqP0/TsX5PLOB5DNu471cmIwiBaRww/F01J+mz2pqChxUMZvpJlmBv3iTocsW4dzewfhkGFix+2febXDAeJO/YEILBB7pU1g8LQFo98QASVGYNQ6DZfEG3fnEqrgLhbf/HV15anbkFNCvohWSl9XPQ2XTM/2s3I4DwPIZwBEDfgitH0Ek6N6x+u/iD7T4g/YdBBYPpWHEaHlqwNw+AQa4Yj54JrJO+aQDB4pt+oCAyYvOPEIQDCgYfeF/9U3AbAMX7ItAlVtAspKZdz5SOlvA2pstxjES3wJ+92NgAGK2gwi78QoVfEhBeQACqNNP1RdoA18kKdgDhxkUI/zKIYDCnqyzB3jwAJnLFOEIW7QEEi1/1Y21ywVglCAcQDD5/Efj7M4CVrZ5AKlkhxeQUaxBI4nvFzxf8IfCVC4HV7cC6ZEX5nen3VX1vAGLZq8ysrvHY+QBwbGfI2E6JpLvdX+ksthpUvQrmX/sVDGZVUJZgb17vJHLFeGQcmCdVb5+Cxd/5xjZ6QzzMLOQBBIOfTV2Ps4HFHQ7CLQUQmUrV0rgKJMsCjsxGAqTn/hzw0EXA4tnAyg5gbTYBorKkUyLnkB9YVhTxu+kT13iccwtwdBewPAus+b2ar9xJAafqfgMQO4dh+J9+BHe5gqZZZzYok1JJUcpaR6bp93P+W/N6p0KuGIemgEWKgPQhWPxdP7NBLhiHKYHUp2DwpZ8rLOD8tmJQVplOLxAqmbRKC6EDYC7/CeCRPcCx3cDSrsISrs04CPm9ArZk55UvKAspYLqPaPdR4/H0g8DRHcDyVr/X6VabLHk2PhjpPVZY7d5xwF6CwS9y/4LbbVyQsEKIufGiKe0p2JvXOx3kinF0GjhOQY+oNRtljji9TQPf/fOV9IZY4Gq4D8Hgy/4W+Oo2YG5bUUy04vUcLCqSJVRWszJbNgxSmMau+q/Ao2cBR88EjtOqbgNWWaTkIFz3YiWrF4nAjtN0nBZrJnU+/8PA3CxwfMYB6LUra3oglL0tps6wlVha5rLiqd9AdDfB4Je6U0s/0BXTDYh80Sr2FOzNA2AXuWIszABL1JaKWq1R+nwGeM17OsoFY5XTVw/B4Cv+Djg0C8xvLYqJCECzgsxmZlq9T8e0XGUyaUizavPtxoFr/zvw2BnA0Z3A8e2FVV3x6c4sqwObckeyhiXAowUSADhD1XhceDMwx37lvU4XxVN2n3rJIocygkr/Vbs7fe+EdBLcfaXXQ3IPWIrpBB6XlnwpR76jYG9e7/SQKzarxM7qJFj8mg8UarMV9IZ4gvNDD8HgKx8HDs8A8zMFAFnPYQPDl0Co2g4fpDZLqKCxT0/7fhJ4fCdwbFvhRiwRgJruCOwUgCpeCvUjZmEFxhfk9W969kW/B8xvKQqnVgg+B6CB0MsI7P70AHgmd2n1NQ0rv7FvALIlVYK73MnQCDLThSGZoDpuP7uCeuX5n8zroB5yxThGnQ0CgyBMxY63Aq/5aBHG6EBviDlOLV0Eg1+0AByZLgbl+HRxnZXJoqqttA4ODovlJZVuSjTQFtq+NwNPbHMAzramdVpVs6wEoPtdNg37wJfvsYiJP9NFqvHY+7vAwjSwxAeNxVO8T6aNVRRRlT6hHrJ0Ovaw0WDJCKng7g86APvNB9wg2JvXO33IFWOBgn8EIf2nRLD4tbe1+AU7yAWbZeskGHwVdd2mgAUCcNKnJgLQrZ/V9/Jnn5JUYmnAE3hCmv3+t8AWQfSzyPK/POOgJgDdsgqA5nfJAvLdLV+bz0kK4RqPZ3wQWJxyAPqDVhZQyQr7gyaXI9axWCFVAGLvRUhV46PgLnUWBs0HbBPszeudPuWKsTRZAJDTo8l8ui/42juL5veQC7ZpsEow+OrZQlqVVuH4FLA8WVyDAOTAmHUQCAWQkOlsQAwDt/9/AE8SgPQpNa07+AhAA6HLXbb5Xr4IaAMfv/eGvP5NzyYA7UGjBWTWjh40v9fSyscHLtaxhJWxFVsNNAXH1khw983+DYPmA5aCvXkdNIBccemfceooAfhAAcA+6A2xLuAGucxrzgKOMexDfV9OwbS2BB/BEoqLSrBoYGgJ3E8qLcIEsP/ngCPuUy7S13L3wb6PU56/m/Xj4Ps0TKCXQA6AXuNeZY3HMz5QANAeND1kwcKXlj6wOZQ+b7R+Pi0PD0DeFAfk590CKg8qncfoFzIRVWVqfFfBhgn25vXOAHLFWCDbvPstBsJZ4LUPt+jdesgFg+qVptWq11bg2gtgfuLiRAAgQeg+oEmsOujsXb5SsAoCIN/3vx04OlNM6Yv0tdx1MKvK7/TFjVmeCD4HQQQhf159eV7/pmc/kwCcKABoeYvR0oept7SEoZQ0Tr1lPuPQFlAtO0nyAcWhpzw/FSjFzGjLx+RGvxzoSeC1hwsA9klvaFN5FAy+9mJgnhaQ0qqagglADo4c9AhCDpJPl5ZommQ8738HcGw6AJBW1VecZv0cePwOY0/wl1lAD/WUCx0mMlDLr8bjmb+Dwp3x4nkDYbD0thIO5aNtfmDi/xGEeRawxhs7Vb/q2huABQJwAlhyy2cC0xoggjAAUCWWAkksOiIY978TmOOqeqqwqAx3WGhHK06n7TDwOcAV/iipPAKjwgrZm2o8nkUA0gKmAHTrp+o9MTrEYvq44o9pZIOtgmu8mafCV72YAKT/RwAy5OPOuVlAAk9Oule6xQRTWUKlWtkU/IvAHAHti5oIwDK841ZPFtCmdr0U8PaC9hVultd4CIC8P2Ztt/m5/qC11TJXlJDGGpfGAmYODgFoCxACkLpuWh3KCgqE8gNVZK4KtxgjJAB/2X1Krao1rfN7CWZf3LSBT4uAEIyWBVpipL7GgwA0AW25GbGENBTRx3rm1M2w39mmrFVwjTd1Kn+VAZALEE5LtIDyMWUBvbLNLGHgd5H/V07BDp7r3uU+Jadgn3ptxekA5MBri0/Wp4wzBjDbCnkMWMqVpE8GJwLQqvfc0pqbkVj5aNk7gbCxgJno30cAjntowtXNaZ1suvSKNhsYTcVKmw9F5xGE+94dfEoP+JYhD/8OC8eIPUsUHokVVKB78XszbzAF4Pvd//PCKVGIpOAr78mn4DZOm8YC1jco+w6EFTDDPJqeCEBZBa5GffVbhmQ8DtZW5TYOvPhXip0GTuu22lTMLSw+aAVl9QhEWjurI/aQiLJkTMLsX9R3r/ymZ73fp1+37OU9hunXSkdl7T3QrhKCtlCM59k2i5CMMSIAGdqxEIwrmptzTsCEut5yilKoJLAcxCq3fe8tLCDBFwO+tKjyuxSCMdYEXoeDrHcHvu0tTwLzmwHA4N/Gh6zNCqqeOSxC2lb8tQSiMwbuqXIqAcjFh2JjBKGJyShQG6ygVbfJegULWBYcMR3rvb6oCRaQwFPgl1M5rR7/JtBZOIZWx/0+s4QeY5z/1/X2tFnAxPpFELaVkdLN8MWGVr4pCBsfMHN8bmTKfCjZ0Ncp456/x58zLzfw6Qf3ABd8pUgEYmqk5bGyek06IQl1bkXScnlN/u8L24Gdx1qVq91KQvrpgwaAAw9p+wnXPw1YjyWMGtDo2ASOFGMU7SIEUzdYD34vMPmXwLbHgdkFYAtlGiim6DpxJtvq9LtlVr/aWKEB8pUXAOOPAFPzwBTZ9r04vdQ9Ts4pAZ3cd+yHxgfMAOH+vcA69/9Uxijmz/AerYpdar1lNSMYzV+vWY/34I8DY58Gph8Bpo8A04vAFEFIknIHohGVR62QhFRSYjQE6qFri2z3iaPAhHNNlxKwArI0Q1IAxwfReacbC5gBPp66/5ICgLKCtqnsrKKlrFZUFPKOr7osMTtdsxzqQRZ93Q1MPARMPllohUxRqkEK6gShOP0S+dY2hlRv99y+ovRi7IiTnTvLqmg6xDPYpqAUgRgsoR7MxgJmgHD/c4E1FXu7FRRbvEgd7evXWlbPpp9EgUjiJpwe6zwOMlvpAWCMVusJYPIYMOlSDZRpoGiNxKzbdIQlXONMWJbGtw4svdgz3El47nzTRvPrrKptAJT6ZrzfintvAJgx4vsvdQvIXK5VYF3sUZxmJUvgA1FOvwF8spKyBtM1y6EepI4LqVMedbEaTp0EIKdPKh5FqYYqSxgo2jgFr13j6XXHnOiSZOeBVSvyC8qC2r05FVvVw9cAMAOA178AWPMp2LJaaekiCPXExwHw660n1oB/niGQazwOkkSepbJ/72I1x4CJ+cJ6lYI1riccrVicUuVSmIW82pkwnHHVOKbFsOozQGkFkwewnBES37ABYMaAX39ZAUCCb82nIlo+40p2gNnvsoKunxH1xGwA/LOzdQOQJPIuHzV2GBg7Cow7AI0l33XfjOsv6oVodes6ISbBsAZMX+kJxU56KY7pkmFVhOciuvTzSt05v0+ryuT/9gDrZNe4wPMsI7VJP3GcP7gUOOdvgL1rRYJ0ZI5IV3hV4/wrGYPPU3/AiRhYusy2K7mU999P+z90ObD7LuBZK0Xdkeq9NSX2+o4HLwfWlopFCC0fgciBMtAFC8CGrYXVoVjnU2G7rTXrzh4kfRzLY1kyGwBoeiGcPiXb5eAzdXWnazPCSScb4j3xfmav8Cx2p50lAMW0VXINitCogl2r9H2dcctWwQxQsn6ZTBbMNtcgdKIbiZj51VcBk38CXPxoQcfCUg8pjcYgZScw/momACnXyr4leBhs5QaBTHpf7X8dMPYJYO8XgAv9e8QJlAZZq8D4xSuANYKPJQn0AR2AHKy1MACKe9nfFI6IEqduEWoHIJ9wlsVKLekoMCa9EAegSTYQeM4TXco2SEMkAHEbBZoj4bbYtdyCVrFqGXgTSxgXYTZeHLi9AMjEQRCVUXP/n4KUaaT8vVTi+Rtg7GPAuYcAWlMCgUVkQfJ2Q12yBvPXMwHImhDWwf81imsTiLSEvHZkr+jY/p9CQRD4p8DOBwteItai05qn31FFdfLlFxYWgCDUIkRkj/TxbCEi/89jfPZ3X2VqYSJQbmUNQY3HQT7hbv2sLoerVwKQHNEEoCsm8R4MhPRjXUGzVEIKIoY7yaEYuY4dgGb5RXruoSgtSCLLarkICQ9f6QNykGjFdjsIBaI4kGlt8W+Rg5g0HJ8qAp47nihAzFpuWtPIMBZJlASILvR6fQ0DCVbJCkJOJCqnk4pGpb99tZ8MopyiKDX7WWDiwYKXiEQOehCrgKh+eJQ+EQHo1Lby/zRlyf8TIbf9XS5ftIb8I92YugH4ay2pLusorl7dAoonWtMwQSTdOFuQSLTGHyIC8kxSIQuA4hwU2WUAoO4/grBcDbsfWElSzg+JCoYDoEGM1ixSkHzgF/wG7y8sIa3J7JPAGWuFJSQIaU01iJHUiYP4e33BrPOHmG/JMaOfTZVYRhwGav87vWKPJ9/rSH4IOGO5sITqg/ggxXs4TOaBAECbeoOsgfl+DrQShFqcEIhyyt0MbMusEkx76iAZXKM8BvXiZAGlF+KaIbaadYpem4aDgpJZQz6YJABV5VcHAJZ0v4FxX6KG5UpYs0KnqjhRuagEVgPglYAl9ciHf8mdUrJh0Qx9vkDBzBywfbkYQIGwahA/kglATsHsDzKA0BATiPyZ4NEDwIeoa/uFYKKXL2f24nQoIgd9R3yQCMTFqwIAfdBWI7+yB5ZLECYLETd85YJl+2YAUNosLIel/xYlu4Jsl6bhNhD6it4WJCvA2Zc4Gxo73RcgJeOqFmGR6rcChLYACyGojmEYdj59KnZ+tIQRhH9IvWA2hiREjDeRI9Cly7fMF3EtWRFawhQIf5IJwE56wdTIYdt7tp9ys1K8JnoJvod9Wn682PNkP4hUy1ndWgstAtBDMLYN5/6PAc5DGNoF4SrZfN+4+IhT8jqwg2Cp8ThIJ5vfSWBXAVCrWN9SMxDK+skaOvhoAc8me654pmUB3f0wyt+E8FyRAGmPlOEoiSD2qgvmAKoOm52fAuiTDHSyIRxx+lI0QxxADubfF5vffMmSajrWlP7nmZ3dSy+4r/ZzAUEHnQ8R70HsXlK+PgJsW68G4XYGZj0EY2EYATCAT6tAhmE0DXcC4faapcwMgAIfLb0kuzT9Qmw5uwAAIABJREFUSi+EfeALkSrpBovbrQDnkm8wAo8/E3i+CCsZ98NCpAp8cUekZyBavI4ET/TnaAk/RQCyAXy6uNSPA0i+wMeB6ePA5HFgZq2wpNGK3FUDAHmv3fSCe7afX8CB4UNEEOolVi/3obastNwJ9cO5BOBKEQMsAcifHWzRAigWWAlCn5K2bQYAOe1KMjTIR2kRUhKVS7IrLia0v+3xwHMZMCbYNP0KfG79zAqK5DxOvyEuWu6VD5KSHy2YAEQAfpaRdl5UkuUctIpBnCIIl4psD03FtIIP1ADAlBuJM47EqqUX3LX9kSBQcuuyftK78xUkHyQ+RLqHZ3Fv1KcgLj5kAQ1s0Qo6IA1nHhNLQzA8ZxvBXuNx8DcS5UYpNnoYxsCnUIqvZo0F3wPTMa7Hv53HOJVbS/l+5bumX7d+5WLE44hxIRJB2NMCqj9ixwuE90svWCaIA6bAp959EKeWChAyA0PTOV2unGMQveCO7bfqHbcS4rJR7Ewqnw5AWhLuImg2uFQAXAVs8RGmntW4+g2hB3P79L/EJ9zGvqrxOPibiVihAOgrWQOf/EBfBcsPNBBqW9Hv6zzGqFzmoXz3B9AePgXiq6bgiv4YOB9QHS8AfpkAFMMjrWAcQA0iO9XJiQyAnos2vV7ESHOOQfWCO7Zf7F40mZFQScRKAYBaSU6vAVcTgN7xXHiUFpDTMK2dFh56912BTiDcvpkATIXzCL4g3WXTZ4jpGfjoF/oihL+fx+0yWUABLwIwtYKKIabgCzHQvi2ggBKn0McEQDaKT5cGkIOo6SuyYzEfjQB0EM5nZgAPoxe8of3sgSqCQM3jkdFLvpRvR13+7UVRuhUFSavNO6otwp88ZZ3+t4M6HLtch6OT9AG/q9cmtf//gV1JDYcnQ2zY6/YakfSrU+Pg1M45NqPt3IEtoM7WFHokyrWKkooglCMWLYjiUXMtK3g8Uzd1WL3gDe3vRRCoUEYCwGtYFxxqgA2E/jI20F5hhmQod98BHNnlxOTig1aGiDanO21yV4DygWuB8YeB6fnC9WEtiKVVKeE0ZGiXWczeJoWMIig5a9V5DA1ANoKDeDylZ9NSXxyAsiKawrQqmCv2HVf5e8aRoxfc1n7xs+khItAUvojvyWryxVcWJZksVSyZoQRA3dcAoHzax4Gj2wtu6FVKM7gMgti02jbV476oUJJs1j/AbA1mQ3Pm8eTRsoZDtR+xZKCiEKmMXTIeXHPGdhYArX8FwG4DGMEnAHIK4yvT58nWC2b73cexaZgWWaEKgU1gjNbPP7PvOYGsUSBkv3hBtmRWNzxjTk9RWktvxp6POj0vARjY9sWkFel8RWxegjIF4RjwAOnZWMPBTGjqvHmszxJOBUD3xyznL2bqROvoP3N3q84jG4C7M/PpcvMBef0cvV9k6hXv+2Yno5QfGArRbaCC0mWv2YtF3ecerNDhkNZIIsXQRv5dlTtGADJSz2gEE1EJQM//026HdIEZLC8B6A0tk0g1Ja8DuzJdphS82QBEZj5dbj7gxZN5er/IZI+67pscgE7QaDOUMyC0Wb8+gXjuR4F5J6YsaXnFhBoAGEVvUhb60jISgCQnoh/OLBgvIrL8v7DdFkEYM5dtNg97tvz5zJqzdfIBmJlPl5sP+DJP5xtW7xffnzeh7H+Z+3+RpkyWT1YxuURJYVtx6T0fCTocouQV85VkHRIGegEuEv/YKpkA/JceVmL8kv6t5/9pu62tfiPWcFQVEa0DZ9WcLJEPwMx8uvfnjT9IgZyj94t/ldeA/S9tMaGa9SNdmsIxbvVscVJ1GScoMt4UPwhAsmMZ0aXzQBsvdGRBjQz0FUpEJRAJQOq4KAnBdz+sfiPJ3bOYn8fsykyVWMfiN3BOzckS+QDMzKe7OW/88aqQzsfE5kH1fvGjeQ0wADodmVGwOeiMsUqHrGOnS4UFy9P/wAEojkEnI+IqOIJQNLgpCXhcmLAtD/D+kgQE235L93tj+YBqgTX9BiCeW/NedT4AmQ+YkU/3sbzxBymQuZhm8g1T+QbV+wWFdjKO/Te2mEFNlCb6gPF708VJ1TXHgKd91GnZpDfi1k/gM2vqU3DUnCuBmNQe3P9vw6pe229KOvB0K1k+ZS+rnrfM2AlA3JMZtah/EZKZT3drxuDz1O/yxAwu9JgJxr3lQfR+8aa8Buy/wdWQZAVl+ZzCrG3q9c/YrkmHy3IRYryAAqAkEBIlopJxNNUbER+fA/H+/+AAdP9PmS9dazicJybm7mlB8nR2dI1HvgVkOlZGPt2nM29GCamcGZjAwlQ+vvrV+8X/zGsAAUiLVPp/wd+zaTMFWw+/kAA0GQQnpCw5mDsAMIrcRB5mC/+MAffTwgfwKY2KfmCZ6ZIkUShrxXxBX4yYaV8Hzmcn13jUA8CMfDqWYeQcSkhVOl8U6uxH7xekrsg49h8oiCENgC5TUG5vKxxT8f2aRtOtcAKQ1s8soPuOVUIwpchNlEEIOyNSIrrvv3hwnckWIZPZsnbcDyzTpvg3lU8mpZQqozyfK74aj3wAKh1LgrsD5tMxiz/nkGD1sHq/YNFOxkEAcuW7oqmXlisuQOT7VV2jwi/kTgj1RkoZhBje8Z83SCAEEJZW0C3gff8tADCt4VASaWIBK0HI9q8BF5yUAMzIp8tNx5Jg9bB6v/jdDPSRns0BWIZeUitIo9IhHmhXTvzCPQddccnZ76U1V/IvC4SBCFyg26DFNg7c++Mhhb6qiCikT7WVUmr6lYn2nRKyrdZ51GMBlZIc07GUBdMjny6XCiUmpA6j94vMZbgBMFo552pu27PXAqXTyAUQcitOQjAm9xX0N9pIwIPmSCmH5QuPqER0L4kDYgp9zOUL6fYxkbZcFceyAreAF3GlV+NRDwAz8uksnT3jiILVSmpWNlhMze+k94vMZfgGAPJeHDjpCrgM01Tdry9OzvmYAzAqLVWIwEShwzbRwwSEn+MqP6bQK5tZlWyhjCCCsC19Xv7gOnBRbgp7cu/5AOyVjqVMmA75dJZ9nHF0yohWNlhMxKnS+0XmMtwAmFq4imnYbrEqNJPc+9kfd62RKh0On8qV9hXZ9askEPgAfI56ziocUgVbzGT28lEtRMoKtg7lBHtznfZNA+CQ+XQWM8k4uglWK/NLYKzS+8U9GReXD0g/Tyvh4Ne17Yb4Zbr6g6y7/aNWcoPpjKRTsJIags5IJwkEAv6en05S6GUBfRWsUExZyVZVQCQwrgN7Wfdd41GPBczIp8ODeXfTSbBa6YYxlY8/p3q/udc3C+jTbtvqt2oadnB2m4oNgMn0W0p+hYWHWbwg9yU/0Kb9EIy+5y2hiCit4UgKyTeAkN8Valk4Le/ldlONRz4AWWBRM6fdIPfHstw/G+SE5rMnVQ/kA5AkLHS0ak7V7reXfhgACaBqDtD3e/nmc5k9kA/A80JReq+U38zGVp3ObJo/BvAOD3dtwiWar9zEHsgHIGlFubqSx7+Jja36anLLcDvvgwA+NDpDfILv+qlzuXwAXuSjrkKemlO2e3U1uWUYnL8dwB/5e2apca9LNv+vsQfyAUheX4VguB+mzIsaG9ntqxhF4Xbe3QD+n7/uHLAW9wQ1tblMRQ/UA0CaHC7plXEh+q4T0OWcfhleYTSHBK0EH/mi+fcRuKQn4I6fWpeoB4AevCz3HOOm9yb3F5mBlZBNclYCj1aRfyfrbgPCTR6AzK+vD4CyglX7jpmN7HY66d1E0ctdIrEEE4wEIMlam+Pk7YF6AMj7EwAVbU82vTerCwhAXopJN9zVI+AYrOeULLZgErY2x8nZA/kAJGWr0naUWdFpy2cT+oCWjpdjLFxE5UzYIBBpEUX5nLnlvAktb76SPVAfAOUHpiAMm96bsVtCAMaKALICMyxDq6cXfycA+b/mOLl6oF4AiqBRIEzBp7/X2Af0+fi1XIioMIlAI+AIPIGPmeROWV3j1Zuvyu2B+gHoFfZiDS2lC0LiY52WUADkQoTTMH1BFSYRdHoRfKSu5v9qrizMHYPT+vx6ARhSuDcAzzmDo5ZGHT1PAKYMwQxME2jiSo/gEwBrrq+u41ZOy++oD4BaCcsXTPiSI3ey8s4KGoG8QwCMFM+0ggQhLR0BF19SXuD/ayakz7uR0/TsMcxg3SjfqWNA0hsrga/ojaq/8WPcC+YIk4Ke4CMSuB2XVht1Oj8zIfXlU8BtU8DhmYRXWdfrdF1fgr3+S8At48CD04DVjXQSDO70PTUnaJ5uOCwsIIFHSSFy1pKPWCDsZxCpw8UVgKSPxLXM937OzxxAljzcPAbcswU4Qh4V3UN8mKoeKm/bu78IfKJQa8VD48CylHQiL3O3/qg5Rf30BKACMtJXjXKQcfBSK8Dfqc3KVCwuN2VFGRnm/yKZtq4Re5ifyQQgM2A+BeB3GHaZBo5MAIue0l7Kt3cC4xhw+5eL7TuCkJk1jBtyerbUfYG5ExjZ/pqrxE5fAOrOq5SmowVIrRp1IyT2R6+fg0bgVYG4CsyZe2UsaiOGKXr4Sfp9k8CxCYAFSKyvXeY1o1BxQux91yMtfsHPutgnnyUuUvhc0ZsgUXib+nVkq6+ZKaABIHsgVZnuwD9sVo66rrR4ImdhLGSQ8zPL/JgBQxeU1ouWkO9PTgDzbgmXxrzMkatl3keivfG5x4r4IRcz5BfkO5vEZ0kgpIfBZ8yKjlL17syy0tMNcOn9dl4Fy6dLFabj1Mpvow9Ify+I4Nlo9Xt+ZqU9VdJpqZh4QDDyxUyYOYJwHDg+DhgI/WUVZl7aSEt93+GO9Ia2iuZKOfA7lhp9JpvAVy61w2mOwO5hmCgMHC1H9O24gu6UD9jP+ZmbtLRaSsei9SL4XDPbAEh/kGQ/pSUcc0lbApFWb67lQUhpVnLBsoKqqZclFMmUtrxPcwxl3X7vOCAtYLSCcugFQmqhdssH7HU+RznjiOlYXA8wqkOfkItTAom+oKygca4ES8jY+N3z7fSG4hfUtp3ihUHruVSsFy1iRvNP+1N7A5BdJACmVpAgZPhGOyCigEjlPLudn7kvFtOxuB4g6OjD8UWLRkCZFRwrLCEXJQQhp2K+37lQeBCRX1A7KPQto1prFEmSYn2mB9EAsO+kYfk8KQhZF8yjVz5gp/MztyOUjiW9bCUhEBhKRCCgSis45uQ/PhX/xfFWMgOnWu2gxB0TF/o0kEZ/kCDM1Ts+3RHYnwVUL6XhDFrAswfIB6w6P1MrTulY0sum1VICglKwCEACqvQFCUK3gHcsFQCM/ILayqP1k9JshVqrncMalOYYvgcGAyCvIwuod8YBJQmZpmGJeyRwkGw4n8jJOJQNw3idLFhMRNB0SgASTJyKoy/4ieXCeFfJBUeV2SoAclFyR0bbm1OHTUiN0/DTAwD7zQeM52dqj8VsGEkVE2jKetG7AEhQ0frJAv6RC0trC1skl+IWlNinGLbSaZg7Mc0xfA8MbgF1LQV1z08A2G8+oM7PVF9Ms2GUE0gQyp+Lwu2yagLgR9ZaYpkSypQ6a6Q2DCqzpkvietXIFdoZfuieGmcOD0DeP0HEbBhNwYPmA/L8zJQsATAKnguEqS+XTqkE4YfWWwCUFZTksYAYwZfIBeN9Tw0cjOwu8gDIZqsoSSvhEeQDiiGYFoyWiSDRypWgi69UP5sc5fIcquSCNeXqe2X9ZAHfM7Khe2pcOB+AT41+aO5iRD3QAHBEHd9ctuiBBoANEkbaAw0AR9r9zcUbADYYGGkPNAAcafc3F28A2GBgpD3QAHCk3d9cvAFgg4GR9kADwJF2f3PxBoANBkbaAw0AR9r9zcUbADYYGGkPNAAcafc3F28A2GBgpD3QAHCk3d9cfOxqYJ2au9RdPtdp/khoEOlglDYT39V1PzQFXLsMXAlgt9PCxJKPbufyf8/KHIPfBPAZABf79Xc5XQ0ZQ1Q7360NbxoHrlsDvs5ZRsgo0une06by6X1mZvtP99PNAp4F4LsBXA5gjw8EGTeqaGF4QhzQF80CX7cAvGIdeDYAfhdZ2sTKUcVrpE7nd31N5gj8e2dIo2osk7NZpMdK0Z19tv+bJ4F9K8D1ACj8yfNSikHeg+5Z969m57Y/8/ZP+dPLKZhP/rcA+AYAF7g1oRUhEMUzFMt6eSJfX78b2DkPfM0i8GIAX+uWlAMppreUUErn8p2gzTl+2flg/sDbTkvIOik+CP20//mzwAXzwDcCuNTPJeFXpEpM6QEjIHm/zTF8D7T5gATYNQCe69aAloRTGulfBESBSYNyxR5g/Bhw7hKwZwl4vk9LnM5JmsBzUyDGAX3B8G23Mz/g9BuUa/0IiutfMkj7zwKmngAuXSvOpUvAWYBtF4BTnspIj/O8zPaf7qdvWITw6eZA0JLQEhKEGgxZhUj/dz3NzSKwbR44exnYvVKcy+mM5Km0JhxInUtrGkmzCPicg3W5LMGkQiZZTm9xS9Z3+4m2o8C5c4X15pTKW2Lb+fCx7WLtjYxzqiql29Icw/dA5SqYf6RTTilg+lYCIXmICKQ4IK9wxfSJY8AZK8CuFWDnanEua9ZTAMsaCog3Dt92O/MvnRGBtGwkqKRmMEkqCaa+2k+0LQDTh4rP88UHj74kF1WaATo9QHQ7mmP4HugYhtEKj4PB6ZQ+FS0hQahpldPya1kXTOqNY8DscgG+HavAttUCvBxInitrkgL4lcO33c7spBdM3kAuSnq2nx9gQfAh4JyVwvrxwel2z3p4aMlzH6DM2z/lT+8aB+Q/OT4EEqckWQSBkGD6EQKQnDCLwBSnYgcf32fXioGUFawC4esyu7CXXnDP9tOCsyD4KLB1rmgvX7zfbu2WG/Jtme0/3U/vKxBNAMoi0KcjkATCN3HOEr3UAjDrwOP71rXixYEkeKMFlSX8ocwR6KUXTJ7AaNE2tF8WfA4Ye7Kw1mwvX/yZn+eKnvcrfzC6IK/ObP/pfnpfAGQnySoISBqUXyAASS1AK0JfagWYcRDOrAF66TxZQU7jBOEbM0egH71gcgXSFZAV54NQtj9YcNIpbONCyh8Ygi8CVospApDuB63g92W2/3Q/vW8AsqM4gLIKBBIH8bcJwMCNMX68BTqBb8s6sGWtsIA6jwDk662ZI9CvXjA5A6NVa2t/IAicnC/aGV+8T74IQPm/AmGuBc+8/VP+9IEAyLslAKMV/LgAyIUInfnjwPQqMOOgI/DstQ5Mr7UAqMF8V2YXDqoXXNl+EQQ6N9v29aKdesUpWJZbAPyPme0/3U8fGIDssDid/pUASCvCaXgJmFguAEfgEXT27gDkuwaUg/nbmSMwjF7whvbLhSDL5TwwvdRqo9oqHzACkCB8U2b7T/fThwIgO01T1IMCoAZxGRhbKoAXQUcQTjkI+a4B5e5FzjGsXvCG9gdqrLGFYrpVG/UuHzBOw2/LaXxzbh43DKeoJwlAHqLndSs4udoCoIBHQE45EPk3DuitmYOQoxdctp8+rFwIWsGFYiFFoLGNchcEQC6e+OJC5J2Z7T/dTx/aApYdJ37AyJK/DIwvFxYvWr0IwEn/H1Opco5sveDUhSAAF4HJpQJkWixp6k2n4IYfMGf0amDHev2I8+l4/UbvNw8Eozw72wJePOJ8und7EkKj9ztKGA1/7WwATo44n45pWI3e7/AAGPWZ2QBkYHCU+XTMfGGQmYIxjd7vqOE0+PXzATjifDrKtTZ6v4MP/MlyRj4AR5xPF+VaqZLJF1UzKdPV6P2eLDDr3I58AI44n07ZMARbo/d78gMubWE+AEecT8e9YOn2Uheu0fs9tUCYD8AR59MpG6bR+z21gKfW1gNAz4geRT5dTEZo9H5PPRDmAzBmRM8BJzqfLiYjSKKr0fs9dYBYDwBHmE9XtRfMsIz04aQZ1+j9npygrA+Akqs8wfl0BCCTWRq935MTYL1aVQ8Ao1zlAnAi8+kEQGZTNXq/vYb75Pt/fQAcUT5dBGCj93vyAaxXi+oDoFLyT3A+3Rcavd9eY3xS/z8fgCQX/LPR3SOzkon55jg1eyAfgD8M4NcAPD6aDmBtB1e4NMDNcer1QD4AbwbwxwDe4UvRE9wHZG1gNSXDLlwLNcep1QP5APxzzwj9IIAPnXhT5ORc5EYCA9HNcWr1QD4AmRH6FQBMTSZZH98ZmD5Bh5g1FopiNns1x6nTA/kAvAfAEwDudnI+EvQxPfkEzYfaCXRSBluQMB7YHKdGD+QDsBNBH/9+AkAobqTADGK7Inw1x8nfA/kA7EXQt8kgrGAGMfBxZ5Cv5ji5eyAfgL0I+r68uR0QmUFoBQU8vfNvzXHy9kA9AORoMw7CdGQCjoUZDwL4kv/+8OZ1gJhBIjGDgMh3vTavBc035/RAPgD7JegjODfhiMwgoqeJwNPPTaB6Ezq/hq+sB4AcXeXEP+ZhGVo9vRimIQD5v5oPAZCupgDI9wg8/qz/1Xz55usyeyAfgMMQ9GU2Op4eAchpOIJQQEz/VuPlm6/K7IH6AMjgGzdl6QtyX5jWjpQFevF3lq3xf6yhrOlIAUgQCojR8gmE+l9Nl2++JrMH6gEgR5UA5KYsc+AZmCbQCDi+IvgEQMob1XBEAHIajgBMLV+0kCdws6aGu3zqfkV9AGTwjftg3JRVVRAtHQEXX/wbAcoXP5d5CID8GoJKvqDAloKOoIz/y7x8c3pmD4zhaqwjRzCYyQg5gr2ZgsFTLweWr8XQgsXjbwLWrnNtMlKgNoLBmZAa7PTCAuYIBlMvlWQswwr2UlUw45jdDSx8HbD+Ctd+HVCwePKbgJV9aASDM8Yg59TWFDysYPBtmYK91IbNOHaPA/M7gUXKXA4hWDz79cA8+W0aweCMURj+1HYfcBjBYO54MMY3tGDv8I3nmWSHOzYOLJ0LLPGXAQWLz3oB8MQUsEa16kYwOG8whjh74yJkUMFgbsNlCfYO0epwissVY34bsHw2sEIRkAEEi/dcU0SP5qhF1ggG5w3GEGdXr4L5134Fg4kAjuDQgr1DtDqcUmZETwArZwAru4BVqsv0KVh8/o3F4v0QXZBGMDhvMIY4u3MYhv95Zh+Cu1xBcxuOU/HfeDIq5cv7FuwdotXhlCBXjOXZAnyrO4BV6in0IVh8wStLuWCsUAyvEQzOG5ABz+4eB+R/ewnu/kOP/3G/l4kJTERlljQtIot2e53/IwO2OPl4FLtcnCqAp9cahT56CBZf+LpSLhhz1N5qBIPzBmTAs/sLRHcTDKbiNHdBGGymOC/3hglEvgjAnoK9A7Y4+XgiV4zVWYDAs/etxaubYPFFP1QkLtCIP8neaASD8wZkwLP7AyC/tJNg8L/xLNBu+YBdBXsHbHEFAINcMVamgdWZAoRrfPdXm8KitLdmgYveWAq+2y7iMqfuRjA4b1AGOLt/APJLqwSD3+y5T1yI0AoSbAxMMzGV1o8/My2ro2DvAK2t+GgiV4zj4+3AIwDXtwBrVJeuECze+9aW4Dut4PxkIhYsdetGMDhvoDqcPRgA+SWp4O4veQ5Uv/mAGwR78+6rQq4Yq9PAOi2fA4/vBkKudKVU7VZw77uKvWFuZbtcMNb5v0YwOG9g+jx7cADyi6Pg7gccgIxlcA5TKhaD01yYKBmVFpBZMfx/m2Bvny3t8LGqoqTliZbVI+gMgHwnMAnCIFi897cLAAZ6QyzFzzSCwXkD1OPs4QDIL5XgLmk5JHk/SD5gKdibd38VcsVYGmuBTaAzEHLHgyCcaokB7/1IkUET5IKxwF5pBIPzBqbPs4cHIC/AaeqvPL9pmHxAE+zts6VdLCD/lcgVY3UyWD0Bj1ZwqgCggXA7sPfWAoAJvaEtZBrB4Lyx6efsPADyCtmCvf00s/NnOsgVY3m8BTRZPZuGBUACdArY+5lWDqGmYbIrLHEx0ggG5w1OH2fnA7CPizQfaXqgUw80AGywMdIeaAA40u5vLt4AsMHASHugAeBIu7+5eAPABgMj7YEGgCPt/ubiDQAbDIy0BxoAjrT7m4s3AGwwMNIeaAA40u5vLt4AsMHASHugAeBIu7+5eAPABgMj7YEGgCPt/ubiDQAbDIy0B8ZYNMbkX+ZekpuIiOQrPar+xs889HJg6jZg5jAwvVZ8B+ll9PlO5/Fc/o+ECjnHfi8zYfkvM5ulmp4qJXVqx5deD4zfAkw/CGxdAZgoHfuh131QkaI5hu8Bs4Ds8B0AWLnIRGCBsFfn87JffDMwdjOw5R5g8giwZa34jnQQUwDo99wBfJ4TM7COiNdlaj2rA/jeV/vfDeATAP4UGH8I2Lrc6gc+SHqY4oMZ74VSKM0xfA+UUzB/oBUUCKMl6zSQ/PsXqZD5KQC/A0w/DEwcAcYXgYnVwppwADuBkefnCim90FmBWXwnK87Uen53BI8sbuwqaz9p5UgnQhBS+ZN1zE8Ak0utviCwq8DI8/nx5hi+Bzb4gJzKZE1SEFZZgS9/2pWR/gTAJ4HJQ8DEMWB8ARhfBsaWCwDquwQKvvNgHXvOcYVbPFJPkw+dDxC/W1Y4tWDpw/Rlgo4lo1T4/KxTihDNpJwj3/UiMLXemprjffC7eWpzDN8DlYsQDiKtVxzEqoHkyX9HRizW+nIgaQnvAiaeBCbmC0s4tgSMu2rMePAR9X252jXklaTFU108K0MHav/nvJ6ZxVVk9OI7GR2IZoGQNc/HgbHgIwqILIVujuF7oOMqWFawCoRxkfEIB5CWgkREBCNf9wMTc8A4QciBWyoGz16rwNgaML5eWKpctYZL3N+TWLX0gvtuP0HHk2n16JDyxXmVhfU0qywbJbr5GSuXKxA/sV5Y9UYWdnjwyS3qKKgarWA69Wg6fjQOIK0HadnIjPVFB+AiME4AuiUkCFnESyCSkmAuU7Cjm15wX+2X2ifBRn9A8mKcW2UFjULVQcgVDl80u40SYh763FfvquhLCxitoBYUsoJfjXKttByMq9CKcHn4sPuCbgXNJwyWkECcz5Q376UX3LNncZyQAAADEklEQVT9fFgIJs6lBBwtn3Tt6FpIz4RWnuQxPh2XIGzm4CwQ9hWIFgBTK0gQHiIAJddKq0ELQh+KL1qUR4MvSEsoENIKrgALHNiMox+94K7tl9qnnMio8MSf6SNwGpYVjCDk/Ju7isq496fCqX0BkDeqlWwKwic1gAQSpzGREnFgREz01eALLvvq2Kfi45m6cf3qBXdsfxRbJMho8dimqOhEK8cXQRr9QVpvPoDNMXQP9A3ACELFxPh+jACkP0fLIKFCCRRqKuPUdqjlC9o07JZwKVNHeBC94DQcZO0XAAkmgotAk9QYrR9f/BvByYfMSATDVMzwTXMM3QMDAVAgVHCZ7/MaQK4QZUHiNCbBQlqUw74YCb7gcmYkelC9YFlwvVv7RRAorTuBkECU9asCID9/x9B935zYzyKkqpfiNHxcA0gLQgvBAaPVkCqm3h2AtC5m/RyEqzw/4xhGL3hD++MmslgqCbgUfLKAcRrmTlBzDN0DA1tAXUlWcDm1IOIIJAjlT/Fd05lbFQFwjdtgGcewesFt7Rc/Gx8iWjUCjGCT1YvWT1MwgUqrf3NG45tTbcu0aximWx9xENcEQHGbcYAEwtSXSqY0gnCdgeuMI0cvuGx/FUGgFhwEYrR80QckWN+X0fjm1DwAWv8RgJFilJZBznz0pQg+AZAAlVWh1GvGka0XzB0cCQi30aSGVa9AF62fLOB7MhrfnJoPwPER59Px+o3e76mL5Kwp2G57xPl0kxc3er+nLvyKtLmhfUC78RHn081ONnq/pzcAR5xPR9mRRu/31IVgvgUccT4dNaobvd/TGYAjzqejumqj93s6A3DE+XRUg2VSCjdaGr3fUw+I+VPwiPPpqJjO8J1Nw43e7ymHwHoAKMFd7QErAeEE5NNJMb3R+z3lsGcNzgfgiPPpomJ6o/d76oGwPgCOKJ8uKqY3er+nKwBHmE+noqRG7/fUA199U/AI8+kEwEbv93QHoEhZTnA+nYqSGr3fBoAtaiqBUImdm5hPJwA2er+nKwBHnE+X1gUzSbnR+z11wPj/AeCpPDD3t7rvAAAAAElFTkSuQmCC",uK="uniform sampler2D weightMap;varying vec2 vOffset0;varying vec2 vOffset1;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 a;a.x=texture2D(weightMap,vOffset0).a;a.y=texture2D(weightMap,vOffset1).g;a.wz=texture2D(weightMap,uv).rb;vec4 color=inputColor;if(dot(a,vec4(1.0))>=1e-5){bool h=max(a.x,a.z)>max(a.y,a.w);vec4 blendingOffset=vec4(0.0,a.y,0.0,a.w);vec2 blendingWeight=a.yw;movec(bvec4(h),blendingOffset,vec4(a.x,0.0,a.z,0.0));movec(bvec2(h),blendingWeight,a.xz);blendingWeight/=dot(blendingWeight,vec2(1.0));vec4 blendingCoord=blendingOffset*vec4(texelSize,-texelSize)+uv.xyxy;color=blendingWeight.x*texture2D(inputBuffer,blendingCoord.xy);color+=blendingWeight.y*texture2D(inputBuffer,blendingCoord.zw);}outputColor=color;}",pK="varying vec2 vOffset0;varying vec2 vOffset1;void mainSupport(const in vec2 uv){vOffset0=uv+texelSize*vec2(1.0,0.0);vOffset1=uv+texelSize*vec2(0.0,1.0);}",jo={LOW:0,MEDIUM:1,HIGH:2,ULTRA:3},WT=class extends Oa{constructor({preset:e=jo.MEDIUM,edgeDetectionMode:t=pm.COLOR,predicationMode:i=lZ.DISABLED}={}){super("SMAAEffect",uK,{vertexShader:pK,blendFunction:Ot.NORMAL,attributes:Aa.CONVOLUTION|Aa.DEPTH,uniforms:new Map([["weightMap",new ye(null)]])});let r,s;arguments.length>1&&(r=arguments[0],s=arguments[1],arguments.length>2&&(e=arguments[2]),arguments.length>3&&(t=arguments[3])),this.renderTargetEdges=new Pt(1,1,{minFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetEdges.texture.name="SMAA.Edges",this.renderTargetWeights=this.renderTargetEdges.clone(),this.renderTargetWeights.texture.name="SMAA.Weights",this.uniforms.get("weightMap").value=this.renderTargetWeights.texture,this.clearPass=new K1(!0,!1,!1),this.clearPass.overrideClearColor=new et(0),this.clearPass.overrideClearAlpha=1,this.edgeDetectionPass=new xs(new hZ),this.edgeDetectionMaterial.edgeDetectionMode=t,this.edgeDetectionMaterial.predicationMode=i,this.weightsPass=new xs(new yZ);let a=new UM;a.onLoad=()=>{let n=new ci(r);n.name="SMAA.Search",n.magFilter=_t,n.minFilter=_t,n.generateMipmaps=!1,n.needsUpdate=!0,n.flipY=!0,this.weightsMaterial.searchTexture=n;let o=new ci(s);o.name="SMAA.Area",o.magFilter=xt,o.minFilter=xt,o.generateMipmaps=!1,o.needsUpdate=!0,o.flipY=!1,this.weightsMaterial.areaTexture=o,this.dispatchEvent({type:"load"})},a.itemStart("search"),a.itemStart("area"),r!==void 0&&s!==void 0?(a.itemEnd("search"),a.itemEnd("area")):typeof Image<"u"&&(r=new Image,s=new Image,r.addEventListener("load",()=>a.itemEnd("search")),s.addEventListener("load",()=>a.itemEnd("area")),r.src=dA,s.src=uA),this.applyPreset(e)}get edgesTexture(){return this.renderTargetEdges.texture}getEdgesTexture(){return this.edgesTexture}get weightsTexture(){return this.renderTargetWeights.texture}getWeightsTexture(){return this.weightsTexture}get edgeDetectionMaterial(){return this.edgeDetectionPass.fullscreenMaterial}get colorEdgesMaterial(){return this.edgeDetectionMaterial}getEdgeDetectionMaterial(){return this.edgeDetectionMaterial}get weightsMaterial(){return this.weightsPass.fullscreenMaterial}getWeightsMaterial(){return this.weightsMaterial}setEdgeDetectionThreshold(e){this.edgeDetectionMaterial.edgeDetectionThreshold=e}setOrthogonalSearchSteps(e){this.weightsMaterial.orthogonalSearchSteps=e}applyPreset(e){let t=this.edgeDetectionMaterial,i=this.weightsMaterial;switch(e){case jo.LOW:t.edgeDetectionThreshold=.15,i.orthogonalSearchSteps=4,i.diagonalDetection=!1,i.cornerDetection=!1;break;case jo.MEDIUM:t.edgeDetectionThreshold=.1,i.orthogonalSearchSteps=8,i.diagonalDetection=!1,i.cornerDetection=!1;break;case jo.HIGH:t.edgeDetectionThreshold=.1,i.orthogonalSearchSteps=16,i.diagonalSearchSteps=8,i.cornerRounding=25,i.diagonalDetection=!0,i.cornerDetection=!0;break;case jo.ULTRA:t.edgeDetectionThreshold=.05,i.orthogonalSearchSteps=32,i.diagonalSearchSteps=16,i.cornerRounding=25,i.diagonalDetection=!0,i.cornerDetection=!0;break}}setDepthTexture(e,t=_n){this.edgeDetectionMaterial.depthBuffer=e,this.edgeDetectionMaterial.depthPacking=t}update(e,t,i){this.clearPass.render(e,this.renderTargetEdges),this.edgeDetectionPass.render(e,t,this.renderTargetEdges),this.weightsPass.render(e,this.renderTargetEdges,this.renderTargetWeights)}setSize(e,t){this.edgeDetectionMaterial.setSize(e,t),this.weightsMaterial.setSize(e,t),this.renderTargetEdges.setSize(e,t),this.renderTargetWeights.setSize(e,t)}dispose(){let{searchTexture:e,areaTexture:t}=this.weightsMaterial;e!==null&&t!==null&&(e.dispose(),t.dispose()),super.dispose()}static get searchImageDataURL(){return dA}static get areaImageDataURL(){return uA}},fK=`uniform float offset;uniform float darkness;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){const vec2 center=vec2(0.5);vec3 color=inputColor.rgb;
  5315. #if VIGNETTE_TECHNIQUE == 0
  5316. float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset));
  5317. #else
  5318. vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord));
  5319. #endif
  5320. outputColor=vec4(color,inputColor.a);}`,hp={DEFAULT:0,ESKIL:1},mK=class extends Oa{constructor({blendFunction:e=Ot.NORMAL,technique:t=hp.DEFAULT,eskil:i=!1,offset:r=.5,darkness:s=.5}={}){super("VignetteEffect",fK,{blendFunction:e,defines:new Map([["VIGNETTE_TECHNIQUE",t.toFixed(0)]]),uniforms:new Map([["offset",new ye(r)],["darkness",new ye(s)]])})}get technique(){return Number(this.defines.get("VIGNETTE_TECHNIQUE"))}set technique(e){this.technique!==e&&(this.defines.set("VIGNETTE_TECHNIQUE",e.toFixed(0)),this.setChanged())}get eskil(){return this.technique===hp.ESKIL}set eskil(e){this.technique=e?hp.ESKIL:hp.DEFAULT}getTechnique(){return this.technique}setTechnique(e){this.technique=e}get offset(){return this.uniforms.get("offset").value}set offset(e){this.uniforms.get("offset").value=e}getOffset(){return this.offset}setOffset(e){this.offset=e}get darkness(){return this.uniforms.get("darkness").value}set darkness(e){this.uniforms.get("darkness").value=e}getDarkness(){return this.darkness}setDarkness(e){this.darkness=e}},Sn=class{constructor(e,t){this.enabled=!1,this.effect=new e(t),Object.defineProperty(this,"opacity",{enumerable:!0,set(i){this.effect.blendMode.opacity.value=i},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(i){this.effect.blendMode.setBlendFunction(Number(i))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=Ot.NORMAL}},gK=class extends Sn{constructor(){super(ZZ),this.blendFunction=Ot.SCREEN}set intensity(e){this.effect.intensity=e}get intensity(){return this.effect.intensity}set luminanceThreshold(e){this.effect.luminanceMaterial.threshold=e}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(e){this.effect.luminanceMaterial.smoothing=e}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(e){this.effect.blurPass.scale=e}get blurScale(){return this.effect.blurPass.scale}set kernelSize(e){this.effect.blurPass.kernelSize=e}get kernelSize(){return this.effect.blurPass.kernelSize}},vK=class extends Sn{constructor(){super(JZ)}set contrast(e){this.effect.uniforms.get("contrast").value=e}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(e){this.effect.uniforms.get("brightness").value=e}get brightness(){return this.effect.uniforms.get("brightness").value}},yK=class extends Sn{constructor(){super(rK),this.effect.offset=new j(.01,.01)}set offset(e){this.effect.offset.set(e[0]/1e3,e[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}},xK=class extends Sn{constructor(){super(eK)}},bK=class extends Sn{constructor(){super(oK),this._hue=0}set hue(e){this._hue=e,this.effect.setHue(e)}get hue(){return this._hue}set saturation(e){this.effect.uniforms.get("saturation").value=e}get saturation(){return this.effect.uniforms.get("saturation").value}},wK=class extends Sn{constructor(){super(hK),this.blendFunction=Ot.OVERLAY}},_K=class extends Sn{constructor(){super(mK)}get eskil(){return this.effect.eskil}set eskil(e){this.effect.eskil=e}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(e){this.effect.uniforms.get("darkness").value=e}get offset(){return this.effect.uniforms.get("offset").value}set offset(e){this.effect.uniforms.get("offset").value=e}},SK=class extends Sn{constructor(e){super(aK)}set focalLength(e){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=e/2e3}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(e){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=this.isPerspectiveCamera?e/2e3:(e+992)/2e3}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(e){this.effect.bokehScale=e}setCamera(e){let t=!1;(e.isPerspectiveCamera&&this.isPerspectiveCamera===!1||!e.isPerspectiveCamera&&this.isPerspectiveCamera===!0)&&(t=!0),e.isPerspectiveCamera?(this.effect.circleOfConfusionMaterial.adoptCameraSettings(e.perspCamera),this.isPerspectiveCamera=!0):(this.effect.circleOfConfusionMaterial.adoptCameraSettings(e),this.isPerspectiveCamera=!1),t&&this.effect.setChanged()}},AK=class extends Sn{constructor(){super(dK)}get granularity(){return this.effect.getGranularity()}set granularity(e){this.effect.setGranularity(e)}},MK=`#define GLSLIFY 1
  5321. varying vec2 vUv;varying vec2 vTexCoords[9];uniform vec2 resolution;void main(){vUv=position.xy*0.5+0.5;vec2 texelSize=vec2(1.0)/resolution;vTexCoords[0]=vUv+vec2(-texelSize.x,-texelSize.y);vTexCoords[1]=vUv+vec2(0.0,-texelSize.y);vTexCoords[2]=vUv+vec2(texelSize.x,-texelSize.y);vTexCoords[3]=vUv+vec2(-texelSize.x,0.0);vTexCoords[4]=vUv+vec2(0.0,0.0);vTexCoords[5]=vUv+vec2(texelSize.x,0.0);vTexCoords[6]=vUv+vec2(-texelSize.x,texelSize.y);vTexCoords[7]=vUv+vec2(0.0,texelSize.y);vTexCoords[8]=vUv+vec2(texelSize.x,texelSize.y);gl_Position=vec4(position.xy,1.0,1.0);}`,EK=`#define GLSLIFY 1
  5322. #include <common>
  5323. varying vec2 vUv;varying vec2 vTexCoords[9];uniform sampler2D inputBuffer;uniform sampler2D historyBuffer;uniform sampler2D velocityBuffer;uniform sampler2D depthBuffer;uniform vec2 resolution;
  5324. #define USE_YCOCG
  5325. #define USE_CATMULL_ROM
  5326. const float feedback_min=0.5;const float feedback_max=0.95;vec3 RGB_YCoCg(vec3 c){return vec3(c.x/4.0+c.y/2.0+c.z/4.0,c.x/2.0-c.z/2.0,-c.x/4.0+c.y/2.0-c.z/4.0);}vec3 YCoCg_RGB(vec3 c){return clamp(vec3(c.x+c.y-c.z,c.x+c.z,c.x-c.y-c.z),vec3(0.0),vec3(1.0));}vec4 sample_color(sampler2D tex,vec2 uv){
  5327. #ifdef USE_YCOCG
  5328. vec4 c=texture(tex,uv);return vec4(RGB_YCoCg(c.rgb),c.a);
  5329. #else
  5330. return texture(tex,uv);
  5331. #endif
  5332. }vec4 sample_catmull_rom(sampler2D tex,vec2 uv,vec2 texSize){vec2 samplePos=uv*texSize;vec2 texPos1=floor(samplePos-0.5)+0.5;vec2 f=samplePos-texPos1;vec2 w0=f*(-0.5+f*(1.0-0.5*f));vec2 w1=1.0+f*f*(-2.5+1.5*f);vec2 w2=f*(0.5+f*(2.0-1.5*f));vec2 w3=f*f*(-0.5+0.5*f);vec2 w12=w1+w2;vec2 offset12=w2/(w1+w2);vec2 texPos0=texPos1-1.0;vec2 texPos3=texPos1+2.0;vec2 texPos12=texPos1+offset12;texPos0/=texSize;texPos3/=texSize;texPos12/=texSize;vec4 result=vec4(0.0);result+=texture2D(tex,vec2(texPos12.x,texPos0.y))*w12.x*w0.y;result+=texture2D(tex,vec2(texPos0.x,texPos12.y))*w0.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos12.y))*w12.x*w12.y;result+=texture2D(tex,vec2(texPos3.x,texPos12.y))*w3.x*w12.y;result+=texture2D(tex,vec2(texPos12.x,texPos3.y))*w12.x*w3.y;return result;}vec3 choose_motion_vector(){
  5333. #ifdef CHOOSE_LONGEST_MOTION_VECTOR
  5334. float longest=-1.0;vec3 v_choose=vec3(-1.0);for(int i=0;i<9;i++){vec3 v=texture2D(velocityBuffer,vTexCoords[i]).rgb;float l=length(v.xy);if(l>longest){longest=l;v_choose=v;}}return v_choose;
  5335. #else
  5336. float closest_depth=1000.0;vec2 closest_uv_offset=vec2(0.0);for(int i=0;i<9;i++){float neighbor_depth=texture2D(depthBuffer,vTexCoords[i]).r;if(neighbor_depth<closest_depth){closest_uv_offset=vTexCoords[i];closest_depth=neighbor_depth;}}return texture2D(velocityBuffer,closest_uv_offset).rgb;
  5337. #endif
  5338. }vec4 clipAabb(vec3 aabb_min,vec3 aabb_max,vec4 avg,vec4 input_texel){const float FLT_EPS=0.00000001;vec3 p_clip=0.5*(aabb_max+aabb_min);vec3 e_clip=0.5*(aabb_max-aabb_min)+FLT_EPS;vec4 v_clip=input_texel-vec4(p_clip,avg.w);vec3 v_unit=v_clip.xyz/e_clip;vec3 a_unit=abs(v_unit);float ma_unit=max(a_unit.x,max(a_unit.y,a_unit.z));if(ma_unit>1.0){return vec4(p_clip,avg.w)+v_clip/ma_unit;}else{return input_texel;}}vec3 clip_aabb_variance(in vec3 cOld,in vec3 cNew,in vec3 centre,in vec3 halfSize){if(all(lessThanEqual(abs(cOld-centre),halfSize))){return cOld;}vec3 dir=(cNew-cOld);vec3 near=centre-sign(dir)*halfSize;vec3 tAll=(near-cOld)/dir;float t=0.0001;for(int i=0;i<3;i++){if(tAll[i]>=0.0&&tAll[i]<t){t=tAll[i];}}if(t>=0.0001){return cOld;}return cOld+dir*t;}void main(){vec3 v=choose_motion_vector();vec2 velocity=v.rg;vec2 previousPixelPos=vUv-velocity;vec4 currentColor=sample_color(inputBuffer,vUv);
  5339. #ifdef USE_CATMULL_ROM
  5340. vec4 previousColor=sample_catmull_rom(historyBuffer,previousPixelPos,resolution);
  5341. #else
  5342. vec4 previousColor=sample_color(historyBuffer,previousPixelPos);
  5343. #endif
  5344. #ifdef USE_YCOCG
  5345. previousColor=vec4(RGB_YCoCg(previousColor.rgb),previousColor.a);
  5346. #endif
  5347. vec4 ctl=sample_color(inputBuffer,vTexCoords[0]);vec4 ctc=sample_color(inputBuffer,vTexCoords[1]);vec4 ctr=sample_color(inputBuffer,vTexCoords[2]);vec4 cml=sample_color(inputBuffer,vTexCoords[3]);vec4 cmc=sample_color(inputBuffer,vTexCoords[4]);vec4 cmr=sample_color(inputBuffer,vTexCoords[5]);vec4 cbl=sample_color(inputBuffer,vTexCoords[6]);vec4 cbc=sample_color(inputBuffer,vTexCoords[7]);vec4 cbr=sample_color(inputBuffer,vTexCoords[8]);vec4 cmin=min(ctl,min(ctc,min(ctr,min(cml,min(cmc,min(cmr,min(cbl,min(cbc,cbr))))))));vec4 cmax=max(ctl,max(ctc,max(ctr,max(cml,max(cmc,max(cmr,max(cbl,max(cbc,cbr))))))));vec4 cavg=(ctl+ctc+ctr+cml+cmc+cmr+cbl+cbc+cbr)/9.0;vec4 cmin5=min(ctc,min(cml,min(cmc,min(cmr,cbc))));vec4 cmax5=max(ctc,max(cml,max(cmc,max(cmr,cbc))));vec4 cavg5=(ctc+cml+cmc+cmr+cbc)/5.0;cmin=0.5*(cmin+cmin5);cmax=0.5*(cmax+cmax5);cavg=0.5*(cavg+cavg5);
  5348. #ifdef USE_YCOCG
  5349. vec2 chroma_extent=vec2(0.25*0.5*(cmax.r-cmin.r));vec2 chroma_center=currentColor.gb;cmin.yz=chroma_center-chroma_extent;cmax.yz=chroma_center+chroma_extent;cavg.yz=chroma_center;
  5350. #endif
  5351. vec4 previousColorClipped=clamp(previousColor,cmin,cmax);
  5352. #ifdef LUMINANCE_DIFFERENCES
  5353. #ifdef USE_YCOCG
  5354. float lum0=currentColor.r;float lum1=previousColorClipped.r;
  5355. #else
  5356. float lum0=luminance(currentColor.rgb);float lum1=luminance(previousColorClipped.rgb);
  5357. #endif
  5358. float unbiased_diff=abs(lum0-lum1)/max(lum0,max(lum1,0.2));float unbiased_weight=1.0-unbiased_diff;float unbiased_weight_sqr=unbiased_weight*unbiased_weight;float k_feedback=mix(feedback_min,feedback_max,unbiased_weight_sqr);vec4 result=mix(currentColor,previousColorClipped,vec4(k_feedback));
  5359. #else
  5360. const float alpha=0.1;vec4 result=mix(currentColor,previousColorClipped,1.0-alpha);
  5361. #endif
  5362. #ifdef USE_YCOCG
  5363. gl_FragColor=vec4(YCoCg_RGB(result.rgb).rgb,result.a);
  5364. #else
  5365. gl_FragColor=result;
  5366. #endif
  5367. }`,CK=`#define GLSLIFY 1
  5368. varying vec2 vUv;void main(){gl_Position=vec4(position.xy,1.0,1.0);vUv=position.xy*0.5+0.5;}`,TK=`#define GLSLIFY 1
  5369. layout(location=1)out vec4 gVelocity;varying vec2 vUv;uniform sampler2D inputBuffer;void main(){gl_FragColor=texture2D(inputBuffer,vUv);gVelocity=vec4(0.0);}`,fy=class extends Dt{constructor(){super({name:"PassthroughMaterial",uniforms:{inputBuffer:new ye(null)},blending:Oi,depthWrite:!1,depthTest:!1,vertexShader:CK,fragmentShader:TK})}set inputBuffer(e){this.uniforms.inputBuffer.value=e}},PK=class extends jr{constructor(){super("TAAResolvePass"),this.MRTCompatible=!0,this.needsSwap=!1,this.passThroughMaterial=new fy,this.resolutionVector=new j,this.resolveMaterial=new Dt({name:"TAAResolveMaterial",uniforms:{inputBuffer:new ye(null),historyBuffer:new ye(null),velocityBuffer:new ye(null),depthBuffer:new ye(null),resolution:new ye(new j)},blending:Oi,depthWrite:!1,depthTest:!1,vertexShader:MK,fragmentShader:EK}),this.historyRenderTarget=new Pt(1024,1024,{minFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.historyRenderTarget.texture.name="TAA.History",this.resultRenderTarget=new Pt(1024,1024,{minFilter:xt,stencilBuffer:!1,depthBuffer:!1}),this.resultRenderTarget.texture.name="TAA.Output"}setSize(e,t){this.historyRenderTarget.setSize(e,t),this.resultRenderTarget.setSize(e,t)}render(e,t){this.fullscreenMaterial=this.resolveMaterial,this.resolveMaterial.uniforms.inputBuffer.value=t.texture[0],this.resolveMaterial.uniforms.velocityBuffer.value=t.texture[1],this.resolveMaterial.uniforms.depthBuffer.value=t.depthTexture,this.resolveMaterial.uniforms.historyBuffer.value=this.historyRenderTarget.texture,this.resolveMaterial.uniforms.resolution.value.set(t.width,t.height),e.setRenderTarget(this.resultRenderTarget),e.render(this.scene,this.camera),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(this.historyRenderTarget),e.render(this.scene,this.camera);let i=this.renderToScreen?null:t;this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=this.resultRenderTarget.texture,e.setRenderTarget(i),e.render(this.scene,this.camera)}dispose(){this.resultRenderTarget.dispose(),this.historyRenderTarget.dispose(),this.resolveMaterial.dispose(),this.passThroughMaterial.dispose()}},DK=class extends jr{constructor(e,t,i){super("TransmissionPass",void 0,t),this.MRTCompatible=!0,this.depthPass=new hA(e,t,{renderTarget:i.transmissionDepthTarget}),this.passThroughMaterial=new fy,this.splineScene=e,this.needsSwap=!1}updatePasses(e){this.passThroughMaterial=new fy,this.depthPass=new hA(this.splineScene,this.camera,{renderTarget:e.transmissionDepthTarget})}setCamera(e){this.camera=e}setScene(e){this.splineScene=e}render(e,t,i){let r=this.camera.layers.mask,s=e;s.setRenderTarget(s.transmissionRenderTarget),this.fullscreenMaterial=this.passThroughMaterial,this.passThroughMaterial.inputBuffer=t.texture[0],s.clear(),s.render(this.scene,this.camera),this.camera.layers.disable(3),this.depthPass.render(e,t,i),s.shadowMap.needsUpdate=!1,s.shadowMap.autoUpdate=!1;let a=this.renderToScreen?null:t;this.camera.layers.set(3),e.setRenderTarget(a),e.render(this.splineScene,this.camera),this.camera.layers.mask=r}},pA=new Jr,IK=new Dt({transparent:!0,vertexShader:`
  5370. void main() {
  5371. gl_Position = vec4(0.0);
  5372. }
  5373. `,fragmentShader:`
  5374. layout(location = 1) out vec4 gVelocity;
  5375. void main() {
  5376. gl_FragColor = vec4(0.0);
  5377. gVelocity = vec4(0.0);
  5378. }
  5379. `}),my=class extends jr{constructor(e,t,i){super("OpaquePass",t??pA,i),this.MRTCompatible=!0,this.originalMaterials=[],this.hasTransmissionPass=!1,this.clear=!0,this.clearColorOnly=!1,this.clearDepth=!1,this.needsSwap=!1,this.MRTCompatible=e}setCamera(e){this.camera=e}setScene(e){this.scene=e??pA}getScene(){return this.scene}render(e,t){this.camera.layers.enable(3),this.hasTransmissionPass&&(this.originalMaterials.length=0,this.scene.traverse(r=>{r.layers.isEnabled(3)&&r instanceof Vr&&(this.originalMaterials.push([r,r.material]),r.material=IK)}),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0),this.camera.layers.enable(8);let i=this.renderToScreen?null:t;e.setRenderTarget(i),this.clearColorOnly&&e.clear(!0,!1,!0),this.clear&&e.clear(),e.render(this.scene,this.camera),this.clearDepth&&e.clear(!1,!0,!1),this.hasTransmissionPass&&this.originalMaterials.forEach(r=>{r[0].material=r[1]})}},OK=class{constructor(e,{depthBuffer:t=!0,stencilBuffer:i=!1,multisampling:r=0,frameBufferType:s=0}={}){this.renderer=e,this.helperStartIndex=0,this.copyPass=new py,this.depthTexture=null,this.timer=new YZ,this._width=1,this._height=1,this.passes=[],this.helperPasses=[],this.autoRenderToScreen=!0,this.inputBuffer=this.createBuffer(t,i,s,r,!0,"input buffer mrt"),this.inputBufferSingle=this.createBuffer(t,i,s,r,!1," input buffer single"),this.inputBufferSingle.texture.dispose(),this.inputBufferSingle.depthTexture.dispose(),this.inputBufferSingle.texture=this.inputBuffer.texture[0],this.inputBufferSingle.depthTexture=this.inputBuffer.depthTexture,this.outputBuffer=this.inputBuffer.clone(),this.outputBuffer.name="output buffer mrt",this.outputBufferSingle=this.createBuffer(t,i,s,r,!1,"output buffer single"),this.outputBufferSingle.texture.dispose(),this.outputBufferSingle.depthTexture.dispose(),this.outputBufferSingle.texture=this.outputBuffer.texture[0],this.outputBufferSingle.depthTexture=this.outputBuffer.depthTexture,this.setRenderer(e)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(e){let t=this.inputBuffer,i=this.multisampling;i>0&&e>0?(this.inputBuffer.samples=e,this.outputBuffer.samples=e,this.inputBuffer.dispose(),this.outputBuffer.dispose()):i!==e&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("creating new input buffer"),this.inputBuffer=this.createBuffer(t.depthBuffer,t.stencilBuffer,t.texture.type,e,!0,"new input buffer"),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(e){var t;if(this.renderer=e,e!==null){let i=e.getSize(new j),r=((t=e.getContext().getContextAttributes())==null?void 0:t.alpha)??!1,s=this.inputBuffer.texture[0].type;s===Er&&e.outputEncoding===gt&&(this.inputBuffer.texture[0].encoding=gt,this.outputBuffer.texture[0].encoding=gt,this.inputBuffer.dispose(),this.outputBuffer.dispose(),console.log("doing some kinda dispose??")),e.autoClear=!1,this.setSize(i.width,i.height,!1);for(let a of this.passes)a.initialize(e,r,s)}}replaceRenderer(e,t=!0){let i=this.renderer,r=i.domElement.parentNode;return this.setRenderer(e),t&&r!==null&&(r.removeChild(i.domElement),r.appendChild(e.domElement)),i}createDepthTexture(){let e=this.depthTexture=new Ph(this._width,this._height);return this.inputBuffer.depthTexture=e,this.inputBuffer.stencilBuffer?(e.format=ol,e.type=$o):e.type=on,e}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(let e of this.passes)e.setDepthTexture(null)}}createBuffer(e,t,i,r,s,a){let n=this.renderer,o=n===null?new j:n.getDrawingBufferSize(new j),l={minFilter:xt,magFilter:xt,wrapS:ai,wrapT:ai,stencilBuffer:t,depthBuffer:e},h;return r>0?(h=new Pt(o.width,o.height,l),h.samples=r):(s?(h=new dM(o.width,o.height,2,l),h.texture[1].type=mn):h=new Pt(o.width,o.height,l),h.depthTexture=new Ph(2048,2048),h.depthTexture.type=jt),i===Er&&n!==null&&n.outputEncoding===gt&&(Array.isArray(h.texture)?h.texture.forEach(c=>c.encoding=gt):h.texture.encoding=gt),Array.isArray(h.texture)?h.texture.forEach((c,d)=>{c.name=`EffectComposer.Buffer ${s} ${d}`,c.generateMipmaps=!1}):(h.texture.name=`EffectComposer.Buffer ${s}`,h.texture.generateMipmaps=!1),h.name=a,h}addPass(e,t){var o;let i=this.passes,r=this.renderer,s=r.getDrawingBufferSize(new j),a=((o=r.getContext().getContextAttributes())==null?void 0:o.alpha)??!1,n;if(e.MRTCompatible&&(n=this.inputBuffer.texture[0].type),e.MRTCompatible||(n=this.inputBuffer.texture.type),e.setRenderer(r),e.setSize(s.width,s.height),e.initialize(r,a,n),this.autoRenderToScreen&&(i.length>0&&(i[i.length-1].renderToScreen=!1),e.renderToScreen&&(this.autoRenderToScreen=!1)),t!==void 0?i.splice(t,0,e):i.push(e),this.autoRenderToScreen&&(i[i.length-1].renderToScreen=!0),e.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){let l=this.createDepthTexture();for(e of i)e.setDepthTexture(l)}else e.setDepthTexture(this.depthTexture)}setHelperStartIndex(e){this.helperStartIndex=e}removePass(e){let t=this.passes,i=t.indexOf(e);if(i!==-1&&t.splice(i,1).length>0){if(this.depthTexture!==null){let r=(s,a)=>s||a.needsDepthTexture;t.reduce(r,!1)||e.getDepthTexture()===this.depthTexture&&e.setDepthTexture(null)}this.autoRenderToScreen&&i===t.length&&(e.renderToScreen=!1,t.length>0&&(t[t.length-1].renderToScreen=!0))}}removeAllPasses(){let e=this.passes;e.length>0&&(this.autoRenderToScreen&&(e[e.length-1].renderToScreen=!1),this.passes=[])}render(e){let t=this.renderer,i=this.copyPass,r=this.inputBuffer,s=this.outputBuffer,a=this.inputBufferSingle,n=this.outputBufferSingle,o=!1,l,h,c,d;e===void 0&&(e=this.timer.update().getDelta());for(let u of this.passes)u.enabled&&(u.MRTCompatible?u.render(t,r,s,e,o):u.render(t,a,n,e,o),u.needsSwap&&(o&&(i.renderToScreen=u.renderToScreen,l=t.getContext(),h=t.state.buffers.stencil,h.setFunc(l.NOTEQUAL,1,4294967295),i.render(t,r,s,e,o),h.setFunc(l.EQUAL,1,4294967295)),c=r,d=a,r=s,a=n,s=c,n=d),u instanceof qZ?o=!0:u instanceof wZ&&(o=!1))}setSize(e,t,i){let r=this.renderer;if(this._width=e,this._height=t,e===void 0||t===void 0){let a=r.getSize(new j);e=a.width,t=a.height}r.setSize(e,t,i);let s=r.getDrawingBufferSize(new j);this.inputBuffer.setSize(s.width,s.height),this.outputBuffer.setSize(s.width,s.height),this.inputBufferSingle.setSize(s.width,s.height),this.outputBufferSingle.setSize(s.width,s.height);for(let a of this.passes)a.setSize(s.width,s.height)}reset(){let e=this.timer.isAutoResetEnabled();this.dispose(),this.autoRenderToScreen=!0,this.timer.setAutoResetEnabled(e)}dispose(){for(let e of this.passes)e.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.inputBufferSingle!==null&&this.inputBufferSingle.dispose(),this.outputBufferSingle!==null&&this.outputBufferSingle.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose()}},RK=new Dt({name:"CombineMaterial",uniforms:{inputBufferA:new ye(null),inputBufferB:new ye(null)},blending:Oi,depthWrite:!1,depthTest:!1,vertexShader:`
  5380. varying vec2 vUv;
  5381. void main() {
  5382. gl_Position = vec4(position.xy, 1.0, 1.0);
  5383. vUv = position.xy * 0.5 + 0.5;
  5384. }
  5385. `,fragmentShader:`
  5386. varying vec2 vUv;
  5387. uniform sampler2D inputBufferA;
  5388. uniform sampler2D inputBufferB;
  5389. // TODO: Why do we need these when postpro of framemode is enabled???
  5390. layout(location = 1) out vec4 gVelocity;
  5391. void main() {
  5392. vec4 resA = texture2D(inputBufferA, vUv);
  5393. vec4 resB = texture2D(inputBufferB, vUv);
  5394. float a = resA.a + resB.a * ( 1.0 - resA.a );
  5395. vec4 res;
  5396. res.rgb = resA.rgb + (resB.rgb * (1.0 - resA.a));
  5397. res.a = resA.a + resB.a * (1.0 - resA.a);
  5398. gl_FragColor = res;
  5399. gVelocity = vec4(0.0);
  5400. }
  5401. `}),LK=class extends jr{constructor(e){super("HelperPass",void 0,e),this.MRTCompatible=!1,this.fullscreenMaterial=RK,this.helperPass=new my(!1,void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperPass.renderToScreen=!1,this.helperPassOnTop=new my(!1,void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this.helperPassOnTop.renderToScreen=!1;let t=new WT({preset:jo.LOW,edgeDetectionMode:pm.COLOR});this.effectPass=new Bf(this.camera,t),this.rt=new Pt(10,10,{minFilter:xt,magFilter:xt,wrapS:ai,wrapT:ai,depthBuffer:!0})}setSize(e,t){this.rt.setSize(e,t),this.effectPass.setSize(e,t)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}setCamera(e){this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}initialize(e,t,i){super.initialize(e,t,i),this.effectPass.initialize(e,t,i)}dispose(){super.dispose(),this.rt.dispose(),this.effectPass.dispose()}render(e,t,i){this.rt.depthTexture=t.depthTexture;let r=e.getClearAlpha();e.setClearAlpha(0),this.helperPass.clearDepth=!0,this.helperPass.clearColorOnly=!0,this.helperPass.render(e,this.rt),this.helperPassOnTop.render(e,this.rt),this.effectPass.renderToScreen=!1,this.effectPass.render(e,this.rt,i),this.fullscreenMaterial.uniforms.inputBufferA.value=i.texture,this.fullscreenMaterial.uniforms.inputBufferB.value=t.texture,e.setClearAlpha(r),e.setRenderTarget(null),e.clear(),e.render(this.scene,this.camera)}},zK=`#define GLSLIFY 1
  5402. #include <skinning_pars_vertex>
  5403. #include <morphtarget_pars_vertex>
  5404. out vec3 n;void main(){
  5405. #include <beginnormal_vertex>
  5406. #include <morphnormal_vertex>
  5407. #include <skinbase_vertex>
  5408. #include <skinnormal_vertex>
  5409. #include <defaultnormal_vertex>
  5410. #include <begin_vertex>
  5411. #include <morphtarget_vertex>
  5412. #include <skinning_vertex>
  5413. vec4 view_space=viewMatrix*modelMatrix*vec4(transformed,1.0);gl_Position=projectionMatrix*view_space;n=normalize(transformedNormal);}`,BK=`#define GLSLIFY 1
  5414. in vec3 n;void main(){gl_FragColor=vec4(n,1.0);}`,FK=`#define GLSLIFY 1
  5415. out vec2 v_uv;void main(){v_uv=uv;gl_Position=vec4(position.xy,1.0,1.0);}`,UK=`#define GLSLIFY 1
  5416. in vec2 v_uv;const float pi=3.14159265;const float num_steps=4.0;const float num_directions=4.0;uniform float near;uniform float far;uniform float fov;uniform vec4 proj_info;uniform bool is_ortho;uniform vec2 resolution;uniform float radius_of_influence;uniform float radius_in_screen_space;uniform float exponent;uniform vec3 ao_color;uniform float bias;uniform sampler2D texture_depth;uniform sampler2D texture_normals;uniform sampler2D texture_blue_noise;uniform sampler2D texture_blue_noise_in_disk;uniform sampler2D texture_color_pass;uniform int frame_index;uniform bool fog_enabled;uniform float fog_near;uniform float fog_far;vec3 uv_to_view_space(vec2 uv,float eye_z){return vec3((uv*proj_info.xy+proj_info.zw)*(is_ortho ? 1.0 : eye_z),eye_z);}float linearize_depth(float depth_sampled){float z=is_ortho ? depth_sampled : depth_sampled*2.0-1.0;return mix((2.0*near*far)/(far+near-z*(far-near)),near+z*(far-near),float(is_ortho));}vec3 get_view_position(vec2 uv_coords){float linear_depth=linearize_depth(texture(texture_depth,uv_coords).x);return uv_to_view_space(uv_coords,linear_depth);}vec3 min_difference(vec3 p,vec3 right,vec3 left){vec3 v1=right-p;vec3 v2=p-left;return(dot(v1,v1)<dot(v2,v2))? v1 : v2;}vec3 rebuild_normal(in vec2 uv,in vec3 p){vec2 one_over_resolution=1.0/resolution;vec3 r=get_view_position(uv+vec2(one_over_resolution.x,0));vec3 l=get_view_position(uv+vec2(-one_over_resolution.x,0));vec3 t=get_view_position(uv+vec2(0,one_over_resolution.y));vec3 b=get_view_position(uv+vec2(0,-one_over_resolution.y));return normalize(cross(min_difference(p,r,l),min_difference(p,t,b)));}float falloff(float distance_squared){float neg_inv_r2=-1.0/(radius_of_influence*radius_of_influence);return distance_squared*neg_inv_r2+1.0;}float ao_contribution(vec3 P,vec3 N,vec3 S){vec3 to_sample=S-P;float norm_squared=dot(to_sample,to_sample);float norm=sqrt(norm_squared);float cos_theta=dot(N,to_sample)/norm;return clamp(cos_theta-bias,0.0,1.0)*clamp(falloff(norm_squared),0.0,1.0);}float compute_ambient_occlusion(vec2 uv,float radius_in_screen_space,vec3 pc,vec3 view_space_n){vec2 one_over_resolution=1.0/resolution;ivec2 noise_uv=ivec2(int(mod(gl_FragCoord.x,128.0)),int(mod(gl_FragCoord.y,128.0)));float noise=texelFetch(texture_blue_noise,noise_uv,0).r;noise=fract(noise+0.61803398875*float(frame_index));float theta=noise*2.0*3.1415;float ct=cos(theta);float st=sin(theta);float step_size=radius_in_screen_space/(num_steps+1.0);const float angle_step=2.0*pi/num_directions;float contribution=0.0;for(int i=0;i<int(num_directions);++i){float current_pixel=step_size+1.0;for(int j=0;j<int(num_steps);++j){int index=i*int(num_steps)+j;vec2 blue_noise_sample=texelFetch(texture_blue_noise_in_disk,ivec2(index,0),0).rg;vec2 disk_point;disk_point.x=blue_noise_sample.x*ct-blue_noise_sample.y*st;disk_point.y=blue_noise_sample.x*st+blue_noise_sample.y*ct;vec2 sample_direction=disk_point;vec2 snapped_uv=round(current_pixel*sample_direction)*one_over_resolution+uv;vec3 ps=get_view_position(snapped_uv);current_pixel+=step_size;contribution+=ao_contribution(pc,view_space_n,ps);}}float mult=1.0/(1.0-bias);contribution*=mult/(num_directions*num_steps);return clamp(1.0-contribution*2.0,0.0,1.0);}
  5417. #define USE_GBUFFER_NORMALS
  5418. void main(){vec3 view_space_p=get_view_position(v_uv);
  5419. #ifdef USE_GBUFFER_NORMALS
  5420. vec3 view_space_n=texture(texture_normals,v_uv).rgb;view_space_n.z*=-1.0;
  5421. #else
  5422. vec3 view_space_n=-rebuild_normal(v_uv,view_space_p);
  5423. #endif
  5424. float radius_ss=radius_in_screen_space/(is_ortho ? 1.0 : view_space_p.z);float ao=compute_ambient_occlusion(v_uv,radius_ss,view_space_p,view_space_n);float final=pow(ao,exponent);if(view_space_p.z>=far){final=1.0;}vec3 color=mix(ao_color,vec3(1.0),final);if(fog_enabled){float fog_factor=smoothstep(fog_near,fog_far,view_space_p.z);color=mix(color,vec3(1.0),fog_factor);}gl_FragColor=vec4(color,1.0);}`,NK=`#define GLSLIFY 1
  5425. out vec2 v_uv;void main(){gl_Position=vec4(position.xy,1.0,1.0);v_uv=uv;}`,kK=`#define GLSLIFY 1
  5426. in vec2 v_uv;uniform sampler2D texture_ao_lrez;uniform sampler2D texture_depth_lrez;uniform sampler2D texture_depth_hrez;uniform float near;uniform float far;float linearize_depth(float depth_sampled){float z=depth_sampled*2.0-1.0;return(2.0*near*far)/(far+near-z*(far-near));}vec2 nearest_depth_filter(in vec2 uv){vec2 resolution=vec2(textureSize(texture_depth_lrez,0));vec2 texel_size=1.0/resolution;vec2 offset=uv-0.5*texel_size;float d_hrez=texture(texture_depth_hrez,uv).r;float a=abs(d_hrez-texture(texture_depth_lrez,offset).r);float b=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,0.0)).r);float c=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(0.0,texel_size.y)).r);float d=abs(d_hrez-texture(texture_depth_lrez,offset+vec2(texel_size.x,texel_size.y)).r);float min_diff=min(a,min(b,min(c,d)));if(min_diff==a)return offset;if(min_diff==b)return offset+vec2(texel_size.x,0.0);if(min_diff==c)return offset+vec2(0.0,texel_size.y);if(min_diff==d)return offset+vec2(texel_size.x,texel_size.y);}void main(){
  5427. #ifdef DEBUG
  5428. float d_lrez=texture(texture_depth_lrez,v_uv).r;float d_hrez=texture(texture_depth_hrez,v_uv).r;float output_d=mix(linearize_depth(d_lrez)/far,linearize_depth(d_hrez)/far,step(0.5,v_uv.x));gl_FragColor=vec4(vec3(output_d),1.0);
  5429. #else
  5430. vec2 filtered_uv=nearest_depth_filter(v_uv);vec4 ao=texture(texture_ao_lrez,filtered_uv);gl_FragColor=vec4(ao.rgb,1.0);gl_FragColor=ao;
  5431. #endif
  5432. }`,Pc=[[.478712,.875764],[-.337956,-.793959],[-.955259,-.028164],[.864527,.325689],[.209342,-.395657],[-.106779,.672585],[.156213,.235113],[-.413644,-.082856],[-.415667,.323909],[.141896,-.93998],[.954932,-.182516],[-.766184,.410799],[-.434912,-.458845],[.415242,-.078724],[.728335,-.491777],[-.058086,-.066401],[.20299,.686837],[-.808362,-.556402],[.507386,-.640839],[-.723494,-.22924],[.48974,.317826],[-.622663,.765301],[-.01064,.929347],[.663146,.647618],[-.096674,-.413835],[.525945,-.321063],[-.122533,.366019],[.195235,-.687983],[-.563203,.098748],[.418563,.561335],[-.378595,.800367],[.826922,.001024],[-.085372,-.766651],[-.92192,.183673],[-.590008,-.721799],[.167751,-.164393],[.032961,-.56253],[.6329,-.107059],[-.46408,.569669],[-.173676,-.958758],[-.242648,-.234303],[-.275362,.157163],[.382295,-.795131],[.562955,.115562],[.190586,.470121],[.770764,-.297576],[.237281,.93105],[-.666642,-.455871],[-.905649,-.298379],[.33952,.157829],[.701438,-.7041],[-.062758,.160346],[-.220674,.957141],[.642692,.432706],[-.77339,-.015272],[-.671467,.24688],[.158051,.062859],[.806009,.527232],[-.05762,-.247071],[.333436,-.51671],[-.550658,-.315773],[-.652078,.589846],[.008818,.530556],[-.210004,.519896]],VK=new Dt({vertexShader:zK,fragmentShader:BK}),Xl=new Dt({vertexShader:NK,fragmentShader:kK,uniforms:{texture_ao_lrez:new ye(null),texture_depth_lrez:new ye(null),texture_depth_hrez:new ye(null),near:new ye(null),far:new ye(null)}}),jK=class extends jr{constructor(e,t){super("AmbientOcclusionPass",void 0,t),this.fogEnabled=!1,this.fogNear=1,this.fogFar=1e3,this.frameIndex=0,this._runHalfRes=!0,this._width=1,this._height=1;let i=1024,r=1024;this.gBuffer=new Pt(i,r,{type:ec?mn:jt,depthTexture:new Ph(i,r),minFilter:xt,magFilter:xt}),this.depthBufferHighRes=new Pt(i,r,{depthTexture:new Ph(i,r)}),this.aoBuffer=new Pt(i,r,{minFilter:xt,magFilter:xt}),this.splineScene=e,this.splineCamera=t;let s=new Float32Array(Pc.length*2);for(let n=0;n<Pc.length;n++){let o=n*2;s[o+0]=Pc[n][0],s[o+1]=Pc[n][1]}this.blueNoiseInDiskTexture=new Ur(s,Pc.length,1,Up,jt),this.blueNoiseInDiskTexture.wrapS=nn,this.blueNoiseInDiskTexture.wrapT=nn,this.blueNoiseInDiskTexture.needsUpdate=!0,this.hbaoMaterial=new Dt({vertexShader:FK,fragmentShader:UK,uniforms:{near:new ye(null),far:new ye(null),fov:new ye(null),proj_info:new ye(new ct),is_ortho:new ye(!1),resolution:new ye(new j),radius_of_influence:new ye(8),radius_in_screen_space:new ye(1),exponent:new ye(1),ao_color:new ye(new M),bias:new ye(.5),texture_depth:new ye(null),texture_normals:new ye(null),texture_blue_noise:new ye(null),texture_blue_noise_in_disk:new ye(this.blueNoiseInDiskTexture),frame_index:new ye(0),fog_enabled:new ye(!1),fog_near:new ye(1),fog_far:new ye(1e3)}}),this.radius=128,this.aoColor={r:0,g:0,b:0},this.bias=.5,this.hbaoMaterial.uniforms.texture_depth.value=this.gBuffer.depthTexture,this.hbaoMaterial.uniforms.texture_normals.value=this.gBuffer.texture,this.needsSwap=!0,this.aaBuffer=new Pt(i,r,{minFilter:xt,magFilter:xt,wrapS:ai,wrapT:ai,depthBuffer:!1,type:jt});let a=new WT({preset:jo.ULTRA,edgeDetectionMode:pm.COLOR});this.effectPass=new Bf(this.camera,a)}initialize(e,t,i){super.initialize(e,t,i),this.effectPass.initialize(e,t,i)}setBlueNoiseTexture(e){this.hbaoMaterial.uniforms.texture_blue_noise.value=e}setSize(e,t){this._width=e,this._height=t,this.depthBufferHighRes.setSize(e,t);let i=this._runHalfRes?.5:1,r=e*i,s=t*i;this.gBuffer.setSize(r,s),this.aoBuffer.setSize(r,s),this.hbaoMaterial.uniforms.resolution.value.set(r,s),this.aaBuffer.setSize(r,s),this.effectPass.setSize(r,s)}get runHalfRes(){return this._runHalfRes}set runHalfRes(e){this._runHalfRes=e,this.setSize(this._width,this._height)}setCamera(e){this.splineCamera=e}setScene(e){this.splineScene=e}setDepthTexture(e){this.depthBufferHighRes.depthTexture=e,Xl.uniforms.texture_depth_hrez.value=e,Xl.needsUpdate=!0}render(e,t,i){this.splineScene.overrideMaterial=VK;let r=this.splineCamera.layers.mask;if(this.splineCamera.layers.set(5),e.setRenderTarget(this.gBuffer),e.clear(),e.render(this.splineScene,this.splineCamera),e.setRenderTarget(this.depthBufferHighRes),e.clear(),e.render(this.splineScene,this.splineCamera),this.splineScene.overrideMaterial=null,this.splineCamera.layers.mask=r,this.hbaoMaterial.uniforms.radius_of_influence.value=this.radius,this.hbaoMaterial.uniforms.ao_color.value.set(this.aoColor.r,this.aoColor.g,this.aoColor.b),this.hbaoMaterial.uniforms.bias.value=this.bias,this.hbaoMaterial.uniforms.fog_enabled.value=this.fogEnabled,this.hbaoMaterial.uniforms.fog_near.value=this.fogNear,this.hbaoMaterial.uniforms.fog_far.value=this.fogFar,this.hbaoMaterial.uniforms.frame_index.value=this.frameIndex,this.frameIndex++,this.splineCamera.isPerspectiveCamera){this.hbaoMaterial.uniforms.near.value=this.splineCamera.perspCamera.near,this.hbaoMaterial.uniforms.far.value=this.splineCamera.perspCamera.far;let s=this.splineCamera.perspCamera.projectionMatrix.elements,a=2/s[0],n=2/s[5],o=-(1-s[8])/s[0],l=-(1+s[9])/s[5];this.hbaoMaterial.uniforms.proj_info.value.set(a,n,o,l);let h=this.splineCamera.perspCamera.fov*(Math.PI/180),c=this.hbaoMaterial.uniforms.resolution.value.y/(Math.tan(h*.5)*2),d=this.hbaoMaterial.uniforms.radius_of_influence.value*.5*c;this.hbaoMaterial.uniforms.radius_in_screen_space.value=d,this.hbaoMaterial.uniforms.is_ortho.value=!1}else{this.hbaoMaterial.uniforms.near.value=this.splineCamera.orthoCamera.near,this.hbaoMaterial.uniforms.far.value=this.splineCamera.orthoCamera.far;let s=this.splineCamera.orthoCamera.projectionMatrix.elements,a=2/s[0],n=2/s[5],o=-(1+s[12])/s[0],l=-(1-s[13])/s[5];this.hbaoMaterial.uniforms.proj_info.value.set(a,n,o,l);let h=.5*(this.hbaoMaterial.uniforms.resolution.value.y/n),c=this.hbaoMaterial.uniforms.radius_of_influence.value*h;this.hbaoMaterial.uniforms.radius_in_screen_space.value=c,this.hbaoMaterial.uniforms.is_ortho.value=!0}this.runHalfRes?(this.fullscreenMaterial=this.hbaoMaterial,e.setRenderTarget(this.aoBuffer),e.clear(),e.render(this.scene,this.camera),this.fullscreenMaterial=Xl,Xl.uniforms.texture_ao_lrez.value=this.aoBuffer.texture,Xl.uniforms.texture_depth_lrez.value=this.gBuffer.depthTexture,Xl.uniforms.texture_depth_hrez.value=this.depthBufferHighRes.depthTexture,e.setRenderTarget(e.aoRenderTarget),e.clear(),e.render(this.scene,this.camera)):(this.fullscreenMaterial=this.hbaoMaterial,e.setRenderTarget(this.aaBuffer),e.clear(),e.render(this.scene,this.camera),this.effectPass.renderToScreen=!1,this.effectPass.render(e,this.aaBuffer,e.aoRenderTarget))}dispose(){this.gBuffer.dispose(),this.depthBufferHighRes.dispose(),this.aoBuffer.dispose()}},GK=`
  5433. varying vec2 vUv;
  5434. void main() {
  5435. vUv = uv;
  5436. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  5437. }`,HK=`
  5438. uniform sampler2D tInput;
  5439. uniform sampler2D tMap;
  5440. uniform vec2 resolution;
  5441. varying vec2 vUv;
  5442. uniform vec2 uResolution;
  5443. uniform vec2 uCoords;
  5444. // Draws a rectangle at center <st> with size <size>
  5445. float rectangle(vec2 st, vec2 size) {
  5446. size = vec2(0.5) - size * 0.5;
  5447. vec2 uv = vec2(step(size.x, st.x), step(size.y, st.y));
  5448. uv *= vec2(step(size.x, 1.0 - st.x), step(size.y, 1.0 - st.y));
  5449. return uv.x * uv.y;
  5450. }
  5451. uniform vec2 uSize;
  5452. uniform float uScale;
  5453. uniform float uDPR;
  5454. uniform float uCurrent;
  5455. uniform vec3 uSceneColor;
  5456. void main() {
  5457. vec2 screenUv = gl_FragCoord.xy / uResolution.xy;
  5458. screenUv *= 1.0 / uDPR;
  5459. vec2 center = vec2(0.5, -0.5);
  5460. vec2 outsideUv = screenUv;
  5461. outsideUv += center;
  5462. outsideUv -= uCoords.xy / uResolution.xy;
  5463. outsideUv = (outsideUv - 0.5) + 0.5;
  5464. outsideUv -= center;
  5465. vec2 s = (uSize / uResolution) * uScale;
  5466. float isOutside = 1.0 - rectangle(outsideUv, s);
  5467. vec2 mid = vec2(0.5);
  5468. vec2 insideUv = (screenUv - mid + s * mid) / s;
  5469. vec4 background = texture2D(tInput, screenUv);
  5470. vec4 image = texture2D(tMap, insideUv);
  5471. gl_FragColor = mix(image, background, isOutside);
  5472. }
  5473. `,WK=class extends xs{constructor(){super(new Dt({vertexShader:GK,fragmentShader:HK,uniforms:{tInput:new ye(null),tMap:new ye(null),uResolution:new ye(new j),uSize:new ye(new j),uCoords:new ye(new j),uScale:new ye(1),uSceneColor:new ye(new et(16711680)),uDPR:new ye(1),uCurrent:new ye(0)}}),"tInput"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tMap.value}set texture(e){this.uniforms.tMap.value=e}},qK=`
  5474. void main() {
  5475. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  5476. }`,XK=`
  5477. uniform sampler2D toScene;
  5478. uniform sampler2D fromScene;
  5479. uniform vec2 resolution;
  5480. uniform vec2 uResolution;
  5481. uniform float uDPR;
  5482. uniform float mixRatio;
  5483. uniform sampler2D tMixTexture;
  5484. uniform int useTexture;
  5485. uniform float threshold;
  5486. void main() {
  5487. vec2 screenUv = gl_FragCoord.xy / uResolution.xy;
  5488. screenUv *= 1.0 / uDPR;
  5489. vec4 texel1 = texture2D( fromScene, screenUv );
  5490. vec4 texel2 = texture2D( toScene, screenUv );
  5491. if (useTexture==1) {
  5492. vec4 transitionTexel = texture2D( tMixTexture, screenUv );
  5493. float r = mixRatio * (1.0 + threshold * 2.0) - threshold;
  5494. float mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0);
  5495. gl_FragColor = mix( texel1, texel2, mixf );
  5496. } else {
  5497. gl_FragColor = mix( texel1, texel2, mixRatio );
  5498. }
  5499. }
  5500. `,YK=[],QK=class extends xs{constructor(){super(new Dt({vertexShader:qK,fragmentShader:XK,uniforms:{toScene:new ye(null),fromScene:new ye(null),uResolution:new ye(new j),uDPR:new ye(1),mixRatio:new ye(0),threshold:new ye(.1),useTexture:new ye(0),tMixTexture:{value:YK[0]}}}),"toScene"),this.needsSwap=!0}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.fromScene.value}set texture(e){this.uniforms.fromScene.value=e}},ZK=`
  5501. void main() {
  5502. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  5503. }`,KK=`
  5504. uniform sampler2D inputBuffer;
  5505. uniform sampler2D blurredInputBuffer;
  5506. uniform sampler2D overlay;
  5507. uniform float blurIntensity;
  5508. uniform vec2 uResolution;
  5509. uniform float uDPR;
  5510. void main() {
  5511. vec2 screenUv = gl_FragCoord.xy / uResolution.xy;
  5512. screenUv *= 1.0 / uDPR;
  5513. vec4 texel1 = texture2D( overlay, screenUv );
  5514. vec4 texel2 = texture2D( inputBuffer, screenUv );
  5515. vec4 texel3 = texture2D( blurredInputBuffer, screenUv );
  5516. float blurMask2 = max(sign(texel1.a), 0.0) * blurIntensity;
  5517. gl_FragColor = mix( mix(texel2, texel3, blurMask2), texel1, texel1.a );
  5518. }
  5519. `,JK=class extends xs{constructor(){super(new Dt({vertexShader:ZK,fragmentShader:KK,uniforms:{inputBuffer:new ye(null),blurredInputBuffer:new ye(null),overlay:new ye(null),uResolution:new ye(new j),uDPR:new ye(1),blurIntensity:new ye(0)}})),this._blurEnabled=!1,this.blurTarget=new Pt(1,1,{minFilter:xt,magFilter:xt,wrapS:ai,wrapT:ai}),this.blurPass=new J1({width:window.innerWidth,height:window.innerHeight,kernelSize:fm.HUGE,resolutionScale:.25}),this.blurPass.renderToScreen=!1,this.uniforms.blurredInputBuffer.value=this.blurTarget.texture}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.overlay.value}set texture(e){this.uniforms.overlay.value=e}setResolution(e,t,i=1){this.uniforms.uResolution.value.set(e,t),this.uniforms.uDPR.value=i,this.blurPass.setSize(e,t),this.blurTarget.setSize(e,t),this.blurPass.setSize(e,t)}get uiCanvas(){return this._uiCanvas}set uiCanvas(e){this._uiCanvas=e,e.texture&&(this.uniforms.overlay.value=e.texture);let t=e.frame;if(t){let i=t.data.backgroundBlur,r=i.radius;this._blurEnabled=i.enabled,this.uniforms.blurIntensity.value=this._blurEnabled?1:0,this.blurPass.scale=r/3}}render(e,t,i,r,s){this._blurEnabled&&(this.blurPass.setDepthTexture(this.getDepthTexture()),this.blurPass.render(e,t,this.blurTarget,r,s)),super.render(e,t,i,r,s)}},$K=`
  5520. varying vec2 vUv;
  5521. void main() {
  5522. vUv = uv;
  5523. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  5524. }`,eJ=`
  5525. uniform sampler2D tInput;
  5526. uniform sampler2D tOverlayImage;
  5527. varying vec2 vUv;
  5528. uniform vec2 uResolution;
  5529. uniform vec2 uRightBottom;
  5530. uniform vec2 uImageSize;
  5531. uniform float uScale;
  5532. uniform float uDPR;
  5533. vec3 blendNormal(vec3 base, vec3 blend) {
  5534. return blend;
  5535. }
  5536. vec3 blendNormal(vec3 base, vec3 blend, float opacity) {
  5537. return (blendNormal(base, blend) * opacity + base * (1.0 - opacity));
  5538. }
  5539. vec4 drawFixedSizeImage(sampler2D image, vec2 screenUV, vec2 imageSize, vec2 imageCoords, vec2 screenSize, float dpr) {
  5540. vec2 uv = (screenUV * screenSize * dpr - imageCoords) / (imageSize * dpr);
  5541. if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {
  5542. return vec4(0.0);
  5543. }
  5544. return texture2D(image, uv);
  5545. }
  5546. void main() {
  5547. vec2 screenUV = gl_FragCoord.xy / (uResolution.xy * uDPR);
  5548. vec2 imageCoords = vec2(uResolution.x * uDPR - uImageSize.x * uScale * uDPR - uRightBottom.x * uDPR, uRightBottom.y * uDPR);
  5549. vec4 background = texture2D(tInput, screenUV);
  5550. vec4 image = drawFixedSizeImage(tOverlayImage, screenUV, uImageSize * uScale, imageCoords, uResolution, uDPR);
  5551. gl_FragColor = vec4(blendNormal(background.rgb, image.rgb, image.a), max(background.a, image.a));
  5552. }
  5553. `,tJ=class extends xs{constructor(){super(new Dt({vertexShader:$K,fragmentShader:eJ,uniforms:{tInput:new ye(null),tOverlayImage:new ye(null),uResolution:new ye(new j),uImageSize:new ye(new j),uRightBottom:new ye(new j(20,20)),uScale:new ye(.25),uDPR:new ye(1)}}),"tInput")}get uniforms(){return this.fullscreenMaterial.uniforms}get texture(){return this.uniforms.tOverlayImage.value}set texture(e){this.uniforms.tOverlayImage.value=e,this.uniforms.uImageSize.value.set(e.image.width,e.image.height)}};function fA(e,t){return t&&t.enabled&&e.push(t.effect),e}var iJ=e=>Object.values(Ot).includes(e)?e:Ot.NORMAL,rJ=class extends yr{constructor(e,t){super(),this._needsDOFResize=t,this.postprocessingState=yf.defaultData,this._scene=new Jr,this._camera=new Mr,this.effects=new Map,this.blueNoiseTexture=new Ur,this._renderToScreen=!0,this._isUIOverlayEnabled=!1,this.clock=new BU,this.renderer=e,this.debug=!1,this.effects.set("bloom",new gK),this.effects.set("chromaticAberration",new yK),this.effects.set("vignette",new _K),this.effects.set("noise",new wK),this.effects.set("colorAverage",new xK),this.effects.set("hueSaturation",new bK),this.effects.set("brightnessContrast",new vK),this.effects.set("depthOfField",new SK),this.effects.set("pixelation",new AK),this.effectComposer=new OK(this.renderer),this.effectComposer.autoRenderToScreen=!1,this.opaquePass=new my(!0,this.scene,this.camera),this.opaquePass.clear=!0,this.transmissionPass=new DK(this.scene,this.camera,this.renderer),this.aoPass=new jK(this.scene,this.camera),this.taaPass=new PK,this.taaPass.renderToScreen=!1,this.helperPass=new LK(this.camera),this.helperPass.renderToScreen=!1,this.stylesOverlayPass=new WK,this.stylesOverlayPass.enabled=!1,this.uiOverlayPass=new JK,this.uiOverlayPass.enabled=!1,this.logoOverlayPass=new tJ,this.logoOverlayPass.enabled=!1,this.sceneTransitionPass=new QK,this.sceneTransitionPass.enabled=!1,this._initCopyPass(),this._initPasses()}set overlayTexture(e){e!==void 0?(this.stylesOverlayPass.texture=e,this.stylesOverlayPass.enabled=!0):this.stylesOverlayPass.enabled=!1}get overlayTexture(){return this.stylesOverlayPass.texture}set sceneHelpers(e){this.helperPass.sceneHelpers=e}get sceneHelpers(){return this.helperPass.sceneHelpers}set sceneHelpersOnTop(e){this.helperPass.sceneHelpersOnTop=e}get sceneHelpersOnTop(){return this.helperPass.sceneHelpersOnTop}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e),this.aoPass.setScene(e)}get camera(){return this._camera}set camera(e){let t=this._camera!==e;this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),t&&this.transmissionPass.updatePasses(this.renderer),this.aoPass.setCamera(e),this.helperPass.setCamera(e),this.effects.get("depthOfField").setCamera(e)}updateRenderToScreen(){let e=!1;for(let t=this.effectComposer.passes.length-1;t>=0;t--){let i=this.effectComposer.passes[t];if(i.enabled===!0&&!e&&this._renderToScreen){i.renderToScreen=!0,e=!0;continue}i.renderToScreen=!1}}get isUIOverlayEnabled(){return this._isUIOverlayEnabled}disableUIOverlay(){this._isUIOverlayEnabled=!1}enableUIOverlay(){this._isUIOverlayEnabled=!0}disableHelpers(){this.helperPass.enabled=!1,this.updateRenderToScreen()}enableHelpers(){this.helperPass.enabled=!0,this.updateRenderToScreen()}updateBlueNoiseTexture(e){this.blueNoiseTexture=new Ur(e,128,128),this.blueNoiseTexture.wrapS=nn,this.blueNoiseTexture.wrapT=nn,this.blueNoiseTexture.minFilter=_t,this.blueNoiseTexture.magFilter=_t,this.blueNoiseTexture.needsUpdate=!0}setAmbientOcclusionParams(e,t,i,r,s,a,n,o){this.aoPass.enabled=e,this.aoPass.radius=t,this.aoPass.bias=i,this.aoPass.aoColor=r,this.aoPass.fogEnabled=s,this.aoPass.fogNear=a,this.aoPass.fogFar=n,this.aoPass.runHalfRes!==!o&&(this.aoPass.runHalfRes=!o)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}_initPasses(){var e,t,i;if((e=this.uvEffectPass)==null||e.dispose(),(t=this.effectPass)==null||t.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.aoPass),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.effectComposer.addPass(this.taaPass),this.postprocessingState.enabled){let r=[this.effects.get("pixelation")].reduce(fA,[]);r.length>0&&(this.uvEffectPass=new Bf(this.camera,...r),this.uvEffectPass.renderToScreen=!1,this.effectComposer.addPass(this.uvEffectPass));let s=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("depthOfField"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(fA,[]);if(s.length>0&&(this.effectPass=new Bf(this.camera,...s),this.effectPass.renderToScreen=!1,this.effectComposer.addPass(this.effectPass),this._needsDOFResize&&((i=this.effects.get("depthOfField"))==null?void 0:i.enabled)&&window!==void 0)){let a=this.renderer.viewportWidth,n=this.renderer.viewportHeight;this.renderer.setSize(a-1,n-1),this.renderer.setSize(a,n)}}this.effectComposer.addPass(this.stylesOverlayPass),this.effectComposer.addPass(this.uiOverlayPass),this.effectComposer.addPass(this.sceneTransitionPass),this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.logoOverlayPass)}_initCopyPass(){if(this._savePass)return;let e=new j;this.renderer.getDrawingBufferSize(e),this._rt=new Pt(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:nn,wrapT:nn}),this._rt.samples=0,this._savePass=new py(this._rt,!1),this._savePass.renderToScreen=!1}setCopyPass(e){this._rt=e,this._savePass=new py(this._rt,!1),this.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(e===!0?t.removePass(this._savePass):t.addPass(this._savePass),this._renderToScreen=e,this.updateRenderToScreen())}set sceneTransitionFromTexture(e){e!==this.sceneTransitionPass.texture&&(e!==null?this.sceneTransitionPass.enabled=!0:(this.sceneTransitionPass.enabled=!1,this.updateRenderToScreen()),this.sceneTransitionPass.texture=e)}setWatermark(e){this.logoOverlayPass.enabled=e!==null,e&&(this.logoOverlayPass.texture=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...i}=e,r=!1;t!==this.postprocessingState.enabled&&(r=!0);for(let s of Object.entries(i)){let a=s[1],n=this.effects.get(s[0]);if(n){n.enabled!==a.enabled&&(r=!0),n.enabled=a.enabled;for(let[o,l]of Object.entries(a))o==="blendFunction"?n.blendFunction=iJ(l):n[o]=l}}this.postprocessingState=e,r&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,t,i,r){e instanceof ct?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,i,r),this.effectComposer.outputBuffer.scissor.set(e,t,i,r));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,i,r)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,i,r){e instanceof ct?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,i,r),this.effectComposer.outputBuffer.viewport.set(e,t,i,r))}resize(e,t,i){if(this.effectComposer.setSize(e,t,i),this._rt){let r=this.renderer.getPixelRatio();this._rt.setSize(e*r,t*r)}}dispose(){var e,t;(e=this.uvEffectPass)==null||e.dispose(),(t=this.effectPass)==null||t.dispose(),this.effectComposer.dispose()}},sJ=e=>`
  5554. // PCSS implementation based on:
  5555. // https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
  5556. // NOTE: This number affects how big the shadow blur can
  5557. // possibly get. Bigger number == bigger blur, but less precise results
  5558. const float gPenumbraFilterSize = 80.0;
  5559. const int gPenumbraSamples = ${e};
  5560. const int gShadowSamples = ${e};
  5561. const float gShadowSamplesRpc = 1.0f / float(gShadowSamples);
  5562. #ifdef USE_SHADOWMAP
  5563. #if NUM_DIR_LIGHT_SHADOWS > 0
  5564. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5565. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5566. struct DirectionalLightShadow {
  5567. float shadowBias;
  5568. float shadowNormalBias;
  5569. float shadowRadius;
  5570. vec2 shadowMapSize;
  5571. };
  5572. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5573. #endif
  5574. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5575. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5576. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_SHADOWS ];
  5577. struct SpotLightShadow {
  5578. float shadowBias;
  5579. float shadowNormalBias;
  5580. float shadowRadius;
  5581. vec2 shadowMapSize;
  5582. };
  5583. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5584. #endif
  5585. #if NUM_POINT_LIGHT_SHADOWS > 0
  5586. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5587. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5588. struct PointLightShadow {
  5589. float shadowBias;
  5590. float shadowNormalBias;
  5591. float shadowRadius;
  5592. vec2 shadowMapSize;
  5593. float shadowCameraNear;
  5594. float shadowCameraFar;
  5595. };
  5596. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5597. #endif
  5598. /*
  5599. #if NUM_RECT_AREA_LIGHTS > 0
  5600. // TODO (abelnation): create uniforms for area light shadows
  5601. #endif
  5602. */
  5603. float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius)
  5604. {
  5605. float penumbra = 1.0;
  5606. float blockerDepthAvg = 0.0;
  5607. float blockerCount = 0.0;
  5608. #pragma unroll_loop_start
  5609. for(int i = 0; i < gPenumbraSamples; i ++)
  5610. {
  5611. vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar;
  5612. float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) );
  5613. if(depth < compare + 0.0001)
  5614. {
  5615. blockerDepthAvg += depth;
  5616. blockerCount++;
  5617. }
  5618. }
  5619. #pragma unroll_loop_end
  5620. if (blockerCount > 0.0)
  5621. {
  5622. blockerDepthAvg /= blockerCount;
  5623. // Compute penumbra
  5624. penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);
  5625. penumbra *= penumbra;
  5626. penumbra *= 200.0 * penumbraSize[min(index, 5 - 1)]; // Magic number that affects how quickly the penumbra grows
  5627. return clamp(penumbra, 0.00, 1.0);
  5628. }
  5629. return 0.0;
  5630. }
  5631. float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius)
  5632. {
  5633. float shadow = 0.0f;
  5634. // NOTE: When using TAA, we should use screen space interleaved gradient noise
  5635. vec2 halton = haltonSequence[frameIndex];
  5636. float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
  5637. float temporalAngle = temporalOffset * PI2;
  5638. float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);
  5639. float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius);
  5640. if (penumbra == -1.0) {
  5641. return 1.0;
  5642. }
  5643. #pragma unroll_loop_start
  5644. for (int i = 0; i < gShadowSamples; i++)
  5645. {
  5646. vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
  5647. // Overall blurring offset
  5648. vec2 offset = vogelSample * (shadowRadius * 2.);
  5649. // Penumbra offset
  5650. offset += vogelSample * (penumbra * texelScalar);
  5651. shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );
  5652. }
  5653. #pragma unroll_loop_end
  5654. return shadow * gShadowSamplesRpc;
  5655. }
  5656. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5657. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5658. }
  5659. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5660. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5661. }
  5662. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5663. float occlusion = 1.0;
  5664. vec2 distribution = texture2DDistribution( shadow, uv );
  5665. float hard_shadow = step( compare , distribution.x ); // Hard Shadow
  5666. if (hard_shadow != 1.0 ) {
  5667. float distance = compare - distribution.x ;
  5668. float variance = max( 0.00000, distribution.y * distribution.y );
  5669. float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality
  5670. softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed
  5671. occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
  5672. }
  5673. return occlusion;
  5674. }
  5675. float getShadow( int i, sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5676. float shadow = 1.0;
  5677. shadowCoord.xyz /= shadowCoord.w;
  5678. shadowCoord.z += shadowBias;
  5679. // if ( something && something ) breaks ATI OpenGL shader compiler
  5680. // if ( all( something, something ) ) using this instead
  5681. bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
  5682. bool inFrustum = all( inFrustumVec );
  5683. bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
  5684. bool frustumTest = all( frustumTestVec );
  5685. if ( frustumTest ) {
  5686. #if defined( SHADOWMAP_TYPE_PCF )
  5687. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5688. return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius );
  5689. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5690. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5691. float dx = texelSize.x;
  5692. float dy = texelSize.y;
  5693. vec2 uv = shadowCoord.xy;
  5694. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5695. uv -= f * texelSize;
  5696. shadow = (
  5697. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5698. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5699. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5700. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5701. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5702. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5703. f.x ) +
  5704. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5705. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5706. f.x ) +
  5707. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5708. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5709. f.y ) +
  5710. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5711. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5712. f.y ) +
  5713. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5714. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5715. f.x ),
  5716. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5717. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5718. f.x ),
  5719. f.y )
  5720. ) * ( 1.0 / 9.0 );
  5721. #elif defined( SHADOWMAP_TYPE_VSM )
  5722. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5723. #else // no percentage-closer filtering:
  5724. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5725. #endif
  5726. }
  5727. return shadow;
  5728. }
  5729. // cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D
  5730. // vector suitable for 2D texture mapping. This code uses the following layout for the
  5731. // 2D texture:
  5732. //
  5733. // xzXZ
  5734. // y Y
  5735. //
  5736. // Y - Positive y direction
  5737. // y - Negative y direction
  5738. // X - Positive x direction
  5739. // x - Negative x direction
  5740. // Z - Positive z direction
  5741. // z - Negative z direction
  5742. //
  5743. // Source and test bed:
  5744. // https://gist.github.com/tschw/da10c43c467ce8afd0c4
  5745. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5746. // Number of texels to avoid at the edge of each square
  5747. vec3 absV = abs( v );
  5748. // Intersect unit cube
  5749. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5750. absV *= scaleToCube;
  5751. // Apply scale to avoid seams
  5752. // two texels less per square (one texel will do for NEAREST)
  5753. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5754. // Unwrap
  5755. // space: -1 ... 1 range for each square
  5756. //
  5757. // #X## dim := ( 4 , 2 )
  5758. // # # center := ( 1 , 1 )
  5759. vec2 planar = v.xy;
  5760. float almostATexel = 1.5 * texelSizeY;
  5761. float almostOne = 1.0 - almostATexel;
  5762. if ( absV.z >= almostOne ) {
  5763. if ( v.z > 0.0 )
  5764. planar.x = 4.0 - v.x;
  5765. } else if ( absV.x >= almostOne ) {
  5766. float signX = sign( v.x );
  5767. planar.x = v.z * signX + 2.0 * signX;
  5768. } else if ( absV.y >= almostOne ) {
  5769. float signY = sign( v.y );
  5770. planar.x = v.x + 2.0 * signY + 2.0;
  5771. planar.y = v.z * signY - 2.0;
  5772. }
  5773. // Transform to UV space
  5774. // scale := 0.5 / dim
  5775. // translate := ( center + 0.5 ) / dim
  5776. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5777. }
  5778. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5779. float shadow = 1.0;
  5780. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5781. // for point lights, the uniform @vShadowCoord is re-purposed to hold
  5782. // the vector from the light to the world-space position of the fragment.
  5783. vec3 lightToPosition = shadowCoord.xyz;
  5784. // dp = normalized distance from light to fragment position
  5785. float compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?
  5786. compare += shadowBias;
  5787. // bd3D = base direction 3D
  5788. vec3 bd3D = normalize( lightToPosition );
  5789. vec2 halton = haltonSequence[frameIndex];
  5790. float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
  5791. float temporalAngle = temporalOffset * PI2;
  5792. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM )
  5793. for (int i = 0; i < gShadowSamples; i++) {
  5794. vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
  5795. // Overall blurring offset
  5796. vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);
  5797. // NOTE: Removed for now
  5798. // Penumbra offset
  5799. //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);
  5800. shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );
  5801. }
  5802. return shadow * gShadowSamplesRpc;
  5803. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5804. for (int i = 0; i < 16; i++) {
  5805. vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
  5806. // Overall blurring offset
  5807. vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);
  5808. shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );
  5809. }
  5810. return shadow * (1.0 / 16.0);
  5811. #else // no percentage-closer filtering
  5812. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare );
  5813. #endif
  5814. }
  5815. #endif
  5816. `,aJ=yt.lights_fragment_begin,nJ=yt.shadowmask_pars_fragment,mA=null,oJ=e=>{switch(e){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},lJ=(e="medium")=>{if(mA===e)return!1;mA=e;let t=oJ(e);yt.shadowmap_pars_fragment=sJ(t);let i=aJ.slice();i=i.replace("getShadow( spotShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX + 3, spotShadowMap[ i ]"),i=i.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),yt.lights_fragment_begin=i;let r=nJ.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),yt.shadowmask_pars_fragment=r,!0},hJ=`
  5817. attribute vec3 randomColor;
  5818. varying vec3 vNormal;
  5819. flat out vec3 vColor;
  5820. #include <skinning_pars_vertex>
  5821. #include <morphtarget_pars_vertex>
  5822. void main()
  5823. {
  5824. #include <beginnormal_vertex>
  5825. #include <morphnormal_vertex>
  5826. #include <skinbase_vertex>
  5827. #include <skinnormal_vertex>
  5828. vec3 transformed = vec3(position);
  5829. #include <morphtarget_vertex>
  5830. #include <skinning_vertex>
  5831. vNormal = normal;
  5832. vColor = randomColor;
  5833. gl_Position = projectionMatrix * (modelViewMatrix * vec4(transformed, 1.0));
  5834. }
  5835. `,cJ=`
  5836. uniform float depthContrast;
  5837. varying vec3 vNormal;
  5838. flat in vec3 vColor;
  5839. void main()
  5840. {
  5841. vec3 normal = (normalize(vNormal)).rgb;
  5842. float contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5;
  5843. vec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4);
  5844. gl_FragColor = vec4(resultColor, vColor.r);
  5845. gl_FragColor = vec4(resultColor, vColor.r);
  5846. }
  5847. `,ev=new Dt({vertexShader:hJ,fragmentShader:cJ,uniforms:{depthContrast:{value:1}}}),gA=new ci,vA=new j,dJ=class extends bM{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new j,this.dummyCamera=new Mr,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.isXRCopyPassSet=!1,this.clear=(s=!0,a=!0,n=!0)=>{let o=this.getContext(),l=0;s&&(l|=o.COLOR_BUFFER_BIT),a&&(l|=o.DEPTH_BUFFER_BIT),n&&(l|=o.STENCIL_BUFFER_BIT),o.clear(l),o.clearBufferfv(o.COLOR,1,[0,0,0,1])},this.pipeline=new rJ(this,(e==null?void 0:e.needsDOFResize)??!1),this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=Uy,this.dummyCamera.matrixAutoUpdate=!1,this.domElement.removeAttribute("data-engine");let r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio!==s&&(this._pixelRatio=s,t(s))},this.setSize=(s,a,n=!0)=>{var o,l;(this.viewportWidth!==s||this.viewportHeight!==a)&&(this.viewportWidth=s,this.viewportHeight=a,i(s,a,n),(o=this.normalRenderTarget)==null||o.setSize(s*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(s,a),(l=this.transmissionDepthTarget)==null||l.setSize(s*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(s,a,n))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new Pt(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:xt,magFilter:xt,wrapS:ai,wrapT:ai,depthBuffer:!1}))}_resizeTransmission(e,t){var i,r;(i=this.transmissionRenderTarget)==null||i.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),t*this._pixelRatio/(this.hdTransmission?1:2)),(r=this.aoRenderTarget)==null||r.setSize(e*this._pixelRatio/1,t*this._pixelRatio/1)}get hdTransmission(){return st.transmissionLod.value===1}set hdTransmission(e){st.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new Pt(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:Ch,magFilter:xt,wrapS:ai,wrapT:ai,depthBuffer:!1}),this.transmissionDepthTarget=new Pt(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:_t,magFilter:_t,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new Pt(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:_t,magFilter:_t,type:jt,depthTexture:new Ph(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t,i){this.normalRenderTarget&&(this.setClearColor(0),i.layers.enable(8),i.layers.disable(0),i.layers.disable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),i instanceof Mr?ev.uniforms.depthContrast.value=(i.far-i.near)/1e4:ev.uniforms.depthContrast.value=1,t.overrideMaterial=ev,this.render(t,i),this.setClearColor(t.bgColor,t.bgColor.a),this.setRenderTarget(null),t.overrideMaterial=e.wireframeState?_y:null,i.layers.enable(0),i.layers.enable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,t,i=1){this.dummyCamera.updateCameraState(t.dataPatched),this.dummyCamera.matrix.copy(t.matrixWorld);let r=t.height,s=t.width,a=this.viewportWidth/this.viewportHeight;s<r?s=r*a:r=s/a,this.dummyCamera.setViewplaneSize(s,r);for(let n=0;n<i;n++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(e,t,{sceneHelpers:i=this.sceneHelpers,sceneHelpersOnTop:r=this.sceneHelpersOnTop,overrideTransmission:s=void 0,overrideNormal:a=void 0}={}){var u;let n=e instanceof nx?e.activePage:e,o=n.visible;n.visible=!0;let l=n.scene;this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(t)),this.setClearColor(n.bgColor,n.bgColor.a),n.penumbraSizeArray.forEach((p,f)=>{st.penumbraSize.value[f]=p}),st.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?st.resolution.value.set(this.resolution.x,this.resolution.y):st.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),a!==void 0?(st.normalRenderTarget.value=a,st.normalRenderTargetDepth.value=gA):l.needsNormal()&&(this.createNormalRenderTarget(),st.normalRenderTarget.value=this.normalRenderTarget.texture,st.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(l,n,t));let h=n.data.ao,c=h.occlusion;if(c&&(this.createAORenderTarget(),st.aoRenderTarget.value=this.aoRenderTarget.texture),st.aoEnabled.value=c,this.pipeline.setAmbientOcclusionParams(h.occlusion,h.radius,h.bias,n.aoColor,n.fog!==null,n.backupFog.near,n.backupFog.far,h.aoFullRes&&!ec),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture),this.pipeline.isUIOverlayEnabled&&((u=n.uiCanvas)==null?void 0:u.enabled)&&n.uiCanvas.texture&&n.uiCanvas.texture.image.width>0){let p=this.getSize(vA),f=this.getPixelRatio();(n.uiCanvas.width!==this.viewportWidth||n.uiCanvas.height!==this.viewportHeight||n.uiCanvas.dpr!==f)&&n.uiCanvas.applySize({width:this.viewportWidth,height:this.viewportHeight},f),n.uiCanvas.render(this),this.pipeline.uiOverlayPass.uiCanvas=n.uiCanvas,this.pipeline.uiOverlayPass.enabled=!0,this.pipeline.uiOverlayPass.setResolution(p.x,p.y,f),this.pipeline.updateRenderToScreen()}else this.pipeline.uiOverlayPass.enabled=!1,this.pipeline.updateRenderToScreen();if(this.pipeline.logoOverlayPass.enabled){let p=this.getSize(vA),f=this.getPixelRatio();this.pipeline.logoOverlayPass.uniforms.uResolution.value.set(p.x,p.y),this.pipeline.logoOverlayPass.uniforms.uDPR.value=f}let d=!1;if(s!==void 0)st.transmissionRenderTarget.value=s,st.transmissionRenderTargetDepth.value=gA,this.pipeline.setTransmissionPassEnabled(!1);else{let p=l.needsTransmission();p&&(this.transmissionRenderTarget===void 0&&(d=!0),this.createTransmissionRenderTarget(),st.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,st.aspectRatio.value=eY(this.viewportWidth,this.viewportHeight),st.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(p)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=n,this.pipeline.camera=t,d&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==n.postprocessing&&(this.pipeline.updatePostprocessing(n.postprocessing),!i&&!r&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),l.shapeBlendIntances.forEach(p=>{p.onBeforeShadowPass(this)}),n.overrideMaterial=l.wireframeState?_y:null,this.pipeline.render(),st.frameIndex.value=(st.frameIndex.value+1)%16,t instanceof Mr&&t.copyHistory(),n.visible=o}renderFromSceneForSceneTransitionPass(e,t,i){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,t),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i,this.pipeline.renderToScreen=!0;let r=this.pipeline.sceneTransitionPass.uniforms;r.uDPR.value=window.devicePixelRatio,r.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){var e,t,i,r,s,a;this._superDispose(),this.pipeline.dispose(),(e=this.aoRenderTarget)==null||e.dispose(),(t=this.transmissionRenderTarget)==null||t.dispose(),(i=this.transmissionDepthTarget)==null||i.dispose(),(r=this.normalRenderTarget)==null||r.dispose(),(a=(s=this.normalRenderTarget)==null?void 0:s.depthTexture)==null||a.dispose()}},qT=class extends Gd(JU){constructor(e,t=15,i=10066329){super(e,t,i),this.object=e,this.added=!1,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Hd(this.object,qT.geometryHelper,e,t)}},XT=class extends Gd(KU){constructor(e,t=15,i=6710886){super(e,t,i),this.object=e,this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Hd(this.object,XT.geometryHelper,e,t)}},gy=class extends Gd(ZU){constructor(e,t=6710886){super(e,t),this.object=e,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Hd(this.object,gy.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=gy._vector,t=this.object.distance?this.object.distance:1e3,i=t*Math.tan(this.object.angle);this.cone.scale.set(i,i,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(r);else this.cone.material.color.set(r)}}},YT=gy;YT._vector=new M;var QT=class extends hn{constructor(){super(),this.caretIndex=0,this._caretVisibleAlpha=1,this._selectionVisibleAlpha=.3,this.current={start:0,end:void 0},this.matrixAutoUpdate=!1,this.caretMesh=new Jt(new Ea(1,1),new gn({transparent:!0,opacity:0,side:Ar})),this.add(this.caretMesh),this.selectionMesh=new Jt(new Ea(1,1),new gn({color:2857471,transparent:!0,depthTest:!1,depthWrite:!1,opacity:0,side:Ar})),this.add(this.selectionMesh),this.hide()}get caretHeight(){var e;return((e=this.object)==null?void 0:e.AD)??0}show(e){this.visible=!0,this.object=e,this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.y=-this.caretHeight*.5,this.setCaretPosition(this.caretIndex),this.update()}hide(){this.visible=!1}update(){if(this.object===void 0)return;this.updateHelperMatrix();let{depth:e}=this.object.geometry.userData.parameters;this.caretMesh.position.z=e,this.selectionMesh.position.z=e}updateHelperMatrix(){if(this.object===void 0)return;let e=this.object,t=e.parent;t!==null&&t.updateWorldMatrix(!0,!1),e.matrixAutoUpdate&&e.updateMatrix(),t!==null?(this.matrixWorld.multiplyMatrices(t.matrixWorld,e.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,e.matrix)):this.matrixWorld.multiplyMatrices(e.hiddenMatrix,e.matrix),this.matrix.copy(this.matrixWorld);for(let i of this.children)i.matrixWorld.copy(this.matrixWorld);e.updateWorldMatrix(!0,!0)}setCaretColor(e){let t=this.caretMesh.material;t.color.setRGB(e.r,e.g,e.b);let i=this._caretVisibleAlpha===t.opacity;this._caretVisibleAlpha=e.a,i&&(t.opacity=this._caretVisibleAlpha)}setSelectionColor(e){this.selectionMesh.material.color.setRGB(e.r,e.g,e.b)}setCaretPosition(e,t={}){if(this.object===void 0)return;this.caretIndex=e;let i=this.object.wrappedText,[r,s]=Ff(i,e),[a,n]=e>0?Ff(i,e-1):[null,null];(e>0&&i.length?i[a].charAt(n):null)===`
  5848. `&&(r++,s=0),this.current.start=e,this.current.end=void 0;let[o,l]=tv(this.object,r,s),{AD:h,descender:c}=this.object,d=c+h*.5,{width:u,height:p,depth:f}=this.object.geometry.userData.parameters,g=typeof u=="string"?0:u,m=typeof p=="string"?0:p;this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.set(o-g*.5,l+d+m*.5,f),this.hideSelectionMesh(),this.showCaretMesh()}setSelection(e,t){if(this.object===void 0)return;let i=this.object.wrappedText;this.current.start=e,this.current.end=t;let r=[],s=[],a=uJ(i,e,t),{lineHeight:n,AD:o,descender:l}=this.object,h=l+o*.5-n*.5;for(let[m,v,y]of a)if(v!==y){let[x,w]=tv(this.object,m,v),[_,b]=tv(this.object,m,y);w+=h,b+=h,b+=n;let A=r.length/3;r.push(x,w,0),r.push(_,w,0),r.push(_,b,0),r.push(x,b,0),s.push(A+0,A+1,A+2),s.push(A+2,A+3,A+0)}let c=new Ge;c.setIndex(s),c.setAttribute("position",new Ie(r,3));let{width:d,height:u,depth:p}=this.object.geometry.userData.parameters,f=typeof d=="string"?0:d,g=typeof u=="string"?0:u;this.selectionMesh.geometry.dispose(),this.selectionMesh.geometry=c,this.selectionMesh.position.x=-f*.5,this.selectionMesh.position.y=g*.5,this.selectionMesh.position.z=p,this.showSelectionMesh(),this.hideCaretMesh()}getSelectionFromPosition(e,t,i="previous"){if(this.object===void 0||this.object.font===void 0)return;let r=this.object.wrappedText,s=r.length,a=this.object.lineHeight,n=s*a,{height:o,verticalAlign:l}=this.object.geometry.userData.parameters,h=typeof o=="string"?0:o,c=0;l===3?c=h-n:l===2&&(c=h*.5-n*.5);let d=Math.min(Math.floor(Math.max(Math.min(-t-c,n),0)/a),s-1),u=this.object.charCoords[d],p=this.object.charWidths[d],f=0,g=!1;if(i==="previous"){for(let m=0;m<u.length;m++)if(u[m][0]+p[m]*.5-e>0){f=m,g=!0;break}}else if(i==="closest"){let m=1/0;for(let v=0;v<u.length;v++){let y=u[v][0]+p[v]*.5,x=Math.abs(y-e);x<m&&(m=x,f=v,g=!0)}}else for(let m=0;m<u.length;m++){let v=u[m][0],y=u[m][0]+p[m];if(e>=v&&e<y){f=m,g=!0;break}}return g||(f=u.length),{index:this.getGlobalIndexFromLineAndCharIndexes(r,d,f),lineIndex:d,characterIndex:f}}getGlobalIndexFromLineAndCharIndexes(e,t,i){return e.slice(0,t).reduce((r,s)=>r+=s.length,0)+i}showSelectionMesh(){this.selectionMesh.material.opacity=this._selectionVisibleAlpha}hideSelectionMesh(){this.selectionMesh.material.opacity=0}showCaretMesh(){this.caretMesh.material.opacity=this._caretVisibleAlpha}hideCaretMesh(){this.caretMesh.material.opacity=0}};function tv(e,t,i){let{charCoords:r,charWidths:s,initialOffsetY:a,lineHeight:n}=e;if(r[t]&&r[t].length===0||r.length===0){let c=0,{horizontalAlign:d}=e.data.geometry,u=e.wrappedText,{width:p}=e.geometry.userData.parameters;return u.length===1&&u[0].length===0&&(d===3?c=p*.5:d===2&&(c=p)),[c,a-n*t]}let o=r[t];if(o===void 0||o.length===0)return[0,0];let[l,h]=o[Math.min(i,o.length-1)];return i>=o.length&&(l+=s[t][i-1]),[l,h]}function Ff(e,t){var r;let i=0;for(let s=0;s<e.length;s++){let a=e[s],n=t-i;if(n<=a.length)return[s,n];i+=a.length}return[Math.max(0,e.length-1),((r=e[e.length-1])==null?void 0:r.length)??0]}function uJ(e,t,i){let[r,s]=Ff(e,t),[a,n]=Ff(e,i),o=[];s>=e[r].length&&(r++,s=0);for(let l=r;l<=a;l++){let h=e[l],c=l===r?s:0,d=l===a?n:h.length;o.push([l,c,d])}return o}function pJ(e,t){let i=ur.fromHex(3223857),r=.8;for(let s of e.layers){if(s.data.type==="light"||s.data.type==="displace"||s.data.type==="fresnel"||s.data.type==="matcap"||s.data.type==="texture"||s.data.type==="toon"||s.data.type==="outline"||s.data.type==="transmission"||s.data.type==="noise")continue;let a=typeof s.data.alpha=="string"?Number(t.getVariable(s.data.alpha)):s.data.alpha;if(s.data.type==="color"&&a>.3){i=fJ(s.data.color,t),r=a;break}else if((s.data.type==="depth"||s.data.type==="gradient")&&a>.3){let n=mJ(s.data);i={r:n[0],g:n[1],b:n[2]},r=typeof s.data.alpha=="string"?1:s.data.alpha;break}}return{...i,a:r}}function fJ(e,t){return typeof e=="string"?t.data.colors[e]:e}function mJ(e){return e.colors[0]}function gJ(e,t){e.shadow.camera.right=t/2,e.shadow.camera.left=-t/2,e.shadow.camera.top=t/2,e.shadow.camera.bottom=-t/2,e.shadow.needsUpdate=!0}var ZT=class extends Z1(zU,qT){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let s=new Zp(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof Zp&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t);let i=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;e.size!==void 0&&gJ(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),i&&this.update()}},yA=new M,xA=new M,bA=new lt,KT=class extends Z1(IU,YT){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=Re.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new Zp(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof Zp&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),xA.setFromMatrixPosition(this.matrixWorld),bA.setFromRotationMatrix(this.matrixWorld),yA.copy(this.up).applyQuaternion(bA).negate().multiplyScalar(this.distance),this.target.position.copy(xA).add(yA),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function vJ(e){let t=(e[0][0]+e[1][1])/2,i=(e[0][0]-e[1][1])/2,r=(e[1][0]+e[0][1])/2,s=(e[1][0]-e[0][1])/2,a=Math.sqrt(t*t+s*s),n=Math.sqrt(i*i+r*r),o=a+n,l=a-n,h=Math.atan2(r,i),c=Math.atan2(s,t),d=(c-h)/2,u=(c+h)/2,p=[[Math.cos(u),Math.sin(u)],[-Math.sin(u),Math.cos(u)]],f=[[o,0],[0,l]],g=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]];return p[0][0]*=-1,p[0][1]*=-1,g[0][0]*=-1,g[1][0]*=-1,[p,f,g]}function Ip(e,t){return[[e[0][0]*t[0][0]+e[0][1]*t[1][0],e[0][0]*t[0][1]+e[0][1]*t[1][1]],[e[1][0]*t[0][0]+e[1][1]*t[1][0],e[1][0]*t[0][1]+e[1][1]*t[1][1]]]}function wA(e){return[[e[0][0],e[1][0]],[e[0][1],e[1][1]]]}function yJ(e){let[t,i,r]=vJ(e),s=Ip(t,wA(r)),a=Ip(Ip(r,i),wA(r)),n=Math.atan2(s[1][0],s[0][0]),o=[a[0][0],a[1][1]],l=[a[0][1]/a[1][1],a[1][0]/a[0][0]];return{rotation:n,scale:o,shear:l}}function xJ({rotation:e,scale:t,shear:i}){let r=Math.cos(e),s=Math.sin(e),a=[[r,-s],[s,r]],n=[[t[0],i[0]*t[1]],[i[1]*t[0],t[1]]],o=Ip(a,n);return[o[0][0],o[1][0],o[0][1],o[1][1]]}var Lt;(e=>{function t(){return[1,0,0,0,1,0,0,0,1]}e.identity=t;function i(b,A=e.identity()){for(let S=0,E=b.length;S<E;S++)A[S]=b[S];return A}e.copy=i;function r(b,A,S,E,C,T){return e.setAbcdef(e.identity(),b,A,S,E,C,T)}e.create=r;function s(b,A,S,E,C,T,D){return b[0]=A,b[1]=E,b[2]=T,b[3]=S,b[4]=C,b[5]=D,b}e.setAbcdef=s;function a(b,A){let[S,E,C,T,D,O]=o(b),[P,U,W,k,F,Z]=o(A),X=P*S+U*C,G=P*E+U*T,q=W*S+k*C,$=W*E+k*T,Q=F*S+Z*C+D,ee=F*E+Z*T+O;return e.create(X,G,q,$,Q,ee)}e.append=a;function n(b,A){let[S,E,C,T,D,O]=o(b),[P,U,W,k,F,Z]=o(A),X=S,G=E,q=C,$=T;(P!==1||U!==0||W!==0||k!==1)&&(X=S*P+E*W,G=S*U+E*k,q=C*P+T*W,$=C*U+T*k);let Q=D*P+O*W+F,ee=D*U+O*k+Z;return e.create(X,G,q,$,Q,ee)}e.prepend=n;function o(b){return[b[0],b[3],b[1],b[4],b[2],b[5]]}e.getAbcdef=o;function l(b){let[A,S,E,C,T,D]=e.getAbcdef(b),O=A*C-S*E,P=C/O,U=-S/O,W=-E/O,k=A/O,F=(E*D-C*T)/O,Z=-(A*D-S*T)/O;return e.create(P,U,W,k,F,Z)}e.invert=l;function h([b,A],S){let[E,C,T,D,O,P]=e.getAbcdef(S);return[E*b+T*A+O,C*b+D*A+P]}e.apply=h;function c(b,A){let[S,E,C,T,D,O]=e.getAbcdef(A),P=1/(S*T+C*-E),[U,W]=b;return[T*P*U+-C*P*W+(O*C-D*T)*P,S*P*W+-E*P*U+(-O*S+D*E)*P]}e.applyInverse=c;function d(b,A,S=A){let[E,C,T,D,O,P]=e.getAbcdef(b);return e.setAbcdef(b,E*A,C*S,T*A,D*S,O*A,P*S),b}e.scale=d;function u(b,A){let S=Math.cos(A),E=Math.sin(A),[C,T,D,O,P,U]=e.getAbcdef(b);return e.setAbcdef(b,C*S-T*E,C*E+T*S,D*S-O*E,D*E+O*S,P*S-U*E,P*E+U*S),b}e.rotate=u;function p(b,A,S){let[E,C]=S,T=e.translate(b,-E,-C);return T=e.rotate(T,A),T=e.translate(T,E,C),T}e.rotateAround=p;function f(b,A,S){let[E,C,T,D,O,P]=e.getAbcdef(b);return e.setAbcdef(b,E,C,T,D,O+A,P+S),b}e.translate=f;function g(b,A,S){let[E,C,T,D]=e.getAbcdef(b);return e.setAbcdef(b,E,C,T,D,A,S),b}e.setTranslate=g;function m(b,A,S){let[E,C,T,D]=e.getAbcdef(b);return e.setAbcdef(b,E,C,T,D,A,S),b}e.setPosition=m;function v(b){let[A,S,E,C]=e.getAbcdef(b),T=Math.sqrt(A*A+S*S),D=Math.sqrt(E*E+C*C);return[T,D]}e.getScale=v;function y(b){let[,,,,A,S]=e.getAbcdef(b);return[A,S]}e.getPosition=y;function x(b,A){return e.decompose(b,A).rotation}e.getRotation=x;function w(b,A){let[S,E,C,T,D,O]=e.getAbcdef(b),{rotation:P,scale:U,shear:W}=yJ([[S,C],[E,T]]);return{position:[D+(A[0]*S+A[1]*C)-A[0],O+(A[0]*E+A[1]*T)-A[1]],scale:U,rotation:P,shear:W,pivot:A}}e.decompose=w;function _(b,A,S,E,C=[0,0]){let[T,D]=b,[O,P]=E,[U,W,k,F]=xJ({rotation:S,scale:A,shear:C}),Z=T-(O*U+P*k)+O,X=D-(O*W+P*F)+P;return e.create(U,W,k,F,Z,X)}e.compose=_})(Lt||(Lt={}));var bJ=Math.PI/180;function wJ(e,t,i,r,s,a){let n=e-i,o=t-r;return n*n/(s*s)+o*o/(a*a)<=1}function _J(e){return e*bJ}var ar=class{constructor(e,t,i){this.uuid=e,this.data=t,this.localMatrix=Lt.identity(),this.worldMatrix=Lt.identity(),this.ignoreCameraZoom=!1,this.visible=!0,this._singleBBox=new vy,this._recursiveBBox=new vy,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.stateSelection=null,this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this.name="",this.position=[0,0],this.scale=[1,1],this.rotation=0,this.shear=[0,0],this.emitter=dm(),this.dpr=i.dpr??1,this.dataPatched=t}project(e,t){let i=this.worldMatrix;return t&&(i=Lt.append(t.worldMatrix,i)),Lt.applyInverse(e,i)}intersects(e,t,i,r=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([e,t],i),r)}intersectsInLocalSpace(e,t,i=!1){let{min:r,max:s}=i?this.recursiveBBox:this.singleBBox;return e>=r[0]&&e<=s[0]&&t>=r[1]&&t<=s[1]}applyTransforms(e){e.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=Lt.compose(this.position,this.scale,_J(this.rotation),rl.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(e,t,i){let r=this.parent;t&&r!==null&&r!==void 0&&r.updateWorldMatrix(e,!0,!1),e&&this.updateLocalMatrix(),this.parent?this.worldMatrix=Lt.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=Lt.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return rl.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(e=>{e.resetBBoxNeedsUpdateSelf()})}updateTransformState(e){let t=!1;e.position!==void 0&&(t=!0,this.position=e.position),e.rotation!==void 0&&(t=!0,this.rotation=e.rotation),e.scale!==void 0&&(t=!0,this.scale=e.scale),e.shear!==void 0&&(t=!0,this.shear=e.shear),t&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(e,t,i){e.type===0&&e.props.visible!==void 0&&(this.visible=e.props.visible),this.data=t,this.data=t;let r=e,s=Qt(e.path,["states","*"]);if(s!==null){if(e.type===0){let[a]=s;if((this==null?void 0:this.stateSelection)===a){let n={...e.props};if(delete n.name,Object.values(e.props).some(o=>o===void 0)){let o=this.data;if(o!==void 0){let l=Gi.zoom(o,e.path.slice(2));if(l)for(let h in e.props)e.props[h]===void 0&&h in l&&(n[h]=l[h])}}r={...e,props:n,path:e.path.slice(2)}}}}else if(e.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(e.props.name!==void 0&&a.name){let{name:o,...l}=a;a=l}let n=Gi.removeOverridden(e.path,e.props,a);r={...e,props:n}}}this.updateByPatchedOpBase(r,Yo.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i)}changeSelectedState(e,t,i=!1){if(!(this.data.states.length===0&&!i)){for(let r of this.data.states)Yo.toOps(this.data,r.data).forEach(s=>{let a=lf.replaceProps(s,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,t)});if(e!==null){let r=this.data.states.data(e);r&&(this.dataPatched=Yo.patch(this.data,r),Yo.toOps(this.data,r).forEach(s=>{this.updateByPatchedOp(s,this.dataPatched,t)}))}i&&this.updateTransformState(this.dataPatched),this.stateSelection=e}}updateState(e,t){e.name!==void 0&&(this.name=e.name),e.visible!==void 0&&(this.visible=e.visible),this.updateTransformState(e)}updateByPatchedOpBase(e,t,i){this.dataPatched=t,this.updateByPatchedOp(e,t,i)}updateByPatchedOp(e,t,i){e.path.length===0&&e.type===0&&this.updateState(e.props,i),this.requestRender()}traverseFrameAncestors(e){this.traverseAncestors(t=>{t.data.type==="frame2d"&&e(t)})}traverseAncestors(e){let t=this.parent;for(;t;)e(t),t=t.parent}requestRender(){this.traverseFrameAncestors(e=>{e.requestRender()})}clone(e){let t=new ar(this.uuid,this.data,e);return t.parent=void 0,t}addEventListener(e,t){this.emitter.on(e,t)}removeEventListener(e,t){this.emitter.off(e,t)}dispatchEvent(e){this.emitter.emit(e.type,{...e,target:e.target??this})}traverseSortNextHelper(){let e=this.parent;if(e){let t=e.children;if(t){let i=t.indexOf(this)+1;return t[i]?t[i]:e.traverseSortNextHelper()}}}sortNext(){let e=this.children;return e&&e.length>0&&e[0]?e[0]:this.traverseSortNextHelper()}isDescendantOf(e){e instanceof ar&&(e=e.uuid);let t=this;for(;t.parent;){if(t.parent.uuid===e)return!0;t=t.parent}return!1}},ks=class extends ar{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.context=i,this.children=[]}add(e){e.parent&&e.parent instanceof ks&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=void 0)}traverse(e){let t=e(this);if(t!==!0)for(let i of this.children)i instanceof ks?i.traverse(e):t=e(i)}intersectsChildrenHelper(e,t,i,r,s){for(let a of this.children)if(a.intersects(e,t,i,!1)&&(s.push(a),r)||a instanceof ks&&a.intersectsChildrenHelper(e,t,i,r,s))return!0;return!1}intersectsChildren(e,t,i,r=!1,s=[],a=!1){return this.intersectsChildrenHelper(e,t,i,r,s),s}intersectsChildrenHelperReverse(e,t,i,r,s){for(let a of this.children)if(a instanceof ks&&a.intersectsChildrenHelperReverse(e,t,i,r,s)||a.intersects(e,t,i,!1)&&(s.push(a),r))return!0;return!1}intersectsChildrenReverse(e,t,i,r=!1,s=[],a=!1){return this.intersectsChildrenHelperReverse(e,t,i,r,s),s}updateWorldMatrix(e,t,i){if(super.updateWorldMatrix(e,t,i),i&&this.children)for(let r of this.children)r.updateWorldMatrix(e,!1,!0)}find(e){let t;return this.traverse(i=>{i.uuid===e&&(t=i)}),t}innerDrawChildren(e){for(let t=this.children.length-1;t>=0;t--)this.children[t].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let t=new ks(this.uuid,this.data,e);t.parent=void 0;for(let i of this.children)t.add(i.clone(e));return t}},po=class extends ks{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.updateState(t,i)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let t=new po(this.uuid,this.data,e);t.parent=void 0;for(let i of this.children)t.add(i.clone(e));return t}};function SJ(e,t){let[[i,r],[s,a]]=e,[[n,o],[l,h]]=t,c=(i-s)*(o-h)-(r-a)*(n-l);if(c===0)return!1;let d=((i-n)*(o-h)-(r-o)*(n-l))/c,u=-((i-s)*(r-o)-(r-a)*(i-n))/c;return d>=0&&d<=1&&u>=0&&u<=1}var JT=[[-1,1],[-1,-1],[1,-1],[1,1]],_A=(e,t,i)=>{let r=e.getCenter(),s=e.getHalfSize(),a=Lt.append(t,e.worldMatrix);s[0]===0&&s[1]===0?i.push(Lt.apply(r,a)):JT.forEach(n=>{let o=[n[0]*s[0]+r[0],n[1]*s[1]+r[1]];i.push(Lt.apply(o,a))})},vy=class{constructor(){this.matrix=Lt.identity(),this.min=[1/0,1/0],this.max=[-1/0,-1/0],this.vertices=[],this.edges=[]}setFromObjectSize(e,t=!1){e.updateWorldMatrix(),this.makeEmpty(),Lt.copy(e.worldMatrix,this.matrix);let i=Lt.invert(e.worldMatrix);this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];i===!0&&e instanceof ks?e.traverse(s=>{s.visible&&_A(s,t,r)}):_A(e,t,r),this.setFromPoints(r)}setFromSize(e,t,i){this.makeEmpty(),Lt.copy(i,this.matrix),this.expandBySize(e,t,i)}expandBySize(e,t,i){[Lt.apply([0,0],i),Lt.apply([0,t],i),Lt.apply([e,t],i),Lt.apply([e,0],i)].forEach(r=>this.expandByPoint(r))}getCenter(){let[e,t]=this.min,[i,r]=this.getHalfSize();return Lt.apply([e+i,t+r],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(e){this.makeEmpty();for(let t of e)this.expandByPoint(t)}expandByPoint(e){this.min=[Math.min(this.min[0],e[0]),Math.min(this.min[1],e[1])],this.max=[Math.max(this.max[0],e[0]),Math.max(this.max[1],e[1])]}computeVertices(){let[e,t]=this.getHalfSize(),i=this.getCenter(),[r,s,a,n]=Lt.getAbcdef(this.matrix),o=Lt.create(r,s,a,n,i[0],i[1]);this.vertices=JT.map(([l,h])=>Lt.apply([l*e,h*t],o))}computeEdges(){this.edges=[];for(let e=0,t=this.vertices.length;e<t;++e)this.edges.push([this.vertices[e],this.vertices[(e+1)%t]])}project(e,t){let i=this.matrix;return t&&(i=Lt.append(t.worldMatrix,i)),Lt.applyInverse(e,i)}intersects(e,t,i){return this.intersectsInLocalSpace(...this.project([e,t],i))}intersectsInLocalSpace(e,t){let{min:i,max:r}=this;return e>=i[0]&&e<=r[0]&&t>=i[1]&&t<=r[1]}containsPoint(e){let[t,i]=e,[r,s]=this.min,[a,n]=this.max;return t>=r&&t<=a&&i>=s&&i<=n}intersectsBBox2D(e){for(let t=0,i=this.edges.length;t<i;t++){let r=this.edges[t];for(let s=0,a=e.edges.length;s<a;s++){let n=e.edges[s];if(SJ(r,n))return!0}}for(let t=0,i=e.vertices.length;t<i;t++){let r=e.vertices[t];if(this.containsPoint(r))return!0}return!1}ensureMinMax(){let e=this.min,t=this.max;this.min=[Math.min(e[0],t[0]),Math.min(e[1],t[1])],this.max=[Math.max(e[0],t[0]),Math.max(e[1],t[1])]}copy(e){this.min=[...e.min],this.max=[...e.max],Lt.copy(e.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let e=new vy;return e.copy(this),e}},$T,AJ=new Promise(e=>{$T=e}),SA=!1,cp;function MJ(){if(SA)return;if(cp)return cp;async function e(){let t=await vo(()=>import("./ui-L7l3pL7d.js"),__vite__mapDeps([]));$T(t.default??t),SA=!0}return cp=e(),cp}function AA(e){let t=!1;return e.scene.objects.traverse((i,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var ut,iv;async function EJ(e){let t=await AJ;ut||(iv||(iv=t({locateFile:()=>e})),ut=await iv)}var MA=Lt.identity(),eP=class{constructor(e,t=1){this.canvas=e,this._dpr=t,this._width=0,this._height=0,this._strokeMode="inside",this._layerBlur=0,this._backgroundBlur=0,this._dropShadowBlur=0,this._dropShadowOffsetX=0,this._dropShadowOffsetY=0,this._dropShadowColor=Ht.transparent,this._innerShadowBlur=0,this._innerShadowOffsetX=0,this._innerShadowOffsetY=0,this._innerShadowSpread=0,this._innerShadowColor=Ht.transparent,this._fonts=new Map,this._isSizeDirty=!1;try{let i=e.getBoundingClientRect();e.width=i.width*t,e.height=i.height*t}catch{console.log(e.width,t)}this._currentM3Transform=MA,this._currentTransform=new Float32Array(MA)}get dpr(){return this._dpr}set dpr(e){this._dpr=e,this._isSizeDirty=!0}async init(){var e,t;if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await EJ(this.wasmURL),this._surface=ut.MakeWebGLCanvasSurface(this.canvas),this.ctx=(e=this._surface)==null?void 0:e.getCanvas(),this._paint=new ut.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(ut.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(ut.PaintStyle.Stroke),(t=this.ctx)==null||t.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(e){this._currentM3Transform=e,this._currentTransform.set(e)}async loadFont(e,t){let i=await(await fetch(e)).arrayBuffer();this.registerFont(i,t)}registerFont(e,t){if(this._fonts.has(t))return;let i=ut.FontMgr.FromData(e);if(i)this._fonts.set(t,i);else throw new Error("Invalid font data for "+t)}get width(){return this._width}get height(){return this._height}set strokeColor(e){this._paintStroke&&this._paintStroke.setColor(dp(e),ut.ColorSpace.DISPLAY_P3)}set fillColor(e){this._paintFill&&this._paintFill.setColor(dp(e),ut.ColorSpace.DISPLAY_P3)}set lineWidth(e){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?e:e*2)}set strokeMode(e){this._strokeMode=e}set dropShadowBlur(e){this._dropShadowBlur=e}set dropShadowColor(e){this._dropShadowColor=e}set dropShadowOffsetX(e){this._dropShadowOffsetX=e}set dropShadowOffsetY(e){this._dropShadowOffsetY=e}set innerShadowBlur(e){this._innerShadowBlur=e}set innerShadowColor(e){this._innerShadowColor=e}set innerShadowOffsetX(e){this._innerShadowOffsetX=e}set innerShadowOffsetY(e){this._innerShadowOffsetY=e}set innerShadowSpread(e){this._innerShadowSpread=e}set layerBlur(e){this._layerBlur=e}set backgroundBlur(e){this._backgroundBlur=e}clear(){var e;(e=this.ctx)==null||e.clear(ut.TRANSPARENT)}save(){var e;(e=this.ctx)==null||e.save()}restore(){var e;(e=this.ctx)==null||e.restore()}beginPath(){var e;(e=this._currentPath)==null||e.delete(),this._currentPath=new ut.Path}closePath(){let e=this._currentPath;if(e){if(e.isEmpty())return;let t=e.getBounds();(t[3]-t[1]||t[2]-t[0])&&e.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(e,t,i,r,s=0,a=0,n=0,o=0){var h,c;let l=ut.XYWHRect(e,t,i,r);if(s===0&&a===0&&o===0&&n===0)(h=this.ctx)==null||h.clipRect(l,ut.ClipOp.Intersect,!0);else{let d=ut.RRectXY(l,s,s);d[4]=d[5]=s,d[6]=d[7]=a,d[8]=d[9]=n,d[10]=d[11]=o,(c=this.ctx)==null||c.clipRRect(d,ut.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let e=Lt.invert(this.currentTransform);this.ctx.concat(e);let t=Lt.translate(Lt.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(t),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(e,t,i=!0){var r,s,a,n;if(this.ctx&&this._currentPath){let o,l=!1;if(i&&this._hasDropShadow()){let h=e.copy();h.setColor(dp(this._dropShadowColor));let c;this._dropShadowBlur>0&&(c=ut.MaskFilter.MakeBlur(ut.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(((r=this.camera)==null?void 0:r.scale)??1),!1),h.setMaskFilter(c)),this.ctx.save(),this.ctx.clipPath(this._currentPath,ut.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),t(h),this.ctx.restore(),h.delete(),c==null||c.delete()}if(this._backgroundBlur>0&&i){this.ctx.save(),this.ctx.clipPath(this._currentPath,ut.ClipOp.Intersect,!0);let h=ut.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,ut.TileMode.Clamp,null),c=e.copy();c.setImageFilter(h),c.setAlphaf(1);let d=this._currentPath.computeTightBounds();this.ctx.saveLayer(c,d,null,ut.SaveLayerInitWithPrevious),this.ctx.drawColor(e.getColor()),this.ctx.restore(),this.ctx.restore(),c.delete(),h.delete(),l=!0}if(this._layerBlur>0){let h=e.copy();o=ut.MaskFilter.MakeBlur(ut.BlurStyle.Normal,this._layerBlur*this.dpr*(((s=this.camera)==null?void 0:s.scale)??1),!1),h.setMaskFilter(o),t(h),h.delete(),o.delete(),l=!0}if(l||t(e),i&&this._hasInnerShadow()){let h=new ut.Paint;h.setAntiAlias(!0),h.setStyle(ut.PaintStyle.Fill),h.setColor(dp(this._innerShadowColor));let c;this._innerShadowBlur>0&&(c=ut.MaskFilter.MakeBlur(ut.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(((a=this.camera)==null?void 0:a.scale)??1),!1),h.setMaskFilter(c));let d=this._currentPath.computeTightBounds(),[u,p,f,g]=d,m=f-u,v=g-p;this.ctx.save(),this.ctx.clipPath(this._currentPath,ut.ClipOp.Intersect,!0),this.ctx.saveLayer(h,d,null,ut.SaveLayerInitWithPrevious),(n=this.ctx)==null||n.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(ut.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+m+Math.abs(this._innerShadowOffsetX*2),2e3+v+Math.abs(this._innerShadowOffsetY*2)),h),h.setBlendMode(ut.BlendMode.Clear),this.ctx.drawPath(this._currentPath,h),this.ctx.restore(),this.ctx.restore(),h.delete(),c==null||c.delete()}}}_paintInner(e,t=!0){if(this.ctx&&this._currentPath&&e){let i=this.ctx,r=this._currentPath;this._applyEffectsToPaint(e,s=>{let a=!1;!t&&this._strokeMode!=="center"&&(i.save(),i.clipPath(r,this._strokeMode==="outside"?ut.ClipOp.Difference:ut.ClipOp.Intersect,!0),a=!0),i.drawPath(r,s),a&&i.restore()},t)}}_hasDropShadow(){var e;return((e=this._dropShadowColor)==null?void 0:e.a)>0}_hasInnerShadow(){var e;return((e=this._innerShadowColor)==null?void 0:e.a)>0}path(e){var t;(t=this._currentPath)==null||t.addPath(ut.Path.MakeFromSVGString(e))}ellipse(e,t,i,r,s,a,n,o){var h;if(!EA([e,t,i,r])||!this._currentPath)return;if(i<0||r<0)throw Error("radii cannot be negative");let l=ut.XYWHRect(e-i,t-r,i*2,r*2);(h=this._currentPath)==null||h.addOval(l)}rect(e,t,i,r,s=0,a=0,n=0,o=0){var h,c;let l=ut.XYWHRect(e,t,i,r);if(EA(l))if(s===0&&a===0&&o===0&&n===0)(h=this._currentPath)==null||h.addRect(l);else{let d=ut.RRectXY(l,s,s);d[4]=d[5]=s,d[6]=d[7]=a,d[8]=d[9]=n,d[10]=d[11]=o,(c=this._currentPath)==null||c.addRRect(d)}}getHorizontalAlign(e){switch(e){case 2:return ut.TextAlign.Right;case 3:return ut.TextAlign.Center;case 4:return ut.TextAlign.Justify;case 1:default:return ut.TextAlign.Left}}drawTextInner(e,t,i,[r,s,a,n],o,l,h=!0){let c=0,{ctx:d}=this;if(!d)return c;let u=l.copy(),p=l.copy();return p.setAlphaf(0),this._applyEffectsToPaint(u,f=>{t.pushPaintStyle(i,f,p),t.addText(e);let g=t.build();g.layout(a);let m=s;o===2?m+=(n-g.getHeight())/2:o===3&&(m+=n-g.getHeight()),d.drawParagraph(g,r,m),c=g.getHeight(),t.reset(),g.delete()},h),u.delete(),p.delete(),c}drawText(e,t){let i=0,r=this._fonts.get(t.font),{ctx:s,_paintFill:a,_paintStroke:n}=this;if(r&&s){let o=new ut.TextStyle({fontFamilies:[t.font],fontSize:t.fontSize,heightMultiplier:t.lineHeight,letterSpacing:t.letterSpacing}),l=new ut.ParagraphStyle({textStyle:o,textAlign:this.getHorizontalAlign(t.horizontalAlign)}),h=ut.XYWHRect(t.x,t.y,t.width,t.height),c=ut.ParagraphBuilder.Make(l,r);a&&(i=this.drawTextInner(e,c,o,h,t.verticalAlign,a,!0)),n&&(i=this.drawTextInner(e,c,o,h,t.verticalAlign,n,!1)),c.delete()}return{height:i}}render(){var e;(e=this._surface)==null||e.flush()}moveTo(e,t){var i;(i=this._currentPath)==null||i.moveTo(e,t)}lineTo(e,t){var i;(i=this._currentPath)==null||i.lineTo(e,t)}bezierCurveTo(e,t,i,r,s,a){var n;(n=this._currentPath)==null||n.cubicTo(e,t,i,r,s,a)}quadraticCurveTo(e,t,i,r){var s;(s=this._currentPath)==null||s.quadTo(e,t,i,r)}setTransform(e,t=!1){var s,a,n,o,l;if(!this.ctx)return;let i=this.ctx.getTotalMatrix(),r=Lt.invert(i);if(r&&this.ctx.concat(r),(s=this.ctx)==null||s.scale(this.dpr,this.dpr),((a=this.camera)==null?void 0:a.enabled)&&((n=this.ctx)==null||n.concat(this.camera.worldMatrix),t)){let h=Lt.getScale(this.camera.worldMatrix);(o=this.ctx)==null||o.scale(1/h[0],1/h[1])}(l=this.ctx)==null||l.concat(e),this.currentTransform=e}transform(e){var t;(t=this.ctx)==null||t.concat(e)}setSize(e,t){var i;!this._isSizeDirty&&e===this._width&&t===this._height||(this._isSizeDirty=!1,this._width=e,this._height=t,this.canvas.style.width=e+"px",this.canvas.style.height=t+"px",this.canvas.width=e*this.dpr,this.canvas.height=t*this.dpr,this._surface&&(this._surface=ut.MakeWebGLCanvasSurface(this.canvas),this.ctx=(i=this._surface)==null?void 0:i.getCanvas()))}};function EA(e){for(let t=0;t<e.length;t++)if(e[t]!==void 0&&!Number.isFinite(e[t]))return!1;return!0}function dp({r:e,g:t,b:i,a:r}){return ut.Color4f(e,t,i,r)}var CA=class{constructor(e,t,i){this.uuid=e,this.data=t,this.enabled=!1,this.color=Ht.transparent,this.blurRadius=0,this.offset=[0,0],this.spread=0,this.update(t)}update(e){e.color!==void 0&&(this.color=e.color),e.enabled!==void 0&&(this.enabled=e.enabled),e.blurRadius!==void 0&&(this.blurRadius=e.blurRadius),e.offset!==void 0&&(this.offset=e.offset),e.spread!==void 0&&(this.spread=e.spread)}},TA=class{constructor(e,t,i){this.uuid=e,this.data=t,this.enabled=!1,this.radius=0,this.update(t)}update(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.radius!==void 0&&(this.radius=e.radius)}},CJ=class{constructor(e,t,i){this.uuid=e,this.data=t,this.enabled=!1,this.color=Ht.transparent,this.update(t)}update(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.color!==void 0&&(this.color=e.color)}},TJ=class{constructor(e,t,i){this.uuid=e,this.data=t,this.enabled=!1,this.color=Ht.transparent,this.thickness=0,this.mode="inside",this.update(t)}update(e){e.enabled!==void 0&&(this.enabled=e.enabled),e.color!==void 0&&(this.color=e.color),e.thickness!==void 0&&(this.thickness=e.thickness),e.mode!==void 0&&(this.mode=e.mode)}},er=class extends ar{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.autoClose=!0,this.fill=new CJ(e+"-fill",t.fill,i),this.stroke=new TJ(e+"-stroke",t.stroke,i),this.dropShadow=new CA(e+"-dropShadow",t.dropShadow,i),this.innerShadow=new CA(e+"-innerShadow",t.innerShadow,i),this.backgroundBlur=new TA(e+"-backgroundBlur",t.backgroundBlur,i),this.layerBlur=new TA(e+"-layerBlur",t.layerBlur,i)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ht.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ht.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Ht.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Ht.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.type===0&&(Qt(e.path,["fill"])?this.fill.update(e.props):Qt(e.path,["stroke"])?this.stroke.update(e.props):Qt(e.path,["dropShadow"])?this.dropShadow.update(e.props):Qt(e.path,["innerShadow"])?this.innerShadow.update(e.props):Qt(e.path,["layerBlur"])?this.layerBlur.update(e.props):Qt(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,t){super.updateState(e,t),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let t=new er(this.uuid,this.data,e);return t.parent=void 0,t}},$1=class extends er{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.width=0,this.height=0,this.updateState(t,i)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,t){return wJ(e,t,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e)}clone(e){let t=new $1(this.uuid,this.data,e);return t.parent=void 0,t}},Xd=class extends er{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.width=0,this.height=0,this.cornerRadius=[0,0,0,0],this.updateState(t,i)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let t=new Xd(this.uuid,this.data,e);return t.parent=void 0,t}},ex=class extends er{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this._textHeight=0,this._textHeightDirty=!0,this.width=0,this.height=0,this.updateState(t,i)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ht.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ht.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){var a;(a=this._fontHolder)!=null&&a.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let t=this.data.textTransform,i=this.data.text.textValue.toString(),r=t===2?i.toUpperCase():t===3?i.toLowerCase():i,{height:s}=e.drawText(r,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=s}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:t}){e.font!==void 0&&(this._fontHolder=t.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateFontState(e,t)}clone(e){let t=new ex(this.uuid,this.data,e);return t.parent=void 0,t}},tP=class extends er{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this.curves=[],this.extremasBBox={min:[0,0],max:[0,0]},this.updateState(t,i)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(r=>Uf.extremas(r)),t=[1/0,1/0],i=[-1/0,-1/0];for(let r=0,s=e.length;r<s;r++){let a=e[r];a[0][0]<t[0]&&(t[0]=a[0][0]),a[0][1]<t[1]&&(t[1]=a[0][1]),a[1][0]>i[0]&&(i[0]=a[1][0]),a[1][1]>i[1]&&(i[1]=a[1][1])}return this.extremasBBox.min=[t[0],t[1]],this.extremasBBox.max=[i[0],i[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let i=1,r=this.data.points.length;i<r;i++){let s=this.data.points[i].data,a=this.data.points[i-1].data,n={start:a.position,cp1:a.controlNext.position,cp2:s.controlPrevious.position,end:s.position};this.curves.push(n)}let e=this.data.points[0].data,t=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let i={start:t.position,cp1:t.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(i)}}getCenter(){let[e,t]=this.extremasBBox.min,[i,r]=this.getHalfSize();return[e+i,t+r]}getHalfSize(){let{min:e,max:t}=this.extremasBBox;return[(t[0]-e[0])*.5,(t[1]-e[1])*.5]}innerDraw(e){for(let r=0,s=this.data.points.length;r<s;r++){let a=this.data.points[r].data;if(r===0){let[n,o]=a.position;e.moveTo(n,o)}else{let n=this.data.points[r-1].data,[o,l]=n.controlNext.position,[h,c]=a.controlPrevious.position,[d,u]=a.position,p={start:n.position,cp1:n.controlNext.position,cp2:a.controlPrevious.position,end:a.position};Uf.derive(p),e.bezierCurveTo(o,l,h,c,d,u)}}let t=this.data.points[0].data,i=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[r,s]=i.controlNext.position,[a,n]=t.controlPrevious.position,[o,l]=t.position;e.bezierCurveTo(r,s,a,n,o,l)}}updateState(e,t){super.updateState(e,t),this.computeExtremas()}clone(e){let t=new tP(this.uuid,this.data,e);return t.parent=void 0,t}},Uf;(e=>{function t(n){let o=n.start,l=n.cp1,h=n.cp2,c=n.end,d=[3*(l[0]-o[0]),3*(l[1]-o[1])],u=[3*(h[0]-l[0]),3*(h[1]-l[1])],p=[3*(c[0]-h[0]),3*(c[1]-h[1])],f={start:d,cp:u,end:p};return n.derivative=f,f.derivative=yy.derive(f),f}e.derive=t;function i(n,o,l,h=!1){let c=n-2*o+l;if(c!==0){let d=-Math.sqrt(Math.abs(o*o-n*l)),u=-n+o,p=-(d+u)/c,f=-(-d+u)/c;return[p,f]}else if(o!==l&&c===0)return[(2*o-l)/(2*(o-l))];return[]}function r(n){let o=n.derivative??e.derive(n),l=o.start,h=o.cp,c=o.end;return[i(l[0],h[0],c[0]),i(l[1],h[1],c[1])]}e.droot=r;function s(n){let[o,l]=e.droot(n),h=[n.start[0],n.end[0]],c=[n.start[1],n.end[1]];for(let d of o)h.push(e.compute(n,Math.min(1,Math.max(0,d)))[0]);for(let d of l)c.push(e.compute(n,Math.min(1,Math.max(0,d)))[1]);return h.sort((d,u)=>d-u),c.sort((d,u)=>d-u),[[h[0],c[0]],[h[h.length-1],c[c.length-1]]]}e.extremas=s;function a(n,o){if(o===0)return[...n.start];if(o===1)return[...n.end];let l=1-o,h=l*l,c=o*o,d=h*l,u=h*o*3,p=l*c*3,f=o*c;return[d*n.start[0]+u*n.cp1[0]+p*n.cp2[0]+f*n.end[0],d*n.start[1]+u*n.cp1[1]+p*n.cp2[1]+f*n.end[1]]}e.compute=a})(Uf||(Uf={}));var yy;(e=>{function t(s){let a=s.start,n=s.cp,o=s.end,l=[2*(n[0]-a[0]),2*(n[1]-a[1])],h=[2*(o[0]-n[0]),2*(o[1]-n[1])],c={start:l,end:h};return c.derivative=xy.derive(c),s.derivative=c,c}e.derive=t;function i(s){let a=s.derivative??e.derive(s),n=a.start,o=a.end;return[n[0]!==o[0]?n[0]/(n[0]-o[0]):0,n[1]!==o[1]?n[1]/(n[1]-o[1]):0]}e.droot=i;function r(s,a){if(a===0)return[...s.start];if(a===1)return[...s.end];let n=1-a,o=n*n,l=a*a,h=o,c=n*a*2,d=l;return[h*s.start[0]+c*s.cp[0]+d*s.end[0],h*s.start[1]+c*s.cp[1]+d*s.end[1]]}e.compute=r})(yy||(yy={}));var xy;(e=>{function t(r){let s=r.start,a=r.end,n=[a[0]-s[0],a[1]-s[1]];return r.derivative=n,r.derivative}e.derive=t;function i(r,s){if(s===0)return[...r.start];if(s===1)return[...r.end];let a=r.start,n=r.end;return[a[0]+(n[0]-a[0])*s,a[1]+(n[1]-a[1])*s]}e.compute=i})(xy||(xy={}));var Ma=class extends ks{constructor(e,t,i){super(e,t,i),this.uuid=e,this.width=0,this.height=0,this.clipped=!0,this.background=new Xd(e+"-background",Ed.defaultData,i),this.background.parent=this,this.updateState(t,i)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){var e;super.updateLocalMatrix(),(e=this.background)==null||e.updateLocalMatrix()}updateWorldMatrix(e,t,i){var r;super.updateWorldMatrix(e,t,i),(r=this.background)==null||r.updateWorldMatrix(e,t,i)}draw(e){if(!this.visible)return;e.save();let t=this.width,i=this.height;this.applyTransforms(e),this.background.width=t,this.background.height=i,this.background.draw(e),this.clipped&&e.clipRect(0,0,t,i,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let t=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,t=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,t=!0),t&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,t){super.updateState(e,t),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),e.type===0&&(Qt(e.path,["fill"])?this.fill.update(e.props):Qt(e.path,["stroke"])?this.stroke.update(e.props):Qt(e.path,["dropShadow"])?this.dropShadow.update(e.props):Qt(e.path,["innerShadow"])?this.innerShadow.update(e.props):Qt(e.path,["layerBlur"])?this.layerBlur.update(e.props):Qt(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let t=new Ma(this.uuid,this.data,e);t.parent=void 0;for(let i of this.children)t.add(i.clone(e));return t}},PJ=xo(Q2(),1),mm=class extends er{constructor(e,t,i){super(e,t,i),this.uuid=e,this.data=t,this._pathBBox=new DOMRect,this.path="",this.updateState(t,i),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg"),t=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(e),t.setAttribute("d",this.path),e.appendChild(t),this._pathBBox=t.getBBox(),e.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,t){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&t>=this._pathBBox.y&&t<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,t){super.updateState(e,t),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let t=new mm(this.uuid,this.data,e);return t.parent=void 0,t}};function DJ(e,t=1,i=1){if(t<=0||i<=0)return e;let r=(0,PJ.parseSVG)(e).map(s=>{let a={...s};return"x"in a&&(a.x=a.x*t),"y"in a&&(a.y=a.y*i),"x1"in a&&(a.x1=a.x1*t),"x2"in a&&(a.x2=a.x2*t),"y1"in a&&(a.y1=a.y1*i),"y2"in a&&(a.y2=a.y2*i),"rx"in a&&(a.rx=a.rx*t),"ry"in a&&(a.ry=a.ry*i),a});return IJ(r)}function IJ(e){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],i;return e.map(r=>{let s=[];t.forEach(n=>{if(n in r){let o=r[n]*1;s.length&&o>=0&&s.push(","),s.push(o)}});let a=(i===r.code?s[0]<0?"":",":r.code)+s.join("");return i=r.code,a}).join("")}function OJ(e,t,i){switch(t.type){case"ellipse2d":return new $1(e,t,i);case"rectangle2d":return new Xd(e,t,i);case"text2d":return new ex(e,t,i);case"vector2d":return new tP(e,t,i);case"path2d":return new mm(e,t,i);case"frame2d":return new Ma(e,t,i);case"group2d":default:return new po(e,t,i)}}var iP=class{constructor(e,t,i){this.uuid=e,this.data=t,this.group=new po(iP.GROUP_ID,{...Cf.defaultData},i),this.createChildrenObjects(t.objects,this.group,i)}createObject(e,t,i,r,s,a){let n=OJ(e,t,a);n&&(r.add(n),r.children.splice(s,0,r.children.pop()),n.updateWorldMatrix(),i.length>0&&(n instanceof po||n instanceof Ma)&&this.createChildrenObjects(i,n,a))}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}draw(e){this.group.draw(e)}updateEntityByOp(e,t,i,r){let s=this.find(e);if(s)try{s.updateByOp(t,i,{shared:r})}catch(a){console.error(a)}}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this.group:this.find(e.parent);i!==void 0&&i instanceof ks&&(this.createObject(e.id,e.data,e.children,i,e.localIndex,t),i.requestRender())}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i!==void 0&&i.parent!==void 0&&i.parent instanceof ks){let r=i.parent;i.resetBBoxNeedsUpdate(),r==null||r.remove(i),r==null||r.requestRender()}}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i!==void 0){let r=i.parent,s=e.parent===null?this:this.find(e.parent);if(s instanceof ks||s===this){s.add(i);let a=e.localIndex;s.children.splice(a,0,s.children.pop()),i.updateWorldMatrix(!0,!1,!0),r==null||r.requestRender(),i.requestRender()}i.resetBBoxNeedsUpdate()}}}add(e){this.group.add(e)}remove(e){this.group.remove(e)}traverse(e){this.group.traverse(t=>{t!==this.group&&e(t)})}intersectsChildren(e,t,i,r=!1,s=[]){return this.group.intersectsChildren(e,t,i,r,s,!0)}intersectsChildrenReverse(e,t,i,r=!1,s=[]){return this.group.intersectsChildrenReverse(e,t,i,r,s,!0)}find(e){return this.group.find(e)}get children(){return this.group.children}project(e,t){return this.group.project(e,t)}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this.group;){let s=r;r=r.parent;let a=r.children.indexOf(s);i.splice(0,0,a)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>FE(i.sortKey,r.sortKey)),t.map(i=>i.entity)}},tx=iP;tx.GROUP_ID="scene2d";function rP({constraints:e,newParentWidth:t,newParentHeight:i,initialParentWidth:r,initialParentHeight:s,objectInitialWidth:a,objectInitialHeight:n,objectInitialPosition:o}){let{horizontalConstraint:l,verticalConstraint:h}=e,c=t-r,d=i-s,u=a,p=n,f=o[0],g=o[1];if(l!==0){if(l===1)f+=c;else if(l===3)f+=c/2;else if(l===2)u=Math.max(1,u+c);else if(l===4){let m=t/r;u*=m,f*=m}}if(h!==0){if(h===1)g+=d;else if(h===3)g+=d/2;else if(h===2)p=Math.max(1,p+d);else if(h===4){let m=i/s;p*=m,g*=m}}return{width:u,height:p,position:[f,g]}}xo(Q2(),1);var RJ=`
  5849. varying vec2 vUv;
  5850. void main() {
  5851. vUv = uv;
  5852. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  5853. }`,LJ=`
  5854. uniform sampler2D tDiffuse;
  5855. varying vec2 vUv;
  5856. void main() {
  5857. vec4 texel = texture2D( tDiffuse, vUv );
  5858. gl_FragColor = texel;
  5859. }`,zJ=new Xf(-1,1,1,-1,0,1),BJ=class extends Ge{constructor(){super(),this.setAttribute("position",new Ie([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ie([0,2,0,0,2,0],2))}},FJ=new BJ,UJ=class{constructor(e){this._mesh=new Jt(FJ,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,zJ)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},sP=new Dt({defines:{},uniforms:{tDiffuse:new ye(null)},vertexShader:RJ,fragmentShader:LJ}),NJ=new UJ(sP),rv=null,sv=null,kJ=()=>(rv===null&&(rv=document.createElement("canvas")),rv),VJ=e=>(sv===null&&(sv=new eP(e)),sv),jJ=Lt.identity(),aP=class{constructor(e,t,i,r){this.uuid=e,this.width=t,this.height=i,this.context=r,this.enabled=!0,this.isScreenSpace=!1,this.dpr=window.devicePixelRatio,this.isFrameDirty=!1,this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()},this._innerApplySize=()=>{let s=this.width,a=this.height,n=this.dpr;this.renderer.dpr=this.isScreenSpace?n:Math.floor(2048/Math.max(s,a)),this.renderer.setSize(s,a)},this.onFrameOverrideObjectEvent=s=>{var a,n;if(((a=s.target)==null?void 0:a.uuid)!==void 0){let o=(n=this.frameRoot)==null?void 0:n.find(s.target.uuid);o&&o.dispatchEvent({...s,target:o})}},this.scene2d=new tx(Re.generateUUID(),j0.defaultData,{dpr:window.devicePixelRatio,shared:r.shared}),this.canvas=kJ(),this.renderer=VJ(this.canvas),this.promise=this.init(),this.renderTarget=new Pt(1,1,{type:mn,stencilBuffer:!1,depthBuffer:!1}),r.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=r.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new GF(this.canvas)),this._canvasTexture}async init(){this.renderer instanceof eP&&(this.renderer.wasmURL=TT.skiaWasmUrl),await this.renderer.init()}render(e){var t,i;if(this.isFrameDirty){this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),(t=this.frameOverride)==null||t.draw(this.renderer),this.renderer.render(),sP.uniforms.tDiffuse.value=this.canvasTexture,this.canvasTexture.needsUpdate=!0;let r=e.getRenderTarget();e.setRenderTarget(this.renderTarget),e.clear(),NJ.render(e),e.setRenderTarget(r),(i=this.textureHolder)==null||i.setNeedsUpdate(!0)}}updateEntity2DByOp(e,t,i,r){this.scene2d.updateEntityByOp(e,t,i,r),this.applySize()}updateTreeByOp(e,t){this.scene2d.updateTreeByOp(e,t),this.applySize()}applyOverrides(e){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let t=(e==null?void 0:e.width)??this.width,i=(e==null?void 0:e.height)??this.height;this.frameOverride.width=t,this.frameOverride.height=i,this.frameOverride.localMatrix=jJ,this.isScreenSpace&&(this.frameOverride.fill.color=Ht.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:t,height:i},nP({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(e,t=window.devicePixelRatio){var o,l;let i=Math.max(1,(e==null?void 0:e.width)??this.width),r=Math.max(1,(e==null?void 0:e.height)??this.height);this.dpr=t,this.width=i,this.height=r,this._innerApplySize();let s=1,a=512,n=512;(i*t<a||r*t<n)&&(s=Math.max(a/(i*t),n/(r*t))),this.renderTarget.setSize(i*t*s,r*t*s),(o=this._canvasTexture)==null||o.dispose(),this._canvasTexture=void 0,this.applyOverrides(e),(l=this.frameOverride)==null||l.requestRender()}applyFrame(e){var i,r;let t=this.context.scene.find2D(e);if(!(!t||!(t instanceof Ma)))return this.disposeFrameOverride(),this.frameRoot=t,this.frameOverride=t.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),(i=this.frame)==null||i.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(s=>{s.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(s=>{s.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),(r=this.frame)==null||r.requestRender(),t}get frame(){return this.frameOverride}get frameId(){var e;return(e=this.frame)==null?void 0:e.uuid}find(e){return this.scene2d.find(e)}get texture(){var e;return(e=this.textureHolder)==null?void 0:e.getTexture(1001)}disposeFrameOverride(){var e,t,i;(e=this.frameOverride)==null||e.removeEventListener("render",this.onRenderRequestedDownstream),(t=this.frameOverride)==null||t.traverse(r=>{r.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),(i=this.frameOverride)==null||i.traverse(r=>{r.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function nP({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:a}){if(e instanceof Ma&&t instanceof Ma||e instanceof po&&t instanceof po)for(let n=0,o=e.children.length;n<o;n++){let l=e.children[n],h=t.children[n];l&&h&&l.uuid===h.uuid&&HJ({objectOverride:l,objectRoot:h,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:a})}}function GJ(e){if(by(e))return[e.width,e.height];if(e instanceof mm){let[t,i]=e.getHalfSize();return[t*2,i*2]}else if(e instanceof po){let[t,i]=e.recursiveBBox.getHalfSize();return[t*2,i*2]}return[0,0]}function HJ({objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:a}){let[n,o]=GJ(t),{width:l,height:h,position:c}=rP({constraints:e.data,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:a,objectInitialWidth:n,objectInitialHeight:o,objectInitialPosition:t.position});if(e.position=c,e.data={...e.data,position:c},e.states)for(let d in e.states)WJ({stateId:d,objectOverride:e,objectRoot:t,newParentWidth:i,newParentHeight:r,initialParentWidth:s,initialParentHeight:a});if(by(e)||e instanceof po)by(e)&&(e.width=l,e.height=h,e.data={...e.data,width:l,height:h}),nP({objectOverride:e,objectRoot:t,newParentWidth:l,newParentHeight:h,initialParentWidth:n,initialParentHeight:o});else if(e instanceof mm){let d=t,u=n!==0?l/n:1,p=o!==0?h/o:1;e.path=DJ(d.path,u,p),e.data={...e.data,path:e.path}}}function WJ({stateId:e,objectOverride:t,objectRoot:i,newParentWidth:r,newParentHeight:s,initialParentWidth:a,initialParentHeight:n}){var h,c;let o=(h=t.states)==null?void 0:h[e],l=(c=i.states)==null?void 0:c[e];if(o&&l){let{width:d,height:u,position:p}=rP({constraints:t.data,newParentWidth:r,newParentHeight:s,initialParentWidth:a,initialParentHeight:n,objectInitialWidth:rl.isResizeable(l)?l.width:0,objectInitialHeight:rl.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[e],{position:p}),rl.isResizeable(o)&&Object.assign(t.states[e],{width:d,height:u})}}function by(e){return e instanceof Xd||e instanceof Ma||e instanceof $1||e instanceof ex}var $i=class extends I1(Jr){constructor(e,t,i){super(),this.data=t,this.bgColor=new vr(1,1,1,1),this.fog=null,this.backupFog=new wM(16777215,.1,2e3),this.fogUseBGColor=!1,this.isActive=!1,this.aoColor=new et,this.penumbraSizeArrayCache=null,this.super_Entity(e,t),this.personalCamera=new Mr(ic,{...Sd.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new PU(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene?this.uiScene=new tx((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:i.shared}):t.uiFrame&&this.createUICanvas(t.uiFrame,i)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){var e;return(e=this.uiCanvas)==null?void 0:e.frame}createUICanvas(e,t){this.uiCanvas=new aP(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{var i,r;(i=this.uiCanvas)==null||i.applyFrame(e),(r=this.uiCanvas)==null||r.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Nr(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(t=>{t instanceof ul&&t.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof xl)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&lJ(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let i=this.scene;i.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Nr(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=Nr(e.aoColor,t))}updateByOp(e,t,i,r){let s=this.data.uiFrame;super.updateByOp(e,t,i,r);let a=t;Qt(e.path,["fog"])?this.updateFog(a.fog,i.shared):Qt(e.path,["ao"])?this.updateAo(a.ao,i.shared):Qt(e.path,["ambient"])?this.updateAmbientLight(a.ambient,i.shared):Qt(e.path,["shadow"])?this.updateShadow(a.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||s!==a.uiFrame)&&this.updateUIFrame(e.props.uiFrame,i)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(Nr(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){var e;return((e=this.scene)==null?void 0:e.find(this.data.publish.playCamera))??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof ZT&&i.visible&&e<3&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize??.5,e+=1),i instanceof KT&&i.visible&&e<2&&(this.penumbraSizeArrayCache[3+t]=i.data.penumbraSize??.5,t+=1)})}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let a=s.cloner;Tt.is(s)&&(s.visible||a!=null&&a.object.data.visible)&&((Ns(s)||cy(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),wy(s,e,t,!0)),i(s))}};return i(this),t}updateEntity2DByOp(e,t,i,r){var s;(s=this.uiCanvas)==null||s.updateEntity2DByOp(e,t,i,r)}},qJ=class extends Z1(RU,XT){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let s=new M(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),a=new M(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),n=new Si(s,a),o=new Kp(n,new et(16755200));o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let e in this.gizmos){let t=this.gizmos[e];if(t instanceof Kp){let i=this.shadow.camera,r=new M(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new M(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);t.box.set(r,s),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}},XJ=class extends Ii{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?N1(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},ix=class extends Ii{constructor(e,t,i){super(e,t,i),this._shapeId=null,this._context=i}updateState(e,t){super.updateState(e,t),this.updateShape(),this.refreshAttachedCloners(t)}updateShape(){var r;let e={...this.data.geometry.extrusion.shape};for(let s in e)typeof e[s]=="string"&&(e[s]=this._context.shared.getVariable(e[s],[this.uuid,"geometry","extrusion","shape",s]));let t;if(e.type==="Custom"){let s=e.shapeId;if(s!==this._shapeId&&this.detachShape(),s){this._shapeId=s;let a=this._context.scene.find(s);a!=null&&a.data&&(a.attachedPaths.add(this),t=(r=a.geometry.userData)==null?void 0:r.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let s;switch(e.type){case"Rectangle":s=U1;break;case"Ellipse":s=F1;break;case"Polygon":s=HC;break;case"Star":s=WC;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=s.create({parameters:e}).userData.shape}let i=this.geometry;t&&i.inputs&&(i.inputs.shapeData=t,i.build())}detachShape(){var e;this._shapeId!==null&&((e=this._context.scene.find(this._shapeId))==null||e.attachedPaths.delete(this))}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,t){return super.updateTransformState(e,t)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?N1(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},rx=class extends Q1{constructor(e,t,i){super(e,t,i),this.data=t}},Eh=class extends ac(hn,Wd){constructor(e,t,i){super(),t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,i)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let i=Sf.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(i){let r,s;for(let a of Jn.rootOverrideProps)e[a]===void 0?(r===void 0&&(r={...e}),r[a]=i.data[a]):(s===void 0&&(s={}),s[a]=e[a],r===void 0&&(r={...e}),r[a]=so.apply(i.data[a],e[a]));return this.overrideData=s,r}else return{...Hi.defaultData,...e,...Sa(Hi.defaultData,Jn.rootOverrideProps)}}updateByOp(e,t,i,r){let s;if(this.isInstanceRoot&&!r){if(t=this.transformAssignData(t,i),e.type===0&&e.path.length===0&&this.component)for(let a of Jn.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&Jn.rootOverrideProps.includes(e.path[0])){let a=e.path[0];s===void 0&&(s={...e,path:[],props:{[a]:t[a]}})}}super.updateByOp(s??e,t,i,r)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let i=e.scene.find(t.component)??null,r=!1;if(i!==this.oldComponent){if(this.oldComponent){let s=0;for(let a of this.children)if(Tt.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),sx(a),s+=1;else break;this.children.splice(0,s)}r=!0}if(i){let s={};oP(e,[this.uuid],t.overrides,this,i,i,0,r,s);for(let a of this.children)if(Tt.is(a)){let n=a.data;n.type==="Empty"&&n.animations&&a.traverseEntity(o=>{let l=o.dataPatched;if(o instanceof Ii&&l.bones&&l.boneInverses){let h=o.dataPatched;if(h.bones&&h.boneInverses){let c=h.bones.map(p=>e.scene.find(s[p])),d=h.boneInverses.map(p=>new we().fromArray(p)),u=new qy(c,d);o.bind(u,o.bindMatrix)}}else o.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function sx(e){if(e.component){let t=e.component.instances.indexOf(e);t>=0&&e.component.instances.splice(t,1);for(let i of e.children)Tt.is(i)&&sx(i)}}function PA(e,t,i,r){return e.component===t&&y1(e.identity,r)?e.overrideData===i?2:1:0}function oP(e,t,i,r,s,a,n,o,l){if(n>50)return!1;if(r.component!==s){if(r.component){let c=r.component.instances.indexOf(r);c>=0&&r.component.instances.splice(c,1)}s.instances.find(c=>c===r)||s.instances.push(r),r.component=s}s instanceof Eh&&s.isInstanceRoot&&s.expandInstanceChildren(e);let h=0;for(let c of s.children)if(Tt.is(c)){let d=[...t,...typeof c.identity=="string"?[c.identity]:c.identity],u=xf.resolve(i,d,1);u!=null&&!(u instanceof Ri)&&(Object.setPrototypeOf(u,Ri.prototype),console.error("wrong prototype"));let p=null,f;if(!o){let g=r.children[h];if(p=Tt.is(g)?g:null,p!==null){let m=PA(p,c,u,d);f=m>=1?p.stateSelection:void 0,m!==2&&(p=null)}if(p===null&&(p=e.scene.findInstance(d)??null,p!==null)){let m=PA(p,c,u,d);if(f=m>=1?p.stateSelection:void 0,m!==2)p=null;else{let v=p.parent.children.indexOf(p);p.parent.children.splice(v,1),r.children.splice(h,0,p),p.parent===r?v<=h&&console.error("not possible"):(p.parent=r,p.matrixWorldNeedsUpdate=!0,p.resetBBoxNeedsUpdate(),p.updateVisible(),e.pendingDeletes.delete(p))}}}if(p===null){let g=u?so.apply(c.data,u):c.data;hl.is(g.type)&&(g={...g,type:"Empty"}),p=$n.createEntity(d,g,e),p.overrideData=u,r.add(p),r.children.splice(r.children.length-1,1),r.children.splice(h,0,p),p.updateState(p.data,e),f&&p.changeSelectedState(f,e),e.scene.registerInstanceAndSetUuid(p)}if(p.isBone){let g=p.identity[p.identity.length-1];l[g]=p.uuid}h+=1,oP(e,t,i,p,c,a,n+1,o,l)}if(!o){let c=h;for(;;){let d=r.children[h];if(Tt.is(d))e.pendingDeletes.add(d);else break;h+=1}r.children.splice(c,h-c)}return!0}var YJ=class extends ac(_M,Wd){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(e,t){this.updateState_Entity(e,t)}},Sr=class extends Ii{constructor(e,t,i){super(e,t,i),this.onBeforeRender=r=>{this.uiCanvas.render(r)},this.uiCanvas=new aP(e+"-canvas",t.geometry.width,t.geometry.height,i),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,i.shared)})}updateByPatchedOpGeometry(e,t,i){super.updateByPatchedOpGeometry(e,t,i),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,i.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,i.shared))}applySize(e,t){let i=(e==null?void 0:e.width)??this.dataPatched.geometry.width,r=(e==null?void 0:e.height)??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:i,height:r}),this.applyGeometryParametersFromFrame(t)}applyFrame(e,t){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(t),this.applyMaterialParametersFromFrame({shared:t})}applyGeometryParametersFromFrame(e){var i;let t=this.frame;t&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:t.cornerRadius,cornerType:0})}),(i=this.localGeometry)==null||i.dispose(),this.localGeometry=Dd(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let t=this.frame;if(t){let i=t.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:i.radius,alpha:i.enabled?1:0}),this.material.reset(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,t,i,r){this.uiCanvas.updateEntity2DByOp(e,t,i,r),e===this.frameId&&t.type===0&&(t.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(r):Qt(t.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:r}))}get frame(){return this.uiCanvas.frame}get frameId(){var e;return(e=this.frame)==null?void 0:e.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.applySize({width:e.width,height:e.height},t)}},QJ=class{constructor(e,t,i){this.variables=[],this.currentTextureIndex=0;let r=jt,s=new Jr,a=new bo;a.position.z=1;let n={passThruTexture:{value:null}},o=c(u(),n),l=new Jt(new Ea(2,2),o);s.add(l),this.setDataType=function(p){return r=p,this},this.addVariable=function(p,f,g){let m=this.createShaderMaterial(f),v={name:p,initialValueTexture:g,material:m,dependencies:null,renderTargets:[],wrapS:null,wrapT:null,minFilter:_t,magFilter:_t};return this.variables.push(v),v},this.setVariableDependencies=function(p,f){p.dependencies=f},this.init=function(){if(i.capabilities.isWebGL2===!1&&i.extensions.has("OES_texture_float")===!1)return"No OES_texture_float support for float textures.";if(i.capabilities.maxVertexTextures===0)return"No support for vertex shader textures.";for(let p=0;p<this.variables.length;p++){let f=this.variables[p];f.renderTargets[0]=this.createRenderTarget(e,t,f.wrapS,f.wrapT,f.minFilter,f.magFilter),f.renderTargets[1]=this.createRenderTarget(e,t,f.wrapS,f.wrapT,f.minFilter,f.magFilter),this.renderTexture(f.initialValueTexture,f.renderTargets[0]),this.renderTexture(f.initialValueTexture,f.renderTargets[1]);let g=f.material,m=g.uniforms;if(f.dependencies!==null)for(let v=0;v<f.dependencies.length;v++){let y=f.dependencies[v];if(y.name!==f.name){let x=!1;for(let w=0;w<this.variables.length;w++)if(y.name===this.variables[w].name){x=!0;break}if(!x)return"Variable dependency not found. Variable="+f.name+", dependency="+y.name}m[y.name]={value:null},g.fragmentShader=`
  5860. uniform sampler2D `+y.name+`;
  5861. `+g.fragmentShader}}return this.currentTextureIndex=0,null},this.compute=function(){let p=this.currentTextureIndex,f=this.currentTextureIndex===0?1:0;for(let g=0,m=this.variables.length;g<m;g++){let v=this.variables[g];if(v.dependencies!==null){let y=v.material.uniforms;for(let x=0,w=v.dependencies.length;x<w;x++){let _=v.dependencies[x];y[_.name].value=_.renderTargets[p].texture}}this.doRenderTarget(v.material,v.renderTargets[f])}this.currentTextureIndex=f},this.getCurrentRenderTarget=function(p){return p.renderTargets[this.currentTextureIndex]},this.getAlternateRenderTarget=function(p){return p.renderTargets[this.currentTextureIndex===0?1:0]},this.dispose=function(){l.geometry.dispose(),l.material.dispose();let p=this.variables;for(let f=0;f<p.length;f++){let g=p[f];g.initialValueTexture&&g.initialValueTexture.dispose();let m=g.renderTargets;for(let v=0;v<m.length;v++)m[v].dispose()}};function h(p){p.defines.resolution="vec2( "+e.toFixed(1)+", "+t.toFixed(1)+" )"}this.addResolutionDefine=h;function c(p,f){f=f||{};let g=new Dt({uniforms:f,vertexShader:d(),fragmentShader:p});return h(g),g}this.createShaderMaterial=c,this.createRenderTarget=function(p,f,g,m,v,y){return p=p||e,f=f||t,g=g||ai,m=m||ai,v=v||_t,y=y||_t,new Pt(p,f,{wrapS:g,wrapT:m,minFilter:v,magFilter:y,format:ni,type:r,depthBuffer:!1})},this.createTexture=function(){let p=new Float32Array(e*t*4),f=new Ur(p,e,t,ni,jt);return f.needsUpdate=!0,f},this.renderTexture=function(p,f){n.passThruTexture.value=p,this.doRenderTarget(o,f),n.passThruTexture.value=null},this.doRenderTarget=function(p,f){let g=i.getRenderTarget(),m=i.xr.enabled,v=i.shadowMap.autoUpdate,y=i.outputEncoding,x=i.toneMapping;i.xr.enabled=!1,i.shadowMap.autoUpdate=!1,i.outputEncoding=qs,i.toneMapping=_a,l.material=p,i.setRenderTarget(f),i.render(s,a),l.material=o,i.xr.enabled=m,i.shadowMap.autoUpdate=v,i.outputEncoding=y,i.toneMapping=x,i.setRenderTarget(g)};function d(){return`void main() {
  5862. gl_Position = vec4( position, 1.0 );
  5863. }
  5864. `}function u(){return`uniform sampler2D passThruTexture;
  5865. void main() {
  5866. vec2 uv = gl_FragCoord.xy / resolution.xy;
  5867. gl_FragColor = texture2D( passThruTexture, uv );
  5868. }
  5869. `}}},or=new pr,up=new M,ZJ=class{constructor(e){let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(console.warn("THREE.MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry."),t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.colorAttribute=this.geometry.getAttribute("color"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(e){return this.weightAttribute=e?this.geometry.getAttribute(e):null,this}build(){let e=this.positionAttribute,t=this.weightAttribute,i=new Float32Array(e.count/3);for(let s=0;s<e.count;s+=3){let a=1;t&&(a=t.getX(s)+t.getX(s+1)+t.getX(s+2)),or.a.fromBufferAttribute(e,s),or.b.fromBufferAttribute(e,s+1),or.c.fromBufferAttribute(e,s+2),a*=or.getArea(),i[s/3]=a}this.distribution=new Float32Array(e.count/3);let r=0;for(let s=0;s<i.length;s++)r+=i[s],this.distribution[s]=r;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t,i){let r=this.distribution[this.distribution.length-1],s=this.binarySearch(this.randomFunction()*r);return this.sampleFace(s,e,t,i)}binarySearch(e){let t=this.distribution,i=0,r=t.length-1,s=-1;for(;i<=r;){let a=Math.ceil((i+r)/2);if(a===0||t[a-1]<=e&&t[a]>e){s=a;break}else e<t[a]?r=a-1:i=a+1}return s}sampleFace(e,t,i,r){let s=this.randomFunction(),a=this.randomFunction();return s+a>1&&(s=1-s,a=1-a),or.a.fromBufferAttribute(this.positionAttribute,e*3),or.b.fromBufferAttribute(this.positionAttribute,e*3+1),or.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(or.a,s).addScaledVector(or.b,a).addScaledVector(or.c,1-(s+a)),i!==void 0&&or.getNormal(i),r!==void 0&&this.colorAttribute!==void 0&&(or.a.fromBufferAttribute(this.colorAttribute,e*3),or.b.fromBufferAttribute(this.colorAttribute,e*3+1),or.c.fromBufferAttribute(this.colorAttribute,e*3+2),up.set(0,0,0).addScaledVector(or.a,s).addScaledVector(or.b,a).addScaledVector(or.c,1-(s+a)),r.r=up.x,r.g=up.y,r.b=up.z),this}};function KJ(e){let t=new Float32Array(e*e*2);for(let i=0;i<e;i++)for(let r=0;r<e;r++){let s=i*e+r;t[s*2+0]=i/(e-1),t[s*2+1]=r/(e-1)}return t}function JJ(e){let t=Math.ceil(Math.sqrt(e));return Math.max(t,1)}function $J(e,t){let i=new Jt(e.geometry,e.material),r=[],s=[],a=new M,n=new M;i.geometry.index!==null&&(i.geometry=i.geometry.toNonIndexed());let o=new ZJ(i).build();for(let c=0;c<t;c++)o.sample(a,n),r.push(a.x,a.y,a.z),s.push(n.x,n.y,n.z);let l=new Float32Array(r),h=new Float32Array(s);return{positions:l,normals:h}}function DA(e,t){let i=e,r=new Float32Array(4*t*t);for(let a=0;a<t*t;a++)r[4*a]=i[3*a],r[4*a+1]=i[3*a+1],r[4*a+2]=i[3*a+2],r[4*a+3]=0;let s=new Ur(r,t,t,ni,jt);return s.needsUpdate=!0,s}function e$({size:e}){let t=new Float32Array(4*e*e);for(let r=0;r<e*e;r++)t[4*r]=r,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let i=new Ur(t,e,e,ni,jt);return i.needsUpdate=!0,i}function t$(e){let t=new Float32Array(4*e*e);for(let r=0;r<e*e;r++)t[4*r]=0,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let i=new Ur(t,e,e,ni,jt);return i.needsUpdate=!0,i}var i$=`
  5870. // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
  5871. // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
  5872. // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
  5873. uniform sampler2D uOriginalPosition;
  5874. uniform float uTime;
  5875. uniform float uSpeed; // update speed of the particles
  5876. uniform vec3 uWorldOffset;
  5877. uniform vec4 uWorldQuaternion;
  5878. uniform float uMaxLifeTime;
  5879. uniform vec3 uEmitterSize;
  5880. uniform float uFPSRatio; // 1 for 60 FPS
  5881. float random (vec2 st) {
  5882. return fract(sin(dot(st.xy,
  5883. vec2(12.9898,78.233)))*
  5884. 43758.5453123);
  5885. }
  5886. vec3 applyQuaternionToVector( vec4 q, vec3 v ){
  5887. return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );
  5888. }
  5889. vec3 applyForce(vec3 force, float mass) {
  5890. vec3 acceleration = force / mass;
  5891. return acceleration;
  5892. }
  5893. void main() {
  5894. vec2 vUv = gl_FragCoord.xy / resolution.xy;
  5895. vec3 position = texture2D( uCurrentPosition, vUv ).xyz;
  5896. float currentLife = texture2D( uCurrentPosition, vUv ).w; // from 1 to 0
  5897. float isSpawning = texture2D( uCurrentEmissionRate, vUv ).r; // 1. = spawning, 0. = not spawning
  5898. float isActive = texture2D( uCurrentEmissionRate, vUv ).g; // 1. = active, 0. = not active
  5899. float timeStart = texture2D( uCurrentEmissionRate, vUv ).b; // timeStart in seconds when the particle was emitted
  5900. vec3 originalPosition = ((texture2D( uOriginalPosition, vUv ).xyz) * uEmitterSize);
  5901. vec3 velocity = texture2D( uCurrentVelocity, vUv ).xyz;
  5902. float collisionFlag = texture2D( uCurrentVelocity, vUv ).w; // 1. = collided, 0. = not collided
  5903. float lifeTime = uMaxLifeTime;
  5904. // Calculate the position adjustment based on collision
  5905. // if (collisionFlag > .5) {
  5906. float isColliding = step(0.5, collisionFlag); // 1.0 if collisionFlag > 0.5, otherwise 0.0
  5907. float bounceOffset = 3.0 * isColliding; // Becomes 3.0 if colliding, 0.0 otherwise
  5908. vec3 collisionAdjustedVelocity = velocity * (1.0 + bounceOffset);
  5909. // Update position based on collision or normal movement
  5910. vec3 fpsVelocity = velocity * min(uFPSRatio, 5.0);
  5911. position += mix(fpsVelocity, collisionAdjustedVelocity, isColliding);
  5912. // EMISSION RATE - BIRTH
  5913. // if (isSpawning == 1.0) {
  5914. // Better Approach to avoid If statement
  5915. vec3 newPosition = applyQuaternionToVector(uWorldQuaternion, originalPosition) + uWorldOffset;
  5916. originalPosition = mix(originalPosition, newPosition, isSpawning);
  5917. position = mix(position, originalPosition, isSpawning);;
  5918. timeStart = mix(timeStart, uTime, isSpawning);
  5919. // Calculate timeLeft for life normalization
  5920. float timeLeft = max(lifeTime - (uTime - timeStart), 0.0);
  5921. float life_Normalize = timeLeft / lifeTime;
  5922. // Use isActive to blend between the calculated color and black
  5923. vec4 activeColor = vec4(position, life_Normalize);
  5924. // if (isActive == 1.0) {
  5925. gl_FragColor = mix(vec4(0.0), activeColor, isActive);
  5926. }
  5927. `,r$=`
  5928. vec3 mod289(vec3 x) {
  5929. return x - floor(x * (1.0 / 289.0)) * 289.0;
  5930. }
  5931. vec4 mod289(vec4 x) {
  5932. return x - floor(x * (1.0 / 289.0)) * 289.0;
  5933. }
  5934. vec4 permute(vec4 x) {
  5935. return mod289(((x*34.0)+1.0)*x);
  5936. }
  5937. vec4 taylorInvSqrt(vec4 r)
  5938. {
  5939. return 1.79284291400159 - 0.85373472095314 * r;
  5940. }
  5941. vec3 fade(vec3 t) {
  5942. return t*t*t*(t*(t*6.0-15.0)+10.0);
  5943. }
  5944. float snoise(vec3 v)
  5945. {
  5946. const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
  5947. const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
  5948. vec3 i = floor(v + dot(v, C.yyy) );
  5949. vec3 x0 = v - i + dot(i, C.xxx) ;
  5950. vec3 g = step(x0.yzx, x0.xyz);
  5951. vec3 l = 1.0 - g;
  5952. vec3 i1 = min( g.xyz, l.zxy );
  5953. vec3 i2 = max( g.xyz, l.zxy );
  5954. vec3 x1 = x0 - i1 + C.xxx;
  5955. vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y
  5956. vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y
  5957. // Permutations
  5958. i = mod289(i);
  5959. vec4 p = permute( permute( permute(
  5960. i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
  5961. + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
  5962. + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
  5963. // Gradients: 7x7 points over a square, mapped onto an octahedron.
  5964. // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
  5965. float n_ = 0.142857142857; // 1.0/7.0
  5966. vec3 ns = n_ * D.wyz - D.xzx;
  5967. vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)
  5968. vec4 x_ = floor(j * ns.z);
  5969. vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
  5970. vec4 x = x_ *ns.x + ns.yyyy;
  5971. vec4 y = y_ *ns.x + ns.yyyy;
  5972. vec4 h = 1.0 - abs(x) - abs(y);
  5973. vec4 b0 = vec4( x.xy, y.xy );
  5974. vec4 b1 = vec4( x.zw, y.zw );
  5975. vec4 s0 = floor(b0)*2.0 + 1.0;
  5976. vec4 s1 = floor(b1)*2.0 + 1.0;
  5977. vec4 sh = -step(h, vec4(0.0));
  5978. vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
  5979. vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
  5980. vec3 p0 = vec3(a0.xy,h.x);
  5981. vec3 p1 = vec3(a0.zw,h.y);
  5982. vec3 p2 = vec3(a1.xy,h.z);
  5983. vec3 p3 = vec3(a1.zw,h.w);
  5984. //Normalise gradients
  5985. vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
  5986. p0 *= norm.x;
  5987. p1 *= norm.y;
  5988. p2 *= norm.z;
  5989. p3 *= norm.w;
  5990. // Mix final noise value
  5991. vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
  5992. m = m * m;
  5993. return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
  5994. dot(p2,x2), dot(p3,x3) ) );
  5995. }
  5996. vec3 snoiseVec3( vec3 x ){
  5997. float s = snoise(vec3( x ));
  5998. float s1 = snoise(vec3( x.y - 19.1 , x.z + 33.4 , x.x + 47.2 ));
  5999. float s2 = snoise(vec3( x.z + 74.2 , x.x - 124.5 , x.y + 99.4 ));
  6000. vec3 c = vec3( s , s1 , s2 );
  6001. return c;
  6002. }
  6003. vec3 curlNoise( vec3 p, float seed){
  6004. p += seed;
  6005. const float e = .1;
  6006. vec3 dx = vec3( e , 0.0 , 0.0 );
  6007. vec3 dy = vec3( 0.0 , e , 0.0 );
  6008. vec3 dz = vec3( 0.0 , 0.0 , e );
  6009. vec3 p_x0 = snoiseVec3( p - dx );
  6010. vec3 p_x1 = snoiseVec3( p + dx );
  6011. vec3 p_y0 = snoiseVec3( p - dy );
  6012. vec3 p_y1 = snoiseVec3( p + dy );
  6013. vec3 p_z0 = snoiseVec3( p - dz );
  6014. vec3 p_z1 = snoiseVec3( p + dz );
  6015. float x = p_y1.z - p_y0.z - p_z1.y + p_z0.y;
  6016. float y = p_z1.x - p_z0.x - p_x1.z + p_x0.z;
  6017. float z = p_x1.y - p_x0.y - p_y1.x + p_y0.x;
  6018. const float divisor = 1.0 / ( 2.0 * e );
  6019. return normalize( vec3( x , y , z ) * divisor );
  6020. }
  6021. // Classic Perlin noise
  6022. float cnoise(vec3 P)
  6023. {
  6024. vec3 Pi0 = floor(P); // Integer part for indexing
  6025. vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1
  6026. Pi0 = mod289(Pi0);
  6027. Pi1 = mod289(Pi1);
  6028. vec3 Pf0 = fract(P); // Fractional part for interpolation
  6029. vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
  6030. vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
  6031. vec4 iy = vec4(Pi0.yy, Pi1.yy);
  6032. vec4 iz0 = Pi0.zzzz;
  6033. vec4 iz1 = Pi1.zzzz;
  6034. vec4 ixy = permute(permute(ix) + iy);
  6035. vec4 ixy0 = permute(ixy + iz0);
  6036. vec4 ixy1 = permute(ixy + iz1);
  6037. vec4 gx0 = ixy0 * (1.0 / 7.0);
  6038. vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
  6039. gx0 = fract(gx0);
  6040. vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
  6041. vec4 sz0 = step(gz0, vec4(0.0));
  6042. gx0 -= sz0 * (step(0.0, gx0) - 0.5);
  6043. gy0 -= sz0 * (step(0.0, gy0) - 0.5);
  6044. vec4 gx1 = ixy1 * (1.0 / 7.0);
  6045. vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
  6046. gx1 = fract(gx1);
  6047. vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
  6048. vec4 sz1 = step(gz1, vec4(0.0));
  6049. gx1 -= sz1 * (step(0.0, gx1) - 0.5);
  6050. gy1 -= sz1 * (step(0.0, gy1) - 0.5);
  6051. vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
  6052. vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
  6053. vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
  6054. vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
  6055. vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
  6056. vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
  6057. vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
  6058. vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
  6059. vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
  6060. g000 *= norm0.x;
  6061. g010 *= norm0.y;
  6062. g100 *= norm0.z;
  6063. g110 *= norm0.w;
  6064. vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
  6065. g001 *= norm1.x;
  6066. g011 *= norm1.y;
  6067. g101 *= norm1.z;
  6068. g111 *= norm1.w;
  6069. float n000 = dot(g000, Pf0);
  6070. float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
  6071. float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
  6072. float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
  6073. float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
  6074. float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
  6075. float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
  6076. float n111 = dot(g111, Pf1);
  6077. vec3 fade_xyz = fade(Pf0);
  6078. vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
  6079. vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
  6080. float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
  6081. return 2.2 * n_xyz;
  6082. }
  6083. vec3 fbm_vec3(vec3 p, float frequency, float offset)
  6084. {
  6085. return vec3(
  6086. cnoise((p+vec3(offset))*frequency),
  6087. cnoise((p+vec3(offset+20.0))*frequency),
  6088. cnoise((p+vec3(offset-30.0))*frequency)
  6089. );
  6090. }
  6091. `,s$=`
  6092. #ifdef USE_COLLIDER
  6093. float restitution = max(uBounce * 2., .01); // Energy Loss
  6094. // SPHERE COLLIDER
  6095. // **************************************************************
  6096. #ifdef USE_SPHERE_COLLIDER
  6097. // Convert collider size to radii (assuming uColliderSize is the diameter in each axis)
  6098. vec3 radii = uColliderSize;
  6099. // Adjust position relative to collider
  6100. vec3 relPos = position - uColliderPos;
  6101. // Apply rotation of the collider to the relative position
  6102. relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos);
  6103. // Scale relative position by radii (for ellipsoid collision detection)
  6104. vec3 scaledPos = relPos / radii;
  6105. // Calculate ellipsoidal distance
  6106. float dist = length(scaledPos); // Distance in terms of ellipsoid
  6107. // Check for collision
  6108. if (dist <= 1. + particleSize / length(radii) && collisionFlag == 0.0) {
  6109. // Compute the normal at the collision point, accounting for particle size
  6110. vec3 adjustedPos = scaledPos * (1.0 + particleSize / length(radii));
  6111. // Compute the normal at the collision point
  6112. vec3 normal = ellipsoidNormal(adjustedPos, radii);
  6113. // Rotate the normal back to world space
  6114. normal = applyQuaternionToVector(uColliderQuaternion, normal);
  6115. // Reflect the velocity vector off the normal
  6116. velocity = reflect(velocity, normal) * restitution;
  6117. collisionFlag = 1.0;
  6118. } else {
  6119. collisionFlag = 0.0;
  6120. }
  6121. #endif
  6122. // BOX COLLIDER or PLANE COLLIDER
  6123. // **************************************************************
  6124. #ifdef USE_BOX_COLLIDER
  6125. // Box dimensions and repulsion variables
  6126. vec3 boxHalfSize = uColliderSize / 2.0;
  6127. // Convert world position to box's local space
  6128. vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos);
  6129. // Collision detection
  6130. vec3 localDistance = abs(localPos) - boxHalfSize;
  6131. float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z));
  6132. // Collision Detected
  6133. if (distToSurface <= particleSize * 0.5 && collisionFlag == 0.0) {
  6134. // Find the nearest face normal for bounce direction
  6135. vec3 normal;
  6136. if (localDistance.x > localDistance.y && localDistance.x > localDistance.z) {
  6137. normal = vec3(sign(localPos.x), 0.0, 0.0);
  6138. } else if (localDistance.y > localDistance.z) {
  6139. normal = vec3(0.0, sign(localPos.y), 0.0);
  6140. } else {
  6141. normal = vec3(0.0, 0.0, sign(localPos.z));
  6142. }
  6143. // Rotate normal back to world space
  6144. normal = applyQuaternionToVector(uColliderQuaternion, normal);
  6145. // Reflect velocity and apply repulsion force
  6146. velocity = reflect(velocity, normal) * restitution;
  6147. collisionFlag = 1.0;
  6148. } else {
  6149. collisionFlag = 0.0;
  6150. }
  6151. #endif
  6152. #endif
  6153. // END COLLIDER
  6154. `,a$=`
  6155. #ifdef USE_ATTRACTOR
  6156. #ifdef USE_SPHERE_COLLIDER
  6157. // Convert collider size to radii (assuming uColliderSize is the diameter in each axis)
  6158. vec3 radii = uColliderSize;
  6159. // Adjust position relative to collider
  6160. vec3 relPos = position - uColliderPos;
  6161. // Apply rotation of the collider to the relative position
  6162. relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos);
  6163. // Scale relative position by radii (for ellipsoid collision detection)
  6164. vec3 scaledPos = relPos / radii;
  6165. // Calculate ellipsoidal distance
  6166. float distToSurface = length(scaledPos); // Distance in terms of ellipsoid
  6167. float insideCheck = 1.0;
  6168. #endif
  6169. #ifdef USE_BOX_COLLIDER
  6170. // Box dimensions
  6171. vec3 boxHalfSize = uColliderSize / 2.0;
  6172. // Convert world position to box's local space
  6173. vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos);
  6174. vec3 localDistance = abs(localPos) - boxHalfSize;
  6175. float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z));
  6176. float insideCheck = particleSize;
  6177. #endif
  6178. // Apply vortex force inside the Helper
  6179. #ifdef USE_FORCE_LOCAL_SPACE
  6180. if (distToSurface <= insideCheck ) {
  6181. // Define parameters for the attractor field
  6182. #ifdef USE_SPHERE_COLLIDER
  6183. float attractorStrength = (1.0 - distToSurface ) * uForceIntensity; // Adjust as needed
  6184. #endif
  6185. #ifdef USE_BOX_COLLIDER
  6186. float attractorStrength = max((1.0 - insideCheck / distToSurface), 0.) * uForceIntensity; // Adjust as needed
  6187. #endif
  6188. float attractorDamping = uForceDamping; // Adjust as needed (higher values will attenuate velocity more)
  6189. // Use the same radii calculation code as for the collider
  6190. vec3 attractorRadii = uColliderSize;
  6191. // Adjust position relative to attractor center
  6192. vec3 relPos = position - uColliderPos;
  6193. // Apply rotation of the collider to the relative position
  6194. relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos);
  6195. // Scale relative position by radii (for ellipsoid attraction)
  6196. vec3 scaledPos = relPos / attractorRadii;
  6197. // Calculate ellipsoidal distance as attractor radius
  6198. float attractorRadius = length(scaledPos);
  6199. // Calculate the distance from the attractor center
  6200. vec3 relativePosition = position - uColliderPos;
  6201. // Calculate the force vector towards the attractor center
  6202. vec3 attractorForce = normalize(relativePosition) * attractorStrength;
  6203. // Apply the attractor force to the particle
  6204. velocity -= attractorForce;
  6205. // Attenuate the particle's velocity
  6206. velocity *= attractorDamping;
  6207. }
  6208. #else
  6209. // Calculate the distance from the attractor center
  6210. vec3 relativePosition = position - uColliderPos;
  6211. // Calculate the force vector towards the attractor center
  6212. vec3 attractorForce = normalize(relativePosition) * uForceIntensity;
  6213. // Apply the attractor force to the particle
  6214. velocity -= attractorForce;
  6215. // Attenuate the particle's velocity
  6216. velocity *= uForceDamping;
  6217. #endif
  6218. #endif
  6219. `,n$=`
  6220. #ifdef USE_VORTEX
  6221. // Box dimensions
  6222. vec3 boxHalfSize = uColliderSize / 2.0;
  6223. // Convert world position to box's local space
  6224. vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos);
  6225. vec3 localDistance = abs(localPos) - boxHalfSize;
  6226. float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z));
  6227. // Apply vortex force inside the box
  6228. if (distToSurface <= particleSize) {
  6229. float vortexStrength = uForceIntensity;
  6230. vec3 localTopCenter = vec3(0.0, 0., 0.0);
  6231. // Transform the local top center to the world space
  6232. vec3 vortexCenter = uColliderPos + applyQuaternionToVector(uColliderQuaternion, localTopCenter);
  6233. // Calculate the vector from particle to vortex center
  6234. vec3 vortexVector = vortexCenter - position;
  6235. // Calculate the rotation axis from the inverse of the collider's quaternion and the fixed up vector
  6236. // Note: important to add a tiny z component to the up vector to avoid instability
  6237. vec3 upVector = vec3(0.0, 1.0, 0.01);
  6238. vec3 rotationAxis = cross(upVector, applyQuaternionToVector(uColliderQuaternion, vortexVector));
  6239. rotationAxis = normalize(rotationAxis);
  6240. // Add rotational component to velocity
  6241. float rotationSpeed = length(vortexVector * vortexStrength * 3.0) ;
  6242. vec3 rotationVelocity = rotationAxis * rotationSpeed;
  6243. // velocity += rotationVelocity * 0.005 ;
  6244. velocity = rotationVelocity * 0.005 ;
  6245. // Calculate vortex force
  6246. // vec3 vortexForce = normalize(vortexVector) * uSpeed * .1 ;
  6247. // Apply the vortex force to the particle
  6248. vec3 originDirection = applyQuaternionToVector(uWorldQuaternion, directions);
  6249. velocity += applyForce( originDirection * uSpeed * (1. - uForceDamping) , mass * .5);
  6250. }
  6251. #endif
  6252. `,o$=`
  6253. // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
  6254. // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
  6255. // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
  6256. uniform sampler2D uOriginalPosition;
  6257. uniform sampler2D uDirections;
  6258. uniform vec3 uDirectionsAxis;
  6259. uniform vec4 uWorldQuaternion;
  6260. uniform vec3 uGravity;
  6261. uniform float uNoiseStrength; // Variation of the noise
  6262. uniform float uNoiseScale; // Scale of the noise
  6263. uniform float uNoiseSeed; // Seed of the noise
  6264. uniform float particleSize;
  6265. uniform float uSpeed; // update speed of the particles
  6266. uniform float uRandomMassFactor;
  6267. // COLLIDER
  6268. uniform vec3 uColliderPos; // Collider Position
  6269. uniform vec3 uColliderSize; // Collider Dimension
  6270. uniform vec4 uColliderQuaternion; // Collider Rotation
  6271. uniform vec4 uColliderQuaternionInvert; // Collider Rotation
  6272. uniform float uBounce; // Bounce factor
  6273. uniform float uForceDamping;
  6274. uniform float uForceIntensity;
  6275. `+r$+`
  6276. float rand(vec2 co){
  6277. return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
  6278. }
  6279. vec3 applyQuaternionToVector( vec4 q, vec3 v ){
  6280. return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );
  6281. }
  6282. vec3 applyForce(vec3 force, float mass) {
  6283. vec3 acceleration = force / mass;
  6284. return acceleration;
  6285. }
  6286. vec4 conjugate(vec4 q) {
  6287. return vec4(q.w, -q.x, -q.y, -q.z);
  6288. }
  6289. // Function to compute the normal of the ellipsoid at a given point
  6290. vec3 ellipsoidNormal(vec3 p, vec3 radii) {
  6291. return normalize(p / (radii * radii));
  6292. }
  6293. float friction = .3;
  6294. void main() {
  6295. vec2 vUv = gl_FragCoord.xy / resolution.xy;
  6296. vec3 position = texture2D( uCurrentPosition, vUv ).xyz;
  6297. vec3 originalPosition = texture2D( uOriginalPosition, vUv ).xyz;
  6298. float timeLeft = texture2D( uCurrentPosition, vUv ).w;
  6299. vec3 directions = texture2D( uDirections, vUv ).xyz;
  6300. vec3 velocity = texture2D( uCurrentVelocity, vUv ).xyz;
  6301. float mass = rand(originalPosition.xy) * 0.5 + 0.5;
  6302. float isSpawning = texture2D( uCurrentEmissionRate, vUv ).x; // 1. = spawning, 0. = not spawning
  6303. float isActive = texture2D( uCurrentEmissionRate, vUv ).y; // 1. = active, 0. = not active
  6304. float collisionFlag =texture2D( uCurrentVelocity, vUv ).w; // Indicate collision
  6305. // Randomness Mass
  6306. mass = (1.0 - (uRandomMassFactor * mass));
  6307. if (isActive == 1.0) {
  6308. // **************************************************************
  6309. // FORCES NOISES
  6310. // **************************************************************
  6311. #ifdef USE_CURL_NOISE
  6312. if (uNoiseScale > 0.0 ) {
  6313. velocity = curlNoise(position * uNoiseScale * .002, uNoiseSeed) * ( uNoiseStrength + 1.0) * .05 * uSpeed;
  6314. }
  6315. // Variation of the noise Over Time
  6316. if (uNoiseStrength > 0.0 && uNoiseScale == 0.0 ) {
  6317. velocity += curlNoise( position, uNoiseSeed) * uNoiseStrength * 0.05 * uSpeed;
  6318. }
  6319. #endif
  6320. // **************************************************************
  6321. #ifdef USE_SIMPLEX_NOISE
  6322. if (uNoiseScale > 0.0 ) {
  6323. velocity = vec3(snoise(position * uNoiseScale * .001) * ( uNoiseStrength + 1.0) * .1);
  6324. velocity *= uSpeed;
  6325. }
  6326. // Variation of the noise Over Time
  6327. if (uNoiseStrength > 0.0 && uNoiseScale == 0.0) {
  6328. velocity += vec3(snoise(position * uNoiseStrength * .001) * .05 * uSpeed);
  6329. }
  6330. #endif
  6331. // **************************************************************
  6332. #ifdef USE_FBM_NOISE
  6333. if (uNoiseScale > 0.0 ) {
  6334. velocity = fbm_vec3(position * uNoiseScale * .001, ( uNoiseStrength + 1.0), uNoiseSeed);
  6335. velocity *= uSpeed;
  6336. }
  6337. // Variation of the noise Over Time
  6338. if (uNoiseStrength > 0.0 && uNoiseScale == 0.0 ) {
  6339. velocity += fbm_vec3(position * uNoiseStrength * .001, ( uNoiseStrength + 1.0), uNoiseSeed) * .1 * uSpeed;
  6340. }
  6341. #endif
  6342. // COLLIDER
  6343. ${s$}
  6344. // ATTRACTION
  6345. ${a$}
  6346. // VORTEX
  6347. ${n$}
  6348. }
  6349. // End isActive
  6350. // SPAWN BIRTH
  6351. // **************************************************************
  6352. // if (isSpawning == 1.)
  6353. #ifdef USE_NORMALS
  6354. velocity = mix(velocity, applyQuaternionToVector(uWorldQuaternion, directions) * uSpeed, isSpawning);
  6355. #else
  6356. velocity = mix(velocity, applyQuaternionToVector(uWorldQuaternion, uDirectionsAxis) * uSpeed, isSpawning);
  6357. #endif
  6358. // if (collisionFlag == 0.0)
  6359. velocity += applyForce(uGravity, mass * .5) * (1.0 - collisionFlag);
  6360. gl_FragColor = vec4(velocity, collisionFlag);
  6361. }
  6362. `,lP=`
  6363. // Linear Fade In
  6364. float linearFadeIn(float t) {
  6365. return t;
  6366. }
  6367. // linear fade out
  6368. float linearFadeOut(float t) {
  6369. return 1.0 - t;
  6370. }
  6371. float linearInOut(float t) {
  6372. return t < 0.5 ? t : (1.0 - t);
  6373. }
  6374. // lerp
  6375. float lerp(float a, float b, float t) {
  6376. return a + (b - a) * t;
  6377. }
  6378. // Ease In Out Quart
  6379. float exponentialInOut(float t) {
  6380. return t < 0.4 ? lerp(0.0, 1.0, t / 0.4) :
  6381. t > 0.6 ? lerp(1.0, 0.0, (t - 0.6) / 0.4) :
  6382. 1.0;
  6383. }
  6384. // constant
  6385. float constant(float t) {
  6386. return 1.0;
  6387. }
  6388. `,l$=`
  6389. float rand(vec3 co){
  6390. return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
  6391. }
  6392. vec3 applyQuaternionToVector( vec4 q, vec3 v ){
  6393. return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );
  6394. }
  6395. vec3 applyForce(vec3 force, float mass) {
  6396. vec3 acceleration = force / mass;
  6397. return acceleration;
  6398. }
  6399. `,h$=`
  6400. vec3 rgb2xyz (in vec3 rgb) {
  6401. float r = rgb.r;
  6402. float g = rgb.g;
  6403. float b = rgb.b;
  6404. r = r > 0.04045 ? pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
  6405. g = g > 0.04045 ? pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
  6406. b = b > 0.04045 ? pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
  6407. float x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
  6408. float y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
  6409. float z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
  6410. vec3 xyz = vec3(
  6411. (r * 0.4124) + (g * 0.3576) + (b * 0.1805) * 100.0,
  6412. (r * 0.2126) + (g * 0.7152) + (b * 0.0722) * 100.0,
  6413. (r * 0.0193) + (g * 0.1192) + (b * 0.9505) * 100.0
  6414. );
  6415. return(xyz);
  6416. }
  6417. vec3 xyz2lab (in vec3 xyz) {
  6418. float x = xyz.x / 95.047;
  6419. float y = xyz.y / 100.0;
  6420. float z = xyz.z / 108.883;
  6421. x = x > 0.008856 ? pow(x, 1.0 / 3.0) : (7.787 * x) + (16.0 / 116.0);
  6422. y = y > 0.008856 ? pow(y, 1.0 / 3.0) : (7.787 * y) + (16.0 / 116.0);
  6423. z = z > 0.008856 ? pow(z, 1.0 / 3.0) : (7.787 * z) + (16.0 / 116.0);
  6424. vec3 lab = vec3((116.0 * y) - 16.0, 500.0 * (x - y), 200.0 * (y - z));
  6425. return(lab);
  6426. }
  6427. vec3 rgb2lab(in vec3 rgb) {
  6428. vec3 xyz = rgb2xyz(rgb);
  6429. vec3 lab = xyz2lab(xyz);
  6430. return(lab);
  6431. }
  6432. vec3 xyz2rgb (in vec3 xyz) {
  6433. float x = xyz.x / 100.0;
  6434. float y = xyz.y / 100.0;
  6435. float z = xyz.z / 100.0;
  6436. float r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
  6437. float g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
  6438. float b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
  6439. r = r > 0.0031308 ? ((1.055 * pow(r, 1.0 / 2.4)) - 0.055) : r * 12.92;
  6440. g = g > 0.0031308 ? ((1.055 * pow(g, 1.0 / 2.4)) - 0.055) : g * 12.92;
  6441. b = b > 0.0031308 ? ((1.055 * pow(b, 1.0 / 2.4)) - 0.055) : b * 12.92;
  6442. r = min(max(0.0, r), 1.0);
  6443. g = min(max(0.0, g), 1.0);
  6444. b = min(max(0.0, b), 1.0);
  6445. return(vec3(r, g, b));
  6446. }
  6447. vec3 lab2xyz (in vec3 lab) {
  6448. float l = lab.x;
  6449. float a = lab.y;
  6450. float b = lab.z;
  6451. float y = (l + 16.0) / 116.0;
  6452. float x = a / 500.0 + y;
  6453. float z = y - b / 200.0;
  6454. float y2 = pow(y, 3.0);
  6455. float x2 = pow(x, 3.0);
  6456. float z2 = pow(z, 3.0);
  6457. y = y2 > 0.008856 ? y2 : (y - 16.0 / 116.0) / 7.787;
  6458. x = x2 > 0.008856 ? x2 : (x - 16.0 / 116.0) / 7.787;
  6459. z = z2 > 0.008856 ? z2 : (z - 16.0 / 116.0) / 7.787;
  6460. x *= 95.047;
  6461. y *= 100.0;
  6462. z *= 108.883;
  6463. return(vec3(x, y, z));
  6464. }
  6465. vec3 lab2rgb (in vec3 lab) {
  6466. vec3 xyz = lab2xyz(lab);
  6467. vec3 rgb = xyz2rgb(xyz);
  6468. return(rgb);
  6469. }
  6470. `,c$=`
  6471. uniform sampler2D uPosition;
  6472. uniform float uSize;
  6473. uniform float uSizeEnd;
  6474. uniform vec3 uWorldOffset;
  6475. uniform vec4 uWorldQuaternion;
  6476. // Billboard Behavior - Currently at Zero, but we can change that
  6477. uniform float uRotation;
  6478. uniform float uRotationEnd;
  6479. uniform vec2 center;
  6480. // Randomness
  6481. uniform float uRandScaleFactor;
  6482. uniform float uRandRotationFactor;
  6483. attribute vec2 ref;
  6484. varying float v_LifeLeft; // normalized lifetime 1 to 0
  6485. varying vec2 vUv;
  6486. varying vec2 vRef;
  6487. ${l$}
  6488. ${lP}
  6489. `,d$=({easeSize:e="linearFadeOut"})=>`
  6490. vUv = uv;
  6491. vRef = ref;
  6492. // Normalized LifeTime 1 to 0
  6493. float lifeLeft = texture2D(uPosition, ref).w;
  6494. v_LifeLeft = lifeLeft;
  6495. // Position From DataTexture Simulation
  6496. vec3 pos = texture2D(uPosition, ref).rgb - uWorldOffset;
  6497. // Apply World Quaternion
  6498. pos = applyQuaternionToVector(uWorldQuaternion, pos);
  6499. #ifdef USE_SIZE_END
  6500. // Scaled Over Time
  6501. float t = 1. - lifeLeft;
  6502. float currentSize = mix(uSize, uSizeEnd, t); // Linearly interpolate between uSize and uSizeEnd
  6503. vec3 scaledPosition = position * vec3(currentSize);
  6504. #else
  6505. // Change Size Behavior over LifeTime
  6506. float easeSize = ${e}(1. - lifeLeft);
  6507. // Scaled Over Time
  6508. vec3 scaledPosition = position * vec3(uSize * easeSize);
  6509. #endif
  6510. // Billboard Behavior
  6511. vec2 scale;
  6512. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  6513. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  6514. // Randomness
  6515. float randRef = rand(ref);
  6516. scale *= (1.0 - (uRandScaleFactor * randRef));
  6517. // Rotation
  6518. float randRotation = 2.0 * PI * ( uRandRotationFactor * randRef);
  6519. float originalRotation = (1.0 - uRotation) * 2.0 * PI;
  6520. float originalRotationEnd = (1.0 - uRotationEnd) * 2.0 * PI;
  6521. // OverTime
  6522. float finalRotation = mix(originalRotation + randRotation, originalRotationEnd + randRotation, lifeLeft);
  6523. vec2 alignedPosition = ( scaledPosition.xy - ( center - vec2( 0.5 ) ) ) * scale;
  6524. vec2 rotatedPosition;
  6525. rotatedPosition.x = cos( finalRotation ) * alignedPosition.x - sin( finalRotation ) * alignedPosition.y;
  6526. rotatedPosition.y = sin( finalRotation ) * alignedPosition.x + cos( finalRotation ) * alignedPosition.y;
  6527. mat4 instanceMatrix = mat4(
  6528. vec4(1.0, 0.0, 0.0, 0.0),
  6529. vec4(0.0, 1.0, 0.0, 0.0),
  6530. vec4(0.0, 0.0, 1.0, 0.0),
  6531. vec4(pos.x, pos.y, pos.z, 1.0)
  6532. );
  6533. mvPosition = modelViewMatrix * instanceMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  6534. mvPosition.xy += rotatedPosition;
  6535. gl_Position = projectionMatrix * mvPosition;
  6536. `,u$=`
  6537. uniform vec4 uColor; // start color
  6538. uniform vec4 uColor2; // end color
  6539. uniform sampler2D uTexture; // texture
  6540. varying float v_LifeLeft; // normalized lifetime 1 to 0
  6541. varying vec2 vUv;
  6542. varying vec2 vRef;
  6543. float random(vec2 co) {
  6544. return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
  6545. }
  6546. `+lP+`
  6547. ${h$}
  6548. `,p$=({easeOpacity:e="linearFadeOut"})=>`
  6549. // if Particle is dead, hide it
  6550. if (v_LifeLeft <= 0.005 ) {
  6551. discard;
  6552. }
  6553. #ifdef USE_RANDOM_COLORING
  6554. float randVal = random(vRef); // Generate a random value based on the reference
  6555. vec4 color = mix(uColor, uColor2, randVal); // Interpolate between the two colors
  6556. #else
  6557. vec4 color = mix(uColor, uColor2, 1. - v_LifeLeft);
  6558. #endif
  6559. // Opacity over Life Time
  6560. float finalAlpha = ${e}(1. - v_LifeLeft);
  6561. vec4 textureColor = texture2D(uTexture, vUv).rgba;
  6562. finalColor = textureColor.rgb * color.rgb;
  6563. finalAlpha = color.a * textureColor.a * finalAlpha;
  6564. gl_FragColor = vec4(finalColor, finalAlpha);
  6565. `,f$=class extends Dt{constructor(e,t){super(),this.needsJitter=!0,this.type="ParticleMaterial",this.easeOpacity="linearFadeIn",this.easeSize="linearFadeIn",this.useSizeEnd=!1,this.isColoringRandom=!1,this.init(e,t),this.context=t}reset(){}init(e,t){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],Vi.startContext(Vi.globalContext),this.lightLayer=new fa(0,"",{...Ji.defaultData("light","phong"),visible:!1},new G1,{},t.shared),Vi.endContext(Vi.globalContext),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new nT;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(WX),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(qX),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(c$),e.addFragmentParsCode(u$),e.addVertexFinalCode(d$({easeSize:this.easeSize})),e.addFragmentFinalCode(p$({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}},av=class{constructor(e,t,i,r){this.type="SphereEmitterShape",this.targetMesh=void 0,this.size=e,this.type=i,this.textureSize=JJ(t);let s=1;this.targetMesh=(r==null?void 0:r.geometry.type)==="BufferGeometry"||(r==null?void 0:r.type)==="Mesh"&&r&&r.geometry.hasAttribute("position")&&r.geometry.hasAttribute("normal")?r:this.getMesh(i,s);let{positions:a,dataTexture:n,dataTextureNormals:o}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(i,s));this.positionsTexture=n,this.positionsAttribute=a,this.directionsTexture=o}createPositions(e,t){let{positions:i,normals:r}=$J(t,e*e),s=DA(i,e),a=DA(r,e);return{dataTexture:s,positions:i,dataTextureNormals:a}}getMesh(e,t){let i=null;switch(e){case"SphereEmitterShape":{i=new gh(t*.5,32,32);break}case"TorusEmitterShape":{i=new OM(t*.5,.3,15,40);break}case"ConeEmitterShape":{i=new Zy(t,t,15);break}case"BoxEmitterShape":{i=new Xs(t,t,t);break}case"PlaneEmitterShape":{i=new Ea(t,t),i.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{i=new gh(t,32,32);break}default:{i=new gh(t,32,32);break}}return new Jt(i,new gn({color:16711680}))}applyToShader(e,t){this.size=new M().fromArray(t.size),e.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function nh(e){let t={...e},i=pf.defaultData;t.forceFieldObjectId&&(t.colliderEntityId=t.forceFieldObjectId);let r={...i.shape,...t.shape},s={...i.renderMaterial,...t.renderMaterial};return{...i,...t,shape:r,renderMaterial:s}}var m$=`
  6566. // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
  6567. // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
  6568. // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
  6569. uniform sampler2D uIndex; // Texture with corresponding index
  6570. uniform float uLastIndexEmitted; // Last emitted index
  6571. uniform float uParticlesToEmit; // Number of particles to emit on that frame
  6572. uniform float uTime;
  6573. void main() {
  6574. vec2 vUv = gl_FragCoord.xy / resolution.xy;
  6575. float particleIndex = texture(uIndex, vUv).x;
  6576. float timeLeft = texture2D( uCurrentPosition, vUv ).w;
  6577. float isActive = texture2D( uCurrentEmissionRate, vUv ).g; // 1. = active, 0. = not active
  6578. float timeStart = texture2D( uCurrentEmissionRate, vUv ).b;
  6579. // ********** Detect Colision to Create a flag and use it in position **********
  6580. // We are doing this here, so
  6581. // ********** Emit Particles **********
  6582. // X = isSpawning 0.0 or 1.0
  6583. // Y = isActive 0.0 or 1.0
  6584. // Check if the vertex index is between the first value and the last value
  6585. // if (particleIndex >= uLastIndexEmitted && particleIndex < uLastIndexEmitted + uParticlesToEmit) {
  6586. // // Emit a particle by writing 1 to the red channel of the color output
  6587. // // r: 1. == emit the particle
  6588. // // g: 1. == particle is now active
  6589. // timeStart = uTime;
  6590. // gl_FragColor = vec4(1.0, 1.0, timeStart, 1.0);
  6591. // } else {
  6592. // // The Particle is either already emitted or not in the range of the particles to emit
  6593. // // Do not emit a particle by writing 0 to the red channel of the color output
  6594. // gl_FragColor = vec4(0.0, isActive, timeStart, 1.0);
  6595. // }
  6596. // Determine if the particle is within the emission range
  6597. float emitLowerBound = step(uLastIndexEmitted, particleIndex);
  6598. float emitUpperBound = step(particleIndex, uLastIndexEmitted + uParticlesToEmit - 1.0);
  6599. float emitParticle = emitLowerBound * emitUpperBound; // 1.0 if in range, 0.0 otherwise
  6600. // Set timeStart and color
  6601. timeStart = mix(timeStart, uTime, emitParticle);
  6602. gl_FragColor = vec4(emitParticle, mix(isActive, 1.0, emitParticle), timeStart, 1.0);
  6603. }
  6604. `,nv=10,g$=class extends kt{constructor(e,t){super(),this.type="ParticleEmitter",this.debugMode=!1,this.worldSpace=!0,this.rootObject=null,this.gpuCompute=null,this.positionSimRT=null,this.velocitySimRT=null,this.emissionRateSimRT=null,this.emitterShape=void 0,this.isEmitting=!1,this.hasBeenReset=!1,this.emittedParticlesAmount=0,this.lastEmitTime=0,this.globalTime=0,this.targetFPS=60,this.previousRatio=1,this.lerpFactor=.4,this.particlesAmount=0,this.noiseStrength=0,this.noiseScale=0,this.isBillboardBased=!0,this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1},this.textureLoader=new TU,this.currentWorldPosition=new M,this.systemQuaternion=new lt,this.worldGravity=new M(0,0,0),this.directionAxis=new M(0,0,0),this.colliderV3=new M(0,0,0),this.colliderQuaternion=new lt(0,0,0,1),this.matrixAutoUpdate=!0,this.renderer=e,this.system=t,this.shared=t.context.shared;let i=t.data;this.material=new f$(i.renderMaterial,t.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:i.renderMaterial.color},uColor2:{value:i.renderMaterial.color2},uPosition:{value:new M(0,0,0)},uEmissionData:{value:new M(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new M(0,0,0)},uWorldQuaternion:{value:new ct(0,0,0,1)},uRandScaleFactor:{value:i.randomScale??0},uRandRotationFactor:{value:i.randomRotation??0},uRotation:{value:i.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:i.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,i.renderMaterial.texture),this.init(i)}setTexture(e,t){let i=t.data;if(typeof t=="string"){let r=this.shared.image(t),s=new ci(r.img);s.needsUpdate=!0,e.uTexture.value=s;return}if(typeof i!="string"){let r=new Image;r.onload=()=>{let n=new ci(r);n.needsUpdate=!0,e.uTexture.value=n};let s=new Blob([i],{type:"image/*"}),a=URL.createObjectURL(s);r.src=a}}updateGeometryAttributes(e,t){var r;let i=KJ(t);!((r=this.emitterShape)!=null&&r.positionsAttribute)||e.geometry.setAttribute("ref",new ud(i,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,t){var n;if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let i=1e3/t,r=this.targetFPS/i,s=this.previousRatio+(r-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=s,this.previousRatio=s;let a=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=a,this.material.uniforms.uPosition.value=(n=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT))==null?void 0:n.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0],t=this.simFeaturesDefinition.USE_COLLIDER||this.simFeaturesDefinition.USE_ATTRACTOR||this.simFeaturesDefinition.USE_VORTEX;if(e.destroyedInAction&&t&&this.init(nh({...this.system.data,colliderEntityId:null})),!e||e.destroyedInAction)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let i=e.data.size;this.colliderV3.fromArray(i),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,t){if(!this.velocitySimRT||!this.positionSimRT)return;t[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),t[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let i=(r,s)=>{let a=[...this.system.data.shape.size];a[r]=s,this.updateParticleState({shape:{...this.system.data.shape,size:a}})};t[2]==="shape_size_0"&&i(0,e),t[2]==="shape_size_1"&&i(1,e),t[2]==="shape_size_2"&&i(2,e),t[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/nv),t[2]==="gravity"&&this.worldGravity.set(0,e/100,0),t[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),t[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),t[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),t[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),t[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){var t,i,r;if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(nh(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/nv),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),((t=e.renderMaterial)==null?void 0:t.size)!==void 0){let s=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(s)}if(((i=e.renderMaterial)==null?void 0:i.spriteRotation)!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let s=e.shape.size??this.system.data.shape.size,a=[Number(this.shared.getVariable(s[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(s[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(s[2],[this.uuid,"particles","shape_size_2"]))],n={...nh(this.system.data).shape,size:a};(r=this.emitterShape)==null||r.applyToShader(this.positionSimRT.material.uniforms,n)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let s=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(s),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let t=[Number(e[0])*Re.DEG2RAD,Number(e[1])*Re.DEG2RAD,Number(e[2])*Re.DEG2RAD],i=new ji(t[0],t[1],t[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(i).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:t,rootObjectType:i,colliderEntityId:r,shape:s,emitTimeDuration:a,emitTimeCycle:n,life:o,directionMode:l,noiseType:h}=e;return t!==void 0||i!==void 0||r||r===null||n!==void 0||s!==void 0||o!==void 0||a!==void 0||l!==void 0||h!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn("The maximum number of particles is limited to 100000."),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let t=setInterval(()=>{if(this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(t)},100);if(!this.emitterShape)return;let i=new QJ(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),r=this.updateSimulationDefinition(e),s=i.addVariable("uCurrentPosition",r+i$,this.emitterShape.positionsTexture),a=i.addVariable("uCurrentVelocity",r+o$,this.emitterShape.directionsTexture),n=i.addVariable("uCurrentEmissionRate",m$,t$(this.emitterShape.textureSize));i.setVariableDependencies(s,[s,a,n]),i.setVariableDependencies(a,[s,a,n]),i.setVariableDependencies(n,[s,a,n]);let o=e$({size:this.emitterShape.textureSize}),l={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new M(0,0,0)},uWorldQuaternion:{value:new ct(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new M(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};s.material.uniforms=l;let h=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(h),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let c=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),d={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new ct(0,0,0,1)},uColliderPos:{value:new M(0,0,0)},uColliderSize:{value:new M(0,0,0)},uForceIntensity:{value:c?c.forceIntensity:0},uForceDamping:{value:c?c.forceDambing:0},uColliderQuaternion:{value:new ct(0,0,0,1)},uColliderQuaternionInvert:{value:new ct(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/nv}};a.material.uniforms=d;let u={uIndex:{value:o},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};n.material.uniforms=u;let p=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],f={...nh(this.system.data).shape,size:p};this.emitterShape.applyToShader(s.material.uniforms,f),i.init(),this.gpuCompute=i,this.positionSimRT=s,this.velocitySimRT=a,this.emissionRateSimRT=n,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let t=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),i=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),r=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[t,i,r]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let i=this.system.getColliderData(e.colliderEntityId);switch(i==null?void 0:i.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let r=i==null?void 0:i.colliderType;r==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),r==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),(i==null?void 0:i.forceRange)==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let t="";for(let[i,r]of Object.entries(this.simFeaturesDefinition))r&&(t+=`#define ${i}
  6605. `);return t}createShape(e,t){this.emitterShape&&this.emitterShape.dispose();let i=new M(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let r=null;return this.system.context.scene.traverseEntity(s=>{s.uuid===e.fromMeshId&&(r=s)}),r?new av(i,t,e.type,r):new av(i,t,"SphereEmitterShape")}else return new av(i,t,e.type)}createPrimaryEmitter(e){let t,i=e*e;return t=new VF(new Ea(1,1,1),this.material,i),this.updateGeometryAttributes(t,e),this.material.needsUpdate=!0,t.onBeforeRender=()=>{this.applyWorldSpace()},t}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:t,loopDuration:i=0}){return Math.ceil(e*(t+i))}dispose(){var e,t,i;!this.gpuCompute||((t=(e=this.rootObject)==null?void 0:e.parent)==null||t.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),(i=this.emitterShape)==null||i.dispose())}GoEmitSomeParticles(e,t){let i=e-this.lastEmitTime,r=1/t;if(i>=r){let s=Math.max(1,Math.floor(i/r));return this.lastEmitTime=e,this.emittedParticlesAmount+s>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=s,s}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(nh(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}},rd=class extends Vr{constructor(e,t,i){super(e,t),this.type="ParticleSystem",this.geometry=new Ge,this.actualTime=0,this.currentLoopTime=0,this.started=!1,this.stopped=!1,this.timeoutId=void 0,this.isFrozen=!1,this.isIdle=!0,this.emitter=null,this.colliderEntities=[],this.renderer=null,this.isPreWarm=!1,this._hasOnAfterRenderBeenCalled=!1,this.onAfterRender=r=>{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(r))},this.context=i,this.data={...t,...nh(t)},this.geometry.setAttribute("position",new Ie([],3)),this.material=new gn({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new g$(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let t=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||t)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),t||this.start(this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let i=this.actualTime/1e3;this.emitter.update(i,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(t=>t.identity===e)}getColliderData(e){let t=this.colliderEntities.find(i=>i.identity===e);return t?t.data:null}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),Qt(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...tr.drop(e,1).props}}),Qt(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...tr.drop(e,1).props}})}updateState(e,t){super.updateState(e,t),this.updateParticleState(e)}updateParticleState(e){if(this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let t=this.context.scene.find(e.colliderEntityId);this.colliderEntities=t?[t]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){var t;if(this.currentLoopTime=0,e){this.timeoutId=window.setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,(t=this.emitter)==null||t.startEmitting(this.actualTime/1e3)}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){var e;this.stopped=!0,this.currentLoopTime=0,(e=this.emitter)==null||e.stopEmitting(),clearTimeout(this.timeoutId)}reset(){var e;this.started=!1,this.stopped=!1,(e=this.emitter)==null||e.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function v$(){try{let e=window.location.href;if(e.includes("reducesubdiv=")){let t=e.indexOf("reducesubdiv=")+13;return parseInt(e.slice(t,t+1))}}catch{}}var ov=v$();function y$(e,t,i){var s;ov!==void 0&&(((s=t==null?void 0:t.geometry)==null?void 0:s.subdivisions)??0)>ov&&(console.log("reducing subdivisions",t.name,t.geometry.subdivisions),t.geometry.subdivisions=ov);let r;return t.geometry.type==="TextGeometry"?new Q1(e,t,i):t.geometry.type==="InputGeometry"?new rx(e,t,i):(t.geometry.type==="SubdivGeometry"?r=new Id(e,t,i):t.geometry.type==="PathGeometry"?r=new ix(e,t,i):t.geometry.type==="VectorGeometry"?r=new XJ(e,t,i):t.geometry.type==="BooleanGeometry"?r=new ul(e,t,i):t.geometry.type==="ShapeBlendGeometry"?r=new pl(e,t,i):t.geometry.type==="UIGeometry"?r=new Sr(e,t,i):r=new Ii(e,t,i),r)}function ax(e,t,i){return console.assert(t.type!==void 0),t.type==="Mesh"?y$(e,t,i):t.type==="Empty"?new Mh(e,t):t.type==="Particle"?new rd(e,t,i):t.type==="ParticleCollider"?new id(e,t,i):t.type==="Splat"?new Mh(e,t):t.type==="Bone"?new YJ(e,t):t.type==="Page"?new $i(e,t,i):t.type==="PointLight"?new qJ(e,t,i):t.type==="SpotLight"?new KT(e,t,i):t.type==="DirectionalLight"?new ZT(e,t,i):t.type==="Component"||t.type==="Instance"?new Eh(e,t,i):hl.is(t.type)?new Mr(e,t):(console.error(t),new Mh(e,t))}$n.createEntity=ax;function x$(e,t,i){let r=ax(e.identity,t,i),s=e.children,a=e.attachedPaths,n=e.parent,o=e.component,l=e.instances,h=e.overrideData,c=e.uuid,d=e.stateSelection;e.dispose();for(let u of Object.keys(e))delete e[u];Object.setPrototypeOf(e,Object.getPrototypeOf(r));for(let u of Object.keys(r))e[u]=r[u];e.children=[...e.children,...s],e.attachedPaths=a,e.parent=n,e.component=o,e.instances=l,e.uuid=c,e.overrideData=h,e.updateState(e.data,i),d&&e.changeSelectedState(d,i),e.resetBBoxNeedsUpdate()}$n.changeEntityProptotype=x$;$n.Cloner=bs;function b$(e,t,i,r){e.updateByOp(t,i,r,!1)}var Go=5,sd=new Ge;sd.setAttribute("position",new tt(new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),3));var Op=class extends yU{constructor(e){super({...e,depthTest:!1,depthWrite:!1,glslVersion:Lv,vertexShader:`
  6606. precision highp float;
  6607. in vec3 position;
  6608. void main() {
  6609. gl_Position = vec4(position, 1);
  6610. }
  6611. `})}customProgramCacheKey(){return""}};function w$(){return{shapeInput:()=>`
  6612. const float posRowCoord = ${.5/Go}; // vec4: px py pz opType
  6613. const float quatRowCoord = ${1.5/Go}; // vec4: qx qy qz qw
  6614. const float param1RowCoord = ${2.5/Go};// vec4: type param1 param2 param3
  6615. const float param2RowCoord = ${3.5/Go};// vec4: blendRange roundness scale param4
  6616. const float colorRowCoord = ${4.5/Go}; // vec4: r g b a
  6617. uniform sampler2D shapesDataTexture;
  6618. vec4 shapePos(float iin) {
  6619. vec4 r = texture(shapesDataTexture, vec2(iin, posRowCoord));
  6620. return r;
  6621. }
  6622. vec4 shapeQuat(float iin) {
  6623. vec4 r = texture(shapesDataTexture, vec2(iin, quatRowCoord));
  6624. return r;
  6625. }
  6626. vec4 shapeParams1(float iin) {
  6627. vec4 r = texture(shapesDataTexture, vec2(iin, param1RowCoord));
  6628. return r;
  6629. }
  6630. vec4 shapeParams2(float iin) {
  6631. vec4 r = texture(shapesDataTexture, vec2(iin, param2RowCoord));
  6632. return r;
  6633. }
  6634. vec4 shapeColor(float iin) {
  6635. vec4 r = texture(shapesDataTexture, vec2(iin, colorRowCoord));
  6636. return r;
  6637. }
  6638. `,getxyzi:`
  6639. // this code must complement lookup
  6640. float xi = mod(gl_FragCoord.x - 0.5, VOXEL_RESOLUTION);
  6641. float yi = mod(gl_FragCoord.y - 0.5, VOXEL_RESOLUTION);
  6642. float zi = floor((gl_FragCoord.x - 0.5) * INV_VOXEL_RESOLUTION) + floor((gl_FragCoord.y - 0.5) * INV_VOXEL_RESOLUTION) * Z_LAYERS_PER_ROW;
  6643. `,lookup:`
  6644. uniform sampler2D potentialPassTexture;
  6645. uniform sampler2D voxelPassTexture; // includes normal (in xyz) and key (in w)
  6646. // box or marching cube lookup value in value texture, integer box coord inputs
  6647. // this code must complement codebits.getxyzi
  6648. vec4 look(float xi, float yi, float zi, sampler2D rt) {// range 0 .. numv etc
  6649. vec2 uv = vec2(
  6650. mod(zi, Z_LAYERS_PER_ROW) + (xi + 0.5) / VOXEL_RESOLUTION,
  6651. floor(zi / Z_LAYERS_PER_ROW) + (yi + 0.5) / VOXEL_RESOLUTION
  6652. );
  6653. uv /= Z_LAYERS_PER_ROW;
  6654. return texture(rt, uv);
  6655. }
  6656. `,getpart:`
  6657. float getpart(inout float a, float b) {
  6658. float t = floor(a/b);
  6659. float r = a - t*b;
  6660. a = t;
  6661. return r;
  6662. }
  6663. `,triTable:new Float32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,1,1,8,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,10,2,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,9,9,2,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,2,8,10,2,8,9,10,-1,-1,-1,-1,-1,-1,-1,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,0,0,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,11,3,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,1,11,9,1,11,8,9,-1,-1,-1,-1,-1,-1,-1,1,10,3,3,10,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,10,0,10,8,0,10,11,8,-1,-1,-1,-1,-1,-1,-1,0,9,3,9,11,3,9,10,11,-1,-1,-1,-1,-1,-1,-1,10,8,9,11,8,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,4,4,3,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,7,4,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,4,1,7,4,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,2,1,7,4,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,4,3,4,0,3,10,2,1,-1,-1,-1,-1,-1,-1,-1,10,2,9,2,0,9,7,4,8,-1,-1,-1,-1,-1,-1,-1,9,10,2,7,9,2,3,7,2,4,9,7,-1,-1,-1,-1,7,4,8,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,4,11,4,2,11,4,0,2,-1,-1,-1,-1,-1,-1,-1,1,0,9,7,4,8,11,3,2,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,9,2,11,9,1,2,9,-1,-1,-1,-1,1,10,3,10,11,3,4,8,7,-1,-1,-1,-1,-1,-1,-1,10,11,1,11,4,1,4,0,1,4,11,7,-1,-1,-1,-1,8,7,4,11,0,9,10,11,9,3,0,11,-1,-1,-1,-1,11,7,4,9,11,4,10,11,9,-1,-1,-1,-1,-1,-1,-1,4,5,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,9,3,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,0,0,5,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,8,5,3,8,5,1,3,-1,-1,-1,-1,-1,-1,-1,10,2,1,4,5,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,3,10,2,1,5,9,4,-1,-1,-1,-1,-1,-1,-1,10,2,5,2,4,5,2,0,4,-1,-1,-1,-1,-1,-1,-1,5,10,2,5,2,3,4,5,3,8,4,3,-1,-1,-1,-1,4,5,9,11,3,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,0,11,8,0,5,9,4,-1,-1,-1,-1,-1,-1,-1,4,5,0,5,1,0,11,3,2,-1,-1,-1,-1,-1,-1,-1,5,1,2,8,5,2,11,8,2,5,8,4,-1,-1,-1,-1,11,3,10,3,1,10,4,5,9,-1,-1,-1,-1,-1,-1,-1,5,9,4,1,8,0,1,10,8,10,11,8,-1,-1,-1,-1,0,4,5,11,0,5,10,11,5,3,0,11,-1,-1,-1,-1,8,4,5,10,8,5,11,8,10,-1,-1,-1,-1,-1,-1,-1,8,7,9,9,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,9,3,5,9,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,7,0,7,1,0,7,5,1,-1,-1,-1,-1,-1,-1,-1,3,5,1,7,5,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,7,9,7,5,9,2,1,10,-1,-1,-1,-1,-1,-1,-1,2,1,10,0,5,9,0,3,5,3,7,5,-1,-1,-1,-1,2,0,8,5,2,8,7,5,8,2,5,10,-1,-1,-1,-1,5,10,2,3,5,2,7,5,3,-1,-1,-1,-1,-1,-1,-1,5,9,7,9,8,7,2,11,3,-1,-1,-1,-1,-1,-1,-1,7,5,9,2,7,9,0,2,9,11,7,2,-1,-1,-1,-1,11,3,2,8,1,0,8,7,1,7,5,1,-1,-1,-1,-1,1,2,11,7,1,11,5,1,7,-1,-1,-1,-1,-1,-1,-1,8,5,9,7,5,8,3,1,10,11,3,10,-1,-1,-1,-1,0,7,5,9,0,5,0,11,7,10,0,1,0,10,11,-1,0,10,11,3,0,11,0,5,10,7,0,8,0,7,5,-1,5,10,11,5,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,6,10,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,0,9,6,10,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,1,8,9,1,6,10,5,-1,-1,-1,-1,-1,-1,-1,5,6,1,1,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,6,1,6,2,1,8,0,3,-1,-1,-1,-1,-1,-1,-1,5,6,9,6,0,9,6,2,0,-1,-1,-1,-1,-1,-1,-1,8,9,5,2,8,5,6,2,5,8,2,3,-1,-1,-1,-1,11,3,2,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,11,0,2,11,5,6,10,-1,-1,-1,-1,-1,-1,-1,9,1,0,11,3,2,6,10,5,-1,-1,-1,-1,-1,-1,-1,6,10,5,2,9,1,2,11,9,11,8,9,-1,-1,-1,-1,11,3,6,3,5,6,3,1,5,-1,-1,-1,-1,-1,-1,-1,11,8,0,5,11,0,1,5,0,6,11,5,-1,-1,-1,-1,6,11,3,6,3,0,5,6,0,9,5,0,-1,-1,-1,-1,9,5,6,11,9,6,8,9,11,-1,-1,-1,-1,-1,-1,-1,6,10,5,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,4,3,7,4,10,5,6,-1,-1,-1,-1,-1,-1,-1,0,9,1,6,10,5,7,4,8,-1,-1,-1,-1,-1,-1,-1,5,6,10,7,9,1,3,7,1,4,9,7,-1,-1,-1,-1,2,1,6,1,5,6,8,7,4,-1,-1,-1,-1,-1,-1,-1,5,2,1,6,2,5,4,0,3,7,4,3,-1,-1,-1,-1,7,4,8,5,0,9,5,6,0,6,2,0,-1,-1,-1,-1,9,3,7,4,9,7,9,2,3,6,9,5,9,6,2,-1,2,11,3,4,8,7,5,6,10,-1,-1,-1,-1,-1,-1,-1,6,10,5,2,7,4,0,2,4,11,7,2,-1,-1,-1,-1,9,1,0,8,7,4,11,3,2,6,10,5,-1,-1,-1,-1,1,2,9,2,11,9,11,4,9,4,11,7,6,10,5,-1,7,4,8,5,11,3,1,5,3,6,11,5,-1,-1,-1,-1,11,1,5,6,11,5,11,0,1,4,11,7,11,4,0,-1,9,5,0,5,6,0,6,3,0,3,6,11,7,4,8,-1,9,5,6,11,9,6,9,7,4,9,11,7,-1,-1,-1,-1,9,4,10,10,4,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,10,4,10,9,4,3,8,0,-1,-1,-1,-1,-1,-1,-1,1,0,10,0,6,10,0,4,6,-1,-1,-1,-1,-1,-1,-1,1,3,8,6,1,8,4,6,8,10,1,6,-1,-1,-1,-1,9,4,1,4,2,1,4,6,2,-1,-1,-1,-1,-1,-1,-1,8,0,3,9,2,1,9,4,2,4,6,2,-1,-1,-1,-1,4,2,0,6,2,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,4,2,8,6,2,4,-1,-1,-1,-1,-1,-1,-1,9,4,10,4,6,10,3,2,11,-1,-1,-1,-1,-1,-1,-1,2,8,0,11,8,2,10,9,4,6,10,4,-1,-1,-1,-1,2,11,3,6,1,0,4,6,0,10,1,6,-1,-1,-1,-1,1,4,6,10,1,6,1,8,4,11,1,2,1,11,8,-1,4,6,9,6,3,9,3,1,9,3,6,11,-1,-1,-1,-1,1,11,8,0,1,8,1,6,11,4,1,9,1,4,6,-1,6,11,3,0,6,3,4,6,0,-1,-1,-1,-1,-1,-1,-1,8,4,6,8,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,10,7,10,8,7,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,7,0,7,10,0,10,9,0,10,7,6,-1,-1,-1,-1,7,6,10,7,10,1,8,7,1,0,8,1,-1,-1,-1,-1,7,6,10,1,7,10,3,7,1,-1,-1,-1,-1,-1,-1,-1,6,2,1,8,6,1,9,8,1,7,6,8,-1,-1,-1,-1,9,6,2,1,9,2,9,7,6,3,9,0,9,3,7,-1,0,8,7,6,0,7,2,0,6,-1,-1,-1,-1,-1,-1,-1,2,3,7,2,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,3,2,8,6,10,9,8,10,7,6,8,-1,-1,-1,-1,7,0,2,11,7,2,7,9,0,10,7,6,7,10,9,-1,0,8,1,8,7,1,7,10,1,10,7,6,11,3,2,-1,1,2,11,7,1,11,1,6,10,1,7,6,-1,-1,-1,-1,6,9,8,7,6,8,6,1,9,3,6,11,6,3,1,-1,1,9,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,6,0,7,0,11,3,0,6,11,-1,-1,-1,-1,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,3,6,7,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,6,7,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,8,1,3,8,6,7,11,-1,-1,-1,-1,-1,-1,-1,2,1,10,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,1,8,0,3,7,11,6,-1,-1,-1,-1,-1,-1,-1,0,9,2,9,10,2,7,11,6,-1,-1,-1,-1,-1,-1,-1,7,11,6,3,10,2,3,8,10,8,9,10,-1,-1,-1,-1,3,2,7,7,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,7,0,6,7,0,2,6,-1,-1,-1,-1,-1,-1,-1,6,7,2,7,3,2,9,1,0,-1,-1,-1,-1,-1,-1,-1,2,6,1,6,8,1,8,9,1,6,7,8,-1,-1,-1,-1,6,7,10,7,1,10,7,3,1,-1,-1,-1,-1,-1,-1,-1,6,7,10,10,7,1,7,8,1,8,0,1,-1,-1,-1,-1,7,3,0,10,7,0,9,10,0,7,10,6,-1,-1,-1,-1,10,6,7,8,10,7,9,10,8,-1,-1,-1,-1,-1,-1,-1,4,8,6,6,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,6,3,6,0,3,6,4,0,-1,-1,-1,-1,-1,-1,-1,11,6,8,6,4,8,1,0,9,-1,-1,-1,-1,-1,-1,-1,6,4,9,3,6,9,1,3,9,6,3,11,-1,-1,-1,-1,4,8,6,8,11,6,1,10,2,-1,-1,-1,-1,-1,-1,-1,10,2,1,11,0,3,11,6,0,6,4,0,-1,-1,-1,-1,8,11,4,11,6,4,9,2,0,9,10,2,-1,-1,-1,-1,3,9,10,2,3,10,3,4,9,6,3,11,3,6,4,-1,3,2,8,2,4,8,2,6,4,-1,-1,-1,-1,-1,-1,-1,2,4,0,2,6,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,4,3,2,6,4,2,8,3,4,-1,-1,-1,-1,4,9,1,2,4,1,6,4,2,-1,-1,-1,-1,-1,-1,-1,3,1,8,1,6,8,6,4,8,1,10,6,-1,-1,-1,-1,0,1,10,6,0,10,4,0,6,-1,-1,-1,-1,-1,-1,-1,3,6,4,8,3,4,3,10,6,9,3,0,3,9,10,-1,4,9,10,4,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,9,4,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,5,9,4,6,7,11,-1,-1,-1,-1,-1,-1,-1,1,0,5,0,4,5,11,6,7,-1,-1,-1,-1,-1,-1,-1,6,7,11,4,3,8,4,5,3,5,1,3,-1,-1,-1,-1,4,5,9,2,1,10,11,6,7,-1,-1,-1,-1,-1,-1,-1,7,11,6,10,2,1,3,8,0,5,9,4,-1,-1,-1,-1,11,6,7,10,4,5,10,2,4,2,0,4,-1,-1,-1,-1,8,4,3,4,5,3,5,2,3,2,5,10,6,7,11,-1,3,2,7,2,6,7,9,4,5,-1,-1,-1,-1,-1,-1,-1,4,5,9,6,8,0,2,6,0,7,8,6,-1,-1,-1,-1,2,6,3,6,7,3,0,5,1,0,4,5,-1,-1,-1,-1,8,2,6,7,8,6,8,1,2,5,8,4,8,5,1,-1,4,5,9,6,1,10,6,7,1,7,3,1,-1,-1,-1,-1,10,6,1,6,7,1,7,0,1,0,7,8,4,5,9,-1,10,0,4,5,10,4,10,3,0,7,10,6,10,7,3,-1,10,6,7,8,10,7,10,4,5,10,8,4,-1,-1,-1,-1,5,9,6,9,11,6,9,8,11,-1,-1,-1,-1,-1,-1,-1,11,6,3,3,6,0,6,5,0,5,9,0,-1,-1,-1,-1,8,11,0,11,5,0,5,1,0,11,6,5,-1,-1,-1,-1,3,11,6,5,3,6,1,3,5,-1,-1,-1,-1,-1,-1,-1,10,2,1,11,5,9,8,11,9,6,5,11,-1,-1,-1,-1,3,11,0,11,6,0,6,9,0,9,6,5,10,2,1,-1,5,8,11,6,5,11,5,0,8,2,5,10,5,2,0,-1,3,11,6,5,3,6,3,10,2,3,5,10,-1,-1,-1,-1,9,8,5,8,2,5,2,6,5,2,8,3,-1,-1,-1,-1,6,5,9,0,6,9,2,6,0,-1,-1,-1,-1,-1,-1,-1,8,5,1,0,8,1,8,6,5,2,8,3,8,2,6,-1,6,5,1,6,1,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,3,1,10,6,1,6,8,3,9,6,5,6,9,8,-1,0,1,10,6,0,10,0,5,9,0,6,5,-1,-1,-1,-1,8,3,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,5,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,11,11,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,11,5,7,11,0,3,8,-1,-1,-1,-1,-1,-1,-1,7,11,5,11,10,5,0,9,1,-1,-1,-1,-1,-1,-1,-1,5,7,10,7,11,10,1,8,9,1,3,8,-1,-1,-1,-1,2,1,11,1,7,11,1,5,7,-1,-1,-1,-1,-1,-1,-1,3,8,0,7,2,1,5,7,1,11,2,7,-1,-1,-1,-1,5,7,9,7,2,9,2,0,9,7,11,2,-1,-1,-1,-1,2,5,7,11,2,7,2,9,5,8,2,3,2,8,9,-1,10,5,2,5,3,2,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,2,8,2,5,8,5,7,8,5,2,10,-1,-1,-1,-1,1,0,9,3,10,5,7,3,5,2,10,3,-1,-1,-1,-1,2,8,9,1,2,9,2,7,8,5,2,10,2,5,7,-1,5,3,1,5,7,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,1,7,0,5,7,1,-1,-1,-1,-1,-1,-1,-1,3,0,9,5,3,9,7,3,5,-1,-1,-1,-1,-1,-1,-1,7,8,9,7,9,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,5,8,10,5,8,11,10,-1,-1,-1,-1,-1,-1,-1,4,0,5,0,11,5,11,10,5,0,3,11,-1,-1,-1,-1,9,1,0,10,4,8,11,10,8,5,4,10,-1,-1,-1,-1,4,11,10,5,4,10,4,3,11,1,4,9,4,1,3,-1,1,5,2,5,8,2,8,11,2,8,5,4,-1,-1,-1,-1,11,4,0,3,11,0,11,5,4,1,11,2,11,1,5,-1,5,2,0,9,5,0,5,11,2,8,5,4,5,8,11,-1,5,4,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,2,2,5,3,5,4,3,4,8,3,-1,-1,-1,-1,2,10,5,4,2,5,0,2,4,-1,-1,-1,-1,-1,-1,-1,2,10,3,10,5,3,5,8,3,8,5,4,9,1,0,-1,2,10,5,4,2,5,2,9,1,2,4,9,-1,-1,-1,-1,5,4,8,3,5,8,1,5,3,-1,-1,-1,-1,-1,-1,-1,5,4,0,5,0,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,4,8,3,5,8,5,0,9,5,3,0,-1,-1,-1,-1,5,4,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,11,4,11,9,4,11,10,9,-1,-1,-1,-1,-1,-1,-1,3,8,0,7,9,4,7,11,9,11,10,9,-1,-1,-1,-1,11,10,1,4,11,1,0,4,1,11,4,7,-1,-1,-1,-1,4,1,3,8,4,3,4,10,1,11,4,7,4,11,10,-1,7,11,4,4,11,9,11,2,9,2,1,9,-1,-1,-1,-1,4,7,9,7,11,9,11,1,9,1,11,2,3,8,0,-1,4,7,11,2,4,11,0,4,2,-1,-1,-1,-1,-1,-1,-1,4,7,11,2,4,11,4,3,8,4,2,3,-1,-1,-1,-1,10,9,2,9,7,2,7,3,2,9,4,7,-1,-1,-1,-1,7,10,9,4,7,9,7,2,10,0,7,8,7,0,2,-1,10,7,3,2,10,3,10,4,7,0,10,1,10,0,4,-1,2,10,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,4,7,1,4,3,1,7,-1,-1,-1,-1,-1,-1,-1,1,9,4,7,1,4,1,8,0,1,7,8,-1,-1,-1,-1,3,0,4,3,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,10,9,8,11,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,3,11,9,3,10,9,11,-1,-1,-1,-1,-1,-1,-1,10,1,0,8,10,0,11,10,8,-1,-1,-1,-1,-1,-1,-1,10,1,3,10,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,2,1,9,11,1,8,11,9,-1,-1,-1,-1,-1,-1,-1,9,0,3,11,9,3,9,2,1,9,11,2,-1,-1,-1,-1,11,2,0,11,0,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,2,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,10,8,2,9,8,10,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,10,8,2,8,1,0,8,10,1,-1,-1,-1,-1,2,10,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]),numTrisTable:new Float32Array([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,2,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,2,3,4,4,3,3,4,4,3,4,5,5,2,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,4,2,3,3,4,3,4,2,3,3,4,4,5,4,5,3,2,3,4,4,3,4,5,3,2,4,5,5,4,5,2,4,1,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,4,3,4,4,5,3,2,4,3,4,3,5,2,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,4,3,4,4,3,4,5,5,4,4,3,5,2,5,4,2,1,2,3,3,4,3,4,4,5,3,4,4,5,2,3,3,2,3,4,4,5,4,5,5,2,4,3,5,4,3,2,4,1,3,4,4,5,4,5,3,4,4,5,5,2,3,4,2,1,2,3,3,2,3,4,2,1,3,2,4,1,2,1,1,0])}}var Rp=new bo,_$=class{constructor(){this.pyramidPassScene=new Jr,this.pyramidPassMaterial=new Op({name:"PyramidPass"}),this.pyramidPassUniforms={inputTexture:{value:void 0},inputWidth:{value:0},inputHeight:{value:0},inputShiftX:{value:0},outputShiftX:{value:0}},this.pyramidTopLevelReadPixelBuffer=new Float32Array(4);let e=`
  6664. precision highp float;
  6665. precision highp sampler2D;
  6666. layout(location = 0) out vec4 pc_FragColor;
  6667. uniform sampler2D inputTexture;
  6668. uniform float inputWidth;
  6669. uniform float inputHeight;
  6670. uniform float inputShiftX;
  6671. uniform float outputShiftX;
  6672. const vec2 half_unit_coord = vec2(0.5);
  6673. const vec4 one = vec4(1.0);
  6674. void main() {
  6675. vec2 inputSize = vec2(inputWidth, inputHeight);
  6676. vec2 input_pixel_uv = 1. / inputSize;
  6677. vec2 coord = gl_FragCoord.xy - half_unit_coord;
  6678. coord.x -= outputShiftX;
  6679. coord = coord * 2. + half_unit_coord;
  6680. coord.x += inputShiftX;
  6681. // sample bottom left corner
  6682. vec2 input_uv = coord / inputSize;
  6683. float bl = texture(inputTexture, input_uv).r;
  6684. // sample bottom right corner
  6685. input_uv.x += input_pixel_uv.x;
  6686. float br = texture(inputTexture, input_uv).r;
  6687. // sample top right corner
  6688. input_uv.y += input_pixel_uv.y;
  6689. float tr = texture(inputTexture, input_uv).r;
  6690. // sample top left corner
  6691. input_uv.x -= input_pixel_uv.x;
  6692. float tl = texture(inputTexture, input_uv).r;
  6693. pc_FragColor.a = bl;
  6694. pc_FragColor.b = pc_FragColor.a + br;
  6695. pc_FragColor.g = pc_FragColor.b + tr;
  6696. pc_FragColor.r = pc_FragColor.g + tl;
  6697. }
  6698. `;this.pyramidPassMaterial.fragmentShader=e,this.pyramidPassMaterial.uniforms=this.pyramidPassUniforms,this.pyramidPassMaterial.depthTest=!1,this.pyramidPassMaterial.depthWrite=!1;let t=new Jt(sd,this.pyramidPassMaterial);t.frustumCulled=!1,this.pyramidPassScene.add(t)}renderPyramid(e,t,i,r,s){new t1().min.setScalar(0);let a=t.length-1,n=new ct;i.getViewport(n),this.pyramidPassUniforms.inputShiftX.value=0,this.pyramidPassUniforms.outputShiftX.value=0;let o=a-1;for(let h=o;h>=0;h--){let c=h%2===o%2?s[0]:s[1],d=h===o?r:h%2===o%2?s[1]:s[0];this.pyramidPassUniforms.inputTexture.value=Array.isArray(d.texture)?d.texture[1]:d.texture,this.pyramidPassUniforms.inputWidth.value=d.width,this.pyramidPassUniforms.inputHeight.value=d.height,i.setRenderTarget(c);let u=t[h],p=i.getPixelRatio();i.setViewport(this.pyramidPassUniforms.outputShiftX.value/p,0,u/p,u/p),h===2&&e%2!==0&&i.setViewport(this.pyramidPassUniforms.outputShiftX.value/p,0,3/p,3/p),i.render(this.pyramidPassScene,Rp);let f=this.pyramidPassUniforms.inputShiftX.value;this.pyramidPassUniforms.inputShiftX.value=this.pyramidPassUniforms.outputShiftX.value,this.pyramidPassUniforms.outputShiftX.value=f,h<o&&(this.pyramidPassUniforms.outputShiftX.value+=t[h+1])}i.setViewport(n);let l=t.length%2===0?0:1;return i.readRenderTargetPixelsAsync(s[l],s[l].width-1,0,1,1,this.pyramidTopLevelReadPixelBuffer).then(()=>this.pyramidTopLevelReadPixelBuffer[0])}},Ls=24,hr=96,na=w$(),ja=2,hP=class extends Ii{constructor(e,t,i){super(e,t,i),this.data=t,this.needsRebuild=!0,this.customDepthMaterialNeedsUpdate=!1,this._npart=-1,this.spatialn=1,this.drawRangeNeedsForceUpdate=!0,this._resolutionLevel=-1,this.resolution=64,this.spatialDivisions=25,this.zLayersPerRow=8,this.basePyramidSize=512,this.pyramidTexture1Width=341,this.pyramidTexture1Height=256,this.pyramidTexture2Width=170,this.pyramidTexture2Height=128,this.numLevels=9,this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512],this.bboxSize=0,this.bboxOffset=0,this.shapesDataTexture={value:void 0},this.spatialscene=new Jr,this.potentialPassScene=new Jr,this.voxelPassScene=new Jr,this._spatialPassRenderTargets=[],this._potentialPassRenderTargets=[],this._voxelPassRenderTargets=[],this._pyramidRenderTargets=[],this.geometry=new Ge,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new Jt(sd,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let r=new Ur(na.triTable,16,256,wp,jt);r.needsUpdate=!0;let s=new Ur(na.numTrisTable,256,1,wp,jt);s.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:s}},this.voxelMesh=new Jt(sd,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new Jt(sd,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:r},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=a=>{if(C$.call(this),this.npart===0){this.geometry.drawRange.count=0;return}let n=this.material.root;if(!n.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(n),n.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new Dt({vertexShader:n.vertexShader,fragmentShader:`
  6699. #include <packing>
  6700. void main()
  6701. {
  6702. gl_FragColor = packDepthToRGBA(gl_FragCoord.z);
  6703. }
  6704. `,uniforms:n.uniforms,defines:this.material.defines}),this.isMeshDepthMaterial=!0,this.customDistanceMaterial=new Dt({vertexShader:n.vertexShader,fragmentShader:`
  6705. #include <common>
  6706. #include <packing>
  6707. uniform vec3 referencePosition;
  6708. uniform float nearDistance;
  6709. uniform float farDistance;
  6710. // World-space position
  6711. varying vec3 vWPosition;
  6712. void main()
  6713. {
  6714. float dist = length(vWPosition - referencePosition);
  6715. dist = (dist - nearDistance) / (farDistance - nearDistance);
  6716. dist = saturate(dist);
  6717. // Required by Three.js for this to work
  6718. gl_FragColor = packDepthToRGBA( dist );
  6719. }`,uniforms:{nearDistance:{value:0},farDistance:{value:0},referencePosition:{value:new M},opacity:{value:0},...n.uniforms},defines:this.material.defines});let h=this.customDistanceMaterial;h.referencePosition=new M,h.nearDistance=0,h.farDistance=0,h.opacity=1,h.isMeshDistanceMaterial=!0}if(this.spatialPassUniforms.npart.value=this.npart,this.spatialPassUniforms.spatialn.value=this.spatialn,this.potentialPassUniforms.npart.value=this.npart,this.potentialPassUniforms.spatialn.value=this.spatialn,this.needsRebuild){this.needsRebuild=!1,this.spatialMesh.material.defines.RES=this.resolutionLevel,this.spatialMesh.material.needsUpdate=!0,this.potentialMesh.material.defines.RES=this.resolutionLevel,this.potentialPassUniforms.spatialPassTexture.value=this.spatialPassRenderTarget.texture,this.potentialMesh.material.needsUpdate=!0,this.voxelMesh.material.defines.RES=this.resolutionLevel,this.voxelMesh.material.needsUpdate=!0,this.voxelPassUniforms.potentialPassTexture.value=this.potentialPassRenderTarget.texture,this.marchPassUniforms.potentialPassTexture.value=this.potentialPassRenderTarget.texture,this.marchPassUniforms.voxelPassTexture.value=this.voxelPassRenderTarget.texture[0],this.material.defines.RES=this.resolutionLevel,this.material.defines.LEVELS=this.pyramidLevelSizes.length,this.material.defines.LOOP=this.pyramidLevelSizes.length%2===0?this.pyramidLevelSizes.length-3:this.pyramidLevelSizes.length-2,this.material.defines.HALF=this.pyramidLevelSizes.length%2===0?1:0,this.material.needsUpdate=!0;let h=this.pyramidLevelSizes.length%2===0?0:1,c=this.pyramidLevelSizes.length%2===0?1:0;this.marchPassUniforms.pyramidTexture2.value=this.pyramidRenderTarget[h].texture,this.marchPassUniforms.pyramidTexture2Size.value=new j(this.pyramidRenderTarget[h].width,this.pyramidRenderTarget[h].height),this.marchPassUniforms.pyramidTexture1.value=this.pyramidRenderTarget[c].texture,this.marchPassUniforms.pyramidTexture1Size.value=new j(this.pyramidRenderTarget[c].width,this.pyramidRenderTarget[c].height),Object.assign(this.material.uniforms,this.marchPassUniforms)}let o=a.shadowMap.enabled;a.shadowMap.enabled=!1;let l=a.getRenderTarget();a.setRenderTarget(this.spatialPassRenderTarget),a.render(this.spatialscene,Rp),a.setRenderTarget(this.potentialPassRenderTarget),a.render(this.potentialPassScene,Rp),a.setRenderTarget(this.voxelPassRenderTarget),a.render(this.voxelPassScene,Rp),hP.streamCompaction.renderPyramid(this.resolutionLevel,this.pyramidLevelSizes,a,this.voxelPassRenderTarget,this.pyramidRenderTarget).then(h=>{this.material.wireframe&&(h*3>this.geometry.attributes.position.count||this.drawRangeNeedsForceUpdate)&&(this.geometry.dispose(),this.geometry=new Ge,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]},this.geometry.attributes.position=new tt(new Float32Array(h*3*2),3)),(h*3>this.geometry.drawRange.count||this.drawRangeNeedsForceUpdate)&&(this.geometry.drawRange.count=Math.floor(h*1.2)*3),this.drawRangeNeedsForceUpdate=!1}),a.shadowMap.enabled=o,a.setRenderTarget(l)}}set npart(e){e!==this._npart&&(this.drawRangeNeedsForceUpdate=!0,this._npart=e,this.spatialn=Math.ceil(e/(4*Ls)))}get npart(){return this._npart}set resolutionLevel(e){let t=Math.min(8,Math.max(5,e));if(t!==this._resolutionLevel){switch(this._resolutionLevel=t,this.resolution=Math.pow(2,t),this.resolutionLevel){case 5:this.pyramidLevelSizes=[1,2,4,6,12,24,48,96,192],this.bboxSize=31*8*ja,this.bboxOffset=8*ja*-1/2;break;case 6:this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512],this.bboxSize=63*4*ja,this.bboxOffset=4*ja*-1/2;break;case 7:this.pyramidLevelSizes=[1,2,4,6,12,24,48,96,192,384,768,1536],this.bboxSize=127*2*ja,this.bboxOffset=2*ja*-1/2;break;case 8:this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096],this.bboxSize=255*ja,this.bboxOffset=ja*-1/2;break}this.pyramidTexture1Width=0,this.pyramidTexture2Width=0,this.pyramidTexture1Height=this.pyramidLevelSizes[this.pyramidLevelSizes.length-2],this.pyramidTexture2Height=this.pyramidLevelSizes[this.pyramidLevelSizes.length-3];for(let i=this.pyramidLevelSizes.length-2;i>=0;i--)(this.pyramidLevelSizes.length-2)%2===i%2?this.pyramidTexture1Width+=this.pyramidLevelSizes[i]:this.pyramidTexture2Width+=this.pyramidLevelSizes[i];this.basePyramidSize=this.pyramidLevelSizes[this.pyramidLevelSizes.length-1],this.zLayersPerRow=this.basePyramidSize/this.resolution,this.numLevels=this.pyramidLevelSizes.length-1,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]},this.needsRebuild=!0,this.customDepthMaterialNeedsUpdate=!0}}get resolutionLevel(){return this._resolutionLevel}get spatialPassRenderTarget(){let e=this._spatialPassRenderTargets[this.resolutionLevel];return e||(e=new Pt(this.spatialDivisions*this.spatialn,this.spatialDivisions**2,{format:ni,type:jt,stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:_t,magFilter:_t}),this._spatialPassRenderTargets[this.resolutionLevel]=e),e}get potentialPassRenderTarget(){let e=this._potentialPassRenderTargets[this.resolutionLevel];return e||(e=new Pt(this.basePyramidSize,this.basePyramidSize,{format:ni,type:jt,stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:_t,magFilter:_t}),this._potentialPassRenderTargets[this.resolutionLevel]=e),e}get voxelPassRenderTarget(){let e=this._voxelPassRenderTargets[this.resolutionLevel];return e||(e=new dM(this.basePyramidSize,this.basePyramidSize,2,{stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:_t,magFilter:_t}),e.texture[0].format=ni,e.texture[0].type=jt,e.texture[1].format=wp,e.texture[1].type=jt,this._voxelPassRenderTargets[this.resolutionLevel]=e),e}get pyramidRenderTarget(){let e=this._pyramidRenderTargets[this.resolutionLevel];if(!e){let t=new Pt(this.pyramidTexture1Width,this.pyramidTexture1Height,{format:ni,type:jt,stencilBuffer:!1,depthBuffer:!1,magFilter:_t,minFilter:_t}),i=new Pt(this.pyramidTexture2Width,this.pyramidTexture2Height,{format:ni,type:jt,stencilBuffer:!1,depthBuffer:!1,magFilter:_t,minFilter:_t});e=[t,i],this._pyramidRenderTargets[this.resolutionLevel]=e}return e}updateState(e,t){let i=this.material;super.updateState(e,t),i!==this.material&&(this.needsRebuild=!0),e.geometry&&(this.resolutionLevel=e.geometry.resolutionLevel,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]}),e.wireframe&&!this.geometry.getAttribute("position")?this.geometry.setAttribute("position",new tt(new Float32Array(this.geometry.drawRange.count*3),3)):!e.wireframe&&this.geometry.getAttribute("position")&&this.geometry.deleteAttribute("position")}spatialPassMaterial(){let e=`
  6720. precision highp float;
  6721. out vec4 pc_FragColor;
  6722. const float spatialDivisions = ${this.spatialDivisions}.;
  6723. uniform float span;
  6724. uniform float npart;
  6725. uniform float spatialn;
  6726. ${na.shapeInput()}
  6727. vec3 low, high; // range of current div; subset of -1 .. 1 with span border
  6728. // lookup one element/channel's worth of spheres for current division
  6729. // stating with low sphere number lowi
  6730. // gives a key to which spheres from lowi..lowi+23 are active within given div (low..high)
  6731. float spatialKey(float lowi) {
  6732. float t = 0.;
  6733. for (float ii = ${Ls-1}.; ii >= 0.; ii--) {
  6734. float i = ii + lowi;
  6735. float iin = (i + 0.5) / ${hr}.;
  6736. vec4 shape = shapePos(iin);
  6737. vec3 d = shape.xyz;
  6738. float op = shape.w;
  6739. t *= 2.;
  6740. t += (
  6741. low.x < d.x && d.x < high.x &&
  6742. low.y < d.y && d.y < high.y &&
  6743. low.z < d.z && d.z < high.z &&
  6744. i < npart || op == -2. // always include if op is -2, which is the intersection operation
  6745. ) ? 1. : 0.;
  6746. }
  6747. return t;
  6748. }
  6749. ${na.getpart}
  6750. void main() { // spatialial fragment shader
  6751. // find active div
  6752. vec3 div; // which div is current
  6753. // out holds x=> x, lowi faster moving and y=> z, y faster moving
  6754. float yz = float(gl_FragCoord.y - 0.5); // contains z, y faster moving
  6755. div.y = getpart(yz, spatialDivisions);
  6756. div.z = yz; // getpart(yz, spatialDivisions.z); // what's left, should be the same as getpart
  6757. float lx = float(gl_FragCoord.x - 0.5); // contains x, lowi faster moving
  6758. float lowi = getpart(lx, spatialn) * ${4*Ls}.;
  6759. div.x = lx;
  6760. low = div / spatialDivisions * 2. - 1. - span;
  6761. high = (div+1.) / spatialDivisions * 2. - 1. + span;
  6762. // find active range of spheres
  6763. pc_FragColor.x = spatialKey(lowi);
  6764. pc_FragColor.y = spatialKey(lowi+${Ls}.);
  6765. pc_FragColor.z = spatialKey(lowi+${2*Ls}.);
  6766. pc_FragColor.w = spatialKey(lowi+${3*Ls}.);
  6767. }
  6768. `;return new Op({name:"Spatial Pass",fragmentShader:e,uniforms:this.spatialPassUniforms})}potentialPassMaterial(){let e=`
  6769. precision highp float;
  6770. out vec4 pc_FragColor;
  6771. ${na.shapeInput()}
  6772. uniform sampler2D spatialPassTexture;
  6773. const float res = float(RES);
  6774. const float VOXEL_RESOLUTION = pow(2., res);
  6775. const float Z_LAYERS_PER_ROW = ceil(pow(2., res / 2.));
  6776. const float VOXEL_RESOLUTION_SUB1 = VOXEL_RESOLUTION - 1.;
  6777. const float INV_VOXEL_RESOLUTION = 1.0 / VOXEL_RESOLUTION;
  6778. uniform float npart;
  6779. uniform float spatialn;
  6780. const float spatialDivisions = ${this.spatialDivisions}.;
  6781. const float spatialDivisions2 = spatialDivisions * spatialDivisions;
  6782. const float spatialDivisionsSub1 = spatialDivisions - 1.;
  6783. ${na.getpart}
  6784. vec3 packRGBAToVec3(vec4 color) {
  6785. uint r = uint(color.r * 255.);
  6786. uint g = uint(color.g * 255.);
  6787. uint combined = (r << 8) | g;
  6788. return vec3(float(combined) * 0.00001525902, color.b, color.a); // 1/65535
  6789. }
  6790. void applyQuaternionToVector(in vec4 q, inout vec3 v) {
  6791. v += 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);
  6792. }
  6793. /**
  6794. * SDF functions (reference: https://iquilezles.org/articles/distfunctions/)
  6795. */
  6796. // branchless version of "Smooth Union, Subtraction and Intersection - bound, bound, bound" in above reference
  6797. float smoothOperation(float op, float sdf, float d, float k) {
  6798. // union: op = 1 => signSubtract = 1, signIntersection = 1
  6799. // subtract: op = -1 => signSubtract = -1, signIntersection = 1
  6800. // intersection: op = -2 => signSubtract = -1, signIntersection = -1
  6801. float signSubtract = clamp(op, -1., 1.);
  6802. float signIntersection = 2. * (op - signSubtract) + 1.;
  6803. float h = clamp(
  6804. 0.5 + signSubtract * 0.5 * (sdf - signSubtract * signIntersection * d) / k,
  6805. 0.0,
  6806. 1.0
  6807. );
  6808. return mix(sdf, signSubtract * signIntersection * d, h) -
  6809. signSubtract * k * h * (1.0 - h);
  6810. }
  6811. float sdSphere( vec3 p, float s )
  6812. {
  6813. return length(p)-s;
  6814. }
  6815. float sdEllipsoid( vec3 p, vec3 r )
  6816. {
  6817. float k0 = length(p/r);
  6818. float k1 = length(p/(r*r));
  6819. return k0*(k0-1.0)/k1;
  6820. }
  6821. float sdBox( vec3 p, vec3 b )
  6822. {
  6823. vec3 q = abs(p) - b;
  6824. return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0);
  6825. }
  6826. float sdTorus( vec3 p, vec2 t )
  6827. {
  6828. vec2 q = vec2(length(p.xy)-t.x,p.z);
  6829. return length(q)-t.y;
  6830. }
  6831. float sdCappedTorus( vec3 p, vec2 sc, float ra, float rb)
  6832. {
  6833. p.x = abs(p.x);
  6834. float k = (sc.y*p.x>sc.x*p.y) ? dot(p.xy,sc) : length(p.xy);
  6835. return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb;
  6836. }
  6837. float dot2( in vec2 v ) { return dot(v,v); }
  6838. float sdCappedCone( vec3 p, float h, float r1, float r2 )
  6839. {
  6840. vec2 q = vec2( length(p.xz), p.y );
  6841. vec2 k1 = vec2(r2,h);
  6842. vec2 k2 = vec2(r2-r1,2.0*h);
  6843. vec2 ca = vec2(q.x-min(q.x,(q.y<0.0)?r1:r2), abs(q.y)-h);
  6844. vec2 cb = q - k1 + k2*clamp( dot(k1-q,k2)/dot2(k2), 0.0, 1.0 );
  6845. float s = (cb.x<0.0 && ca.y<0.0) ? -1.0 : 1.0;
  6846. return s*sqrt( min(dot2(ca),dot2(cb)) );
  6847. }
  6848. float sdCappedCylinder( vec3 p, float h, float r )
  6849. {
  6850. vec2 d = abs(vec2(length(p.xz),p.y)) - vec2(r,h);
  6851. return min(max(d.x,d.y),0.0) + length(max(d,0.0));
  6852. }
  6853. float maxBlend = 0.0;
  6854. // compute potential from A (=24) spheres, using the bit flags in 'activeKey'
  6855. // to avoid lookup/compute for inactive spheres
  6856. // return field potential, side effect updates track,
  6857. // compute and return +ve and -ve values separately
  6858. void fillSpatialInner(
  6859. float ii,
  6860. float activeKey,
  6861. vec3 corner,
  6862. inout float sdf,
  6863. inout float colorDivisor,
  6864. inout vec4 trackColor
  6865. ) {
  6866. for (float i = 0.; i < ${Ls}.; i++) {
  6867. if (activeKey < 1.) break; // activeKey exhausted, no more active spheres
  6868. activeKey *= 0.5;
  6869. if (fract(activeKey) < 0.5) continue;
  6870. float iin = (i + ii + 0.5) * ${1/hr};
  6871. vec4 shape = shapePos(iin);
  6872. vec4 quat = shapeQuat(iin);
  6873. vec4 params1 = shapeParams1(iin);
  6874. vec4 params2 = shapeParams2(iin);
  6875. vec3 p = corner - shape.xyz;
  6876. applyQuaternionToVector(quat, p);
  6877. p /= params2.z; // scale
  6878. float d; // d in -1..1 coordinates
  6879. switch (int(params1.x)) {
  6880. case 0: d = sdSphere(p, params1.y); break;
  6881. case 1: d = sdEllipsoid(p, params1.yzw); break;
  6882. case 2: d = sdBox(p, params1.yzw); break;
  6883. case 3: d = sdCappedCylinder(p, params1.y, params1.z); break;
  6884. case 4: d = sdCappedCone(p, params1.y, params1.z, params1.w); break;
  6885. case 5: d = sdTorus(p, params1.yz); break;
  6886. case 6: d = sdCappedTorus(p, params1.yz, params1.w, params2.w); break;
  6887. }
  6888. d -= params2.y; // rounded edge
  6889. d *= params2.z; // scale
  6890. float k = params2.x;
  6891. float op = shape.w;
  6892. sdf = smoothOperation(shape.w, sdf, d, k);
  6893. float isNegativeOne = step(-1.5, op) * step(op, -0.5); // 1 when op == -1, 0 otherwise
  6894. float colorCull = smoothstep(maxBlend, 0., -d);
  6895. float cullFactor = mix(1.0, colorCull, isNegativeOne);
  6896. trackColor *= cullFactor;
  6897. colorDivisor *= cullFactor;
  6898. maxBlend = max(maxBlend, k);
  6899. k += 2. * INV_VOXEL_RESOLUTION; // avoid division by zero, and other color artifacts with very small k
  6900. float nearness = smoothstep(k, 0., d);
  6901. vec4 color = shapeColor(iin);
  6902. nearness *= float(color.a >= 0.);
  6903. colorDivisor += nearness;
  6904. trackColor += color * nearness;
  6905. }
  6906. }
  6907. vec3 div;
  6908. // compute potential from all spheres; collect +ve and =ve values separately
  6909. // work in blocks of A*4 (=96) spheres, using the bit flags in 4 float channel 'activeKey' values
  6910. // TODO check if extra vec3 output useful, not really used at present
  6911. float fillSpatial(vec3 corner, inout vec4 trackColor) {
  6912. float sdf = 1e3; // hack: initialize to large value
  6913. float colorDivisor = 0.;
  6914. // spatialPassTexture holds x=> lowi, x faster moving and y=> z, y faster moving
  6915. float divyz = (div.y + div.z * spatialDivisions + 0.5) / (spatialDivisions2);
  6916. for (float ii = 0.; ii < spatialn; ii++) {
  6917. float i = ii * ${4*Ls}.;
  6918. vec4 activeKey = texture(spatialPassTexture, vec2((div.x * spatialn + ii + 0.5)/(spatialn * spatialDivisions), divyz));
  6919. fillSpatialInner(i, activeKey.x, corner, sdf, colorDivisor, trackColor);
  6920. fillSpatialInner(i+${Ls}., activeKey.y, corner, sdf, colorDivisor, trackColor);
  6921. fillSpatialInner(i+${2*Ls}., activeKey.z, corner, sdf, colorDivisor, trackColor);
  6922. fillSpatialInner(i+${3*Ls}., activeKey.w, corner, sdf, colorDivisor, trackColor);
  6923. }
  6924. trackColor /= colorDivisor;
  6925. return mix(sdf, 0.0, step(1e20 - 0.1, sdf));
  6926. }
  6927. void main() {
  6928. ${na.getxyzi} // get xi yi zi from 2d position
  6929. vec3 xyzi = vec3(xi,yi,zi);
  6930. vec3 corner = xyzi / VOXEL_RESOLUTION_SUB1 * 2. - 1.; // -1..1 coords
  6931. div = floor(xyzi / VOXEL_RESOLUTION_SUB1 * spatialDivisionsSub1);
  6932. vec4 c = vec4(0.);
  6933. float t = fillSpatial(corner, c);
  6934. pc_FragColor = vec4(t, packRGBAToVec3(c)); // RGB texture
  6935. }
  6936. `;return new Op({name:"PotentialPass",fragmentShader:e,uniforms:this.potentialPassUniforms})}voxelPassMaterial(){let e=`
  6937. precision highp float;
  6938. layout(location = 0) out vec4 pc_FragColor;
  6939. layout(location = 1) out vec4 numTris;
  6940. const float res = float(RES);
  6941. const float VOXEL_RESOLUTION = pow(2., res);
  6942. const float VOXEL_RESOLUTION_SUB1 = VOXEL_RESOLUTION - 1.;
  6943. const float Z_LAYERS_PER_ROW = ceil(pow(2., res / 2.));
  6944. const float INV_VOXEL_RESOLUTION = 1.0 / VOXEL_RESOLUTION;
  6945. uniform sampler2D numTrisTable; // 256 x 1
  6946. float keyi(float f000, float f100, float f010, float f110, float f001, float f101, float f011, float f111) {
  6947. return (float(f000 < 0.) * 1.) +
  6948. (float(f100 < 0.) * 2.) +
  6949. (float(f010 < 0.) * 8.) +
  6950. (float(f110 < 0.) * 4.) +
  6951. (float(f001 < 0.) * 16.) +
  6952. (float(f101 < 0.) * 32.) +
  6953. (float(f011 < 0.) * 128.) +
  6954. (float(f111 < 0.) * 64.);
  6955. }
  6956. ${na.lookup}
  6957. vec3 compNormi(float xi, float yi, float zi) {
  6958. float dx = look(xi + 1., yi, zi, potentialPassTexture).r - look(xi - 1., yi, zi, potentialPassTexture).r;
  6959. float dy = look(xi, yi + 1., zi, potentialPassTexture).r - look(xi, yi - 1., zi, potentialPassTexture).r;
  6960. float dz = look(xi, yi, zi + 1., potentialPassTexture).r - look(xi, yi, zi - 1., potentialPassTexture).r;
  6961. // if we allow (common) 0,0,0 case through then NaN can spread
  6962. // eg r = vec4(compNorm i(???), 1.) will pollute r.w
  6963. if (dx == 0.0 && dy == 0.0 && dz == 0.0) {
  6964. return vec3(0.199, 0.299, 0.399);
  6965. }
  6966. return normalize(vec3(dx, dy, dz));
  6967. }
  6968. void main() {
  6969. ${na.getxyzi} // get xi yi zi from 2d
  6970. vec3 normal = compNormi(xi, yi, zi); // even if our key is -1 this may be needed by a neighbouring voxel
  6971. if (xi >= VOXEL_RESOLUTION_SUB1 || yi >= VOXEL_RESOLUTION_SUB1 || zi >= VOXEL_RESOLUTION_SUB1) {
  6972. pc_FragColor = vec4(normal, 0.);
  6973. numTris = vec4(0.);
  6974. return;
  6975. }
  6976. float
  6977. f000 = look(xi, yi, zi, potentialPassTexture).r,
  6978. f100 = look(xi+1., yi, zi, potentialPassTexture).r,
  6979. f010 = look(xi, yi+1., zi, potentialPassTexture).r,
  6980. f110 = look(xi+1., yi+1., zi, potentialPassTexture).r,
  6981. f001 = look(xi, yi, zi+1., potentialPassTexture).r,
  6982. f101 = look(xi+1., yi, zi+1., potentialPassTexture).r,
  6983. f011 = look(xi, yi+1., zi+1., potentialPassTexture).r,
  6984. f111 = look(xi+1., yi+1., zi+1., potentialPassTexture).r;
  6985. float key = keyi(f000, f100, f010, f110, f001, f101, f011, f111);
  6986. pc_FragColor = vec4(normal, key);
  6987. numTris = texture(numTrisTable, vec2((key + 0.5) / 256., 0.5));
  6988. }
  6989. `;return new Op({name:"VoxelPass",fragmentShader:e,uniforms:this.voxelPassUniforms})}patchVertexShaderForShapeBlend(e){let t=`
  6990. #ifdef SHAPEBLEND
  6991. precision highp sampler2D;
  6992. uniform float isol;
  6993. uniform sampler2D triTable; // 256 x 16
  6994. uniform sampler2D pyramidTexture1;
  6995. uniform vec2 pyramidTexture1Size;
  6996. uniform sampler2D pyramidTexture2;
  6997. uniform vec2 pyramidTexture2Size;
  6998. const vec2 halfPixelOffset = vec2(0.5, 0.5);
  6999. const vec2 rShift = vec2(0., 1.);
  7000. const vec2 gShift = vec2(1., 1.);
  7001. const vec2 bShift = vec2(1., 0.);
  7002. const float res = float(RES);
  7003. const float VOXEL_RESOLUTION = pow(2., res);
  7004. const float Z_LAYERS_PER_ROW = ceil(pow(2., res / 2.));
  7005. const float INV_VOXEL_RESOLUTION = 1.0 / VOXEL_RESOLUTION;
  7006. const float scale_factor = ${ja}.;
  7007. #if SHAPEBLEND == 5
  7008. const float levelShiftX[7] = float[7](4., 6., 12., 24., 48., 96., 192.);
  7009. const float scale = 8. * scale_factor;
  7010. const vec3 originOffset = vec3(16.);
  7011. #elif SHAPEBLEND == 7
  7012. const float levelShiftX[10] = float[10](4., 6., 12., 24., 48., 96., 192., 384., 768., 1536.);
  7013. const float scale = 2. * scale_factor;
  7014. const vec3 originOffset = vec3(64.);
  7015. #elif SHAPEBLEND == 8
  7016. const float levelShiftX[11] = float[11](4., 8., 16., 32., 64., 128., 256., 512., 1024., 2048., 4096.);
  7017. const float scale = scale_factor;
  7018. const vec3 originOffset = vec3(128.);
  7019. #else
  7020. const float levelShiftX[8] = float[8](4., 8., 16., 32., 64., 128., 256., 512.);
  7021. const float scale = 4. * scale_factor;
  7022. const vec3 originOffset = vec3(32.);
  7023. #endif
  7024. ${na.lookup}
  7025. const vec3 offsets[24] = vec3[](
  7026. vec3(0., 0., 0.), vec3(1., 0., 0.),
  7027. vec3(1., 0., 0.), vec3(1., 1., 0.),
  7028. vec3(0., 1., 0.), vec3(1., 1., 0.),
  7029. vec3(0., 0., 0.), vec3(0., 1., 0.),
  7030. vec3(0., 0., 1.), vec3(1., 0., 1.),
  7031. vec3(1., 0., 1.), vec3(1., 1., 1.),
  7032. vec3(0., 1., 1.), vec3(1., 1., 1.),
  7033. vec3(0., 0., 1.), vec3(0., 1., 1.),
  7034. vec3(0., 0., 0.), vec3(0., 0., 1.),
  7035. vec3(1., 0., 0.), vec3(1., 0., 1.),
  7036. vec3(1., 1., 0.), vec3(1., 1., 1.),
  7037. vec3(0., 1., 0.), vec3(0., 1., 1.)
  7038. );
  7039. vec2 computeShiftedPosition1(vec2 xy, float levelOriginX) {
  7040. vec2 xyShifted = xy;
  7041. xyShifted.x += levelOriginX;
  7042. return (xyShifted + halfPixelOffset) / pyramidTexture1Size;
  7043. }
  7044. vec2 computeShiftedPosition2(vec2 xy, float levelOriginX) {
  7045. vec2 xyShifted = xy;
  7046. xyShifted.x += levelOriginX;
  7047. return (xyShifted + halfPixelOffset) / pyramidTexture2Size;
  7048. }
  7049. vec4 unpackVec3ToRGBA(vec3 vec) {
  7050. uint combined = uint(vec.x * 65535.0 + 0.5); // Add 0.5 for rounding
  7051. float g = float(combined & uint(0xFF)) * 0.00392156862; // 1/255
  7052. float r = float((combined >> 8) & uint(0xFF)) * 0.00392156862;
  7053. return vec4(r, g, vec.y, vec.z);
  7054. }
  7055. out vec4 marchColor;
  7056. // end of marchvertPre
  7057. #endif
  7058. `,i=`
  7059. #ifdef SHAPEBLEND
  7060. float triIndex = floor(float(gl_VertexID/3));
  7061. float vertexIndex = float(gl_VertexID);
  7062. // Initial pyramid lookup
  7063. float levelOriginX1 = pyramidTexture1Size.x - 2.;
  7064. float levelOriginX2 = pyramidTexture2Size.x - 1.;
  7065. vec2 xy = vec2(0.);
  7066. vec4 lookUp = texture(pyramidTexture2, computeShiftedPosition2(xy, levelOriginX2));
  7067. // Early exit check
  7068. if (triIndex >= lookUp.r) return;
  7069. // Optimize loop variables
  7070. float start = 0.;
  7071. vec4 triIndexVec = vec4(triIndex);
  7072. // Main position computation loop
  7073. for (int i = 0; i < LOOP;) {
  7074. // Compute boundaries
  7075. vec4 ends = lookUp + vec4(start);
  7076. vec4 starts = vec4(ends.gba, start);
  7077. vec4 check = vec4(greaterThanEqual(triIndexVec, starts)) *
  7078. vec4(lessThan(triIndexVec, ends));
  7079. // Update position
  7080. xy *= 2.;
  7081. xy += check.r * rShift + check.g * gShift + check.b * bShift;
  7082. // Update loop variables
  7083. start = dot(check, starts);
  7084. levelOriginX2 -= levelShiftX[i];
  7085. // Update lookup
  7086. lookUp = texture(pyramidTexture1, computeShiftedPosition1(xy, levelOriginX1));
  7087. i++;
  7088. ends = lookUp + vec4(start);
  7089. starts = vec4(ends.gba, start);
  7090. check = vec4(greaterThanEqual(triIndexVec, starts)) *
  7091. vec4(lessThan(triIndexVec, ends));
  7092. // Update position
  7093. xy *= 2.;
  7094. xy += check.r * rShift + check.g * gShift + check.b * bShift;
  7095. // Update loop variables
  7096. start = dot(check, starts);
  7097. levelOriginX1 -= levelShiftX[i];
  7098. // Update lookup
  7099. lookUp = texture(pyramidTexture2, computeShiftedPosition2(xy, levelOriginX2));
  7100. i++;
  7101. }
  7102. #if HALF == 1
  7103. vec4 ends = lookUp + vec4(start);
  7104. vec4 starts = vec4(ends.gba, start);
  7105. vec4 check = vec4(greaterThanEqual(triIndexVec, starts)) * vec4(lessThan(triIndexVec, ends));
  7106. // Update position
  7107. xy *= 2.;
  7108. xy += check.r * rShift + check.g * gShift + check.b * bShift;
  7109. // Update loop variables
  7110. start = dot(check, starts);
  7111. #endif
  7112. // Compute final coordinates
  7113. vec3 gridPos;
  7114. gridPos.x = mod(xy.x, VOXEL_RESOLUTION);
  7115. gridPos.y = mod(xy.y, VOXEL_RESOLUTION);
  7116. gridPos.z = floor(xy.x * INV_VOXEL_RESOLUTION) +
  7117. floor(xy.y * INV_VOXEL_RESOLUTION) * Z_LAYERS_PER_ROW;
  7118. // Vertex key computation
  7119. vertexIndex -= start * 3.;
  7120. float vk = vertexIndex * 0.0625 + 0.03125; // Optimized division by 16 and addition of 1/32
  7121. // Voxel lookup and edge computation
  7122. vec4 voxel = look(gridPos.x, gridPos.y, gridPos.z, voxelPassTexture);
  7123. float key = (voxel.w + 0.5) * 0.00390625; // Optimized division by 256
  7124. // Edge lookup and offset computation
  7125. float edgeNum = texture(triTable, vec2(vk, key)).x;
  7126. int edgeIndex = int(edgeNum) * 2;
  7127. // Compute edge positions
  7128. vec3 p1 = gridPos + offsets[edgeIndex];
  7129. vec3 p2 = gridPos + offsets[edgeIndex + 1];
  7130. // Compute potentials and normals
  7131. vec4 potential1 = look(p1.x, p1.y, p1.z, potentialPassTexture);
  7132. vec4 potential2 = look(p2.x, p2.y, p2.z, potentialPassTexture);
  7133. // Final position and normal computation
  7134. float mu = potential1.r / (potential1.r - potential2.r);
  7135. marchColor = mix(
  7136. unpackVec3ToRGBA(potential1.gba),
  7137. unpackVec3ToRGBA(potential2.gba),
  7138. mu
  7139. );
  7140. transformed = p1 + (p2 - p1) * mu;
  7141. transformed -= originOffset;
  7142. transformed *= scale;
  7143. vec4 data1 = look(p1.x, p1.y, p1.z, voxelPassTexture);
  7144. vec4 data2 = look(p2.x, p2.y, p2.z, voxelPassTexture);
  7145. objectNormal = normalize(mix(data1.xyz, data2.xyz, mu));
  7146. transformedNormal = normalMatrix * objectNormal;
  7147. #ifndef FLAT_SHADED
  7148. vNormal = transformedNormal;
  7149. #endif
  7150. #endif
  7151. `;e.vertexShader=t+e.vertexShader.replace("#include <project_vertex>",i+`
  7152. #include <project_vertex>`);let r=e.fragmentShader.match(/vec3 diffuseColor[^\n]*\n/);if(!r)return;let s=`
  7153. #ifdef SHAPEBLEND_C
  7154. #if SHAPEBLEND_C == 1
  7155. ${r[0].replace(/nodeU0,/g,"marchColor.rgb,").replace(/nodeU\d+(?=,g_uid\d+_calpha\))/g,"marchColor.a")}
  7156. #else
  7157. ${r[0]}
  7158. #endif
  7159. #else
  7160. ${r[0]}
  7161. #endif
  7162. `;e.fragmentShader=`in vec4 marchColor;
  7163. `+e.fragmentShader.replace(r[0],s),Object.assign(e.uniforms,this.marchPassUniforms)}initDebugPass(e){console.log("fboToDebug.width",e.width,e.height),this.geometry=new Ea(e.width,e.height),this.geometry.userData={parameters:{width:4,height:4}};let t={inputTexture:{value:Array.isArray(e.texture)?e.texture[1]:e.texture},pyramidTextureSize:{value:void 0}},i=r=>{r.vertexShader=`
  7164. precision highp float;
  7165. varying vec2 vUv;
  7166. void main() {
  7167. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  7168. vUv = uv;
  7169. }
  7170. `,r.fragmentShader=`
  7171. layout(location = 1) out vec4 gVelocity;
  7172. precision highp float;
  7173. uniform sampler2D inputTexture;
  7174. varying vec2 vUv;
  7175. uniform vec2 pyramidTextureSize;
  7176. void main() {
  7177. // Sample the input texture using UV coordinates
  7178. gl_FragColor = texture(inputTexture, vUv);
  7179. gVelocity = vec4(0.0);
  7180. }
  7181. `,t.pyramidTextureSize.value=new j(this.pyramidRenderTarget.width,this.pyramidRenderTarget.height),Object.assign(r.uniforms,t)};this.material.shapeBlendhack=i,this.material.root.shapeBlendhack=i}},pl=hP;pl.streamCompaction=new _$;var S$=new we,A$=new we,Yl=new lt,Bn=new M,pp=new M,M$=new lt;function E$(e,t=0){let i=this.children.length;for(;i--;){let r=this.children[i];cl.is(r)&&cP.call(r,e,t+1)}}function cP(e,t=0){if(e(this,t)!==!0){let i=this.children.length;for(;i--;){let r=this.children[i];cl.is(r)&&cP.call(r,e,t+1)}}}function C$(){if(this.shapesDataTexture.value===void 0){let n=new Ur(new Float32Array(4*hr*Go),hr,Go,ni,jt);this.shapesDataTexture.value=n}let e=this.shapesDataTexture.value,t=e.image.data;e.needsUpdate=!0;let i=0,r=this.data.geometry.blendRange,s=S$.copy(this.matrixWorld).invert(),a=0;E$.call(this,n=>{var v;if(n.visible===!1)return!0;let o;if(n instanceof bs||n instanceof id||n instanceof rd)return;n instanceof gr?o=n.object:o=n;let l=(v=n.data)==null?void 0:v.cloner;if(Tt.is(n)&&l&&!l.hideBase&&l.type!=="radial"&&l.disabled!==!0||!(o instanceof Ii))return;let h=o.geometry.userData.parameters,c=h.shapeBlendNode;if(c===void 0)return;if(A$.multiplyMatrices(s,n.matrixWorld).decompose(pp,Yl,Bn),h.type==="TorusGeometry"&&h.arc!==360){let y=h.arc*Math.PI/180;y=y/4,Yl.multiply(M$.set(0,0,Math.sin(y),Math.cos(y)))}let d=c.overrideGlobalBlend?c.blendRange:r;d=d/this.bboxSize*2,t[a*4]=(pp.x-this.bboxOffset)/this.bboxSize*2,t[a*4+1]=(pp.y-this.bboxOffset)/this.bboxSize*2,t[a*4+2]=(pp.z-this.bboxOffset)/this.bboxSize*2,t[a*4+3]=c.operation===0?1:c.operation===2?-1:-2,t[hr*4+a*4]=-Yl.x,t[hr*4+a*4+1]=-Yl.y,t[hr*4+a*4+2]=-Yl.z,t[hr*4+a*4+3]=Yl.w;let u=new Float32Array(4),p=0;if(h.type==="SphereGeometry")h.width===h.height&&h.width===h.depth?u[0]=0:u[0]=1,u[1]=h.width/this.bboxSize,u[2]=h.height/this.bboxSize,u[3]=h.depth/this.bboxSize,i=Math.max(i,u[1]*Bn.x+d,u[2]*Bn.x+d,u[3]*Bn.x+d);else if(h.type==="CubeGeometry"){p=h.cornerRadius;let y=h.width,x=h.height,w=h.depth;u[0]=2,u[1]=(y-2*p)/this.bboxSize,u[2]=(x-2*p)/this.bboxSize,u[3]=(w-2*p)/this.bboxSize,i=Math.max(i,Math.sqrt(y**2+x**2+w**2)/this.bboxSize*Bn.x+d)}else if(h.type==="CylinderGeometry"){p=h.cornerRadius;let y=h.height,x=h.radiusBottom,w=h.radiusTop;if(w>=x){let _=Math.atan2(w-x,y),b=(Math.PI/2-_)/2;w-=p/Math.tan(b),x-=p*Math.tan(b)}else if(x>w){let _=Math.atan2(x-w,y),b=(Math.PI/2-_)/2;w-=p*Math.tan(b),x-=p/Math.tan(b)}u[1]=(h.height-2*p)/this.bboxSize,x===w?(u[0]=3,u[2]=x/this.bboxSize*2):(u[0]=4,u[2]=x/this.bboxSize*2,u[3]=w/this.bboxSize*2),i=Math.max(i,u[1]*4*Bn.x+d)}else if(h.type==="TorusGeometry"){if(u[0]=5,u[1]=(h.width-h.depth)/this.bboxSize,u[2]=h.depth/this.bboxSize,h.arc!==360){u[0]=6,u[3]=u[1],t[hr*12+a*4+3]=u[2];let y=2*Math.atan2(u[2]/2,u[1]),x=h.arc*Math.PI/180/2-y;u[1]=Math.sin(x),u[2]=Math.cos(x)}i=Math.max(i,h.width*Bn.x/this.bboxSize+d)}t.set(u,hr*8+a*4),t[hr*12+a*4]=d,t[hr*12+a*4+1]=p/this.bboxSize*2,t[hr*12+a*4+2]=Bn.x;let f=o.material,g=f.uniforms.nodeU0.node.value,m=f.uniforms.nodeU1.value;c.operation!==0&&!c.useColor&&(m=-1),t[hr*16+a*4]=g.r,t[hr*16+a*4+1]=g.g,t[hr*16+a*4+2]=g.b,t[hr*16+a*4+3]=m,m<1&&this.material.defines.SHAPEBLEND_C===1&&(this.material.transparent=!0),a++}),this.npart=a,this.spatialPassUniforms.span.value=i*1.4}var dP=512;function IA(e,t){let i=!1,r=e.layers.mask&dP,s=t.getLayersOfType("transmission"),a=t.getLayersOfType("outline");return a.length>0&&(e.layers.set(8),s.length>0&&e.layers.enable(3),i=!0,Y1(e),X1(e)),s.length===0&&a.length===0&&e.layers.set(0),r&&e.layers.set(9),e instanceof xl&&e.needsAO&&e.layers.enable(5),i}function OA(e,t){if(!t.layers)return!1;let i=e.layers.mask&dP,r=!1,s=t.getLayersOfType("transmission").filter(n=>n.data.visible),a=t.getLayersOfType("outline").filter(n=>n.data.visible);return s.length>0&&(e.layers.set(3),a.length>0&&e.layers.enable(8),r=!0),s.length===0&&a.length===0&&e.layers.set(0),i&&e.layers.set(9),e.needsAO&&e.layers.enable(5),r}function T$(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof xl)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)IA(i,i.material[r])&&(t=!0);else IA(i,i.material)&&(t=!0)}),t}function P$(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof xl)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)OA(i,i.material[r])&&(t=!0);else OA(i,i.material)&&(t=!0)}),t}var D$=new VM,I$=new we,O$=new Hh;function wy(e,t,i,r=!1){let s=e.cloner;if(s)for(let a of s.children){let n=I$.copy(a.matrixWorld).invert(),o=O$.copy(t.ray).applyMatrix4(n),l=e.matrixWorld;o.applyMatrix4(l);let h=D$;h.set(o.origin,o.direction),h.near=t.near,h.far=t.far;let c=h.intersectObject(e,!1);c.length>0&&i.push({...c[0],object:r?a:e})}}var R$=class{constructor(){this._constraints=new Map}setConstraint(e,t){t===null?this._constraints.delete(e):this._constraints.set(e,t)}removeDependencies(e){this._constraints.delete(e)}applyConstraints(e){let t=new Set;this._constraints.forEach((i,r)=>{let s=[r,i],a=i;for(;this._constraints.has(a);){if(a=this._constraints.get(a),s.includes(a)){console.warn(`circular dependency detected: ${s.join(" -> ")}`);break}t.has(a)||s.push(a)}for(let n=s.length-2;n>=0;n--)if(!t.has(s[n])){let o=e.find(s[n]);o?o.applyPathSnapping(e):console.warn(`missing entity ${s[n]}`),t.add(s[n])}})}findDependency(e,t){let i=e;for(;this._constraints.has(i);)if(i=this._constraints.get(i),i===t)return!0;return!1}},L$="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL",to=class{};Bc(to,"DepthMapRange",65536),Bc(to,"MemoryPageSize",65536),Bc(to,"BytesPerFloat",4),Bc(to,"BytesPerInt",4);function z$(e){let t,i,r,s,a,n,o,l,h,c,d,u,p,f,g,m;function v(T){let D=new Float64Array(c,n,16);for(let P=0;P<16;P++)D[P]=T[P];let O;if(r>1){t.exports.sortIndexes(s,a,h,n,o,l,u.DepthMapRange,r);let P=new Uint32Array(r);O=P.buffer,P.set(new Uint32Array(c,l,r))}else if(r===1){let P=new Uint32Array(r);P[0]=new Uint32Array(c,s,i)[0],O=P.buffer}else O=new ArrayBuffer(0);e.postMessage({sortDone:!0,indexesBuffer:O},[O])}function y(T,D,O){let P=new Float32Array(c,a,i*3);r=0;let U=new Uint32Array(c,s,i);for(let W=0;W<O.length-1;W++){let k=D[W],F=T[W].elements,Z=k.filter(G=>G.enabled&&G.mode==="Include").map(G=>G.type==="Box"?b(G):E(G)),X=k.filter(G=>G.enabled&&G.mode==="Exclude").map(G=>G.type==="Box"?b(G):E(G));for(let G=O[W];G<O[W+1];G++){let q=p[G*3],$=p[G*3+1],Q=p[G*3+2];if((Z.length===0||w(q,$,Q,Z))&&(X.length===0||!w(q,$,Q,X))){let ee=1/(F[3]*q+F[7]*$+F[11]*Q+F[15]);P[r*3]=(F[0]*q+F[4]*$+F[8]*Q+F[12])*ee,P[r*3+1]=(F[1]*q+F[5]*$+F[9]*Q+F[13])*ee,P[r*3+2]=(F[2]*q+F[6]*$+F[10]*Q+F[14])*ee,U[r]=G,r++}}}}function x(T,D){let O=[],P=D.filter(k=>k.enabled&&k.mode==="Include").map(k=>k.type==="Box"?b(k):E(k)),U=D.filter(k=>k.enabled&&k.mode==="Exclude").map(k=>k.type==="Box"?b(k):E(k)),W=T.length;for(let k=0;k<W;k+=3){let F=T[k],Z=T[k+1],X=T[k+2];(P.length===0||w(F,Z,X,P))&&(U.length===0||!w(F,Z,X,U))||O.push(k/3)}return O}function w(T,D,O,P,U){return P[U==="Intersect"?"every":"some"](W=>{let k=_(T,D,O,W.invRotationMatrix,W.cropCenter);return Array.isArray(W)?S(k.x,k.y,k.z,W):C(k.x,k.y,k.z,W)})}function _(T,D,O,P,U){let W=T-U[0],k=D-U[1],F=O-U[2],Z=1/(P[3]*W+P[7]*k+P[11]*F+P[15]);return{x:(P[0]*W+P[4]*k+P[8]*F+P[12])*Z+U[0],y:(P[1]*W+P[5]*k+P[9]*F+P[13])*Z+U[1],z:(P[2]*W+P[6]*k+P[10]*F+P[14])*Z+U[2]}}function b(T){let D=T.cropSize[0]/2,O=T.cropSize[1]/2,P=T.cropSize[2]/2,U=[T.cropCenter[0]-D,T.cropCenter[1]-O,T.cropCenter[2]-P,T.cropCenter[0]+D,T.cropCenter[1]+O,T.cropCenter[2]+P],W=A(T.cropRotation);return Object.assign(U,{invRotationMatrix:W,cropCenter:T.cropCenter})}function A(T){let D=[],O=T[0]*Math.PI/180,P=T[1]*Math.PI/180,U=T[2]*Math.PI/180,W=Math.cos(O),k=Math.sin(O),F=Math.cos(P),Z=Math.sin(P),X=Math.cos(U),G=Math.sin(U),q=W*X,$=W*G,Q=k*X,ee=k*G;return D[0]=F*X,D[1]=-F*G,D[2]=Z,D[4]=$+Q*Z,D[5]=q-ee*Z,D[6]=-k*F,D[8]=ee-q*Z,D[9]=Q+$*Z,D[10]=W*F,D[12]=0,D[13]=0,D[14]=0,D[3]=0,D[7]=0,D[11]=0,D[15]=1,D}function S(T,D,O,P){return T>=P[0]&&T<=P[3]&&D>=P[1]&&D<=P[4]&&O>=P[2]&&O<=P[5]}function E(T){let D=2/T.cropSize[0],O=2/T.cropSize[1],P=2/T.cropSize[2],U=A(T.cropRotation);return{invRadiusX:D,invRadiusY:O,invRadiusZ:P,cropCenter:T.cropCenter,invRotationMatrix:U}}function C(T,D,O,P){let U=(T-P.cropCenter[0])*P.invRadiusX,W=(D-P.cropCenter[1])*P.invRadiusY,k=(O-P.cropCenter[2])*P.invRadiusZ;return U*U+W*W+k*k<=1}e.onmessage=T=>{if(T.data.getCroppedIndexes){let D=new Uint32Array(x(new Float32Array(T.data.positions),T.data.crops)).buffer;e.postMessage({outOfBoundsIndexes:D},[D])}else if(T.data.positions)d=T.data.positions,p=new Float32Array(d),g=T.data.meshMatrixWorlds,m=T.data.cropsArray,f=T.data.meshIndexIntervals,y(g,m,f),e.postMessage({sortSetupComplete:!0});else if(T.data.sort||T.data.newMatrixWorlds||T.data.newCropsArray)(T.data.newMatrixWorlds||T.data.newCropsArray)&&(m=T.data.newCropsArray||m,g=T.data.newMatrixWorlds||g,y(g,m,f)),v(T.data.sort.view,T.data.sort.cameraPosition);else if(T.data.init){u=T.data.init.Constants,i=T.data.init.splatCount;let D=u.BytesPerInt,O=u.BytesPerFloat*3,P=new Uint8Array(T.data.init.sorterWasmBytes),U=D+O,W=i*U,k=i*u.BytesPerInt*2+u.DepthMapRange*u.BytesPerInt*2,F=u.MemoryPageSize*32,Z=W+k+F,X=Math.floor(Z/u.MemoryPageSize)+1,G={module:{},env:{memory:new WebAssembly.Memory({initial:X*2,maximum:X*3,shared:!0})}};WebAssembly.compile(P).then(q=>WebAssembly.instantiate(q,G)).then(q=>{t=q,s=0,a=i*D,n=a+i*O,h=n+16*u.BytesPerFloat*2,o=h+i*u.BytesPerInt,l=o+u.DepthMapRange*u.BytesPerInt,c=G.env.memory.buffer,e.postMessage({sortSetupPhase1Complete:!0})})}}}function B$(e){let t=new Worker(URL.createObjectURL(new Blob(["(",z$.toString(),")(self)"],{type:"application/javascript"}))),i=atob(L$),r=new Uint8Array(i.length);for(let s=0;s<i.length;s++)r[s]=i.charCodeAt(s);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:e,Constants:{BytesPerFloat:to.BytesPerFloat,BytesPerInt:to.BytesPerInt,DepthMapRange:to.DepthMapRange,MemoryPageSize:to.MemoryPageSize}}}),t}var lv=function(){let e=new Float32Array(1),t=new Int32Array(e.buffer);return function(i){return e[0]=i,t[0]}}(),F$=function(e,t,i,r){return e+(t<<8)+(i<<16)+(r<<24)},fp=new j;function RA(e){let t=!1;return e.scene.objects.traverse((i,r)=>{if(r.visible===!1)return!0;r.type==="Splat"&&(t=!0)}),t}var Lp=class extends Jt{constructor(e,t,i,r,s=!1,a=1,n,o){super(i,r),this.splatCount=t,this.meshIndexIntervals=n,this.meshMatrixWorlds=o,this.splatBuffers=e,this.geometry=i,this.material=r,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=s,this.devicePixelRatio=a,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,t,i=!1,r=1,s,a){let n=Lp.buildGeomtery(t),o=Lp.buildMaterial(s);return new Lp(e,t,n,o,i,r,s,a)}static buildMaterial(e){let t=`
  7182. precision highp float;
  7183. #include <common>
  7184. attribute uint splatIndex;
  7185. uniform highp sampler2D covariancesTexture;
  7186. uniform highp usampler2D centersColorsTexture;
  7187. uniform vec2 focal;
  7188. uniform vec2 viewport;
  7189. uniform vec2 basisViewport;
  7190. uniform vec2 covariancesTextureSize;
  7191. uniform vec2 centersColorsTextureSize;
  7192. uniform highp sampler2D meshMatrixWorldsTexture;
  7193. uniform uint meshIndexIntervals[257];
  7194. uniform float orthoZoom;
  7195. varying vec4 vColor;
  7196. varying vec2 vUv;
  7197. varying vec2 vPosition;
  7198. const vec4 encodeNorm4 = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
  7199. const uvec4 mask4 = uvec4(uint(0x000000FF), uint(0x0000FF00), uint(0x00FF0000), uint(0xFF000000));
  7200. const uvec4 shift4 = uvec4(0, 8, 16, 24);
  7201. vec4 uintToRGBAVec (uint u) {
  7202. uvec4 urgba = mask4 & u;
  7203. urgba = urgba >> shift4;
  7204. vec4 rgba = vec4(urgba) * encodeNorm4;
  7205. return rgba;
  7206. }
  7207. vec2 getDataUV(in int stride, in int offset, in vec2 dimensions) {
  7208. vec2 samplerUV = vec2(0.0, 0.0);
  7209. float d = float(splatIndex * uint(stride) + uint(offset)) / dimensions.x;
  7210. samplerUV.y = float(floor(d)) / dimensions.y;
  7211. samplerUV.x = fract(d);
  7212. return samplerUV;
  7213. }
  7214. void main () {
  7215. uvec4 sampledCenterColor = texture(centersColorsTexture, getDataUV(1, 0, centersColorsTextureSize));
  7216. vec3 splatCenter = uintBitsToFloat(uvec3(sampledCenterColor.gba));
  7217. vColor = uintToRGBAVec(sampledCenterColor.r);
  7218. vPosition = position.xy * 2.0;
  7219. uint meshIndex;
  7220. for (int i = 1; i < 257; i++) {
  7221. if (splatIndex < meshIndexIntervals[i]) {
  7222. meshIndex = uint(i - 1);
  7223. break;
  7224. }
  7225. }
  7226. float strideMulmeshIndex = float(4u*meshIndex);
  7227. float meshMatrixWorldsTextureLength = float(256*4);
  7228. mat4 modelMat = mat4(
  7229. texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+0.0)/meshMatrixWorldsTextureLength, 0)),
  7230. texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+1.0)/meshMatrixWorldsTextureLength, 0)),
  7231. texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+2.0)/meshMatrixWorldsTextureLength, 0)),
  7232. texture(meshMatrixWorldsTexture, vec2((strideMulmeshIndex+3.0)/meshMatrixWorldsTextureLength, 0))
  7233. );
  7234. mat4 modelViewMat = viewMatrix * modelMat;
  7235. vec4 viewCenter = modelViewMat * vec4(splatCenter, 1.0);
  7236. vec4 clipCenter = projectionMatrix * viewCenter;
  7237. vec2 sampledCovarianceA = texture(covariancesTexture, getDataUV(3, 0, covariancesTextureSize)).rg;
  7238. vec2 sampledCovarianceB = texture(covariancesTexture, getDataUV(3, 1, covariancesTextureSize)).rg;
  7239. vec2 sampledCovarianceC = texture(covariancesTexture, getDataUV(3, 2, covariancesTextureSize)).rg;
  7240. vec3 cov3D_M11_M12_M13 = vec3(sampledCovarianceA.rg, sampledCovarianceB.r);
  7241. vec3 cov3D_M22_M23_M33 = vec3(sampledCovarianceB.g, sampledCovarianceC.rg);
  7242. // Compute the 2D covariance matrix from the upper-right portion of the 3D covariance matrix
  7243. mat3 Vrk = mat3(
  7244. cov3D_M11_M12_M13.x, cov3D_M11_M12_M13.y, cov3D_M11_M12_M13.z,
  7245. cov3D_M11_M12_M13.y, cov3D_M22_M23_M33.x, cov3D_M22_M23_M33.y,
  7246. cov3D_M11_M12_M13.z, cov3D_M22_M23_M33.y, cov3D_M22_M23_M33.z
  7247. );
  7248. float s = 1.0 / (viewCenter.z * viewCenter.z);
  7249. mat3 W = transpose(mat3(modelViewMat));
  7250. mat3 T = orthoZoom > 0.0 ? W : W * mat3(
  7251. focal.x / viewCenter.z, 0., -(focal.x * viewCenter.x) * s,
  7252. 0., focal.y / viewCenter.z, -(focal.y * viewCenter.y) * s,
  7253. 0., 0., 0.
  7254. );
  7255. mat3 cov2Dm = transpose(T) * Vrk * T;
  7256. cov2Dm[0][0] += 0.3;
  7257. cov2Dm[1][1] += 0.3;
  7258. // We are interested in the upper-left 2x2 portion of the projected 3D covariance matrix because
  7259. // we only care about the X and Y values. We want the X-diagonal, cov2Dm[0][0],
  7260. // the Y-diagonal, cov2Dm[1][1], and the correlation between the two cov2Dm[0][1]. We don't
  7261. // need cov2Dm[1][0] because it is a symetric matrix.
  7262. vec3 cov2Dv = vec3(cov2Dm[0][0], cov2Dm[0][1], cov2Dm[1][1]);
  7263. vec3 ndcCenter = clipCenter.xyz / clipCenter.w;
  7264. // We now need to solve for the eigen-values and eigen vectors of the 2D covariance matrix
  7265. // so that we can determine the 2D basis for the splat. This is done using the method described
  7266. // here: https://people.math.harvard.edu/~knill/teaching/math21b2004/exhibits/2dmatrices/index.html
  7267. //
  7268. // This is a different approach than in the original work at INRIA. In that work they compute the
  7269. // max extents of the 2D covariance matrix in screen space to form an axis aligned bounding rectangle
  7270. // which forms the geometry that is actually rasterized. They then use the inverse 2D covariance
  7271. // matrix (called 'conic') to determine fragment opacity.
  7272. float a = cov2Dv.x;
  7273. float d = cov2Dv.z;
  7274. float b = cov2Dv.y;
  7275. float D = a * d - b * b;
  7276. float trace = a + d;
  7277. float traceOver2 = 0.5 * trace;
  7278. float term2 = sqrt(trace * trace / 4.0 - D);
  7279. float eigenValue1 = traceOver2 + term2;
  7280. float eigenValue2 = max(traceOver2 - term2, 0.00); // prevent negative eigen value
  7281. const float maxSplatSize = 1024.0;
  7282. vec2 eigenVector1 = normalize(vec2(b, eigenValue1 - a));
  7283. // since the eigen vectors are orthogonal, we derive the second one from the first
  7284. vec2 eigenVector2 = vec2(eigenVector1.y, -eigenVector1.x);
  7285. vec2 basisVector1 = eigenVector1 * min(sqrt(2.0 * eigenValue1), maxSplatSize);
  7286. vec2 basisVector2 = eigenVector2 * min(sqrt(2.0 * eigenValue2), maxSplatSize);
  7287. vec2 ndcOffset = vec2(vPosition.x * basisVector1 + vPosition.y * basisVector2) * basisViewport;
  7288. if (orthoZoom > 0.0) {
  7289. ndcOffset *= orthoZoom;
  7290. }
  7291. gl_Position = vec4(ndcCenter.xy + ndcOffset, ndcCenter.z, 1.0);
  7292. }`,i=`
  7293. precision highp float;
  7294. #include <common>
  7295. uniform vec3 debugColor;
  7296. varying vec4 vColor;
  7297. varying vec2 vUv;
  7298. varying vec2 vPosition;
  7299. layout(location = 1) out vec4 gVelocity;
  7300. void main () {
  7301. // compute the negative squared distance from the center of the splat to the
  7302. // current fragment in the splat's local space.
  7303. float A = -dot(vPosition, vPosition);
  7304. if (A < -4.0) discard;
  7305. vec3 color = vColor.rgb;
  7306. A = exp(A) * vColor.a;
  7307. gl_FragColor = vec4(color.rgb, A);
  7308. gVelocity = vec4(0.0); // so it is ignored by TAA
  7309. }`,r={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new j},viewport:{type:"v2",value:new j},basisViewport:{type:"v2",value:new j},debugColor:{type:"v3",value:new et},covariancesTextureSize:{type:"v2",value:new j(1024,1024)},centersColorsTextureSize:{type:"v2",value:new j(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Dt({uniforms:r,vertexShader:t,fragmentShader:i,transparent:!0,alphaTest:1,blending:Jo,depthTest:!0,depthWrite:!1,side:Ar})}static buildGeomtery(e){let t=new Ge;t.setIndex([0,1,2,0,2,3]);let i=new Float32Array(4*3),r=new tt(i,3);t.setAttribute("position",r),r.setXYZ(0,-1,-1,0),r.setXYZ(1,-1,1,0),r.setXYZ(2,1,1,0),r.setXYZ(3,1,-1,0),r.needsUpdate=!0;let s=new NM().copy(t),a=new Uint32Array(e),n=new ud(a,1,!1);return n.setUsage(ER),s.setAttribute("splatIndex",n),s.instanceCount=e,s}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(r=>r.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,t=0,i=0;for(let r of this.splatBuffers){let s=r.nsplats;this.colors.subarray(e,e+s*4).set(r.colorsA),e+=s*4,this.centers.subarray(t,t+s*3).set(r.decoded.xyz.denormDequant().data),t+=s*3,this.covariances.subarray(i,i+s*6).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=s*6}}allocateAndStoreLocalSplatDataInTextures(){let e=this.splatCount,t=new j(4096,1024);for(;t.x*t.y*2<e*6;)t.y*=2;let i=new j(4096,1024);for(;i.x*i.y*4<e*4;)i.y*=2;let r,s;if(this.halfPrecisionCovariancesOnGPU){s=new Uint16Array(t.x*t.y*2);for(let c=0;c<this.covariances.length;c++)s[c]=rN.toHalfFloat(this.covariances[c]);r=new Ur(s,t.x,t.y,Up,mn)}else s=new Float32Array(t.x*t.y*2),s.set(this.covariances),r=new Ur(s,t.x,t.y,Up,jt);r.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=r,this.material.uniforms.covariancesTextureSize.value.copy(t);let a=new Uint32Array(i.x*i.y*4);for(let c=0;c<e;c++){let d=c*4,u=c*3,p=c*4;a[p]=F$(this.colors[d],this.colors[d+1],this.colors[d+2],this.colors[d+3]),a[p+1]=lv(this.centers[u]),a[p+2]=lv(this.centers[u+1]),a[p+3]=lv(this.centers[u+2])}let n=new Ur(a,i.x,i.y,tM,on);n.internalFormat="RGBA32UI",n.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=n,this.material.uniforms.centersColorsTextureSize.value.copy(i);let o=256*4,l=new Float32Array(256*16);for(let c=0;c<this.meshMatrixWorlds.length;c++)l.set(this.meshMatrixWorlds[c].elements,c*16);let h=new Ur(l,o,1,ni,jt);h.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=h,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:s,texture:r,size:t},centerColors:{data:a,texture:n,size:i},meshMatrixWorlds:{data:l,texture:h}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,i,r){this.splatCount>0&&(fp.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(fp),this.material.uniforms.basisViewport.value.set(2/fp.x,2/fp.y),this.material.uniforms.focal.value.set(t,i),this.material.uniforms.orthoZoom.value=r,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}},uP,U$=new Promise(e=>{uP=e}),LA=!1,mp;function N$(){if(LA)return;if(mp)return mp;async function e(){let t=await vo(()=>import("./gaussian-splat-compression-CuwKY2Va.js"),__vite__mapDeps([]));uP(t),LA=!0}return mp=e(),mp}var pP;U$.then(e=>pP=e);var k$=class{constructor(e={}){Bc(this,"updateView",function(){let t=new we,i=[],r=new M(0,0,-1),s=new M(0,0,-1),a=new M,n=new M;return function(o=!1,l){let h=this.updateMatrixWorldsInWorkerIfNeeded(),c=this.cropsChanged();if(!o){s.set(0,0,-1).applyQuaternion(l.quaternion);let u=!1,p=!1;if(s.dot(r)<=.95&&(u=!0),n.copy(l.position).sub(a).length()>=1&&(p=!0),!u&&!p&&!h&&!c&&!this.needsInitialRender)return}this.needsInitialRender=!1,a.copy(l.position),r.copy(s),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),i[0]=l.position.x,i[1]=l.position.y,i[2]=l.position.z;let d={sort:{view:t.elements,cameraPosition:i,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...h?{newMatrixWorlds:this.meshMatrixWorlds}:{},...c?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}()),this.scene=e.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new we().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(e,t){let i=new j;this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(e.getSize(i),this.cameraFocalLengthX=t.projectionMatrix.elements[0]*this.devicePixelRatio*i.x*.45,this.cameraFocalLengthY=t.projectionMatrix.elements[5]*this.devicePixelRatio*i.y*.45,this.splatMesh.updateUniforms(i,this.cameraFocalLengthX,this.cameraFocalLengthY,t.isPerspectiveCamera?-1:t.zoom*this.devicePixelRatio))}loadSplat(e={}){this.activePage=this.scene.activePage,e.position&&(e.position=new M().fromArray(e.position)),e.orientation&&(e.orientation=new lt().fromArray(e.orientation)),e.halfPrecisionCovariances=!!e.halfPrecisionCovariances;let t=[];if(this.splatEntries=t,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&t.push(a)}),this.splatMesh&&this.splatMesh.dispose(),t.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=t.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=t.map(a=>a.matrixWorld.clone()),this.cropsArray=t.map(a=>a.data.crops.map(n=>n.data));let i=t.map(a=>new pP.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),r=0,s=[0];for(let a of i)r+=a.getSplatCount(),s.push(r);return this.setupSplatMesh(i,r,e.position,e.orientation,e.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let e=this.splatDataTextures.meshMatrixWorlds.data;for(let t=0;t<this.meshMatrixWorlds.length;t++)e.set(this.meshMatrixWorlds[t].elements,t*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((t,i)=>t.equals(this.meshMatrixWorldsOld[i]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(t=>t.clone()),!0)}cropsChanged(){let e=!1;return this.splatEntries.forEach((t,i)=>{var r;t.data.crops.forEach((s,a)=>{this.cropsArray[i][a]===void 0?(e=!0,this.cropsArray[i][a]=s.data):Object.entries(s.data).forEach(([n,o])=>{var l;Array.isArray(o)&&o.some((h,c)=>h!==this.cropsArray[i][a][n][c])?(e=!0,this.cropsArray[i][a][n]=o):o!==((l=this.cropsArray[i][a])==null?void 0:l[n])&&(e=!0,this.cropsArray[i][a][n]=o)})}),t.data.crops.length!==((r=this.cropsArray[i])==null?void 0:r.length)&&(this.cropsArray[i].length=t.data.crops.length,e=!0)}),e}setupSplatMesh(e,t,i=new M,r=new lt,s=!1,a=1,n,o){this.splatMesh=Lp.buildMesh(e,t,s,a,n,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=t,this.splatMesh.onBeforeRender=(l,h,c)=>this.update(l,c)}setupSortWorker(e){this.sortWorker=B$(e),this.sortWorker.onmessage=t=>{var i;t.data.sortDone?(this.sortRunning=!1,(i=this.splatMesh)==null||i.updateIndexes(new Uint32Array(t.data.indexesBuffer)),this.lastSortTime=t.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):t.data.sortCanceled?this.sortRunning=!1:t.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):t.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(e,t){this.splatMesh!==null&&(this.updateSplatMeshUniforms(e,t),this.updateView(!1,t))}getSplatMesh(){return this.splatMesh}},_y=new gn;_y.wireframe=!0;var zA=new M,nx=class extends Jr{constructor(e,t){super(),this.data=e,this.sharedAssets=t,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.splatViewer=null,this.shapeBlendIntances=[],this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new R$,this.invisibleObjects=new Mh("jflkdsafjasdifjaslk",{...P0.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new $i("fdasfa",{...Uh.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=P$(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=T$(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof $i&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let s=r;r=r.parent;let a=r.children.indexOf(s);i.splice(0,0,a)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>FE(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===ic)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof $i&&t.uiScene){let i=t.uiScene.find(e);if(i)return i}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof $i&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(i=>{t===void 0&&i instanceof Sr&&(t=i.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof $i&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{var t;(t=e.cloner)==null||t.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){var i;if(e.path.length===0&&e.type===7){let r=e.parent===null?this:this.find(e.parent);if(r===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,r,e.localIndex,t);s.updateVisible(this),s.resetBBoxNeedsUpdate(),Ns(s)&&un(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s),this.markPenumbraSizeDirty(),s.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let r=this.find(e.id);if(r===void 0)throw new Error("unexpected");r.traverseEntity(a=>{a instanceof pl&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(n=>n!==a))}),this.markToExpandCloner(r),r.resetBBoxNeedsUpdate(),this.unregisterObject(r);let s=r.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(r),this.markPenumbraSizeDirty(),r.parent.remove(r),un(r.parent)&&(r.parent.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ns(r)&&(r.freeBooleanPointer(),s instanceof ul&&s.invalidateDownstreamBooleanData().recomputeBoolean()),r instanceof ix&&r.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r),this.pathConstraints.removeDependencies(r.uuid),r.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let r=this.find(e.id);if(r===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(r);let s=r.parent;this.markNeedsRecomputeInstancesForAncessors(s),(i=r.cloner)==null||i.resetOnMove(),this.markToExpandCloner(r);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(r),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(r),r.invalidateClonerTransform(r),r.updateVisible(this),r.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let n=e.localIndex;a.children.splice(n,0,a.children.pop()),Ns(r)&&(r.invalidateUpstreamBooleanData(),un(r.parent)?r.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof ul&&s.invalidateDownstreamBooleanData().recomputeBoolean()),r.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){var t;this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let i of this.children)i instanceof $i&&(i.visible=i.uuid===e,i.visible&&(this.activePage=i,this.activePage.onActive(this)));this.activePage!==((t=this.splatViewer)==null?void 0:t.activePage)&&this.reloadSplats()}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:a}=t.props;t={...t,props:a},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{b$(s,t,i,{scene:this,shared:r}),s instanceof Ii&&s.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}updateEntity2DByOp(e,t,i,r,s,a=[]){e.updateEntityByOp(t,i,r,s),this.traverseEntity(n=>{(n instanceof Sr||n instanceof $i)&&(a.includes(n.frameId??"")||n.frameId===t)&&n.updateEntity2DByOp(t,i,r,s)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let i=Object.entries(t.data.lib.components).map((r,s)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:s}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(r=>{r instanceof Mr&&r.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Tt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Tt.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,a,n){if(e){let o=r.find(e);o&&o!==r&&s.forInstancesRec(l=>{l.data=_d(l.data,h=>{let c=h.events.data(n.id),d=l.goUp(a);if(d){let u=[...BE(d.identity),e].join("-"),p=this.entityIdentityToEntity[u];if(p){let f=p.uuid,g=Gi.zoom(c,t);g[i]=f}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,s,a){e.forEach(n=>{n.data.type==="Transition"?this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,s,a):n.data.type==="Animation"?this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,s,a):n.data.type==="Conditional"&&(this.rewriteActions(n.data.ifActions,[...t,n.id,"ifActions"],i,r,s,a),this.rewriteActions(n.data.elseActions,[...t,n.id,"elseActions"],i,r,s,a))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Eh&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if(r.data.type==="GameControl"){let s=!1;if(t.forInstancesRec(a=>{a.data=_d(a.data,n=>{a.isInstanceRoot||(n.events.delete(r.id),s=!0)}).data}),s===!1)for(let a of wf.list)this.rewriteActions(r.data.gameActions[a],["gameActions",a],e,t,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(s=>{if(s instanceof Eh&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||s.resetBBoxNeedsUpdate(),i&&s.traverseEntity(a=>{i.addClip(a)}),!0});for(let s of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),sx(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof Eh&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){for(let e of this.children)Tt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=s=>{for(let a of s.children){let n=a.cloner;if(Tt.is(a)&&!a.raycastLock&&(a.visible||n!=null&&n.object.data.visible))if(t===!0&&a.isInstanceRoot){let o=[];if(e.intersectObject(a,!0,o),o.length){let l=o[0];l.object=a,l.point.applyMatrix4(l.object.matrixWorld);let h=a.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(Ns(a)||cy(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,i),wy(a,e,i)),r(a)}};return r(this.activePage),i}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let a=s.cloner;Tt.is(s)&&(s.visible||a!=null&&a.object.data.visible)&&((Ns(s)||cy(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),wy(s,e,t,!0)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)Tt.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Tt.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Tt.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof Ii&&i.data.type==="Mesh"&&(i.data.geometry.type==="TextGeometry"||i.data.geometry.type==="InputGeometry")&&i.data.geometry.font===e){let r=i.geometry,s=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(s,t);let a=i.invalidateDownstreamBooleanData();un(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)cl.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Tt.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,s,a){var l;let n={scene:this,shared:a},o=ax(e,t,n);return o instanceof pl&&this.shapeBlendIntances.push(o),o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,a)),o.updateState(t,n),o instanceof Ii&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(this),o.cloner&&this.toExpandCloner.add(o),(l=t.pathSnapping)!=null&&l.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&o.traverseEntity(h=>{let c=h.dataPatched;if(h instanceof Ii&&c.bones&&c.boneInverses){let d=c.bones.map(f=>this.find(f)),u=c.boneInverses.map(f=>new we().fromArray(f)),p=new qy(d,u);h.bind(p,h.bindMatrix)}else h.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let r=0,s=e.length;r<s;++r){let{id:a,recursive:n}=e[r],o=this.find(a),l=n?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new Si;return i.setFromPoints(t),i.getCenter(zA),zA}copyMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e);i?t.copy(i.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){var r;if(e===null){t.identity();return}let i=(r=this.find(e))==null?void 0:r.parent;i?t.copy(i.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Vr)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof uo&&e(t.material[i]);else t.material instanceof uo&&e(t.material)})}updateViewPlaneSize(e,t,i=!1){this.traverseConcreteEntity(r=>{r instanceof Mr&&r.setViewplaneSize(e,t,i)})}initializeSplatViewer(){this.splatViewer=new k$({scene:this}),this.reloadSplats()}reloadSplats(){var e;(e=this.splatViewer)==null||e.loadSplat()}},zp=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},V$=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return G$(Math.atan2(r,i))},j$=(e,t,i)=>{let r={x:0,y:0};return i=Sy(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},Sy=e=>e*(Math.PI/180),G$=e=>e*(180/Math.PI),H$=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,hv=new Map,BA=e=>{hv.has(e)&&clearTimeout(hv.get(e)),hv.set(e,setTimeout(e,100))},Nf=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let a=0;a<r.length;a+=1)s=r[a],e.addEventListener?e.addEventListener(s,i,!1):e.attachEvent&&e.attachEvent(s,i)},FA=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let a=0;a<r.length;a+=1)s=r[a],e.removeEventListener?e.removeEventListener(s,i):e.detachEvent&&e.detachEvent(s,i)},fP=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),UA=()=>{if(typeof window>"u")return;let e=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:e,y:t}},Ay=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},ox=(e,t,i)=>{let r=mP(e);for(let s in r)if(r.hasOwnProperty(s))if(typeof t=="string")r[s]=t+" "+i;else{let a="";for(let n=0,o=t.length;n<o;n+=1)a+=t[n]+" "+i+", ";r[s]=a.slice(0,-2)}return r},W$=(e,t)=>{let i=mP(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},mP=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},cv=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},q$=(e,t)=>{let i={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?i[r]=t[r]:e.hasOwnProperty(r)&&(i[r]=e[r]);return i},My=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},X$=(e,t,i)=>({x:Math.min(Math.max(e.x,t.x-i),t.x+i),y:Math.min(Math.max(e.y,t.y-i),t.y+i)});typeof window<"u"&&(gP="ontouchstart"in window,vP=!!window.PointerEvent,yP=!!window.MSPointerEvent);var gP,vP,yP,Dc={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},fh,Od={};vP?fh=Dc.pointer:yP?fh=Dc.MSPointer:gP?(fh=Dc.touch,Od=Dc.mouse):fh=Dc.mouse;function bl(){}bl.prototype.on=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var a=0;a<r.length;a+=1)s=r[a],i._handlers_[s]=i._handlers_[s]||[],i._handlers_[s].push(t);return i};bl.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i};bl.prototype.trigger=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var a=0;a<r.length;a+=1)s=r[a],i._handlers_[s]&&i._handlers_[s].length&&i._handlers_[s].forEach(function(n){n.call(i,{type:s,target:i},t)})};bl.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=q$(t.options,e))};bl.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Nf(e,fh[t],i._domHandlers_[t]),Od[t]&&Nf(e,Od[t],i._domHandlers_[t]),i};bl.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},FA(e,fh[t],i._domHandlers_[t]),Od[t]&&FA(e,Od[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var lx=bl;function Xi(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Xi.id,Xi.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Xi.prototype=new lx;Xi.constructor=Xi;Xi.id=0;Xi.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};Xi.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=W$("borderRadius","50%"),i=ox("transition","opacity",e),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},cv(r.el,i),this.options.shape==="circle"&&cv(r.back,t),cv(r.front,t),this.applyStyles(r),this};Xi.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this};Xi.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Xi.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Xi.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Xi.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t};Xi.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t};Xi.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",s={};s.front=ox("transition",["top","left"],r);var a={front:{}};a.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(a),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)};Xi.prototype.restCallback=function(){var e=this,t={};t.front=ox("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};Xi.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Xi.prototype.computeDirection=function(e){var t=e.angle.radian,i=Math.PI/4,r=Math.PI/2,s,a,n;if(t>i&&t<i*3&&!e.lockX?s="up":t>-i&&t<=i&&!e.lockY?s="left":t>-i*3&&t<=-i&&!e.lockX?s="down":e.lockY||(s="right"),e.lockY||(t>-r&&t<r?a="left":a="right"),e.lockX||(t>0?n="up":n="down"),e.force>this.options.threshold){var o={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(o[l]=this.direction[l]);var h={};this.direction={x:a,y:n,angle:s},e.direction=this.direction;for(l in o)o[l]===this.direction[l]&&(h[l]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+a,e),h.y||this.trigger("plain:"+n,e),h.angle||this.trigger("dir dir:"+s,e)}else this.resetDirection();return e};var Y$=Xi;function Ai(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=Ai.id,Ai.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(t),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}Ai.prototype=new lx;Ai.constructor=Ai;Ai.id=0;Ai.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,s=t.length;r<s;r+=1)if(t[r].identifier===i)return t[r];return!1}};Ai.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};Ai.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}};Ai.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,s={},a=i.options,n={x:i.parentIsFlex?r.x:r.x+i.box.left,y:i.parentIsFlex?r.y:r.y+i.box.top};if(e.x&&e.y)s={x:e.x-n.x,y:e.y-n.y};else if(e.top||e.right||e.bottom||e.left){var o=document.createElement("DIV");o.style.display="hidden",o.style.top=e.top,o.style.right=e.right,o.style.bottom=e.bottom,o.style.left=e.left,o.style.position="absolute",a.zone.appendChild(o);var l=o.getBoundingClientRect();a.zone.removeChild(o),s=e,e={x:l.left+r.x,y:l.top+r.y}}var h=new Y$(i,{color:a.color,size:a.size,threshold:a.threshold,fadeTime:a.fadeTime,dataOnly:a.dataOnly,restJoystick:a.restJoystick,restOpacity:a.restOpacity,mode:a.mode,identifier:t,position:e,zone:a.zone,frontPosition:{x:0,y:0},shape:a.shape});return a.dataOnly||(Ay(h.ui.el,s),Ay(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h};Ai.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};Ai.prototype.bindNipple=function(e){var t=this,i,r=function(s,a){i=s.type+" "+a.id+":"+s.type,t.trigger(i,a)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};Ai.prototype.pressureFn=function(e,t,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval((function(){var a=e.force||e.pressure||e.webkitForce||0;a!==s&&(t.trigger("pressure",a),r.trigger("pressure "+t.identifier+":pressure",a),s=a)}).bind(r),100)};Ai.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=fP(e),t.updateBox();var s=function(a){t.actives.length<i.maxNumberOfNipples?t.processOnStart(a):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(l){return l.identifier===n})<0){var o=[e[0]];o.identifier=n,t.processOnEnd(o)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(a))};return My(e,s),t.manager.bindDocument(),!1};Ai.prototype.processOnStart=function(e){var t=this,i=t.options,r,s=t.manager.getIdentifier(e),a=e.force||e.pressure||e.webkitForce||0,n={x:e.pageX,y:e.pageY},o=t.getOrCreate(s,n);o.identifier!==s&&t.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(c){c.trigger("start",c),t.trigger("start "+c.id+":start",c),c.show(),a>0&&t.pressureFn(e,c,c.identifier),t.processOnMove(e)};if((r=t.idles.indexOf(o))>=0&&t.idles.splice(r,1),t.actives.push(o),t.ids.push(o.identifier),i.mode!=="semi")l(o);else{var h=zp(n,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};Ai.prototype.getOrCreate=function(e,t){var i=this,r=i.options,s;return/(semi|static)/.test(r.mode)?(s=i.idles[0],s?(i.idles.splice(0,1),s):r.mode==="semi"?i.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1)):(s=i.createNipple(t,e),s)};Ai.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),a=t.manager.scroll;if(!H$(e)){this.processOnEnd(e);return}if(!s){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(i.dynamicPage){var n=s.el.getBoundingClientRect();s.position={x:a.x+n.left,y:a.y+n.top}}s.identifier=r;var o=s.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var h=zp(l,s.position),c=V$(l,s.position),d=Sy(c),u=h/o,p={distance:h,position:l},f,g;if(s.options.shape==="circle"?(f=Math.min(h,o),g=j$(s.position,f,c)):(g=X$(l,s.position,o),f=zp(g,s.position)),i.follow){if(h>o){let x=l.x-g.x,w=l.y-g.y;s.position.x+=x,s.position.y+=w,s.el.style.top=s.position.y-(t.box.top+a.y)+"px",s.el.style.left=s.position.x-(t.box.left+a.x)+"px",h=zp(l,s.position)}}else l=g,h=f;var m=l.x-s.position.x,v=l.y-s.position.y;s.frontPosition={x:m,y:v},i.dataOnly||Ay(s.ui.front,s.frontPosition);var y={identifier:s.identifier,position:l,force:u,pressure:e.force||e.pressure||e.webkitForce||0,distance:h,angle:{radian:d,degree:c},vector:{x:m/o,y:-v/o},raw:p,instance:s,lockX:i.lockX,lockY:i.lockY};y=s.computeDirection(y),y.angle={radian:Sy(180-c),degree:180-c},s.trigger("move",y),t.trigger("move "+s.id+":move",y)};Ai.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),a=t.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),t.trigger("removed "+s.id+":removed",s),t.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(t.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),t.trigger("end "+s.id+":end",s),t.ids.indexOf(s.identifier)>=0&&t.ids.splice(t.ids.indexOf(s.identifier),1),t.actives.indexOf(s)>=0&&t.actives.splice(t.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?t.idles.push(s):t.nipples.indexOf(s)>=0&&t.nipples.splice(t.nipples.indexOf(s),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[a.id]=a.identifier))};Ai.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()};Ai.prototype.destroy=function(){var e=this;e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()});for(var t in e.pressureIntervals)e.pressureIntervals.hasOwnProperty(t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off()};var Q$=Ai;function nr(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=UA(),t.config(e),t.prepareCollections();var i=function(){var s;t.collections.forEach(function(a){a.forEach(function(n){s=n.el.getBoundingClientRect(),n.position={x:t.scroll.x+s.left,y:t.scroll.y+s.top}})})};if(typeof window>"u")return t.collections;Nf(window,"resize",function(){BA(i)});var r=function(){t.scroll=UA()};return Nf(window,"scroll",function(){BA(r)}),t.collections}nr.prototype=new lx;nr.constructor=nr;nr.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return i=r.get(t),!i}),i}};nr.prototype.create=function(e){return this.createCollection(e)};nr.prototype.createCollection=function(e){var t=this,i=new Q$(t,e);return t.bindCollection(i),t.collections.push(i),i};nr.prototype.bindCollection=function(e){var t=this,i,r=function(s,a){i=s.type+" "+a.id+":"+s.type,t.trigger(i,a)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};nr.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};nr.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};nr.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};nr.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t};nr.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};nr.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};nr.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};nr.prototype.onAny=function(e,t){var i=this,r,s="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=fP(t);var a=function(o,l,h){h.ids.indexOf(l)>=0&&(h[s](o),o._found_=!0)},n=function(o){r=i.getIdentifier(o),My(i.collections,a.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return My(t,n),!1};nr.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};nr.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1)};var Z$=nr,NA=new Z$,K$={create:function(e){return NA.create(e)},factory:NA},xP=new Map,ad=new Map,Zo=class{constructor(e,t,i,r){this.data=t;let{audio:s,volume:a,delay:n,loop:o}=t;if(!s)throw new Error("Missing property");let l=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new qc({src:l,volume:a,delay:n,loop:o}),ad.has(i.uuid)?ad.get(i.uuid).push(this):ad.set(i.uuid,[this]),xP.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},Ey=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=xP.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=ad.get(e);!(t!=null&&t.length)||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let e=[...ad.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},bP=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new Zo(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Ey(t);else throw new Error("Missing property")}dispatchBasic(){if(ri(this.shared,this.condition)===!1)return!1;this.interaction instanceof Zo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(ri(this.shared,this.condition)===!1)return!1;this.interaction instanceof Zo?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){if(ri(this.shared,this.condition)===!1)return!1;this.interaction instanceof Zo&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}},wP=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.delay=0,this.emission=e.emission,e.delay!==void 0&&(this.delay=e.delay),this.particleSystem=this.page.scene.find(this.data.emitterObjectId)}toggleEmitting(){this.particleSystem.started&&!this.particleSystem.stopped?this.stop(this.delay):this.start(this.delay)}toggleFroze(){this.particleSystem.started&&!this.particleSystem.isFrozen?this.freeze(this.delay):this.unFreeze(this.delay)}start(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.start(0),this.clearDelay()},e);return}this.particleSystem.start()}stop(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.stop(0),this.clearDelay()},e);return}this.particleSystem.stop()}freeze(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.freeze(0),this.clearDelay()},e);return}this.particleSystem.froze()}unFreeze(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.unFreeze(0),this.clearDelay()},e);return}this.particleSystem.unFroze()}reset(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.reset(0),this.clearDelay()},e);return}this.particleSystem.reset()}reverseFromCurrent(){switch(this.emission){case"emitToggle":this.toggleEmitting();break;case"pauseToggle":this.toggleFroze();break}}dispatchBasic(){if(ri(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"emitToggle":this.toggleEmitting();break;case"pause":this.freeze(this.delay);break;case"pauseToggle":this.toggleFroze();break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay);break}}dispatchConditional(){if(ri(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay);break}}dispatchGameControl(e){if(ri(this.shared,this.condition)===!1||!this.particleSystem)return!1;e==="start"?this.start(this.delay):this.stop(this.delay)}dispose(){!this.particleSystem||(this.particleSystem.reset(),this.clearDelay())}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}},J$="text/plain",$$="us-ascii",kA=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),eee=(e,{stripHash:t})=>{let i=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!i)throw new Error(`Invalid URL: ${e}`);let{type:r,data:s,hash:a}=i.groups,n=r.split(";");a=t?"":a;let o=!1;n[n.length-1]==="base64"&&(n.pop(),o=!0);let l=(n.shift()||"").toLowerCase(),h=[...n.map(c=>{let[d,u=""]=c.split("=").map(p=>p.trim());return d==="charset"&&(u=u.toLowerCase(),u===$$)?"":`${d}${u?`=${u}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==J$)&&h.unshift(l),`data:${h.join(";")},${o?s.trim():s}${a?`#${a}`:""}`};function tee(e,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},e=e.trim(),/^data:/i.test(e))return eee(e,t);if(/^view-source:/i.test(e))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let i=e.startsWith("//");!i&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&r.protocol==="https:"&&(r.protocol="http:"),t.forceHttps&&r.protocol==="http:"&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){let a=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,n=0,o="";for(;;){let h=a.exec(r.pathname);if(!h)break;let c=h[0],d=h.index,u=r.pathname.slice(n,d);o+=u.replace(/\/{2,}/g,"/"),o+=c,n=d+c.length}let l=r.pathname.slice(n,r.pathname.length);o+=l.replace(/\/{2,}/g,"/"),r.pathname=o}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let a=r.pathname.split("/"),n=a[a.length-1];kA(n,t.removeDirectoryIndex)&&(a=a.slice(0,-1),r.pathname=a.slice(1).join("/")+"/")}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let a of[...r.searchParams.keys()])kA(a,t.removeQueryParameters)&&r.searchParams.delete(a);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let s=e;return e=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!s.endsWith("/")&&r.hash===""&&(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),i&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}var iee=class{constructor({url:e,context:t},i,r,s){if(this.controlsManager=i,this.shared=r,this.condition=s,!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:tee(e,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=t??"tab"}dispatch(){var e;if(ri(this.shared,this.condition)===!1)return!1;ec?window.location.assign(this.url):(this.context==="tab"||zE&&this.context==="none"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),(e=this.controlsManager.orbitControls)==null||e.onPointerUp(at[0]),g8())}},_P=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=s,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=a=>{var h,c;this.timeoutIdQueue.shift();let n=this.page.scene.find(a);if(n===void 0)return;let o=this.controlsManager.sharedGameControlGlobals.rapierWorld,l=o?(h=n.dataPatched.physics)==null?void 0:h.fusedBody:!0;if(n.cloner){for(let d of n.cloner.children)l?(d.playModeVisible=!1,d.rigidBody&&((c=n.dataPatched.physics)==null?void 0:c.rigidBody)==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(d.rigidBody.collider(0).handle),o.removeRigidBody(d.rigidBody),d.rigidBody=void 0),d.bvhGeometry&&(d.bvhGeometry=void 0)):this.clone===void 0||this.clone===d?(d.playModeVisible=!1,d.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(d.rigidBody.collider(0).handle),o.removeRigidBody(d.rigidBody),d.rigidBody=void 0)):d.playModeVisible===void 0&&(d.playModeVisible=!0);(l||this.clone===void 0||this.clone===!1)&&(n.visible=!1,n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0))}else n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0),n.visible=!1;o===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(d=>d.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(d=>d.rigidBody!==void 0),n.destroyedInAction=!0,this.controlsManager.requestRender()},this.objects=[...e.objects]}dispatch(e){if(ri(this.shared,this.condition)===!1)return!1;this.clone=e,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(ri(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(e=>window.clearTimeout(e))}},SP=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.shared=i,this.eventManager=r,this.condition=s,this.shared=i}dispatch(){if(ri(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{var e;this.shared.reset(this.shared.data,!0),xx(this.page,this.shared,!0),this.eventManager.reset(),(e=this.eventManager.controlsManager.gameControl)==null||e.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},AP={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,timelineChangeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},hx={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},ree=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],kf={CSS:{},springs:{}};function Gs(e,t,i){return Math.min(Math.max(e,t),i)}function nd(e,t){return e.indexOf(t)>-1}function dv(e,t){return e.apply(null,t)}var ht={arr:function(e){return Array.isArray(e)},obj:function(e){return nd(Object.prototype.toString.call(e),"Object")},pth:function(e){return ht.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||ht.svg(e))},str:function(e){return typeof e=="string"},fnc:function(e){return typeof e=="function"},und:function(e){return typeof e>"u"},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return ht.hex(e)||ht.rgb(e)||ht.hsl(e)},key:function(e){return!AP.hasOwnProperty(e)&&!hx.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function MP(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function EP(e,t){var i=MP(e),r=Gs(ht.und(i[0])?1:i[0],.1,100),s=Gs(ht.und(i[1])?100:i[1],.1,100),a=Gs(ht.und(i[2])?10:i[2],.1,100),n=Gs(ht.und(i[3])?0:i[3],.1,100),o=Math.sqrt(s/r),l=a/(2*Math.sqrt(s*r)),h=l<1?o*Math.sqrt(1-l*l):0,c=1,d=l<1?(l*o+-n)/h:-n+o;function u(f){var g=t?t*f/1e3:f;return l<1?g=Math.exp(-g*l*o)*(c*Math.cos(h*g)+d*Math.sin(h*g)):g=(c+d*g)*Math.exp(-g*o),f===0||f===1?f:1-g}function p(){var f=kf.springs[e];if(f)return f;for(var g=1/6,m=0,v=0;;)if(m+=g,u(m)===1){if(v++,v>=16)break}else v=0;var y=m*g*1e3;return kf.springs[e]=y,y}return t?u:p}function see(e){return e===void 0&&(e=10),function(t){return Math.ceil(Gs(t,1e-6,1)*e)*(1/e)}}var aee=function(){var e=11,t=1/(e-1);function i(c,d){return 1-3*d+3*c}function r(c,d){return 3*d-6*c}function s(c){return 3*c}function a(c,d,u){return((i(d,u)*c+r(d,u))*c+s(d))*c}function n(c,d,u){return 3*i(d,u)*c*c+2*r(d,u)*c+s(d)}function o(c,d,u,p,f){var g,m,v=0;do m=d+(u-d)/2,g=a(m,p,f)-c,g>0?u=m:d=m;while(Math.abs(g)>1e-7&&++v<10);return m}function l(c,d,u,p){for(var f=0;f<4;++f){var g=n(d,u,p);if(g===0)return d;var m=a(d,u,p)-c;d-=m/g}return d}function h(c,d,u,p){if(!(0<=c&&c<=1&&0<=u&&u<=1))return;var f=new Float32Array(e);if(c!==d||u!==p)for(var g=0;g<e;++g)f[g]=a(g*t,c,u);function m(v){for(var y=0,x=1,w=e-1;x!==w&&f[x]<=v;++x)y+=t;--x;var _=(v-f[x])/(f[x+1]-f[x]),b=y+_*t,A=n(b,c,u);return A>=.001?l(v,b,c,u):A===0?b:o(v,y,y+t,c,u)}return function(v){return c===d&&u===p||v===0||v===1?v:a(m(v),d,p)}}return h}(),CP=function(){var e={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var s,a=4;r<((s=Math.pow(2,--a))-1)/11;);return 1/Math.pow(4,3-a)-7.5625*Math.pow((s*3-2)/22-r,2)}},Elastic:function(r,s){r===void 0&&(r=1),s===void 0&&(s=.5);var a=Gs(r,1,10),n=Gs(s,.1,2);return function(o){return o===0||o===1?o:-a*Math.pow(2,10*(o-1))*Math.sin((o-1-n/(Math.PI*2)*Math.asin(1/a))*(Math.PI*2)/n)}}},i=["Quad","Cubic","Quart","Quint","Expo"];return i.forEach(function(r,s){t[r]=function(){return function(a){return Math.pow(a,s+2)}}}),Object.keys(t).forEach(function(r){var s=t[r];e["easeIn"+r]=s,e["easeOut"+r]=function(a,n){return function(o){return 1-s(a,n)(1-o)}},e["easeInOut"+r]=function(a,n){return function(o){return o<.5?s(a,n)(o*2)/2:1-s(a,n)(o*-2+2)/2}}}),e}();function cx(e,t){if(ht.fnc(e))return e;var i=e.split("(")[0],r=CP[i],s=MP(e);switch(i){case"spring":return EP(e,t);case"cubicBezier":return dv(aee,s);case"steps":return dv(see,s);default:return dv(r,s)}}function TP(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function gm(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,s=[],a=0;a<i;a++)if(a in e){var n=e[a];t.call(r,n,a,e)&&s.push(n)}return s}function vm(e){return e.reduce(function(t,i){return t.concat(ht.arr(i)?vm(i):i)},[])}function VA(e){return ht.arr(e)?e:(ht.str(e)&&(e=TP(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function dx(e,t){return e.some(function(i){return i===t})}function ux(e){var t={};for(var i in e)t[i]=e[i];return t}function Cy(e,t){var i=ux(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function ym(e,t){var i=ux(e);for(var r in t)i[r]=ht.und(e[r])?t[r]:e[r];return i}function nee(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function oee(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,c){return l+l+h+h+c+c}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),s=parseInt(r[1],16),a=parseInt(r[2],16),n=parseInt(r[3],16);return"rgba("+s+","+a+","+n+",1)"}function lee(e){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,s=parseInt(t[3],10)/100,a=t[4]||1;function n(u,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?u+(p-u)*6*f:f<1/2?p:f<2/3?u+(p-u)*(2/3-f)*6:u}var o,l,h;if(r==0)o=l=h=s;else{var c=s<.5?s*(1+r):s+r-s*r,d=2*s-c;o=n(d,c,i+1/3),l=n(d,c,i),h=n(d,c,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+a+")"}function hee(e){if(ht.rgb(e))return nee(e);if(ht.hex(e))return oee(e);if(ht.hsl(e))return lee(e)}function fn(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function cee(e){if(nd(e,"translate")||e==="perspective")return"px";if(nd(e,"rotate")||nd(e,"skew"))return"deg"}function Ty(e,t){return ht.fnc(e)?e(t.target,t.id,t.total):e}function wa(e,t){return e.getAttribute(t)}function px(e,t,i){var r=fn(t);if(dx([i,"deg","rad","turn"],r))return t;var s=kf.CSS[t+i];if(!ht.und(s))return s;var a=100,n=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(n),n.style.position="absolute",n.style.width=a+i;var l=a/n.offsetWidth;o.removeChild(n);var h=l*parseFloat(t);return kf.CSS[t+i]=h,h}function PP(e,t,i){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return i?px(e,s,i):s}}function fx(e,t){if(ht.dom(e)&&!ht.inp(e)&&(wa(e,t)||ht.svg(e)&&e[t]))return"attribute";if(ht.dom(e)&&dx(ree,t))return"transform";if(ht.dom(e)&&t!=="transform"&&PP(e,t))return"css";if(e[t]!=null)return"object"}function DP(e){if(ht.dom(e)){for(var t=e.style.transform||"",i=/(\w+)\(([^)]*)\)/g,r=new Map,s;s=i.exec(t);)r.set(s[1],s[2]);return r}}function dee(e,t,i,r){var s=nd(t,"scale")?1:0+cee(t),a=DP(e).get(t)||s;return i&&(i.transforms.list.set(t,a),i.transforms.last=t),r?px(e,a,r):a}function mx(e,t,i,r){switch(fx(e,t)){case"transform":return dee(e,t,r,i);case"css":return PP(e,t,i);case"attribute":return wa(e,t);default:return e[t]||0}}function gx(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=fn(e)||0,s=parseFloat(t),a=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return s+a+r;case"-":return s-a+r;case"*":return s*a+r}}function IP(e,t){if(ht.col(e))return hee(e);if(/\s/g.test(e))return e;var i=fn(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function vx(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function uee(e){return Math.PI*2*wa(e,"r")}function pee(e){return wa(e,"width")*2+wa(e,"height")*2}function fee(e){return vx({x:wa(e,"x1"),y:wa(e,"y1")},{x:wa(e,"x2"),y:wa(e,"y2")})}function OP(e){for(var t=e.points,i=0,r,s=0;s<t.numberOfItems;s++){var a=t.getItem(s);s>0&&(i+=vx(r,a)),r=a}return i}function mee(e){var t=e.points;return OP(e)+vx(t.getItem(t.numberOfItems-1),t.getItem(0))}function RP(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return uee(e);case"rect":return pee(e);case"line":return fee(e);case"polyline":return OP(e);case"polygon":return mee(e)}}function gee(e){var t=RP(e);return e.setAttribute("stroke-dasharray",t),t}function vee(e){for(var t=e.parentNode;ht.svg(t)&&ht.svg(t.parentNode);)t=t.parentNode;return t}function LP(e,t){var i=t||{},r=i.el||vee(e),s=r.getBoundingClientRect(),a=wa(r,"viewBox"),n=s.width,o=s.height,l=i.viewBox||(a?a.split(" "):[0,0,n,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:n/l[2],h:o/l[3]}}function yee(e,t){var i=ht.str(e)?TP(e)[0]:e,r=t||100;return function(s){return{property:s,el:i,svg:LP(i),totalLength:RP(i)*(r/100)}}}function xee(e,t){function i(o){o===void 0&&(o=0);var l=t+o>=1?t+o:0;return e.el.getPointAtLength(l)}var r=LP(e.el,e.svg),s=i(),a=i(-1),n=i(1);switch(e.property){case"x":return(s.x-r.x)*r.w;case"y":return(s.y-r.y)*r.h;case"angle":return Math.atan2(n.y-a.y,n.x-a.x)*180/Math.PI}}function jA(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=IP(ht.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:ht.str(e)||t?r.split(i):[]}}function zP(e){var t=e?vm(ht.arr(e)?e.map(VA):VA(e)):[];return gm(t,function(i,r,s){return s.indexOf(i)===r})}function BP(e){var t=zP(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:DP(i)}}})}function bee(e,t){var i=ux(t);if(/^spring/.test(i.easing)&&(i.duration=EP(i.easing)),ht.arr(e)){var r=e.length,s=r===2&&!ht.obj(e[0]);s?e={value:e}:ht.fnc(t.duration)||(i.duration=t.duration/r)}var a=ht.arr(e)?e:[e];return a.map(function(n,o){var l=ht.obj(n)&&!ht.pth(n)?n:{value:n};return ht.und(l.delay)&&(l.delay=o?0:t.delay),ht.und(l.endDelay)&&(l.endDelay=o===a.length-1?t.endDelay:0),l}).map(function(n){return ym(n,i)})}function wee(e){for(var t=gm(vm(e.map(function(a){return Object.keys(a)})),function(a){return ht.key(a)}).reduce(function(a,n){return a.indexOf(n)<0&&a.push(n),a},[]),i={},r=function(a){var n=t[a];i[n]=e.map(function(o){var l={};for(var h in o)ht.key(h)?h==n&&(l.value=o[h]):l[h]=o[h];return l})},s=0;s<t.length;s++)r(s);return i}function _ee(e,t){var i=[],r=t.keyframes;r&&(t=ym(wee(r),t));for(var s in t)ht.key(s)&&i.push({name:s,tweens:bee(t[s],e)});return i}function See(e,t){var i={};for(var r in e){var s=Ty(e[r],t);ht.arr(s)&&(s=s.map(function(a){return Ty(a,t)}),s.length===1&&(s=s[0])),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function Aee(e,t){var i;return e.tweens.map(function(r){var s=See(r,t),a=s.value,n=ht.arr(a)?a[1]:a,o=fn(n),l=mx(t.target,e.name,o,t),h=i?i.to.original:l,c=ht.arr(a)?a[0]:h,d=fn(c)||fn(l),u=o||d;return ht.und(n)&&(n=h),s.from=jA(c,u),s.to=jA(gx(n,c),u),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=cx(s.easing,s.duration),s.isPath=ht.pth(a),s.isColor=ht.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}var FP={css:function(e,t,i){return e.style[t]=i},attribute:function(e,t,i){return e.setAttribute(t,i)},object:function(e,t,i){return e[t]=i},transform:function(e,t,i,r,s){if(r.list.set(t,i),t===r.last||s){var a="";r.list.forEach(function(n,o){a+=o+"("+n+") "}),e.style.transform=a}}};function UP(e,t){var i=BP(e);i.forEach(function(r){for(var s in t){var a=Ty(t[s],r),n=r.target,o=fn(a),l=mx(n,s,o,r),h=o||fn(l),c=gx(IP(a,h),l),d=fx(n,s);FP[d](n,s,c,r.transforms,!0)}})}function Mee(e,t){var i=fx(e.target,t.name);if(i){var r=Aee(t,e),s=r[r.length-1];return{type:i,property:t.name,animatable:e,tweens:r,duration:s.end,delay:r[0].delay,endDelay:s.endDelay}}}function Eee(e,t){return gm(vm(e.map(function(i){return t.map(function(r){return Mee(i,r)})})),function(i){return!ht.und(i)})}function NP(e,t){var i=e.length,r=function(a){return a.timelineOffset?a.timelineOffset:0},s={};return s.duration=i?Math.max.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0,l=a.pingPongEndDelayCorrection??0;return r(a)+n+o+l+a.duration*(a.loop??1)})):t.duration,s.delay=i?Math.min.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0;return r(a)+n+o+a.delay})):t.delay,s.endDelay=i?s.duration-Math.max.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0,l=a.pingPongEndDelayCorrection??0;return r(a)+n+o+a.duration*(a.loop??1)-a.endDelay-l})):t.endDelay,s}var GA=0;function Cee(e){var t=Cy(AP,e),i=Cy(hx,e),r=_ee(i,e),s=BP(e.targets),a=Eee(s,r),n=NP(a,i),o=GA;return GA++,ym(t,{id:o,children:[],animatables:s,animations:a,duration:n.duration,delay:n.delay,endDelay:n.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection,pingPongEndDelayCorrection:i.pingPongEndDelayCorrection})}var Ss=[],HA=[],oh,WA=function(){let e=0,t=!0;function i(a){let n=Ss.length;if(n){let o=0;for(;o<n;){let l=Ss[o];l.paused?(Ss.splice(o,1),n--):(l.tick(a),o++)}oh=requestAnimationFrame(i)}else oh&&(cancelAnimationFrame(oh),oh=null)}function r(){e=performance.now(),oh=requestAnimationFrame(i)}function s(a){e+=a,i(e)}return{isUsingInternalRaf:t,play:r,update:s}}();function Tee(e){document.hidden?(Ss.forEach(function(t){return t.pause(e.timeStamp)}),HA=Ss.slice(0),_i.running=Ss=[]):HA.forEach(function(t){return t.play(e.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",Tee);function _i(e){e===void 0&&(e={});var t=0,i=0,r=0,s,a,n=0,o=null;function l(b){var A=window.Promise&&new Promise(function(S){return o=S});return b.finished=A,A}var h=Cee(e);l(h);function c(){var b=h.direction;b!=="alternate"&&(h.direction=b!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,a.forEach(function(A){(A.loop===1||A.loop%2===0)&&(A.reversed=h.reversed)})}function d(){h.direction="normal",h.reversed=!1,a.forEach(function(b){return b.reversed=!1})}function u(b){return h.reversed?h.duration-b:b}function p(){t=0,i=u(h.currentTime)*(1/_i.speed)}function f(b,A,S=!1){A&&(h.reversed?A.seek(A.duration*A.loop-(b-A.timelineOffset-A.pingPongDelayCorrection),S):A.seek(b-A.timelineOffset-A.startOnceDelay-A.pingPongDelayCorrection,S))}function g(b,A=!1){if(h.reversed)for(var S=n;S--;)f(b,a[S],A);else for(var E=0;E<n;E++)f(b,a[E],A)}function m(b){var he,re,te,ae,de,pe,be,Le,Me,Ve;var A=0,S=h.animations,E=S.length;for(h.direction!=="alternate"&&((he=h.parent)==null?void 0:he.direction)==="alternate"?((re=h.parent)==null?void 0:re.rewind)===!1&&h.reversePlayback===!0&&h.rewind===!1&&((te=h.parent)!=null&&te.reversed&&h.direction==="alternate"?b=h.duration-h.delay+h.endDelay-b:b=h.duration+h.delay-h.endDelay-b):w(!1,(ae=h.parent)==null?void 0:ae.rewind,h.rewind,(de=h.parent)==null?void 0:de.reversePlayback,h.reversePlayback)&&((pe=h.parent)!=null&&pe.reversed&&h.direction==="alternate"?b=h.duration-h.delay+h.endDelay-b:b=h.duration+h.delay-h.endDelay-b);A<E;){var C=S[A],T=C.animatable,D=C.tweens,O=D.length-1,P=D[O];O&&(P=gm(D,function(Ce){return b<Ce.end})[0]||P);let Ue;(be=h.parent)!=null&&be.reversed&&h.direction==="alternate"?Ue=Gs(b-P.start-P.endDelay,0,P.duration)/P.duration:Ue=Gs(b-P.start-P.delay,0,P.duration)/P.duration;for(var U=isNaN(Ue)?1:P.easing(Ue),W=P.to.strings,k=P.round,F=[],Z=P.to.numbers.length,X=void 0,G=0;G<Z;G++){var q=void 0;let Ce,Ee;h.direction!=="alternate"?((Le=h.parent)==null?void 0:Le.rewind)===!1&&h.reversePlayback===!0&&h.rewind===!1?(Ce=P.to.numbers[G],Ee=P.from.numbers[G]||0):(Ee=P.to.numbers[G],Ce=P.from.numbers[G]||0):w(!0,(Me=h.parent)==null?void 0:Me.rewind,h.rewind,(Ve=h.parent)==null?void 0:Ve.reversePlayback,h.reversePlayback)?(Ce=P.to.numbers[G],Ee=P.from.numbers[G]||0):(Ee=P.to.numbers[G],Ce=P.from.numbers[G]||0),P.isPath?q=xee(P.value,U*Ee):q=Ce+U*(Ee-Ce),k&&(P.isColor&&G>2||(q=Math.round(q*k)/k)),F.push(q)}var $=W.length;if(!$)X=F[0];else{X=W[0];for(var Q=0;Q<$;Q++){W[Q];var ee=W[Q+1],H=F[Q];isNaN(H)||(ee?X+=H+ee:X+=H+" ")}}FP[C.type](T.target,C.property,X,T.transforms),C.currentValue=X,A++}}function v(b){h[b]&&!h.passThrough&&h[b](h)}function y(){h.remaining&&h.remaining!==!0&&h.remaining--}let x={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function w(b,A,S,E,C){return x[b<<4|A<<3|S<<2|E<<1|C]}function _(b,A=!1){var D;var S=h.duration;let E=h.delay,C=S-h.endDelay;(D=h.parent)!=null&&D.reversed&&h.direction==="alternate"&&(E=h.endDelay,C=S-h.delay);var T=u(b);if(h.progress=Gs(T/S*100,0,100),A||(h.reversePlayback=T<h.currentTime),n&&g(T,A),!h.began&&h.currentTime>=0&&(h.began=!0,v("begin")),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,v("loopBegin")),(h.reversed||T>=0)&&T<=E&&h.currentTime!==0&&(m(0),v("change")),(T>=C&&h.currentTime!==S+h.pingPongDelayCorrection||!S)&&(m(S),v("change")),T>E&&T<C?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,v("changeBegin")),m(T),v("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,v("change"),n&&v("timelineChangeComplete")):h.began&&T>C&&v("changeComplete"),h.currentTime=Gs(T,0,S+h.pingPongDelayCorrection),h.began&&v("update"),b>=S)if(y(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,v("loopComplete"),v("complete"),!h.passThrough&&"Promise"in window&&(o(),l(h)));else{n?t+=h.duration/_i.speed:t+=h.duration;for(let O of a)O.setStartTime(0),O.remaining=O.loop;v("loopComplete"),h.loopBegan=!1,h.direction==="alternate"?c():n&&d()}}return h.reset=function(){var b=h.direction;h.passThrough=!1,h.currentTime=0,h.progress=0,h.paused=!0,h.began=!1,h.loopBegan=!1,h.changeBegan=!1,h.completed=!1,h.changeCompleted=!1,h.reversePlayback=!1,h.reversed=b==="reverse",h.remaining=h.loop,a=h.children,n=a.length;for(var A=n;A--;)h.children[A].reset();m(h.reversed?h.duration:0)},h.setStartTime=function(b){t=b},h.set=function(b,A){return UP(b,A),h},h.tick=function(b){r=b,t||(t=r),_((r+(i-t))*_i.speed)},h.seek=function(b,A=!1){_(b-t,A)},h.pause=function(b){h.paused=!0,n&&(s=b??performance.now())},h.play=function(b){!h.paused||(h.completed&&h.reset(),h.paused=!1,Ss.push(h),n&&s!==void 0&&(t+=(b??performance.now())-s),!oh&&WA.isUsingInternalRaf&&WA.play())},h.reverse=function(){c(),h.completed=!h.reversed,p()},h.restart=function(){h.reset(),h.play()},h.reset(),h.autoplay&&h.play(),h}function qA(e,t){for(var i=t.length;i--;)dx(e,t[i].animatable.target)&&t.splice(i,1)}function Pee(e){for(var t=zP(e),i=Ss.length;i--;){var r=Ss[i],s=r.animations,a=r.children;qA(t,s);for(var n=a.length;n--;){var o=a[n],l=o.animations;qA(t,l),!l.length&&!o.children.length&&a.splice(n,1)}!s.length&&!a.length&&r.pause()}}function Dee(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?cx(t.easing):null,s=t.grid,a=t.axis,n=t.from||0,o=n==="first",l=n==="center",h=n==="last",c=ht.arr(e),d=parseFloat(c?e[0]:e),u=c?parseFloat(e[1]):0,p=fn(c?e[1]:e)||0,f=t.start||0+(c?d:0),g=[],m=0;return function(v,y,x){if(o&&(n=0),l&&(n=(x-1)/2),h&&(n=x-1),!g.length){for(var w=0;w<x;w++){if(!s)g.push(Math.abs(n-w));else{var _=l?(s[0]-1)/2:n%s[0],b=l?(s[1]-1)/2:Math.floor(n/s[0]),A=w%s[0],S=Math.floor(w/s[0]),E=_-A,C=b-S,T=Math.sqrt(E*E+C*C);a==="x"&&(T=-E),a==="y"&&(T=-C),g.push(T)}m=Math.max.apply(Math,g)}r&&(g=g.map(function(O){return r(O/m)*m})),i==="reverse"&&(g=g.map(function(O){return a?O<0?O*-1:-O:Math.abs(m-O)}))}var D=c?(u-d)/m:d;return f+D*(Math.round(g[y]*100)/100)+p}}function Iee(e){e===void 0&&(e={});var t=_i(e);return t.duration=0,t.add=function(i,r){var s=Ss.indexOf(t),a=t.children;s>-1&&Ss.splice(s,1);function n(u){u.passThrough=!0}for(var o=0;o<a.length;o++)n(a[o]);var l=ym(i,Cy(hx,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=ht.und(r)?h:gx(r,h),n(t);var c=_i(l);n(c),a.push(c),c.parent=t;var d=NP(a,e);return t.delay=d.delay,t.endDelay=d.endDelay,t.duration=d.duration,c.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}_i.version="3.2.0";_i.speed=1;_i.running=Ss;_i.remove=Pee;_i.get=mx;_i.set=UP;_i.convertPx=px;_i.path=yee;_i.setDashoffset=gee;_i.stagger=Dee;_i.timeline=Iee;_i.easing=cx;_i.penner=CP;_i.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var od=_i,XA=new M,YA=new M,QA=new lt;function Oee(e,t,i,r){if(r===0)return i.copy(e);if(r===1)return i.copy(t);let s=e.w*t.w+e.x*t.x+e.y*t.y+e.z*t.z;if(s>=1)return i.copy(e);let a=1-s*s;if(a<=Number.EPSILON){let c=1-r;return i.w=c*e.w+r*t.w,i.x=c*e.x+r*t.x,i.y=c*e.y+r*t.y,i.z=c*e.z+r*t.z,i.normalize(),i}let n=Math.sqrt(a),o=Math.atan2(n,s),l=Math.sin((1-r)*o)/n,h=Math.sin(r*o)/n;return i.w=e.w*l+t.w*h,i.x=e.x*l+t.x*h,i.y=e.y*l+t.y*h,i.z=e.z*l+t.z*h,i}function dr(e,t,i,r,s,a){let n=i[e]!==void 0?i[e]:void 0,o=r[e];if(o==null)return;let l=n!=null?typeof n=="string"?Number(s.getVariable(n)??0):n:t[e],h=typeof o=="string"?Number(s.getVariable(o)??0):o;if(l!==h)return{update:c=>{let d=Re.lerp(l,h,c);a?t[e]=Math.trunc(d):t[e]=d},start:()=>{t[e]=l},end:()=>{t[e]=h}}}function yx(e,t,i,r,s,a){let n=i[e]?i[e]:void 0,o=r[e];if(!o)return;let l=t[e],h=[...n??l].map(d=>typeof d=="string"?Number(s.getVariable(d)??0):d),c=[...o].map(d=>typeof d=="string"?Number(s.getVariable(d)??0):d);if(!(h.length!==c.length||y1(h,c)))return{update:d=>{h.forEach((u,p)=>{let f=Re.lerp(u,c[p],d);t[e][p]=a?Math.trunc(f):f})},start:()=>{Object.assign(t[e],h)},end:()=>{Object.assign(t[e],c)}}}function Vf(e,t,i){return t.forEach((r,s)=>{e.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function ZA(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=a?Vf(new M,a,s):o.clone(),h=Vf(new M,n,s);if(!l.equals(h))return{update:c=>{o.lerpVectors(l,h,c)},start:()=>{o.copy(l)},end:()=>{o.copy(h)}}}function KA(e,t,i){return t.forEach((r,s)=>{e.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function jf(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=!(o instanceof j),h=o instanceof j?o:new j().fromArray(o),c=a?KA(new j,a,s):h.clone(),d=KA(new j,n,s);if(!c.equals(d))return{update:u=>{h.lerpVectors(c,d,u),l&&(t[e]=h.toArray())},start:()=>{h.copy(c),l&&(t[e]=h.toArray())},end:()=>{h.copy(d),l&&(t[e]=h.toArray())}}}function Ree(e,t,i,r){let s=i[e]?i[e]:void 0,a=r[e];if(!a)return;let n=t[e],o=s?new we().fromArray(s):n.clone(),l=new M,h=new lt,c=new M;o.decompose(l,h,c);let d=new we().fromArray(a),u=new M,p=new lt,f=new M;if(d.decompose(u,p,f),!o.equals(d))return{update:g=>{QA.slerpQuaternions(h,p,g),XA.lerpVectors(l,u,g),YA.lerpVectors(c,f,g),n.compose(XA,QA,YA)},start:()=>{n.compose(l,h,c)},end:()=>{n.compose(u,p,f)}}}function Lee(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=a?typeof a=="string"?s.getColor(a).clone():new et().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new et().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let c=o.clone();return{update:d=>{var u,p;c.lerpColors(l,h,d),(p=(u=t[e])==null?void 0:u.copy)==null||p.call(u,c)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function gp(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=new vr(o.r,o.g,o.b,o.a),h=a?typeof a=="string"?s.getColor(a).clone():new vr(a.r,a.g,a.b,a.a):l.clone(),c=typeof n=="string"?s.getColor(n).clone():new vr(n.r,n.g,n.b,n.a);if(!h.equals(c))return{update:d=>{l.lerpColors(h,c,d);let u=Re.lerp(h.a,c.a,d);l.a=u,t[e]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(h)},end:()=>{l.copy(c)}}}function _o(e,t,i,r,s){if(typeof t[e]=="number")return dr(e,t,i??{},r,s);if(Array.isArray(t[e]))return yx(e,t,i??{},r,s)}function zee(e,t,i,r){var o,l,h,c;let s=[],a=e.cameraType==="OrthographicCamera"?(o=t.orthographic)==null?void 0:o.zoom:(l=t.perspective)==null?void 0:l.zoom,n=e.cameraType==="OrthographicCamera"?(h=i.orthographic)==null?void 0:h.zoom:(c=i.perspective)==null?void 0:c.zoom;if(n!==void 0){let d=a??e.zoom,u=n;d!==u&&s.push({update:p=>{e.zoom=Re.lerp(d,u,p),e.updateProjectionMatrix()},start:()=>{e.zoom=d,e.updateProjectionMatrix()},end:()=>{e.zoom=u,e.updateProjectionMatrix()}})}if(i.targetOffset!==void 0){let d=dr("targetOffset",e,t,i,r);d&&s.push(d)}return s}function Bee(e,t,i,r){if(i.scaleBaked===void 0)return;let s=(t.scaleBaked??e.data.geometry.scaleBaked).map(o=>typeof o=="string"?Number(r.getVariable(o)??0):o),a=i.scaleBaked.map(o=>typeof o=="string"?Number(r.getVariable(o)??0):o);if(il.isEqual(s,a))return;let n=[];return n.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[Re.lerp(s[0],a[0],o),Re.lerp(s[1],a[1],o),Re.lerp(s[2],a[2],o)]},r),e.invalidateDownstreamBooleanData(),e.refreshAttachedClonersInteractions()},start:()=>{e.updateGeometryInteractions({scaleBaked:s},r),e.invalidateDownstreamBooleanData(),e.refreshAttachedClonersInteractions()},end:()=>{e.updateGeometryInteractions({scaleBaked:a},r),e.invalidateDownstreamBooleanData(),e.refreshAttachedClonersInteractions()}}),n}function Fee(e,t,i,r){if(!i.extrusion)return;let s=e.extrusion,a=t.extrusion??{},n=i.extrusion,o=[];return yC.forEach(l=>{let h=_o(l,s,a,n,r);h&&o.push(h)}),o}function Uee(e,t,i,r){let s=[];if(!("geometry"in i))return s;let a=e.geometry.userData.parameters,n="geometry"in t?t.geometry:{},o=i.geometry;if(e instanceof Id){let l=Bee(e,n,o,r);l&&s.push(...l)}else{let l={};if(Object.assign(l,Sa(a,vg),Sa(n,vg)),vg.forEach(h=>{let c=_o(h,l,n,o,r);c&&s.push(c)}),e instanceof ix){Object.assign(l,{extrusion:{...a.extrusion}});let h=Fee(l,n,o,r);h&&s.push(...h)}s.length&&s.push({update:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded(),e.refreshAttachedClonersInteractions()},start:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded(),e.refreshAttachedClonersInteractions()},end:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded(),e.refreshAttachedClonersInteractions()}})}return s}function Nee(e,t,i,r){let s=[];if(i.intensity!==void 0){let a=dr("intensity",e,t,i,r);a&&s.push(a)}if(i.color!==void 0){let a=Lee("color",e,t,i,r);a&&s.push(a)}return s}function kee(e,t,i,r){let s=[];if(Array.isArray(e.material)){if(!("materials"in i&&i.materials))return s;let a="materials"in t&&t.materials?t.materials:[],n=i.materials;e.material.forEach((o,l)=>{if(!n[l])return;let h=a[l]??{},c=n[l];typeof h=="string"||typeof c=="string"||s.push(...JA(o,h,c,r))})}else{if(!("material"in i&&i.material))return s;let a="material"in t&&t.material?t.material:{},n=i.material;if(typeof a=="string"||typeof n=="string")return s;s.push(...JA(e.material,a,n,r))}return s}function JA(e,t,i,r){var n;let s=[],a=ph(i,r)||!!t.layers&&ph(t,r);s.push(Qee(e,a));for(let o of e.layers){let l=(n=t.layers)==null?void 0:n.data(o.uuid),h=i.layers.data(o.uuid);if(!h||o.type!=="light"&&(!(o.visible??!0)||!(h.visible??!0)))continue;let c=o.getNames().filter(d=>!mC.some(u=>d.includes(u)));for(let d of c)try{let u=o.getValue(d),p;if(d==="colors")p=Xee(o,l,h,d);else if(Array.isArray(u))d==="steps"&&(p=qee(o,l,h,d));else if(typeof u=="number")p=Vee(o,l,h,d,r);else{if(typeof u=="boolean")continue;u instanceof j?p=jee(o,l,h,d):u instanceof M?p=Gee(o,l,h,d,r):u instanceof vr?p=Wee(o,l,h,d,r):u instanceof et?p=Hee(o,l,h,d,r):"isTexture"in u&&(p=Yee(o,l,h,d))}p&&(Array.isArray(p)?s.push(...p):s.push(p))}catch(u){console.error(`lerpMaterial: unexpected material layer for ${d}`,u)}}return s}function Vee(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:e.getValue(r),n=i[r],o=typeof a=="string"?Number(s.getVariable(a)??0):a,l=typeof n=="string"?Number(s.getVariable(n)??0):n;if(o!==l)return{update:h=>{e.setValue(r,Re.lerp(o,l,h))},start:()=>{e.setValue(r,o)},end:()=>{e.setValue(r,l)}}}function jee(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),a=t?new j().fromArray(t[r]):s.clone(),n=new j().fromArray(i[r]);if(!a.equals(n))return{update:o=>{s.lerpVectors(a,n,o)},start:()=>{s.copy(a)},end:()=>{s.copy(n)}}}function Gee(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=e.getValue(r),n=t?t[r]:void 0,o=i[r],l=n?Vf(new M,n,s):a.clone(),h=Vf(new M,o,s);if(!l.equals(h))return{update:c=>{a.lerpVectors(l,h,c)},start:()=>{a.copy(l)},end:()=>{a.copy(h)}}}function Hee(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=a?typeof a=="string"?s.getColor(a).clone():new et().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new et().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let c=o.clone();return{update:d=>{e.getValue(r)!==c&&e.setValue(r,c),c.lerpColors(l,h,d)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function Wee(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=a?typeof a=="string"?s.getColor(a).clone():new et().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new vr(n.r,n.g,n.b,n.a);if(l.equals(h))return;let c=o.clone();return{update:d=>{e.getValue(r)!==c&&e.setValue(r,c),c.lerpColors(l,h,d)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function qee(e,t,i,r="steps"){if(!e.hasValue(r)||!(r in i))return;let s=[],a=e.getValue(r),n=t?t[r]:a,o=i[r];return y1(n,o)||s.push({update:l=>{let h=[...a];for(let c=0;c<a.length;++c){let d=n[c],u=o[c];h[c]=Re.lerp(d,u,l)}e.setValue(r,h)},start:()=>{e.setValue(r,n)},end:()=>{e.setValue(r,o)}}),s.length?s:void 0}function Xee(e,t,i,r="colors"){if(!e.hasValue(r)||!(r in i))return;let s=[],a=e.getValue(r),n=t?t[r]:a.map(l=>l.toArray()),o=i[r];for(let l=0;l<a.length;++l){let h=[...n[l]],c=[...o[l]];uf.isEqual(h,c)||s.push({update:d=>{a[l].fromArray(uf.lerp(h,c,d))},start:()=>{a[l].fromArray(h)},end:()=>{a[l].fromArray(c)}})}return s.length?s:void 0}function Yee(e,t,i,r="texture"){var m,v;if(!e.hasValue(r)||!(r in i))return;let s=e.getNode("rotation"),a=((m=t==null?void 0:t[r])==null?void 0:m.rotation)??0,n=((v=i[r])==null?void 0:v.rotation)??0;if(s&&a!==n)return{update:y=>{s.value=Re.lerp(a,n,y)*Re.DEG2RAD},start:()=>{s.value=a*Re.DEG2RAD},end:()=>{s.value=n*Re.DEG2RAD}};let o=e.getNode("mat");if(!o)return;let l=t?t[r]:o,h=i[r],c=[...l.repeat],d=[...l.offset],u=[...h.repeat],p=[...h.offset],f=l.rotation??0,g=h.rotation??0;if(!cn.isEqual(c,u)||!cn.isEqual(d,p)||f!==g)return{update:y=>{o.repeat=cn.lerp(c,u,y),o.offset=cn.lerp(d,p,y),o.rotation=Re.lerp(f,g,y),o.updateMatrix()},start:()=>{o.repeat=[...c],o.offset=[...d],o.rotation=f,o.updateMatrix()},end:()=>{o.repeat=[...u],o.offset=[...p],o.rotation=g,o.updateMatrix()}}}function Qee(e,t){return{update:()=>{e.transparent=t}}}var uv=new M,$A=new ji;function Zee(e,t,i,r,s){var f,g,m,v,y,x;let a=[],n,o,l,h,c,d,u,p;if(e instanceof ar?(n=jf("position",e,t,i,s),n&&a.push(n),l=dr("rotation",e,t,i,s),l&&a.push(l),h=jf("shear",e,t,i,s),h&&a.push(h)):(p={slide:((f=t.pathSnapping)==null?void 0:f.slide)??((g=e.updatedPathSnapping)==null?void 0:g.slide)??((m=e.dataPatched.pathSnapping)==null?void 0:m.slide)??0,offset:((v=t.pathSnapping)==null?void 0:v.offset)??((y=e.updatedPathSnapping)==null?void 0:y.offset)??((x=e.dataPatched.pathSnapping)==null?void 0:x.offset)??0},d=dr("slide",p,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,s),d&&a.push(d),u=dr("offset",p,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,s),u&&a.push(u),!d&&!u&&(n=ZA("position",e,t,i,s),n&&a.push(n),o=ZA("scale",e,t,i,s),o&&a.push(o),l=Kee(e,t,i,r,s),l&&a.push(l),c=Ree("hiddenMatrix",e,t,i),c&&a.push(c))),n||o||l||c||d||u){let w=e instanceof ar?()=>{e.updateWorldMatrix(!0,!1,!0),e.resetBBoxNeedsUpdate()}:()=>{var _;e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),(_=e.parent)!=null&&_.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),Ns(e)&&un(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,p))};a.push({update:w,start:w,end:w})}return a}function Kee(e,t,i,r,s){var c;let a=t!=null&&t.rotation?t.rotation.map(d=>(typeof d=="string"?Number(s.getVariable(d)??0):d)*Re.DEG2RAD):void 0,n=(c=i.rotation)==null?void 0:c.map(d=>(typeof d=="string"?Number(s.getVariable(d)??0):d)*Re.DEG2RAD);if(!n)return;let o=a?new M().fromArray(a):new M().setFromEuler(e.rotation),l=new M().fromArray(n);if(o.equals(l))return;let h=uv.subVectors(l,o);if(r&&h.toArray().every(d=>Math.abs(d)<2*Math.PI)){let d=new lt().setFromEuler($A.setFromVector3(o)),u=new lt().setFromEuler($A.setFromVector3(l));return{update:p=>{Oee(d,u,e.quaternion,p)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}else return{update:d=>{uv.lerpVectors(o,l,d),e.rotation.setFromVector3(uv)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}function Jee(e,t,i,r){let s=[];if(!("cloner"in i)||!e.cloner)return s;let a=e.cloner,n="cloner"in t?t.cloner:{},o=i.cloner;hC.forEach(p=>{let f;p==="count"?f=dr("count",a.parameters,n,o,r,!0):f=_o(p,a.parameters,n??{},o,r),f&&s.push(f)});let l=$ee(a,n,o,r);l!=null&&l.length&&s.push(...l);let h=ete(a,n,o,r);h!=null&&h.length&&s.push(...h);let c=tte(a,n,o,r);c!=null&&c.length&&s.push(...c);let d=ite(a,n,o,r);d!=null&&d.length&&s.push(...d);let u=rte(a,n,o,r);return u!=null&&u.length&&s.push(...u),s.length&&s.push({update:()=>{a.update()}}),s}function $ee(e,t,i,r){if(e.parameters.type!=="radial")return;let s=t.radial,a=i.radial;if(!a)return;let n=e.parameters.radial,o=[];return cC.forEach(l=>{let h=_o(l,n,s??{},a,r);h&&o.push(h)}),o}function ete(e,t,i,r){if(e.parameters.type!=="linear")return;let s=t.linear,a=i.linear;if(!a)return;let n=[],o=e.parameters.linear;return dC.forEach(l=>{let h=_o(l,o,s??{},a,r);h&&n.push(h)}),n}function tte(e,t,i,r){if(e.parameters.type!=="grid")return;let s=t.grid,a=i.grid;if(!a)return;let n=[],o=e.parameters.grid;return uC.forEach(l=>{let h;l==="count"?h=yx(l,o,s??{},a,r,!0):h=_o(l,o,s??{},a,r),h&&n.push(h)}),n}function ite(e,t,i,r){if(e.parameters.type!=="toObject")return;let s=t.toObject,a=i.toObject;if(!a)return;let n=[],o=e.parameters.toObject;return pC.forEach(l=>{let h;l==="count"?h=dr(l,o,s??{},a,r,!0):h=_o(l,o,s??{},a,r),h&&n.push(h)}),n}function rte(e,t,i,r){if(!e.parameters.randomness)return;let s=t.randomnessObject,a=i.randomnessObject;if(!a)return;let n=[],o=e.parameters.randomnessObject;return fC.forEach(l=>{let h=_o(l,o,s??{},a,r);h&&n.push(h)}),n}function ste(e,t){return{update:()=>{e instanceof er&&(e.fill.enabled=t)}}}function ate(e,t){return{update:()=>{e instanceof er&&(e.stroke.enabled=t)}}}function nte(e,t){return{update:()=>{e instanceof er&&(e.dropShadow.enabled=t)}}}function ote(e,t){return{update:()=>{e instanceof er&&(e.innerShadow.enabled=t)}}}function lte(e,t){return{update:()=>{e instanceof er&&(e.backgroundBlur.enabled=t)}}}function hte(e,t){return{update:()=>{e instanceof er&&(e.layerBlur.enabled=t)}}}function cte(e,t,i,r,s){let a=[],n,o,l,h,c,d,u,p,f,g,m,v,y,x,w;if("width"in e&&(n=dr("width",e,t,i,s),n&&a.push(n)),"height"in e&&(o=dr("height",e,t,i,s),o&&a.push(o)),e instanceof er||e instanceof Ma){let _={...t.fill},b={...i.fill};_.enabled!==void 0&&_.enabled!==b.enabled&&(a.push(ste(e,!0)),_.enabled||Object.assign(_,{enabled:!0,color:{..._.color,a:0}}),b.enabled||Object.assign(b,{enabled:!0,color:{...b.color,a:0}})),l=gp("color",e.fill,_,b,s),l&&a.push(l)}if(e instanceof er){let _={...t.stroke},b={...i.stroke};(_.enabled||b.enabled)&&(a.push(ate(e,!0)),_.enabled||Object.assign(_,{enabled:!0,color:{..._.color,a:0}}),b.enabled||Object.assign(b,{enabled:!0,color:{...b.color,a:0}})),h=gp("color",e.stroke,_,b,s),h&&a.push(h),c=dr("thickness",e.stroke,_,b,s),c&&a.push(c)}if(e instanceof er){let _={...t.dropShadow},b={...i.dropShadow};(_.enabled||b.enabled)&&(a.push(nte(e,!0)),_.enabled||Object.assign(_,{enabled:!0,color:{..._.color,a:0}}),b.enabled||Object.assign(b,{enabled:!0,color:{...b.color,a:0}})),d=gp("color",e.dropShadow,_,b,s),d&&a.push(d),u=dr("blurRadius",e.dropShadow,_,b,s),u&&a.push(u),f=dr("spread",e.dropShadow,_,b,s),f&&a.push(f),p=jf("offset",e.dropShadow,_,b,s),p&&a.push(p)}if(e instanceof er){let _={...t.innerShadow},b={...i.innerShadow};(_.enabled||b.enabled)&&(a.push(ote(e,!0)),_.enabled||Object.assign(_,{enabled:!0,color:{..._.color,a:0}}),b.enabled||Object.assign(b,{enabled:!0,color:{...b.color,a:0}})),g=gp("color",e.innerShadow,_,b,s),g&&a.push(g),m=dr("blurRadius",e.innerShadow,_,b,s),m&&a.push(m),y=dr("spread",e.innerShadow,_,b,s),y&&a.push(y),v=jf("offset",e.innerShadow,_,b,s),v&&a.push(v)}if(e instanceof er||e instanceof Ma){let _={...t.backgroundBlur},b={...i.backgroundBlur};(_.enabled||b.enabled)&&(a.push(lte(e,!0)),_.enabled||Object.assign(_,{enabled:!0,radius:0}),b.enabled||Object.assign(b,{enabled:!0,radius:0})),x=dr("radius",e.backgroundBlur,_,b,s),x&&a.push(x)}if(e instanceof er){let _={...t.layerBlur},b={...i.layerBlur};(_.enabled||b.enabled)&&(a.push(hte(e,!0)),_.enabled||Object.assign(_,{enabled:!0,radius:0}),b.enabled||Object.assign(b,{enabled:!0,radius:0})),w=dr("radius",e.layerBlur,_,b,s),w&&a.push(w)}if(e instanceof Ma||e instanceof Xd){let _=yx("cornerRadius",e,t,i,s);_&&a.push(_)}return a}function e2(e,t,i,r,s){let a=[];return e.data.visible&&a.push(...Zee(e,t,i,s,r)),e instanceof ar?a.push(...cte(e,t,i,s,r)):(e.data.visible&&a.push(...Jee(e,t,i,r)),Ns(e)?(e instanceof Ii&&e.data.visible&&a.push(...Uee(e,t,i,r)),e.data.visible&&a.push(...kee(e,t,i,r))):ZQ(e)?e.data.visible&&a.push(...Nee(e,t,i,r)):QQ(e)&&a.push(...zee(e,t,i,r))),a.length?{update:n=>{a.forEach(o=>o.update(n))},start:n=>{a.forEach(o=>{var l;return(l=o.start)==null?void 0:l.call(o,n)})},end:n=>{a.forEach(o=>{var l;return(l=o.end)==null?void 0:l.call(o,n)})}}:void 0}var t2=new M;function xx(e,t,i=!1){var a;let r=[],s=n=>{let o=n.data;delete n.states,n.currentState=null,n.reversibleToState=null,n.currentTransitionEvent=null;for(let l of o.states){let h={...l.data};n.states||(n.states={}),n.states[l.id]=Yo.patch(o,h)}r2(e.scene,n,null,t,o.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0),i2(e)};e.scene.traverse2D(s),e.traverseChildren(n=>{var c,d,u,p,f,g;if(i&&((c=n.rigidBody)==null||c.setTranslation(n.position0,!0),(d=n.rigidBody)==null||d.setRotation(n.rotation0,!0),(u=n.rigidBody)==null||u.setLinvel(t2,!0),(p=n.rigidBody)==null||p.setAngvel(t2,!0)),!Tt.is(n))return;let o=n.uuid,l=n.data;if(delete n.states,n.uuid===ic)return;let h=!1;r.some(m=>{var v;return(v=e.scene.find(o))==null?void 0:v.isDescendantOf(m)})?h=!0:((f=l.physics)==null?void 0:f.fusedBody)===!0&&l.physics.rigidBody==="dynamic"&&r.push(o),n.data=l,n.currentState=null,n.reversibleToState=null,n.currentTransitionEvent=null;for(let m of l.states){let v={...m.data};e.data.globalPhysics.usePhysics===!0&&l.physics&&(l.physics.rigidBody==="dynamic"||h)&&(m.data.position!==void 0&&delete v.position,m.data.rotation!==void 0&&delete v.rotation,m.data.hiddenMatrix!==void 0&&delete v.hiddenMatrix),n.states||(n.states={}),n.states[m.id]=Wo.patch(l,v)}r2(e.scene,n,null,t,l.events.find(m=>m.data.type==="Follow"||m.data.type==="LookAt")!==void 0),n instanceof Sr&&n.frame&&(n.frame.traverse(m=>s(m)),(g=n.uiCanvas)==null||g.applySize())}),i2(e),e.frame&&(e.frame.traverse(n=>s(n)),(a=e.uiCanvas)==null||a.applySize())}function i2(e){e.traverseEntity(t=>{for(let i of t.data.events){let r=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...i.data.actions);break;case"GameControl":for(let s of Object.values(i.data.gameActions))r.push(...s);break;case"DragDrop":r.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":r.push(...i.data.inActions,...i.data.outActions);break}for(let s of r)if(s.data.type==="Create"&&s.data.hideBase==="Yes"){let a=e.scene.find(s.data.object);a&&(a.visible=!1)}}})}function r2(e,t,i,r,s=!1){if(t instanceof Ii&&!(t instanceof pl)&&t.removeInteractionGeometry(r),t instanceof ar?t.changeSelectedState(i,{shared:r},s):t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof Ii&&t.updateGeometryGroupsIfNeeded(),t instanceof Mr&&t.updateCameraState(t.dataPatched,{scene:e,shared:r}),!(t instanceof ar)){if(t.cloner)for(let a of t.cloner.children)a.playModeVisible=void 0;t.updateVisible()}}function kP(e){let t;if(e.easing===5){let{control1:i,control2:r}=e;t=`cubicBezier(
  7310. ${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
  7311. )`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:a}=e;t=`spring( ${i}, ${r}, ${s}, ${a} )`}else{let i;switch(e.easing){case 0:i=Vn.linear;break;case 1:i=Vn.ease;break;case 2:i=Vn.easeIn;break;case 3:i=Vn.easeOut;break;case 4:i=Vn.easeInOut;break;default:i=Vn.linear}let[r,s,a,n]=i;t=`cubicBezier( ${r}, ${s}, ${a}, ${n} )`}return{duration:Math.max(e.duration,1e-4),easing:t}}function Py(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var dte={type:"beginState"},ute={type:"completeState",isfromEntity:!1},Dy=class{constructor(e,t,i,r,s,a){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=a,this.targets={t:0},this.firstLoop=!0,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.requestRender()),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let n=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=n,this.object.dispatchEvent({type:"beginState",state:n}),this.object instanceof ar||this.object.traverseEntity(o=>{o!==this.object&&o instanceof Mr&&o.dispatchEvent(dte)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let n=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=n,this.object.dispatchEvent({type:"completeState",state:n}),this.object instanceof ar||this.object.traverseEntity(o=>{o!==this.object&&o instanceof Mr&&o.dispatchEvent(ute)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=e2(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let n=Bp(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!n)throw new Error("Missing property");this.from=n}else{let n=Bp(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(i===void 0)throw new Error("Missing property");{let n=Bp(this.object,i);if(!n)throw new Error("Missing property");this.to=n}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...Py(r),...kP(r),change:this.onChange},this.callback=e2(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},VP=class extends yr{constructor(e,t,i,r,s){var n;if(super(),this.eventType=e,this.data=t,this.page=i,this.shared=r,this.condition=s,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.hasPlayedOnce=!1,this.onTimelineChangeComplete=()=>{var o;this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&((o=this.timeline)==null||o.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!t.object)throw new Error("Missing property");let a=this.page.scene.find(t.object)??((n=this.page.uiCanvas)==null?void 0:n.find(t.object))??this.page.scene.find2DInUIObjects(t.object);if(!a)throw new Error("Missing property");if(!a.states)throw new Error("Missing property");if(this.object=a,t.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=t.tweens[0].data.delayDirection==="start-once"?t.tweens[0].data.delay:0,this.init()}get playing(){var e;return((e=this.timeline)==null?void 0:e.paused)===!1}get changeBegan(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=Bp(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.data.runMode==="Toggle"&&t_(this.eventType)?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){var r,s,a,n;try{let o=Py(this.data.tweens[0].data);i&&typeof o.loop=="number"&&o.loop--,(r=this.timeline)==null||r.pause(),this.timeline=od.timeline({autoplay:!1,...o,...o.loop===!0||o.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let l=this.tweens.findIndex(h=>h==null?void 0:h.changeBegan);if(t===!0&&(this.timelineNeedsRebuild=!0),e){let h=l===-1?0:l;for(let c=h;c<this.data.tweens.length-1;c++){let d=this.data.tweens[c],u=this.data.tweens[c+1],p;c===h&&(this.object.wasMovedByUser===!0||((s=this.object.previousAction)==null?void 0:s.changeBegan)===!0)?(p=void 0,this.object instanceof Mr&&(this.object.wasMovedByUser=!1)):p=d.data.state===void 0?this.currentState:d.data.state;let f=new Dy(this.object,p,u.data.state===void 0?this.currentState:u.data.state,u.data,this.shared,this.data.allowSlerp??!1);l!==-1&&c===h&&Object.assign(f.params,{startOnceDelay:0}),this.tweens[c]=f,this.timeline.add(f.params,this.timeline.duration+(c===h?o.delay:0))}this.timeline.duration+=o.endDelay}else{let h=l===-1?this.data.tweens.length-1:l+1;for(let c=h;c>0;c--){let d=this.data.tweens[c],u=this.data.tweens[c-1],p;c===h&&(this.object.wasMovedByUser===!0||((a=this.object.previousAction)==null?void 0:a.changeBegan)===!0)?(p=void 0,this.object instanceof Mr&&(this.object.wasMovedByUser=!1)):p=d.data.state===void 0?this.currentState:d.data.state;let f=new Dy(this.object,p,u.data.state===void 0?this.currentState:u.data.state,d.data,this.shared,this.data.allowSlerp??!1);l!==-1&&c===h&&Object.assign(f.params,{startOnceDelay:0}),this.tweens[c-1]=f,this.timeline.add(f.params,this.timeline.duration+(c===h?o.endDelay:0))}this.timeline.duration+=o.delay}}catch(o){o instanceof Error&&console.error(o.message)}((n=this.object.previousAction)==null?void 0:n.playing)===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(ri(this.shared,this.condition)===!1||t_(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||(this.hasPlayedOnce=!0,this.playing))return!1;clearTimeout(this.timeoutId);let e=Py(this.data.tweens[0].data).pingPongDelayCorrection;od({targets:{},duration:this.startOnceDelay+e,easing:"linear",complete:()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}}})}pause(){var e;(e=this.timeline)==null||e.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object instanceof ar?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){var t;if(ri(this.shared,this.condition)===!1)return!1;this.timeline===void 0&&this.buildTimeline(),(t=this.timeline)==null||t.seek(e*this.timeline.duration,!0)}toggle(e){var t;if(ri(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?((t=this.timeline)==null||t.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):od({targets:{},duration:this.startOnceDelay,easing:"linear",complete:()=>{var i;(i=this.timeline)==null||i.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()}})}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function Bp(e,t){var s;let i,r;if(typeof t=="string"?(i=t,r=(s=e.states)==null?void 0:s[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var pte={type:"beginState"},s2={type:"completeState",isfromEntity:!1},a2={type:"requestRender"},jP=class extends yr{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.posStart=new M,this.posEnd=new M,this.qStart=new lt,this.qEnd=new lt,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=od({targets:i,t:1,...kP(this.data),update:()=>{i.t===0&&(this.data.runMode==="Toggle"&&!this.toggleIsForward?this.fromCamera&&(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(pte));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(a2),i.t===1&&r.dispatchEvent(s2)}})}switchCamera(e){let t=this.page.activeCamera,i=this.page.scene.find(e);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),t.dispatchEvent({type:"cameraChange",camera:i})}play(){if(ri(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{var e;delete this.timeoutId,this.data.animate?(this.buildAnimation(),(e=this.animation)==null||e.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){var e;(e=this.animation)==null||e.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){var t,i;if(ri(this.shared,this.condition)===!1)return!1;if(window.clearTimeout(this.timeoutId),delete this.timeoutId,e!==this.toggleIsForward)try{this.playing?((t=this.animation)==null||t.pause(),this.toggleIsForward=e??!this.toggleIsForward,this.buildAnimation(!0),(i=this.animation)==null||i.play()):this.timeoutId=window.setTimeout(()=>{var r,s;this.toggleIsForward=e??!this.toggleIsForward,this.data.animate?((r=this.animation)==null||r.pause(),this.buildAnimation(),(s=this.animation)==null||s.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.fromCamera&&this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(s2),this.page.activeCamera.dispatchEvent(a2))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};function GP(e){let t=e==null?void 0:e.tracks.filter(i=>i.ValueTypeName==="vector"||i.ValueTypeName==="quaternion").map(i=>i.times.length);if(t!=null&&t.length){let i=BW(t);return i&&i>2?i:2}return 2}var HP=class extends yr{constructor(e,t,i,r,s){var l,h,c;super(),this.data=e,this.page=t,this.animationControls=i,this.shared=r,this.condition=s,this.startOnceDelay=0,this.toggleIsForward=!1;let a=e.object,n=t.scene.find(e.object);n&&Array.isArray(n.identity)&&(a=n.identity[0]),this.data={...e,object:a};let o=this.animationControls.clipIdToAction[e.clipId+"/"+a];if(this.duration=((l=o==null?void 0:o.getClip())==null?void 0:l.duration)??1,this.data.crop2){let d=GP(o==null?void 0:o.getClip());this.leftFrameTime=this.data.crop2[0]/(d-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(d-1)*this.duration}else{let d=(c=(h=o==null?void 0:o.getClip())==null?void 0:h.tracks[0])==null?void 0:c.times.length;d&&d>1?(this.leftFrameTime=this.data.crop[0]/d*this.duration,this.rightFrameTime=this.data.crop[1]/d*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=e.delay}get playing(){var e;return((e=this.threeAnimAction)==null?void 0:e.isRunning())??!1}play(e=!1){if(ri(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{var i;if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let a=r.split("/")[1];this.threeAnimAction!==s&&a===t&&s.isRunning()&&(e?s.fadeOut(.2):s.stop())}),e&&((i=this.threeAnimAction)==null||i.fadeIn(.2))},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){var e;(e=this.threeAnimAction)==null||e.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Re.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){if(ri(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{var i;if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let r=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,a])=>{let n=s.split("/")[1];this.threeAnimAction!==a&&n===r&&a.isRunning()&&(t?a.fadeOut(.2):a.stop())}),t&&((i=this.threeAnimAction)==null||i.fadeIn(.2))}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){var t;let e=(t=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object])==null?void 0:t.getClip();e&&(e.duration=this.duration),this.pause()}},WP=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.condition=s,this.timeOutId=-1,this.scene=t.scene}dispatch(){if(ri(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target||t.data.uiScene))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(t=>{t.type==="ParticleSystem"&&(t.sleep(),t.wakeUp(),t.data.autoPlay?t.start():t.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),xx(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},qP=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=ri(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=YC(this.data.expression,this.shared,mr.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},XP=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(ri(this.shared,this.condition)===!1)return!1;let e=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,e==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&e!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&e!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&e!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let t=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);e==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,t===void 0?!1:!t):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!t),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let e=this.data.delay,t=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&t==="Playing"&&(e=this.data.pauseDelay),e!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},e)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}},fte=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r}dispatch(){if(ri(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(e=>{var i;this.shared.getVariable(e);let t=(i=this.shared.data.variables.data(e))==null?void 0:i.value;t!==void 0&&this.shared.updateVariable(e,t),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(ly(e))})}dispose(){}},mte=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r}dispatch(){var e;if(ri(this.shared,this.condition)===!1)return!1;this.data.userAPIId&&((e=this.shared.getUserAPI(this.data.userAPIId))==null||e.callUserAPI(this.shared))}dispose(){}};function ri(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=YC(t.expression,e,"boolean");return t.negate?!i:!!i}function Li(e,t,i,r,s,a){let n={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},o=l=>({id:h,data:c})=>{try{c.type==="Audio"?br[e.type].includes("Audio")&&n.Audio.push(new bP(h,c,a,r,l)):c.type==="Video"&&!(a instanceof ar)?br[e.type].includes("Video")&&n.Video.push(new QP(h,c,a,r,l)):c.type==="Particles"?br[e.type].includes("Particles")&&n.Particles.push(new wP(c,i,r,l)):c.type==="Link"?br[e.type].includes("Link")&&n.Link.push(new iee(c,s.controlsManager,r,l)):c.type==="Create"?br[e.type].includes("Create")&&n.Create.push(new ZP(c,i,s.controlsManager,r,l)):c.type==="Destroy"?br[e.type].includes("Destroy")&&n.Destroy.push(new _P(c,i,s.controlsManager,r,l)):c.type==="Reset"?br[e.type].includes("Reset")&&n.Reset.push(new SP(c,i,r,s,l)):c.type==="Transition"?br[e.type].includes("Transition")&&n.Transition.push(new VP(e.type,c,i,r,l)):c.type==="SwitchCamera"?br[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new jP(c,i,r,l)):c.type==="SceneTransition"?br[e.type].includes("SceneTransition")&&n.SceneTransition.push(new WP(c,i,s,r,l)):c.type==="Animation"?br[e.type].includes("Animation")&&n.Animation.push(new HP(c,i,s.animationControls,r,l)):c.type==="SetVariable"?br[e.type].includes("SetVariable")&&n.SetVariable.push(new qP(c,i,r,l)):c.type==="DynamicVariablePlay"?br[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new XP(c,i,r,l)):c.type==="Conditional"?br[e.type].includes("Conditional")&&(c.ifActions.forEach(o({expression:c.condition,negate:!1})),c.elseActions.forEach(o({expression:c.condition,negate:!0}))):c.type==="ClearLocalStorage"?br[e.type].includes("ClearLocalStorage")&&n.ClearLocalStorage.push(new fte(c,i,r,l)):c.type==="UserAPI"&&br[e.type].includes("UserAPI")&&n.UserAPI.push(new mte(c,i,r,l))}catch{}};return t.forEach(o()),n}function sr(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof bP||i instanceof QP||i instanceof wP||i instanceof HP||i instanceof VP||i instanceof ZP||i instanceof _P||i instanceof jP||i instanceof WP||i instanceof SP||i instanceof qP||i instanceof XP)&&i.dispose()})})}function gte(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(s=>s.uuid===t):i=e.material.layers.find(s=>s.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var YP=new Map,ld=new Map,io=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:a,delay:n}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=gte(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,ec&&(this.videoElement.autoplay=!0),a!==void 0&&(this.videoElement.volume=a)),n!==void 0&&(this.delay=n),ld.has(i.uuid)?ld.get(i.uuid).push(this):ld.set(i.uuid,[this]),YP.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}seek(e){return new Promise((t,i)=>{if(!this.videoElement)return i();let r=this.videoElement.duration;if(r>0){let s=e%r;this.videoElement.currentTime=s}this.videoElement.addEventListener("seeked",()=>t(),{once:!0})})}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Iy=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=YP.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=ld.get(e);!(t!=null&&t.length)||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...ld.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},QP=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new io(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Iy(t);else throw new Error("Missing property")}dispatchBasic(){if(ri(this.shared,this.condition)===!1)return!1;this.interaction instanceof io?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(ri(this.shared,this.condition)===!1)return!1;this.interaction instanceof io?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},n2=(()=>{let e,t,i,r;function s(o){!e&&!o2()&&(t==null?void 0:t.sharedGameControlGlobals.createdObjects.length)>0&&(e=requestAnimationFrame(a)),o&&(t=o,r=o.requestRender)}function a(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,d=h.length,u=0;for(;u<d;){let p=h[u];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&c[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),u++):(c[p.userData.actionId]>p.userData.quantity&&c[p.userData.actionId]--,h.splice(u,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),d--,r())}e=u>0?requestAnimationFrame(a):void 0,i=u>0?o:void 0}function n(){o2()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",n),s})();function o2(){return!!document&&document.hidden}var l2=new lt,vte=new M,yte=new M,ZP=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=s,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=Re.generateUUID(),this.dispatch=()=>{if(ri(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{if(ri(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=e8(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let n=new gr(this.object);if(n.playModeVisible=!0,n.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldSVD(),n.hiddenMatrix.copy(h.matrixWorldRigid))}n.scale.copy(this.object.scale),n.position.fromArray(this.data.position),n.rotation.fromArray(this.data.rotation),n.updateMatrix(),this.page.add(n);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(n),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,n.updateWorldMatrix(!0,!0),n.traverseObject(this.traverseObjectCB),n2(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{var c,d,u,p;n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof bs)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof gr)o=n.object;else if(o=n,(c=o.dataPatched.cloner)==null?void 0:c.hideBase)return!0}else{if(n instanceof bs)return;n instanceof gr?o=n.object:o=n}this.data.destroy==="Time"?n.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(n.userData.quantity=this.data.destroyAfterQuantity,n.userData.actionId=this.uniqueId);let l=new M().fromArray(this.data.velocity),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(n,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&((d=n.rigidBody)==null||d.collider(0).setActiveEvents(1),n.userData.hasCollisionDestroy=!0),n.matrixWorld.decompose(vte,l2,yte),l.applyQuaternion(l2),this.data.velocity.some(f=>f!==0)&&this.data.dynamic&&((u=n.rigidBody)==null||u.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0))):("geometry"in n.object&&this.controlsManager.addBoundsTree(n),this.data.velocity.some(f=>f!==0)&&this.data.dynamic&&(n.userData.velocity=l)),((p=o.dataPatched.physics)==null?void 0:p.fusedBody)===!0))return!0};let a=this.page.scene.find(this.data.object);if(!a)throw new Error("Missing Property");if(this.object=a,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");n2(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},KP=200,pv=.02,fv=.3,xte=65;new M;var h2=new M,c2=new M,bte=new M,Rr=new M,Hr=new M,Fn=new M,mv=new we,d2=new we,wte=new we;new we;var zs=new lt,Ga=new lt,oa=new ji(0,0,0,"YXZ"),_te=new M(1,0,0),Bs=new M(0,1,0),Ste=new M(0,0,1),u2=new M(1,1,1);new $r;var Ate=1,Mte=.025,Ete=16e-6,p2=12,Cte=20,Zi=new _s,ds=new Si,Tte={type:"requestRender"},Pte={type:"updateMatrix"},f2=Math.PI/6,Oy=class extends yr{constructor(e,t,i,r,s,a,n,o,l){var f;super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=a,this.camera=n,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new we,this.target0=new M,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=KP,this.euler0=new ji(0,0,0,"YXZ"),this.position0Cam=new M,this.quat0Cam=new lt,this.scale0Cam=new M,this.hiddenMatrix0Cam=new we,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new _s(new M(0,-40,0),new M(0,40,0)),matrix:new we,position:new M,rotation:new lt},this.euler=new ji(0,0,0,"YXZ"),this.eulerDelta=new M,this.lastPosition=new M,this.lastCameraQuaternion=new lt,this.lastCameraPosition=new M,this.PI_2=Math.PI/2,this.prevMouse=new j,this.velocityTarget=new M,this.velocity=new M,this.directionXZ=new M,this.rotVelocityStick=new M,this.rotVelocityTarget=new M,this.rotVelocity=new M,this.rotDirection=new M,this.nonColliderRotOffset=new we,this.nonColliderPosOffset=new we,this.firstPointerId=-1,this.rot=new M,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new we,this.objectToTarget=new M,this.objectToTarget0=new M,this.objectToCamXZ=new M,this.objectToCamXZ0=new M,this.targetToCamera=new M,this.targetToCamera0=new M,this.cameraPolarAxis0=new M,this.targetPos=new M,this.targetQuat=new lt,this.lerpFactorPos=new M().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new lt,this.objXZQuatInv=new lt,this.objXZRotMat=new we,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new M,this.pushedVelocity=new M,this.groundYRotation=0,this.objectRealQuat=new lt,this.colliderWorldQuat=new lt,this.groundNormal=new M,this.groundTilt=new lt,this.groundTiltInv=new lt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new M,this.quaternion=new lt,this.scale=new M,this.initialAction=!0,this.onPointerDown=g=>{var m;!(g.target===this.domElement||g.target instanceof HTMLElement&&g.target.tagName==="SPLINE-VIEWER"&&((m=g.target.shadowRoot)!=null&&m.contains(this.domElement)))||this.firstPointerId!==-1||(this.firstPointerId=g.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!ss&&!kw&&this.domElement.requestPointerLock(),this.prevMouse.set(g.clientX,g.clientY))},this.onPointerUp=g=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),g.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=g=>{if(g.pointerId!==this.firstPointerId)return;let m=g.clientX-this.prevMouse.x,v=g.clientY-this.prevMouse.y;this.prevMouse.set(g.clientX,g.clientY),g.pointerType==="mouse"&&this.rotBy!=="keys"&&(kw&&f8<15.5&&!ss?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-v*this.mouseOrbitSensitivity):(this.eulerDelta.y=-g.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-g.movementY*this.mouseOrbitSensitivity)),g.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-v*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=g=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Oy.isLocked=!0:Oy.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document!=null&&document.hidden)for(let g in this.movementState)this.movementState[g]=0},this.onKeyDown=g=>{!(g.target instanceof HTMLInputElement)&&(g.code==="ArrowLeft"||g.code==="ArrowUp"||g.code==="ArrowRight"||g.code==="ArrowDown"||g.code==="Space")&&g.preventDefault();for(let m of this.keyAssignments)if(g.key.toUpperCase()===m[1]||g.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=g=>{for(let m of this.keyAssignments)if(g.key.toUpperCase()===m[1]||g.key===m[1]||g.code.slice(3,g.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(g,m)=>{for(let v=2;v<4;v++){let y=g.axes[v];m===0?v===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(g.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,v===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(y)>=.3&&(this.vrEulerYOffset+=y<0?1:-1),this.movementState.rotPosY=y):this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,e===n&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),c=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,c,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy((f=this.camera)==null?void 0:f.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let g=new M(0,0,-1).applyQuaternion(this.camera.quaternion),m=new M().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,y;Math.abs(g.y)<1e-6?(m.y=0,g.y=0,y=m.projectOnVector(g)):m.y/g.y>0?y=g.multiplyScalar(m.y/g.y):y=g.multiplyScalar(m.length()),this.targetToCamera0.copy(y).negate(),v=this.camera.position.clone().add(y),this.objectToTarget0.subVectors(v,this.position);let x=new ji().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-x.x,x.x=0,x.z=0,x.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(x)}if(this.object instanceof Mr&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*Ate,this.speedOrbit=(i.speedRotate??100)*Mte,this.mouseOrbitSensitivity=(i.speedRotate??100)*Ete,this.keyAssignments=i.keyAssignments.map(g=>{let m=[g[0],g[1]];return m[1]==="▲"?m[1]="ArrowUp":m[1]==="◀"?m[1]="ArrowLeft":m[1]==="▼"?m[1]="ArrowDown":m[1]==="▶"?m[1]="ArrowRight":m[1]==="⇧"?m[1]="Shift":m[1]==="↵"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="⌘"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let g;g=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),g!==-1&&(this.keyAssignments[g][1]=""),g=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),g!==-1&&(this.keyAssignments[g][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Bh.defaultData.gravity)*p2,this.usePhysics=this.gloabalPhysics.usePhysics??Bh.defaultData.usePhysics,this.jumpPower=i.jumpPower*Cte,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??_f.defaultDataThirdPerson.orientWith,this.slopeThresh=xte*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*pv/this.pixelsPerMeter,this.stepThresh=i.collider.height*fv/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*pv/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*fv/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*pv/this.pixelsPerMeter,this.stepThresh=i.collider.height*fv/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let d=new M().fromArray(i.collider.position),u=new lt().setFromEuler(new ji().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(d).multiply(this.scale),this.collider.rotation.copy(u),this.collider.matrix.compose(d,u,u2),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let g=new We;g.push({fi:0,data:{...Ji.defaultData("light","phong"),alpha:0},id:"layer1"}),g.push({fi:0,data:{...Ji.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=new H1({layers:g},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new Jt(CC.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new ji().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Mr?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){var e;this.deactivate(),(e=this.navMeshPathDest)!=null&&e.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},wf.list.forEach(i=>{this.actions[i]=Li({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),sr(this.actions.idle),sr(this.actions.move),sr(this.actions.run),sr(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Rr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){var o,l,h,c,d,u,p,f,g;if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let s=r*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let m=Hr.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*p2),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),v=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,m,(o=this.object.rigidBody)==null?void 0:o.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(v){this.onObject=!0,this.groundNormal.set(v.normal2.x,v.normal2.y,v.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),((l=v.collider.parent())==null?void 0:l.bodyType())===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let y=v.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let x of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(x.rigidBody===y&&x.userData.isFollowingObj!==this.object.uuid){(x.hasNonUniformScale?x.matrixWorldRigid:x.matrixWorld).decompose(Rr,Ga,Hr),this.groundVelocity.subVectors(Rr,x.prevT),this.object.getWorldPosition(Hr).add(this.collider.position).sub(Rr),this.groundYRotation=oa.setFromQuaternion(Ga).y-x.prevR.y,Fn.copy(Hr).applyAxisAngle(Bs,this.groundYRotation),this.groundVelocity.add(Fn.sub(Hr)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*s),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let m=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let v=Rr.subVectors(this.path[1],this.position),y=Hr.subVectors(this.path[1],this.path[0]);v.dot(y)<0?this.path.shift():(this.directionXZ.x=y.x,this.directionXZ.z=y.z),m.opacity=m.userData.opacity0}else m.opacity-=.05*m.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**s),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**s),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**s)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=bte.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let m=Hr.copy(n);m.y=0,n.set(0,n.y,m.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let m=Rr;this.camera.getWorldDirection(m);let v=Fn.copy(Bs).multiplyScalar(m.dot(Bs));m.sub(v);let y=Hr.copy(this.directionXZ);y.x*=-1,this.rot.y=m.angleTo(y)*(m.cross(y).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(oa.setFromVector3(this.rot),this.moveMode==="walk"&&(oa.x=0),n.applyEuler(oa),a&&(Ga.setFromUnitVectors(Bs,this.groundNormal),n.applyQuaternion(Ga)),i){let m=oa.set(0,this.vrEulerYOffset*f2,0);i.applyEuler(m),n.x+=i.x,n.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let m=Hr;this.pushedVelocity.set(0,0,0);for(let v of this.sharedGameControlGlobals.entitiesWithTransformAnim){let y=Fn.setFromMatrixPosition(v.matrixWorld).sub(v.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),x=v.rigidBody.collider(0).castCollider(y,this.object.rigidBody.collider(0),Rr.copy(n).divideScalar(this.pixelsPerMeter),r,!1);y.multiplyScalar(this.pixelsPerMeter);let w=Tt.is(v)?v:v.object;if(x!==null&&this.lastHitObj!==w){let _;v instanceof gr&&(_=v);let b=this.sharedGameControlGlobals.entityToCollisionEvents[w.uuid];if(b)for(let A of b)A.data.target==="character"&&(A.dispatch(_),w.dispatchEvent(Ly));this.lastHitObj=w}if(x!==null){this.pushedVelocity.copy(y),m.copy(x.normal1).applyQuaternion(v.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let v=m.dot(n);v<0&&n.addScaledVector(m,-v),n.add(this.pushedVelocity)}else n.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**s):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**s),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Bs,this.euler.y-this.euler0.y);let m=Hr.copy(this.objectToCamXZ).normalize(),v=Fn.copy(n).multiplyScalar(r);v.y=0;let y=v.sub(Rr.copy(m).multiplyScalar(v.dot(m))).cross(m).y;this.euler.y-=Math.atan2(y,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Re.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Re.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Re.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(oa.copy(t),oa.y=0):(oa.copy(this.euler),oa.y=0),this.nonColliderRotOffset.makeRotationFromEuler(oa)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*f2),zs.setFromAxisAngle(_te,this.rot.x),Ga.setFromAxisAngle(Bs,this.rot.y),Ga.multiply(zs),zs.setFromAxisAngle(Ste,this.rot.z),Ga.multiply(zs),this.quaternion.copy(Ga),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let m=Hr.copy(n).multiplyScalar(r/this.pixelsPerMeter),v=null;this.didHit=!1;let y=new M;for(let x=0;x<5;x++){let w=m.length(),_=Fn.copy(m).normalize();if(v=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(y),this.colliderWorldQuat,_,(h=this.object.rigidBody)==null?void 0:h.collider(0).shape,w,!1,24,void 0,void 0,this.object.rigidBody),v!==null){this.didHit=!0;let b=this.sharedGameControlGlobals.colliderToEntity.get(v.collider.handle);if(b!==this.lastHitObj&&x===0){this.lastHitObj=b;let C=this.sharedGameControlGlobals.entityToCollisionEvents[b==null?void 0:b.uuid];if(C){for(let T of C)if(T.data.target==="character"){let D=((c=this.sharedGameControlGlobals.rapierWorld)==null?void 0:c.getCollider(v.collider.handle))._parent,O;if(b.cloner){for(let P of b.cloner.children)if(P.rigidBody===D){O=P;break}}T.dispatch(O),b.dispatchEvent(Ly)}}}let A=h2.set(v.normal2.x,v.normal2.y,v.normal2.z).applyQuaternion(this.colliderWorldQuat),S=c2.copy(_).multiplyScalar(v.toi).dot(A),E=v.toi;if(E===0&&(this.position.y+=this.offset*this.pixelsPerMeter),S>this.offset&&(E=v.toi*(S-this.offset)/S,y.addScaledVector(_,E)),m.copy(_).multiplyScalar(w-E),Math.acos(-A.y)>this.slopeThresh){let C=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(y),T=Fn.copy(v.witness2).applyQuaternion(this.colliderWorldQuat);T.y=0;let D=C.add(T);D.y+=this.stepThresh;let O=this.sharedGameControlGlobals.rapierWorld.castShape(D,this.colliderWorldQuat,m,(d=this.object.rigidBody)==null?void 0:d.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);O!==null&&O.toi===0&&(A.y=0,A.normalize())}m.addScaledVector(A,-m.dot(A))}else{x===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),y.add(m);break}}this.position.addScaledVector(y,this.pixelsPerMeter),(u=this.object.rigidBody)==null||u.setTranslation(Rr.copy(this.position).divideScalar(this.pixelsPerMeter),!0),(p=this.object.rigidBody)==null||p.setRotation(zs.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let m=this.onObject?1:5,v=n.multiplyScalar(r/m);for(let y=0;y<m;y++)this.position.add(v),this.collisionAdjustment(r/m)}else this.position.addScaledVector(n,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let m=this.objectToTarget.add(this.position),v=this.targetToCamera.add(m);mv.lookAt(v,m,Bs).setPosition(v),mv.decompose(this.targetPos,this.targetQuat,Rr),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**s),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**s),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Re.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Re.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(Pte),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*((g=(f=this.navMeshPathDest)==null?void 0:f.material)==null?void 0:g.userData.opacity0))?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(Tte),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=zs.setFromAxisAngle(Bs,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Re.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=Re.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=Re.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Rr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=Ga.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){Bs.angleTo(e)*180/Math.PI<15||Bs.angleTo(e)*180/Math.PI>85?zs.identity():zs.setFromUnitVectors(Bs,e),this.groundTilt.slerp(zs,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){var s;let t=c2.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=mv.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Rr,zs,Hr).compose(Rr,zs,u2);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object))return;ds.makeEmpty(),a.updateMatrixWorldSVD();let n=a.matrixWorldRigid,o=d2.copy(n).invert(),l=wte.copy(d2).multiply(i);Zi.copy(this.collider.segment),Zi.start.applyMatrix4(l),Zi.end.applyMatrix4(l);let h=h2.copy(this.position).applyMatrix4(o);ds.expandByPoint(Zi.start),ds.expandByPoint(Zi.end),ds.min.addScalar(-this.collider.radius),ds.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(c){return c.distanceToPoint(Zi.end)},intersectsBounds:c=>c.intersectsBox(ds),intersectsTriangle:c=>{let d=Rr,u=Hr,p=c.closestPointToSegment(Zi,d,u);if(p<this.collider.radius){let f=this.collider.radius-p,g=u.sub(d).normalize(),m=Fn.copy(h);m.addScaledVector(g,f);let v=m.applyMatrix4(n).sub(this.position);t.add(v),Zi.start.addScaledVector(g,f),Zi.end.addScaledVector(g,f)}}})}),ds.makeEmpty(),Zi.copy(this.collider.segment),Zi.start.applyMatrix4(i),Zi.end.applyMatrix4(i),ds.expandByPoint(Zi.start),ds.expandByPoint(Zi.end),ds.min.addScalar(-this.collider.radius),ds.max.addScalar(this.collider.radius),(s=this.sharedGameControlGlobals.staticMeshBVH)==null||s.shapecast({traverseBoundsOrder(a){return a.distanceToPoint(Zi.end)},intersectsBounds:a=>a.intersectsBox(ds),intersectsTriangle:a=>{let n=Rr,o=Hr,l=a.closestPointToSegment(Zi,n,o);if(l<this.collider.radius){let h=this.collider.radius-l,c=o.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(c),t.addScaledVector(c,h),Zi.start.addScaledVector(c,h),Zi.end.addScaledVector(c,h)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},JP=Oy;JP.isLocked=!1;var Dte=xo(Y2());function $P(e){let t=e.elements,i=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,s=t[8]**2+t[9]**2+t[10]**2,a=t[0]**2+t[4]**2+t[8]**2,n=t[1]**2+t[5]**2+t[9]**2,o=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return i<l||r<l||s<l||a<l||n<l||o<l}function tn(e,t){let i=new Ge;if(t&&$P(t))return i.setAttribute("position",new Ie([],3)),i.setIndex([]),i;if(!e.getAttribute("position"))return i.setAttribute("position",new Ie([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=um(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Ie(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var Ite=new we,Ote=new we,la=[[0,0,0],[0,0,0],[0,0,0]];function eD(e){let t=e.elements;la[0][0]=t[0],la[0][1]=t[4],la[0][2]=t[8],la[1][0]=t[1],la[1][1]=t[5],la[1][2]=t[9],la[2][0]=t[2],la[2][1]=t[6],la[2][2]=t[10];let{u:i,v:r}=(0,Dte.SVD)(la),s=Ite.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),a=Ote.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return s.multiply(a.transpose())}var Rte=class extends VM{constructor(){super(),this.layers.enable(3),this.layers.enable(8),this.layers.enable(9)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new wo({color:65280,linewidth:10}),t=new M(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new M(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new M().addVectors(t,i.multiplyScalar(r)),a=new Ge;return a.setFromPoints([t,s]),new Hp(a,e)}},tD=e=>e instanceof Mh||e instanceof Eh;function Lte(e,t){return e.distance-t.distance}function iD(e,t,i){if(!(!en(t)||!t.visible)){Ns(t)&&t.raycast(e,i);for(let r of t.children)iD(e,r,i)}}function Fp(e,t,i,r=!1){if(!r&&!i.some(a=>Gf(e,a)!==void 0))return[];let s=[];return t.children.forEach(a=>iD(e,a,s)),s.sort(Lte),s}function Ry(e){let t=[];if(e.length){let i=e[0].object;en(i)&&t.push(i);let r=i.parent;for(;r;)tD(r)&&t.push(r),r=r.parent}return t}function rn(e,t,i,r){let s=e.frame;if(s){let a=t[0]*s.width,n=(1-t[1])*s.height;for(let o of i){let l=o===s.uuid?s:s.find(o);if(l!=null&&l.intersects(a,n))return r(l),!0}}return!1}function Gf(e,t){if(Ns(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(tD(t))return rD(e,t)}function rD(e,t){if(!(!en(t)||!t.visible)){if(Ns(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=rD(e,i);if(r)return r}}}function zte(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}function Bte(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width,y:1-(t-(i.top+window.scrollY))/i.height}}var Fte=class{constructor(e,t,i,r,s,a,n,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=a,this.isExport=n,this.frame=o,this.raycaster=new Rte,this._useWindowEvents=!1,this.pointerWorld={x:0,y:0},this.pointerScreen={x:0,y:0},this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(e){this._domRect=e}get domRect(){return this._domRect}updateRaycaster(e){var r;let{pageX:t,pageY:i}=((r=e.touches)==null?void 0:r.length)>0?e.touches[0]:e;this.pointerWorld=zte(t,i,this._domRect),this.pointerScreen=Bte(t,i,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}},Pr=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},bx=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],sD=e=>{var t;return(t=bx.find(([i,r])=>r===e))==null?void 0:t[0]},Yd=e=>{var t;return(t=bx.find(([i])=>i===e))==null?void 0:t[1]},Ute=(e,t)=>{let i=sD(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},Nte=class extends Pr{constructor(){super(...arguments),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=e=>{var r;if(!e.eventName||!e.target||e.eventName==="Scroll")return;let t=(r=this.splineEvents[sD(e.eventName)])==null?void 0:r[e.target.uuid];if(!t)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(t,{deltaY:e.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(t)}}connect(){let{page:e}=this.eventContext;e.traverseEntity(t=>{var i,r;if((i=t.data)!=null&&i.events.length){for(let[s,a]of bx)if(t.data.events.some(n=>n.data.type===a&&!n.data.disabled)){this.objectsPerEvents.has(s)?(r=this.objectsPerEvents.get(s))==null||r.push(t):this.objectsPerEvents.set(s,[t]);let n={id:t.uuid,name:t.name},o=Ute(a,n),l=this.splineEvents[s];l?l[t.uuid]=o:this.splineEvents[s]={[t.uuid]:o}}}}),this.objectsPerEvents.forEach(t=>{t.forEach(i=>{i.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},kte=class{constructor(e,t,i,r,s,a){if(this.id=e,this.data=t,this.object=i,this.entered=!1,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Li(t,t.actions,r,s,a,i)}disconnect(){sr(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing&&t.data.runMode!=="Toggle")||this.actions.Transition.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.SwitchCamera.some(t=>t.playing&&t.data.runMode!=="Toggle")||this.actions.SwitchCamera.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},Vte=class extends Pr{constructor(e,t,i){super(e),this.eventManager=t,this.useForRaycastProperty=i,this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.sceneInterects=null,this.onCanvasRaycast=r=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=Fp(s,a,[],!0);this.sceneInterects=n,n.length&&(this.eventContext.sharedAssets.raycastProperty={x:n[0].point.x,y:n[0].point.y,z:n[0].point.z,objX:n[0].object.matrixWorld.elements[12],objY:n[0].object.matrixWorld.elements[13],objZ:n[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(s=>{(s.data.type==="MouseDown"||s.data.type==="MousePress")&&(this.onCanvasRaycast(r),s.dispatch())})},this.onCanvasMouseUp=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(s=>{s.data.type==="MouseUp"?(this.onCanvasRaycast(r),s.dispatch()):s.data.type==="MousePress"&&s.dispatchRelease()})},this.onMouseDown=r=>{at.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseDown"))},this.onMouseUp=r=>{at.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=r=>{at.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent())},this.onMousePressRelease=r=>{at.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent(!0))},this.onKeyDown=r=>{this.heldKeys[r.key]||(this.handleKeyEvent(r,"KeyDown"),this.handleKeyEventHeld(r,"KeyDown",!0)),this.heldKeys[r.key]=!0},this.onKeyUp=r=>{this.handleKeyEvent(r,"KeyUp"),this.handleKeyEventHeld(r,"KeyUp",!0)},this.onKeyPressDown=r=>{this.heldKeysPress[r.key]?this.handleKeyEventHeld(r,"KeyPress"):(this.handleKeyEvent(r,"KeyPress"),this.handleKeyEventHeld(r,"KeyPress",!0)),this.heldKeysPress[r.key]=!0},this.onKeyPressUp=r=>{this.handleKeyEvent(r,"KeyPress",!0)},this.releaseHeldKey=r=>{delete this.heldKeys[r.key]},this.releaseHeldKeyPress=r=>{delete this.heldKeysPress[r.key]},this._onUserEvent=({eventName:r,target:s,reverse:a})=>{var o,l,h,c;if(!r||!s)return;let n=Yd(r);n&&(n==="MouseDown"||n==="MouseUp"||n==="MousePress"?(s.dispatchEvent({type:"beginEvent",eventName:n}),(l=(o=this.eventsPerObjects[n])==null?void 0:o[s.uuid])==null||l.forEach(d=>{d.dispatchUserEvent(a)})):(n==="KeyDown"||n==="KeyUp"||n==="KeyPress")&&(s.dispatchEvent({type:"beginEvent",eventName:n}),(c=(h=this.eventsPerObjects[n])==null?void 0:h[s.uuid])==null||c.forEach(d=>{d.dispatchUserEvent()})))}}connect(){var s,a,n,o,l,h;let{page:e,sharedAssets:t,domElement:i}=this.eventContext,r=(c,d)=>{var p,f;if(!((p=c.data)!=null&&p.events.length))return;let u=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let g of u){let m=this.eventsPerObjects[g];if(c.data.events.filter(({data:v})=>v.type===g&&v.disabled!==!0).forEach(({id:v,data:y})=>{try{let x=new kte(v,y,c,e,t,this.eventManager);x.actions.Video.length&&(this.hasVideoAction=!0),(y.type==="MouseDown"||y.type==="MouseUp"||y.type==="MousePress")&&(y.mode==="Canvas"||y.mode==="Window")?this.canvasMouseEvents.push(x):(m[c.uuid]?m[c.uuid].some(w=>w.id===x.id)||m[c.uuid].push(x):m[c.uuid]=[x],c instanceof pl&&c.traverseChildren(w=>{var _;if(!w.visible)return!0;w instanceof Ii&&((_=w.data.geometry.shapeBlendNode)==null?void 0:_.operation)!==2&&(m[w.uuid]?m[w.uuid].push(x):m[w.uuid]=[x])}))}catch{}}),((f=m[c.uuid])==null?void 0:f.length)&&(this.objectsPerTypes[g].push(c instanceof ar&&(g==="MouseDown"||g==="MouseUp"||g==="MousePress")?d:c),c instanceof pl)){let v=this.objectsPerTypes[g];c.traverseChildren(y=>{if(!y.visible)return!0;y instanceof Ii&&v.indexOf(y)===-1&&v.push(y)})}}};e.traverseEntity(c=>{var d;(c instanceof Sr||c instanceof $i)&&((d=c.frame)==null||d.traverse(u=>{r(u,c)})),r(c)}),this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),i.addEventListener("pointerdown",this.onCanvasMouseDown),i.addEventListener("pointerup",this.onCanvasMouseUp),((s=this.objectsPerTypes.MouseDown)!=null&&s.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMouseDown)),(a=this.objectsPerTypes.MouseUp)!=null&&a.length&&(this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMouseUp)),(n=this.objectsPerTypes.MousePress)!=null&&n.length&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMousePressRelease)),(o=this.objectsPerTypes.KeyDown)!=null&&o.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),(l=this.objectsPerTypes.KeyUp)!=null&&l.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),(h=this.objectsPerTypes.KeyPress)!=null&&h.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([c,d])=>{d.forEach(u=>{u.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){var o,l,h,c;let{stopRaycast:t,raycaster:i,page:r,pointerScreen:s}=this.eventContext,a=this.objectsPerTypes[e],n=a.filter(d=>!(d instanceof ar));if(!(!a.length&&!this.useForRaycastProperty)&&!(r.uiCanvas&&rn(r,[s.x,s.y],Object.keys(this.eventsPerObjects[e]),d=>{this.handleObjectMouseEventDispatch(d,e)}))){if(t||this.useForRaycastProperty){let d;if(this.sceneInterects===null?d=Fp(i,r,n,this.useForRaycastProperty):(d=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&d.length&&(this.eventContext.sharedAssets.raycastProperty={x:d[0].point.x,y:d[0].point.y,z:d[0].point.z,objX:d[0].object.matrixWorld.elements[12],objY:d[0].object.matrixWorld.elements[13],objZ:d[0].object.matrixWorld.elements[14]}),t){let u=[((l=(o=d[0])==null?void 0:o.uv)==null?void 0:l.x)??0,((c=(h=d[0])==null?void 0:h.uv)==null?void 0:c.y)??0];Ry(d).forEach(p=>{p instanceof Sr&&rn(p,u,Object.keys(this.eventsPerObjects[e]),f=>{this.handleObjectMouseEventDispatch(f,e)}),this.eventsPerObjects[e][p.uuid]&&this.handleObjectMouseEventDispatch(p,e)})}}t||n.forEach(d=>{var p,f;let u=Gf(i,d);u&&(this.handleObjectMouseEventDispatch(d,e),d instanceof Sr&&rn(d,[((p=u==null?void 0:u.uv)==null?void 0:p.x)??0,((f=u==null?void 0:u.uv)==null?void 0:f.y)??0],Object.keys(this.eventsPerObjects[e]),g=>{this.handleObjectMouseEventDispatch(g,e)}))})}}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=i.filter(a=>!(a instanceof ar)),s=[];if(i.length){if(!e){let{stopRaycast:a,raycaster:n,page:o,pointerScreen:l}=this.eventContext,h=!1;if(o.uiCanvas&&(h=rn(o,[l.x,l.y],Object.keys(this.eventsPerObjects[t]),c=>{s.push(c)})),a&&!h){let c=Fp(n,o,r);s=Ry(c),c.forEach(d=>{var u,p;d.object instanceof Sr&&rn(d.object,[((u=d==null?void 0:d.uv)==null?void 0:u.x)??0,((p=d==null?void 0:d.uv)==null?void 0:p.y)??0],Object.keys(this.eventsPerObjects[t]),f=>{s.push(f)})})}else r.forEach(c=>{var u,p;let d=Gf(n,c);d&&(s.push(c),c instanceof Sr&&rn(c,[((u=d==null?void 0:d.uv)==null?void 0:u.x)??0,((p=d==null?void 0:d.uv)==null?void 0:p.y)??0],Object.keys(this.eventsPerObjects[t]),f=>{s.push(f)}))})}this._prevObjects.length&&this._prevObjects.forEach(a=>{s.includes(a)||this.handleObjectMouseEventDispatchRelease(a,t)}),s.length&&s.forEach(a=>{this.handleObjectMouseEventDispatch(a,t)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,t){var i,r;e.dispatchEvent({type:"beginEvent",eventName:t}),(r=(i=this.eventsPerObjects[t])==null?void 0:i[e.uuid])==null||r.forEach(s=>{s.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){var i,r;e.dispatchEvent({type:"beginEvent",eventName:t}),(r=(i=this.eventsPerObjects[t])==null?void 0:i[e.uuid])==null||r.forEach(s=>{s.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:a})=>"key"in a&&a.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(i?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},jte=new M,Gte=new M,aD=class{constructor(e,t,i,r,s){this.actionsIn=Li(e,e.inActions,i,r,s,t),this.actionsOut=Li(e,e.outActions,i,r,s,t)}disconnect(){sr(this.actionsIn),sr(this.actionsOut)}},Hte=class extends aD{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let u of this.objects)if(!u.visible)return;let h=jte.setFromMatrixPosition(this.objects[0].matrixWorld),c=Gte.setFromMatrixPosition(this.objects[1].matrixWorld),d=h.distanceTo(c)<=this.distance?"in":"out";if(this.stage!==d){this.stage=d;let u=d==="in"?this.actionsIn:this.actionsOut;u.Audio.forEach(p=>p.dispatchConditional()),u.Particles.forEach(p=>p.dispatchConditional()),u.Video.forEach(p=>p.dispatchConditional()),u.Link.forEach(p=>p.dispatch()),u.Create.forEach(p=>p.dispatch()),u.Destroy.forEach(p=>p.dispatch()),u.Reset.forEach(p=>p.dispatch()),u.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),u.Transition.forEach(p=>p.play()),u.Animation.forEach(p=>p.play()),u.SwitchCamera.forEach(p=>p.play()),u.SceneTransition.forEach(p=>p.dispatch()),u.SetVariable.forEach(p=>p.checkConditions()),u.SetVariable.forEach(p=>p.dispatch()),u.DynamicVariablePlay.forEach(p=>p.dispatch()),u.ClearLocalStorage.forEach(p=>p.dispatch()),u.UserAPI.forEach(p=>p.dispatch())}};let{distance:n,fromObject:o,toObject:l}=t.condition;this.distance=n;for(let h of[o,l]){if(!h)throw new Error("Missing property");let c=r.find(h);if(!c)throw new Error("Missing property");this.objects.push(c)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},Wte=class extends aD{constructor(e,t,i,r,s,a){var l;super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.onBegin=({target:h,state:c})=>{this.toState!==c&&(this.actionsOut.Audio.forEach(d=>d.dispatchConditional()),this.actionsOut.Particles.forEach(d=>d.dispatchConditional()),this.actionsOut.Video.forEach(d=>d.dispatchConditional()),this.actionsOut.Link.forEach(d=>d.dispatch()),this.actionsOut.Create.forEach(d=>d.dispatch()),this.actionsOut.Destroy.forEach(d=>d.dispatch()),this.actionsOut.Reset.forEach(d=>d.dispatch()),this.actionsIn.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(d=>d.play()),this.actionsOut.Animation.forEach(d=>d.play()),this.actionsIn.SwitchCamera.forEach(d=>d.pause()),this.actionsOut.SwitchCamera.forEach(d=>d.play()),this.actionsOut.SceneTransition.forEach(d=>d.dispatch()),this.actionsOut.SetVariable.forEach(d=>d.checkConditions()),this.actionsOut.SetVariable.forEach(d=>d.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(d=>d.dispatch()),this.actionsOut.ClearLocalStorage.forEach(d=>d.dispatch()),this.actionsOut.UserAPI.forEach(d=>d.dispatch()))},this.onComplete=({target:h,state:c})=>{this.toState===c&&(this.actionsIn.Audio.forEach(d=>d.dispatchConditional()),this.actionsIn.Particles.forEach(d=>d.dispatchConditional()),this.actionsIn.Video.forEach(d=>d.dispatchConditional()),this.actionsIn.Link.forEach(d=>d.dispatch()),this.actionsIn.Create.forEach(d=>d.dispatch()),this.actionsIn.Destroy.forEach(d=>d.dispatch()),this.actionsIn.Reset.forEach(d=>d.dispatch()),this.actionsOut.Transition.forEach(d=>d.pause()),this.actionsOut.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(d=>d.play()),this.actionsIn.Animation.forEach(d=>d.play()),this.actionsOut.SwitchCamera.forEach(d=>d.pause()),this.actionsIn.SwitchCamera.forEach(d=>d.play()),this.actionsIn.SceneTransition.forEach(d=>d.dispatch()),this.actionsIn.SetVariable.forEach(d=>d.checkConditions()),this.actionsIn.SetVariable.forEach(d=>d.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(d=>d.dispatch()),this.actionsOut.ClearLocalStorage.forEach(d=>d.dispatch()),this.actionsOut.UserAPI.forEach(d=>d.dispatch()))};let{condition:n}=t;if(!n.object)throw new Error("Missing property");let o=r.find(n.object)??r.scene.find2D(n.object);if(!o)throw new Error("Missing property");if(this.toObject=o,n.state&&!((l=this.toObject.states)!=null&&l[n.state]))throw new Error("Missing property");this.toState=n.state}connect(){Ho(this.actionsOut).forEach(e=>{var t;(t=this.actionsOut[e])!=null&&t.length&&this.toObject.addEventListener("beginState",this.onBegin)}),Ho(this.actionsIn).forEach(e=>{var t;(t=this.actionsIn[e])!=null&&t.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),Ho(this.actionsOut).forEach(e=>{var t;(t=this.actionsIn[e])!=null&&t.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),Ho(this.actionsIn).forEach(e=>{var t;(t=this.actionsIn[e])!=null&&t.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},qte=class extends Pr{constructor(e,t){super(e),this.eventManager=t,this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1}connect(){super.connect();let{page:e,sharedAssets:t}=this.eventContext;e.traverseEntity(i=>{var r;if((r=i.data)!=null&&r.events.length){for(let{id:s,data:a}of i.data.events)if(!a.disabled&&a.type==="Conditional")try{let n;a.condition.type==="Comparison"||(a.condition.type==="Distance"?n=new Hte(s,a,i,e,t,this.eventManager):a.condition.type==="State"&&(n=new Wte(s,a,i,e,t,this.eventManager))),n&&(this.eventsPerConditions[a.condition.type].push(n),(n.actionsIn.Video.length||n.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}}),Object.values(this.eventsPerConditions).forEach(i=>i.forEach(r=>r.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Ic=new M,Un=new M,Do=new M,m2=new qr,Xte=.01,Ft=new M,Ni=new M,g2=new M,Ko=new lt,gv=new ji,Yte=new we,vv=new Di,Ql=new M,ha=new M,Zl=.2;function yv(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var Qte=function(){let e=new we;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&yv(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?yv(s.position,t.limits):t.reference==="local"&&(Ko.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(Ko),yv(s.position,t.limits),Ko.invert(),s.position.applyQuaternion(Ko),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(Ft,s.quaternion,Ni),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof Vr&&un(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),Zte=class{constructor(e,t,i,r,s,a,n){this.object=e,this.id=t,this.data=i,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Li(i,i.dragDropActions.drag,r,s,a,this.object),this.actionsDrop=Li(i,i.dragDropActions.drop,r,s,a,this.object);let o=[];this.data.objects.forEach(l=>{let h=r.find(l);!h||h.data.visible!==!1&&(o.push(h),n[h.uuid]&&n[h.uuid].forEach(c=>{let d=r.find(c);!d||d.data.visible!==!1&&o.push(d)}))}),this.data.dropDestinations.forEach(l=>{let h=r.find(l);!h||h.data.visible!==!1&&(this.dropDestIds.push(h.uuid),n[h.uuid]&&n[h.uuid].forEach(c=>{let d=r.find(c);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=o.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new M().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new M().setFromMatrixPosition(l.matrixWorld),pointStart:new M,pointEnd:new M,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new M().copy(l.position),quat0:new lt().copy(l.quaternion),snapped:!1,orientationMatrix:new we,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){sr(this.actionsDrag),sr(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},Kte=class extends Pr{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=i=>{var n;if(at.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:r,page:s}=this.eventContext,a=s.raycastWithClones(r);if(this.lastDropDestination=null,a.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:c,pointStart:d}of o.dragItems){if(h===a[0].object||h===a[0].object.object||Tt.is(h)&&h.isAncestorOf(a[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let u=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(Ft,Ko,Ni),gv.setFromQuaternion(Ko),u.prevR===void 0?(u.prevR=gv.clone(),u.prevT=Ft.clone()):(u.prevR.copy(gv),u.prevT.copy(Ft)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,d,o.data.plane,o.data.referenceFrame),c.copy(d),(this.eventManager.controlsManager.usePhysics&&((n=h.data.physics)==null?void 0:n.rigidBody)==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=i=>{var n,o,l,h;if(at.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:r,page:s}=this.eventContext,a=s.raycastWithClones(r);if(at.length===0){let c=!1;for(let d of this.events){for(let{obj:u}of d.dragItems)if(u===((n=a[0])==null?void 0:n.object)||u===((l=(o=a[0])==null?void 0:o.object)==null?void 0:l.object)||Tt.is(u)&&u.isAncestorOf((h=a[0])==null?void 0:h.object.uuid)){switch(c=!0,d.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break}break}if(c)break}c||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let c=this.activeEvent.activeDragItem;c.snapped=!1;let d;if(this.activeEvent.data.drop&&(d=a.filter(u=>c.obj!==u.object&&!c.obj.isAncestorOf(u.object.uuid)&&!(u.object instanceof Mh)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(p=>p===u.object.uuid||s.scene.find(p).isAncestorOf(u.object.uuid))))[0]),d){let u=g2.copy(d.face.normal).applyMatrix3(vv.getNormalMatrix(d.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")c.fromPosition.setFromMatrixPosition(d.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(c.fromPosition.copy(d.point),this.activeEvent.data.snapSurfaceMode==="bbox"){Ft.copy(u).applyMatrix3(vv.setFromMatrix4(c.obj.matrixWorld).transpose());let p=c.obj;Ft.x>Zl?Ni.x=-p.recursiveBBox.min.x:Ft.x<-Zl&&(Ni.x=-p.recursiveBBox.max.x),Ft.y>Zl?Ni.y=-p.recursiveBBox.min.y:Ft.y<-Zl&&(Ni.y=-p.recursiveBBox.max.y),Ft.z>Zl?Ni.z=-p.recursiveBBox.min.z:Ft.z<-Zl&&(Ni.z=-p.recursiveBBox.max.z),Ni.applyMatrix3(vv.invert())}else Ni.copy(u).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);c.fromPosition.add(Ni)}this.activeEvent.data.autoOrient&&(Ft.set(0,1,0).cross(u),Ft.length()<1e-4&&Ft.set(-1,0,0).cross(u),Ni.crossVectors(g2,Ft),c.orientationMatrix.makeBasis(Ft,Ni,u)),c.pointStart.copy(c.fromPosition),c.pointEnd.copy(c.pointStart),c.currentDampingFactor=this.activeEvent.snapDampingFactor,c.snapped=!0,this.lastDropDestination!==d.object&&(this.lastDropDestination=d.object,this.activeEvent.actionsDrop.Transition.forEach(p=>{p.play()}),this.activeEvent.actionsDrop.Animation.forEach(p=>{p.play()}),this.activeEvent.actionsDrop.Audio.forEach(p=>{p.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(p=>{p.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(p=>{p.dispatchThrottled()}))}else c.orientationMatrix.makeRotationFromQuaternion(c.quat0),this.lastDropDestination=null,c.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(c.obj,c.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(u=>{u.stop(),u.object.currentState!==null&&u.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.stop()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(u=>{u.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(u=>{u.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(u=>u.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(u=>u.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(u=>u.dispatch()),this.activeEvent.actionsDrag.ClearLocalStorage.forEach(u=>u.dispatch()),this.activeEvent.actionsDrag.UserAPI.forEach(u=>u.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrag.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrag.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.forEach(u=>{u.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(u=>{u.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(u=>{u.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(u=>{u.stop(),u.object.currentState!==null&&u.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(u=>{u.stop()}))},500),this.updateDragItem(c),c.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=i=>{var r;if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=((r=this.activeEvent.activeDragItem.obj.data.physics)==null?void 0:r.rigidBody)==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&s&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(a=>{a.stop(),a.object.currentState!==null&&a.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(a=>{a.stop()}),this.activeEvent.actionsDrag.Audio.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.ClearLocalStorage.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.UserAPI.forEach(a=>a.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}}}connect(){let e={};if(this.eventContext.page.traverseEntity(i=>{i.component&&(e[i.component.uuid]?e[i.component.uuid].push(i.uuid):e[i.component.uuid]=[i.uuid])}),this.eventContext.page.traverseEntity(i=>{var r;(r=i.data)==null||r.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new Zte(i,s.id,s.data,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager,e))})}),!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let t=this.eventContext.domElement;t.addEventListener("pointerdown",this.onPointerDown),t.addEventListener("pointermove",this.onPointerMove),t.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:s,raycaster:a}=this.eventContext;s().getWorldDirection(Un),Un.negate();let n=Ko.identity();switch(r==="parent"?Yte.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(Ft,n,Ni):r==="local"&&e.matrixWorld.decompose(Ft,n,Ni),i){case"x":Ft.set(1,0,0).applyQuaternion(n),Ql.copy(Un).cross(Ft),ha.copy(Ft).cross(Ql);break;case"y":Ft.set(0,1,0).applyQuaternion(n),Ql.copy(Un).cross(Ft),ha.copy(Ft).cross(Ql);break;case"z":Ft.set(0,0,1).applyQuaternion(n),Ql.copy(Un).cross(Ft),ha.copy(Ft).cross(Ql);break;case"xy":ha.set(0,0,1).applyQuaternion(n);break;case"yz":ha.set(1,0,0).applyQuaternion(n);break;case"xz":ha.set(0,1,0).applyQuaternion(n);break;case"adaptive":Un.angleTo(Ni.set(0,1,0))>Math.PI/6?(Ft.crossVectors(Ni.set(0,1,0),Un),ha.crossVectors(Ft,Ni)):ha.set(0,1,0);break;default:ha.copy(Un);break}Do.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:Do;if(m2.setFromNormalAndCoplanarPoint(ha,o),!!a.ray.intersectPlane(m2,t)&&(i==="x"||i==="y"||i==="z")){let l=Ni.subVectors(t,o).dot(Ft);t.copy(o).addScaledVector(Ft,l)}}updateDragItem(e,t=!1){var i,r;Do.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Ic.subVectors(e.fromPosition,Do).divideScalar(e.currentDampingFactor):e.reset==="original"?(Ic.subVectors(e.obj.userData.worldPosition0,Do).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Ic.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Do).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Ic.length()<Xte:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&Qte(e,Ic.add(Do),(i=this.activeEvent)!=null&&i.data.drop&&((r=this.activeEvent)!=null&&r.data.autoOrient)?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},Kl=new M,xv=new M,Ha=new M,Wa=new M,v2=new qr,Jte=.01,$te={type:"requestRender"},eie=function(){let e=new M,t=new M;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),y2=function(){let e=new we;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Vr&&un(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),tie=class{constructor(e,t,i,r,s,a){this.data=e,this.id=t,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new M,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...o0.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=r.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Li(e,e.actions,r,s,a,i)}},iie=class extends Pr{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.pairOfEventListeners=[],this.onMouseMove=i=>{if(!(at.length>1)){this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(r=>{var a,n;let s=(a=r.data)==null?void 0:a.events.find(o=>o.data.type==="Follow"&&!o.data.disabled);s&&(!e.data.globalPhysics.usePhysics||((n=r.dataPatched.physics)==null?void 0:n.rigidBody)!=="dynamic")&&this.events.push(new tie(s.data,s.id,r,e,this.eventContext.sharedAssets,this.eventManager))}),!this.events.length)return;let{domElement:t,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),ss&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events)if(r.target!==void 0){let s=r.target,a=this.onTargetChange(r);this.pairOfEventListeners.push([s,a]),s.addEventListener("requestRender",a)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),ss&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,sr(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){var n;this.events.forEach(o=>{o.actions.Create.forEach(l=>{l.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition(Ha),e.isReset)Wa.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Wa);else{let{getCamera:o,raycaster:l}=this.eventContext;if(i==="custom"?(o().getWorldDirection(xv),xv.negate(),Kl.copy(xv)):i==="xy"?Kl.set(0,0,1):i==="xz"?Kl.set(0,1,0):i==="yz"&&Kl.set(1,0,0),v2.setFromNormalAndCoplanarPoint(Kl,Ha),!l.ray.intersectPlane(v2,Wa))return}if(!e.isReset){if(Wa.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Wa.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(Wa.x=Ha.x),e.data.enabledTranslation[1]===!1&&(Wa.y=Ha.y),e.data.enabledTranslation[2]===!1&&(Wa.z=Ha.z);let a=eie(Ha,Wa,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let o=Kl.subVectors(a,Ha).divideScalar(e.currentDampingFactor);Ha.add(o),t&&y2(e.object,Ha),e.paused=o.length()<Jte}else y2(e.object,a),e.paused=!0;(n=e.object)==null||n.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent($te)}},Oc=new M,vp=new M,Rc=new we,Jl=new lt,Nn=new lt,Lc=new M,zc=new M,Io=new M,qa=new M,bv=new qr,rie=1e-6,sie={type:"requestRender"},aie={type:"changeRotation"},x2=function(){let e=new we;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(eD(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Vr&&un(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),nie=class{constructor(e,t,i,r){this.id=t,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new lt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...l0.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=r.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},oie=class extends Pr{constructor(){super(...arguments),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=e=>{if(!(at.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let t of this.events)t.target===void 0&&this.updateSingleEvent(t)}},this.onMouseEnter=e=>{for(let t of this.events)t.target===void 0&&(t.isReset=!1,t.currentDampingFactor=t.data.dampingFactor)},this.onMouseLeave=e=>{for(let t of this.events)t.target===void 0&&(t.data.resetOnPointerLeave&&(t.isReset=!0,t.currentDampingFactor=t.resetDampingFactor),this.updateSingleEvent(t))},this.onScroll=e=>{if(this._lastMouseEvent){let t=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(t)}},this.onTargetChange=e=>()=>{this.updateSingleEvent(e)},this.createUserEventListener=e=>({eventName:t,target:i})=>{if(!t||!i)return;let r=Yd(t);r&&r==="LookAt"&&this.updateSingleEvent(e)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(r=>{var a,n;let s=(a=r.data)==null?void 0:a.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!e.data.globalPhysics.usePhysics||((n=r.dataPatched.physics)==null?void 0:n.rigidBody)!=="dynamic")&&this.events.push(new nie(s.data,s.id,r,e))}),!this.events.length)return;let{domElement:t,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),ss&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?i.addEventListener("scroll",this.onScroll):(t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events){if(r.target!==void 0){let n=this.onTargetChange(r),o=r.target;this.pairOfEventListeners.push([o,n]),o.addEventListener("requestRender",n)}let s=this.createUserEventListener(r),a=r.object;this.pairOfUserEventListeners.push([a,s]),a.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),ss&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){var u;let{tilt:t,axis:i,distance:r,plane:s,limitDistance:a,enabledRotation:n,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:c,target:d}=e;if(c.getWorldPosition(Lc),!e.isReset)if(e.target)e.target.getWorldPosition(zc);else{if(s==="custom"?(l().getWorldDirection(vp),vp.negate(),bv.setFromNormalAndCoplanarPoint(vp,Lc)):(s==="xy"?Oc.set(0,0,1):s==="xz"?Oc.set(0,1,0):s==="yz"&&Oc.set(1,0,0),bv.setFromNormalAndCoplanarPoint(Oc,Lc)),!h.ray.intersectPlane(bv,zc))return;r>0&&(s==="custom"||s===void 0)&&zc.addScaledVector(vp,r)}if(e.isReset||(d?t==="target"?Io.copy(d.up).applyMatrix4(Rc.extractRotation(d.matrixWorld)).normalize():n.some(p=>p===!1)?(i==="x"?(qa.set(0,0,1),n[2]===!1&&qa.set(0,1,0)):i==="y"?(qa.set(1,0,0),n[0]===!1&&qa.set(0,0,1)):(qa.set(0,1,0),n[1]===!1&&qa.set(1,0,0)),Io.copy(qa).applyQuaternion(e.worldQuaternion0).normalize()):Io.set(0,1,0):s==="custom"?Io.set(0,1,0):Io.copy(Oc)),e.isReset)Nn.copy(e.worldQuaternion0);else if(Lc.distanceTo(zc)>a&&o&&d)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)Nn.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;lie(Rc,zc,Lc,Io,i,qa),Nn.setFromRotationMatrix(Rc),Jl.setFromUnitVectors(qa.applyQuaternion(Nn),Io),n.some(p=>p===!1)&&t!=="target"&&Nn.premultiply(Jl).normalize()}e.currentDampingFactor>1?(c.updateWorldMatrix(!0,!1),Jl.setFromRotationMatrix(eD(c.matrixWorld)),Jl.slerp(Nn,1/e.currentDampingFactor),x2(c,Rc.makeRotationFromQuaternion(Jl)),e.paused=8*(1-Jl.dot(Nn))<rie):(x2(c,Rc.makeRotationFromQuaternion(Nn)),e.paused=!0),(u=e.object)==null||u.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),c.dispatchEvent(sie),c.dispatchEvent(aie)}},us=new M,Ui=new M,bi=new M;function lie(e,t,i,r,s,a){let n=e.elements;bi.subVectors(t,i),bi.lengthSq()===0&&(bi.z=1),bi.normalize(),Ui.crossVectors(r,bi),Ui.lengthSq()===0&&(Math.abs(r.z)===1?bi.x+=1e-4:bi.z+=1e-4,bi.normalize(),Ui.crossVectors(r,bi)),Ui.normalize(),us.crossVectors(bi,Ui),s==="x"?a.z===1?[Ui,us,bi]=[bi,Ui,us]:(Ui.negate(),[Ui,bi]=[bi,Ui]):s==="y"?a.x===1?[Ui,us,bi]=[us,bi,Ui]:(Ui.negate(),[us,bi]=[bi,us]):a.x===1&&(Ui.negate(),[Ui,us]=[us,Ui]),n[0]=Ui.x,n[4]=us.x,n[8]=bi.x,n[1]=Ui.y,n[5]=us.y,n[9]=bi.y,n[2]=Ui.z,n[6]=us.z,n[10]=bi.z}var hie=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=Li(t,t.actions,r,s,a,i)}disconnect(){sr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatchStart()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Create.forEach(e=>e.dispatchStop()),this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},cie=class extends Pr{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObjects={},this.objects=[],this.objects2D=[],this._prevObjects=[],this.onMouseDown=i=>{at.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onMouseUp=i=>{at.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=i=>{at.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{var n;if(!i||!r)return;let a=Yd(i);a&&a==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),(n=this.eventsPerObjects[r.uuid])==null||n.forEach(o=>o.dispatchUserEvent(s)))}}connect(){let{page:e,sharedAssets:t}=this.eventContext,i=(s,a)=>{var n,o;if(!(!s.visible||!((n=s.data)!=null&&n.events.length))){for(let{id:l,data:h}of s.data.events)if(!h.disabled&&h.type==="MouseHover")try{let c=new hie(l,h,s,e,t,this.eventManager);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(c):this.eventsPerObjects[s.uuid]=[c]}catch{}(o=this.eventsPerObjects[s.uuid])!=null&&o.length&&this.objects.push(s instanceof ar?a:s)}};if(e.traverseEntity(s=>{var a;(s instanceof Sr||s instanceof $i)&&((a=s.frame)==null||a.traverse(n=>{i(n,s)})),i(s)}),!this.objects.length)return;let{domElement:r}=this.eventContext;this.domEventsNeeded.clear(),ss&&(this.domEventsNeeded.add("pointerdown"),r.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),r.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(s=>{s.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),ss&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:s,pointerScreen:a}=this.eventContext,n=!1;if(s.uiCanvas&&(n=rn(s,[a.x,a.y],Object.keys(this.eventsPerObjects),o=>{t.push(o)})),i&&!n){let o=Fp(r,s,this.objects);t=Ry(o),o.forEach(l=>{var h,c;l.object instanceof Sr&&rn(l.object,[((h=l==null?void 0:l.uv)==null?void 0:h.x)??0,((c=l==null?void 0:l.uv)==null?void 0:c.y)??0],Object.keys(this.eventsPerObjects),d=>{t.push(d)})})}else this.objects.forEach(o=>{var h,c;let l=Gf(r,o);l&&(t.push(o),o instanceof Sr&&rn(o,[((h=l==null?void 0:l.uv)==null?void 0:h.x)??0,((c=l==null?void 0:l.uv)==null?void 0:c.y)??0],Object.keys(this.eventsPerObjects),d=>{t.push(d)}))})}this._prevObjects.length&&this._prevObjects.forEach(i=>{var r;t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),(r=this.eventsPerObjects[i.uuid])==null||r.forEach(s=>s.dispatchLeave()))}),t.length&&t.forEach(i=>{var r;i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),(r=this.eventsPerObjects[i.uuid])==null||r.forEach(s=>s.dispatchEnter())}),this._prevObjects=t}},die=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=Li(t,t.actions,r,s,a,i)}connect(){this.scrollCounter=0}disconnect(){sr(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch()),this.actions.ClearLocalStorage.forEach(r=>r.dispatch()),this.actions.UserAPI.forEach(r=>r.dispatch())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},uie=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.object=i,this.domElement=a,this.eventManager=n,this.scrollStart=0,this.scrollEnd=0,this.actions=Li(t,t.actions,r,s,n,i)}getStickyParentElement(){let e=this.domElement;for(;e;){if(window.getComputedStyle(e).position==="sticky")return e;e=e.parentElement}return null}computeScrollBounds(){let e=this.getStickyParentElement(),t=e==null?void 0:e.parentElement,i=this.domElement.getBoundingClientRect(),r={top:i.top,bottom:i.bottom,left:i.left,right:i.right,width:i.width,height:i.height};if(t){let h=t.getBoundingClientRect(),c=window.getComputedStyle(e),d=parseFloat(c.marginTop)+parseFloat(c.marginBottom),u=parseFloat(c.top),p=parseFloat(c.bottom),f=h.height-d;if(!isNaN(u))i.top===u?(r.top+=h.top-u,r.bottom+=h.top-u):i.top<0&&(r.top-=f-i.height,r.bottom-=f-i.height);else if(!isNaN(p)){let g=document.body.clientHeight??window.innerHeight,m=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);i.bottom===g-p?(r.top+=h.top-i.height+p+m,r.bottom+=h.top-i.height+p+m):i.bottom<g-p&&(r.top-=f-i.height,r.bottom-=f-i.height)}}let s=document.body,a=document.documentElement,n=window.pageYOffset||a.scrollTop||s.scrollTop,o=a.clientTop||s.clientTop||0,l=Math.round(r.top+n-o);if(this.data.startFrom==="enter"){let h=window.innerHeight,c=r.height,d=this.data.enterAnchor,u=d==="top"?h:d==="bottom"?h-c:h-c*.5;this.scrollStart=l-u}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=r,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){sr(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch()),this.actions.ClearLocalStorage.forEach(s=>s.dispatch()),this.actions.UserAPI.forEach(s=>s.dispatch())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},pie=class extends Pr{constructor(e,t){super(e),this.managers=t,this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([i,r])=>{r.forEach(s=>s.handleResize())})},this.onScroll=i=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([s,a])=>{s.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),a.forEach(n=>n.dispatch(r))})},this.onWheel=i=>{!this.isInview||i.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:i.deltaY}),s.forEach(a=>a.dispatch(i.deltaY))})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{var n;if(!i||!r)return;let a=Yd(i);a&&a==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),(n=this.wheelEventsPerObject.get(r))==null||n.forEach(o=>{o.dispatchUserEvent(s)}))}}connect(){let{page:e,sharedAssets:t,domElement:i,isExport:r}=this.eventContext,s=a=>{var n,o,l;if((n=a.data)!=null&&n.events.length){for(let{id:h,data:c}of a.data.events)if(!c.disabled&&c.type==="Scroll")if(c.trigger==="load"||!r){let d=new die(h,c,a,e,t,this.managers);this.wheelEventsPerObject.has(a)?(o=this.wheelEventsPerObject.get(a))==null||o.push(d):this.wheelEventsPerObject.set(a,[d])}else{let d=new uie(h,c,a,e,t,i,this.managers);this.scrollEventsPerObject.has(a)?(l=this.scrollEventsPerObject.get(a))==null||l.push(d):this.scrollEventsPerObject.set(a,[d])}}};e.traverseEntity(a=>{var n;(a instanceof Sr||a instanceof $i)&&((n=a.frame)==null||n.traverse(o=>{s(o)})),s(a)}),this.intersectionObserver=new IntersectionObserver(a=>{let n=a[0];n&&(this.isInview=n.isIntersecting)},{root:null}),this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([a,n])=>{n.forEach(o=>o.connect()),a.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([a,n])=>{n.forEach(o=>o.connect()),a.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(a=>a.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(a=>a.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},fie=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Li(t,t.actions,r,s,a,i)}disconnect(){sr(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof Zo?t.interaction.audioPlayer.play():t.interaction instanceof Ey&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof io?t.interaction.play(i==="autoplay"):t.interaction instanceof Iy&&t.interaction.dispatch())}),this.actions.Particles.forEach(t=>{(t.data.triggerAfter??"any")===e&&t.dispatchBasic()})}async seekVideos(e){let t=[];this.actions.Video.forEach(i=>{(i.interaction.data.triggerAfter??"autoplay")==="autoplay"&&i.interaction instanceof io&&t.push(i.interaction.seek(e))}),await Promise.all(t)}pauseVideos(){this.actions.Video.forEach(e=>{e.interaction instanceof io&&e.interaction.pause()})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof Zo?t.interaction.audioPlayer.play():t.interaction instanceof Ey&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof io?t.interaction.play():t.interaction instanceof Iy&&t.interaction.dispatch()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()})}},mie=class extends Pr{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.removeEventListener("pointerdown",this.onAny),s.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,n])=>{a.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(o=>{o.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(a=>{a.interaction instanceof Zo&&a.interaction.audioPlayer.play()}),s.actions.Video.forEach(a=>{let n=a.interaction.data.triggerAfter??"autoplay";a.interaction instanceof io&&a.interaction.play(n==="autoplay")}),s.actions.Particles.forEach(a=>{a.dispatchBasic()})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.seekVideos=async i=>{let r=[];[...this.eventsAfterPerObject.entries()].forEach(([s,a])=>{a.forEach(n=>{r.push(n.seekVideos(i))})}),await Promise.all(r)},this.pauseVideos=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{r.forEach(s=>{s.pauseVideos()})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{var n,o;if(!i||!r)return;let a=Yd(i);a&&a==="Start"&&(r instanceof ar||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),(n=this.eventsPerObject.get(r))==null||n.forEach(l=>{l.dispatchUserEvent(s)}),(o=this.eventsAfterPerObject.get(r))==null||o.forEach(l=>{l.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext,i=r=>{var s,a,n,o,l;if((s=r.data)!=null&&s.events.length)for(let{id:h,data:c}of r.data.events){if(c.disabled||c.type!=="Start")continue;let d=new fie(h,c,r,t,e,this.eventManager);(d.actions.Transition.length||d.actions.Animation.length||d.actions.SwitchCamera.length||d.actions.Create.length||d.actions.Destroy.length||d.actions.SceneTransition.length||d.actions.Reset.length||d.actions.SetVariable.length||d.actions.DynamicVariablePlay.length||d.actions.ClearLocalStorage.length||d.actions.UserAPI.length)&&(this.eventsPerObject.has(r)?(a=this.eventsPerObject.get(r))==null||a.push(d):this.eventsPerObject.set(r,[d])),d.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?(n=this.eventsAfterPerObject.get(r))==null||n.push(d):this.eventsAfterPerObject.set(r,[d])),d.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?(o=this.eventsAfterPerObject.get(r))==null||o.push(d):this.eventsAfterPerObject.set(r,[d])),d.actions.Particles.length&&(this.eventsAfterPerObject.has(r)?(l=this.eventsAfterPerObject.get(r))==null||l.push(d):this.eventsAfterPerObject.set(r,[d]))}};if(t.traverseEntity(r=>{var s;(r instanceof Sr||r instanceof $i)&&((s=r.frame)==null||s.traverse(a=>{i(a)})),i(r)}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:s}=this.eventContext,a=s?document:r;a.addEventListener("pointerdown",this.onMouseDown,{once:!0}),a.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),a.addEventListener("pointerdown",this.onAny),a.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,o])=>{n.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(a=>a.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},gie=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.initialDisabled=!1,this.actions=Li(t,t.actions,r,s,a,i),this.target=t.target}disconnect(){sr(this.actions)}dispatch(e){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},vie=class extends Pr{constructor(e,t,i,r,s){super(e),this.sharedVariables=t,this.eventManager=i,this.needsMouse=r,this.needsRaycast=s,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.isOutOfFocus=!1,this.events=[],this.onFrame=a=>{let n=this.eventContext.sharedAssets;if(this.rafId=window.requestAnimationFrame(this.onFrame),this.isOutOfFocus)return;let o=new Date,l=[],h=[];for(let u=0;u<this.propertiesToWatch.length;u++){let{objectId:p,property:f,prevValue:g}=this.propertiesToWatch[u],m=this.eventContext.scene.find(p),v=c0.propertyPaths[f];if(v[0]==="width"||v[0]==="height"||v[0]==="depth")m=m.geometry.userData.parameters[v[0]];else for(let y=0;y<v.length;y++)m=m[v[y]];g===null?this.propertiesToWatch[u].prevValue=m instanceof M?m.clone():m:(m instanceof M?!m.equals(g):g!==m)&&(h.push({objId:p,property:f}),m instanceof M?this.propertiesToWatch[u].prevValue.copy(m):this.propertiesToWatch[u].prevValue=m)}for(let u=0;u<this.variablesToWatch.length;u++){let{id:p,prevValue:f}=this.variablesToWatch[u],g=n.getVariable(p);g!==f&&(l.push(p),this.variablesToWatch[u].prevValue=g)}for(let u=0;u<this.dynamicVars.length;u++){let{id:p,expectedTime:f,last:g,data:m,timerSeconds:v,startValue:y}=this.dynamicVars[u],x=1e3;if((m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&m.format==="number3decimal"?x=1:m.dynamicVariableType==="counter"?x=m.updateInterval:m.dynamicVariableType==="random"&&(x=m.isStatic?1/0:m.updateInterval),f===-1){this.dynamicVars[u].last=a,this.dynamicVars[u].expectedTime=a+x;continue}if(!((n.getDynamicVariablePlayState(p)==="Stopped"||n.getDynamicVariablePlayState(p)==="Restarted")&&(this.dynamicVars[u].last=a,this.dynamicVars[u].expectedTime=a+x,m.dynamicVariableType==="counter"&&n.getVariable(p)!==y&&(n.updateVariable(p,y),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[u].timerSeconds!==y&&(this.dynamicVars[u].timerSeconds=y,n.updateVariable(p,vs.getFormattedTimerTime(y,m)),this.eventManager.requestRender()),n.getDynamicVariablePlayState(p)==="Restarted"&&n.setDynamicVariablePlayState(p,"Playing"),n.getDynamicVariablePlayState(p)==="Stopped"))){if(n.getDynamicVariablePlayState(p)==="Paused"){this.dynamicVars[u].deltaToExpectedTime===void 0&&(this.dynamicVars[u].deltaToExpectedTime=Math.max(this.dynamicVars[u].expectedTime-a,0)),this.dynamicVars[u].last=a-(x-this.dynamicVars[u].deltaToExpectedTime),this.dynamicVars[u].expectedTime=a+this.dynamicVars[u].deltaToExpectedTime;continue}else this.dynamicVars[u].deltaToExpectedTime=void 0;if(a>=f)if(this.dynamicVars[u].last=a,this.dynamicVars[u].expectedTime+=x,m.dynamicVariableType==="random"){let w=m.min+Math.random()*(m.max-m.min),_=m.decimals;w=Math.round(w*Math.pow(10,_))/Math.pow(10,_),n.updateVariable(p,w),l.push(p),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){let w=n.getVariable(p),_=n.getDynamicVariableToggleIsForward(p)??!0,b=n.getVariable(p)+m.increment*(_?1:-1);m.hasEnd&&(b=m.increment>0?Re.clamp(b,y,m.endValue):Re.clamp(b,m.endValue,y),b===y&&n.setDynamicVariableToggleIsForward(p,void 0),m.repeat?b===m.endValue&&(b=y):(b===y||b===m.endValue)&&n.setDynamicVariablePlayState(p,"Paused")),b!==w&&(l.push(p),n.updateVariable(p,b),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time"){let w=n.getVariable(p),_=RS(o,m);if(typeof w=="object"&&"textValue"in w&&typeof _=="object"&&"textValue"in _){if(Array.isArray(w.textValue)&&Array.isArray(_.textValue)){if(w.textValue.every((b,A)=>b===_.textValue[A]))continue}else if(w.textValue===_.textValue)continue}else if(w===_)continue;n.updateVariable(p,_),l.push(p),this.eventManager.requestRender()}else{let w=mr.isTextValue(m.endValue)?b2(m.endValue.textValue):m.endValue,_=n.getDynamicVariableToggleIsForward(p)??!0,b=v+(a-g)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(_?1:-1);b=Math.max(b,0),m.hasEnd&&(b=m.dynamicVariableType==="stopwatch"?Re.clamp(b,y,w):Re.clamp(b,w,y),b===y&&n.setDynamicVariableToggleIsForward(p,void 0),m.repeat?Math.abs(b-w)<(m.format==="number3decimal"?1e-4:.1)&&(b=y):(Math.abs(b-y)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(b-w)<(m.format==="number3decimal"?1e-4:.1))&&n.setDynamicVariablePlayState(p,"Paused")),b!==v&&(l.push(p),this.dynamicVars[u].timerSeconds=b,n.updateVariable(p,vs.getFormattedTimerTime(b,m)),this.eventManager.requestRender())}}}let c=!1;n.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=n.mouseProperty,c=!0);let d=!1;n.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=n.raycastProperty,d=!0),this.events.forEach(u=>{(l.includes(u.data.variableId)||h.find(p=>p.objId===u.data.objectId&&p.property===u.data.property)||u.data.variableId==="mouseProperty"&&c||u.data.variableId==="raycastProperty"&&d)&&(u.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()}}pause(){this.isOutOfFocus||(this.isOutOfFocus=!0,this.pauseTime=Date.now())}resume(){if(!this.isOutOfFocus)return;this.isOutOfFocus=!1;let e=Date.now()-this.pauseTime;for(let t=0;t<this.dynamicVars.length;t++)this.dynamicVars[t].last+=e,this.dynamicVars[t].expectedTime+=e}connect(){this.eventContext.page.traverseEntity(t=>{var i;(i=t.data)==null||i.events.filter(r=>r.data.type==="VariableChange"&&!r.data.disabled).forEach(r=>{this.events.push(new yie(r.id,r.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.propertiesToWatch=this.events.filter(t=>t.data.variableId==="objectProperty"&&t.data.objectId!==null).map(t=>({objectId:t.data.objectId,property:t.data.property,prevValue:null}));let e=this.eventContext.sharedAssets;this.sharedVariables.forEach(({id:t,data:i})=>{if(!("dynamicVariableType"in i)){this.events.find(s=>s.data.variableId===t)&&this.variablesToWatch.push({id:t,prevValue:e.getVariable(t)});return}let r;if(i.dynamicVariableType==="timer"||i.dynamicVariableType==="stopwatch"){let s;if(mr.isTextValue(i.value)&&Array.isArray(i.value.textValue)){let a=i.value.textValue;a.length===3?s=a[2]+a[1]*60+a[0]*3600:s=a[1]+a[0]*60}else s=i.value;r=s,this.dynamicVars.push({id:t,last:-1,expectedTime:-1,data:i,timerSeconds:s,startValue:r})}else i.dynamicVariableType==="time"&&e.updateVariable(t,RS(new Date,i)),i.dynamicVariableType==="counter"&&(r=mr.isTextValue(i.value)?b2(i.value.textValue):i.value),this.dynamicVars.push({id:t,last:-1,expectedTime:-1,data:i,startValue:r})}),this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},yie=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Li(t,t.actions,r,s,a,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}dispose(){sr(this.actions)}};function b2(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var xie="https://unpkg.com/@splinetool/runtime@1.10.53/build/",bie="https://unpkg.com/@splinetool/navmesh-wasm@1.10.53/build/",wie=`
  7312. (async function() {
  7313. const [wasmImport, wasmBinary] = await Promise.all([
  7314. import('${xie}' + 'navmesh.js'),
  7315. fetch('${bie}' + 'navmesh.wasm').then((res) => res.arrayBuffer()),
  7316. ]);
  7317. const wasmModule = wasmImport.default;
  7318. self.module = await wasmModule({ wasmBinary });
  7319. postMessage('ready');
  7320. })();
  7321. `,_ie=`
  7322. (async function() {
  7323. const [wasmImport, wasmBinary] = await Promise.all([
  7324. import(self.location.origin + '/_libraries/navmesh.js'),
  7325. fetch(self.location.origin + '/_libraries/navmesh.wasm').then((res) => res.arrayBuffer()),
  7326. ]);
  7327. const wasmModule = wasmImport.default;
  7328. self.module = await wasmModule({ wasmBinary });
  7329. postMessage('ready');
  7330. })();
  7331. `,Sie=`
  7332. onmessage = function(messageEvent) {
  7333. const meshData = messageEvent.data;
  7334. const positions = meshData[0];
  7335. const offset = meshData[1];
  7336. const indices = meshData[2];
  7337. const indicesLength = meshData[3];
  7338. const parameters = meshData[4];
  7339. const module = self.module;
  7340. const rc = new module.rcConfig();
  7341. rc.cs = parameters.cs;
  7342. rc.ch = parameters.ch;
  7343. rc.borderSize = parameters.borderSize ? parameters.borderSize : 0;
  7344. rc.tileSize = parameters.tileSize ? parameters.tileSize : 0;
  7345. rc.walkableSlopeAngle = parameters.walkableSlopeAngle;
  7346. rc.walkableHeight = parameters.walkableHeight;
  7347. rc.walkableClimb = parameters.walkableClimb;
  7348. rc.walkableRadius = parameters.walkableRadius;
  7349. rc.maxEdgeLen = parameters.maxEdgeLen;
  7350. rc.maxSimplificationError = parameters.maxSimplificationError;
  7351. rc.minRegionArea = parameters.minRegionArea;
  7352. rc.mergeRegionArea = parameters.mergeRegionArea;
  7353. rc.maxVertsPerPoly = parameters.maxVertsPerPoly;
  7354. rc.detailSampleDist = parameters.detailSampleDist;
  7355. rc.detailSampleMaxError = parameters.detailSampleMaxError;
  7356. if (!self.navMesh) {
  7357. self.navMesh = new module.NavMesh();
  7358. }
  7359. self.navMesh.build(positions, offset, indices, indicesLength, rc);
  7360. const navmeshData = navMesh.getNavmeshData();
  7361. const arrView = new Uint8Array(module.HEAPU8.buffer, navmeshData.dataPointer, navmeshData.size);
  7362. const ret = new Uint8Array(navmeshData.size);
  7363. ret.set(arrView);
  7364. navMesh.freeNavmeshData(navmeshData);
  7365. postMessage(ret);
  7366. }
  7367. `,Aie=.001,Mie={cs:6,ch:2,walkableSlopeAngle:90,walkableHeight:20,walkableClimb:5,walkableRadius:0,maxEdgeLen:12,maxSimplificationError:1.3,minRegionArea:8,mergeRegionArea:20,maxVertsPerPoly:6,detailSampleDist:6,detailSampleMaxError:1},nD,Mt,lr;x8.then(e=>{nD=e,Mt=new e.Vec3,lr=new e.Vec3});var Eie=new M,Cie=class{constructor(e=!1,t=!1){this.usePhysics=e,this.isExport=t,this.onPointerDown=i=>{if(at.length!==1)return;let{raycaster:r,page:s}=this.eventContext;this.eventContext.updateRaycaster(i);let a=s.raycastWithClones(r);if(a.length!==0){if(this.gameControl){let n=Eie.copy(this.gameControl.colliderWorldPosition);n.y-=this.gameControl.colliderHeight/2,this.gameControl.path=this.computePath(n,a[0].point)}this.eventContext.requestRender()}},this.traverseWithPhysics=(i,r)=>s=>{var u,p,f,g,m,v,y;let a;if(s instanceof bs)if(s.objectForSample){if(s.objectForSample.dataPatched.physics.fusedBody)return;a=s.object}else return s.object.dataPatched.physics.fusedBody===!0&&s.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(s instanceof gr)a=s.object;else if(a=s,((u=a.dataPatched.cloner)==null?void 0:u.disabled)===!1&&((p=a.dataPatched.cloner)==null?void 0:p.hideBase)&&((f=a.dataPatched.physics)==null?void 0:f.fusedBody)!==!0)return!0;if(r&&!a.userData.navmesh)return;let n=a.dataPatched;if(!n.visible&&((g=n.physics)==null?void 0:g.enabled)!==!0)return!0;s.updateMatrixWorldSVD();let o=Hf(n),l=a.userData.hasDestroy,h=a.userData.hasDrag,c=!1,d=!1;for(let x of n.events)x.data.disabled!==!0&&(x.data.type==="GameControl"?c=!0:x.data.type==="Follow"&&(d=!0));if(c||o||d||l||h)return!0;if(this.usePhysics&&((m=n.physics)==null?void 0:m.rigidBody)==="dynamic"){if(this.usePhysics&&((v=n.physics)!=null&&v.fusedBody))return!0}else if("geometry"in s&&s.geometry&&i.push(tn(s.geometry,s.matrixWorld)),this.usePhysics&&((y=n.physics)==null?void 0:y.fusedBody))return s.traverseObject((x,w)=>{var A,S;if(w===0)return;let _;if(x instanceof bs)if(x.objectForSample){if(x.objectForSample.dataPatched.physics.fusedBody)return;_=x.object}else return x.object.dataPatched.physics.fusedBody===!0&&x.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(x instanceof gr)_=x.object;else if(_=x,(A=x.dataPatched.cloner)==null?void 0:A.hideBase)return!0;let b=_.dataPatched;if(!b.visible&&((S=b.physics)==null?void 0:S.enabled)!==!0)return!0;"geometry"in x&&x.geometry&&i.push(tn(x.geometry,x.matrixWorld))}),!0},this.traverseNoPhysics=(i,r)=>s=>{let a;if(s instanceof bs)return;s instanceof gr?a=s.object:a=s;let n=a.dataPatched;if(n.physics.enabled==="visibility"?!n.visible:!n.physics.enabled)return!0;if(r&&!a.userData.navmesh)return;let o=s.geometry,l=a.userData.hasDestroy===!0,h=a.userData.hasDrag===!0;if(Hf(n)||l||h||a.dataPatched.events.some(c=>c.data.disabled!==!0&&c.data.type==="GameControl"))return!0;o&&i.push(tn(o,s.matrixWorld))},this.navmeshWasm=nD,this.navMesh=new this.navmeshWasm.NavMesh,this._workerURL=URL.createObjectURL(new Blob([(t?wie:_ie)+Sie])),this._worker=new Worker(this._workerURL)}init(e,t,i){this.gameControl=t,this.eventContext=i,this.setDefaultQueryExtent(new M().setScalar(e.ch*e.walkableRadius*1.2)),this._worker.onmessage=()=>{this.createNavMesh(i.page,e,r=>{this.buildFromNavmeshData(r.data)})},this.eventContext.renderer.domElement.addEventListener("pointerdown",this.onPointerDown)}createNavMesh(e,t,i){t.objects.forEach(l=>{var c;let h=e.scene.find(l);h.traverseEntity(d=>{d.userData.navmesh=!0}),(c=h.cloner)==null||c.traverseObject(d=>{d.userData.navmesh=!0})});let r=[],s=(this.usePhysics?this.traverseWithPhysics:this.traverseNoPhysics)(r,t.zones==="custom");if(e.traverseChildren(s),t.objects.forEach(l=>{var c;let h=e.scene.find(l);h.traverseEntity(d=>{d.userData.navmesh=void 0}),(c=h.cloner)==null||c.traverseObject(d=>{d.userData.navmesh=void 0})}),r.length===0)return!1;let a=Qo(r),{positions:n,triIndices:o}=um(a.getAttribute("position"),a.getIndex());return this._worker.postMessage([n,n.length/3,o,o.length,{...Mie,...t}]),this._worker.onmessage=i,!0}createDebugNavGeometry(){let e,t,i=this.navMesh.getDebugNavMesh(),r=i.getTriangleCount(),s=new Uint32Array(r*3),a=new Float32Array(r*3*3);for(e=0;e<r*3;e++)s[e]=e;for(e=0;e<r;e++)for(t=0;t<3;t++){let o=i.getTriangle(e).getPoint(t);a[e*9+t*3+0]=o.x,a[e*9+t*3+1]=o.y,a[e*9+t*3+2]=o.z}let n=new Ge;return n.setIndex(new tt(s,1)),n.setAttribute("position",new tt(a,3)),n}getClosestPoint(e){return Mt.x=e.x,Mt.y=e.y,Mt.z=e.z,this.navMesh.getClosestPoint(Mt)}getClosestPointToRef(e,t){Mt.x=e.x,Mt.y=e.y,Mt.z=e.z;let i=this.navMesh.getClosestPoint(Mt);t.set(i.x,i.y,i.z)}getRandomPointAround(e,t){return Mt.x=e.x,Mt.y=e.y,Mt.z=e.z,this.navMesh.getRandomPointAround(Mt,t)}getRandomPointAroundToRef(e,t,i){Mt.x=e.x,Mt.y=e.y,Mt.z=e.z;let r=this.navMesh.getRandomPointAround(Mt,t);i.set(r.x,r.y,r.z)}moveAlong(e,t){return Mt.x=e.x,Mt.y=e.y,Mt.z=e.z,lr.x=t.x,lr.y=t.y,lr.z=t.z,this.navMesh.moveAlong(Mt,lr)}moveAlongToRef(e,t,i){return Mt.x=e.x,Mt.y=e.y,Mt.z=e.z,lr.x=t.x,lr.y=t.y,lr.z=t.z,this.navMesh.moveAlong(Mt,lr)}computePath(e,t){let i=this.getClosestPoint(t);if(lr.x=i.x,lr.y=i.y,lr.z=i.z,Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)+Math.pow(t.z-i.z,2))>this.getDefaultQueryExtent().y)return[];this.getClosestPoint(e);let r=this.navMesh.computePath(Mt,lr),s=r.getPointCount(),a=[];for(let n=0;n<s;n++){let o=r.getPoint(n);a.push(new M(o.x,o.y,o.z))}return a}createCrowd(e,t){return new Tie(this,e,t)}setDefaultQueryExtent(e){Mt.x=e.x,Mt.y=e.y,Mt.z=e.z,this.navMesh.setDefaultQueryExtent(Mt)}getDefaultQueryExtent(){return this.navMesh.getDefaultQueryExtent()}buildFromNavmeshData(e){let t=e.length*e.BYTES_PER_ELEMENT,i=this.navmeshWasm._malloc(t),r=new Uint8Array(this.navmeshWasm.HEAPU8.buffer,i,t);r.set(e);let s=new this.navmeshWasm.NavmeshData;s.dataPointer=r.byteOffset,s.size=e.length,this.navMesh.buildFromNavmeshData(s),this.navmeshWasm._free(r.byteOffset)}getNavmeshData(){let e=this.navMesh.getNavmeshData(),t=new Uint8Array(this.navmeshWasm.HEAPU8.buffer,e.dataPointer,e.size),i=new Uint8Array(e.size);return i.set(t),this.navMesh.freeNavmeshData(e),i}getDefaultQueryExtentToRef(e){let t=this.navMesh.getDefaultQueryExtent();e.set(t.x,t.y,t.z)}dispose(){var e;this.navMesh.destroy(),this._worker.terminate(),URL.revokeObjectURL(this._workerURL),(e=this.eventContext)==null||e.renderer.domElement.removeEventListener("pointerdown",this.onPointerDown)}addCylinderObstacle(e,t,i){return Mt.x=e.x,Mt.y=e.y,Mt.z=e.z,this.navMesh.addCylinderObstacle(Mt,t,i)}addBoxObstacle(e,t,i){return Mt.x=e.x,Mt.y=e.y,Mt.z=e.z,lr.x=t.x,lr.y=t.y,lr.z=t.z,this.navMesh.addBoxObstacle(Mt,lr,i)}removeObstacle(e){this.navMesh.removeObstacle(e)}isSupported(){return this.navmeshWasm!==void 0}},Tie=class{constructor(e,t,i){this.navmeshWasmWrapper=e,this.transforms=[],this.agents=new Array,this.reachRadii=new Array,this._agentDestinationArmed=new Array,this._agentDestination=new Array,this.crowd=new this.navmeshWasmWrapper.navmeshWasm.Crowd(t,i,this.navmeshWasmWrapper.navMesh.getNavMesh())}onReachTarget(e,t){}addAgent(e,t,i){let r=new this.navmeshWasmWrapper.navmeshWasm.dtCrowdAgentParams;r.radius=t.radius,r.height=t.height,r.maxAcceleration=t.maxAcceleration,r.maxSpeed=t.maxSpeed,r.collisionQueryRange=t.collisionQueryRange,r.pathOptimizationRange=t.pathOptimizationRange,r.separationWeight=t.separationWeight,r.updateFlags=7,r.obstacleAvoidanceType=0,r.queryFilterType=0,r.userData=0;let s=this.crowd.addAgent(new this.navmeshWasmWrapper.navmeshWasm.Vec3(e.x,e.y,e.z),r);return this.transforms.push(i),this.agents.push(s),this.reachRadii.push(t.reachRadius?t.reachRadius:t.radius),this._agentDestinationArmed.push(!1),this._agentDestination.push(new M(0,0,0)),s}getAgentPosition(e){return this.crowd.getAgentPosition(e)}getAgentPositionToRef(e,t){let i=this.crowd.getAgentPosition(e);t.set(i.x,i.y,i.z)}getAgentVelocity(e){return this.crowd.getAgentVelocity(e)}getAgentVelocityToRef(e,t){let i=this.crowd.getAgentVelocity(e);t.set(i.x,i.y,i.z)}getAgentNextTargetPath(e){return this.crowd.getAgentNextTargetPath(e)}getAgentNextTargetPathToRef(e,t){let i=this.crowd.getAgentNextTargetPath(e);t.set(i.x,i.y,i.z)}getAgentState(e){return this.crowd.getAgentState(e)}overOffmeshConnection(e){return this.crowd.overOffmeshConnection(e)}agentGoto(e,t){this.crowd.agentGoto(e,new this.navmeshWasmWrapper.navmeshWasm.Vec3(t.x,t.y,t.z));let i=this.agents.indexOf(e);i>-1&&(this._agentDestinationArmed[i]=!0,this._agentDestination[i].set(t.x,t.y,t.z))}agentTeleport(e,t){this.crowd.agentTeleport(e,new this.navmeshWasmWrapper.navmeshWasm.Vec3(t.x,t.y,t.z))}updateAgentParameters(e,t){let i=this.crowd.getAgentParameters(e);t.radius!==void 0&&(i.radius=t.radius),t.height!==void 0&&(i.height=t.height),t.maxAcceleration!==void 0&&(i.maxAcceleration=t.maxAcceleration),t.maxSpeed!==void 0&&(i.maxSpeed=t.maxSpeed),t.collisionQueryRange!==void 0&&(i.collisionQueryRange=t.collisionQueryRange),t.pathOptimizationRange!==void 0&&(i.pathOptimizationRange=t.pathOptimizationRange),t.separationWeight!==void 0&&(i.separationWeight=t.separationWeight),this.crowd.setAgentParameters(e,i)}removeAgent(e){this.crowd.removeAgent(e);let t=this.agents.indexOf(e);t>-1&&(this.agents.splice(t,1),this.transforms.splice(t,1),this.reachRadii.splice(t,1),this._agentDestinationArmed.splice(t,1),this._agentDestination.splice(t,1))}getAgents(){return this.agents}update(e){if(this.navmeshWasmWrapper.navMesh.update(),e<=Aie)return;let t=1/60,i=10;{let r=Math.floor(e/t);r>i&&(r=i),r<1&&(r=1);let s=e/r;for(let a=0;a<r;a++)this.crowd.update(s)}for(let r=0;r<this.agents.length;r++){let s=this.agents[r],a=this.getAgentPosition(s);if(this.transforms[r].copy(a),this._agentDestinationArmed[r]){let n=a.x-this._agentDestination[r].x,o=a.z-this._agentDestination[r].z,l=this.reachRadii[r],h=this._agentDestination[r].y-this.reachRadii[r],c=this._agentDestination[r].y+this.reachRadii[r],d=n*n+o*o;a.y>h&&a.y<c&&d<l*l&&(this.onReachTarget(s,this._agentDestination[r]),this._agentDestinationArmed[r]=!1)}}}setDefaultQueryExtent(e){let t=new this.navmeshWasmWrapper.navmeshWasm.Vec3(e.x,e.y,e.z);this.crowd.setDefaultQueryExtent(t)}getDefaultQueryExtent(){return this.crowd.getDefaultQueryExtent()}getDefaultQueryExtentToRef(e){let t=this.crowd.getDefaultQueryExtent();e.set(t.x,t.y,t.z)}getCorners(e){let t,i=this.crowd.getCorners(e),r=i.getPointCount(),s=[];for(t=0;t<r;t++){let a=i.getPoint(t);s.push(new M(a.x,a.y,a.z))}return s}dispose(){this.crowd.destroy()}};function Pie(e){let t=!1;return e.scene.objects.forEach(i=>{i.data.type==="Page"&&!t&&i.data.publish.gameControlObject&&Ad.traverseModuleInstances(e,i.id,(r,s,a)=>{for(let n of a)n.data.type==="GameControl"&&n.data.navmesh.enabled&&(t=!0)})}),t}var Die={type:"change"},w2={type:"changeZoom"},Iie={type:"changePan"},Oo={type:"start"},Ro={type:"end",changed:!0},Oie={type:"end",changed:!1},wv=new lt,_2=new j,Rie=2*Math.PI,Lie=1e-8,zie=.01,_v=new M,yp=new j,Sv=new M,xp=new lt,S2=new we,Bie={type:"requestRender"},oD=class extends yr{constructor(e,t,i={isPlayMode:!1,isExport:!1}){super(),this.object=e,this.domElement=t,this.options=i,this.enabled=!0,this.useKeyEvents=!0,this.enableDamping=!1,this.enableZoom=!0,this.enableRotate=!0,this.enablePan=!0,this.autoRotate=!1,this.rotationLimitsMode=0,this.panLimitsMode=0,this.rotationSoftLimit=2,this.panSoftLimit=2,this.hoverRotatePanMode=0,this.zoomLimitsEnabled=!1,this.mouseButtons=[0,5],this.mouseButtonsPlay=[3,4,5],this.touches=[null,os.DOLLY_ROTATE,os.PAN],this.offset=new M,this.eye=new M,this.lastPosition=new M,this.lastQuaternion=new lt,this.current=new j,this.overShoot=new j,this.overRatio=new j,this.spherical=new Kb,this.sphericalDelta=new Kb,this.panOffset=new M,this.panLeftV=new M,this.panUpV=new M,this.panV=new M,this.rotateStart=new j,this.rotateEnd=new j,this.rotateDelta=new j,this.panStart=new j,this.panEnd=new j,this.panDelta=new j,this.dollyStart=new j,this.dollyEnd=new j,this.dollyDelta=new j,this.rotationRangeFactor=new j,this.panRangeFactor=new j,this.state=-1,this.zoomChanged=!1,this.isPointerDown=!1,this.isThetaFlipped=!1,this.prevScale=0,this.scale=1,this.gesture=!1,this.timer=-1,this.timerHover=-1,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPhi=0,this.maxPhi=Math.PI,this.minTheta=-1/0,this.maxTheta=1/0,this.minH=0,this.maxH=Math.PI,this.minV=-1/0,this.maxV=1/0,this.autoRotateClockwise=!0,this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.resetHoverEffectOnPointerLeave=!1,this.hasChange=!1,this.useWindowEvents=!1,this.isTouchZoom=!0,this.autoRotateSpeed=2,this.dampingFactor=.125,this.zoomSpeed=2,this.rotateSpeed=1,this.panSpeed=1,this.hoverRotatePanStrength=.1,this.hoverRotateDamping=this.dampingFactor,this.isCurrentlyDamping=!1,this.thetaIsFree=!1,this.phiIsFree=!1,this.needsUpdate=!0,this.onCameraChange=r=>{this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange),this.object=r.camera,this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)},this.update=()=>{this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(Sv,xp,_v),this.offset.copy(Sv).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&this.object.isPerspectiveCamera&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(wv.copy(xp).invert()),this.panOffset.applyQuaternion(wv),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(xp),this.panOffset.applyQuaternion(xp)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state===-1&&!this.gesture?(this.panOffset.multiplyScalar(1-this.dampingFactor),this.target.add(this.panOffset)):(this.target.add(this.panOffset),this.panOffset.set(0,0,0)),this.offset.setFromSpherical(this.spherical),Sv.copy(this.target).add(this.offset),this.object.position.copy(this.target).add(this.offset),this.object.parent&&(S2.copy(this.object.parent.matrixWorld).invert(),this.object.position.applyMatrix4(S2));let r=this.spherical.phi%Rie;if(this.eye.copy(this.offset).normalize(),this.object.up.copy(kt.DEFAULT_UP).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),r>0&&r>Math.PI||r<0&&r>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0){let s=this.hoverRotatePanMode===1?this.hoverRotateDamping:this.dampingFactor;this.sphericalDelta.theta*=1-s,this.sphericalDelta.phi*=1-s}else this.sphericalDelta.set(0,0,0);if(this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>zie||8*(1-this.lastQuaternion.dot(this.object.quaternion))>Lie){this.dispatchEvent(Die),this.object.dispatchEvent(Bie),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,this.isCurrentlyDamping=!0;return}this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.object.wasMovedBySwitchCameraAction=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),this.isCurrentlyDamping=!1},this.onPointerDown=r=>{this.enabled!==!1&&(r.pointerType==="touch"||r.pointerType==="pen"&&ss?this.onPointerDownTouch(r):this.onPointerDownMouse(r),this.state!==-1&&(this.isPointerDown=!0,this.dispatchEvent(Oo),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),r.stopPropagation(),r.pointerType==="touch"||r.pointerType==="pen"&&ss||this.domElement.setPointerCapture(r.pointerId)))},this.onPointerLeave=r=>{this.resetHoverEffectOnPointerLeave&&!this.useWindowEvents?(this.hoverRotatePanMode===1?(this.sphericalDelta.theta=-this.spherical.theta,this.sphericalDelta.phi=-this.spherical.phi,_v.subVectors(this.position0,this.target0),this.spherical.setFromVector3(_v),this.sphericalDelta.theta+=this.spherical.theta,this.sphericalDelta.phi+=this.spherical.phi,this.sphericalDelta.theta/=8,this.sphericalDelta.phi/=8):this.hoverRotatePanMode===2&&this.panOffset.subVectors(this.target0,this.target).divideScalar(8),this.update()):this.pointerLeaveEvent=r},this.onPointerEnter=r=>{this.resetHoverEffectOnPointerLeave||this.pointerLeaveEvent===void 0?yp.set(r.clientX-this.domElement.clientWidth/2,r.clientY-this.domElement.clientHeight/2):yp.set(r.clientX-this.pointerLeaveEvent.clientX,r.clientY-this.pointerLeaveEvent.clientY),this.hoverRotatePanMode===1?(this.rotateDelta.copy(yp).multiplyScalar(this.rotateSpeed*this.hoverRotatePanStrength).rotateAround(_2,-this.object.angleOffsetFromUp),this.rotateLeft(2*Math.PI*this.rotateDelta.x/this.domElement.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/this.domElement.clientHeight),this.rotateStart.set(r.clientX,r.clientY)):this.hoverRotatePanMode===2&&(this.panDelta.copy(yp).multiplyScalar(this.panSpeed*this.hoverRotatePanStrength),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.set(r.clientX,r.clientY)),this.update()},this.onPointerMove=r=>{this.enabled!==!1&&(this.checkRaycastLock()||(r.pointerType==="touch"||r.pointerType==="pen"&&ss?this.onPointerMoveTouch(r):this.onPointerMoveMouse(r),r.stopPropagation()))},this.onPointerUp=r=>{this.isPointerDown=!1,at.length===0&&(this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)),at.length>1&&r.preventDefault(),this.hasChange?this.dispatchEvent(Ro):this.dispatchEvent(Oie),this.state=-1,r&&(r.stopPropagation(),r.pointerType==="touch"||r.pointerType==="pen"&&ss||this.domElement.releasePointerCapture(r.pointerId))},this.onPointerDownMouse=r=>{let s;switch(this.useKeyEvents?s=this.mouseButtons[r.button]:s=this.mouseButtonsPlay[r.button],s){case 0:if(r.altKey===!0&&!r.shiftKey&&!Pu(r)){if(this.enableRotate===!1)return;this.handleMouseDownRotate(r),this.state=0}else if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(r),this.state=2}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(r),this.state=2;break;case 3:if(Pu(r)||r.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(r),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(r),this.state=0}break;case 5:if(Pu(r)||r.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(r),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(r),this.state=2}break;default:this.state=-1}},this.onPointerMoveMouse=r=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(r);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(r);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(r);break}this.object.wasMovedByUser=!0},this.onPointerDownTouch=r=>{switch(at.length>1&&r.preventDefault(),this.touches[at.length-1]){case os.ROTATE:if(this.enableRotate===!1){this.state=-1;return}this.handleTouchStartRotate(),this.state=3;break;case os.PAN:if(this.enablePan===!1){this.state=-1;return}this.handleTouchStartPan(),this.state=4;break;case os.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case os.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}},this.onPointerMoveTouch=r=>{switch(at.length>1&&r.preventDefault(),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(r),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(r),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(r),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(r),this.update();break;default:this.state=-1}this.object.wasMovedByUser=!0},this.dispatchEndDebounced=xd(()=>this.dispatchEvent(Ro),33),this.onMouseWheel=r=>{this.enabled===!1||this.enableZoom===!1&&this.enablePan===!1||this.checkRaycastLock()||(!this.options.isExport&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&r.preventDefault(),this.dispatchEvent(Oo),this.handleMouseWheel(r),this.dispatchEndDebounced(),this.object.wasMovedByUser=!0)},this.onGesture=r=>{if(r.preventDefault(),this.enabled!==!1&&!this.checkRaycastLock()&&!ec)if(r.type==="gesturechange"){if(this.enableZoom===!1||this.isTouchZoom===!1)return;this.dispatchEvent(Oo),r.scale>this.prevScale?this.dollyIn(this.getZoomScale()):r.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=r.scale,this.update(),this.object.wasMovedByUser=!0}else this.dispatchEvent(Ro)},this.onContextMenu=r=>{r.preventDefault()},this.onTouchEnd=r=>{r.preventDefault()},this.onKeyDown=r=>{this.enabled!==!1&&(this.key=r.key,r.key===" "&&this.dispatchEvent(Oo))},this.onKeyUp=r=>{this.enabled!==!1&&(this.key=void 0,this.state!==-1&&r.key==="Alt"&&this.onPointerUp(at[0]),r.key===" "&&this.dispatchEvent(Ro))},this.onPointerHover=r=>{r.pointerType!=="mouse"||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot||(this.isPointerDown=!0,this.hoverRotatePanMode===2?this.handleMouseMovePan(r,this.hoverRotatePanStrength):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(r,this.hoverRotatePanStrength))},this.onBeginState=()=>{this.enabled=!1,this.needsUpdate=!1},this.onCompleteState=r=>{r.isfromEntity&&this.options.isPlayMode||(this.enabled=!0,this.needsUpdate=!0,this.object.updateUp(),this.object.getTarget(this.target))},this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.quat0=this.object.quaternion.clone(),this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.offset.copy(this.object.position).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.initialSphericalRadius=this.spherical.radius,this.addEventListenersToCamera()}dispatchEvent(e){e.type==="start"?this.hasChange=!1:this.hasChange=!0,super.dispatchEvent(e)}addEventListenersToCamera(){this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)}removeEventListenersFromCamera(){this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange)}updateUseWindowEvents(e){if(window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("pointermove",this.onPointerHover),this.useWindowEvents=e,this.hoverRotatePanMode!==0&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover)),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.hoverRotatePanMode!==0&&!this.useWindowEvents){let t=this.useWindowEvents?window:this.domElement;t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerenter",this.onPointerEnter)}}fromJSON(e,t){this.setEnableDampingSpeed(e.enableDamping),this.enablePan=e.enablePan,this.enableZoom=e.enableZoom,this.enableRotate=e.enableRotate,this.rotationLimitsMode=e.rotationLimitsMode,this.thetaIsFree=e.rotationHorizontalOffset.min===e.rotationHorizontalOffset.max&&e.rotationHorizontalOffset.min===Math.PI,this.phiIsFree=e.rotationVerticalOffset.min===e.rotationVerticalOffset.max&&e.rotationVerticalOffset.min===Math.PI,this.panLimitsMode=e.panLimitsMode,this.panSoftLimit=e.panSoftLimit,this.rotationSoftLimit=e.rotationSoftLimit,this.hoverRotatePanMode=e.hoverRotatePanMode,this.hoverRotateDamping=e.hoverRotateDamping??this.dampingFactor,this.useWindowEvents=t==="window",this.hoverRotatePanMode!==0&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover));let i=e.hoverRotatePanStrength/100;this.hoverRotatePanStrength=i**2,this.zoomLimitsEnabled=e.zoomLimitsEnabled,this.minZoom=e.zoomLimits.min,this.maxZoom=Math.max(e.zoomLimits.min,e.zoomLimits.max),this.minDistance=1e3/this.maxZoom,this.maxDistance=Math.max(this.minDistance,1e3/e.zoomLimits.min),this.autoRotate=e.autoRotate,this.autoRotateSpeed=e.autoRotateSpeed,this.autoRotateClockwise=e.autoRotateClockwise;let r=this.object.getTarget().applyQuaternion(wv.copy(this.object.quaternion).invert());this.minV=-e.panVerticalOffset.min+r.y,this.maxV=e.panVerticalOffset.max+r.y,this.minH=-e.panHorizontalOffset.min+r.x,this.maxH=e.panHorizontalOffset.max+r.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=ca(this.spherical.phi-e.rotationVerticalOffset.min),this.maxPhi=ca(this.spherical.phi+e.rotationVerticalOffset.max),this.minTheta=ca(ca(this.spherical.theta)-e.rotationHorizontalOffset.min),this.maxTheta=ca(ca(this.spherical.theta)+e.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,e.orbitTouches===1&&(this.touches[0]=os.ROTATE),e.panTouches===1&&(this.touches[0]=os.PAN),e.orbitTouches===2&&(this.touches[1]=os.DOLLY_ROTATE),e.panTouches===2&&(this.touches[1]=os.DOLLY_PAN),e.orbitTouches===3&&(this.touches[2]=os.ROTATE),e.panTouches===3&&(this.touches[2]=os.PAN),this.isTouchZoom=e.isTouchZoom,this.resetHoverEffectOnPointerLeave=e.resetHoverEffectOnPointerLeave??!1}connect(){if(this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture),this.domElement.addEventListener("touchend",this.onTouchEnd),this.hoverRotatePanMode!==0&&!this.useWindowEvents){let e=this.useWindowEvents?window:this.domElement;e.addEventListener("pointerleave",this.onPointerLeave),e.addEventListener("pointerenter",this.onPointerEnter)}this.pointerLeaveEvent=void 0}dispose(){this.removeEventListenersFromCamera(),this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)}applyLimits(e,t,i,r,s,a,n,o){this.overShoot.set(0,0);let l,h,c;e instanceof M?(l=e.x,h=e.y,this.current.set(this.target.x,this.target.y),c=!0):(l=e.theta,h=e.phi,this.current.set(ca(this.spherical.theta),ca(this.spherical.phi)),c=!1),i===0&&(this.current.x+=l,this.current.y+=h),(t===3||t===2)&&(!c&&this.isThetaFlipped?this.current.x>r&&this.current.x<0?this.overShoot.x=r-this.current.x:this.current.x<s&&this.current.x>0&&(this.overShoot.x=s-this.current.x):this.current.x>r?this.overShoot.x=r-this.current.x:this.current.x<s&&(this.overShoot.x=s-this.current.x)),(t===3||t===1)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<n&&(this.overShoot.y=n-this.current.y)),c||(this.overShoot.x=ca(this.overShoot.x),this.overShoot.y=ca(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(o),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=A2(Math.abs(this.overRatio.x)),this.overRatio.y=A2(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9&&!this.thetaIsFree||this.overRatio.y>.9&&!this.phiIsFree)?this.isPointerDown=!1:(l*this.overShoot.x<0&&!this.thetaIsFree&&(l*=1-this.overRatio.x),h*this.overShoot.y<0&&!this.phiIsFree&&(h*=1-this.overRatio.y)):i===2&&(!c&&(this.overRatio.x>.002&&!this.thetaIsFree||this.overRatio.y>.002&&!this.phiIsFree)||c&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(this.thetaIsFree||(l=this.overShoot.x*.05),this.phiIsFree||(h=this.overShoot.y*.05),c?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):c?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(l+=this.overShoot.x,h+=this.overShoot.y),e instanceof M?(e.x=l,e.y=h):(this.thetaIsFree||(e.theta=l),this.phiIsFree||(e.phi=h))}setEnableDampingSpeed(e){this.enableDamping=e,this.rotateSpeed=e===!0?.2:1}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(e){this.sphericalDelta.theta-=e}rotateUp(e){this.sphericalDelta.phi-=e}panLeft(e,t){this.panLeftV.setFromMatrixColumn(t,0),this.panLeftV.multiplyScalar(-e),this.panOffset.add(this.panLeftV)}panUp(e,t){this.panUpV.setFromMatrixColumn(t,1),this.panUpV.multiplyScalar(e),this.panOffset.add(this.panUpV)}pan(e,t){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let r=this.object.position;this.panV.copy(r).sub(this.target);let s=this.panV.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*e*s/i.clientHeight,this.object.matrixWorld),this.panUp(2*t*s/i.clientHeight,this.object.matrixWorld)}else i&&this.object.isOrthographicCamera&&(this.panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrixWorld),this.panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrixWorld));this.dispatchEvent(Iie)}dollyOut(e){this.object.isPerspectiveCamera?this.scale/=e:this.object.isOrthographicCamera&&(this.object.zoom*=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(w2)}dollyIn(e){this.object.isPerspectiveCamera?this.scale*=e:this.object.isOrthographicCamera&&(this.object.zoom/=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(w2)}zoomOut(e=this.getZoomScale()){this.dispatchEvent(Oo),this.dollyOut(e),this.dispatchEvent(Ro)}zoomIn(e=this.getZoomScale()){this.dispatchEvent(Oo),this.dollyIn(e),this.dispatchEvent(Ro)}setZoom(e){if(this.dispatchEvent(Oo),this.object.isPerspectiveCamera){let t=this.initialSphericalRadius/e/this.spherical.radius;this.scale=t}else this.object.isOrthographicCamera&&(this.object.zoom=e,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0);this.dispatchEvent(Ro)}handleMouseDownRotate(e){this.rotateStart.set(e.clientX,e.clientY)}handleMouseDownDolly(e){this.dollyStart.set(e.clientX,e.clientY)}handleMouseDownPan(e){this.panStart.set(e.clientX,e.clientY)}handleMouseMoveRotate(e,t=1){e.movementX!==void 0?this.rotateDelta.set(e.movementX,e.movementY):(this.rotateEnd.set(e.clientX,e.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)),this.rotateDelta.multiplyScalar(this.rotateSpeed*t).rotateAround(_2,-this.object.angleOffsetFromUp);let i=this.domElement,r=this.useWindowEvents?window.innerHeight:i.clientHeight,s=2*Math.PI*this.rotateDelta.x/r,a=2*Math.PI*this.rotateDelta.y/r;this.rotateLeft(s),this.rotateUp(a),this.update()}handleMouseMoveDolly(e){this.dollyEnd.set(e.clientX,e.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(e,t=1){e.movementX!==void 0?this.panDelta.set(e.movementX,e.movementY):(this.panEnd.set(e.clientX,e.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)),this.panDelta.multiplyScalar(this.panSpeed*t),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(e){if(p8===!1&&Pu(e)===!1&&m8(e)===!0){if(this.enablePan===!1)return;this.gesture?(this.panDelta.set(-e.deltaX,-e.deltaY).multiplyScalar(this.panSpeed),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),e.altKey?this.pan(0,this.panDelta.y):e.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()):(this.gesture=!0,this.isPointerDown=!0),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1},30)}else{if(this.enableZoom===!1||this.gesture)return;e.deltaY===0?e.deltaX<0?this.dollyIn(this.getZoomScale()):e.deltaX>0&&this.dollyOut(this.getZoomScale()):e.deltaY<0?this.dollyIn(this.getZoomScale()):e.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}}handleTouchStartRotate(){if(at.length===2){let e=.5*(at[0].pageX+at[1].pageX),t=.5*(at[0].pageY+at[1].pageY);this.rotateStart.set(e,t)}else this.rotateStart.set(at[0].pageX,at[0].pageY)}handleTouchStartPan(){if(at.length===2){let e=.5*(at[0].pageX+at[1].pageX),t=.5*(at[0].pageY+at[1].pageY);this.panStart.set(e,t)}else this.panStart.set(at[0].pageX,at[0].pageY)}handleTouchStartDolly(){let e=at[0].pageX-at[1].pageX,t=at[0].pageY-at[1].pageY,i=Math.sqrt(e*e+t*t);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(e){if(at.length===2){let i=ug(e),r=.5*(e.pageX+i.x),s=.5*(e.pageY+i.y);this.rotateEnd.set(r,s)}else{if(e.pointerId!==at[0].pointerId)return;this.rotateEnd.set(e.pageX,e.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;t&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/t.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/t.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(e){if(at.length===2){let t=ug(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this.panEnd.set(i,r)}else{if(e.pointerId!==at[0].pointerId)return;this.panEnd.set(e.pageX,e.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(e){let t=ug(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+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)}handleTouchMoveDollyPan(e){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchMoveDolly(e),this.enablePan&&this.handleTouchMovePan(e)}handleTouchMoveDollyRotate(e){this.enableZoom&&this.isTouchZoom===!0&&this.handleTouchMoveDolly(e),this.enableRotate&&this.handleTouchMoveRotate(e)}checkRaycastLock(){var e;if(this.object.data.raycastLock){if(this.options.isPlayMode)return!1;{let t=(e=this.options)==null?void 0:e.showCameraLock;return t&&t(),!0}}else return!1}};function ca(e){let t=Math.PI*2;for(;e<=-Math.PI;)e+=t;for(;e>Math.PI;)e-=t;return e}function A2(e){return 1-Math.pow(1-e,4)}var M2=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.page=r,this.currentIntersectedObjects=[],this.actions=Li(t,t.actions,r,s,a,i),this.target=t.target,this.triggeringObjects=[];for(let n of t.triggeringObjects){let o=r.scene.find(n);o&&this.triggeringObjects.push(o)}}isValidTriggeringObject(e){return this.target==="all"?!0:this.triggeringObjects.some(t=>t===e||t.isAncestorOf(e.uuid)||e.isAncestorOf(t.uuid))}disconnect(){sr(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.SwitchCamera.forEach(e=>{e.data.runMode==="Toggle"?e.toggle():e.play()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(!1)}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}},It;w8.then(e=>It=e);var Ei=new M,Fs=new lt,kn=new M,Av=new ji(0,0,0,"YXZ"),E2=new ji(0,0,0,"XYZ"),Us=new M,Mv=new M,Ev=new M(1,1,1),$l=new lt,bp=new we,C2=new we,Fie={type:"updateMatrix"},T2=new lt,Cv=new $r,Ly={type:"beginEvent",eventName:"Collision"},Uie={type:"beginEvent",eventName:"Trigger"};function Nie(e){if(Ad.physicsEnabled(e.scene.objects))return!0;let t=!1;return e.scene.objects.traverse((i,r)=>{if(r.events){if(Array.isArray(r.events)){for(let s of r.events)if(s.data.disabled!==!0&&s.data.type==="GameControl"&&s.data.collisionEnabled){t=!0;break}}else for(let s of Object.values(r.events))if(s.disabled!==!0&&s.type==="GameControl"&&s.collisionEnabled){t=!0;break}}}),t}var Hf=e=>e.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0),kie=class{constructor(e){this.eventContext=e,this.isEnabled=!1,this.gameControl=null,this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}},this.sensorToTriggerEvent={},this.eventManager=void 0,this.needsCollisionDetection=!1,this.initializationCounter=-1,this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.isExport=!1,this.skipRender=!0,this.processRigidBody=t=>{if(t.bodyType()!==It.RigidBodyType.Dynamic)return;t.isSleeping()||this.nActiveRigidBodies++;let[i,r,s]=this.rigidBodyToMesh.get(t.handle);if(Ei.copy(t.translation()).multiplyScalar(this.pixelsPerMeter),Fs.copy(t.rotation()),i.matrixWorld.compose(Ei,Fs,r),i.hasNonUniformScale&&i.matrixWorld.multiply(i.shearScale),i.dispatchEvent(Fie),s){let a=i.cloner;if(a&&a.objectForSample===void 0){a.matrixWorld.copy(i.matrixWorld);for(let n of a.children)n.updateMatrixWorld(!0)}for(let n of i.children)n.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(t,i,r)=>{var n,o,l,h;if(r===!1)return;let s,a;if(this.sensorToTriggerEvent[t]?(s=this.sensorToTriggerEvent[t],a=this.sharedGameControlGlobals.colliderToEntity.get(i)):this.sensorToTriggerEvent[i]&&(s=this.sensorToTriggerEvent[i],a=this.sharedGameControlGlobals.colliderToEntity.get(t)),s&&a&&s.isValidTriggeringObject(a)){s.dispatch();return}for(let c=this.sharedGameControlGlobals.createdObjects.length-1;c>=0;c--){let d=this.sharedGameControlGlobals.createdObjects[c];if(d.userData.hasCollisionDestroy&&(((n=d.rigidBody)==null?void 0:n.collider(0).handle)===t||((o=d.rigidBody)==null?void 0:o.collider(0).handle)===i)){this.sharedGameControlGlobals.createdObjects.splice(c,1),d.removeFromParent(),requestAnimationFrame(()=>{var u;return(u=this.sharedGameControlGlobals.rapierWorld)==null?void 0:u.removeRigidBody(d.rigidBody)});break}}if(((l=this.gameControl)==null?void 0:l.object)!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(t)){let c=this.sharedGameControlGlobals.colliderToEntity.get(i),d=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(d===void 0)return;for(let u of d)u.data.target==="character"&&this.dispatchCollisionEvent(u,c,i)}else if(((h=this.gameControl)==null?void 0:h.object)!==void 0&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(i)){let c=this.sharedGameControlGlobals.colliderToEntity.get(t),d=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(d===void 0)return;for(let u of d)u.data.target==="character"&&this.dispatchCollisionEvent(u,c,t)}else{let c=this.sharedGameControlGlobals.colliderToEntity.get(t),d=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(d!==void 0)for(let f of d)f.data.target==="scene"&&this.dispatchCollisionEvent(f,c,t);let u=this.sharedGameControlGlobals.colliderToEntity.get(i),p=this.sharedGameControlGlobals.entityToCollisionEvents[u==null?void 0:u.uuid];if(p!==void 0)for(let f of p)f.data.target==="scene"&&this.dispatchCollisionEvent(f,u,i)}},this.isExport=e.isExport,this.sharedAssets=e.sharedAssets,this.renderer=e.renderer,this.requestRender=e.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=KP,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}attachVRControllers(e){e.forEach(t=>{t.addEventListener("connected",i=>{"gamepad"in i.data&&"axes"in i.data.gamepad&&this.sharedGameControlGlobals.gamePads.push(i.data.gamepad)})})}markIsDestroyTarget(){this.page.traverseVisibleEntity(e=>{var i,r;let t=e.dataPatched;for(let s of t.events){if(s.data.disabled===!0)continue;let a=(r=(i=s.data.actions)==null?void 0:i.find(n=>n.data.type==="Destroy"))==null?void 0:r.data;if(a)for(let n of a.objects){let o=this.page.scene.find(n);o&&(o.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(e=>{let t=e.dataPatched;for(let i of t.events)if(!(i.data.disabled===!0||i.data.type!=="DragDrop"))for(let r of i.data.objects){let s=this.page.scene.find(r);s&&(s.userData.hasDrag=!0)}})}initBVH(){let e=[];if(this.page.traverseChildren(t=>{var h,c;let i,r=t instanceof id,s=t instanceof rd;if(t instanceof bs||r||s)return;t instanceof gr?i=t.object:i=t;let a=i.dataPatched;if(((h=a.physics)==null?void 0:h.enabled)==="visibility"?!a.visible:!((c=a.physics)!=null&&c.enabled))return!0;let n=t.geometry,o=i.userData.hasDestroy===!0,l=i.userData.hasDrag===!0;if(Hf(a)||o||l||i.dataPatched.events.some(d=>d.data.disabled!==!0&&(d.data.type==="GameControl"||d.data.type==="Follow")))return t.updateMatrixWorldSVD(),this.addBoundsTree(t),!0;n&&n.getAttribute("position").count>0&&e.push(tn(n,t.matrixWorld))}),e.length>0){let t=Qo(e,!1);this.sharedGameControlGlobals.staticMeshBVH=new ed(t)}}addRigidBody(e,t,i){if($P(e.matrixWorld))return;let r=[],s="geometry"in e?e.geometry:void 0,a=t.dataPatched;if((s==null?void 0:s.getAttribute("position"))!==void 0&&r.push(tn(s,e.shearScale)),a.physics.fusedBody){let n=this.gatherChildrenGeom(e,r);e.traverseObject(n),e.children.forEach(l=>l.updateMatrixWorld(!0));let o=e.cloner;o&&o.objectForSample===void 0&&a.physics.rigidBody==="dynamic"&&(o.traverseObject(n),o.children.forEach(l=>l.updateMatrixWorld(!0)))}if(r.length>0){let n,o=!i.fromCreate&&a.physics.rigidBody==="dynamic"||i.fromCreate&&i.dynamic;o?(n=It.RigidBodyDesc.dynamic(),n.setLinearDamping(a.physics.damping).setAngularDamping(a.physics.damping).setAdditionalMass(1e-9).setGravityScale(a.physics.gravityScale).enabledRotations(...a.physics.enabledRotation).enabledTranslations(...a.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(n=It.RigidBodyDesc.kinematicPositionBased(),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e)):n=It.RigidBodyDesc.fixed();let l=Qo(r);(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(Ei,Fs,kn),e.position0=Ei.clone().divideScalar(this.pixelsPerMeter),e.rotation0=Fs.clone(),Ei.divideScalar(this.pixelsPerMeter),n.setTranslation(Ei.x,Ei.y,Ei.z).setRotation(Fs),s?l==null||l.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):l==null||l.scale(kn.x/this.pixelsPerMeter,kn.y/this.pixelsPerMeter,kn.z/this.pixelsPerMeter);let h=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n);o&&this.rigidBodyToMesh.set(h.handle,[e,kn.clone(),a.physics.fusedBody]);let c=!(a.geometry===void 0||a.geometry.type==="SubdivGeometry"||a.geometry.type==="NonParametricGeometry"||a.geometry.type==="BooleanGeometry"||a.geometry.type==="VectorGeometry"||a.geometry.type==="StarGeometry"||a.geometry.type==="RectangleGeometry"||a.geometry.type==="EllipseGeometry"||a.geometry.type==="TriangleGeometry"||a.geometry.type==="TorusGeometry"||a.geometry.type==="HelixGeometry");try{this.addCollider(h,a.physics,l,t,c)}catch{try{this.addCollider(h,a.physics,l,t,!1)}catch(d){console.error(d)}}e.rigidBody=h}}addBoundsTree(e){var i,r;let t=[];if(((i=e.geometry)==null?void 0:i.getAttribute("position"))!==void 0&&((r=e.geometry)==null?void 0:r.getAttribute("position").count)>0&&t.push(tn(e.geometry,e.shearScale)),e.traverseObject(this.gatherChildrenGeom(e,t)),e.children.forEach(s=>s.updateMatrixWorld(!0)),t.length>0){let s=Qo(t,!1);e.bvhGeometry=s,s.getAttribute("position").count>0&&(e.bvhGeometry.boundsTree=new ed(s),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e))}}addCollider(e,t,i,r,s=!0){var o,l;if((i==null?void 0:i.getAttribute("position").count)===0||((o=i==null?void 0:i.getIndex())==null?void 0:o.count)===0)return;let a;i&&(t.colliderType==="trimesh"?a=It.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):a=It.ColliderDesc.convexMesh(i.getAttribute("position").array,s?i.getIndex().array:void 0)),a.setFrictionCombineRule(It.CoefficientCombineRule.Average).setRestitutionCombineRule(It.CoefficientCombineRule.Average).setDensity(t.density).setFriction(t.friction).setRestitution(t.restitution);let n=this.sharedGameControlGlobals.rapierWorld.createCollider(a,e);this.sharedGameControlGlobals.colliderToEntity.set(n.handle,r),(l=this.sharedGameControlGlobals.entityToCollisionEvents[r.uuid])!=null&&l.some(h=>h.target==="scene")&&n.setActiveEvents(It.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(e,t){return(i,r)=>{var o;if(r===0)return;let s;if(i instanceof bs)if(i.objectForSample){if(i.objectForSample.dataPatched.physics.fusedBody)return;s=i.object}else return i.object.dataPatched.physics.fusedBody===!0&&i.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(i instanceof gr)s=i.object;else if(s=i,(o=s.dataPatched.cloner)==null?void 0:o.hideBase)return!0;let a=s.dataPatched;if(a.physics.enabled==="visibility"?!a.visible:!a.physics.enabled)return!0;r===1?e.hasNonUniformScale?i.matrixWorld.multiplyMatrices(e.shearScale,i.hiddenMatrix):i.matrixWorld.copy(i.hiddenMatrix):i.matrixWorld.multiplyMatrices(i.parent.matrixWorld,i.hiddenMatrix),i.matrixWorld.multiply(i.matrix);let n=i.geometry;(n==null?void 0:n.getAttribute("position"))!==void 0&&t.push(tn(n,i.matrixWorld))}}activate(e){var u,p;if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=e,this.usePhysics=this.page.data.globalPhysics.usePhysics;let t=this.page.playCamera,i=!1,r=5,s=8,a=9,n="drag",o=this.page.data.publish.gameControlObject,l=o!==null?this.page.find(o):null,h=null;if(l)for(let f of l.data.events){if(f.data.disabled||f.data.type!=="GameControl")continue;let g=l;for(;this.usePhysics&&((u=g=g.parent)==null?void 0:u.parent)!==null;)(p=g.data.physics)==null||p.fusedBody;f.data.collisionEnabled&&(this.needsCollisionDetection=!0),h===null&&(h=f.data)}if(this.page.traverseEntity(f=>{for(let g of f.dataPatched.events)if(g.data.disabled===!1&&g.data.type==="Trigger")return this.needsCollisionDetection=!0,!0}),l&&h&&(l.data.visible===!0||l.data.physics.enabled===!0)){i=i||h.camera===t.uuid||l.uuid===t.uuid;let f=new JP(l,this.renderer.domElement,h,this.eventContext.page.data.globalPhysics,this,l.uuid!==t.uuid&&h.camera===t.uuid,t,this.page,this.sharedAssets);this.gameControl=f,r=h.joystickPosLoc,s=h.joystickRotLoc,a=h.jumpTouchButtonLoc,n=h.rotByTouch,ss&&h.touchControl&&(this.joystickToGameControls[r]="pos",h.moveMode==="walk"&&(this.joystickToGameControls[a]="jmp"),n==="joystick"&&(this.joystickToGameControls[s]="rot"))}if(this.gameControl&&this.gameControl.data.navmesh.enabled){let f=this.gameControl.data;if(!this.navigationMeshWrapper){this.navigationMeshWrapper=new Cie(this.usePhysics,this.isExport);let g;f.collider.type==="sphere"?g=f.collider.radius*2:g=f.collider.height,g=Math.floor(g/f.navmesh.ch-1),this.navigationMeshWrapper.init({...f.navmesh,walkableHeight:g},this.gameControl,this.eventContext)}}if(i===!1){let{enableRotate:f,enablePan:g,enableZoom:m,autoRotate:v,hoverRotatePanMode:y}=this.eventManager.publish.orbitControls;(f||g||m||v||y!==0)&&(this.orbitControls=new oD(t,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let c=this.renderer.domElement.width/this.renderer.getPixelRatio(),d=this.renderer.domElement.height/this.renderer.getPixelRatio();this.joystickToGameControls.forEach((f,g)=>{let m=document.body.appendChild(document.createElement("div")),[v,y,x]=this.eventManager.eventContext.publish.joystickSizeAndXYOffset[g],w=(c-5*v)/4+v,_={},b=f==="jmp",A=b?0:v;g<10?(g<5?_.top=A/2:_.bottom=A/2,_.left=A/2+g%5*w):g===10?(_.left=A/2,_.top=d/2):(_.right=A/2,_.top=d/2),_.top?_.top-=y[1]:_.bottom+=y[1],_.left?_.left+=y[0]:_.right-=y[0];for(let C in _)_[C]+="px";if(b){let C=m.appendChild(document.createElement("div"));Object.assign(C.style,_,{position:"absolute",width:v+"px",height:v+"px",backgroundColor:`rgba(255,255,255,${x==="show"?.4:0})`,zIndex:"9999",borderRadius:v+"px",border:x==="show"?"solid 2px rgba(0, 0, 0, .1)":"none",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"});let T=v/16*16*.4;x==="show"&&(C.innerHTML=`
  7368. <svg width="${T}" height="${v*.4}" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
  7369. <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
  7370. </svg>
  7371. `),C.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),C.addEventListener("touchend",D=>D.preventDefault()),this.joysticks[g]=[void 0,m];return}let S={zone:m,mode:"static",position:_,size:v};x==="hide"&&(S.restOpacity=0);let E=K$.create(S);E.on("move",(C,T)=>{let D=this.gameControl;f==="pos"?T.force<.2?D.moveForce=0:(D.movementState.movePosZ=Math.sin(-T.angle.radian),D.movementState.movePosX=Math.cos(-T.angle.radian),T.force>1.2?D.movementState.run=1:D.movementState.run=0,T.force<.3?D.moveForce=(T.force-.2)/.1:D.moveForce=1):f==="rot"&&(T.force<.2?D.rotForce=0:(D.movementState.rotPosX=T.vector.y,D.movementState.rotPosY=-T.vector.x,T.force<.3?D.rotForce=(T.force-.2)/.1:D.rotForce=1)),this.requestRender()}),E.on("end",(C,T)=>{let D=this.gameControl;f==="pos"?(D.movementState.movePosZ=0,D.movementState.movePosX=0,D.moveForce=1):f==="rot"&&(D.movementState.rotPosX=0,D.movementState.rotPosY=0,D.rotForce=1)}),this.joysticks[g]=[E,m]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(f=>f.initialDisabled=!1)},80)}initPhysics(){var n;(n=this.sharedGameControlGlobals.rapierWorld)==null||n.free(),this.sharedGameControlGlobals.rapierWorld=new It.World(new It.Vector3(0,this.gravity,0)),this.events=new It.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(o=>{var v,y,x,w;let l;if(o instanceof bs)if(o.objectForSample){if(o.objectForSample.dataPatched.physics.fusedBody)return;l=o.object}else return o.object.dataPatched.physics.fusedBody===!0&&o.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(o instanceof gr)l=o.object;else{if(o instanceof rd||o instanceof id)return;if(l=o,((v=l.dataPatched.cloner)==null?void 0:v.disabled)===!1&&((y=l.dataPatched.cloner)==null?void 0:y.hideBase)&&((x=l.dataPatched.physics)==null?void 0:x.fusedBody)!==!0)return!0}let h=l.dataPatched,c;for(let _ of h.events)_.data.disabled!==!0&&_.data.type==="GameControl"&&(c=_.data);if(!h.physics||(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled))return!0;o.updateMatrixWorldSVD();let d=Hf(h),u=!1,p=l.userData.hasDestroy,f=l.userData.hasDrag,g=!1;for(let _ of h.events)if(_.data.disabled!==!0){if(_.data.type==="Collision"){u=!0;let b=new gie(_.id,_.data,l,this.page,this.sharedAssets,this.eventManager);b.initialDisabled=!0,this.collisionEvents.push(b),this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].every(A=>A.id!==_.id)?this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].push(b):this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]=[b]}else if(_.data.type==="Follow"){g=!0;let b=_.data.target;o.traverseVisible(A=>{A.userData.isFollowingObj=b})}}h.physics.rigidBody==="dynamic"&&h.physics.fusedBody===!1&&(o.matrixWorldFusedFalse=o.matrixWorld.clone());let m=o.geometry;if(c!==void 0){let _=It.RigidBodyDesc.kinematicPositionBased();(o.hasNonUniformScale?o.matrixWorldRigid:o.matrixWorld).decompose(Ei,Fs,kn),o.position0=Ei.clone().divideScalar(this.pixelsPerMeter),o.rotation0=Fs.clone(),Ei.divideScalar(this.pixelsPerMeter),_.setTranslation(Ei.x,Ei.y,Ei.z).setRotation(Fs);let b=this.sharedGameControlGlobals.rapierWorld.createRigidBody(_);o.rigidBody=b;let A;c.collider.type==="sphere"?A=It.ColliderDesc.ball(c.collider.radius/this.pixelsPerMeter):c.collider.type==="capsule"?A=It.ColliderDesc.capsule((c.collider.height/2-c.collider.radius)/this.pixelsPerMeter,c.collider.radius/this.pixelsPerMeter):A=It.ColliderDesc.cuboid(c.collider.width/this.pixelsPerMeter/2,c.collider.height/this.pixelsPerMeter/2,c.collider.depth/this.pixelsPerMeter/2),A.setFrictionCombineRule(It.CoefficientCombineRule.Average).setRestitutionCombineRule(It.CoefficientCombineRule.Average).setDensity(h.physics.density).setFriction(h.physics.friction).setRestitution(h.physics.restitution);let S=this.sharedGameControlGlobals.rapierWorld.createCollider(A,b);this.sharedGameControlGlobals.colliderToEntity.set(S.handle,l),Ei.fromArray(c.collider.position).multiply(kn.setFromMatrixScale(l.matrixWorld)).divideScalar(this.pixelsPerMeter),S.setTranslationWrtParent(Ei);let E=new lt().setFromEuler(new ji().setFromVector3(new M().fromArray(c.collider.rotation)));S.setRotationWrtParent(E),S.setActiveEvents(It.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(l,!0)}else h.physics.rigidBody==="dynamic"||d||g||p||f||u?(this.addRigidBody(o,l,{hasFollow:g,hasTransformAnim:d,hasDrag:f}),this.generateSensorColliderDescs(l,h.physics.fusedBody)):(m&&e.push(tn(m,o.matrixWorld)),h.physics.fusedBody&&o.traverseObject((_,b)=>{var C;if(b===0)return;let A;if(_ instanceof bs)if(_.objectForSample){if(_.objectForSample.dataPatched.physics.fusedBody)return;A=_.object}else return _.object.dataPatched.physics.fusedBody===!0&&_.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else{if(_ instanceof rd||_ instanceof id)return;if(_ instanceof gr)A=_.object;else if(A=_,(C=A.dataPatched.cloner)==null?void 0:C.hideBase)return!0}let S=A.dataPatched;if(S.physics.enabled==="visibility"?!S.visible:!S.physics.enabled)return!0;let E=_.geometry;(E==null?void 0:E.getAttribute("position"))!==void 0&&e.push(tn(E,_.matrixWorld))}),this.generateSensorColliderDescs(l,h.physics.fusedBody,t));if(((w=h.physics)==null?void 0:w.fusedBody)===!0||c)return!0}),e.length===0)return;let i=Qo(e);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=It.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),a=It.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(It.CoefficientCombineRule.Multiply).setRestitutionCombineRule(It.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);for(let[o,l]of t){let h=this.sharedGameControlGlobals.rapierWorld.createCollider(o,s);this.sensorToTriggerEvent[h.handle]=l}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(e=>{for(let t of e.dataPatched.events)if(t.data.type==="Trigger"&&t.data.disabled!==!0){let i=new M2(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new we().compose(Us.fromArray(t.data.position),$l.setFromEuler(E2.fromArray(t.data.rotation)),Ev);if(t.data.triggerZone==="box"){let s=new Si;s.min.fromArray(t.data.size).multiplyScalar(-.5),s.max.fromArray(t.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){var e,t,i,r;if(this.isEnabled){this.isEnabled=!1,this.page.traverse(s=>{let a=s;a.matrixWorldFusedFalse&&(a.matrixWorldFusedFalse=void 0),a.rigidBody&&(a.rigidBody=void 0),a.position0&&(a.position0=void 0),a.rotation0&&(a.rotation0=void 0)}),(e=this.sharedGameControlGlobals.rapierWorld)==null||e.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.disconnectEvents(),(t=this.gameControl)==null||t.reset(),(i=this.gameControl)==null||i.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([s,a])=>{s==null||s.destroy(),a.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),(r=this.navigationMeshWrapper)==null||r.dispose(),this.navigationMeshWrapper=void 0;for(let s of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))s.forEach(a=>a.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(e,t,i){if(!this.isEnabled)return!0;let r=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),r=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,r=!1):this.initializationCounter===2&&this.gameControl&&(r=!this.gameControl.update(e,t,i)&&r),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let s=.016666666666666666;if(e===0)r=this.stepPhysics()&&r;else{let a=e/1e3;a<s&&a>s*.55&&(a=s),this.accumulator+=a;let n=performance.now(),o=0,l=6;for(;this.accumulator>=s&&o<l&&(r=this.stepPhysics()&&r,this.accumulator-=s,o++,!(performance.now()-n>s*1e3)););this.accumulator=this.accumulator%s}}this.skipRender=r}stepPhysics(){var e;for(let t of this.sharedGameControlGlobals.entitiesWithTransformAnim){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(Ei,Fs,kn),Av.setFromQuaternion(Fs);let i=t;i.prevR===void 0?(i.prevR=Av.clone(),i.prevT=Ei.clone()):(i.prevR.copy(Av),i.prevT.copy(Ei)),t.rigidBody&&(t.rigidBody.setNextKinematicTranslation(Ei.divideScalar(this.pixelsPerMeter)),t.rigidBody.setNextKinematicRotation(Fs))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),(e=this.events)==null||e.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(e,t,i){var a;let r=((a=this.sharedGameControlGlobals.rapierWorld)==null?void 0:a.getCollider(i))._parent,s;if(t.cloner){for(let n of t.cloner.children)if(n.rigidBody===r){s=n;break}}e.dispatch(s),t.dispatchEvent(Ly)}updateUseWindowEvents(e){var t;(t=this.orbitControls)==null||t.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=C2.copy(e.matrixWorld).invert();e.traverseEntity((s,a)=>{if(t===!1&&a===1)return!0;for(let n of s.dataPatched.events)if(n.data.type==="Trigger"&&n.data.disabled!==!0){let o=new M2(n.id,n.data,s,this.page,this.sharedAssets,this.eventManager),l;if(n.data.triggerZone==="box"?l=It.ColliderDesc.cuboid(...n.data.size.map(h=>h/(2*this.pixelsPerMeter))):l=It.ColliderDesc.ball(n.data.radius/this.pixelsPerMeter),l.setDensity(0).setSensor(!0).setActiveEvents(It.ActiveEvents.COLLISION_EVENTS),Us.fromArray(n.data.position),$l.setFromEuler(E2.fromArray(n.data.rotation)),bp.compose(Us,$l,Ev).premultiply(s.matrixWorld),i?(bp.decompose(Us,$l,Mv),l.setActiveCollisionTypes(It.ActiveCollisionTypes.KINEMATIC_FIXED|It.ActiveCollisionTypes.DYNAMIC_FIXED)):(bp.premultiply(r).decompose(Us,$l,Mv),e.rigidBody.bodyType()===It.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===It.RigidBodyType.Fixed?l.setActiveCollisionTypes(It.ActiveCollisionTypes.KINEMATIC_FIXED|It.ActiveCollisionTypes.DYNAMIC_FIXED):l.setActiveCollisionTypes(It.ActiveCollisionTypes.KINEMATIC_KINEMATIC|It.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Us.divideScalar(this.pixelsPerMeter),l.setTranslation(Us.x,Us.y,Us.z),l.setRotation($l),i)i.push([l,o]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(l,e.rigidBody);this.sensorToTriggerEvent[h.handle]=o}}})}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,s,a]=this.sharedGameControlGlobals.triggers[t];for(let n=0;n<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;n++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[n];if(s===o||a.isValidTriggeringObject(Tt.is(o)?o:o.object)===!1)continue;let l=C2.copy(s.matrixWorld).decompose(Us,T2,Mv).compose(Us,T2,Ev).multiply(r),h=bp.copy(o.matrixWorld).invert().multiply(l);i instanceof Si?e=o.bvhGeometry.boundsTree.intersectsBox(i,h):(Cv.radius=i,Cv.center.setFromMatrixPosition(h),e=o.bvhGeometry.boundsTree.intersectsSphere(Cv)),e?a.currentIntersectedObjects.indexOf(o)===-1&&(a.currentIntersectedObjects.push(o),a.dispatch(),s.dispatchEvent(Uie)):a.currentIntersectedObjects=a.currentIntersectedObjects.filter(c=>c!==o)}}}};function Vie(e){let t=this._clip.duration,i=this._clip.start??0,r=this.loop,s=this.time+e,a=this._loopCount,n=r===Ny;if(e===0)return a===-1?s:n&&(a&1)===1?t-(s-i):s;if(r===iM){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,n)):this._setEndings(this.repetitions===0,!0,n)),s>=t||s<i){let o=Math.floor((s-i)/(t-i));s-=(t-i)*o,a+=Math.abs(o);let l=this.repetitions-a;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n||(s=e>0?t:i,this.repetitions===1&&(s=t)),this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let h=e<0;this._setEndings(h,!h,n)}else this._setEndings(!1,!1,n);this._loopCount=a,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=s;if(n&&(a&1)===1)return t-(s-i)}return s}var P2=!1,jie=class{constructor(e,t,i,r){this.scene=e,this.requestRender=t,this.updateDisplayProgress=i,this.animationInspectorState=r,this.clipIdToAction={},this.activeClip=null,this.needsUpdate=!1,this.addClip=s=>{s.data.type==="Empty"&&s.data.animations&&s.data.animations.forEach((a,n)=>{let o=a[0]+"/";if(Array.isArray(s.identity)?o+=s.identity[0]:o+=s.uuid,this.clipIdToAction[o])return;let l=Vv.parse(JSON.parse(a[2]));s.animations[n]=l;let h=this.mixer.clipAction(l,s);P2===!1&&(Object.getPrototypeOf(h)._updateTime=Vie,P2=!0),h.clampWhenFinished=!0,this.clipIdToAction[o]=h})},this.mixer=new QU(e),this.scene.traverseEntity(this.addClip)}deleteClip(e,t){let i=this.scene.find(t);if(!i)return;let r=i.animations.find(a=>a.uuid===e);if(!r)return;let s=this.clipIdToAction[e];!s||(s.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[e],i.animations=i.animations.filter(a=>a.uuid!==e))}get isPlaying(){return Object.values(this.clipIdToAction).some(e=>e.isRunning())}playFromInspector(e){this.mixer.stopAllAction();let t=this.clipIdToAction[e];!t||(t.play(),this.activeClip=t.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(e=>{e.repetitions=1/0,e.loop=rM}),this.mixer.stopAllAction(),this.requestRender()}play(e){let t=e.clipId+"/"+e.object,i=this.clipIdToAction[t];if(i)return e&&(e.repeat>=0&&(i.repetitions=e.repeat+1),e.direction==="pingpong"&&e.repeat!==0&&(i.loop=Ny)),i.play(),i.paused=!1,this.requestRender(),i}resumeFromInspector(e){let t=this.clipIdToAction[e];!t||(t.play(),t.paused=!1,this.requestRender())}pauseFromInspector(e){let t=this.clipIdToAction[e];!t||(t.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(e){var t;if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||(t=this.animationInspectorState)!=null&&t.isScrubbing)return;this.mixer.update(e/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*(this.maxFrames-1)%(this.maxFrames-1))),this.requestRender()}get maxFrames(){return GP(this.activeClip??void 0)}setProgressFromInspector(e,t){if(!this.clipIdToAction[t])return;this.activeClip!==this.clipIdToAction[t].getClip()&&this.playFromInspector(t);let i=this.clipIdToAction[t].paused;this.clipIdToAction[t].paused=!1,this.mixer.setTime(Math.min(e/(this.maxFrames-1),.9999)*this.activeClip.duration),this.requestRender(),i&&(this.clipIdToAction[t].paused=!0)}},Tv=new WeakMap,Gie=class extends Fd{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){let s=new jv(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,a=>{this.decodeDracoFile(a,t).catch(r)},i,r)}decodeDracoFile(e,t,i,r){let s={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i};return this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){let i=JSON.stringify(t);if(Tv.has(e)){let o=Tv.get(e);if(o.key===i)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,a=e.byteLength,n=this._getWorker(s,a).then(o=>(r=o,new Promise((l,h)=>{r._callbacks[s]={resolve:l,reject:h},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return n.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),Tv.set(e,{key:i,promise:n}),n}_createGeometry(e){let t=new Ge;e.index&&t.setIndex(new tt(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let r=e.attributes[i],s=r.name,a=r.array,n=r.itemSize;t.setAttribute(s,new tt(a,n))}return t}_loadLibrary(e,t){let i=new jv(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,s)=>{i.load(e,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{let r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);let s=Hie.toString(),a=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
  7372. `);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let a=s.data;switch(a.type){case"decode":r._callbacks[a.id].resolve(a);break;case"error":r._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function Hie(){let e,t;onmessage=function(n){let o=n.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(c){e.onModuleLoaded=function(d){c({draco:d})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(c=>{let d=c.draco,u=new d.Decoder,p=new d.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(d,u,p,h),g=f.attributes.map(m=>m.array.buffer);f.index&&g.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},g)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{d.destroy(p),d.destroy(u)}});break}};function i(n,o,l,h){let c=h.attributeIDs,d=h.attributeTypes,u,p,f=o.GetEncodedGeometryType(l);if(f===n.TRIANGULAR_MESH)u=new n.Mesh,p=o.DecodeBufferToMesh(l,u);else if(f===n.POINT_CLOUD)u=new n.PointCloud,p=o.DecodeBufferToPointCloud(l,u);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||u.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let g={index:null,attributes:[]};for(let m in c){let v=self[d[m]],y,x;if(h.useUniqueIDs)x=c[m],y=o.GetAttributeByUniqueId(u,x);else{if(x=o.GetAttributeId(u,n[c[m]]),x===-1)continue;y=o.GetAttribute(u,x)}g.attributes.push(s(n,o,u,m,v,y))}return f===n.TRIANGULAR_MESH&&(g.index=r(n,o,u)),n.destroy(u),g}function r(n,o,l){let h=l.num_faces()*3,c=h*4,d=n._malloc(c);o.GetTrianglesUInt32Array(l,c,d);let u=new Uint32Array(n.HEAPF32.buffer,d,h).slice();return n._free(d),{array:u,itemSize:1}}function s(n,o,l,h,c,d){let u=d.num_components(),p=l.num_points()*u,f=p*c.BYTES_PER_ELEMENT,g=a(n,c),m=n._malloc(f);o.GetAttributeDataArrayForAllPoints(l,d,g,f,m);let v=new c(n.HEAPF32.buffer,m,p).slice();return n._free(m),{name:h,array:v,itemSize:u}}function a(n,o){switch(o){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}var ro;function Wie(e){return ro||(ro=new Gie,ro.setDecoderPath(e?`${e}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ro.decoderPending}async function qie(e){if(ro){let t={attributeIDs:ro.defaultAttributeIDs,attributeTypes:ro.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await ro.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))}}return null}async function Xie(e,t){let[i,r]=ZE(a0.deserialize(new Uint8Array(e)));return wC(i),t&&t(i),r.result().data}function Yie(e){let t=[];return e.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function Qie(e){for(let t of e){let i=await qie(t.geometry.data.draco);if(i){let r=t.geometry.data;i.index&&(r.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};i.attributes.forEach(({name:a,array:n,itemSize:o})=>{s[a]={array:n,itemSize:o,type:"Float32Array",normalized:!1}}),r.attributes=s,r.draco=void 0}}}var Zie=class{constructor(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0],this._delay=500,this._distance=2,this._onMouseDown=e=>{let t=[e.clientX,e.clientY],i=new Date().getTime();if(this._clickCount>0){let r=t[0]-this._lastPosition[0],s=t[1]-this._lastPosition[1];Math.sqrt(r*r+s*s)>this._distance&&(this._clickCount=0)}this._lastPosition=t,this._clickCount=i-this._lastTime>this._delay?1:this._clickCount+1,this._lastTime=i},this._onMouseUp=e=>{}}start(e,t=500,i=2){this._target&&this.stop(),this.reset(),this._delay=t,this._distance=i,this._target=e,this._target.addEventListener("pointerdown",this._onMouseDown,!1),this._target.addEventListener("pointerup",this._onMouseUp,!1)}stop(){this._target&&(this._target.removeEventListener("pointerdown",this._onMouseDown,!1),this._target.removeEventListener("pointerup",this._onMouseUp,!1),this._target=void 0)}get clickCount(){return this._clickCount}reset(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0]}},Kie=class{constructor(e,t,i,r,s,a,n,o){this.eventId=e,this.id=t,this.data=i,this.dataEvent=r,this.object=s,this.stage=!1,this.actions=Li(r,i.actions,a,n,o,s)}disconnect(){sr(this.actions)}dispatchIn(){this.actions.Audio.forEach(e=>e.dispatchBasic()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Video.forEach(e=>e.dispatchBasic()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.Link.forEach(e=>e.dispatch()),this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.actions.Transition.forEach(e=>e.toggle()),this.actions.Animation.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>e.play()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},Jie=class extends Pr{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.resize=(i,r)=>{this.breakpoints.forEach(s=>{let a=h0.deviceToSize(s.data.size),n=s.dataEvent.orientation==="horizontal"?i:r,o;switch(s.data.operator){case"<":o=n<a[0];break;case">":o=n>a[0];break;case"<>":o=n>a[0]&&n<a[1];break}s.stage!==o&&(s.stage=o,s.stage?s.dispatchIn():s.dispatchOut())})},this.onResizeObserver=new ResizeObserver(i=>{for(let r of i){let{width:s,height:a}=r.contentRect;this.resize(s,a)}})}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext;this.onResizeObserver.observe(i);let r=s=>{var a;if(!(!s.visible||!((a=s.data)!=null&&a.events.length)))for(let{data:n,id:o}of s.data.events)n.disabled||n.type==="Resize"&&n.breakpoints.forEach(({data:l,id:h})=>{try{let c=new Kie(o,h,l,n,s,e,t,this.eventManager);this.breakpoints.push(c)}catch{}})};e.traverseEntity(s=>{var a;(s instanceof Sr||s instanceof $i)&&((a=s.frame)==null||a.traverse(n=>{r(n)})),r(s)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}},$ie=class extends Pr{constructor(e,t){super(e),this.eventManager=t,this.userAPIs={},this.events=[],this.onSuccess=({userAPIId:i})=>{this.events.forEach(r=>{r.data.userAPIId===i&&r.dispatchSuccess()})},this.onError=({userAPIId:i})=>{this.events.forEach(r=>{r.data.userAPIId===i&&r.dispatchError()})},this.userAPIs=e.sharedAssets.getUserAPIs()}connect(){this.eventContext.page.traverseEntity(e=>{var t;(t=e.data)==null||t.events.filter(i=>i.data.type==="API"&&!i.data.disabled).forEach(i=>{this.events.push(new ere(i.id,i.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userAPIs).forEach(([e,t])=>{t.on("success",this.onSuccess),t.on("error",this.onError),t.autostart&&t.callUserAPI(this.eventContext.sharedAssets)})}disconnect(){Object.entries(this.userAPIs).forEach(([e,t])=>{t.off("success",this.onSuccess),t.off("error",this.onError)})}},ere=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.successActions=Li(t,t.successActions,r,s,a,i),this.errorActions=Li(t,t.errorActions,r,s,a,i)}dispatchSuccess(){this.dispatchActions(this.successActions)}dispatchError(){this.dispatchActions(this.errorActions)}dispatchActions(e){e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}},tre=class extends Pr{constructor(e,t){super(e),this.eventManager=t,this.userWebhooks={},this.events=[],this.onMessage=({userWebhookId:i})=>{this.events.forEach(r=>{r.data.userWebhookId===i&&r.dispatch()})},this.userWebhooks=e.sharedAssets.getUserWebhooks()}connect(){this.eventContext.page.traverseEntity(e=>{var t;(t=e.data)==null||t.events.filter(i=>i.data.type==="WEBHOOK"&&!i.data.disabled).forEach(i=>{this.events.push(new ire(i.id,i.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userWebhooks).forEach(([e,t])=>{t.connect(),t.on("message",this.onMessage)})}disconnect(){Object.entries(this.userWebhooks).forEach(([e,t])=>{t.off("message",this.onMessage),t.disconnect()})}},ire=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Li(t,t.actions,r,s,a,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}};function rre(){let e=document.createElement("textarea");return e.style.position="fixed",e.style.top="200px",e.style.left="400px",e.style.zIndex="-1",e.style.border="1px solid rgba(255,0,0,0.5)",e.style.width="10px",e.style.height="500px",e.style.color="white",e.style.opacity="0.5",e.style.background="transparent",e.style.display="none",e.style.margin="0px",e.style.padding="0px",e.style.boxSizing="content-box",e.style.pointerEvents="none",e}var sre=new M(0,0,1),D2=new M,I2=new M,O2=new Di,are=class{constructor(e,t,i,r,s){this.containerScene=e,this.raycaster=t,this.sharedAssets=i,this.requestRender=r,this.onExit=s,this.htmlInput=null,this.virtualInput=null,this.helper=new QT,this.doubleClickHandler=new Zie,this.isDragging=!1,this.plane=new qr,this.caretInterval=0,this.planeIntersection=new M,this.projected=new j,this._lastIndex=0,this._isFirstDragMove=!1,this.selectionOnDragStart=0,this.onTextMaterialChanged=()=>{var n;let a=(n=this.virtualInput)==null?void 0:n.data;if(this.virtualInput!==void 0&&a){let o=a.material,l=typeof o=="string"?this.sharedAssets.data.materials[o]:o,h=pJ(l,this.sharedAssets);this.helper.setCaretColor(h)}},this.stopAnimateTextCursor=()=>{clearInterval(this.caretInterval),this.helper&&(this.helper.caretMesh.visible=!1)},this.startAnimateTextCursor=()=>{this.stopAnimateTextCursor(),this.helper&&(this.helper.caretMesh.visible=!0,this.caretInterval=setInterval(()=>{this.helper&&(this.helper.caretMesh.visible=!this.helper.caretMesh.visible),this.requestRender()},600))},this.handleCaretUpdate=a=>{if(!this.htmlInput||!this.virtualInput)return;let n=this.helper,o=(a==null?void 0:a.key)==="ArrowLeft"||(a==null?void 0:a.key)==="ArrowRight",l=(a==null?void 0:a.key)==="ArrowUp"||(a==null?void 0:a.key)==="ArrowDown";this.htmlInput.selectionStart===this.htmlInput.selectionEnd?(n.setCaretPosition(this.htmlInput.selectionStart,{horizontalKeyMove:o,verticalKeyMove:l}),this.startAnimateTextCursor()):n.setSelection(this.htmlInput.selectionStart,this.htmlInput.selectionEnd),this.requestRender()},this.containerScene.add(this.helper)}createInput(){return this.htmlInput=rre(),this.htmlInput}connect(){}disconnect(){var e;this.stopAnimateTextCursor(),this.helper.hide(),(e=this.htmlInput)==null||e.remove(),this.doubleClickHandler.stop()}handleMouseDown(){var a,n;if(!this.htmlInput||!this.virtualInput)return!0;this.getPointOnPlane();let e=this.doubleClickHandler.clickCount,{index:t,lineIndex:i,characterIndex:r}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,e>1?"inside":"previous")??{index:0,lineIndex:0,characterIndex:0};(n=(a=this.virtualInput)==null?void 0:a.wrappedText)!=null&&n.length&&this.virtualInput.wrappedText[i][Math.max(0,r-1)]===`
  7373. `&&(t--,r--),this._lastIndex=t,this._isFirstDragMove=!0;let s=this.checkClickedObject();if(e===1){if(s===null)return this.onExit(this.virtualInput),!0;this.selectionOnDragStart=t,this.isDragging=!0,this.setInputSelection(t)}else s===this.virtualInput&&(e===2?this.selectClosestWord(i,r):e>2&&(this.setInputSelection(0,this.htmlInput.value.length),this.doubleClickHandler.reset()))}handleMouseUp(){this.applyRangeToTextInput(),this.isDragging=!1,this._isFirstDragMove=!1}handleMouseMove(){!this.virtualInput||(this._isFirstDragMove&&this.doubleClickHandler.clickCount>1&&(this.selectionOnDragStart=this._lastIndex,this.isDragging=!0,this.setInputSelection(this._lastIndex)),this._isFirstDragMove=!1,this.getPointOnPlane(),this.applyRangeToTextInput())}focus(e){var t;if(this.virtualInput=e,this.updateTextInputStyles(),this.htmlInput)if(e){let i=(t=this.data)==null?void 0:t.geometry.text;this.htmlInput.value=typeof i=="string"?"":(i==null?void 0:i.textValue.toString())??""}else this.htmlInput.value=""}blur(){}get data(){let{virtualInput:e}=this;if(e)return e.dataPatched}applyRangeToTextInput(){var s;if(!this.isDragging||!this.virtualInput||!this.htmlInput)return;let e=this.selectionOnDragStart,{index:t,lineIndex:i,characterIndex:r}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,this.doubleClickHandler.clickCount>2?"inside":"previous")??{index:0};i!==void 0&&r!==void 0&&((s=this.virtualInput)==null?void 0:s.wrappedText[i][r-1])===`
  7374. `&&t--,this.htmlInput.setSelectionRange(Math.min(e,t),Math.max(e,t))}checkClickedObject(){if(this.virtualInput){let e=this.raycaster.intersectObject(this.virtualInput,!1);if(e.length>0){let t=e[0];if(t.object instanceof rx)return t.object}}return null}selectClosestWord(e,t){if(!this.virtualInput)return;let i=this.virtualInput.wrappedText,r=i[e],s=t+1,a=t;r[t]!==" "&&(s=this.findNextCharOccurence(r,t,"forward"," "),a=this.findNextCharOccurence(r,t,"backward"," "),a>0&&a++,s>=r.length-1&&e===i.length-1&&s++);let n=this.helper,o=n.getGlobalIndexFromLineAndCharIndexes(i,e,a),l=n.getGlobalIndexFromLineAndCharIndexes(i,e,s);this.setInputSelection(o,l)}findNextCharOccurence(e,t,i,r=" "){let s=Math.max(0,e.length-1),a=i==="forward"?s:0,n=i==="forward"?1:-1,o=Math.max(Math.min(t,s),0);for(;o!==a;)if(o+=n,e.charAt(o)===r)return o;return a}getPointOnPlane(){var t;let e=(t=this.virtualInput)==null?void 0:t.data;if(!(!this.virtualInput||!e)&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new M);let i=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(i){this.planeIntersection.copy(this.virtualInput.worldToLocal(i));let r=typeof e.geometry.width=="number"?e.geometry.width:1,s=typeof e.geometry.height=="number"?e.geometry.height:1;this.projected.set(i.x+r*.5,i.y-s*.5)}}}updatePlane(){var t;let e=(t=this.virtualInput)==null?void 0:t.data;this.virtualInput&&e&&(O2.getNormalMatrix(this.virtualInput.matrixWorld),D2.copy(sre).applyMatrix3(O2).normalize(),this.virtualInput.localToWorld(I2.set(0,0,e.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(D2,I2))}setInputSelection(e,t=e){var i,r;(i=this.htmlInput)==null||i.setSelectionRange(e,t),ec&&((r=this.htmlInput)==null||r.focus()),setTimeout(()=>{var s;(s=this.htmlInput)==null||s.focus()})}updateTextInputStyles(){var t;let e=(t=this.virtualInput)==null?void 0:t.data;this.virtualInput&&e&&this.htmlInput&&(this.htmlInput.style.fontSize=e.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=e.geometry.letterSpacing*e.geometry.fontSize+"px",this.htmlInput.style.lineHeight=e.geometry.fontSize*e.geometry.lineHeight+"px",this.htmlInput.style.width=e.geometry.width+"px",this.htmlInput.style.height=e.geometry.height+"px",this.htmlInput.style.textAlign=nre(e.geometry.horizontalAlign))}};function nre(e){return e===4?"justify":e===2?"right":e===3?"center":"left"}var lD=(e,t)=>{if(typeof e=="string"){let i=t.data(e);if(i)return lD(i.value,t)}return mr.getDisplayedValue(e)};function R2(e,t){let i=e.text,r="";if(typeof i=="string"){let s=t.variables.data(r);s&&(r=lD(s.value,t.variables))}else r=i.textValue.toString();return r}var ore=class extends Pr{constructor(e,t){super(e),this.eventManager=t,this._textInputs=[],this.sceneHelpers=new Jr,this.helper=new QT,this._onMouseDownFocusIn=i=>{if(at.length>1)return;this.eventContext.updateRaycaster(i);let r=null;if(this.eventContext.raycaster){for(let s of this._textInputs)if(this.eventContext.raycaster.intersectObject(s,!0).length>0){r=s;break}}this.focusOnTextInput(r),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(i),this._onMouseDown(i)},this.onExit=()=>{let{virtualInput:i}=this.textInputManager;if(i===null)return;let r=this.textInputManager.htmlInput;this.helper.hide(),r==null||r.setSelectionRange(r.value.length,r.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:s}=this.eventContext;s.removeEventListener("pointerdown",this._onMouseDown,!1),s.removeEventListener("pointerup",this._onMouseUp,!1),s.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),s.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()},this._onMouseDown=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)},this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)},this._onMouseMove=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseMove()},this._onTextEdit=i=>{let{htmlInput:r,virtualInput:s,helper:a}=this.textInputManager;if(!r||!s)return;let n=r.value;s.textGeometry.setText(n,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let o=s.data;a.update();let l=o.geometry.text;if(typeof l=="string"){let h=l;this.eventContext.sharedAssets.updateVariable(h,{textValue:n})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()},this._onCaretUpdate=i=>{this.textInputManager.handleCaretUpdate(i)},this._onKeyPress=i=>{i.key==="Escape"&&this.onExit()},this.textInputManager=new are(this.sceneHelpers,e.raycaster,e.sharedAssets,e.requestRender,this.onExit)}connect(){let e=[];if(this.eventContext.scene.traverseEntity(r=>{r instanceof rx&&e.push(r)}),this._textInputs=e,e.length===0)return;let{domElement:t}=this.eventContext;t.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let e=this.textInputManager.htmlInput,{domElement:t,sharedAssets:i}=this.eventContext;t.removeEventListener("pointerdown",this._onMouseDownFocusIn),e==null||e.removeEventListener("keyup",this._onCaretUpdate),e==null||e.removeEventListener("keydown",this._onCaretUpdate),e==null||e.removeEventListener("beforeinput",this._onCaretUpdate),e==null||e.removeEventListener("paste",this._onCaretUpdate),e==null||e.removeEventListener("cut",this._onCaretUpdate),e==null||e.removeEventListener("select",this._onCaretUpdate),e==null||e.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(r=>{let s=R2(r.data.geometry,this.eventContext.sharedAssets.data);r.textGeometry.setText(s,i)}),t.removeEventListener("pointerdown",this._onMouseDown,!1),t.removeEventListener("pointerup",this._onMouseUp,!1),t.removeEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(e){this.textInputManager.focus(e),this.textInputManager.onTextMaterialChanged();let t=this.textInputManager.htmlInput;if(!t||e===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=R2(e.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);t.value=i,t.setSelectionRange(0,0),this.textInputManager.helper.show(e),t.style.display="block",t.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:r}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDownFocusIn),r.addEventListener("pointerdown",this._onMouseDown,!1),r.addEventListener("pointerup",this._onMouseUp,!1),r.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}},lre=class extends Pr{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onVoice=({value:i,frequencies:r})=>{this.events.forEach(s=>{s.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{var t;(t=e.data)==null||t.events.filter(i=>i.data.type==="AIAssistantListener"&&!i.data.disabled).forEach(i=>{this.events.push(new hre(i.id,i.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){var e;(e=this.openAIRealtime)==null||e.off("voice",this.onVoice)}},hre=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Li(t,t.actions,r,s,a,i)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(e){e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}},cre=class extends Pr{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onTriggerEvent=({description:i,direction:r})=>{let s=this.events.find(a=>a.data.description===i);s&&(r==="backward"?s.dispatchReverse():s.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{var t;(t=e.data)==null||t.events.filter(i=>i.data.type==="AIAssistantTrigger"&&!i.data.disabled).forEach(i=>{this.events.push(new dre(i.id,i.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){var e;(e=this.openAIRealtime)==null||e.off("trigger_event",this.onTriggerEvent)}},dre=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Li(t,t.actions,r,s,a,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}dispatchReverse(){let e=this.actions;e.Transition.forEach(t=>t.reverseFromCurrent()),e.Particles.forEach(t=>t.reverseFromCurrent()),e.Animation.forEach(t=>t.reverseFromCurrent()),e.SwitchCamera.forEach(t=>t.reverseFromCurrent()),e.Create.forEach(t=>t.dispatchStop())}},ure=class{constructor(e,t,i,r,s){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.sharedVariables=s,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onTouchMovePreventScroll=a=>{let n=window.parent!==window,o=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(a.touches.length>1||this.preventTouchScroll||n===!1&&o===!1)&&a.preventDefault()},this.onMouseWheelPreventScroll=a=>{this.preventScroll&&a.preventDefault()},this.onMouseMove=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:a.buttons>0}},this.onMouseDown=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!0}},this.onMouseUp=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!1}},this.getMousePosition=a=>{var h;let{domRect:n}=this.eventContext,{pageX:o,pageY:l}=((h=a.touches)==null?void 0:h.length)>0?a.touches[0]:a;return{x:o-(n.left+window.scrollX),y:l-(n.top+window.scrollY)}},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(e=!1){var r;if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new Nte(this.eventContext),VariableChange:new vie(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),API:new $ie(this.eventContext,this),WEBHOOK:new tre(this.eventContext,this),AIAssistantListener:new lre(this.eventContext,this),AIAssistantTrigger:new cre(this.eventContext,this),Conditional:new qte(this.eventContext,this),Start:new mie(this.eventContext,this),Basic:new Vte(this.eventContext,this,this.needsRaycast),MouseHover:new cie(this.eventContext,this),Scroll:new pie(this.eventContext,this),Follow:new iie(this.eventContext,this),DragDrop:new Kte(this.eventContext,this),LookAt:new oie(this.eventContext),Resize:new Jie(this.eventContext,this),Textfields:new ore(this.eventContext,this)};let{page:t,domElement:i}=this.eventContext;this.hideCursor&&(i.style.cursor="none"),t.traverseEntity(s=>{s.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(s=>s.connect()),i.addEventListener("wheel",this.onMouseWheelPreventScroll),i.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++,e||((r=this.eventContext.sharedAssets.openAIRealtime)==null||r.connect())}deactivate(e=!1){var r,s;if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:t,domElement:i}=this.eventContext;i.style.cursor="",Object.values(this.handlers).forEach(a=>a.disconnect()),(r=this.controlsManager.gameControl)==null||r.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(a=>{a.removeEventListener("requestRender",this.requestRender),a.destroyedInAction=!1}),i.removeEventListener("touchmove",this.onTouchMovePreventScroll),i.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode(),e||((s=this.eventContext.sharedAssets.openAIRealtime)==null||s.disconnect())}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(!0),this.activate(!0),this.controlsManager.deactivate(),this.controlsManager.activate(this),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}initializeActionsDependentStates(){let e=this.eventContext.sharedAssets;e.resetDynamicVariablePlayState();let t=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(t),i.data.elseActions.forEach(t)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&e.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{var r;if((r=i.data)!=null&&r.events.length)for(let s of i.data.events)if(s.data.type==="VariableChange"&&(s.data.variableId==="mouseProperty"&&(this.needsMouse=!0),s.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),s.data.type==="Conditional")for(let a of["inActions","outActions"])s.data[a].forEach(t);else if(s.data.type==="DragDrop")for(let a of["drag","drop"])s.data.dragDropActions[a].forEach(t);else if(s.data.type==="GameControl")for(let a of["idle","move","jump","run"])s.data.gameActions[a].forEach(t);else if(s.data.type==="Resize")for(let a of s.data.breakpoints)a.data.actions.forEach(t);else s.data.type==="LookAt"||s.data.type==="API"||s.data.actions.forEach(t)})}},pre=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new j().copy(i),this._editorSize=new j().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let s=fre(t,1080,2160,1,15)/100;r*=t/i,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function fre(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var mre=class{get sharedAssets(){return this.shared}constructor(e,t={},i=!0){this.shared=new q1(e.shared,t,!0,i),this.scene=new nx(e.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof $i&&!e.uiScene&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Ii&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},gre=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){var e;(e=this.element.parentElement)==null||e.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function vre(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function hd(e){return e instanceof Id?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function yre(e,t){let i={};return e.traverseEntity(r=>{var l;if(!r.visible||!(r instanceof Vr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof Vr&&r.states&&Object.keys(r.states).length)return;s=s.parent}let a=r.material.uuid,n=t.shared.materials[a];if(n){if(!ir.isMergable(n))return}else{let h=(l=t.scene.objects.get(r.uuid))==null?void 0:l.data;if(h&&"material"in h&&typeof h.material!="string"){if(!ir.isMergable(h.material))return;a=ir.getHash(h.material)}}i[a]||(i[a]={});let o=i[a][hd(r)];if(o){if(o.push(r),r.cloner)for(let h of r.cloner.children)o.push(h)}else if(i[a][hd(r)]=[r],r.cloner)for(let h of r.cloner.children)i[a][hd(r)].push(h)}),i}function xre(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function bre(e,t){let i=yre(t,e),r=xre(i),s=new Array(r),a=0,n=new Array(r),o=0,l=new Array(r),h=0,c=new Array(r),d=0;for(let[u,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(m=>{m instanceof Vr&&(n[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),n[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&vre(n[m]);let g=Qo(n.slice(0,o),!1);if(g){let m;switch(u){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new Jt(g,l[0].material);break}default:{m=new Jt(g,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let v=y=>{d=0;for(let x of y)x.children&&v(x.children),x instanceof Vr&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][hd(x)]&&i[x.material.uuid][hd(x)].length>1||(c[d++]=x));for(let x=0;x<d;x++)t.attach(c[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[a++]=x}}}for(let u=0;u<a;u++)s[u].removeFromParent()}var wre=xo(RO(),1),_re=new j;function Sre(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}function L2(e){let t=new vr(0,0,0,1);try{t.setStyle(e)}catch(i){console.error(i)}finally{return t}}var Are=class{constructor(e,{renderOnDemand:t,renderMode:i="auto",wasmPath:r}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=s=>{var a,n,o,l,h,c,d,u,p,f,g,m,v;if(this.time=s,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,(a=this._perfs)==null||a.start(),!this._renderer){(n=this._perfs)==null||n.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){(o=this._perfs)==null||o.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&((l=this._eventManager.handlers)!=null&&l.Start.hasVideoAction||(h=this._eventManager.handlers)!=null&&h.Basic.hasVideoAction||(c=this._eventManager.handlers)!=null&&c.Conditional.hasVideoAction)&&(this._skipRender=!1),(d=this._animationControls)==null||d.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,(u=this._scene)==null||u.traverseVisibleEntity(y=>{y.type==="ParticleSystem"&&(y.update(this.dt),this._skipRender=!1)}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),(p=this._eventManager)!=null&&p.isEnabled&&(((f=this._eventManager.handlers)==null?void 0:f.Follow).onAnimationFrameDamping(),((g=this._eventManager.handlers)==null?void 0:g.LookAt).onAnimationFrameDamping(),((m=this._eventManager.handlers)==null?void 0:m.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let y=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=y,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),(v=this._perfs)==null||v.end()},this._resize=s=>{var a,n,o,l,h,c,d,u,p,f;if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=_re.set(this._viewportWidth,this._viewportHeight)),s){let g=this._viewportWidth,m=this._viewportHeight;this._renderer.setSize(g-1,m-1,!1),this._renderer.setSize(g,m,!1)}else this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1);if(this._camera=(a=this._scene)==null?void 0:a.activeCamera,(d=this._scene)==null||d.updateViewPlaneSize(((o=(n=this._frameView)==null?void 0:n.frameSize)==null?void 0:o.x)??this._viewportWidth,((h=(l=this._frameView)==null?void 0:l.frameSize)==null?void 0:h.y)??this._viewportHeight,((c=this._frameView)==null?void 0:c.enableResponsive)??!1),this._camera){let g=Object.values(((u=this._data)==null?void 0:u.frames)??{})[0].preset??"fullscreen";(p=this._frameView)==null||p.setCamera(this._camera),(f=this._frameView)==null||f.updateCamera(g!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}},this._debouncedResize=xd(this._resize,10),this._onScroll=s=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this.renderMode=t?"auto":i,r&&(this._wasmPath=s8(r,"/")),this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new gre({x:10,y:10})),v8(e)}async load(e,t,i){Sre(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){var l,h,c,d;if(this.disposed)return;let r=await Xie(e);this._data=r;let s=Yie(r);r.version&&(0,wre.default)(r.version,"1.10.53")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath&&this.setUIWasmUrl(`${this._wasmPath}/ui.wasm`),await Promise.all([s.length&&Wie(this._wasmPath),rA(r)&&SX(this._wasmPath),TQ(r)&&xX(this._wasmPath),Ad.physicsEnabled(r.scene.objects)&&_8(),$S(r)&&sQ(),RA(r)&&N$(),iQ(r)&&tQ(),AA(r)&&MJ(),Pie(r)&&b8(this._wasmPath)].filter(Boolean)),s.length&&await Qie(s),(l=this._eventManager)==null||l.deactivate(),(h=this._controls)==null||h.deactivate(),(c=this._scene)==null||c.dispose();let a=new mre(r);if(a.resetPersonalCameraFromDocumentData(),this._scene=a.scene,this._sharedAssetsManager=a.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let u=performance.now();bre(r,a.scene);let p=performance.now();console.log("Merged geometries in ",p-u," ms")}rA(r)&&this._scene.traverse(u=>{un(u)&&u.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{var u;this._requestRenderAutoMode(),(u=this._scene)==null||u.traverse(p=>{p instanceof bs&&p.pendingMediaLoad&&p.update()})}),(d=this._scene)==null||d.traverse(u=>{u.type==="ParticleSystem"&&(u.wakeUp(),u.data.autoPlay?u.start():u.stop())});let n=Object.keys(r.shared.fonts).map(u=>this._sharedAssetsManager.getFont(u).loadingPromise);if(Promise.all(n).then(()=>{a.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),$S(r)&&Nie(r)&&await Promise.all(n),AA(r)){let u=[];this._scene.traverseEntity(p=>{(p instanceof Sr||p instanceof $i)&&p.uiCanvas&&u.push(p.uiCanvas)}),await Promise.all(u.map(p=>p.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),xx(this._scene.activePage,this._sharedAssetsManager),!this._renderer){this._renderer=new dJ({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0;let u=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),p=this._getPixelRatio(u()?r.scene.publish.settings.web.pixelRatioMobile:r.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(p),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),r.shared.images.SplineWatermark){let f=this._sharedAssetsManager.getImage("SplineWatermark");await f.loadPromise;let g=f.getTexture(1001);this._renderer.pipeline.setWatermark(g)}}RA(r)&&this._scene.initializeSplatViewer(),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let o=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(o.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=o.size[0],this._viewportHeight=o.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new pre(this._renderer,this._camera,new j(this._viewportWidth,this._viewportHeight),new j(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(o.allowResponsive??!1)&&o.preset==="fullscreen"),t){let u=new Fte(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,o);this._scene.updateMatrixWorld(!0),this._controls=new kie(u),this._animationControls=new jie(this._scene,this._requestRenderAutoMode),this._eventManager=new ure(r.scene.publish,this._controls,this._animationControls,u,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this._scene.activePage.data.postprocessing.depthOfField.enabled&&Promise.all(this._sharedAssetsManager.getImageLoadPromises()).then(()=>{this._resize(!0)}),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{var u;(u=this._renderer)==null||u.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300),document.addEventListener("scroll",this._onScroll)}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){var r;let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){let s=t;typeof i.data.value=="number"?s=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t):typeof i.data.value=="boolean"?s=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()==="false"?!1:!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(s=t.toString());let a=typeof s=="string"?{textValue:s}:s;(r=this._sharedAssetsManager)==null||r.updateVariable(i.id,a),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&mr.isTextValue(e)?mr.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}_getPixelRatio(e){switch(e){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(e){var i;let t=(i=this._scene)==null?void 0:i.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){var i;let t=(i=this._scene)==null?void 0:i.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){var t;let e=[];return(t=this._scene)==null||t.traverseEntity(i=>{if(i.uuid!==ic&&!this._scene.isInvisibleObjects(i)&&!(i instanceof $i)){let r=this._createProxyObject(i);r&&e.push(r)}}),e}getSplineEvents(){var e,t;return((t=(e=this._eventManager)==null?void 0:e.handlers)==null?void 0:t.Spline).splineEvents}emitEvent(e,t){var i;(i=this.findObjectById(t)||this.findObjectByName(t))==null||i.emitEvent(e)}emitEventReverse(e,t){var i;(i=this.findObjectById(t)||this.findObjectByName(t))==null||i.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){var t,i;((t=this._controls)==null?void 0:t.orbitControls)instanceof oD&&((i=this._controls)==null||i.orbitControls.setZoom(e))}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){var i;let t=L2(e);(i=this._scene)==null||i.activePage.setBackgroundColor(t),this._requestRenderAutoMode()}dispose(){var e,t,i,r,s,a,n;this.disposed=!0,(e=this._eventManager)==null||e.deactivate(),(t=this._scene)==null||t.dispose(),(i=this._sharedAssetsManager)==null||i.dispose(),this._proxyObjectCache.forEach(o=>{ow.unsubscribe(o)}),this._variablesCache.clear(),(r=this._renderer)==null||r.setAnimationLoop(null),(s=this._renderer)==null||s.dispose(),this._renderer=void 0,(a=this._sharedAssetsManager)==null||a.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),(n=this._controls)==null||n.deactivate(),this.dt=0,y8(this.canvas),document.removeEventListener("scroll",this._onScroll)}get isStopped(){return this._isPaused}stop(){var e,t,i;this._isPaused||((e=this._renderer)==null||e.setAnimationLoop(null),this._isPaused=!0,(t=this._eventManager)==null||t.pause(),(i=this._controls)!=null&&i.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){var e,t,i;!this._isPaused||(this._isPaused=!1,(e=this._eventManager)==null||e.resume(),(t=this._controls)!=null&&t.orbitControls&&(this._controls.orbitControls.enabled=!0),(i=this._renderer)==null||i.setAnimationLoop(this.render))}setGlobalEvents(e){var t;(t=this._eventManager)==null||t.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){var o;if(!this._scene||e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t;e.traverseAncestors(l=>{l instanceof $i&&(t=l.name)});let i=this._sharedAssetsManager,r={shared:i,scene:this._scene},s=l=>{if(l===null||l==="Base State")return null;if(l&&e.data.states){let h=e.data.states.find(c=>c.data.name===l);return h?h.id:void 0}},a={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof $i||e instanceof nx||(o=e.parent)==null?void 0:o.uuid,emitEvent(l){e.dispatchEvent({type:"userEvent",eventName:l})},emitEventReverse(l){e.dispatchEvent({type:"userEvent",eventName:l,reverse:!0})},hide(){e.visible&&(e.visible=!1,r.shared.requestRender())},show(){e.visible||(e.visible=!0,r.shared.requestRender())},get state(){var h;let l=e.stateSelection;if(l!==null)return(h=e.data.states.find(({id:c})=>c===l))==null?void 0:h.data.name},set state(l){let h;if(l!==void 0){let c=typeof l=="string"?e.data.states.find(({id:d})=>d===l):e.data.states[l];if(c)h=c.id;else{let d=typeof l=="string"?s(l):void 0;d&&(h=d)}}e.changeSelectedState(h??null,r),e.currentState=h??null,e.dispatchEvent({type:"completeState",state:h??null}),r.shared.requestRender()},transition(l){let h=this,c,d=od.timeline({autoplay:l.autoPlay??!0}),u={transition({from:p,to:f,duration:g,delay:m,...v}){let y=s(p);y===void 0&&(y=c);let x=s(f);c=x;let w=new Dy(e,y,x,{state:x,repeat:0,delay:m??0,delayDirection:"start-once",direction:"normal",duration:g??1e3,...v,...v.easing===6?u0.defaultData:v.easing===5?p0.defaultData:{}},i,!1);return d.add({...w.params,begin:()=>{(p&&y||p==="Base State"&&!y)&&(h.state=y??void 0)},complete:()=>{h.state=x??void 0}},d.duration),this},play(){return d.play(),this},pause(){return d.pause(),this},reset(){return d.reset(),this},seek(p){return d.seek(p),this}};return u.transition(l),u},set color(l){var p;let h=L2(l);if(zf.is(e)){e.color=h;return}else if(e.type!=="Mesh"||!("material"in e)||!(e instanceof xl))return;let c={r:h.r,g:h.g,b:h.b,a:h.a},d=Array.isArray(e.material)?e.material[0]:e.material,u=(p=d.data.layers.find(f=>f.data.type==="color"))==null?void 0:p.id;u&&d.updateByOp({type:0,path:["layers",u],props:{color:{...c}}},d.data,r)}},n=ow(a,(l,h)=>{var c;typeof e[l]!="object"&&((c=Object.getOwnPropertyDescriptor(e,l))!=null&&c.writable)&&(e[l]=h),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,n),n}setUIWasmUrl(e){TT.skiaWasmUrl=e}pauseGameControls(){var e,t;(t=(e=this._eventManager)==null?void 0:e.controlsManager.gameControl)==null||t.pause()}resumeGameControls(){var e,t;(t=(e=this._eventManager)==null?void 0:e.controlsManager.gameControl)==null||t.resume()}};const Mre={class:"map_container"},Ere={class:"backimg"},Cre=ne("div",{class:"canvas_infobox"},[ne("iframe",{src:"http://home.ynims.com:10000/map_threejs/index_map.html",style:{border:"none"},width:"100%",height:"100%"})],-1),Tre={__name:"map",setup(e){const t=ti(null);ti("");const i=()=>{new Are(t.value).load("https://prod.spline.design/D2d56-uXgeR4muly/scene.splinecode").then(()=>{})};return jh(()=>{i()}),(r,s)=>(Zt(),ki("div",Mre,[ne("div",Ere,[ne("canvas",{id:"echars_idel3928",class:"canvas-3d",ref_key:"ref3d",ref:t},null,512)]),Cre]))}},z2="/assets/index_bock_back1-DYWn9-5P.png",Pre="/assets/index_bock_back2-B0UPOH3Q.png",Dre="/assets/index_bock_back3-C_UddrN0.png",Ire="/assets/index_bock_back1-DYWn9-5P.png",Ore="/assets/index_bock_back1-DYWn9-5P.png",Rre="/assets/index_bock_back7-DGSoLFBg.png",hD=e=>(mo("data-v-1cf0fc5c"),e=e(),go(),e),Lre={class:"index"},zre=hD(()=>ne("div",{class:"box-line box-line-left"},[ne("div",{class:"putImg",id:"main",style:{width:"32px",height:"1348px"}})],-1)),Bre=hD(()=>ne("div",{class:"box-line box-line-right"},[ne("div",{class:"putImg",id:"main",style:{width:"32px",height:"1348px"}})],-1)),Fre={class:"backPlateBox center_map"},Ure={key:0,class:"backPlateBox box1"},Nre={key:1,class:"backPlateBox box1"},kre={class:"backPlateBox box2"},Vre={class:"backPlateBox box3"},jre={class:"backPlateBox right_router"},Gre={class:"backPlateBox box6"},Hre={key:2,class:"backPlateBox box7"},Wre={key:3,class:"backPlateBox box8"},qre={__name:"index",setup(e){const t=B2(),i=ti(!0),r=ti({}),s=ti({}),a=ti({}),n=ti({}),o=ti({}),l=ti({}),h=ti({}),c=ti(!1),d=ti(!1),u=ti(!1),p=ti(!1),f=ti(!1),g=ti(!1);ti({});const m=w=>{w==1?(i.value=1,c.value=!1,v()):(c.value=!1,i.value=0,console.log(w.elderlyTrendsYearBarChart),r.value=w.overviewSummary,s.value=w.elderlyTrendsYearBarChart,setTimeout(()=>{c.value=!0},100))};jh(()=>{t.setRoomDetail(!1),v()});function v(){let w={};w={queryFlag:1},uD(w).then(_=>{r.value=_.data.overviewSummary,s.value=_.data.elderlyTrendsYearBarChart,a.value=_.data.diseaseType,n.value=_.data,o.value=_.data.elderlyTrendsMonthBarChart,l.value=_.data.business,h.value=_.data.tenantList,c.value=!0,d.value=!0,u.value=!0,p.value=!0,f.value=!0,g.value=!0})}const y=ti([1]);ti(0);function x(w){y.value=w}return(w,_)=>{const b=dD("RouterView");return Zt(),ki("div",Lre,[zre,Bre,_x(ne("div",Fre,[Ci(Tre)],512),[[Sx,i.value]]),i.value==1?(Zt(),ki("div",Ure,[Ci(Ao,{title:"概况统计",url:wr(z2)},{default:ua(()=>[c.value?(Zt(),Mn(t3,{key:0,overviewStatisticsData:r.value},null,8,["overviewStatisticsData"])):ps("",!0)]),_:1},8,["url"])])):(Zt(),ki("div",Nre,[Ci(Ao,{title:"概况统计",url:wr(z2)},{default:ua(()=>[c.value?(Zt(),Mn(H3,{key:0,overviewStatisticsData:r.value},null,8,["overviewStatisticsData"])):ps("",!0)]),_:1},8,["url"])])),ne("div",kre,[Ci(Ao,{title:"长者趋势统计",url:wr(Pre)},{default:ua(()=>[c.value?(Zt(),Mn(Z3,{key:0,box2_data:s.value},null,8,["box2_data"])):ps("",!0)]),_:1},8,["url"])]),ne("div",Vre,[Ci(Ao,{title:"病种人数统计",url:wr(Dre)},{default:ua(()=>[d.value?(Zt(),Mn(iI,{key:0,box3_data:a.value,onSet_listdata:x,id:"yuj"+Math.random()},null,8,["box3_data","id"])):ps("",!0)]),_:1},8,["url"])]),ne("div",jre,[g.value?(Zt(),Mn(b,{key:0,onDow_map:m,right_data:h.value},null,8,["right_data"])):ps("",!0)]),_x(ne("div",Gre,[Ci(Ao,{title:"户籍地统计",url:wr(Rre)},{default:ua(()=>[u.value?(Zt(),Mn(EI,{key:0,box6_data:n.value},null,8,["box6_data"])):ps("",!0)]),_:1},8,["url"])],512),[[Sx,i.value]]),i.value?(Zt(),ki("div",Hre,[Ci(Ao,{title:"近6个月入住统计",url:wr(Ore)},{default:ua(()=>[p.value?(Zt(),Mn(OI,{key:0,box7_data:o.value},null,8,["box7_data"])):ps("",!0)]),_:1},8,["url"])])):ps("",!0),i.value?(Zt(),ki("div",Wre,[Ci(Ao,{title:"业务统计",url:wr(Ire)},{default:ua(()=>[c.value?(Zt(),Mn(bO,{key:0,businessStatisticsDats:l.value},null,8,["businessStatisticsDats"])):ps("",!0)]),_:1},8,["url"])])):ps("",!0)])}}},tse=fo(qre,[["__scopeId","data-v-1cf0fc5c"]]);export{tse as default};