viewer.js 1.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538
  1. var z2 = Object.defineProperty;
  2. var N2 = Object.getOwnPropertyDescriptor;
  3. var Pr = (e, t, i, r) => {
  4. for (var s = r > 1 ? void 0 : r ? N2(t, i) : t, n = e.length - 1, a; n >= 0; n--) (a = e[n]) && (s = (r ? a(t, i, s) : a(s)) || s);
  5. return r && s && z2(t, i, s), s;
  6. };
  7. var U2 = Object.create,
  8. ag = Object.defineProperty,
  9. F2 = Object.getOwnPropertyDescriptor,
  10. k2 = Object.getOwnPropertyNames,
  11. j2 = Object.getPrototypeOf,
  12. G2 = Object.prototype.hasOwnProperty,
  13. au = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports),
  14. V2 = (e, t) => {
  15. for (var i in t) ag(e, i, { get: t[i], enumerable: !0 });
  16. },
  17. H2 = (e, t, i, r) => {
  18. if ((t && typeof t == 'object') || typeof t == 'function')
  19. for (let s of k2(t)) !G2.call(e, s) && s !== i && ag(e, s, { get: () => t[s], enumerable: !(r = F2(t, s)) || r.enumerable });
  20. return e;
  21. },
  22. Eh = (e, t, i) => (
  23. (i = e != null ? U2(j2(e)) : {}), H2(t || !e || !e.__esModule ? ag(i, 'default', { value: e, enumerable: !0 }) : i, e)
  24. ),
  25. W2 = au((e, t) => {
  26. (function (i, r) {
  27. typeof e == 'object' ? (t.exports = r()) : typeof define == 'function' && define.amd ? define(r) : (i.Alea = r());
  28. })(e, function () {
  29. 'use strict';
  30. return (
  31. (i.importState = function (s) {
  32. var n = new i();
  33. return n.importState(s), n;
  34. }),
  35. i
  36. );
  37. function i() {
  38. return (function (s) {
  39. var n = 0,
  40. a = 0,
  41. o = 0,
  42. l = 1;
  43. s.length == 0 && (s = [+new Date()]);
  44. var h = r();
  45. (n = h(' ')), (a = h(' ')), (o = h(' '));
  46. for (var u = 0; u < s.length; u++)
  47. (n -= h(s[u])), n < 0 && (n += 1), (a -= h(s[u])), a < 0 && (a += 1), (o -= h(s[u])), o < 0 && (o += 1);
  48. h = null;
  49. var c = function () {
  50. var d = 2091639 * n + l * 2.3283064365386963e-10;
  51. return (n = a), (a = o), (o = d - (l = d | 0));
  52. };
  53. return (
  54. (c.next = c),
  55. (c.uint32 = function () {
  56. return c() * 4294967296;
  57. }),
  58. (c.fract53 = function () {
  59. return c() + ((c() * 2097152) | 0) * 11102230246251565e-32;
  60. }),
  61. (c.version = 'Alea 0.9'),
  62. (c.args = s),
  63. (c.exportState = function () {
  64. return [n, a, o, l];
  65. }),
  66. (c.importState = function (d) {
  67. (n = +d[0] || 0), (a = +d[1] || 0), (o = +d[2] || 0), (l = +d[3] || 0);
  68. }),
  69. c
  70. );
  71. })(Array.prototype.slice.call(arguments));
  72. }
  73. function r() {
  74. var s = 4022871197,
  75. n = function (a) {
  76. a = a.toString();
  77. for (var o = 0; o < a.length; o++) {
  78. s += a.charCodeAt(o);
  79. var l = 0.02519603282416938 * s;
  80. (s = l >>> 0), (l -= s), (l *= s), (s = l >>> 0), (l -= s), (s += l * 4294967296);
  81. }
  82. return (s >>> 0) * 2.3283064365386963e-10;
  83. };
  84. return (n.version = 'Mash 0.9'), n;
  85. }
  86. });
  87. }),
  88. rw = au((e, t) => {
  89. (function (i, r) {
  90. typeof e == 'object' && typeof t < 'u'
  91. ? r(e)
  92. : typeof define == 'function' && define.amd
  93. ? define(['exports'], r)
  94. : r(((i = typeof globalThis < 'u' ? globalThis : i || self).SVDJS = {}));
  95. })(e, function (i) {
  96. 'use strict';
  97. (i.SVD = function (r, s, n, a, o) {
  98. if (((s = s === void 0 || s), (n = n === void 0 || n), (o = 1e-64 / (a = a || Math.pow(2, -52))), !r))
  99. throw new TypeError('Matrix a is not defined');
  100. var l,
  101. h,
  102. u,
  103. c,
  104. d,
  105. p,
  106. f,
  107. g,
  108. m,
  109. v,
  110. y,
  111. b,
  112. x = r[0].length,
  113. w = r.length;
  114. if (w < x) throw new TypeError('Invalid matrix: m < n');
  115. for (var A = [], S = [], _ = [], M = s === 'f' ? w : x, C = (v = f = 0); C < w; C++) S[C] = new Array(M).fill(0);
  116. for (C = 0; C < x; C++) _[C] = new Array(x).fill(0);
  117. var T,
  118. P = new Array(x).fill(0);
  119. for (C = 0; C < w; C++) for (l = 0; l < x; l++) S[C][l] = r[C][l];
  120. for (C = 0; C < x; C++) {
  121. for (A[C] = f, m = 0, u = C + 1, l = C; l < w; l++) m += Math.pow(S[l][C], 2);
  122. if (m < o) f = 0;
  123. else
  124. for (g = (p = S[C][C]) * (f = p < 0 ? Math.sqrt(m) : -Math.sqrt(m)) - m, S[C][C] = p - f, l = u; l < x; l++) {
  125. for (m = 0, h = C; h < w; h++) m += S[h][C] * S[h][l];
  126. for (p = m / g, h = C; h < w; h++) S[h][l] = S[h][l] + p * S[h][C];
  127. }
  128. for (P[C] = f, m = 0, l = u; l < x; l++) m += Math.pow(S[C][l], 2);
  129. if (m < o) f = 0;
  130. else {
  131. for (g = (p = S[C][C + 1]) * (f = p < 0 ? Math.sqrt(m) : -Math.sqrt(m)) - m, S[C][C + 1] = p - f, l = u; l < x; l++)
  132. A[l] = S[C][l] / g;
  133. for (l = u; l < w; l++) {
  134. for (m = 0, h = u; h < x; h++) m += S[l][h] * S[C][h];
  135. for (h = u; h < x; h++) S[l][h] = S[l][h] + m * A[h];
  136. }
  137. }
  138. v < (y = Math.abs(P[C]) + Math.abs(A[C])) && (v = y);
  139. }
  140. if (n)
  141. for (C = x - 1; 0 <= C; C--) {
  142. if (f !== 0) {
  143. for (g = S[C][C + 1] * f, l = u; l < x; l++) _[l][C] = S[C][l] / g;
  144. for (l = u; l < x; l++) {
  145. for (m = 0, h = u; h < x; h++) m += S[C][h] * _[h][l];
  146. for (h = u; h < x; h++) _[h][l] = _[h][l] + m * _[h][C];
  147. }
  148. }
  149. for (l = u; l < x; l++) (_[C][l] = 0), (_[l][C] = 0);
  150. (_[C][C] = 1), (f = A[C]), (u = C);
  151. }
  152. if (s) {
  153. if (s === 'f')
  154. for (C = x; C < w; C++) {
  155. for (l = x; l < w; l++) S[C][l] = 0;
  156. S[C][C] = 1;
  157. }
  158. for (C = x - 1; 0 <= C; C--) {
  159. for (u = C + 1, f = P[C], l = u; l < M; l++) S[C][l] = 0;
  160. if (f !== 0) {
  161. for (g = S[C][C] * f, l = u; l < M; l++) {
  162. for (m = 0, h = u; h < w; h++) m += S[h][C] * S[h][l];
  163. for (p = m / g, h = C; h < w; h++) S[h][l] = S[h][l] + p * S[h][C];
  164. }
  165. for (l = C; l < w; l++) S[l][C] = S[l][C] / f;
  166. } else for (l = C; l < w; l++) S[l][C] = 0;
  167. S[C][C] = S[C][C] + 1;
  168. }
  169. }
  170. for (a *= v, h = x - 1; 0 <= h; h--)
  171. for (var L = 0; L < 50; L++) {
  172. for (T = !1, u = h; 0 <= u; u--) {
  173. if (Math.abs(A[u]) <= a) {
  174. T = !0;
  175. break;
  176. }
  177. if (Math.abs(P[u - 1]) <= a) break;
  178. }
  179. if (!T) {
  180. for (d = 0, c = u - (m = 1), C = u; C < h + 1 && ((p = m * A[C]), (A[C] = d * A[C]), !(Math.abs(p) <= a)); C++)
  181. if (((f = P[C]), (P[C] = Math.sqrt(p * p + f * f)), (d = f / (g = P[C])), (m = -p / g), s))
  182. for (l = 0; l < w; l++) (y = S[l][c]), (b = S[l][C]), (S[l][c] = y * d + b * m), (S[l][C] = -y * m + b * d);
  183. }
  184. if (((b = P[h]), u === h)) {
  185. if (b < 0 && ((P[h] = -b), n)) for (l = 0; l < x; l++) _[l][h] = -_[l][h];
  186. break;
  187. }
  188. for (
  189. v = P[u],
  190. p = (((y = P[h - 1]) - b) * (y + b) + ((f = A[h - 1]) - (g = A[h])) * (f + g)) / (2 * g * y),
  191. f = Math.sqrt(p * p + 1),
  192. p = ((v - b) * (v + b) + g * (y / (p < 0 ? p - f : p + f) - g)) / v,
  193. C = u + (m = d = 1);
  194. C < h + 1;
  195. C++
  196. ) {
  197. if (
  198. ((f = A[C]),
  199. (y = P[C]),
  200. (g = m * f),
  201. (f *= d),
  202. (b = Math.sqrt(p * p + g * g)),
  203. (p = v * (d = p / (A[C - 1] = b)) + f * (m = g / b)),
  204. (f = -v * m + f * d),
  205. (g = y * m),
  206. (y *= d),
  207. n)
  208. )
  209. for (l = 0; l < x; l++) (v = _[l][C - 1]), (b = _[l][C]), (_[l][C - 1] = v * d + b * m), (_[l][C] = -v * m + b * d);
  210. if (((b = Math.sqrt(p * p + g * g)), (p = (d = p / (P[C - 1] = b)) * f + (m = g / b) * y), (v = -m * f + d * y), s))
  211. for (l = 0; l < w; l++) (y = S[l][C - 1]), (b = S[l][C]), (S[l][C - 1] = y * d + b * m), (S[l][C] = -y * m + b * d);
  212. }
  213. (A[u] = 0), (A[h] = p), (P[h] = v);
  214. }
  215. for (C = 0; C < x; C++) P[C] < a && (P[C] = 0);
  216. return { u: S, q: P, v: _ };
  217. }),
  218. (i.VERSION = '1.1.1'),
  219. Object.defineProperty(i, '__esModule', { value: !0 });
  220. });
  221. }),
  222. X2 = au((e) => {
  223. (function () {
  224. 'use strict';
  225. var t = function () {
  226. this.init();
  227. };
  228. t.prototype = {
  229. init: function () {
  230. var c = this || i;
  231. return (
  232. (c._counter = 1e3),
  233. (c._html5AudioPool = []),
  234. (c.html5PoolSize = 10),
  235. (c._codecs = {}),
  236. (c._howls = []),
  237. (c._muted = !1),
  238. (c._volume = 1),
  239. (c._canPlayEvent = 'canplaythrough'),
  240. (c._navigator = typeof window < 'u' && window.navigator ? window.navigator : null),
  241. (c.masterGain = null),
  242. (c.noAudio = !1),
  243. (c.usingWebAudio = !0),
  244. (c.autoSuspend = !0),
  245. (c.ctx = null),
  246. (c.autoUnlock = !0),
  247. c._setup(),
  248. c
  249. );
  250. },
  251. volume: function (c) {
  252. var d = this || i;
  253. if (((c = parseFloat(c)), d.ctx || u(), typeof c < 'u' && c >= 0 && c <= 1)) {
  254. if (((d._volume = c), d._muted)) return d;
  255. d.usingWebAudio && d.masterGain.gain.setValueAtTime(c, i.ctx.currentTime);
  256. for (var p = 0; p < d._howls.length; p++)
  257. if (!d._howls[p]._webAudio)
  258. for (var f = d._howls[p]._getSoundIds(), g = 0; g < f.length; g++) {
  259. var m = d._howls[p]._soundById(f[g]);
  260. m && m._node && (m._node.volume = m._volume * c);
  261. }
  262. return d;
  263. }
  264. return d._volume;
  265. },
  266. mute: function (c) {
  267. var d = this || i;
  268. d.ctx || u(), (d._muted = c), d.usingWebAudio && d.masterGain.gain.setValueAtTime(c ? 0 : d._volume, i.ctx.currentTime);
  269. for (var p = 0; p < d._howls.length; p++)
  270. if (!d._howls[p]._webAudio)
  271. for (var f = d._howls[p]._getSoundIds(), g = 0; g < f.length; g++) {
  272. var m = d._howls[p]._soundById(f[g]);
  273. m && m._node && (m._node.muted = c ? !0 : m._muted);
  274. }
  275. return d;
  276. },
  277. stop: function () {
  278. for (var c = this || i, d = 0; d < c._howls.length; d++) c._howls[d].stop();
  279. return c;
  280. },
  281. unload: function () {
  282. for (var c = this || i, d = c._howls.length - 1; d >= 0; d--) c._howls[d].unload();
  283. return c.usingWebAudio && c.ctx && typeof c.ctx.close < 'u' && (c.ctx.close(), (c.ctx = null), u()), c;
  284. },
  285. codecs: function (c) {
  286. return (this || i)._codecs[c.replace(/^x-/, '')];
  287. },
  288. _setup: function () {
  289. var c = this || i;
  290. if (((c.state = (c.ctx && c.ctx.state) || 'suspended'), c._autoSuspend(), !c.usingWebAudio))
  291. if (typeof Audio < 'u')
  292. try {
  293. var d = new Audio();
  294. typeof d.oncanplaythrough > 'u' && (c._canPlayEvent = 'canplay');
  295. } catch {
  296. c.noAudio = !0;
  297. }
  298. else c.noAudio = !0;
  299. try {
  300. var d = new Audio();
  301. d.muted && (c.noAudio = !0);
  302. } catch {}
  303. return c.noAudio || c._setupCodecs(), c;
  304. },
  305. _setupCodecs: function () {
  306. var c = this || i,
  307. d = null;
  308. try {
  309. d = typeof Audio < 'u' ? new Audio() : null;
  310. } catch {
  311. return c;
  312. }
  313. if (!d || typeof d.canPlayType != 'function') return c;
  314. var p = d.canPlayType('audio/mpeg;').replace(/^no$/, ''),
  315. f = c._navigator ? c._navigator.userAgent : '',
  316. g = f.match(/OPR\/([0-6].)/g),
  317. m = g && parseInt(g[0].split('/')[1], 10) < 33,
  318. v = f.indexOf('Safari') !== -1 && f.indexOf('Chrome') === -1,
  319. y = f.match(/Version\/(.*?) /),
  320. b = v && y && parseInt(y[1], 10) < 15;
  321. return (
  322. (c._codecs = {
  323. mp3: !!(!m && (p || d.canPlayType('audio/mp3;').replace(/^no$/, ''))),
  324. mpeg: !!p,
  325. opus: !!d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ''),
  326. ogg: !!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''),
  327. oga: !!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''),
  328. wav: !!(d.canPlayType('audio/wav; codecs="1"') || d.canPlayType('audio/wav')).replace(/^no$/, ''),
  329. aac: !!d.canPlayType('audio/aac;').replace(/^no$/, ''),
  330. caf: !!d.canPlayType('audio/x-caf;').replace(/^no$/, ''),
  331. m4a: !!(d.canPlayType('audio/x-m4a;') || d.canPlayType('audio/m4a;') || d.canPlayType('audio/aac;')).replace(/^no$/, ''),
  332. m4b: !!(d.canPlayType('audio/x-m4b;') || d.canPlayType('audio/m4b;') || d.canPlayType('audio/aac;')).replace(/^no$/, ''),
  333. mp4: !!(d.canPlayType('audio/x-mp4;') || d.canPlayType('audio/mp4;') || d.canPlayType('audio/aac;')).replace(/^no$/, ''),
  334. weba: !!(!b && d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')),
  335. webm: !!(!b && d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')),
  336. dolby: !!d.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/, ''),
  337. flac: !!(d.canPlayType('audio/x-flac;') || d.canPlayType('audio/flac;')).replace(/^no$/, '')
  338. }),
  339. c
  340. );
  341. },
  342. _unlockAudio: function () {
  343. var c = this || i;
  344. if (!(c._audioUnlocked || !c.ctx)) {
  345. (c._audioUnlocked = !1),
  346. (c.autoUnlock = !1),
  347. !c._mobileUnloaded && c.ctx.sampleRate !== 44100 && ((c._mobileUnloaded = !0), c.unload()),
  348. (c._scratchBuffer = c.ctx.createBuffer(1, 1, 22050));
  349. var d = function (p) {
  350. for (; c._html5AudioPool.length < c.html5PoolSize; )
  351. try {
  352. var f = new Audio();
  353. (f._unlocked = !0), c._releaseHtml5Audio(f);
  354. } catch {
  355. c.noAudio = !0;
  356. break;
  357. }
  358. for (var g = 0; g < c._howls.length; g++)
  359. if (!c._howls[g]._webAudio)
  360. for (var m = c._howls[g]._getSoundIds(), v = 0; v < m.length; v++) {
  361. var y = c._howls[g]._soundById(m[v]);
  362. y && y._node && !y._node._unlocked && ((y._node._unlocked = !0), y._node.load());
  363. }
  364. c._autoResume();
  365. var b = c.ctx.createBufferSource();
  366. (b.buffer = c._scratchBuffer),
  367. b.connect(c.ctx.destination),
  368. typeof b.start > 'u' ? b.noteOn(0) : b.start(0),
  369. typeof c.ctx.resume == 'function' && c.ctx.resume(),
  370. (b.onended = function () {
  371. b.disconnect(0),
  372. (c._audioUnlocked = !0),
  373. document.removeEventListener('touchstart', d, !0),
  374. document.removeEventListener('touchend', d, !0),
  375. document.removeEventListener('click', d, !0),
  376. document.removeEventListener('keydown', d, !0);
  377. for (var x = 0; x < c._howls.length; x++) c._howls[x]._emit('unlock');
  378. });
  379. };
  380. return (
  381. document.addEventListener('touchstart', d, !0),
  382. document.addEventListener('touchend', d, !0),
  383. document.addEventListener('click', d, !0),
  384. document.addEventListener('keydown', d, !0),
  385. c
  386. );
  387. }
  388. },
  389. _obtainHtml5Audio: function () {
  390. var c = this || i;
  391. if (c._html5AudioPool.length) return c._html5AudioPool.pop();
  392. var d = new Audio().play();
  393. return (
  394. d &&
  395. typeof Promise < 'u' &&
  396. (d instanceof Promise || typeof d.then == 'function') &&
  397. d.catch(function () {
  398. console.warn('HTML5 Audio pool exhausted, returning potentially locked audio object.');
  399. }),
  400. new Audio()
  401. );
  402. },
  403. _releaseHtml5Audio: function (c) {
  404. var d = this || i;
  405. return c._unlocked && d._html5AudioPool.push(c), d;
  406. },
  407. _autoSuspend: function () {
  408. var c = this;
  409. if (!(!c.autoSuspend || !c.ctx || typeof c.ctx.suspend > 'u' || !i.usingWebAudio)) {
  410. for (var d = 0; d < c._howls.length; d++)
  411. if (c._howls[d]._webAudio) {
  412. for (var p = 0; p < c._howls[d]._sounds.length; p++) if (!c._howls[d]._sounds[p]._paused) return c;
  413. }
  414. return (
  415. c._suspendTimer && clearTimeout(c._suspendTimer),
  416. (c._suspendTimer = setTimeout(function () {
  417. if (c.autoSuspend) {
  418. (c._suspendTimer = null), (c.state = 'suspending');
  419. var f = function () {
  420. (c.state = 'suspended'), c._resumeAfterSuspend && (delete c._resumeAfterSuspend, c._autoResume());
  421. };
  422. c.ctx.suspend().then(f, f);
  423. }
  424. }, 3e4)),
  425. c
  426. );
  427. }
  428. },
  429. _autoResume: function () {
  430. var c = this;
  431. if (!(!c.ctx || typeof c.ctx.resume > 'u' || !i.usingWebAudio))
  432. return (
  433. c.state === 'running' && c.ctx.state !== 'interrupted' && c._suspendTimer
  434. ? (clearTimeout(c._suspendTimer), (c._suspendTimer = null))
  435. : c.state === 'suspended' || (c.state === 'running' && c.ctx.state === 'interrupted')
  436. ? (c.ctx.resume().then(function () {
  437. c.state = 'running';
  438. for (var d = 0; d < c._howls.length; d++) c._howls[d]._emit('resume');
  439. }),
  440. c._suspendTimer && (clearTimeout(c._suspendTimer), (c._suspendTimer = null)))
  441. : c.state === 'suspending' && (c._resumeAfterSuspend = !0),
  442. c
  443. );
  444. }
  445. };
  446. var i = new t(),
  447. r = function (c) {
  448. var d = this;
  449. if (!c.src || c.src.length === 0) {
  450. console.error('An array of source files must be passed with any new Howl.');
  451. return;
  452. }
  453. d.init(c);
  454. };
  455. r.prototype = {
  456. init: function (c) {
  457. var d = this;
  458. return (
  459. i.ctx || u(),
  460. (d._autoplay = c.autoplay || !1),
  461. (d._format = typeof c.format != 'string' ? c.format : [c.format]),
  462. (d._html5 = c.html5 || !1),
  463. (d._muted = c.mute || !1),
  464. (d._loop = c.loop || !1),
  465. (d._pool = c.pool || 5),
  466. (d._preload = typeof c.preload == 'boolean' || c.preload === 'metadata' ? c.preload : !0),
  467. (d._rate = c.rate || 1),
  468. (d._sprite = c.sprite || {}),
  469. (d._src = typeof c.src != 'string' ? c.src : [c.src]),
  470. (d._volume = c.volume !== void 0 ? c.volume : 1),
  471. (d._xhr = {
  472. method: c.xhr && c.xhr.method ? c.xhr.method : 'GET',
  473. headers: c.xhr && c.xhr.headers ? c.xhr.headers : null,
  474. withCredentials: c.xhr && c.xhr.withCredentials ? c.xhr.withCredentials : !1
  475. }),
  476. (d._duration = 0),
  477. (d._state = 'unloaded'),
  478. (d._sounds = []),
  479. (d._endTimers = {}),
  480. (d._queue = []),
  481. (d._playLock = !1),
  482. (d._onend = c.onend ? [{ fn: c.onend }] : []),
  483. (d._onfade = c.onfade ? [{ fn: c.onfade }] : []),
  484. (d._onload = c.onload ? [{ fn: c.onload }] : []),
  485. (d._onloaderror = c.onloaderror ? [{ fn: c.onloaderror }] : []),
  486. (d._onplayerror = c.onplayerror ? [{ fn: c.onplayerror }] : []),
  487. (d._onpause = c.onpause ? [{ fn: c.onpause }] : []),
  488. (d._onplay = c.onplay ? [{ fn: c.onplay }] : []),
  489. (d._onstop = c.onstop ? [{ fn: c.onstop }] : []),
  490. (d._onmute = c.onmute ? [{ fn: c.onmute }] : []),
  491. (d._onvolume = c.onvolume ? [{ fn: c.onvolume }] : []),
  492. (d._onrate = c.onrate ? [{ fn: c.onrate }] : []),
  493. (d._onseek = c.onseek ? [{ fn: c.onseek }] : []),
  494. (d._onunlock = c.onunlock ? [{ fn: c.onunlock }] : []),
  495. (d._onresume = []),
  496. (d._webAudio = i.usingWebAudio && !d._html5),
  497. typeof i.ctx < 'u' && i.ctx && i.autoUnlock && i._unlockAudio(),
  498. i._howls.push(d),
  499. d._autoplay &&
  500. d._queue.push({
  501. event: 'play',
  502. action: function () {
  503. d.play();
  504. }
  505. }),
  506. d._preload && d._preload !== 'none' && d.load(),
  507. d
  508. );
  509. },
  510. load: function () {
  511. var c = this,
  512. d = null;
  513. if (i.noAudio) {
  514. c._emit('loaderror', null, 'No audio support.');
  515. return;
  516. }
  517. typeof c._src == 'string' && (c._src = [c._src]);
  518. for (var p = 0; p < c._src.length; p++) {
  519. var f, g;
  520. if (c._format && c._format[p]) f = c._format[p];
  521. else {
  522. if (((g = c._src[p]), typeof g != 'string')) {
  523. c._emit('loaderror', null, 'Non-string found in selected audio sources - ignoring.');
  524. continue;
  525. }
  526. (f = /^data:audio\/([^;,]+);/i.exec(g)), f || (f = /\.([^.]+)$/.exec(g.split('?', 1)[0])), f && (f = f[1].toLowerCase());
  527. }
  528. if (
  529. (f || console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),
  530. f && i.codecs(f))
  531. ) {
  532. d = c._src[p];
  533. break;
  534. }
  535. }
  536. if (!d) {
  537. c._emit('loaderror', null, 'No codec support for selected audio sources.');
  538. return;
  539. }
  540. return (
  541. (c._src = d),
  542. (c._state = 'loading'),
  543. window.location.protocol === 'https:' && d.slice(0, 5) === 'http:' && ((c._html5 = !0), (c._webAudio = !1)),
  544. new s(c),
  545. c._webAudio && a(c),
  546. c
  547. );
  548. },
  549. play: function (c, d) {
  550. var p = this,
  551. f = null;
  552. if (typeof c == 'number') (f = c), (c = null);
  553. else {
  554. if (typeof c == 'string' && p._state === 'loaded' && !p._sprite[c]) return null;
  555. if (typeof c > 'u' && ((c = '__default'), !p._playLock)) {
  556. for (var g = 0, m = 0; m < p._sounds.length; m++)
  557. p._sounds[m]._paused && !p._sounds[m]._ended && (g++, (f = p._sounds[m]._id));
  558. g === 1 ? (c = null) : (f = null);
  559. }
  560. }
  561. var v = f ? p._soundById(f) : p._inactiveSound();
  562. if (!v) return null;
  563. if ((f && !c && (c = v._sprite || '__default'), p._state !== 'loaded')) {
  564. (v._sprite = c), (v._ended = !1);
  565. var y = v._id;
  566. return (
  567. p._queue.push({
  568. event: 'play',
  569. action: function () {
  570. p.play(y);
  571. }
  572. }),
  573. y
  574. );
  575. }
  576. if (f && !v._paused) return d || p._loadQueue('play'), v._id;
  577. p._webAudio && i._autoResume();
  578. var b = Math.max(0, v._seek > 0 ? v._seek : p._sprite[c][0] / 1e3),
  579. x = Math.max(0, (p._sprite[c][0] + p._sprite[c][1]) / 1e3 - b),
  580. w = (x * 1e3) / Math.abs(v._rate),
  581. A = p._sprite[c][0] / 1e3,
  582. S = (p._sprite[c][0] + p._sprite[c][1]) / 1e3;
  583. (v._sprite = c), (v._ended = !1);
  584. var _ = function () {
  585. (v._paused = !1), (v._seek = b), (v._start = A), (v._stop = S), (v._loop = !!(v._loop || p._sprite[c][2]));
  586. };
  587. if (b >= S) {
  588. p._ended(v);
  589. return;
  590. }
  591. var M = v._node;
  592. if (p._webAudio) {
  593. var C = function () {
  594. (p._playLock = !1), _(), p._refreshBuffer(v);
  595. var D = v._muted || p._muted ? 0 : v._volume;
  596. M.gain.setValueAtTime(D, i.ctx.currentTime),
  597. (v._playStart = i.ctx.currentTime),
  598. typeof M.bufferSource.start > 'u'
  599. ? v._loop
  600. ? M.bufferSource.noteGrainOn(0, b, 86400)
  601. : M.bufferSource.noteGrainOn(0, b, x)
  602. : v._loop
  603. ? M.bufferSource.start(0, b, 86400)
  604. : M.bufferSource.start(0, b, x),
  605. w !== 1 / 0 && (p._endTimers[v._id] = setTimeout(p._ended.bind(p, v), w)),
  606. d ||
  607. setTimeout(function () {
  608. p._emit('play', v._id), p._loadQueue();
  609. }, 0);
  610. };
  611. i.state === 'running' && i.ctx.state !== 'interrupted' ? C() : ((p._playLock = !0), p.once('resume', C), p._clearTimer(v._id));
  612. } else {
  613. var T = function () {
  614. (M.currentTime = b),
  615. (M.muted = v._muted || p._muted || i._muted || M.muted),
  616. (M.volume = v._volume * i.volume()),
  617. (M.playbackRate = v._rate);
  618. try {
  619. var D = M.play();
  620. if (
  621. (D && typeof Promise < 'u' && (D instanceof Promise || typeof D.then == 'function')
  622. ? ((p._playLock = !0),
  623. _(),
  624. D.then(function () {
  625. (p._playLock = !1), (M._unlocked = !0), d ? p._loadQueue() : p._emit('play', v._id);
  626. }).catch(function () {
  627. (p._playLock = !1),
  628. p._emit(
  629. 'playerror',
  630. v._id,
  631. 'Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.'
  632. ),
  633. (v._ended = !0),
  634. (v._paused = !0);
  635. }))
  636. : d || ((p._playLock = !1), _(), p._emit('play', v._id)),
  637. (M.playbackRate = v._rate),
  638. M.paused)
  639. ) {
  640. p._emit(
  641. 'playerror',
  642. v._id,
  643. 'Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.'
  644. );
  645. return;
  646. }
  647. c !== '__default' || v._loop
  648. ? (p._endTimers[v._id] = setTimeout(p._ended.bind(p, v), w))
  649. : ((p._endTimers[v._id] = function () {
  650. p._ended(v), M.removeEventListener('ended', p._endTimers[v._id], !1);
  651. }),
  652. M.addEventListener('ended', p._endTimers[v._id], !1));
  653. } catch (k) {
  654. p._emit('playerror', v._id, k);
  655. }
  656. };
  657. M.src === 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA' &&
  658. ((M.src = p._src), M.load());
  659. var P = (window && window.ejecta) || (!M.readyState && i._navigator.isCocoonJS);
  660. if (M.readyState >= 3 || P) T();
  661. else {
  662. (p._playLock = !0), (p._state = 'loading');
  663. var L = function () {
  664. (p._state = 'loaded'), T(), M.removeEventListener(i._canPlayEvent, L, !1);
  665. };
  666. M.addEventListener(i._canPlayEvent, L, !1), p._clearTimer(v._id);
  667. }
  668. }
  669. return v._id;
  670. },
  671. pause: function (c) {
  672. var d = this;
  673. if (d._state !== 'loaded' || d._playLock)
  674. return (
  675. d._queue.push({
  676. event: 'pause',
  677. action: function () {
  678. d.pause(c);
  679. }
  680. }),
  681. d
  682. );
  683. for (var p = d._getSoundIds(c), f = 0; f < p.length; f++) {
  684. d._clearTimer(p[f]);
  685. var g = d._soundById(p[f]);
  686. if (g && !g._paused && ((g._seek = d.seek(p[f])), (g._rateSeek = 0), (g._paused = !0), d._stopFade(p[f]), g._node))
  687. if (d._webAudio) {
  688. if (!g._node.bufferSource) continue;
  689. typeof g._node.bufferSource.stop > 'u' ? g._node.bufferSource.noteOff(0) : g._node.bufferSource.stop(0),
  690. d._cleanBuffer(g._node);
  691. } else (!isNaN(g._node.duration) || g._node.duration === 1 / 0) && g._node.pause();
  692. arguments[1] || d._emit('pause', g ? g._id : null);
  693. }
  694. return d;
  695. },
  696. stop: function (c, d) {
  697. var p = this;
  698. if (p._state !== 'loaded' || p._playLock)
  699. return (
  700. p._queue.push({
  701. event: 'stop',
  702. action: function () {
  703. p.stop(c);
  704. }
  705. }),
  706. p
  707. );
  708. for (var f = p._getSoundIds(c), g = 0; g < f.length; g++) {
  709. p._clearTimer(f[g]);
  710. var m = p._soundById(f[g]);
  711. m &&
  712. ((m._seek = m._start || 0),
  713. (m._rateSeek = 0),
  714. (m._paused = !0),
  715. (m._ended = !0),
  716. p._stopFade(f[g]),
  717. m._node &&
  718. (p._webAudio
  719. ? m._node.bufferSource &&
  720. (typeof m._node.bufferSource.stop > 'u' ? m._node.bufferSource.noteOff(0) : m._node.bufferSource.stop(0),
  721. p._cleanBuffer(m._node))
  722. : (!isNaN(m._node.duration) || m._node.duration === 1 / 0) &&
  723. ((m._node.currentTime = m._start || 0), m._node.pause(), m._node.duration === 1 / 0 && p._clearSound(m._node))),
  724. d || p._emit('stop', m._id));
  725. }
  726. return p;
  727. },
  728. mute: function (c, d) {
  729. var p = this;
  730. if (p._state !== 'loaded' || p._playLock)
  731. return (
  732. p._queue.push({
  733. event: 'mute',
  734. action: function () {
  735. p.mute(c, d);
  736. }
  737. }),
  738. p
  739. );
  740. if (typeof d > 'u')
  741. if (typeof c == 'boolean') p._muted = c;
  742. else return p._muted;
  743. for (var f = p._getSoundIds(d), g = 0; g < f.length; g++) {
  744. var m = p._soundById(f[g]);
  745. m &&
  746. ((m._muted = c),
  747. m._interval && p._stopFade(m._id),
  748. p._webAudio && m._node
  749. ? m._node.gain.setValueAtTime(c ? 0 : m._volume, i.ctx.currentTime)
  750. : m._node && (m._node.muted = i._muted ? !0 : c),
  751. p._emit('mute', m._id));
  752. }
  753. return p;
  754. },
  755. volume: function () {
  756. var c = this,
  757. d = arguments,
  758. p,
  759. f;
  760. if (d.length === 0) return c._volume;
  761. if (d.length === 1 || (d.length === 2 && typeof d[1] > 'u')) {
  762. var g = c._getSoundIds(),
  763. m = g.indexOf(d[0]);
  764. m >= 0 ? (f = parseInt(d[0], 10)) : (p = parseFloat(d[0]));
  765. } else d.length >= 2 && ((p = parseFloat(d[0])), (f = parseInt(d[1], 10)));
  766. var v;
  767. if (typeof p < 'u' && p >= 0 && p <= 1) {
  768. if (c._state !== 'loaded' || c._playLock)
  769. return (
  770. c._queue.push({
  771. event: 'volume',
  772. action: function () {
  773. c.volume.apply(c, d);
  774. }
  775. }),
  776. c
  777. );
  778. typeof f > 'u' && (c._volume = p), (f = c._getSoundIds(f));
  779. for (var y = 0; y < f.length; y++)
  780. (v = c._soundById(f[y])),
  781. v &&
  782. ((v._volume = p),
  783. d[2] || c._stopFade(f[y]),
  784. c._webAudio && v._node && !v._muted
  785. ? v._node.gain.setValueAtTime(p, i.ctx.currentTime)
  786. : v._node && !v._muted && (v._node.volume = p * i.volume()),
  787. c._emit('volume', v._id));
  788. } else return (v = f ? c._soundById(f) : c._sounds[0]), v ? v._volume : 0;
  789. return c;
  790. },
  791. fade: function (c, d, p, f) {
  792. var g = this;
  793. if (g._state !== 'loaded' || g._playLock)
  794. return (
  795. g._queue.push({
  796. event: 'fade',
  797. action: function () {
  798. g.fade(c, d, p, f);
  799. }
  800. }),
  801. g
  802. );
  803. (c = Math.min(Math.max(0, parseFloat(c)), 1)), (d = Math.min(Math.max(0, parseFloat(d)), 1)), (p = parseFloat(p)), g.volume(c, f);
  804. for (var m = g._getSoundIds(f), v = 0; v < m.length; v++) {
  805. var y = g._soundById(m[v]);
  806. if (y) {
  807. if ((f || g._stopFade(m[v]), g._webAudio && !y._muted)) {
  808. var b = i.ctx.currentTime,
  809. x = b + p / 1e3;
  810. (y._volume = c), y._node.gain.setValueAtTime(c, b), y._node.gain.linearRampToValueAtTime(d, x);
  811. }
  812. g._startFadeInterval(y, c, d, p, m[v], typeof f > 'u');
  813. }
  814. }
  815. return g;
  816. },
  817. _startFadeInterval: function (c, d, p, f, g, m) {
  818. var v = this,
  819. y = d,
  820. b = p - d,
  821. x = Math.abs(b / 0.01),
  822. w = Math.max(4, x > 0 ? f / x : f),
  823. A = Date.now();
  824. (c._fadeTo = p),
  825. (c._interval = setInterval(function () {
  826. var S = (Date.now() - A) / f;
  827. (A = Date.now()),
  828. (y += b * S),
  829. (y = Math.round(y * 100) / 100),
  830. b < 0 ? (y = Math.max(p, y)) : (y = Math.min(p, y)),
  831. v._webAudio ? (c._volume = y) : v.volume(y, c._id, !0),
  832. m && (v._volume = y),
  833. ((p < d && y <= p) || (p > d && y >= p)) &&
  834. (clearInterval(c._interval), (c._interval = null), (c._fadeTo = null), v.volume(p, c._id), v._emit('fade', c._id));
  835. }, w));
  836. },
  837. _stopFade: function (c) {
  838. var d = this,
  839. p = d._soundById(c);
  840. return (
  841. p &&
  842. p._interval &&
  843. (d._webAudio && p._node.gain.cancelScheduledValues(i.ctx.currentTime),
  844. clearInterval(p._interval),
  845. (p._interval = null),
  846. d.volume(p._fadeTo, c),
  847. (p._fadeTo = null),
  848. d._emit('fade', c)),
  849. d
  850. );
  851. },
  852. loop: function () {
  853. var c = this,
  854. d = arguments,
  855. p,
  856. f,
  857. g;
  858. if (d.length === 0) return c._loop;
  859. if (d.length === 1)
  860. if (typeof d[0] == 'boolean') (p = d[0]), (c._loop = p);
  861. else return (g = c._soundById(parseInt(d[0], 10))), g ? g._loop : !1;
  862. else d.length === 2 && ((p = d[0]), (f = parseInt(d[1], 10)));
  863. for (var m = c._getSoundIds(f), v = 0; v < m.length; v++)
  864. (g = c._soundById(m[v])),
  865. g &&
  866. ((g._loop = p),
  867. c._webAudio &&
  868. g._node &&
  869. g._node.bufferSource &&
  870. ((g._node.bufferSource.loop = p),
  871. p &&
  872. ((g._node.bufferSource.loopStart = g._start || 0),
  873. (g._node.bufferSource.loopEnd = g._stop),
  874. c.playing(m[v]) && (c.pause(m[v], !0), c.play(m[v], !0)))));
  875. return c;
  876. },
  877. rate: function () {
  878. var c = this,
  879. d = arguments,
  880. p,
  881. f;
  882. if (d.length === 0) f = c._sounds[0]._id;
  883. else if (d.length === 1) {
  884. var g = c._getSoundIds(),
  885. m = g.indexOf(d[0]);
  886. m >= 0 ? (f = parseInt(d[0], 10)) : (p = parseFloat(d[0]));
  887. } else d.length === 2 && ((p = parseFloat(d[0])), (f = parseInt(d[1], 10)));
  888. var v;
  889. if (typeof p == 'number') {
  890. if (c._state !== 'loaded' || c._playLock)
  891. return (
  892. c._queue.push({
  893. event: 'rate',
  894. action: function () {
  895. c.rate.apply(c, d);
  896. }
  897. }),
  898. c
  899. );
  900. typeof f > 'u' && (c._rate = p), (f = c._getSoundIds(f));
  901. for (var y = 0; y < f.length; y++)
  902. if (((v = c._soundById(f[y])), v)) {
  903. c.playing(f[y]) && ((v._rateSeek = c.seek(f[y])), (v._playStart = c._webAudio ? i.ctx.currentTime : v._playStart)),
  904. (v._rate = p),
  905. c._webAudio && v._node && v._node.bufferSource
  906. ? v._node.bufferSource.playbackRate.setValueAtTime(p, i.ctx.currentTime)
  907. : v._node && (v._node.playbackRate = p);
  908. var b = c.seek(f[y]),
  909. x = (c._sprite[v._sprite][0] + c._sprite[v._sprite][1]) / 1e3 - b,
  910. w = (x * 1e3) / Math.abs(v._rate);
  911. (c._endTimers[f[y]] || !v._paused) && (c._clearTimer(f[y]), (c._endTimers[f[y]] = setTimeout(c._ended.bind(c, v), w))),
  912. c._emit('rate', v._id);
  913. }
  914. } else return (v = c._soundById(f)), v ? v._rate : c._rate;
  915. return c;
  916. },
  917. seek: function () {
  918. var c = this,
  919. d = arguments,
  920. p,
  921. f;
  922. if (d.length === 0) c._sounds.length && (f = c._sounds[0]._id);
  923. else if (d.length === 1) {
  924. var g = c._getSoundIds(),
  925. m = g.indexOf(d[0]);
  926. m >= 0 ? (f = parseInt(d[0], 10)) : c._sounds.length && ((f = c._sounds[0]._id), (p = parseFloat(d[0])));
  927. } else d.length === 2 && ((p = parseFloat(d[0])), (f = parseInt(d[1], 10)));
  928. if (typeof f > 'u') return 0;
  929. if (typeof p == 'number' && (c._state !== 'loaded' || c._playLock))
  930. return (
  931. c._queue.push({
  932. event: 'seek',
  933. action: function () {
  934. c.seek.apply(c, d);
  935. }
  936. }),
  937. c
  938. );
  939. var v = c._soundById(f);
  940. if (v)
  941. if (typeof p == 'number' && p >= 0) {
  942. var y = c.playing(f);
  943. y && c.pause(f, !0),
  944. (v._seek = p),
  945. (v._ended = !1),
  946. c._clearTimer(f),
  947. !c._webAudio && v._node && !isNaN(v._node.duration) && (v._node.currentTime = p);
  948. var b = function () {
  949. y && c.play(f, !0), c._emit('seek', f);
  950. };
  951. if (y && !c._webAudio) {
  952. var x = function () {
  953. c._playLock ? setTimeout(x, 0) : b();
  954. };
  955. setTimeout(x, 0);
  956. } else b();
  957. } else if (c._webAudio) {
  958. var w = c.playing(f) ? i.ctx.currentTime - v._playStart : 0,
  959. A = v._rateSeek ? v._rateSeek - v._seek : 0;
  960. return v._seek + (A + w * Math.abs(v._rate));
  961. } else return v._node.currentTime;
  962. return c;
  963. },
  964. playing: function (c) {
  965. var d = this;
  966. if (typeof c == 'number') {
  967. var p = d._soundById(c);
  968. return p ? !p._paused : !1;
  969. }
  970. for (var f = 0; f < d._sounds.length; f++) if (!d._sounds[f]._paused) return !0;
  971. return !1;
  972. },
  973. duration: function (c) {
  974. var d = this,
  975. p = d._duration,
  976. f = d._soundById(c);
  977. return f && (p = d._sprite[f._sprite][1] / 1e3), p;
  978. },
  979. state: function () {
  980. return this._state;
  981. },
  982. unload: function () {
  983. for (var c = this, d = c._sounds, p = 0; p < d.length; p++)
  984. d[p]._paused || c.stop(d[p]._id),
  985. c._webAudio ||
  986. (c._clearSound(d[p]._node),
  987. d[p]._node.removeEventListener('error', d[p]._errorFn, !1),
  988. d[p]._node.removeEventListener(i._canPlayEvent, d[p]._loadFn, !1),
  989. d[p]._node.removeEventListener('ended', d[p]._endFn, !1),
  990. i._releaseHtml5Audio(d[p]._node)),
  991. delete d[p]._node,
  992. c._clearTimer(d[p]._id);
  993. var f = i._howls.indexOf(c);
  994. f >= 0 && i._howls.splice(f, 1);
  995. var g = !0;
  996. for (p = 0; p < i._howls.length; p++)
  997. if (i._howls[p]._src === c._src || c._src.indexOf(i._howls[p]._src) >= 0) {
  998. g = !1;
  999. break;
  1000. }
  1001. return n && g && delete n[c._src], (i.noAudio = !1), (c._state = 'unloaded'), (c._sounds = []), (c = null), null;
  1002. },
  1003. on: function (c, d, p, f) {
  1004. var g = this,
  1005. m = g['_on' + c];
  1006. return typeof d == 'function' && m.push(f ? { id: p, fn: d, once: f } : { id: p, fn: d }), g;
  1007. },
  1008. off: function (c, d, p) {
  1009. var f = this,
  1010. g = f['_on' + c],
  1011. m = 0;
  1012. if ((typeof d == 'number' && ((p = d), (d = null)), d || p))
  1013. for (m = 0; m < g.length; m++) {
  1014. var v = p === g[m].id;
  1015. if ((d === g[m].fn && v) || (!d && v)) {
  1016. g.splice(m, 1);
  1017. break;
  1018. }
  1019. }
  1020. else if (c) f['_on' + c] = [];
  1021. else {
  1022. var y = Object.keys(f);
  1023. for (m = 0; m < y.length; m++) y[m].indexOf('_on') === 0 && Array.isArray(f[y[m]]) && (f[y[m]] = []);
  1024. }
  1025. return f;
  1026. },
  1027. once: function (c, d, p) {
  1028. var f = this;
  1029. return f.on(c, d, p, 1), f;
  1030. },
  1031. _emit: function (c, d, p) {
  1032. for (var f = this, g = f['_on' + c], m = g.length - 1; m >= 0; m--)
  1033. (!g[m].id || g[m].id === d || c === 'load') &&
  1034. (setTimeout(
  1035. function (v) {
  1036. v.call(this, d, p);
  1037. }.bind(f, g[m].fn),
  1038. 0
  1039. ),
  1040. g[m].once && f.off(c, g[m].fn, g[m].id));
  1041. return f._loadQueue(c), f;
  1042. },
  1043. _loadQueue: function (c) {
  1044. var d = this;
  1045. if (d._queue.length > 0) {
  1046. var p = d._queue[0];
  1047. p.event === c && (d._queue.shift(), d._loadQueue()), c || p.action();
  1048. }
  1049. return d;
  1050. },
  1051. _ended: function (c) {
  1052. var d = this,
  1053. p = c._sprite;
  1054. if (!d._webAudio && c._node && !c._node.paused && !c._node.ended && c._node.currentTime < c._stop)
  1055. return setTimeout(d._ended.bind(d, c), 100), d;
  1056. var f = !!(c._loop || d._sprite[p][2]);
  1057. if ((d._emit('end', c._id), !d._webAudio && f && d.stop(c._id, !0).play(c._id), d._webAudio && f)) {
  1058. d._emit('play', c._id), (c._seek = c._start || 0), (c._rateSeek = 0), (c._playStart = i.ctx.currentTime);
  1059. var g = ((c._stop - c._start) * 1e3) / Math.abs(c._rate);
  1060. d._endTimers[c._id] = setTimeout(d._ended.bind(d, c), g);
  1061. }
  1062. return (
  1063. d._webAudio &&
  1064. !f &&
  1065. ((c._paused = !0),
  1066. (c._ended = !0),
  1067. (c._seek = c._start || 0),
  1068. (c._rateSeek = 0),
  1069. d._clearTimer(c._id),
  1070. d._cleanBuffer(c._node),
  1071. i._autoSuspend()),
  1072. !d._webAudio && !f && d.stop(c._id, !0),
  1073. d
  1074. );
  1075. },
  1076. _clearTimer: function (c) {
  1077. var d = this;
  1078. if (d._endTimers[c]) {
  1079. if (typeof d._endTimers[c] != 'function') clearTimeout(d._endTimers[c]);
  1080. else {
  1081. var p = d._soundById(c);
  1082. p && p._node && p._node.removeEventListener('ended', d._endTimers[c], !1);
  1083. }
  1084. delete d._endTimers[c];
  1085. }
  1086. return d;
  1087. },
  1088. _soundById: function (c) {
  1089. for (var d = this, p = 0; p < d._sounds.length; p++) if (c === d._sounds[p]._id) return d._sounds[p];
  1090. return null;
  1091. },
  1092. _inactiveSound: function () {
  1093. var c = this;
  1094. c._drain();
  1095. for (var d = 0; d < c._sounds.length; d++) if (c._sounds[d]._ended) return c._sounds[d].reset();
  1096. return new s(c);
  1097. },
  1098. _drain: function () {
  1099. var c = this,
  1100. d = c._pool,
  1101. p = 0,
  1102. f = 0;
  1103. if (!(c._sounds.length < d)) {
  1104. for (f = 0; f < c._sounds.length; f++) c._sounds[f]._ended && p++;
  1105. for (f = c._sounds.length - 1; f >= 0; f--) {
  1106. if (p <= d) return;
  1107. c._sounds[f]._ended && (c._webAudio && c._sounds[f]._node && c._sounds[f]._node.disconnect(0), c._sounds.splice(f, 1), p--);
  1108. }
  1109. }
  1110. },
  1111. _getSoundIds: function (c) {
  1112. var d = this;
  1113. if (typeof c > 'u') {
  1114. for (var p = [], f = 0; f < d._sounds.length; f++) p.push(d._sounds[f]._id);
  1115. return p;
  1116. } else return [c];
  1117. },
  1118. _refreshBuffer: function (c) {
  1119. var d = this;
  1120. return (
  1121. (c._node.bufferSource = i.ctx.createBufferSource()),
  1122. (c._node.bufferSource.buffer = n[d._src]),
  1123. c._panner ? c._node.bufferSource.connect(c._panner) : c._node.bufferSource.connect(c._node),
  1124. (c._node.bufferSource.loop = c._loop),
  1125. c._loop && ((c._node.bufferSource.loopStart = c._start || 0), (c._node.bufferSource.loopEnd = c._stop || 0)),
  1126. c._node.bufferSource.playbackRate.setValueAtTime(c._rate, i.ctx.currentTime),
  1127. d
  1128. );
  1129. },
  1130. _cleanBuffer: function (c) {
  1131. var d = this,
  1132. p = i._navigator && i._navigator.vendor.indexOf('Apple') >= 0;
  1133. if (i._scratchBuffer && c.bufferSource && ((c.bufferSource.onended = null), c.bufferSource.disconnect(0), p))
  1134. try {
  1135. c.bufferSource.buffer = i._scratchBuffer;
  1136. } catch {}
  1137. return (c.bufferSource = null), d;
  1138. },
  1139. _clearSound: function (c) {
  1140. var d = /MSIE |Trident\//.test(i._navigator && i._navigator.userAgent);
  1141. d || (c.src = 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA');
  1142. }
  1143. };
  1144. var s = function (c) {
  1145. (this._parent = c), this.init();
  1146. };
  1147. s.prototype = {
  1148. init: function () {
  1149. var c = this,
  1150. d = c._parent;
  1151. return (
  1152. (c._muted = d._muted),
  1153. (c._loop = d._loop),
  1154. (c._volume = d._volume),
  1155. (c._rate = d._rate),
  1156. (c._seek = 0),
  1157. (c._paused = !0),
  1158. (c._ended = !0),
  1159. (c._sprite = '__default'),
  1160. (c._id = ++i._counter),
  1161. d._sounds.push(c),
  1162. c.create(),
  1163. c
  1164. );
  1165. },
  1166. create: function () {
  1167. var c = this,
  1168. d = c._parent,
  1169. p = i._muted || c._muted || c._parent._muted ? 0 : c._volume;
  1170. return (
  1171. d._webAudio
  1172. ? ((c._node = typeof i.ctx.createGain > 'u' ? i.ctx.createGainNode() : i.ctx.createGain()),
  1173. c._node.gain.setValueAtTime(p, i.ctx.currentTime),
  1174. (c._node.paused = !0),
  1175. c._node.connect(i.masterGain))
  1176. : i.noAudio ||
  1177. ((c._node = i._obtainHtml5Audio()),
  1178. (c._errorFn = c._errorListener.bind(c)),
  1179. c._node.addEventListener('error', c._errorFn, !1),
  1180. (c._loadFn = c._loadListener.bind(c)),
  1181. c._node.addEventListener(i._canPlayEvent, c._loadFn, !1),
  1182. (c._endFn = c._endListener.bind(c)),
  1183. c._node.addEventListener('ended', c._endFn, !1),
  1184. (c._node.src = d._src),
  1185. (c._node.preload = d._preload === !0 ? 'auto' : d._preload),
  1186. (c._node.volume = p * i.volume()),
  1187. c._node.load()),
  1188. c
  1189. );
  1190. },
  1191. reset: function () {
  1192. var c = this,
  1193. d = c._parent;
  1194. return (
  1195. (c._muted = d._muted),
  1196. (c._loop = d._loop),
  1197. (c._volume = d._volume),
  1198. (c._rate = d._rate),
  1199. (c._seek = 0),
  1200. (c._rateSeek = 0),
  1201. (c._paused = !0),
  1202. (c._ended = !0),
  1203. (c._sprite = '__default'),
  1204. (c._id = ++i._counter),
  1205. c
  1206. );
  1207. },
  1208. _errorListener: function () {
  1209. var c = this;
  1210. c._parent._emit('loaderror', c._id, c._node.error ? c._node.error.code : 0), c._node.removeEventListener('error', c._errorFn, !1);
  1211. },
  1212. _loadListener: function () {
  1213. var c = this,
  1214. d = c._parent;
  1215. (d._duration = Math.ceil(c._node.duration * 10) / 10),
  1216. Object.keys(d._sprite).length === 0 && (d._sprite = { __default: [0, d._duration * 1e3] }),
  1217. d._state !== 'loaded' && ((d._state = 'loaded'), d._emit('load'), d._loadQueue()),
  1218. c._node.removeEventListener(i._canPlayEvent, c._loadFn, !1);
  1219. },
  1220. _endListener: function () {
  1221. var c = this,
  1222. d = c._parent;
  1223. d._duration === 1 / 0 &&
  1224. ((d._duration = Math.ceil(c._node.duration * 10) / 10),
  1225. d._sprite.__default[1] === 1 / 0 && (d._sprite.__default[1] = d._duration * 1e3),
  1226. d._ended(c)),
  1227. c._node.removeEventListener('ended', c._endFn, !1);
  1228. }
  1229. };
  1230. var n = {},
  1231. a = function (c) {
  1232. var d = c._src;
  1233. if (n[d]) {
  1234. (c._duration = n[d].duration), h(c);
  1235. return;
  1236. }
  1237. if (/^data:[^;]+;base64,/.test(d)) {
  1238. for (var p = atob(d.split(',')[1]), f = new Uint8Array(p.length), g = 0; g < p.length; ++g) f[g] = p.charCodeAt(g);
  1239. l(f.buffer, c);
  1240. } else {
  1241. var m = new XMLHttpRequest();
  1242. m.open(c._xhr.method, d, !0),
  1243. (m.withCredentials = c._xhr.withCredentials),
  1244. (m.responseType = 'arraybuffer'),
  1245. c._xhr.headers &&
  1246. Object.keys(c._xhr.headers).forEach(function (v) {
  1247. m.setRequestHeader(v, c._xhr.headers[v]);
  1248. }),
  1249. (m.onload = function () {
  1250. var v = (m.status + '')[0];
  1251. if (v !== '0' && v !== '2' && v !== '3') {
  1252. c._emit('loaderror', null, 'Failed loading audio file with status: ' + m.status + '.');
  1253. return;
  1254. }
  1255. l(m.response, c);
  1256. }),
  1257. (m.onerror = function () {
  1258. c._webAudio && ((c._html5 = !0), (c._webAudio = !1), (c._sounds = []), delete n[d], c.load());
  1259. }),
  1260. o(m);
  1261. }
  1262. },
  1263. o = function (c) {
  1264. try {
  1265. c.send();
  1266. } catch {
  1267. c.onerror();
  1268. }
  1269. },
  1270. l = function (c, d) {
  1271. var p = function () {
  1272. d._emit('loaderror', null, 'Decoding audio data failed.');
  1273. },
  1274. f = function (g) {
  1275. g && d._sounds.length > 0 ? ((n[d._src] = g), h(d, g)) : p();
  1276. };
  1277. typeof Promise < 'u' && i.ctx.decodeAudioData.length === 1
  1278. ? i.ctx.decodeAudioData(c).then(f).catch(p)
  1279. : i.ctx.decodeAudioData(c, f, p);
  1280. },
  1281. h = function (c, d) {
  1282. d && !c._duration && (c._duration = d.duration),
  1283. Object.keys(c._sprite).length === 0 && (c._sprite = { __default: [0, c._duration * 1e3] }),
  1284. c._state !== 'loaded' && ((c._state = 'loaded'), c._emit('load'), c._loadQueue());
  1285. },
  1286. u = function () {
  1287. if (i.usingWebAudio) {
  1288. try {
  1289. typeof AudioContext < 'u'
  1290. ? (i.ctx = new AudioContext())
  1291. : typeof webkitAudioContext < 'u'
  1292. ? (i.ctx = new webkitAudioContext())
  1293. : (i.usingWebAudio = !1);
  1294. } catch {
  1295. i.usingWebAudio = !1;
  1296. }
  1297. i.ctx || (i.usingWebAudio = !1);
  1298. var c = /iP(hone|od|ad)/.test(i._navigator && i._navigator.platform),
  1299. d = i._navigator && i._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),
  1300. p = d ? parseInt(d[1], 10) : null;
  1301. if (c && p && p < 9) {
  1302. var f = /safari/.test(i._navigator && i._navigator.userAgent.toLowerCase());
  1303. i._navigator && !f && (i.usingWebAudio = !1);
  1304. }
  1305. i.usingWebAudio &&
  1306. ((i.masterGain = typeof i.ctx.createGain > 'u' ? i.ctx.createGainNode() : i.ctx.createGain()),
  1307. i.masterGain.gain.setValueAtTime(i._muted ? 0 : i._volume, i.ctx.currentTime),
  1308. i.masterGain.connect(i.ctx.destination)),
  1309. i._setup();
  1310. }
  1311. };
  1312. typeof define == 'function' &&
  1313. define.amd &&
  1314. define([], function () {
  1315. return { Howler: i, Howl: r };
  1316. }),
  1317. typeof e < 'u' && ((e.Howler = i), (e.Howl = r)),
  1318. typeof global < 'u'
  1319. ? ((global.HowlerGlobal = t), (global.Howler = i), (global.Howl = r), (global.Sound = s))
  1320. : typeof window < 'u' && ((window.HowlerGlobal = t), (window.Howler = i), (window.Howl = r), (window.Sound = s));
  1321. })(),
  1322. (function () {
  1323. 'use strict';
  1324. (HowlerGlobal.prototype._pos = [0, 0, 0]),
  1325. (HowlerGlobal.prototype._orientation = [0, 0, -1, 0, 1, 0]),
  1326. (HowlerGlobal.prototype.stereo = function (i) {
  1327. var r = this;
  1328. if (!r.ctx || !r.ctx.listener) return r;
  1329. for (var s = r._howls.length - 1; s >= 0; s--) r._howls[s].stereo(i);
  1330. return r;
  1331. }),
  1332. (HowlerGlobal.prototype.pos = function (i, r, s) {
  1333. var n = this;
  1334. if (!n.ctx || !n.ctx.listener) return n;
  1335. if (((r = typeof r != 'number' ? n._pos[1] : r), (s = typeof s != 'number' ? n._pos[2] : s), typeof i == 'number'))
  1336. (n._pos = [i, r, s]),
  1337. typeof n.ctx.listener.positionX < 'u'
  1338. ? (n.ctx.listener.positionX.setTargetAtTime(n._pos[0], Howler.ctx.currentTime, 0.1),
  1339. n.ctx.listener.positionY.setTargetAtTime(n._pos[1], Howler.ctx.currentTime, 0.1),
  1340. n.ctx.listener.positionZ.setTargetAtTime(n._pos[2], Howler.ctx.currentTime, 0.1))
  1341. : n.ctx.listener.setPosition(n._pos[0], n._pos[1], n._pos[2]);
  1342. else return n._pos;
  1343. return n;
  1344. }),
  1345. (HowlerGlobal.prototype.orientation = function (i, r, s, n, a, o) {
  1346. var l = this;
  1347. if (!l.ctx || !l.ctx.listener) return l;
  1348. var h = l._orientation;
  1349. if (
  1350. ((r = typeof r != 'number' ? h[1] : r),
  1351. (s = typeof s != 'number' ? h[2] : s),
  1352. (n = typeof n != 'number' ? h[3] : n),
  1353. (a = typeof a != 'number' ? h[4] : a),
  1354. (o = typeof o != 'number' ? h[5] : o),
  1355. typeof i == 'number')
  1356. )
  1357. (l._orientation = [i, r, s, n, a, o]),
  1358. typeof l.ctx.listener.forwardX < 'u'
  1359. ? (l.ctx.listener.forwardX.setTargetAtTime(i, Howler.ctx.currentTime, 0.1),
  1360. l.ctx.listener.forwardY.setTargetAtTime(r, Howler.ctx.currentTime, 0.1),
  1361. l.ctx.listener.forwardZ.setTargetAtTime(s, Howler.ctx.currentTime, 0.1),
  1362. l.ctx.listener.upX.setTargetAtTime(n, Howler.ctx.currentTime, 0.1),
  1363. l.ctx.listener.upY.setTargetAtTime(a, Howler.ctx.currentTime, 0.1),
  1364. l.ctx.listener.upZ.setTargetAtTime(o, Howler.ctx.currentTime, 0.1))
  1365. : l.ctx.listener.setOrientation(i, r, s, n, a, o);
  1366. else return h;
  1367. return l;
  1368. }),
  1369. (Howl.prototype.init = (function (i) {
  1370. return function (r) {
  1371. var s = this;
  1372. return (
  1373. (s._orientation = r.orientation || [1, 0, 0]),
  1374. (s._stereo = r.stereo || null),
  1375. (s._pos = r.pos || null),
  1376. (s._pannerAttr = {
  1377. coneInnerAngle: typeof r.coneInnerAngle < 'u' ? r.coneInnerAngle : 360,
  1378. coneOuterAngle: typeof r.coneOuterAngle < 'u' ? r.coneOuterAngle : 360,
  1379. coneOuterGain: typeof r.coneOuterGain < 'u' ? r.coneOuterGain : 0,
  1380. distanceModel: typeof r.distanceModel < 'u' ? r.distanceModel : 'inverse',
  1381. maxDistance: typeof r.maxDistance < 'u' ? r.maxDistance : 1e4,
  1382. panningModel: typeof r.panningModel < 'u' ? r.panningModel : 'HRTF',
  1383. refDistance: typeof r.refDistance < 'u' ? r.refDistance : 1,
  1384. rolloffFactor: typeof r.rolloffFactor < 'u' ? r.rolloffFactor : 1
  1385. }),
  1386. (s._onstereo = r.onstereo ? [{ fn: r.onstereo }] : []),
  1387. (s._onpos = r.onpos ? [{ fn: r.onpos }] : []),
  1388. (s._onorientation = r.onorientation ? [{ fn: r.onorientation }] : []),
  1389. i.call(this, r)
  1390. );
  1391. };
  1392. })(Howl.prototype.init)),
  1393. (Howl.prototype.stereo = function (i, r) {
  1394. var s = this;
  1395. if (!s._webAudio) return s;
  1396. if (s._state !== 'loaded')
  1397. return (
  1398. s._queue.push({
  1399. event: 'stereo',
  1400. action: function () {
  1401. s.stereo(i, r);
  1402. }
  1403. }),
  1404. s
  1405. );
  1406. var n = typeof Howler.ctx.createStereoPanner > 'u' ? 'spatial' : 'stereo';
  1407. if (typeof r > 'u')
  1408. if (typeof i == 'number') (s._stereo = i), (s._pos = [i, 0, 0]);
  1409. else return s._stereo;
  1410. for (var a = s._getSoundIds(r), o = 0; o < a.length; o++) {
  1411. var l = s._soundById(a[o]);
  1412. if (l)
  1413. if (typeof i == 'number')
  1414. (l._stereo = i),
  1415. (l._pos = [i, 0, 0]),
  1416. l._node &&
  1417. ((l._pannerAttr.panningModel = 'equalpower'),
  1418. (!l._panner || !l._panner.pan) && t(l, n),
  1419. n === 'spatial'
  1420. ? typeof l._panner.positionX < 'u'
  1421. ? (l._panner.positionX.setValueAtTime(i, Howler.ctx.currentTime),
  1422. l._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime),
  1423. l._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime))
  1424. : l._panner.setPosition(i, 0, 0)
  1425. : l._panner.pan.setValueAtTime(i, Howler.ctx.currentTime)),
  1426. s._emit('stereo', l._id);
  1427. else return l._stereo;
  1428. }
  1429. return s;
  1430. }),
  1431. (Howl.prototype.pos = function (i, r, s, n) {
  1432. var a = this;
  1433. if (!a._webAudio) return a;
  1434. if (a._state !== 'loaded')
  1435. return (
  1436. a._queue.push({
  1437. event: 'pos',
  1438. action: function () {
  1439. a.pos(i, r, s, n);
  1440. }
  1441. }),
  1442. a
  1443. );
  1444. if (((r = typeof r != 'number' ? 0 : r), (s = typeof s != 'number' ? -0.5 : s), typeof n > 'u'))
  1445. if (typeof i == 'number') a._pos = [i, r, s];
  1446. else return a._pos;
  1447. for (var o = a._getSoundIds(n), l = 0; l < o.length; l++) {
  1448. var h = a._soundById(o[l]);
  1449. if (h)
  1450. if (typeof i == 'number')
  1451. (h._pos = [i, r, s]),
  1452. h._node &&
  1453. ((!h._panner || h._panner.pan) && t(h, 'spatial'),
  1454. typeof h._panner.positionX < 'u'
  1455. ? (h._panner.positionX.setValueAtTime(i, Howler.ctx.currentTime),
  1456. h._panner.positionY.setValueAtTime(r, Howler.ctx.currentTime),
  1457. h._panner.positionZ.setValueAtTime(s, Howler.ctx.currentTime))
  1458. : h._panner.setPosition(i, r, s)),
  1459. a._emit('pos', h._id);
  1460. else return h._pos;
  1461. }
  1462. return a;
  1463. }),
  1464. (Howl.prototype.orientation = function (i, r, s, n) {
  1465. var a = this;
  1466. if (!a._webAudio) return a;
  1467. if (a._state !== 'loaded')
  1468. return (
  1469. a._queue.push({
  1470. event: 'orientation',
  1471. action: function () {
  1472. a.orientation(i, r, s, n);
  1473. }
  1474. }),
  1475. a
  1476. );
  1477. if (((r = typeof r != 'number' ? a._orientation[1] : r), (s = typeof s != 'number' ? a._orientation[2] : s), typeof n > 'u'))
  1478. if (typeof i == 'number') a._orientation = [i, r, s];
  1479. else return a._orientation;
  1480. for (var o = a._getSoundIds(n), l = 0; l < o.length; l++) {
  1481. var h = a._soundById(o[l]);
  1482. if (h)
  1483. if (typeof i == 'number')
  1484. (h._orientation = [i, r, s]),
  1485. h._node &&
  1486. (h._panner || (h._pos || (h._pos = a._pos || [0, 0, -0.5]), t(h, 'spatial')),
  1487. typeof h._panner.orientationX < 'u'
  1488. ? (h._panner.orientationX.setValueAtTime(i, Howler.ctx.currentTime),
  1489. h._panner.orientationY.setValueAtTime(r, Howler.ctx.currentTime),
  1490. h._panner.orientationZ.setValueAtTime(s, Howler.ctx.currentTime))
  1491. : h._panner.setOrientation(i, r, s)),
  1492. a._emit('orientation', h._id);
  1493. else return h._orientation;
  1494. }
  1495. return a;
  1496. }),
  1497. (Howl.prototype.pannerAttr = function () {
  1498. var i = this,
  1499. r = arguments,
  1500. s,
  1501. n,
  1502. a;
  1503. if (!i._webAudio) return i;
  1504. if (r.length === 0) return i._pannerAttr;
  1505. if (r.length === 1)
  1506. if (typeof r[0] == 'object')
  1507. (s = r[0]),
  1508. typeof n > 'u' &&
  1509. (s.pannerAttr ||
  1510. (s.pannerAttr = {
  1511. coneInnerAngle: s.coneInnerAngle,
  1512. coneOuterAngle: s.coneOuterAngle,
  1513. coneOuterGain: s.coneOuterGain,
  1514. distanceModel: s.distanceModel,
  1515. maxDistance: s.maxDistance,
  1516. refDistance: s.refDistance,
  1517. rolloffFactor: s.rolloffFactor,
  1518. panningModel: s.panningModel
  1519. }),
  1520. (i._pannerAttr = {
  1521. coneInnerAngle: typeof s.pannerAttr.coneInnerAngle < 'u' ? s.pannerAttr.coneInnerAngle : i._coneInnerAngle,
  1522. coneOuterAngle: typeof s.pannerAttr.coneOuterAngle < 'u' ? s.pannerAttr.coneOuterAngle : i._coneOuterAngle,
  1523. coneOuterGain: typeof s.pannerAttr.coneOuterGain < 'u' ? s.pannerAttr.coneOuterGain : i._coneOuterGain,
  1524. distanceModel: typeof s.pannerAttr.distanceModel < 'u' ? s.pannerAttr.distanceModel : i._distanceModel,
  1525. maxDistance: typeof s.pannerAttr.maxDistance < 'u' ? s.pannerAttr.maxDistance : i._maxDistance,
  1526. refDistance: typeof s.pannerAttr.refDistance < 'u' ? s.pannerAttr.refDistance : i._refDistance,
  1527. rolloffFactor: typeof s.pannerAttr.rolloffFactor < 'u' ? s.pannerAttr.rolloffFactor : i._rolloffFactor,
  1528. panningModel: typeof s.pannerAttr.panningModel < 'u' ? s.pannerAttr.panningModel : i._panningModel
  1529. }));
  1530. else return (a = i._soundById(parseInt(r[0], 10))), a ? a._pannerAttr : i._pannerAttr;
  1531. else r.length === 2 && ((s = r[0]), (n = parseInt(r[1], 10)));
  1532. for (var o = i._getSoundIds(n), l = 0; l < o.length; l++)
  1533. if (((a = i._soundById(o[l])), a)) {
  1534. var h = a._pannerAttr;
  1535. h = {
  1536. coneInnerAngle: typeof s.coneInnerAngle < 'u' ? s.coneInnerAngle : h.coneInnerAngle,
  1537. coneOuterAngle: typeof s.coneOuterAngle < 'u' ? s.coneOuterAngle : h.coneOuterAngle,
  1538. coneOuterGain: typeof s.coneOuterGain < 'u' ? s.coneOuterGain : h.coneOuterGain,
  1539. distanceModel: typeof s.distanceModel < 'u' ? s.distanceModel : h.distanceModel,
  1540. maxDistance: typeof s.maxDistance < 'u' ? s.maxDistance : h.maxDistance,
  1541. refDistance: typeof s.refDistance < 'u' ? s.refDistance : h.refDistance,
  1542. rolloffFactor: typeof s.rolloffFactor < 'u' ? s.rolloffFactor : h.rolloffFactor,
  1543. panningModel: typeof s.panningModel < 'u' ? s.panningModel : h.panningModel
  1544. };
  1545. var u = a._panner;
  1546. u
  1547. ? ((u.coneInnerAngle = h.coneInnerAngle),
  1548. (u.coneOuterAngle = h.coneOuterAngle),
  1549. (u.coneOuterGain = h.coneOuterGain),
  1550. (u.distanceModel = h.distanceModel),
  1551. (u.maxDistance = h.maxDistance),
  1552. (u.refDistance = h.refDistance),
  1553. (u.rolloffFactor = h.rolloffFactor),
  1554. (u.panningModel = h.panningModel))
  1555. : (a._pos || (a._pos = i._pos || [0, 0, -0.5]), t(a, 'spatial'));
  1556. }
  1557. return i;
  1558. }),
  1559. (Sound.prototype.init = (function (i) {
  1560. return function () {
  1561. var r = this,
  1562. s = r._parent;
  1563. (r._orientation = s._orientation),
  1564. (r._stereo = s._stereo),
  1565. (r._pos = s._pos),
  1566. (r._pannerAttr = s._pannerAttr),
  1567. i.call(this),
  1568. r._stereo ? s.stereo(r._stereo) : r._pos && s.pos(r._pos[0], r._pos[1], r._pos[2], r._id);
  1569. };
  1570. })(Sound.prototype.init)),
  1571. (Sound.prototype.reset = (function (i) {
  1572. return function () {
  1573. var r = this,
  1574. s = r._parent;
  1575. return (
  1576. (r._orientation = s._orientation),
  1577. (r._stereo = s._stereo),
  1578. (r._pos = s._pos),
  1579. (r._pannerAttr = s._pannerAttr),
  1580. r._stereo
  1581. ? s.stereo(r._stereo)
  1582. : r._pos
  1583. ? s.pos(r._pos[0], r._pos[1], r._pos[2], r._id)
  1584. : r._panner && (r._panner.disconnect(0), (r._panner = void 0), s._refreshBuffer(r)),
  1585. i.call(this)
  1586. );
  1587. };
  1588. })(Sound.prototype.reset));
  1589. var t = function (i, r) {
  1590. (r = r || 'spatial'),
  1591. r === 'spatial'
  1592. ? ((i._panner = Howler.ctx.createPanner()),
  1593. (i._panner.coneInnerAngle = i._pannerAttr.coneInnerAngle),
  1594. (i._panner.coneOuterAngle = i._pannerAttr.coneOuterAngle),
  1595. (i._panner.coneOuterGain = i._pannerAttr.coneOuterGain),
  1596. (i._panner.distanceModel = i._pannerAttr.distanceModel),
  1597. (i._panner.maxDistance = i._pannerAttr.maxDistance),
  1598. (i._panner.refDistance = i._pannerAttr.refDistance),
  1599. (i._panner.rolloffFactor = i._pannerAttr.rolloffFactor),
  1600. (i._panner.panningModel = i._pannerAttr.panningModel),
  1601. typeof i._panner.positionX < 'u'
  1602. ? (i._panner.positionX.setValueAtTime(i._pos[0], Howler.ctx.currentTime),
  1603. i._panner.positionY.setValueAtTime(i._pos[1], Howler.ctx.currentTime),
  1604. i._panner.positionZ.setValueAtTime(i._pos[2], Howler.ctx.currentTime))
  1605. : i._panner.setPosition(i._pos[0], i._pos[1], i._pos[2]),
  1606. typeof i._panner.orientationX < 'u'
  1607. ? (i._panner.orientationX.setValueAtTime(i._orientation[0], Howler.ctx.currentTime),
  1608. i._panner.orientationY.setValueAtTime(i._orientation[1], Howler.ctx.currentTime),
  1609. i._panner.orientationZ.setValueAtTime(i._orientation[2], Howler.ctx.currentTime))
  1610. : i._panner.setOrientation(i._orientation[0], i._orientation[1], i._orientation[2]))
  1611. : ((i._panner = Howler.ctx.createStereoPanner()), i._panner.pan.setValueAtTime(i._stereo, Howler.ctx.currentTime)),
  1612. i._panner.connect(i._node),
  1613. i._paused || i._parent.pause(i._id, !0).play(i._id, !0);
  1614. };
  1615. })();
  1616. }),
  1617. q2 = au((e, t) => {
  1618. t.exports = function (i, r) {
  1619. for (var s = i.split('.'), n = r.split('.'), a = 0; a < 3; a++) {
  1620. var o = Number(s[a]),
  1621. l = Number(n[a]);
  1622. if (o > l) return 1;
  1623. if (l > o) return -1;
  1624. if (!isNaN(o) && isNaN(l)) return 1;
  1625. if (isNaN(o) && !isNaN(l)) return -1;
  1626. }
  1627. return 0;
  1628. };
  1629. }),
  1630. Wo = '149',
  1631. hr = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 },
  1632. Y2 = 0,
  1633. Jv = 1,
  1634. Q2 = 2,
  1635. og = 1,
  1636. sw = 2,
  1637. jl = 3,
  1638. Vr = 0,
  1639. hi = 1,
  1640. er = 2,
  1641. fi = 0,
  1642. Ao = 1,
  1643. $v = 2,
  1644. e0 = 3,
  1645. t0 = 4,
  1646. Z2 = 5,
  1647. no = 100,
  1648. K2 = 101,
  1649. J2 = 102,
  1650. i0 = 103,
  1651. r0 = 104,
  1652. $2 = 200,
  1653. eM = 201,
  1654. tM = 202,
  1655. iM = 203,
  1656. nw = 204,
  1657. aw = 205,
  1658. rM = 206,
  1659. sM = 207,
  1660. nM = 208,
  1661. aM = 209,
  1662. oM = 210,
  1663. lM = 0,
  1664. hM = 1,
  1665. cM = 2,
  1666. Bf = 3,
  1667. dM = 4,
  1668. uM = 5,
  1669. pM = 6,
  1670. fM = 7,
  1671. ow = 0,
  1672. mM = 1,
  1673. gM = 2,
  1674. Gs = 0,
  1675. vM = 1,
  1676. yM = 2,
  1677. xM = 3,
  1678. bM = 4,
  1679. wM = 5,
  1680. lw = 300,
  1681. ya = 301,
  1682. xa = 302,
  1683. zf = 303,
  1684. Nf = 304,
  1685. Ch = 306,
  1686. oh = 1e3,
  1687. Ji = 1001,
  1688. Uf = 1002,
  1689. Ot = 1003,
  1690. s0 = 1004,
  1691. Wu = 1005,
  1692. mt = 1006,
  1693. _M = 1007,
  1694. Bo = 1008,
  1695. Mi = 1009,
  1696. AM = 1010,
  1697. SM = 1011,
  1698. hw = 1012,
  1699. MM = 1013,
  1700. gn = 1014,
  1701. vn = 1015,
  1702. lh = 1016,
  1703. EM = 1017,
  1704. CM = 1018,
  1705. ca = 1020,
  1706. TM = 1021,
  1707. Ur = 1023,
  1708. PM = 1024,
  1709. DM = 1025,
  1710. da = 1026,
  1711. ba = 1027,
  1712. LM = 1028,
  1713. OM = 1029,
  1714. IM = 1030,
  1715. RM = 1031,
  1716. BM = 1033,
  1717. Xu = 33776,
  1718. qu = 33777,
  1719. Yu = 33778,
  1720. Qu = 33779,
  1721. n0 = 35840,
  1722. a0 = 35841,
  1723. o0 = 35842,
  1724. l0 = 35843,
  1725. zM = 36196,
  1726. h0 = 37492,
  1727. c0 = 37496,
  1728. d0 = 37808,
  1729. u0 = 37809,
  1730. p0 = 37810,
  1731. f0 = 37811,
  1732. m0 = 37812,
  1733. g0 = 37813,
  1734. v0 = 37814,
  1735. y0 = 37815,
  1736. x0 = 37816,
  1737. b0 = 37817,
  1738. w0 = 37818,
  1739. _0 = 37819,
  1740. A0 = 37820,
  1741. S0 = 37821,
  1742. Zu = 36492,
  1743. NM = 36283,
  1744. M0 = 36284,
  1745. E0 = 36285,
  1746. C0 = 36286,
  1747. dd = 2300,
  1748. ud = 2301,
  1749. Ku = 2302,
  1750. T0 = 2400,
  1751. P0 = 2401,
  1752. D0 = 2402,
  1753. gs = 3e3,
  1754. Ke = 3001,
  1755. qs = 3200,
  1756. cw = 3201,
  1757. UM = 0,
  1758. FM = 1,
  1759. rs = 'srgb',
  1760. pd = 'srgb-linear',
  1761. Ju = 7680,
  1762. kM = 519,
  1763. Ff = 35044,
  1764. L0 = '300 es',
  1765. kf = 1035,
  1766. Vi = class {
  1767. addEventListener(e, t) {
  1768. this._listeners === void 0 && (this._listeners = {});
  1769. let i = this._listeners;
  1770. i[e] === void 0 && (i[e] = []), i[e].indexOf(t) === -1 && i[e].push(t);
  1771. }
  1772. hasEventListener(e, t) {
  1773. if (this._listeners === void 0) return !1;
  1774. let i = this._listeners;
  1775. return i[e] !== void 0 && i[e].indexOf(t) !== -1;
  1776. }
  1777. removeEventListener(e, t) {
  1778. if (this._listeners === void 0) return;
  1779. let i = this._listeners[e];
  1780. if (i !== void 0) {
  1781. let r = i.indexOf(t);
  1782. r !== -1 && i.splice(r, 1);
  1783. }
  1784. }
  1785. dispatchEvent(e) {
  1786. if (this._listeners === void 0) return;
  1787. let t = this._listeners[e.type];
  1788. if (t !== void 0) {
  1789. e.target = this;
  1790. let i = t.slice(0);
  1791. for (let r = 0, s = i.length; r < s; r++) i[r].call(this, e);
  1792. e.target = null;
  1793. }
  1794. }
  1795. },
  1796. yi = [
  1797. '00',
  1798. '01',
  1799. '02',
  1800. '03',
  1801. '04',
  1802. '05',
  1803. '06',
  1804. '07',
  1805. '08',
  1806. '09',
  1807. '0a',
  1808. '0b',
  1809. '0c',
  1810. '0d',
  1811. '0e',
  1812. '0f',
  1813. '10',
  1814. '11',
  1815. '12',
  1816. '13',
  1817. '14',
  1818. '15',
  1819. '16',
  1820. '17',
  1821. '18',
  1822. '19',
  1823. '1a',
  1824. '1b',
  1825. '1c',
  1826. '1d',
  1827. '1e',
  1828. '1f',
  1829. '20',
  1830. '21',
  1831. '22',
  1832. '23',
  1833. '24',
  1834. '25',
  1835. '26',
  1836. '27',
  1837. '28',
  1838. '29',
  1839. '2a',
  1840. '2b',
  1841. '2c',
  1842. '2d',
  1843. '2e',
  1844. '2f',
  1845. '30',
  1846. '31',
  1847. '32',
  1848. '33',
  1849. '34',
  1850. '35',
  1851. '36',
  1852. '37',
  1853. '38',
  1854. '39',
  1855. '3a',
  1856. '3b',
  1857. '3c',
  1858. '3d',
  1859. '3e',
  1860. '3f',
  1861. '40',
  1862. '41',
  1863. '42',
  1864. '43',
  1865. '44',
  1866. '45',
  1867. '46',
  1868. '47',
  1869. '48',
  1870. '49',
  1871. '4a',
  1872. '4b',
  1873. '4c',
  1874. '4d',
  1875. '4e',
  1876. '4f',
  1877. '50',
  1878. '51',
  1879. '52',
  1880. '53',
  1881. '54',
  1882. '55',
  1883. '56',
  1884. '57',
  1885. '58',
  1886. '59',
  1887. '5a',
  1888. '5b',
  1889. '5c',
  1890. '5d',
  1891. '5e',
  1892. '5f',
  1893. '60',
  1894. '61',
  1895. '62',
  1896. '63',
  1897. '64',
  1898. '65',
  1899. '66',
  1900. '67',
  1901. '68',
  1902. '69',
  1903. '6a',
  1904. '6b',
  1905. '6c',
  1906. '6d',
  1907. '6e',
  1908. '6f',
  1909. '70',
  1910. '71',
  1911. '72',
  1912. '73',
  1913. '74',
  1914. '75',
  1915. '76',
  1916. '77',
  1917. '78',
  1918. '79',
  1919. '7a',
  1920. '7b',
  1921. '7c',
  1922. '7d',
  1923. '7e',
  1924. '7f',
  1925. '80',
  1926. '81',
  1927. '82',
  1928. '83',
  1929. '84',
  1930. '85',
  1931. '86',
  1932. '87',
  1933. '88',
  1934. '89',
  1935. '8a',
  1936. '8b',
  1937. '8c',
  1938. '8d',
  1939. '8e',
  1940. '8f',
  1941. '90',
  1942. '91',
  1943. '92',
  1944. '93',
  1945. '94',
  1946. '95',
  1947. '96',
  1948. '97',
  1949. '98',
  1950. '99',
  1951. '9a',
  1952. '9b',
  1953. '9c',
  1954. '9d',
  1955. '9e',
  1956. '9f',
  1957. 'a0',
  1958. 'a1',
  1959. 'a2',
  1960. 'a3',
  1961. 'a4',
  1962. 'a5',
  1963. 'a6',
  1964. 'a7',
  1965. 'a8',
  1966. 'a9',
  1967. 'aa',
  1968. 'ab',
  1969. 'ac',
  1970. 'ad',
  1971. 'ae',
  1972. 'af',
  1973. 'b0',
  1974. 'b1',
  1975. 'b2',
  1976. 'b3',
  1977. 'b4',
  1978. 'b5',
  1979. 'b6',
  1980. 'b7',
  1981. 'b8',
  1982. 'b9',
  1983. 'ba',
  1984. 'bb',
  1985. 'bc',
  1986. 'bd',
  1987. 'be',
  1988. 'bf',
  1989. 'c0',
  1990. 'c1',
  1991. 'c2',
  1992. 'c3',
  1993. 'c4',
  1994. 'c5',
  1995. 'c6',
  1996. 'c7',
  1997. 'c8',
  1998. 'c9',
  1999. 'ca',
  2000. 'cb',
  2001. 'cc',
  2002. 'cd',
  2003. 'ce',
  2004. 'cf',
  2005. 'd0',
  2006. 'd1',
  2007. 'd2',
  2008. 'd3',
  2009. 'd4',
  2010. 'd5',
  2011. 'd6',
  2012. 'd7',
  2013. 'd8',
  2014. 'd9',
  2015. 'da',
  2016. 'db',
  2017. 'dc',
  2018. 'dd',
  2019. 'de',
  2020. 'df',
  2021. 'e0',
  2022. 'e1',
  2023. 'e2',
  2024. 'e3',
  2025. 'e4',
  2026. 'e5',
  2027. 'e6',
  2028. 'e7',
  2029. 'e8',
  2030. 'e9',
  2031. 'ea',
  2032. 'eb',
  2033. 'ec',
  2034. 'ed',
  2035. 'ee',
  2036. 'ef',
  2037. 'f0',
  2038. 'f1',
  2039. 'f2',
  2040. 'f3',
  2041. 'f4',
  2042. 'f5',
  2043. 'f6',
  2044. 'f7',
  2045. 'f8',
  2046. 'f9',
  2047. 'fa',
  2048. 'fb',
  2049. 'fc',
  2050. 'fd',
  2051. 'fe',
  2052. 'ff'
  2053. ],
  2054. O0 = 1234567,
  2055. Ql = Math.PI / 180,
  2056. hh = 180 / Math.PI;
  2057. function ps() {
  2058. let e = (Math.random() * 4294967295) | 0,
  2059. t = (Math.random() * 4294967295) | 0,
  2060. i = (Math.random() * 4294967295) | 0,
  2061. r = (Math.random() * 4294967295) | 0;
  2062. return (
  2063. yi[e & 255] +
  2064. yi[(e >> 8) & 255] +
  2065. yi[(e >> 16) & 255] +
  2066. yi[(e >> 24) & 255] +
  2067. '-' +
  2068. yi[t & 255] +
  2069. yi[(t >> 8) & 255] +
  2070. '-' +
  2071. yi[((t >> 16) & 15) | 64] +
  2072. yi[(t >> 24) & 255] +
  2073. '-' +
  2074. yi[(i & 63) | 128] +
  2075. yi[(i >> 8) & 255] +
  2076. '-' +
  2077. yi[(i >> 16) & 255] +
  2078. yi[(i >> 24) & 255] +
  2079. yi[r & 255] +
  2080. yi[(r >> 8) & 255] +
  2081. yi[(r >> 16) & 255] +
  2082. yi[(r >> 24) & 255]
  2083. ).toLowerCase();
  2084. }
  2085. function ti(e, t, i) {
  2086. return Math.max(t, Math.min(i, e));
  2087. }
  2088. function lg(e, t) {
  2089. return ((e % t) + t) % t;
  2090. }
  2091. function jM(e, t, i, r, s) {
  2092. return r + ((e - t) * (s - r)) / (i - t);
  2093. }
  2094. function GM(e, t, i) {
  2095. return e !== t ? (i - e) / (t - e) : 0;
  2096. }
  2097. function Zl(e, t, i) {
  2098. return (1 - i) * e + i * t;
  2099. }
  2100. function VM(e, t, i, r) {
  2101. return Zl(e, t, 1 - Math.exp(-i * r));
  2102. }
  2103. function HM(e, t = 1) {
  2104. return t - Math.abs(lg(e, t * 2) - t);
  2105. }
  2106. function WM(e, t, i) {
  2107. return e <= t ? 0 : e >= i ? 1 : ((e = (e - t) / (i - t)), e * e * (3 - 2 * e));
  2108. }
  2109. function XM(e, t, i) {
  2110. return e <= t ? 0 : e >= i ? 1 : ((e = (e - t) / (i - t)), e * e * e * (e * (e * 6 - 15) + 10));
  2111. }
  2112. function qM(e, t) {
  2113. return e + Math.floor(Math.random() * (t - e + 1));
  2114. }
  2115. function YM(e, t) {
  2116. return e + Math.random() * (t - e);
  2117. }
  2118. function QM(e) {
  2119. return e * (0.5 - Math.random());
  2120. }
  2121. function ZM(e) {
  2122. e !== void 0 && (O0 = e);
  2123. let t = (O0 += 1831565813);
  2124. return (t = Math.imul(t ^ (t >>> 15), t | 1)), (t ^= t + Math.imul(t ^ (t >>> 7), t | 61)), ((t ^ (t >>> 14)) >>> 0) / 4294967296;
  2125. }
  2126. function KM(e) {
  2127. return e * Ql;
  2128. }
  2129. function JM(e) {
  2130. return e * hh;
  2131. }
  2132. function jf(e) {
  2133. return (e & (e - 1)) === 0 && e !== 0;
  2134. }
  2135. function $M(e) {
  2136. return Math.pow(2, Math.ceil(Math.log(e) / Math.LN2));
  2137. }
  2138. function fd(e) {
  2139. return Math.pow(2, Math.floor(Math.log(e) / Math.LN2));
  2140. }
  2141. function eE(e, t, i, r, s) {
  2142. let n = Math.cos,
  2143. a = Math.sin,
  2144. o = n(i / 2),
  2145. l = a(i / 2),
  2146. h = n((t + r) / 2),
  2147. u = a((t + r) / 2),
  2148. c = n((t - r) / 2),
  2149. d = a((t - r) / 2),
  2150. p = n((r - t) / 2),
  2151. f = a((r - t) / 2);
  2152. switch (s) {
  2153. case 'XYX':
  2154. e.set(o * u, l * c, l * d, o * h);
  2155. break;
  2156. case 'YZY':
  2157. e.set(l * d, o * u, l * c, o * h);
  2158. break;
  2159. case 'ZXZ':
  2160. e.set(l * c, l * d, o * u, o * h);
  2161. break;
  2162. case 'XZX':
  2163. e.set(o * u, l * f, l * p, o * h);
  2164. break;
  2165. case 'YXY':
  2166. e.set(l * p, o * u, l * f, o * h);
  2167. break;
  2168. case 'ZYZ':
  2169. e.set(l * f, l * p, o * u, o * h);
  2170. break;
  2171. default:
  2172. console.warn('THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + s);
  2173. }
  2174. }
  2175. function ks(e, t) {
  2176. switch (t.constructor) {
  2177. case Float32Array:
  2178. return e;
  2179. case Uint16Array:
  2180. return e / 65535;
  2181. case Uint8Array:
  2182. return e / 255;
  2183. case Int16Array:
  2184. return Math.max(e / 32767, -1);
  2185. case Int8Array:
  2186. return Math.max(e / 127, -1);
  2187. default:
  2188. throw new Error('Invalid component type.');
  2189. }
  2190. }
  2191. function _t(e, t) {
  2192. switch (t.constructor) {
  2193. case Float32Array:
  2194. return e;
  2195. case Uint16Array:
  2196. return Math.round(e * 65535);
  2197. case Uint8Array:
  2198. return Math.round(e * 255);
  2199. case Int16Array:
  2200. return Math.round(e * 32767);
  2201. case Int8Array:
  2202. return Math.round(e * 127);
  2203. default:
  2204. throw new Error('Invalid component type.');
  2205. }
  2206. }
  2207. var it = Object.freeze({
  2208. __proto__: null,
  2209. DEG2RAD: Ql,
  2210. RAD2DEG: hh,
  2211. ceilPowerOfTwo: $M,
  2212. clamp: ti,
  2213. damp: VM,
  2214. degToRad: KM,
  2215. denormalize: ks,
  2216. euclideanModulo: lg,
  2217. floorPowerOfTwo: fd,
  2218. generateUUID: ps,
  2219. inverseLerp: GM,
  2220. isPowerOfTwo: jf,
  2221. lerp: Zl,
  2222. mapLinear: jM,
  2223. normalize: _t,
  2224. pingpong: HM,
  2225. radToDeg: JM,
  2226. randFloat: YM,
  2227. randFloatSpread: QM,
  2228. randInt: qM,
  2229. seededRandom: ZM,
  2230. setQuaternionFromProperEuler: eE,
  2231. smootherstep: XM,
  2232. smoothstep: WM
  2233. }),
  2234. G = class {
  2235. constructor(e = 0, t = 0) {
  2236. (G.prototype.isVector2 = !0), (this.x = e), (this.y = t);
  2237. }
  2238. get width() {
  2239. return this.x;
  2240. }
  2241. set width(e) {
  2242. this.x = e;
  2243. }
  2244. get height() {
  2245. return this.y;
  2246. }
  2247. set height(e) {
  2248. this.y = e;
  2249. }
  2250. set(e, t) {
  2251. return (this.x = e), (this.y = t), this;
  2252. }
  2253. setScalar(e) {
  2254. return (this.x = e), (this.y = e), this;
  2255. }
  2256. setX(e) {
  2257. return (this.x = e), this;
  2258. }
  2259. setY(e) {
  2260. return (this.y = e), this;
  2261. }
  2262. setComponent(e, t) {
  2263. switch (e) {
  2264. case 0:
  2265. this.x = t;
  2266. break;
  2267. case 1:
  2268. this.y = t;
  2269. break;
  2270. default:
  2271. throw new Error('index is out of range: ' + e);
  2272. }
  2273. return this;
  2274. }
  2275. getComponent(e) {
  2276. switch (e) {
  2277. case 0:
  2278. return this.x;
  2279. case 1:
  2280. return this.y;
  2281. default:
  2282. throw new Error('index is out of range: ' + e);
  2283. }
  2284. }
  2285. clone() {
  2286. return new this.constructor(this.x, this.y);
  2287. }
  2288. copy(e) {
  2289. return (this.x = e.x), (this.y = e.y), this;
  2290. }
  2291. add(e) {
  2292. return (this.x += e.x), (this.y += e.y), this;
  2293. }
  2294. addScalar(e) {
  2295. return (this.x += e), (this.y += e), this;
  2296. }
  2297. addVectors(e, t) {
  2298. return (this.x = e.x + t.x), (this.y = e.y + t.y), this;
  2299. }
  2300. addScaledVector(e, t) {
  2301. return (this.x += e.x * t), (this.y += e.y * t), this;
  2302. }
  2303. sub(e) {
  2304. return (this.x -= e.x), (this.y -= e.y), this;
  2305. }
  2306. subScalar(e) {
  2307. return (this.x -= e), (this.y -= e), this;
  2308. }
  2309. subVectors(e, t) {
  2310. return (this.x = e.x - t.x), (this.y = e.y - t.y), this;
  2311. }
  2312. multiply(e) {
  2313. return (this.x *= e.x), (this.y *= e.y), this;
  2314. }
  2315. multiplyScalar(e) {
  2316. return (this.x *= e), (this.y *= e), this;
  2317. }
  2318. divide(e) {
  2319. return (this.x /= e.x), (this.y /= e.y), this;
  2320. }
  2321. divideScalar(e) {
  2322. return this.multiplyScalar(1 / e);
  2323. }
  2324. applyMatrix3(e) {
  2325. let t = this.x,
  2326. i = this.y,
  2327. r = e.elements;
  2328. return (this.x = r[0] * t + r[3] * i + r[6]), (this.y = r[1] * t + r[4] * i + r[7]), this;
  2329. }
  2330. min(e) {
  2331. return (this.x = Math.min(this.x, e.x)), (this.y = Math.min(this.y, e.y)), this;
  2332. }
  2333. max(e) {
  2334. return (this.x = Math.max(this.x, e.x)), (this.y = Math.max(this.y, e.y)), this;
  2335. }
  2336. clamp(e, t) {
  2337. 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;
  2338. }
  2339. clampScalar(e, t) {
  2340. return (this.x = Math.max(e, Math.min(t, this.x))), (this.y = Math.max(e, Math.min(t, this.y))), this;
  2341. }
  2342. clampLength(e, t) {
  2343. let i = this.length();
  2344. return this.divideScalar(i || 1).multiplyScalar(Math.max(e, Math.min(t, i)));
  2345. }
  2346. floor() {
  2347. return (this.x = Math.floor(this.x)), (this.y = Math.floor(this.y)), this;
  2348. }
  2349. ceil() {
  2350. return (this.x = Math.ceil(this.x)), (this.y = Math.ceil(this.y)), this;
  2351. }
  2352. round() {
  2353. return (this.x = Math.round(this.x)), (this.y = Math.round(this.y)), this;
  2354. }
  2355. roundToZero() {
  2356. return (
  2357. (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
  2358. );
  2359. }
  2360. negate() {
  2361. return (this.x = -this.x), (this.y = -this.y), this;
  2362. }
  2363. dot(e) {
  2364. return this.x * e.x + this.y * e.y;
  2365. }
  2366. cross(e) {
  2367. return this.x * e.y - this.y * e.x;
  2368. }
  2369. lengthSq() {
  2370. return this.x * this.x + this.y * this.y;
  2371. }
  2372. length() {
  2373. return Math.sqrt(this.x * this.x + this.y * this.y);
  2374. }
  2375. manhattanLength() {
  2376. return Math.abs(this.x) + Math.abs(this.y);
  2377. }
  2378. normalize() {
  2379. return this.divideScalar(this.length() || 1);
  2380. }
  2381. angle() {
  2382. return Math.atan2(-this.y, -this.x) + Math.PI;
  2383. }
  2384. distanceTo(e) {
  2385. return Math.sqrt(this.distanceToSquared(e));
  2386. }
  2387. distanceToSquared(e) {
  2388. let t = this.x - e.x,
  2389. i = this.y - e.y;
  2390. return t * t + i * i;
  2391. }
  2392. manhattanDistanceTo(e) {
  2393. return Math.abs(this.x - e.x) + Math.abs(this.y - e.y);
  2394. }
  2395. setLength(e) {
  2396. return this.normalize().multiplyScalar(e);
  2397. }
  2398. lerp(e, t) {
  2399. return (this.x += (e.x - this.x) * t), (this.y += (e.y - this.y) * t), this;
  2400. }
  2401. lerpVectors(e, t, i) {
  2402. return (this.x = e.x + (t.x - e.x) * i), (this.y = e.y + (t.y - e.y) * i), this;
  2403. }
  2404. equals(e) {
  2405. return e.x === this.x && e.y === this.y;
  2406. }
  2407. fromArray(e, t = 0) {
  2408. return (this.x = e[t]), (this.y = e[t + 1]), this;
  2409. }
  2410. toArray(e = [], t = 0) {
  2411. return (e[t] = this.x), (e[t + 1] = this.y), e;
  2412. }
  2413. fromBufferAttribute(e, t) {
  2414. return (this.x = e.getX(t)), (this.y = e.getY(t)), this;
  2415. }
  2416. rotateAround(e, t) {
  2417. let i = Math.cos(t),
  2418. r = Math.sin(t),
  2419. s = this.x - e.x,
  2420. n = this.y - e.y;
  2421. return (this.x = s * i - n * r + e.x), (this.y = s * r + n * i + e.y), this;
  2422. }
  2423. random() {
  2424. return (this.x = Math.random()), (this.y = Math.random()), this;
  2425. }
  2426. *[Symbol.iterator]() {
  2427. yield this.x, yield this.y;
  2428. }
  2429. },
  2430. Ai = class {
  2431. constructor() {
  2432. (Ai.prototype.isMatrix3 = !0), (this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1]);
  2433. }
  2434. set(e, t, i, r, s, n, a, o, l) {
  2435. let h = this.elements;
  2436. return (h[0] = e), (h[1] = r), (h[2] = a), (h[3] = t), (h[4] = s), (h[5] = o), (h[6] = i), (h[7] = n), (h[8] = l), this;
  2437. }
  2438. identity() {
  2439. return this.set(1, 0, 0, 0, 1, 0, 0, 0, 1), this;
  2440. }
  2441. copy(e) {
  2442. let t = this.elements,
  2443. i = e.elements;
  2444. return (
  2445. (t[0] = i[0]),
  2446. (t[1] = i[1]),
  2447. (t[2] = i[2]),
  2448. (t[3] = i[3]),
  2449. (t[4] = i[4]),
  2450. (t[5] = i[5]),
  2451. (t[6] = i[6]),
  2452. (t[7] = i[7]),
  2453. (t[8] = i[8]),
  2454. this
  2455. );
  2456. }
  2457. extractBasis(e, t, i) {
  2458. return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), i.setFromMatrix3Column(this, 2), this;
  2459. }
  2460. setFromMatrix4(e) {
  2461. let t = e.elements;
  2462. return this.set(t[0], t[4], t[8], t[1], t[5], t[9], t[2], t[6], t[10]), this;
  2463. }
  2464. multiply(e) {
  2465. return this.multiplyMatrices(this, e);
  2466. }
  2467. premultiply(e) {
  2468. return this.multiplyMatrices(e, this);
  2469. }
  2470. multiplyMatrices(e, t) {
  2471. let i = e.elements,
  2472. r = t.elements,
  2473. s = this.elements,
  2474. n = i[0],
  2475. a = i[3],
  2476. o = i[6],
  2477. l = i[1],
  2478. h = i[4],
  2479. u = i[7],
  2480. c = i[2],
  2481. d = i[5],
  2482. p = i[8],
  2483. f = r[0],
  2484. g = r[3],
  2485. m = r[6],
  2486. v = r[1],
  2487. y = r[4],
  2488. b = r[7],
  2489. x = r[2],
  2490. w = r[5],
  2491. A = r[8];
  2492. return (
  2493. (s[0] = n * f + a * v + o * x),
  2494. (s[3] = n * g + a * y + o * w),
  2495. (s[6] = n * m + a * b + o * A),
  2496. (s[1] = l * f + h * v + u * x),
  2497. (s[4] = l * g + h * y + u * w),
  2498. (s[7] = l * m + h * b + u * A),
  2499. (s[2] = c * f + d * v + p * x),
  2500. (s[5] = c * g + d * y + p * w),
  2501. (s[8] = c * m + d * b + p * A),
  2502. this
  2503. );
  2504. }
  2505. multiplyScalar(e) {
  2506. let t = this.elements;
  2507. 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;
  2508. }
  2509. determinant() {
  2510. let e = this.elements,
  2511. t = e[0],
  2512. i = e[1],
  2513. r = e[2],
  2514. s = e[3],
  2515. n = e[4],
  2516. a = e[5],
  2517. o = e[6],
  2518. l = e[7],
  2519. h = e[8];
  2520. return t * n * h - t * a * l - i * s * h + i * a * o + r * s * l - r * n * o;
  2521. }
  2522. invert() {
  2523. let e = this.elements,
  2524. t = e[0],
  2525. i = e[1],
  2526. r = e[2],
  2527. s = e[3],
  2528. n = e[4],
  2529. a = e[5],
  2530. o = e[6],
  2531. l = e[7],
  2532. h = e[8],
  2533. u = h * n - a * l,
  2534. c = a * o - h * s,
  2535. d = l * s - n * o,
  2536. p = t * u + i * c + r * d;
  2537. if (p === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
  2538. let f = 1 / p;
  2539. return (
  2540. (e[0] = u * f),
  2541. (e[1] = (r * l - h * i) * f),
  2542. (e[2] = (a * i - r * n) * f),
  2543. (e[3] = c * f),
  2544. (e[4] = (h * t - r * o) * f),
  2545. (e[5] = (r * s - a * t) * f),
  2546. (e[6] = d * f),
  2547. (e[7] = (i * o - l * t) * f),
  2548. (e[8] = (n * t - i * s) * f),
  2549. this
  2550. );
  2551. }
  2552. transpose() {
  2553. let e,
  2554. t = this.elements;
  2555. 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;
  2556. }
  2557. getNormalMatrix(e) {
  2558. return this.setFromMatrix4(e).invert().transpose();
  2559. }
  2560. transposeIntoArray(e) {
  2561. let t = this.elements;
  2562. return (
  2563. (e[0] = t[0]),
  2564. (e[1] = t[3]),
  2565. (e[2] = t[6]),
  2566. (e[3] = t[1]),
  2567. (e[4] = t[4]),
  2568. (e[5] = t[7]),
  2569. (e[6] = t[2]),
  2570. (e[7] = t[5]),
  2571. (e[8] = t[8]),
  2572. this
  2573. );
  2574. }
  2575. setUvTransform(e, t, i, r, s, n, a) {
  2576. let o = Math.cos(s),
  2577. l = Math.sin(s);
  2578. return this.set(i * o, i * l, -i * (o * n + l * a) + n + e, -r * l, r * o, -r * (-l * n + o * a) + a + t, 0, 0, 1), this;
  2579. }
  2580. scale(e, t) {
  2581. return this.premultiply($u.makeScale(e, t)), this;
  2582. }
  2583. rotate(e) {
  2584. return this.premultiply($u.makeRotation(-e)), this;
  2585. }
  2586. translate(e, t) {
  2587. return this.premultiply($u.makeTranslation(e, t)), this;
  2588. }
  2589. makeTranslation(e, t) {
  2590. return this.set(1, 0, e, 0, 1, t, 0, 0, 1), this;
  2591. }
  2592. makeRotation(e) {
  2593. let t = Math.cos(e),
  2594. i = Math.sin(e);
  2595. return this.set(t, -i, 0, i, t, 0, 0, 0, 1), this;
  2596. }
  2597. makeScale(e, t) {
  2598. return this.set(e, 0, 0, 0, t, 0, 0, 0, 1), this;
  2599. }
  2600. equals(e) {
  2601. let t = this.elements,
  2602. i = e.elements;
  2603. for (let r = 0; r < 9; r++) if (t[r] !== i[r]) return !1;
  2604. return !0;
  2605. }
  2606. fromArray(e, t = 0) {
  2607. for (let i = 0; i < 9; i++) this.elements[i] = e[i + t];
  2608. return this;
  2609. }
  2610. toArray(e = [], t = 0) {
  2611. let i = this.elements;
  2612. return (
  2613. (e[t] = i[0]),
  2614. (e[t + 1] = i[1]),
  2615. (e[t + 2] = i[2]),
  2616. (e[t + 3] = i[3]),
  2617. (e[t + 4] = i[4]),
  2618. (e[t + 5] = i[5]),
  2619. (e[t + 6] = i[6]),
  2620. (e[t + 7] = i[7]),
  2621. (e[t + 8] = i[8]),
  2622. e
  2623. );
  2624. }
  2625. clone() {
  2626. return new this.constructor().fromArray(this.elements);
  2627. }
  2628. },
  2629. $u = new Ai();
  2630. function dw(e) {
  2631. for (let t = e.length - 1; t >= 0; --t) if (e[t] >= 65535) return !0;
  2632. return !1;
  2633. }
  2634. var tE = {
  2635. Int8Array: Int8Array,
  2636. Uint8Array: Uint8Array,
  2637. Uint8ClampedArray: Uint8ClampedArray,
  2638. Int16Array: Int16Array,
  2639. Uint16Array: Uint16Array,
  2640. Int32Array: Int32Array,
  2641. Uint32Array: Uint32Array,
  2642. Float32Array: Float32Array,
  2643. Float64Array: Float64Array
  2644. };
  2645. function Wh(e, t) {
  2646. return new tE[e](t);
  2647. }
  2648. function md(e) {
  2649. return document.createElementNS('http://www.w3.org/1999/xhtml', e);
  2650. }
  2651. function ua(e) {
  2652. return e < 0.04045 ? e * 0.0773993808 : Math.pow(e * 0.9478672986 + 0.0521327014, 2.4);
  2653. }
  2654. function Kc(e) {
  2655. return e < 0.0031308 ? e * 12.92 : 1.055 * Math.pow(e, 0.41666) - 0.055;
  2656. }
  2657. var ep = { [rs]: { [pd]: ua }, [pd]: { [rs]: Kc } },
  2658. Ci = {
  2659. legacyMode: !0,
  2660. get workingColorSpace() {
  2661. return pd;
  2662. },
  2663. set workingColorSpace(e) {
  2664. console.warn('THREE.ColorManagement: .workingColorSpace is readonly.');
  2665. },
  2666. convert: function (e, t, i) {
  2667. if (this.legacyMode || t === i || !t || !i) return e;
  2668. if (ep[t] && ep[t][i] !== void 0) {
  2669. let r = ep[t][i];
  2670. return (e.r = r(e.r)), (e.g = r(e.g)), (e.b = r(e.b)), e;
  2671. }
  2672. throw new Error('Unsupported color space conversion.');
  2673. },
  2674. fromWorkingColorSpace: function (e, t) {
  2675. return this.convert(e, this.workingColorSpace, t);
  2676. },
  2677. toWorkingColorSpace: function (e, t) {
  2678. return this.convert(e, t, this.workingColorSpace);
  2679. }
  2680. },
  2681. uw = {
  2682. aliceblue: 15792383,
  2683. antiquewhite: 16444375,
  2684. aqua: 65535,
  2685. aquamarine: 8388564,
  2686. azure: 15794175,
  2687. beige: 16119260,
  2688. bisque: 16770244,
  2689. black: 0,
  2690. blanchedalmond: 16772045,
  2691. blue: 255,
  2692. blueviolet: 9055202,
  2693. brown: 10824234,
  2694. burlywood: 14596231,
  2695. cadetblue: 6266528,
  2696. chartreuse: 8388352,
  2697. chocolate: 13789470,
  2698. coral: 16744272,
  2699. cornflowerblue: 6591981,
  2700. cornsilk: 16775388,
  2701. crimson: 14423100,
  2702. cyan: 65535,
  2703. darkblue: 139,
  2704. darkcyan: 35723,
  2705. darkgoldenrod: 12092939,
  2706. darkgray: 11119017,
  2707. darkgreen: 25600,
  2708. darkgrey: 11119017,
  2709. darkkhaki: 12433259,
  2710. darkmagenta: 9109643,
  2711. darkolivegreen: 5597999,
  2712. darkorange: 16747520,
  2713. darkorchid: 10040012,
  2714. darkred: 9109504,
  2715. darksalmon: 15308410,
  2716. darkseagreen: 9419919,
  2717. darkslateblue: 4734347,
  2718. darkslategray: 3100495,
  2719. darkslategrey: 3100495,
  2720. darkturquoise: 52945,
  2721. darkviolet: 9699539,
  2722. deeppink: 16716947,
  2723. deepskyblue: 49151,
  2724. dimgray: 6908265,
  2725. dimgrey: 6908265,
  2726. dodgerblue: 2003199,
  2727. firebrick: 11674146,
  2728. floralwhite: 16775920,
  2729. forestgreen: 2263842,
  2730. fuchsia: 16711935,
  2731. gainsboro: 14474460,
  2732. ghostwhite: 16316671,
  2733. gold: 16766720,
  2734. goldenrod: 14329120,
  2735. gray: 8421504,
  2736. green: 32768,
  2737. greenyellow: 11403055,
  2738. grey: 8421504,
  2739. honeydew: 15794160,
  2740. hotpink: 16738740,
  2741. indianred: 13458524,
  2742. indigo: 4915330,
  2743. ivory: 16777200,
  2744. khaki: 15787660,
  2745. lavender: 15132410,
  2746. lavenderblush: 16773365,
  2747. lawngreen: 8190976,
  2748. lemonchiffon: 16775885,
  2749. lightblue: 11393254,
  2750. lightcoral: 15761536,
  2751. lightcyan: 14745599,
  2752. lightgoldenrodyellow: 16448210,
  2753. lightgray: 13882323,
  2754. lightgreen: 9498256,
  2755. lightgrey: 13882323,
  2756. lightpink: 16758465,
  2757. lightsalmon: 16752762,
  2758. lightseagreen: 2142890,
  2759. lightskyblue: 8900346,
  2760. lightslategray: 7833753,
  2761. lightslategrey: 7833753,
  2762. lightsteelblue: 11584734,
  2763. lightyellow: 16777184,
  2764. lime: 65280,
  2765. limegreen: 3329330,
  2766. linen: 16445670,
  2767. magenta: 16711935,
  2768. maroon: 8388608,
  2769. mediumaquamarine: 6737322,
  2770. mediumblue: 205,
  2771. mediumorchid: 12211667,
  2772. mediumpurple: 9662683,
  2773. mediumseagreen: 3978097,
  2774. mediumslateblue: 8087790,
  2775. mediumspringgreen: 64154,
  2776. mediumturquoise: 4772300,
  2777. mediumvioletred: 13047173,
  2778. midnightblue: 1644912,
  2779. mintcream: 16121850,
  2780. mistyrose: 16770273,
  2781. moccasin: 16770229,
  2782. navajowhite: 16768685,
  2783. navy: 128,
  2784. oldlace: 16643558,
  2785. olive: 8421376,
  2786. olivedrab: 7048739,
  2787. orange: 16753920,
  2788. orangered: 16729344,
  2789. orchid: 14315734,
  2790. palegoldenrod: 15657130,
  2791. palegreen: 10025880,
  2792. paleturquoise: 11529966,
  2793. palevioletred: 14381203,
  2794. papayawhip: 16773077,
  2795. peachpuff: 16767673,
  2796. peru: 13468991,
  2797. pink: 16761035,
  2798. plum: 14524637,
  2799. powderblue: 11591910,
  2800. purple: 8388736,
  2801. rebeccapurple: 6697881,
  2802. red: 16711680,
  2803. rosybrown: 12357519,
  2804. royalblue: 4286945,
  2805. saddlebrown: 9127187,
  2806. salmon: 16416882,
  2807. sandybrown: 16032864,
  2808. seagreen: 3050327,
  2809. seashell: 16774638,
  2810. sienna: 10506797,
  2811. silver: 12632256,
  2812. skyblue: 8900331,
  2813. slateblue: 6970061,
  2814. slategray: 7372944,
  2815. slategrey: 7372944,
  2816. snow: 16775930,
  2817. springgreen: 65407,
  2818. steelblue: 4620980,
  2819. tan: 13808780,
  2820. teal: 32896,
  2821. thistle: 14204888,
  2822. tomato: 16737095,
  2823. turquoise: 4251856,
  2824. violet: 15631086,
  2825. wheat: 16113331,
  2826. white: 16777215,
  2827. whitesmoke: 16119285,
  2828. yellow: 16776960,
  2829. yellowgreen: 10145074
  2830. },
  2831. Jt = { r: 0, g: 0, b: 0 },
  2832. Dr = { h: 0, s: 0, l: 0 },
  2833. Xh = { h: 0, s: 0, l: 0 };
  2834. function tp(e, t, i) {
  2835. return (
  2836. 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
  2837. );
  2838. }
  2839. function qh(e, t) {
  2840. return (t.r = e.r), (t.g = e.g), (t.b = e.b), t;
  2841. }
  2842. var Ge = class {
  2843. constructor(e, t, i) {
  2844. 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);
  2845. }
  2846. set(e) {
  2847. return e && e.isColor ? this.copy(e) : typeof e == 'number' ? this.setHex(e) : typeof e == 'string' && this.setStyle(e), this;
  2848. }
  2849. setScalar(e) {
  2850. return (this.r = e), (this.g = e), (this.b = e), this;
  2851. }
  2852. setHex(e, t = rs) {
  2853. return (
  2854. (e = Math.floor(e)),
  2855. (this.r = ((e >> 16) & 255) / 255),
  2856. (this.g = ((e >> 8) & 255) / 255),
  2857. (this.b = (e & 255) / 255),
  2858. Ci.toWorkingColorSpace(this, t),
  2859. this
  2860. );
  2861. }
  2862. setRGB(e, t, i, r = Ci.workingColorSpace) {
  2863. return (this.r = e), (this.g = t), (this.b = i), Ci.toWorkingColorSpace(this, r), this;
  2864. }
  2865. setHSL(e, t, i, r = Ci.workingColorSpace) {
  2866. if (((e = lg(e, 1)), (t = ti(t, 0, 1)), (i = ti(i, 0, 1)), t === 0)) this.r = this.g = this.b = i;
  2867. else {
  2868. let s = i <= 0.5 ? i * (1 + t) : i + t - i * t,
  2869. n = 2 * i - s;
  2870. (this.r = tp(n, s, e + 1 / 3)), (this.g = tp(n, s, e)), (this.b = tp(n, s, e - 1 / 3));
  2871. }
  2872. return Ci.toWorkingColorSpace(this, r), this;
  2873. }
  2874. setStyle(e, t = rs) {
  2875. function i(s) {
  2876. s !== void 0 && parseFloat(s) < 1 && console.warn('THREE.Color: Alpha component of ' + e + ' will be ignored.');
  2877. }
  2878. let r;
  2879. if ((r = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e))) {
  2880. let s,
  2881. n = r[1],
  2882. a = r[2];
  2883. switch (n) {
  2884. case 'rgb':
  2885. case 'rgba':
  2886. if ((s = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)))
  2887. return (
  2888. (this.r = Math.min(255, parseInt(s[1], 10)) / 255),
  2889. (this.g = Math.min(255, parseInt(s[2], 10)) / 255),
  2890. (this.b = Math.min(255, parseInt(s[3], 10)) / 255),
  2891. Ci.toWorkingColorSpace(this, t),
  2892. i(s[4]),
  2893. this
  2894. );
  2895. if ((s = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)))
  2896. return (
  2897. (this.r = Math.min(100, parseInt(s[1], 10)) / 100),
  2898. (this.g = Math.min(100, parseInt(s[2], 10)) / 100),
  2899. (this.b = Math.min(100, parseInt(s[3], 10)) / 100),
  2900. Ci.toWorkingColorSpace(this, t),
  2901. i(s[4]),
  2902. this
  2903. );
  2904. break;
  2905. case 'hsl':
  2906. case 'hsla':
  2907. if ((s = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))) {
  2908. let o = parseFloat(s[1]) / 360,
  2909. l = parseFloat(s[2]) / 100,
  2910. h = parseFloat(s[3]) / 100;
  2911. return i(s[4]), this.setHSL(o, l, h, t);
  2912. }
  2913. break;
  2914. }
  2915. } else if ((r = /^\#([A-Fa-f\d]+)$/.exec(e))) {
  2916. let s = r[1],
  2917. n = s.length;
  2918. if (n === 3)
  2919. return (
  2920. (this.r = parseInt(s.charAt(0) + s.charAt(0), 16) / 255),
  2921. (this.g = parseInt(s.charAt(1) + s.charAt(1), 16) / 255),
  2922. (this.b = parseInt(s.charAt(2) + s.charAt(2), 16) / 255),
  2923. Ci.toWorkingColorSpace(this, t),
  2924. this
  2925. );
  2926. if (n === 6)
  2927. return (
  2928. (this.r = parseInt(s.charAt(0) + s.charAt(1), 16) / 255),
  2929. (this.g = parseInt(s.charAt(2) + s.charAt(3), 16) / 255),
  2930. (this.b = parseInt(s.charAt(4) + s.charAt(5), 16) / 255),
  2931. Ci.toWorkingColorSpace(this, t),
  2932. this
  2933. );
  2934. }
  2935. return e && e.length > 0 ? this.setColorName(e, t) : this;
  2936. }
  2937. setColorName(e, t = rs) {
  2938. let i = uw[e.toLowerCase()];
  2939. return i !== void 0 ? this.setHex(i, t) : console.warn('THREE.Color: Unknown color ' + e), this;
  2940. }
  2941. clone() {
  2942. return new this.constructor(this.r, this.g, this.b);
  2943. }
  2944. copy(e) {
  2945. return (this.r = e.r), (this.g = e.g), (this.b = e.b), this;
  2946. }
  2947. copySRGBToLinear(e) {
  2948. return (this.r = ua(e.r)), (this.g = ua(e.g)), (this.b = ua(e.b)), this;
  2949. }
  2950. copyLinearToSRGB(e) {
  2951. return (this.r = Kc(e.r)), (this.g = Kc(e.g)), (this.b = Kc(e.b)), this;
  2952. }
  2953. convertSRGBToLinear() {
  2954. return this.copySRGBToLinear(this), this;
  2955. }
  2956. convertLinearToSRGB() {
  2957. return this.copyLinearToSRGB(this), this;
  2958. }
  2959. getHex(e = rs) {
  2960. return (
  2961. Ci.fromWorkingColorSpace(qh(this, Jt), e),
  2962. (ti(Jt.r * 255, 0, 255) << 16) ^ (ti(Jt.g * 255, 0, 255) << 8) ^ (ti(Jt.b * 255, 0, 255) << 0)
  2963. );
  2964. }
  2965. getHexString(e = rs) {
  2966. return ('000000' + this.getHex(e).toString(16)).slice(-6);
  2967. }
  2968. getHSL(e, t = Ci.workingColorSpace) {
  2969. Ci.fromWorkingColorSpace(qh(this, Jt), t);
  2970. let i = Jt.r,
  2971. r = Jt.g,
  2972. s = Jt.b,
  2973. n = Math.max(i, r, s),
  2974. a = Math.min(i, r, s),
  2975. o,
  2976. l,
  2977. h = (a + n) / 2;
  2978. if (a === n) (o = 0), (l = 0);
  2979. else {
  2980. let u = n - a;
  2981. switch (((l = h <= 0.5 ? u / (n + a) : u / (2 - n - a)), n)) {
  2982. case i:
  2983. o = (r - s) / u + (r < s ? 6 : 0);
  2984. break;
  2985. case r:
  2986. o = (s - i) / u + 2;
  2987. break;
  2988. case s:
  2989. o = (i - r) / u + 4;
  2990. break;
  2991. }
  2992. o /= 6;
  2993. }
  2994. return (e.h = o), (e.s = l), (e.l = h), e;
  2995. }
  2996. getRGB(e, t = Ci.workingColorSpace) {
  2997. return Ci.fromWorkingColorSpace(qh(this, Jt), t), (e.r = Jt.r), (e.g = Jt.g), (e.b = Jt.b), e;
  2998. }
  2999. getStyle(e = rs) {
  3000. return (
  3001. Ci.fromWorkingColorSpace(qh(this, Jt), e),
  3002. e !== rs ? `color(${e} ${Jt.r} ${Jt.g} ${Jt.b})` : `rgb(${(Jt.r * 255) | 0},${(Jt.g * 255) | 0},${(Jt.b * 255) | 0})`
  3003. );
  3004. }
  3005. offsetHSL(e, t, i) {
  3006. return this.getHSL(Dr), (Dr.h += e), (Dr.s += t), (Dr.l += i), this.setHSL(Dr.h, Dr.s, Dr.l), this;
  3007. }
  3008. add(e) {
  3009. return (this.r += e.r), (this.g += e.g), (this.b += e.b), this;
  3010. }
  3011. addColors(e, t) {
  3012. return (this.r = e.r + t.r), (this.g = e.g + t.g), (this.b = e.b + t.b), this;
  3013. }
  3014. addScalar(e) {
  3015. return (this.r += e), (this.g += e), (this.b += e), this;
  3016. }
  3017. sub(e) {
  3018. 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;
  3019. }
  3020. multiply(e) {
  3021. return (this.r *= e.r), (this.g *= e.g), (this.b *= e.b), this;
  3022. }
  3023. multiplyScalar(e) {
  3024. return (this.r *= e), (this.g *= e), (this.b *= e), this;
  3025. }
  3026. lerp(e, t) {
  3027. return (this.r += (e.r - this.r) * t), (this.g += (e.g - this.g) * t), (this.b += (e.b - this.b) * t), this;
  3028. }
  3029. lerpColors(e, t, i) {
  3030. 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;
  3031. }
  3032. lerpHSL(e, t) {
  3033. this.getHSL(Dr), e.getHSL(Xh);
  3034. let i = Zl(Dr.h, Xh.h, t),
  3035. r = Zl(Dr.s, Xh.s, t),
  3036. s = Zl(Dr.l, Xh.l, t);
  3037. return this.setHSL(i, r, s), this;
  3038. }
  3039. equals(e) {
  3040. return e.r === this.r && e.g === this.g && e.b === this.b;
  3041. }
  3042. fromArray(e, t = 0) {
  3043. return (this.r = e[t]), (this.g = e[t + 1]), (this.b = e[t + 2]), this;
  3044. }
  3045. toArray(e = [], t = 0) {
  3046. return (e[t] = this.r), (e[t + 1] = this.g), (e[t + 2] = this.b), e;
  3047. }
  3048. fromBufferAttribute(e, t) {
  3049. return (this.r = e.getX(t)), (this.g = e.getY(t)), (this.b = e.getZ(t)), this;
  3050. }
  3051. toJSON() {
  3052. return this.getHex();
  3053. }
  3054. *[Symbol.iterator]() {
  3055. yield this.r, yield this.g, yield this.b;
  3056. }
  3057. };
  3058. Ge.NAMES = uw;
  3059. var Ra,
  3060. pw = class {
  3061. static getDataURL(e) {
  3062. if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > 'u') return e.src;
  3063. let t;
  3064. if (e instanceof HTMLCanvasElement) t = e;
  3065. else {
  3066. Ra === void 0 && (Ra = md('canvas')), (Ra.width = e.width), (Ra.height = e.height);
  3067. let i = Ra.getContext('2d');
  3068. e instanceof ImageData ? i.putImageData(e, 0, 0) : i.drawImage(e, 0, 0, e.width, e.height), (t = Ra);
  3069. }
  3070. return t.width > 2048 || t.height > 2048
  3071. ? (console.warn('THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons', e), t.toDataURL('image/jpeg', 0.6))
  3072. : t.toDataURL('image/png');
  3073. }
  3074. static sRGBToLinear(e) {
  3075. if (
  3076. (typeof HTMLImageElement < 'u' && e instanceof HTMLImageElement) ||
  3077. (typeof HTMLCanvasElement < 'u' && e instanceof HTMLCanvasElement) ||
  3078. (typeof ImageBitmap < 'u' && e instanceof ImageBitmap)
  3079. ) {
  3080. let t = md('canvas');
  3081. (t.width = e.width), (t.height = e.height);
  3082. let i = t.getContext('2d');
  3083. i.drawImage(e, 0, 0, e.width, e.height);
  3084. let r = i.getImageData(0, 0, e.width, e.height),
  3085. s = r.data;
  3086. for (let n = 0; n < s.length; n++) s[n] = ua(s[n] / 255) * 255;
  3087. return i.putImageData(r, 0, 0), t;
  3088. } else if (e.data) {
  3089. let t = e.data.slice(0);
  3090. for (let i = 0; i < t.length; i++)
  3091. t instanceof Uint8Array || t instanceof Uint8ClampedArray ? (t[i] = Math.floor(ua(t[i] / 255) * 255)) : (t[i] = ua(t[i]));
  3092. return { data: t, width: e.width, height: e.height };
  3093. } else return console.warn('THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.'), e;
  3094. }
  3095. },
  3096. fw = class {
  3097. constructor(e = null) {
  3098. (this.isSource = !0), (this.uuid = ps()), (this.data = e), (this.version = 0);
  3099. }
  3100. set needsUpdate(e) {
  3101. e === !0 && this.version++;
  3102. }
  3103. toJSON(e) {
  3104. let t = e === void 0 || typeof e == 'string';
  3105. if (!t && e.images[this.uuid] !== void 0) return e.images[this.uuid];
  3106. let i = { uuid: this.uuid, url: '' },
  3107. r = this.data;
  3108. if (r !== null) {
  3109. let s;
  3110. if (Array.isArray(r)) {
  3111. s = [];
  3112. for (let n = 0, a = r.length; n < a; n++) r[n].isDataTexture ? s.push(ip(r[n].image)) : s.push(ip(r[n]));
  3113. } else s = ip(r);
  3114. i.url = s;
  3115. }
  3116. return t || (e.images[this.uuid] = i), i;
  3117. }
  3118. };
  3119. function ip(e) {
  3120. return (typeof HTMLImageElement < 'u' && e instanceof HTMLImageElement) ||
  3121. (typeof HTMLCanvasElement < 'u' && e instanceof HTMLCanvasElement) ||
  3122. (typeof ImageBitmap < 'u' && e instanceof ImageBitmap)
  3123. ? pw.getDataURL(e)
  3124. : e.data
  3125. ? { data: Array.from(e.data), width: e.width, height: e.height, type: e.data.constructor.name }
  3126. : (console.warn('THREE.Texture: Unable to serialize Texture.'), {});
  3127. }
  3128. var iE = 0,
  3129. ci = class extends Vi {
  3130. constructor(
  3131. e = ci.DEFAULT_IMAGE,
  3132. t = ci.DEFAULT_MAPPING,
  3133. i = Ji,
  3134. r = Ji,
  3135. s = mt,
  3136. n = Bo,
  3137. a = Ur,
  3138. o = Mi,
  3139. l = ci.DEFAULT_ANISOTROPY,
  3140. h = gs
  3141. ) {
  3142. super(),
  3143. (this.isTexture = !0),
  3144. Object.defineProperty(this, 'id', { value: iE++ }),
  3145. (this.uuid = ps()),
  3146. (this.name = ''),
  3147. (this.source = new fw(e)),
  3148. (this.mipmaps = []),
  3149. (this.mapping = t),
  3150. (this.wrapS = i),
  3151. (this.wrapT = r),
  3152. (this.magFilter = s),
  3153. (this.minFilter = n),
  3154. (this.anisotropy = l),
  3155. (this.format = a),
  3156. (this.internalFormat = null),
  3157. (this.type = o),
  3158. (this.offset = new G(0, 0)),
  3159. (this.repeat = new G(1, 1)),
  3160. (this.center = new G(0, 0)),
  3161. (this.rotation = 0),
  3162. (this.matrixAutoUpdate = !0),
  3163. (this.matrix = new Ai()),
  3164. (this.generateMipmaps = !0),
  3165. (this.premultiplyAlpha = !1),
  3166. (this.flipY = !0),
  3167. (this.unpackAlignment = 4),
  3168. (this.encoding = h),
  3169. (this.userData = {}),
  3170. (this.version = 0),
  3171. (this.onUpdate = null),
  3172. (this.isRenderTargetTexture = !1),
  3173. (this.needsPMREMUpdate = !1);
  3174. }
  3175. get image() {
  3176. return this.source.data;
  3177. }
  3178. set image(e) {
  3179. this.source.data = e;
  3180. }
  3181. updateMatrix() {
  3182. this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
  3183. }
  3184. clone() {
  3185. return new this.constructor().copy(this);
  3186. }
  3187. copy(e) {
  3188. return (
  3189. (this.name = e.name),
  3190. (this.source = e.source),
  3191. (this.mipmaps = e.mipmaps.slice(0)),
  3192. (this.mapping = e.mapping),
  3193. (this.wrapS = e.wrapS),
  3194. (this.wrapT = e.wrapT),
  3195. (this.magFilter = e.magFilter),
  3196. (this.minFilter = e.minFilter),
  3197. (this.anisotropy = e.anisotropy),
  3198. (this.format = e.format),
  3199. (this.internalFormat = e.internalFormat),
  3200. (this.type = e.type),
  3201. this.offset.copy(e.offset),
  3202. this.repeat.copy(e.repeat),
  3203. this.center.copy(e.center),
  3204. (this.rotation = e.rotation),
  3205. (this.matrixAutoUpdate = e.matrixAutoUpdate),
  3206. this.matrix.copy(e.matrix),
  3207. (this.generateMipmaps = e.generateMipmaps),
  3208. (this.premultiplyAlpha = e.premultiplyAlpha),
  3209. (this.flipY = e.flipY),
  3210. (this.unpackAlignment = e.unpackAlignment),
  3211. (this.encoding = e.encoding),
  3212. (this.userData = JSON.parse(JSON.stringify(e.userData))),
  3213. (this.needsUpdate = !0),
  3214. this
  3215. );
  3216. }
  3217. toJSON(e) {
  3218. let t = e === void 0 || typeof e == 'string';
  3219. if (!t && e.textures[this.uuid] !== void 0) return e.textures[this.uuid];
  3220. let i = {
  3221. metadata: { version: 4.5, type: 'Texture', generator: 'Texture.toJSON' },
  3222. uuid: this.uuid,
  3223. name: this.name,
  3224. image: this.source.toJSON(e).uuid,
  3225. mapping: this.mapping,
  3226. repeat: [this.repeat.x, this.repeat.y],
  3227. offset: [this.offset.x, this.offset.y],
  3228. center: [this.center.x, this.center.y],
  3229. rotation: this.rotation,
  3230. wrap: [this.wrapS, this.wrapT],
  3231. format: this.format,
  3232. type: this.type,
  3233. encoding: this.encoding,
  3234. minFilter: this.minFilter,
  3235. magFilter: this.magFilter,
  3236. anisotropy: this.anisotropy,
  3237. flipY: this.flipY,
  3238. generateMipmaps: this.generateMipmaps,
  3239. premultiplyAlpha: this.premultiplyAlpha,
  3240. unpackAlignment: this.unpackAlignment
  3241. };
  3242. return Object.keys(this.userData).length > 0 && (i.userData = this.userData), t || (e.textures[this.uuid] = i), i;
  3243. }
  3244. dispose() {
  3245. this.dispatchEvent({ type: 'dispose' });
  3246. }
  3247. transformUv(e) {
  3248. if (this.mapping !== lw) return e;
  3249. if ((e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1))
  3250. switch (this.wrapS) {
  3251. case oh:
  3252. e.x = e.x - Math.floor(e.x);
  3253. break;
  3254. case Ji:
  3255. e.x = e.x < 0 ? 0 : 1;
  3256. break;
  3257. case Uf:
  3258. Math.abs(Math.floor(e.x) % 2) === 1 ? (e.x = Math.ceil(e.x) - e.x) : (e.x = e.x - Math.floor(e.x));
  3259. break;
  3260. }
  3261. if (e.y < 0 || e.y > 1)
  3262. switch (this.wrapT) {
  3263. case oh:
  3264. e.y = e.y - Math.floor(e.y);
  3265. break;
  3266. case Ji:
  3267. e.y = e.y < 0 ? 0 : 1;
  3268. break;
  3269. case Uf:
  3270. Math.abs(Math.floor(e.y) % 2) === 1 ? (e.y = Math.ceil(e.y) - e.y) : (e.y = e.y - Math.floor(e.y));
  3271. break;
  3272. }
  3273. return this.flipY && (e.y = 1 - e.y), e;
  3274. }
  3275. set needsUpdate(e) {
  3276. e === !0 && (this.version++, (this.source.needsUpdate = !0));
  3277. }
  3278. };
  3279. ci.DEFAULT_IMAGE = null;
  3280. ci.DEFAULT_MAPPING = lw;
  3281. ci.DEFAULT_ANISOTROPY = 1;
  3282. var $e = class {
  3283. constructor(e = 0, t = 0, i = 0, r = 1) {
  3284. ($e.prototype.isVector4 = !0), (this.x = e), (this.y = t), (this.z = i), (this.w = r);
  3285. }
  3286. get width() {
  3287. return this.z;
  3288. }
  3289. set width(e) {
  3290. this.z = e;
  3291. }
  3292. get height() {
  3293. return this.w;
  3294. }
  3295. set height(e) {
  3296. this.w = e;
  3297. }
  3298. set(e, t, i, r) {
  3299. return (this.x = e), (this.y = t), (this.z = i), (this.w = r), this;
  3300. }
  3301. setScalar(e) {
  3302. return (this.x = e), (this.y = e), (this.z = e), (this.w = e), this;
  3303. }
  3304. setX(e) {
  3305. return (this.x = e), this;
  3306. }
  3307. setY(e) {
  3308. return (this.y = e), this;
  3309. }
  3310. setZ(e) {
  3311. return (this.z = e), this;
  3312. }
  3313. setW(e) {
  3314. return (this.w = e), this;
  3315. }
  3316. setComponent(e, t) {
  3317. switch (e) {
  3318. case 0:
  3319. this.x = t;
  3320. break;
  3321. case 1:
  3322. this.y = t;
  3323. break;
  3324. case 2:
  3325. this.z = t;
  3326. break;
  3327. case 3:
  3328. this.w = t;
  3329. break;
  3330. default:
  3331. throw new Error('index is out of range: ' + e);
  3332. }
  3333. return this;
  3334. }
  3335. getComponent(e) {
  3336. switch (e) {
  3337. case 0:
  3338. return this.x;
  3339. case 1:
  3340. return this.y;
  3341. case 2:
  3342. return this.z;
  3343. case 3:
  3344. return this.w;
  3345. default:
  3346. throw new Error('index is out of range: ' + e);
  3347. }
  3348. }
  3349. clone() {
  3350. return new this.constructor(this.x, this.y, this.z, this.w);
  3351. }
  3352. copy(e) {
  3353. return (this.x = e.x), (this.y = e.y), (this.z = e.z), (this.w = e.w !== void 0 ? e.w : 1), this;
  3354. }
  3355. add(e) {
  3356. return (this.x += e.x), (this.y += e.y), (this.z += e.z), (this.w += e.w), this;
  3357. }
  3358. addScalar(e) {
  3359. return (this.x += e), (this.y += e), (this.z += e), (this.w += e), this;
  3360. }
  3361. addVectors(e, t) {
  3362. 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;
  3363. }
  3364. addScaledVector(e, t) {
  3365. return (this.x += e.x * t), (this.y += e.y * t), (this.z += e.z * t), (this.w += e.w * t), this;
  3366. }
  3367. sub(e) {
  3368. return (this.x -= e.x), (this.y -= e.y), (this.z -= e.z), (this.w -= e.w), this;
  3369. }
  3370. subScalar(e) {
  3371. return (this.x -= e), (this.y -= e), (this.z -= e), (this.w -= e), this;
  3372. }
  3373. subVectors(e, t) {
  3374. 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;
  3375. }
  3376. multiply(e) {
  3377. return (this.x *= e.x), (this.y *= e.y), (this.z *= e.z), (this.w *= e.w), this;
  3378. }
  3379. multiplyScalar(e) {
  3380. return (this.x *= e), (this.y *= e), (this.z *= e), (this.w *= e), this;
  3381. }
  3382. applyMatrix4(e) {
  3383. let t = this.x,
  3384. i = this.y,
  3385. r = this.z,
  3386. s = this.w,
  3387. n = e.elements;
  3388. return (
  3389. (this.x = n[0] * t + n[4] * i + n[8] * r + n[12] * s),
  3390. (this.y = n[1] * t + n[5] * i + n[9] * r + n[13] * s),
  3391. (this.z = n[2] * t + n[6] * i + n[10] * r + n[14] * s),
  3392. (this.w = n[3] * t + n[7] * i + n[11] * r + n[15] * s),
  3393. this
  3394. );
  3395. }
  3396. divideScalar(e) {
  3397. return this.multiplyScalar(1 / e);
  3398. }
  3399. setAxisAngleFromQuaternion(e) {
  3400. this.w = 2 * Math.acos(e.w);
  3401. let t = Math.sqrt(1 - e.w * e.w);
  3402. 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;
  3403. }
  3404. setAxisAngleFromRotationMatrix(e) {
  3405. let t,
  3406. i,
  3407. r,
  3408. s,
  3409. n = e.elements,
  3410. a = n[0],
  3411. o = n[4],
  3412. l = n[8],
  3413. h = n[1],
  3414. u = n[5],
  3415. c = n[9],
  3416. d = n[2],
  3417. p = n[6],
  3418. f = n[10];
  3419. if (Math.abs(o - h) < 0.01 && Math.abs(l - d) < 0.01 && Math.abs(c - p) < 0.01) {
  3420. if (Math.abs(o + h) < 0.1 && Math.abs(l + d) < 0.1 && Math.abs(c + p) < 0.1 && Math.abs(a + u + f - 3) < 0.1)
  3421. return this.set(1, 0, 0, 0), this;
  3422. t = Math.PI;
  3423. let m = (a + 1) / 2,
  3424. v = (u + 1) / 2,
  3425. y = (f + 1) / 2,
  3426. b = (o + h) / 4,
  3427. x = (l + d) / 4,
  3428. w = (c + p) / 4;
  3429. return (
  3430. m > v && m > y
  3431. ? m < 0.01
  3432. ? ((i = 0), (r = 0.707106781), (s = 0.707106781))
  3433. : ((i = Math.sqrt(m)), (r = b / i), (s = x / i))
  3434. : v > y
  3435. ? v < 0.01
  3436. ? ((i = 0.707106781), (r = 0), (s = 0.707106781))
  3437. : ((r = Math.sqrt(v)), (i = b / r), (s = w / r))
  3438. : y < 0.01
  3439. ? ((i = 0.707106781), (r = 0.707106781), (s = 0))
  3440. : ((s = Math.sqrt(y)), (i = x / s), (r = w / s)),
  3441. this.set(i, r, s, t),
  3442. this
  3443. );
  3444. }
  3445. let g = Math.sqrt((p - c) * (p - c) + (l - d) * (l - d) + (h - o) * (h - o));
  3446. return (
  3447. Math.abs(g) < 0.001 && (g = 1),
  3448. (this.x = (p - c) / g),
  3449. (this.y = (l - d) / g),
  3450. (this.z = (h - o) / g),
  3451. (this.w = Math.acos((a + u + f - 1) / 2)),
  3452. this
  3453. );
  3454. }
  3455. min(e) {
  3456. return (
  3457. (this.x = Math.min(this.x, e.x)),
  3458. (this.y = Math.min(this.y, e.y)),
  3459. (this.z = Math.min(this.z, e.z)),
  3460. (this.w = Math.min(this.w, e.w)),
  3461. this
  3462. );
  3463. }
  3464. max(e) {
  3465. return (
  3466. (this.x = Math.max(this.x, e.x)),
  3467. (this.y = Math.max(this.y, e.y)),
  3468. (this.z = Math.max(this.z, e.z)),
  3469. (this.w = Math.max(this.w, e.w)),
  3470. this
  3471. );
  3472. }
  3473. clamp(e, t) {
  3474. return (
  3475. (this.x = Math.max(e.x, Math.min(t.x, this.x))),
  3476. (this.y = Math.max(e.y, Math.min(t.y, this.y))),
  3477. (this.z = Math.max(e.z, Math.min(t.z, this.z))),
  3478. (this.w = Math.max(e.w, Math.min(t.w, this.w))),
  3479. this
  3480. );
  3481. }
  3482. clampScalar(e, t) {
  3483. return (
  3484. (this.x = Math.max(e, Math.min(t, this.x))),
  3485. (this.y = Math.max(e, Math.min(t, this.y))),
  3486. (this.z = Math.max(e, Math.min(t, this.z))),
  3487. (this.w = Math.max(e, Math.min(t, this.w))),
  3488. this
  3489. );
  3490. }
  3491. clampLength(e, t) {
  3492. let i = this.length();
  3493. return this.divideScalar(i || 1).multiplyScalar(Math.max(e, Math.min(t, i)));
  3494. }
  3495. floor() {
  3496. return (
  3497. (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
  3498. );
  3499. }
  3500. ceil() {
  3501. 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;
  3502. }
  3503. round() {
  3504. return (
  3505. (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
  3506. );
  3507. }
  3508. roundToZero() {
  3509. return (
  3510. (this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x)),
  3511. (this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y)),
  3512. (this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z)),
  3513. (this.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(this.w)),
  3514. this
  3515. );
  3516. }
  3517. negate() {
  3518. return (this.x = -this.x), (this.y = -this.y), (this.z = -this.z), (this.w = -this.w), this;
  3519. }
  3520. dot(e) {
  3521. return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w;
  3522. }
  3523. lengthSq() {
  3524. return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
  3525. }
  3526. length() {
  3527. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  3528. }
  3529. manhattanLength() {
  3530. return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);
  3531. }
  3532. normalize() {
  3533. return this.divideScalar(this.length() || 1);
  3534. }
  3535. setLength(e) {
  3536. return this.normalize().multiplyScalar(e);
  3537. }
  3538. lerp(e, t) {
  3539. return (
  3540. (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
  3541. );
  3542. }
  3543. lerpVectors(e, t, i) {
  3544. return (
  3545. (this.x = e.x + (t.x - e.x) * i),
  3546. (this.y = e.y + (t.y - e.y) * i),
  3547. (this.z = e.z + (t.z - e.z) * i),
  3548. (this.w = e.w + (t.w - e.w) * i),
  3549. this
  3550. );
  3551. }
  3552. equals(e) {
  3553. return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w;
  3554. }
  3555. fromArray(e, t = 0) {
  3556. return (this.x = e[t]), (this.y = e[t + 1]), (this.z = e[t + 2]), (this.w = e[t + 3]), this;
  3557. }
  3558. toArray(e = [], t = 0) {
  3559. return (e[t] = this.x), (e[t + 1] = this.y), (e[t + 2] = this.z), (e[t + 3] = this.w), e;
  3560. }
  3561. fromBufferAttribute(e, t) {
  3562. return (this.x = e.getX(t)), (this.y = e.getY(t)), (this.z = e.getZ(t)), (this.w = e.getW(t)), this;
  3563. }
  3564. random() {
  3565. return (this.x = Math.random()), (this.y = Math.random()), (this.z = Math.random()), (this.w = Math.random()), this;
  3566. }
  3567. *[Symbol.iterator]() {
  3568. yield this.x, yield this.y, yield this.z, yield this.w;
  3569. }
  3570. },
  3571. ii = class extends Vi {
  3572. constructor(e = 1, t = 1, i = {}) {
  3573. super(),
  3574. (this.isWebGLRenderTarget = !0),
  3575. (this.width = e),
  3576. (this.height = t),
  3577. (this.depth = 1),
  3578. (this.scissor = new $e(0, 0, e, t)),
  3579. (this.scissorTest = !1),
  3580. (this.viewport = new $e(0, 0, e, t));
  3581. let r = { width: e, height: t, depth: 1 };
  3582. (this.texture = new ci(r, i.mapping, i.wrapS, i.wrapT, i.magFilter, i.minFilter, i.format, i.type, i.anisotropy, i.encoding)),
  3583. (this.texture.isRenderTargetTexture = !0),
  3584. (this.texture.flipY = !1),
  3585. (this.texture.generateMipmaps = i.generateMipmaps !== void 0 ? i.generateMipmaps : !1),
  3586. (this.texture.internalFormat = i.internalFormat !== void 0 ? i.internalFormat : null),
  3587. (this.texture.minFilter = i.minFilter !== void 0 ? i.minFilter : mt),
  3588. (this.depthBuffer = i.depthBuffer !== void 0 ? i.depthBuffer : !0),
  3589. (this.stencilBuffer = i.stencilBuffer !== void 0 ? i.stencilBuffer : !1),
  3590. (this.depthTexture = i.depthTexture !== void 0 ? i.depthTexture : null),
  3591. (this.samples = i.samples !== void 0 ? i.samples : 0);
  3592. }
  3593. setSize(e, t, i = 1) {
  3594. (this.width !== e || this.height !== t || this.depth !== i) &&
  3595. ((this.width = e),
  3596. (this.height = t),
  3597. (this.depth = i),
  3598. (this.texture.image.width = e),
  3599. (this.texture.image.height = t),
  3600. (this.texture.image.depth = i),
  3601. this.dispose()),
  3602. this.viewport.set(0, 0, e, t),
  3603. this.scissor.set(0, 0, e, t);
  3604. }
  3605. clone() {
  3606. return new this.constructor().copy(this);
  3607. }
  3608. copy(e) {
  3609. (this.width = e.width),
  3610. (this.height = e.height),
  3611. (this.depth = e.depth),
  3612. this.viewport.copy(e.viewport),
  3613. (this.texture = e.texture.clone()),
  3614. (this.texture.isRenderTargetTexture = !0);
  3615. let t = Object.assign({}, e.texture.image);
  3616. return (
  3617. (this.texture.source = new fw(t)),
  3618. (this.depthBuffer = e.depthBuffer),
  3619. (this.stencilBuffer = e.stencilBuffer),
  3620. e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()),
  3621. (this.samples = e.samples),
  3622. this
  3623. );
  3624. }
  3625. dispose() {
  3626. this.dispatchEvent({ type: 'dispose' });
  3627. }
  3628. },
  3629. mw = class extends ci {
  3630. constructor(e = null, t = 1, i = 1, r = 1) {
  3631. super(null),
  3632. (this.isDataArrayTexture = !0),
  3633. (this.image = { data: e, width: t, height: i, depth: r }),
  3634. (this.magFilter = Ot),
  3635. (this.minFilter = Ot),
  3636. (this.wrapR = Ji),
  3637. (this.generateMipmaps = !1),
  3638. (this.flipY = !1),
  3639. (this.unpackAlignment = 1);
  3640. }
  3641. },
  3642. rE = class extends ci {
  3643. constructor(e = null, t = 1, i = 1, r = 1) {
  3644. super(null),
  3645. (this.isData3DTexture = !0),
  3646. (this.image = { data: e, width: t, height: i, depth: r }),
  3647. (this.magFilter = Ot),
  3648. (this.minFilter = Ot),
  3649. (this.wrapR = Ji),
  3650. (this.generateMipmaps = !1),
  3651. (this.flipY = !1),
  3652. (this.unpackAlignment = 1);
  3653. }
  3654. },
  3655. ct = class {
  3656. constructor(e = 0, t = 0, i = 0, r = 1) {
  3657. (this.isQuaternion = !0), (this._x = e), (this._y = t), (this._z = i), (this._w = r);
  3658. }
  3659. static slerpFlat(e, t, i, r, s, n, a) {
  3660. let o = i[r + 0],
  3661. l = i[r + 1],
  3662. h = i[r + 2],
  3663. u = i[r + 3],
  3664. c = s[n + 0],
  3665. d = s[n + 1],
  3666. p = s[n + 2],
  3667. f = s[n + 3];
  3668. if (a === 0) {
  3669. (e[t + 0] = o), (e[t + 1] = l), (e[t + 2] = h), (e[t + 3] = u);
  3670. return;
  3671. }
  3672. if (a === 1) {
  3673. (e[t + 0] = c), (e[t + 1] = d), (e[t + 2] = p), (e[t + 3] = f);
  3674. return;
  3675. }
  3676. if (u !== f || o !== c || l !== d || h !== p) {
  3677. let g = 1 - a,
  3678. m = o * c + l * d + h * p + u * f,
  3679. v = m >= 0 ? 1 : -1,
  3680. y = 1 - m * m;
  3681. if (y > Number.EPSILON) {
  3682. let x = Math.sqrt(y),
  3683. w = Math.atan2(x, m * v);
  3684. (g = Math.sin(g * w) / x), (a = Math.sin(a * w) / x);
  3685. }
  3686. let b = a * v;
  3687. if (((o = o * g + c * b), (l = l * g + d * b), (h = h * g + p * b), (u = u * g + f * b), g === 1 - a)) {
  3688. let x = 1 / Math.sqrt(o * o + l * l + h * h + u * u);
  3689. (o *= x), (l *= x), (h *= x), (u *= x);
  3690. }
  3691. }
  3692. (e[t] = o), (e[t + 1] = l), (e[t + 2] = h), (e[t + 3] = u);
  3693. }
  3694. static multiplyQuaternionsFlat(e, t, i, r, s, n) {
  3695. let a = i[r],
  3696. o = i[r + 1],
  3697. l = i[r + 2],
  3698. h = i[r + 3],
  3699. u = s[n],
  3700. c = s[n + 1],
  3701. d = s[n + 2],
  3702. p = s[n + 3];
  3703. return (
  3704. (e[t] = a * p + h * u + o * d - l * c),
  3705. (e[t + 1] = o * p + h * c + l * u - a * d),
  3706. (e[t + 2] = l * p + h * d + a * c - o * u),
  3707. (e[t + 3] = h * p - a * u - o * c - l * d),
  3708. e
  3709. );
  3710. }
  3711. get x() {
  3712. return this._x;
  3713. }
  3714. set x(e) {
  3715. (this._x = e), this._onChangeCallback();
  3716. }
  3717. get y() {
  3718. return this._y;
  3719. }
  3720. set y(e) {
  3721. (this._y = e), this._onChangeCallback();
  3722. }
  3723. get z() {
  3724. return this._z;
  3725. }
  3726. set z(e) {
  3727. (this._z = e), this._onChangeCallback();
  3728. }
  3729. get w() {
  3730. return this._w;
  3731. }
  3732. set w(e) {
  3733. (this._w = e), this._onChangeCallback();
  3734. }
  3735. set(e, t, i, r) {
  3736. return (this._x = e), (this._y = t), (this._z = i), (this._w = r), this._onChangeCallback(), this;
  3737. }
  3738. clone() {
  3739. return new this.constructor(this._x, this._y, this._z, this._w);
  3740. }
  3741. copy(e) {
  3742. return (this._x = e.x), (this._y = e.y), (this._z = e.z), (this._w = e.w), this._onChangeCallback(), this;
  3743. }
  3744. setFromEuler(e, t) {
  3745. let i = e._x,
  3746. r = e._y,
  3747. s = e._z,
  3748. n = e._order,
  3749. a = Math.cos,
  3750. o = Math.sin,
  3751. l = a(i / 2),
  3752. h = a(r / 2),
  3753. u = a(s / 2),
  3754. c = o(i / 2),
  3755. d = o(r / 2),
  3756. p = o(s / 2);
  3757. switch (n) {
  3758. case 'XYZ':
  3759. (this._x = c * h * u + l * d * p),
  3760. (this._y = l * d * u - c * h * p),
  3761. (this._z = l * h * p + c * d * u),
  3762. (this._w = l * h * u - c * d * p);
  3763. break;
  3764. case 'YXZ':
  3765. (this._x = c * h * u + l * d * p),
  3766. (this._y = l * d * u - c * h * p),
  3767. (this._z = l * h * p - c * d * u),
  3768. (this._w = l * h * u + c * d * p);
  3769. break;
  3770. case 'ZXY':
  3771. (this._x = c * h * u - l * d * p),
  3772. (this._y = l * d * u + c * h * p),
  3773. (this._z = l * h * p + c * d * u),
  3774. (this._w = l * h * u - c * d * p);
  3775. break;
  3776. case 'ZYX':
  3777. (this._x = c * h * u - l * d * p),
  3778. (this._y = l * d * u + c * h * p),
  3779. (this._z = l * h * p - c * d * u),
  3780. (this._w = l * h * u + c * d * p);
  3781. break;
  3782. case 'YZX':
  3783. (this._x = c * h * u + l * d * p),
  3784. (this._y = l * d * u + c * h * p),
  3785. (this._z = l * h * p - c * d * u),
  3786. (this._w = l * h * u - c * d * p);
  3787. break;
  3788. case 'XZY':
  3789. (this._x = c * h * u - l * d * p),
  3790. (this._y = l * d * u - c * h * p),
  3791. (this._z = l * h * p + c * d * u),
  3792. (this._w = l * h * u + c * d * p);
  3793. break;
  3794. default:
  3795. console.warn('THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + n);
  3796. }
  3797. return t !== !1 && this._onChangeCallback(), this;
  3798. }
  3799. setFromAxisAngle(e, t) {
  3800. let i = t / 2,
  3801. r = Math.sin(i);
  3802. return (this._x = e.x * r), (this._y = e.y * r), (this._z = e.z * r), (this._w = Math.cos(i)), this._onChangeCallback(), this;
  3803. }
  3804. setFromRotationMatrix(e) {
  3805. let t = e.elements,
  3806. i = t[0],
  3807. r = t[4],
  3808. s = t[8],
  3809. n = t[1],
  3810. a = t[5],
  3811. o = t[9],
  3812. l = t[2],
  3813. h = t[6],
  3814. u = t[10],
  3815. c = i + a + u;
  3816. if (c > 0) {
  3817. let d = 0.5 / Math.sqrt(c + 1);
  3818. (this._w = 0.25 / d), (this._x = (h - o) * d), (this._y = (s - l) * d), (this._z = (n - r) * d);
  3819. } else if (i > a && i > u) {
  3820. let d = 2 * Math.sqrt(1 + i - a - u);
  3821. (this._w = (h - o) / d), (this._x = 0.25 * d), (this._y = (r + n) / d), (this._z = (s + l) / d);
  3822. } else if (a > u) {
  3823. let d = 2 * Math.sqrt(1 + a - i - u);
  3824. (this._w = (s - l) / d), (this._x = (r + n) / d), (this._y = 0.25 * d), (this._z = (o + h) / d);
  3825. } else {
  3826. let d = 2 * Math.sqrt(1 + u - i - a);
  3827. (this._w = (n - r) / d), (this._x = (s + l) / d), (this._y = (o + h) / d), (this._z = 0.25 * d);
  3828. }
  3829. return this._onChangeCallback(), this;
  3830. }
  3831. setFromUnitVectors(e, t) {
  3832. let i = e.dot(t) + 1;
  3833. return (
  3834. i < Number.EPSILON
  3835. ? ((i = 0),
  3836. Math.abs(e.x) > Math.abs(e.z)
  3837. ? ((this._x = -e.y), (this._y = e.x), (this._z = 0), (this._w = i))
  3838. : ((this._x = 0), (this._y = -e.z), (this._z = e.y), (this._w = i)))
  3839. : ((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)),
  3840. this.normalize()
  3841. );
  3842. }
  3843. angleTo(e) {
  3844. return 2 * Math.acos(Math.abs(ti(this.dot(e), -1, 1)));
  3845. }
  3846. rotateTowards(e, t) {
  3847. let i = this.angleTo(e);
  3848. if (i === 0) return this;
  3849. let r = Math.min(1, t / i);
  3850. return this.slerp(e, r), this;
  3851. }
  3852. identity() {
  3853. return this.set(0, 0, 0, 1);
  3854. }
  3855. invert() {
  3856. return this.conjugate();
  3857. }
  3858. conjugate() {
  3859. return (this._x *= -1), (this._y *= -1), (this._z *= -1), this._onChangeCallback(), this;
  3860. }
  3861. dot(e) {
  3862. return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w;
  3863. }
  3864. lengthSq() {
  3865. return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
  3866. }
  3867. length() {
  3868. return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
  3869. }
  3870. normalize() {
  3871. let e = this.length();
  3872. return (
  3873. e === 0
  3874. ? ((this._x = 0), (this._y = 0), (this._z = 0), (this._w = 1))
  3875. : ((e = 1 / e), (this._x = this._x * e), (this._y = this._y * e), (this._z = this._z * e), (this._w = this._w * e)),
  3876. this._onChangeCallback(),
  3877. this
  3878. );
  3879. }
  3880. multiply(e) {
  3881. return this.multiplyQuaternions(this, e);
  3882. }
  3883. premultiply(e) {
  3884. return this.multiplyQuaternions(e, this);
  3885. }
  3886. multiplyQuaternions(e, t) {
  3887. let i = e._x,
  3888. r = e._y,
  3889. s = e._z,
  3890. n = e._w,
  3891. a = t._x,
  3892. o = t._y,
  3893. l = t._z,
  3894. h = t._w;
  3895. return (
  3896. (this._x = i * h + n * a + r * l - s * o),
  3897. (this._y = r * h + n * o + s * a - i * l),
  3898. (this._z = s * h + n * l + i * o - r * a),
  3899. (this._w = n * h - i * a - r * o - s * l),
  3900. this._onChangeCallback(),
  3901. this
  3902. );
  3903. }
  3904. slerp(e, t) {
  3905. if (t === 0) return this;
  3906. if (t === 1) return this.copy(e);
  3907. let i = this._x,
  3908. r = this._y,
  3909. s = this._z,
  3910. n = this._w,
  3911. a = n * e._w + i * e._x + r * e._y + s * e._z;
  3912. if ((a < 0 ? ((this._w = -e._w), (this._x = -e._x), (this._y = -e._y), (this._z = -e._z), (a = -a)) : this.copy(e), a >= 1))
  3913. return (this._w = n), (this._x = i), (this._y = r), (this._z = s), this;
  3914. let o = 1 - a * a;
  3915. if (o <= Number.EPSILON) {
  3916. let d = 1 - t;
  3917. return (
  3918. (this._w = d * n + t * this._w),
  3919. (this._x = d * i + t * this._x),
  3920. (this._y = d * r + t * this._y),
  3921. (this._z = d * s + t * this._z),
  3922. this.normalize(),
  3923. this._onChangeCallback(),
  3924. this
  3925. );
  3926. }
  3927. let l = Math.sqrt(o),
  3928. h = Math.atan2(l, a),
  3929. u = Math.sin((1 - t) * h) / l,
  3930. c = Math.sin(t * h) / l;
  3931. return (
  3932. (this._w = n * u + this._w * c),
  3933. (this._x = i * u + this._x * c),
  3934. (this._y = r * u + this._y * c),
  3935. (this._z = s * u + this._z * c),
  3936. this._onChangeCallback(),
  3937. this
  3938. );
  3939. }
  3940. slerpQuaternions(e, t, i) {
  3941. return this.copy(e).slerp(t, i);
  3942. }
  3943. random() {
  3944. let e = Math.random(),
  3945. t = Math.sqrt(1 - e),
  3946. i = Math.sqrt(e),
  3947. r = 2 * Math.PI * Math.random(),
  3948. s = 2 * Math.PI * Math.random();
  3949. return this.set(t * Math.cos(r), i * Math.sin(s), i * Math.cos(s), t * Math.sin(r));
  3950. }
  3951. equals(e) {
  3952. return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w;
  3953. }
  3954. fromArray(e, t = 0) {
  3955. return (this._x = e[t]), (this._y = e[t + 1]), (this._z = e[t + 2]), (this._w = e[t + 3]), this._onChangeCallback(), this;
  3956. }
  3957. toArray(e = [], t = 0) {
  3958. return (e[t] = this._x), (e[t + 1] = this._y), (e[t + 2] = this._z), (e[t + 3] = this._w), e;
  3959. }
  3960. fromBufferAttribute(e, t) {
  3961. return (this._x = e.getX(t)), (this._y = e.getY(t)), (this._z = e.getZ(t)), (this._w = e.getW(t)), this;
  3962. }
  3963. _onChange(e) {
  3964. return (this._onChangeCallback = e), this;
  3965. }
  3966. _onChangeCallback() {}
  3967. *[Symbol.iterator]() {
  3968. yield this._x, yield this._y, yield this._z, yield this._w;
  3969. }
  3970. },
  3971. E = class {
  3972. constructor(e = 0, t = 0, i = 0) {
  3973. (E.prototype.isVector3 = !0), (this.x = e), (this.y = t), (this.z = i);
  3974. }
  3975. set(e, t, i) {
  3976. return i === void 0 && (i = this.z), (this.x = e), (this.y = t), (this.z = i), this;
  3977. }
  3978. setScalar(e) {
  3979. return (this.x = e), (this.y = e), (this.z = e), this;
  3980. }
  3981. setX(e) {
  3982. return (this.x = e), this;
  3983. }
  3984. setY(e) {
  3985. return (this.y = e), this;
  3986. }
  3987. setZ(e) {
  3988. return (this.z = e), this;
  3989. }
  3990. setComponent(e, t) {
  3991. switch (e) {
  3992. case 0:
  3993. this.x = t;
  3994. break;
  3995. case 1:
  3996. this.y = t;
  3997. break;
  3998. case 2:
  3999. this.z = t;
  4000. break;
  4001. default:
  4002. throw new Error('index is out of range: ' + e);
  4003. }
  4004. return this;
  4005. }
  4006. getComponent(e) {
  4007. switch (e) {
  4008. case 0:
  4009. return this.x;
  4010. case 1:
  4011. return this.y;
  4012. case 2:
  4013. return this.z;
  4014. default:
  4015. throw new Error('index is out of range: ' + e);
  4016. }
  4017. }
  4018. clone() {
  4019. return new this.constructor(this.x, this.y, this.z);
  4020. }
  4021. copy(e) {
  4022. return (this.x = e.x), (this.y = e.y), (this.z = e.z), this;
  4023. }
  4024. add(e) {
  4025. return (this.x += e.x), (this.y += e.y), (this.z += e.z), this;
  4026. }
  4027. addScalar(e) {
  4028. return (this.x += e), (this.y += e), (this.z += e), this;
  4029. }
  4030. addVectors(e, t) {
  4031. return (this.x = e.x + t.x), (this.y = e.y + t.y), (this.z = e.z + t.z), this;
  4032. }
  4033. addScaledVector(e, t) {
  4034. return (this.x += e.x * t), (this.y += e.y * t), (this.z += e.z * t), this;
  4035. }
  4036. sub(e) {
  4037. return (this.x -= e.x), (this.y -= e.y), (this.z -= e.z), this;
  4038. }
  4039. subScalar(e) {
  4040. return (this.x -= e), (this.y -= e), (this.z -= e), this;
  4041. }
  4042. subVectors(e, t) {
  4043. return (this.x = e.x - t.x), (this.y = e.y - t.y), (this.z = e.z - t.z), this;
  4044. }
  4045. multiply(e) {
  4046. return (this.x *= e.x), (this.y *= e.y), (this.z *= e.z), this;
  4047. }
  4048. multiplyScalar(e) {
  4049. return (this.x *= e), (this.y *= e), (this.z *= e), this;
  4050. }
  4051. multiplyVectors(e, t) {
  4052. return (this.x = e.x * t.x), (this.y = e.y * t.y), (this.z = e.z * t.z), this;
  4053. }
  4054. applyEuler(e) {
  4055. return this.applyQuaternion(I0.setFromEuler(e));
  4056. }
  4057. applyAxisAngle(e, t) {
  4058. return this.applyQuaternion(I0.setFromAxisAngle(e, t));
  4059. }
  4060. applyMatrix3(e) {
  4061. let t = this.x,
  4062. i = this.y,
  4063. r = this.z,
  4064. s = e.elements;
  4065. return (
  4066. (this.x = s[0] * t + s[3] * i + s[6] * r),
  4067. (this.y = s[1] * t + s[4] * i + s[7] * r),
  4068. (this.z = s[2] * t + s[5] * i + s[8] * r),
  4069. this
  4070. );
  4071. }
  4072. applyNormalMatrix(e) {
  4073. return this.applyMatrix3(e).normalize();
  4074. }
  4075. applyMatrix4(e) {
  4076. let t = this.x,
  4077. i = this.y,
  4078. r = this.z,
  4079. s = e.elements,
  4080. n = 1 / (s[3] * t + s[7] * i + s[11] * r + s[15]);
  4081. return (
  4082. (this.x = (s[0] * t + s[4] * i + s[8] * r + s[12]) * n),
  4083. (this.y = (s[1] * t + s[5] * i + s[9] * r + s[13]) * n),
  4084. (this.z = (s[2] * t + s[6] * i + s[10] * r + s[14]) * n),
  4085. this
  4086. );
  4087. }
  4088. applyQuaternion(e) {
  4089. let t = this.x,
  4090. i = this.y,
  4091. r = this.z,
  4092. s = e.x,
  4093. n = e.y,
  4094. a = e.z,
  4095. o = e.w,
  4096. l = o * t + n * r - a * i,
  4097. h = o * i + a * t - s * r,
  4098. u = o * r + s * i - n * t,
  4099. c = -s * t - n * i - a * r;
  4100. return (
  4101. (this.x = l * o + c * -s + h * -a - u * -n),
  4102. (this.y = h * o + c * -n + u * -s - l * -a),
  4103. (this.z = u * o + c * -a + l * -n - h * -s),
  4104. this
  4105. );
  4106. }
  4107. project(e) {
  4108. return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);
  4109. }
  4110. unproject(e) {
  4111. return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld);
  4112. }
  4113. transformDirection(e) {
  4114. let t = this.x,
  4115. i = this.y,
  4116. r = this.z,
  4117. s = e.elements;
  4118. return (
  4119. (this.x = s[0] * t + s[4] * i + s[8] * r),
  4120. (this.y = s[1] * t + s[5] * i + s[9] * r),
  4121. (this.z = s[2] * t + s[6] * i + s[10] * r),
  4122. this.normalize()
  4123. );
  4124. }
  4125. divide(e) {
  4126. return (this.x /= e.x), (this.y /= e.y), (this.z /= e.z), this;
  4127. }
  4128. divideScalar(e) {
  4129. return this.multiplyScalar(1 / e);
  4130. }
  4131. min(e) {
  4132. 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;
  4133. }
  4134. max(e) {
  4135. 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;
  4136. }
  4137. clamp(e, t) {
  4138. return (
  4139. (this.x = Math.max(e.x, Math.min(t.x, this.x))),
  4140. (this.y = Math.max(e.y, Math.min(t.y, this.y))),
  4141. (this.z = Math.max(e.z, Math.min(t.z, this.z))),
  4142. this
  4143. );
  4144. }
  4145. clampScalar(e, t) {
  4146. return (
  4147. (this.x = Math.max(e, Math.min(t, this.x))),
  4148. (this.y = Math.max(e, Math.min(t, this.y))),
  4149. (this.z = Math.max(e, Math.min(t, this.z))),
  4150. this
  4151. );
  4152. }
  4153. clampLength(e, t) {
  4154. let i = this.length();
  4155. return this.divideScalar(i || 1).multiplyScalar(Math.max(e, Math.min(t, i)));
  4156. }
  4157. floor() {
  4158. return (this.x = Math.floor(this.x)), (this.y = Math.floor(this.y)), (this.z = Math.floor(this.z)), this;
  4159. }
  4160. ceil() {
  4161. return (this.x = Math.ceil(this.x)), (this.y = Math.ceil(this.y)), (this.z = Math.ceil(this.z)), this;
  4162. }
  4163. round() {
  4164. return (this.x = Math.round(this.x)), (this.y = Math.round(this.y)), (this.z = Math.round(this.z)), this;
  4165. }
  4166. roundToZero() {
  4167. return (
  4168. (this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x)),
  4169. (this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y)),
  4170. (this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z)),
  4171. this
  4172. );
  4173. }
  4174. negate() {
  4175. return (this.x = -this.x), (this.y = -this.y), (this.z = -this.z), this;
  4176. }
  4177. dot(e) {
  4178. return this.x * e.x + this.y * e.y + this.z * e.z;
  4179. }
  4180. lengthSq() {
  4181. return this.x * this.x + this.y * this.y + this.z * this.z;
  4182. }
  4183. length() {
  4184. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  4185. }
  4186. manhattanLength() {
  4187. return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
  4188. }
  4189. normalize() {
  4190. return this.divideScalar(this.length() || 1);
  4191. }
  4192. setLength(e) {
  4193. return this.normalize().multiplyScalar(e);
  4194. }
  4195. lerp(e, t) {
  4196. return (this.x += (e.x - this.x) * t), (this.y += (e.y - this.y) * t), (this.z += (e.z - this.z) * t), this;
  4197. }
  4198. lerpVectors(e, t, i) {
  4199. 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;
  4200. }
  4201. cross(e) {
  4202. return this.crossVectors(this, e);
  4203. }
  4204. crossVectors(e, t) {
  4205. let i = e.x,
  4206. r = e.y,
  4207. s = e.z,
  4208. n = t.x,
  4209. a = t.y,
  4210. o = t.z;
  4211. return (this.x = r * o - s * a), (this.y = s * n - i * o), (this.z = i * a - r * n), this;
  4212. }
  4213. projectOnVector(e) {
  4214. let t = e.lengthSq();
  4215. if (t === 0) return this.set(0, 0, 0);
  4216. let i = e.dot(this) / t;
  4217. return this.copy(e).multiplyScalar(i);
  4218. }
  4219. projectOnPlane(e) {
  4220. return rp.copy(this).projectOnVector(e), this.sub(rp);
  4221. }
  4222. reflect(e) {
  4223. return this.sub(rp.copy(e).multiplyScalar(2 * this.dot(e)));
  4224. }
  4225. angleTo(e) {
  4226. let t = Math.sqrt(this.lengthSq() * e.lengthSq());
  4227. if (t === 0) return Math.PI / 2;
  4228. let i = this.dot(e) / t;
  4229. return Math.acos(ti(i, -1, 1));
  4230. }
  4231. distanceTo(e) {
  4232. return Math.sqrt(this.distanceToSquared(e));
  4233. }
  4234. distanceToSquared(e) {
  4235. let t = this.x - e.x,
  4236. i = this.y - e.y,
  4237. r = this.z - e.z;
  4238. return t * t + i * i + r * r;
  4239. }
  4240. manhattanDistanceTo(e) {
  4241. return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z);
  4242. }
  4243. setFromSpherical(e) {
  4244. return this.setFromSphericalCoords(e.radius, e.phi, e.theta);
  4245. }
  4246. setFromSphericalCoords(e, t, i) {
  4247. let r = Math.sin(t) * e;
  4248. return (this.x = r * Math.sin(i)), (this.y = Math.cos(t) * e), (this.z = r * Math.cos(i)), this;
  4249. }
  4250. setFromCylindrical(e) {
  4251. return this.setFromCylindricalCoords(e.radius, e.theta, e.y);
  4252. }
  4253. setFromCylindricalCoords(e, t, i) {
  4254. return (this.x = e * Math.sin(t)), (this.y = i), (this.z = e * Math.cos(t)), this;
  4255. }
  4256. setFromMatrixPosition(e) {
  4257. let t = e.elements;
  4258. return (this.x = t[12]), (this.y = t[13]), (this.z = t[14]), this;
  4259. }
  4260. setFromMatrixScale(e) {
  4261. let t = this.setFromMatrixColumn(e, 0).length(),
  4262. i = this.setFromMatrixColumn(e, 1).length(),
  4263. r = this.setFromMatrixColumn(e, 2).length();
  4264. return (this.x = t), (this.y = i), (this.z = r), this;
  4265. }
  4266. setFromMatrixColumn(e, t) {
  4267. return this.fromArray(e.elements, t * 4);
  4268. }
  4269. setFromMatrix3Column(e, t) {
  4270. return this.fromArray(e.elements, t * 3);
  4271. }
  4272. setFromEuler(e) {
  4273. return (this.x = e._x), (this.y = e._y), (this.z = e._z), this;
  4274. }
  4275. equals(e) {
  4276. return e.x === this.x && e.y === this.y && e.z === this.z;
  4277. }
  4278. fromArray(e, t = 0) {
  4279. return (this.x = e[t]), (this.y = e[t + 1]), (this.z = e[t + 2]), this;
  4280. }
  4281. toArray(e = [], t = 0) {
  4282. return (e[t] = this.x), (e[t + 1] = this.y), (e[t + 2] = this.z), e;
  4283. }
  4284. fromBufferAttribute(e, t) {
  4285. return (this.x = e.getX(t)), (this.y = e.getY(t)), (this.z = e.getZ(t)), this;
  4286. }
  4287. random() {
  4288. return (this.x = Math.random()), (this.y = Math.random()), (this.z = Math.random()), this;
  4289. }
  4290. randomDirection() {
  4291. let e = (Math.random() - 0.5) * 2,
  4292. t = Math.random() * Math.PI * 2,
  4293. i = Math.sqrt(1 - e ** 2);
  4294. return (this.x = i * Math.cos(t)), (this.y = i * Math.sin(t)), (this.z = e), this;
  4295. }
  4296. *[Symbol.iterator]() {
  4297. yield this.x, yield this.y, yield this.z;
  4298. }
  4299. },
  4300. rp = new E(),
  4301. I0 = new ct(),
  4302. Kt = class {
  4303. constructor(e = new E(1 / 0, 1 / 0, 1 / 0), t = new E(-1 / 0, -1 / 0, -1 / 0)) {
  4304. (this.isBox3 = !0), (this.min = e), (this.max = t);
  4305. }
  4306. set(e, t) {
  4307. return this.min.copy(e), this.max.copy(t), this;
  4308. }
  4309. setFromArray(e) {
  4310. let t = 1 / 0,
  4311. i = 1 / 0,
  4312. r = 1 / 0,
  4313. s = -1 / 0,
  4314. n = -1 / 0,
  4315. a = -1 / 0;
  4316. for (let o = 0, l = e.length; o < l; o += 3) {
  4317. let h = e[o],
  4318. u = e[o + 1],
  4319. c = e[o + 2];
  4320. h < t && (t = h), u < i && (i = u), c < r && (r = c), h > s && (s = h), u > n && (n = u), c > a && (a = c);
  4321. }
  4322. return this.min.set(t, i, r), this.max.set(s, n, a), this;
  4323. }
  4324. setFromBufferAttribute(e) {
  4325. let t = 1 / 0,
  4326. i = 1 / 0,
  4327. r = 1 / 0,
  4328. s = -1 / 0,
  4329. n = -1 / 0,
  4330. a = -1 / 0;
  4331. for (let o = 0, l = e.count; o < l; o++) {
  4332. let h = e.getX(o),
  4333. u = e.getY(o),
  4334. c = e.getZ(o);
  4335. h < t && (t = h), u < i && (i = u), c < r && (r = c), h > s && (s = h), u > n && (n = u), c > a && (a = c);
  4336. }
  4337. return this.min.set(t, i, r), this.max.set(s, n, a), this;
  4338. }
  4339. setFromPoints(e) {
  4340. this.makeEmpty();
  4341. for (let t = 0, i = e.length; t < i; t++) this.expandByPoint(e[t]);
  4342. return this;
  4343. }
  4344. setFromCenterAndSize(e, t) {
  4345. let i = Hn.copy(t).multiplyScalar(0.5);
  4346. return this.min.copy(e).sub(i), this.max.copy(e).add(i), this;
  4347. }
  4348. setFromObject(e, t = !1) {
  4349. return this.makeEmpty(), this.expandByObject(e, t);
  4350. }
  4351. clone() {
  4352. return new this.constructor().copy(this);
  4353. }
  4354. copy(e) {
  4355. return this.min.copy(e.min), this.max.copy(e.max), this;
  4356. }
  4357. makeEmpty() {
  4358. return (this.min.x = this.min.y = this.min.z = 1 / 0), (this.max.x = this.max.y = this.max.z = -1 / 0), this;
  4359. }
  4360. isEmpty() {
  4361. return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
  4362. }
  4363. getCenter(e) {
  4364. return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5);
  4365. }
  4366. getSize(e) {
  4367. return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min);
  4368. }
  4369. expandByPoint(e) {
  4370. return this.min.min(e), this.max.max(e), this;
  4371. }
  4372. expandByVector(e) {
  4373. return this.min.sub(e), this.max.add(e), this;
  4374. }
  4375. expandByScalar(e) {
  4376. return this.min.addScalar(-e), this.max.addScalar(e), this;
  4377. }
  4378. expandByObject(e, t = !1) {
  4379. e.updateWorldMatrix(!1, !1);
  4380. let i = e.geometry;
  4381. if (i !== void 0)
  4382. if (t && i.attributes != null && i.attributes.position !== void 0) {
  4383. let s = i.attributes.position;
  4384. for (let n = 0, a = s.count; n < a; n++) Hn.fromBufferAttribute(s, n).applyMatrix4(e.matrixWorld), this.expandByPoint(Hn);
  4385. } else i.boundingBox === null && i.computeBoundingBox(), sp.copy(i.boundingBox), sp.applyMatrix4(e.matrixWorld), this.union(sp);
  4386. let r = e.children;
  4387. for (let s = 0, n = r.length; s < n; s++) this.expandByObject(r[s], t);
  4388. return this;
  4389. }
  4390. containsPoint(e) {
  4391. 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);
  4392. }
  4393. containsBox(e) {
  4394. return (
  4395. this.min.x <= e.min.x &&
  4396. e.max.x <= this.max.x &&
  4397. this.min.y <= e.min.y &&
  4398. e.max.y <= this.max.y &&
  4399. this.min.z <= e.min.z &&
  4400. e.max.z <= this.max.z
  4401. );
  4402. }
  4403. getParameter(e, t) {
  4404. return t.set(
  4405. (e.x - this.min.x) / (this.max.x - this.min.x),
  4406. (e.y - this.min.y) / (this.max.y - this.min.y),
  4407. (e.z - this.min.z) / (this.max.z - this.min.z)
  4408. );
  4409. }
  4410. intersectsBox(e) {
  4411. return !(
  4412. e.max.x < this.min.x ||
  4413. e.min.x > this.max.x ||
  4414. e.max.y < this.min.y ||
  4415. e.min.y > this.max.y ||
  4416. e.max.z < this.min.z ||
  4417. e.min.z > this.max.z
  4418. );
  4419. }
  4420. intersectsSphere(e) {
  4421. return this.clampPoint(e.center, Hn), Hn.distanceToSquared(e.center) <= e.radius * e.radius;
  4422. }
  4423. intersectsPlane(e) {
  4424. let t, i;
  4425. return (
  4426. e.normal.x > 0
  4427. ? ((t = e.normal.x * this.min.x), (i = e.normal.x * this.max.x))
  4428. : ((t = e.normal.x * this.max.x), (i = e.normal.x * this.min.x)),
  4429. e.normal.y > 0
  4430. ? ((t += e.normal.y * this.min.y), (i += e.normal.y * this.max.y))
  4431. : ((t += e.normal.y * this.max.y), (i += e.normal.y * this.min.y)),
  4432. e.normal.z > 0
  4433. ? ((t += e.normal.z * this.min.z), (i += e.normal.z * this.max.z))
  4434. : ((t += e.normal.z * this.max.z), (i += e.normal.z * this.min.z)),
  4435. t <= -e.constant && i >= -e.constant
  4436. );
  4437. }
  4438. intersectsTriangle(e) {
  4439. if (this.isEmpty()) return !1;
  4440. this.getCenter(dl),
  4441. Yh.subVectors(this.max, dl),
  4442. Ba.subVectors(e.a, dl),
  4443. za.subVectors(e.b, dl),
  4444. Na.subVectors(e.c, dl),
  4445. Ks.subVectors(za, Ba),
  4446. Js.subVectors(Na, za),
  4447. Wn.subVectors(Ba, Na);
  4448. let t = [
  4449. 0,
  4450. -Ks.z,
  4451. Ks.y,
  4452. 0,
  4453. -Js.z,
  4454. Js.y,
  4455. 0,
  4456. -Wn.z,
  4457. Wn.y,
  4458. Ks.z,
  4459. 0,
  4460. -Ks.x,
  4461. Js.z,
  4462. 0,
  4463. -Js.x,
  4464. Wn.z,
  4465. 0,
  4466. -Wn.x,
  4467. -Ks.y,
  4468. Ks.x,
  4469. 0,
  4470. -Js.y,
  4471. Js.x,
  4472. 0,
  4473. -Wn.y,
  4474. Wn.x,
  4475. 0
  4476. ];
  4477. return !np(t, Ba, za, Na, Yh) || ((t = [1, 0, 0, 0, 1, 0, 0, 0, 1]), !np(t, Ba, za, Na, Yh))
  4478. ? !1
  4479. : (Qh.crossVectors(Ks, Js), (t = [Qh.x, Qh.y, Qh.z]), np(t, Ba, za, Na, Yh));
  4480. }
  4481. clampPoint(e, t) {
  4482. return t.copy(e).clamp(this.min, this.max);
  4483. }
  4484. distanceToPoint(e) {
  4485. return Hn.copy(e).clamp(this.min, this.max).sub(e).length();
  4486. }
  4487. getBoundingSphere(e) {
  4488. return this.getCenter(e.center), (e.radius = this.getSize(Hn).length() * 0.5), e;
  4489. }
  4490. intersect(e) {
  4491. return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this;
  4492. }
  4493. union(e) {
  4494. return this.min.min(e.min), this.max.max(e.max), this;
  4495. }
  4496. applyMatrix4(e) {
  4497. return this.isEmpty()
  4498. ? this
  4499. : (Cs[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e),
  4500. Cs[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e),
  4501. Cs[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e),
  4502. Cs[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e),
  4503. Cs[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e),
  4504. Cs[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e),
  4505. Cs[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e),
  4506. Cs[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e),
  4507. this.setFromPoints(Cs),
  4508. this);
  4509. }
  4510. translate(e) {
  4511. return this.min.add(e), this.max.add(e), this;
  4512. }
  4513. equals(e) {
  4514. return e.min.equals(this.min) && e.max.equals(this.max);
  4515. }
  4516. },
  4517. Cs = [new E(), new E(), new E(), new E(), new E(), new E(), new E(), new E()],
  4518. Hn = new E(),
  4519. sp = new Kt(),
  4520. Ba = new E(),
  4521. za = new E(),
  4522. Na = new E(),
  4523. Ks = new E(),
  4524. Js = new E(),
  4525. Wn = new E(),
  4526. dl = new E(),
  4527. Yh = new E(),
  4528. Qh = new E(),
  4529. Xn = new E();
  4530. function np(e, t, i, r, s) {
  4531. for (let n = 0, a = e.length - 3; n <= a; n += 3) {
  4532. Xn.fromArray(e, n);
  4533. let o = s.x * Math.abs(Xn.x) + s.y * Math.abs(Xn.y) + s.z * Math.abs(Xn.z),
  4534. l = t.dot(Xn),
  4535. h = i.dot(Xn),
  4536. u = r.dot(Xn);
  4537. if (Math.max(-Math.max(l, h, u), Math.min(l, h, u)) > o) return !1;
  4538. }
  4539. return !0;
  4540. }
  4541. var sE = new Kt(),
  4542. ul = new E(),
  4543. ap = new E(),
  4544. Mr = class {
  4545. constructor(e = new E(), t = -1) {
  4546. (this.center = e), (this.radius = t);
  4547. }
  4548. set(e, t) {
  4549. return this.center.copy(e), (this.radius = t), this;
  4550. }
  4551. setFromPoints(e, t) {
  4552. let i = this.center;
  4553. t !== void 0 ? i.copy(t) : sE.setFromPoints(e).getCenter(i);
  4554. let r = 0;
  4555. for (let s = 0, n = e.length; s < n; s++) r = Math.max(r, i.distanceToSquared(e[s]));
  4556. return (this.radius = Math.sqrt(r)), this;
  4557. }
  4558. copy(e) {
  4559. return this.center.copy(e.center), (this.radius = e.radius), this;
  4560. }
  4561. isEmpty() {
  4562. return this.radius < 0;
  4563. }
  4564. makeEmpty() {
  4565. return this.center.set(0, 0, 0), (this.radius = -1), this;
  4566. }
  4567. containsPoint(e) {
  4568. return e.distanceToSquared(this.center) <= this.radius * this.radius;
  4569. }
  4570. distanceToPoint(e) {
  4571. return e.distanceTo(this.center) - this.radius;
  4572. }
  4573. intersectsSphere(e) {
  4574. let t = this.radius + e.radius;
  4575. return e.center.distanceToSquared(this.center) <= t * t;
  4576. }
  4577. intersectsBox(e) {
  4578. return e.intersectsSphere(this);
  4579. }
  4580. intersectsPlane(e) {
  4581. return Math.abs(e.distanceToPoint(this.center)) <= this.radius;
  4582. }
  4583. clampPoint(e, t) {
  4584. let i = this.center.distanceToSquared(e);
  4585. return (
  4586. t.copy(e), i > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t
  4587. );
  4588. }
  4589. getBoundingBox(e) {
  4590. return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e);
  4591. }
  4592. applyMatrix4(e) {
  4593. return this.center.applyMatrix4(e), (this.radius = this.radius * e.getMaxScaleOnAxis()), this;
  4594. }
  4595. translate(e) {
  4596. return this.center.add(e), this;
  4597. }
  4598. expandByPoint(e) {
  4599. if (this.isEmpty()) return this.center.copy(e), (this.radius = 0), this;
  4600. ul.subVectors(e, this.center);
  4601. let t = ul.lengthSq();
  4602. if (t > this.radius * this.radius) {
  4603. let i = Math.sqrt(t),
  4604. r = (i - this.radius) * 0.5;
  4605. this.center.addScaledVector(ul, r / i), (this.radius += r);
  4606. }
  4607. return this;
  4608. }
  4609. union(e) {
  4610. return e.isEmpty()
  4611. ? this
  4612. : this.isEmpty()
  4613. ? (this.copy(e), this)
  4614. : (this.center.equals(e.center) === !0
  4615. ? (this.radius = Math.max(this.radius, e.radius))
  4616. : (ap.subVectors(e.center, this.center).setLength(e.radius),
  4617. this.expandByPoint(ul.copy(e.center).add(ap)),
  4618. this.expandByPoint(ul.copy(e.center).sub(ap))),
  4619. this);
  4620. }
  4621. equals(e) {
  4622. return e.center.equals(this.center) && e.radius === this.radius;
  4623. }
  4624. clone() {
  4625. return new this.constructor().copy(this);
  4626. }
  4627. },
  4628. Ts = new E(),
  4629. op = new E(),
  4630. Zh = new E(),
  4631. $s = new E(),
  4632. lp = new E(),
  4633. Kh = new E(),
  4634. hp = new E(),
  4635. Xo = class {
  4636. constructor(e = new E(), t = new E(0, 0, -1)) {
  4637. (this.origin = e), (this.direction = t);
  4638. }
  4639. set(e, t) {
  4640. return this.origin.copy(e), this.direction.copy(t), this;
  4641. }
  4642. copy(e) {
  4643. return this.origin.copy(e.origin), this.direction.copy(e.direction), this;
  4644. }
  4645. at(e, t) {
  4646. return t.copy(this.direction).multiplyScalar(e).add(this.origin);
  4647. }
  4648. lookAt(e) {
  4649. return this.direction.copy(e).sub(this.origin).normalize(), this;
  4650. }
  4651. recast(e) {
  4652. return this.origin.copy(this.at(e, Ts)), this;
  4653. }
  4654. closestPointToPoint(e, t) {
  4655. t.subVectors(e, this.origin);
  4656. let i = t.dot(this.direction);
  4657. return i < 0 ? t.copy(this.origin) : t.copy(this.direction).multiplyScalar(i).add(this.origin);
  4658. }
  4659. distanceToPoint(e) {
  4660. return Math.sqrt(this.distanceSqToPoint(e));
  4661. }
  4662. distanceSqToPoint(e) {
  4663. let t = Ts.subVectors(e, this.origin).dot(this.direction);
  4664. return t < 0
  4665. ? this.origin.distanceToSquared(e)
  4666. : (Ts.copy(this.direction).multiplyScalar(t).add(this.origin), Ts.distanceToSquared(e));
  4667. }
  4668. distanceSqToSegment(e, t, i, r) {
  4669. op.copy(e).add(t).multiplyScalar(0.5), Zh.copy(t).sub(e).normalize(), $s.copy(this.origin).sub(op);
  4670. let s = e.distanceTo(t) * 0.5,
  4671. n = -this.direction.dot(Zh),
  4672. a = $s.dot(this.direction),
  4673. o = -$s.dot(Zh),
  4674. l = $s.lengthSq(),
  4675. h = Math.abs(1 - n * n),
  4676. u,
  4677. c,
  4678. d,
  4679. p;
  4680. if (h > 0)
  4681. if (((u = n * o - a), (c = n * a - o), (p = s * h), u >= 0))
  4682. if (c >= -p)
  4683. if (c <= p) {
  4684. let f = 1 / h;
  4685. (u *= f), (c *= f), (d = u * (u + n * c + 2 * a) + c * (n * u + c + 2 * o) + l);
  4686. } else (c = s), (u = Math.max(0, -(n * c + a))), (d = -u * u + c * (c + 2 * o) + l);
  4687. else (c = -s), (u = Math.max(0, -(n * c + a))), (d = -u * u + c * (c + 2 * o) + l);
  4688. else
  4689. c <= -p
  4690. ? ((u = Math.max(0, -(-n * s + a))), (c = u > 0 ? -s : Math.min(Math.max(-s, -o), s)), (d = -u * u + c * (c + 2 * o) + l))
  4691. : c <= p
  4692. ? ((u = 0), (c = Math.min(Math.max(-s, -o), s)), (d = c * (c + 2 * o) + l))
  4693. : ((u = Math.max(0, -(n * s + a))), (c = u > 0 ? s : Math.min(Math.max(-s, -o), s)), (d = -u * u + c * (c + 2 * o) + l));
  4694. else (c = n > 0 ? -s : s), (u = Math.max(0, -(n * c + a))), (d = -u * u + c * (c + 2 * o) + l);
  4695. return i && i.copy(this.direction).multiplyScalar(u).add(this.origin), r && r.copy(Zh).multiplyScalar(c).add(op), d;
  4696. }
  4697. intersectSphere(e, t) {
  4698. Ts.subVectors(e.center, this.origin);
  4699. let i = Ts.dot(this.direction),
  4700. r = Ts.dot(Ts) - i * i,
  4701. s = e.radius * e.radius;
  4702. if (r > s) return null;
  4703. let n = Math.sqrt(s - r),
  4704. a = i - n,
  4705. o = i + n;
  4706. return a < 0 && o < 0 ? null : a < 0 ? this.at(o, t) : this.at(a, t);
  4707. }
  4708. intersectsSphere(e) {
  4709. return this.distanceSqToPoint(e.center) <= e.radius * e.radius;
  4710. }
  4711. distanceToPlane(e) {
  4712. let t = e.normal.dot(this.direction);
  4713. if (t === 0) return e.distanceToPoint(this.origin) === 0 ? 0 : null;
  4714. let i = -(this.origin.dot(e.normal) + e.constant) / t;
  4715. return i >= 0 ? i : null;
  4716. }
  4717. intersectPlane(e, t) {
  4718. let i = this.distanceToPlane(e);
  4719. return i === null ? null : this.at(i, t);
  4720. }
  4721. intersectsPlane(e) {
  4722. let t = e.distanceToPoint(this.origin);
  4723. return t === 0 || e.normal.dot(this.direction) * t < 0;
  4724. }
  4725. intersectBox(e, t) {
  4726. let i,
  4727. r,
  4728. s,
  4729. n,
  4730. a,
  4731. o,
  4732. l = 1 / this.direction.x,
  4733. h = 1 / this.direction.y,
  4734. u = 1 / this.direction.z,
  4735. c = this.origin;
  4736. return (
  4737. l >= 0 ? ((i = (e.min.x - c.x) * l), (r = (e.max.x - c.x) * l)) : ((i = (e.max.x - c.x) * l), (r = (e.min.x - c.x) * l)),
  4738. h >= 0 ? ((s = (e.min.y - c.y) * h), (n = (e.max.y - c.y) * h)) : ((s = (e.max.y - c.y) * h), (n = (e.min.y - c.y) * h)),
  4739. i > n ||
  4740. s > r ||
  4741. ((s > i || isNaN(i)) && (i = s),
  4742. (n < r || isNaN(r)) && (r = n),
  4743. u >= 0 ? ((a = (e.min.z - c.z) * u), (o = (e.max.z - c.z) * u)) : ((a = (e.max.z - c.z) * u), (o = (e.min.z - c.z) * u)),
  4744. i > o || a > r) ||
  4745. ((a > i || i !== i) && (i = a), (o < r || r !== r) && (r = o), r < 0)
  4746. ? null
  4747. : this.at(i >= 0 ? i : r, t)
  4748. );
  4749. }
  4750. intersectsBox(e) {
  4751. return this.intersectBox(e, Ts) !== null;
  4752. }
  4753. intersectTriangle(e, t, i, r, s) {
  4754. lp.subVectors(t, e), Kh.subVectors(i, e), hp.crossVectors(lp, Kh);
  4755. let n = this.direction.dot(hp),
  4756. a;
  4757. if (n > 0) {
  4758. if (r) return null;
  4759. a = 1;
  4760. } else if (n < 0) (a = -1), (n = -n);
  4761. else return null;
  4762. $s.subVectors(this.origin, e);
  4763. let o = a * this.direction.dot(Kh.crossVectors($s, Kh));
  4764. if (o < 0) return null;
  4765. let l = a * this.direction.dot(lp.cross($s));
  4766. if (l < 0 || o + l > n) return null;
  4767. let h = -a * $s.dot(hp);
  4768. return h < 0 ? null : this.at(h / n, s);
  4769. }
  4770. applyMatrix4(e) {
  4771. return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this;
  4772. }
  4773. equals(e) {
  4774. return e.origin.equals(this.origin) && e.direction.equals(this.direction);
  4775. }
  4776. clone() {
  4777. return new this.constructor().copy(this);
  4778. }
  4779. },
  4780. ve = class {
  4781. constructor() {
  4782. (ve.prototype.isMatrix4 = !0), (this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
  4783. }
  4784. set(e, t, i, r, s, n, a, o, l, h, u, c, d, p, f, g) {
  4785. let m = this.elements;
  4786. return (
  4787. (m[0] = e),
  4788. (m[4] = t),
  4789. (m[8] = i),
  4790. (m[12] = r),
  4791. (m[1] = s),
  4792. (m[5] = n),
  4793. (m[9] = a),
  4794. (m[13] = o),
  4795. (m[2] = l),
  4796. (m[6] = h),
  4797. (m[10] = u),
  4798. (m[14] = c),
  4799. (m[3] = d),
  4800. (m[7] = p),
  4801. (m[11] = f),
  4802. (m[15] = g),
  4803. this
  4804. );
  4805. }
  4806. identity() {
  4807. return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this;
  4808. }
  4809. clone() {
  4810. return new ve().fromArray(this.elements);
  4811. }
  4812. copy(e) {
  4813. let t = this.elements,
  4814. i = e.elements;
  4815. return (
  4816. (t[0] = i[0]),
  4817. (t[1] = i[1]),
  4818. (t[2] = i[2]),
  4819. (t[3] = i[3]),
  4820. (t[4] = i[4]),
  4821. (t[5] = i[5]),
  4822. (t[6] = i[6]),
  4823. (t[7] = i[7]),
  4824. (t[8] = i[8]),
  4825. (t[9] = i[9]),
  4826. (t[10] = i[10]),
  4827. (t[11] = i[11]),
  4828. (t[12] = i[12]),
  4829. (t[13] = i[13]),
  4830. (t[14] = i[14]),
  4831. (t[15] = i[15]),
  4832. this
  4833. );
  4834. }
  4835. copyPosition(e) {
  4836. let t = this.elements,
  4837. i = e.elements;
  4838. return (t[12] = i[12]), (t[13] = i[13]), (t[14] = i[14]), this;
  4839. }
  4840. setFromMatrix3(e) {
  4841. let t = e.elements;
  4842. 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;
  4843. }
  4844. extractBasis(e, t, i) {
  4845. return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), i.setFromMatrixColumn(this, 2), this;
  4846. }
  4847. makeBasis(e, t, i) {
  4848. 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;
  4849. }
  4850. extractRotation(e) {
  4851. let t = this.elements,
  4852. i = e.elements,
  4853. r = 1 / Ua.setFromMatrixColumn(e, 0).length(),
  4854. s = 1 / Ua.setFromMatrixColumn(e, 1).length(),
  4855. n = 1 / Ua.setFromMatrixColumn(e, 2).length();
  4856. return (
  4857. (t[0] = i[0] * r),
  4858. (t[1] = i[1] * r),
  4859. (t[2] = i[2] * r),
  4860. (t[3] = 0),
  4861. (t[4] = i[4] * s),
  4862. (t[5] = i[5] * s),
  4863. (t[6] = i[6] * s),
  4864. (t[7] = 0),
  4865. (t[8] = i[8] * n),
  4866. (t[9] = i[9] * n),
  4867. (t[10] = i[10] * n),
  4868. (t[11] = 0),
  4869. (t[12] = 0),
  4870. (t[13] = 0),
  4871. (t[14] = 0),
  4872. (t[15] = 1),
  4873. this
  4874. );
  4875. }
  4876. makeRotationFromEuler(e) {
  4877. let t = this.elements,
  4878. i = e.x,
  4879. r = e.y,
  4880. s = e.z,
  4881. n = Math.cos(i),
  4882. a = Math.sin(i),
  4883. o = Math.cos(r),
  4884. l = Math.sin(r),
  4885. h = Math.cos(s),
  4886. u = Math.sin(s);
  4887. if (e.order === 'XYZ') {
  4888. let c = n * h,
  4889. d = n * u,
  4890. p = a * h,
  4891. f = a * u;
  4892. (t[0] = o * h),
  4893. (t[4] = -o * u),
  4894. (t[8] = l),
  4895. (t[1] = d + p * l),
  4896. (t[5] = c - f * l),
  4897. (t[9] = -a * o),
  4898. (t[2] = f - c * l),
  4899. (t[6] = p + d * l),
  4900. (t[10] = n * o);
  4901. } else if (e.order === 'YXZ') {
  4902. let c = o * h,
  4903. d = o * u,
  4904. p = l * h,
  4905. f = l * u;
  4906. (t[0] = c + f * a),
  4907. (t[4] = p * a - d),
  4908. (t[8] = n * l),
  4909. (t[1] = n * u),
  4910. (t[5] = n * h),
  4911. (t[9] = -a),
  4912. (t[2] = d * a - p),
  4913. (t[6] = f + c * a),
  4914. (t[10] = n * o);
  4915. } else if (e.order === 'ZXY') {
  4916. let c = o * h,
  4917. d = o * u,
  4918. p = l * h,
  4919. f = l * u;
  4920. (t[0] = c - f * a),
  4921. (t[4] = -n * u),
  4922. (t[8] = p + d * a),
  4923. (t[1] = d + p * a),
  4924. (t[5] = n * h),
  4925. (t[9] = f - c * a),
  4926. (t[2] = -n * l),
  4927. (t[6] = a),
  4928. (t[10] = n * o);
  4929. } else if (e.order === 'ZYX') {
  4930. let c = n * h,
  4931. d = n * u,
  4932. p = a * h,
  4933. f = a * u;
  4934. (t[0] = o * h),
  4935. (t[4] = p * l - d),
  4936. (t[8] = c * l + f),
  4937. (t[1] = o * u),
  4938. (t[5] = f * l + c),
  4939. (t[9] = d * l - p),
  4940. (t[2] = -l),
  4941. (t[6] = a * o),
  4942. (t[10] = n * o);
  4943. } else if (e.order === 'YZX') {
  4944. let c = n * o,
  4945. d = n * l,
  4946. p = a * o,
  4947. f = a * l;
  4948. (t[0] = o * h),
  4949. (t[4] = f - c * u),
  4950. (t[8] = p * u + d),
  4951. (t[1] = u),
  4952. (t[5] = n * h),
  4953. (t[9] = -a * h),
  4954. (t[2] = -l * h),
  4955. (t[6] = d * u + p),
  4956. (t[10] = c - f * u);
  4957. } else if (e.order === 'XZY') {
  4958. let c = n * o,
  4959. d = n * l,
  4960. p = a * o,
  4961. f = a * l;
  4962. (t[0] = o * h),
  4963. (t[4] = -u),
  4964. (t[8] = l * h),
  4965. (t[1] = c * u + f),
  4966. (t[5] = n * h),
  4967. (t[9] = d * u - p),
  4968. (t[2] = p * u - d),
  4969. (t[6] = a * h),
  4970. (t[10] = f * u + c);
  4971. }
  4972. return (t[3] = 0), (t[7] = 0), (t[11] = 0), (t[12] = 0), (t[13] = 0), (t[14] = 0), (t[15] = 1), this;
  4973. }
  4974. makeRotationFromQuaternion(e) {
  4975. return this.compose(nE, e, aE);
  4976. }
  4977. lookAt(e, t, i) {
  4978. let r = this.elements;
  4979. return (
  4980. qi.subVectors(e, t),
  4981. qi.lengthSq() === 0 && (qi.z = 1),
  4982. qi.normalize(),
  4983. en.crossVectors(i, qi),
  4984. en.lengthSq() === 0 && (Math.abs(i.z) === 1 ? (qi.x += 1e-4) : (qi.z += 1e-4), qi.normalize(), en.crossVectors(i, qi)),
  4985. en.normalize(),
  4986. Jh.crossVectors(qi, en),
  4987. (r[0] = en.x),
  4988. (r[4] = Jh.x),
  4989. (r[8] = qi.x),
  4990. (r[1] = en.y),
  4991. (r[5] = Jh.y),
  4992. (r[9] = qi.y),
  4993. (r[2] = en.z),
  4994. (r[6] = Jh.z),
  4995. (r[10] = qi.z),
  4996. this
  4997. );
  4998. }
  4999. multiply(e) {
  5000. return this.multiplyMatrices(this, e);
  5001. }
  5002. premultiply(e) {
  5003. return this.multiplyMatrices(e, this);
  5004. }
  5005. multiplyMatrices(e, t) {
  5006. let i = e.elements,
  5007. r = t.elements,
  5008. s = this.elements,
  5009. n = i[0],
  5010. a = i[4],
  5011. o = i[8],
  5012. l = i[12],
  5013. h = i[1],
  5014. u = i[5],
  5015. c = i[9],
  5016. d = i[13],
  5017. p = i[2],
  5018. f = i[6],
  5019. g = i[10],
  5020. m = i[14],
  5021. v = i[3],
  5022. y = i[7],
  5023. b = i[11],
  5024. x = i[15],
  5025. w = r[0],
  5026. A = r[4],
  5027. S = r[8],
  5028. _ = r[12],
  5029. M = r[1],
  5030. C = r[5],
  5031. T = r[9],
  5032. P = r[13],
  5033. L = r[2],
  5034. D = r[6],
  5035. k = r[10],
  5036. W = r[14],
  5037. X = r[3],
  5038. z = r[7],
  5039. j = r[11],
  5040. U = r[15];
  5041. return (
  5042. (s[0] = n * w + a * M + o * L + l * X),
  5043. (s[4] = n * A + a * C + o * D + l * z),
  5044. (s[8] = n * S + a * T + o * k + l * j),
  5045. (s[12] = n * _ + a * P + o * W + l * U),
  5046. (s[1] = h * w + u * M + c * L + d * X),
  5047. (s[5] = h * A + u * C + c * D + d * z),
  5048. (s[9] = h * S + u * T + c * k + d * j),
  5049. (s[13] = h * _ + u * P + c * W + d * U),
  5050. (s[2] = p * w + f * M + g * L + m * X),
  5051. (s[6] = p * A + f * C + g * D + m * z),
  5052. (s[10] = p * S + f * T + g * k + m * j),
  5053. (s[14] = p * _ + f * P + g * W + m * U),
  5054. (s[3] = v * w + y * M + b * L + x * X),
  5055. (s[7] = v * A + y * C + b * D + x * z),
  5056. (s[11] = v * S + y * T + b * k + x * j),
  5057. (s[15] = v * _ + y * P + b * W + x * U),
  5058. this
  5059. );
  5060. }
  5061. multiplyScalar(e) {
  5062. let t = this.elements;
  5063. return (
  5064. (t[0] *= e),
  5065. (t[4] *= e),
  5066. (t[8] *= e),
  5067. (t[12] *= e),
  5068. (t[1] *= e),
  5069. (t[5] *= e),
  5070. (t[9] *= e),
  5071. (t[13] *= e),
  5072. (t[2] *= e),
  5073. (t[6] *= e),
  5074. (t[10] *= e),
  5075. (t[14] *= e),
  5076. (t[3] *= e),
  5077. (t[7] *= e),
  5078. (t[11] *= e),
  5079. (t[15] *= e),
  5080. this
  5081. );
  5082. }
  5083. determinant() {
  5084. let e = this.elements,
  5085. t = e[0],
  5086. i = e[4],
  5087. r = e[8],
  5088. s = e[12],
  5089. n = e[1],
  5090. a = e[5],
  5091. o = e[9],
  5092. l = e[13],
  5093. h = e[2],
  5094. u = e[6],
  5095. c = e[10],
  5096. d = e[14],
  5097. p = e[3],
  5098. f = e[7],
  5099. g = e[11],
  5100. m = e[15];
  5101. return (
  5102. p * (+s * o * u - r * l * u - s * a * c + i * l * c + r * a * d - i * o * d) +
  5103. f * (+t * o * d - t * l * c + s * n * c - r * n * d + r * l * h - s * o * h) +
  5104. g * (+t * l * u - t * a * d - s * n * u + i * n * d + s * a * h - i * l * h) +
  5105. m * (-r * a * h - t * o * u + t * a * c + r * n * u - i * n * c + i * o * h)
  5106. );
  5107. }
  5108. transpose() {
  5109. let e = this.elements,
  5110. t;
  5111. return (
  5112. (t = e[1]),
  5113. (e[1] = e[4]),
  5114. (e[4] = t),
  5115. (t = e[2]),
  5116. (e[2] = e[8]),
  5117. (e[8] = t),
  5118. (t = e[6]),
  5119. (e[6] = e[9]),
  5120. (e[9] = t),
  5121. (t = e[3]),
  5122. (e[3] = e[12]),
  5123. (e[12] = t),
  5124. (t = e[7]),
  5125. (e[7] = e[13]),
  5126. (e[13] = t),
  5127. (t = e[11]),
  5128. (e[11] = e[14]),
  5129. (e[14] = t),
  5130. this
  5131. );
  5132. }
  5133. setPosition(e, t, i) {
  5134. let r = this.elements;
  5135. 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;
  5136. }
  5137. invert() {
  5138. let e = this.elements,
  5139. t = e[0],
  5140. i = e[1],
  5141. r = e[2],
  5142. s = e[3],
  5143. n = e[4],
  5144. a = e[5],
  5145. o = e[6],
  5146. l = e[7],
  5147. h = e[8],
  5148. u = e[9],
  5149. c = e[10],
  5150. d = e[11],
  5151. p = e[12],
  5152. f = e[13],
  5153. g = e[14],
  5154. m = e[15],
  5155. v = u * g * l - f * c * l + f * o * d - a * g * d - u * o * m + a * c * m,
  5156. y = p * c * l - h * g * l - p * o * d + n * g * d + h * o * m - n * c * m,
  5157. b = h * f * l - p * u * l + p * a * d - n * f * d - h * a * m + n * u * m,
  5158. x = p * u * o - h * f * o - p * a * c + n * f * c + h * a * g - n * u * g,
  5159. w = t * v + i * y + r * b + s * x;
  5160. if (w === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  5161. let A = 1 / w;
  5162. return (
  5163. (e[0] = v * A),
  5164. (e[1] = (f * c * s - u * g * s - f * r * d + i * g * d + u * r * m - i * c * m) * A),
  5165. (e[2] = (a * g * s - f * o * s + f * r * l - i * g * l - a * r * m + i * o * m) * A),
  5166. (e[3] = (u * o * s - a * c * s - u * r * l + i * c * l + a * r * d - i * o * d) * A),
  5167. (e[4] = y * A),
  5168. (e[5] = (h * g * s - p * c * s + p * r * d - t * g * d - h * r * m + t * c * m) * A),
  5169. (e[6] = (p * o * s - n * g * s - p * r * l + t * g * l + n * r * m - t * o * m) * A),
  5170. (e[7] = (n * c * s - h * o * s + h * r * l - t * c * l - n * r * d + t * o * d) * A),
  5171. (e[8] = b * A),
  5172. (e[9] = (p * u * s - h * f * s - p * i * d + t * f * d + h * i * m - t * u * m) * A),
  5173. (e[10] = (n * f * s - p * a * s + p * i * l - t * f * l - n * i * m + t * a * m) * A),
  5174. (e[11] = (h * a * s - n * u * s - h * i * l + t * u * l + n * i * d - t * a * d) * A),
  5175. (e[12] = x * A),
  5176. (e[13] = (h * f * r - p * u * r + p * i * c - t * f * c - h * i * g + t * u * g) * A),
  5177. (e[14] = (p * a * r - n * f * r - p * i * o + t * f * o + n * i * g - t * a * g) * A),
  5178. (e[15] = (n * u * r - h * a * r + h * i * o - t * u * o - n * i * c + t * a * c) * A),
  5179. this
  5180. );
  5181. }
  5182. scale(e) {
  5183. let t = this.elements,
  5184. i = e.x,
  5185. r = e.y,
  5186. s = e.z;
  5187. return (
  5188. (t[0] *= i),
  5189. (t[4] *= r),
  5190. (t[8] *= s),
  5191. (t[1] *= i),
  5192. (t[5] *= r),
  5193. (t[9] *= s),
  5194. (t[2] *= i),
  5195. (t[6] *= r),
  5196. (t[10] *= s),
  5197. (t[3] *= i),
  5198. (t[7] *= r),
  5199. (t[11] *= s),
  5200. this
  5201. );
  5202. }
  5203. getMaxScaleOnAxis() {
  5204. let e = this.elements,
  5205. t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2],
  5206. i = e[4] * e[4] + e[5] * e[5] + e[6] * e[6],
  5207. r = e[8] * e[8] + e[9] * e[9] + e[10] * e[10];
  5208. return Math.sqrt(Math.max(t, i, r));
  5209. }
  5210. makeTranslation(e, t, i) {
  5211. return this.set(1, 0, 0, e, 0, 1, 0, t, 0, 0, 1, i, 0, 0, 0, 1), this;
  5212. }
  5213. makeRotationX(e) {
  5214. let t = Math.cos(e),
  5215. i = Math.sin(e);
  5216. return this.set(1, 0, 0, 0, 0, t, -i, 0, 0, i, t, 0, 0, 0, 0, 1), this;
  5217. }
  5218. makeRotationY(e) {
  5219. let t = Math.cos(e),
  5220. i = Math.sin(e);
  5221. return this.set(t, 0, i, 0, 0, 1, 0, 0, -i, 0, t, 0, 0, 0, 0, 1), this;
  5222. }
  5223. makeRotationZ(e) {
  5224. let t = Math.cos(e),
  5225. i = Math.sin(e);
  5226. return this.set(t, -i, 0, 0, i, t, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this;
  5227. }
  5228. makeRotationAxis(e, t) {
  5229. let i = Math.cos(t),
  5230. r = Math.sin(t),
  5231. s = 1 - i,
  5232. n = e.x,
  5233. a = e.y,
  5234. o = e.z,
  5235. l = s * n,
  5236. h = s * a;
  5237. return (
  5238. this.set(
  5239. l * n + i,
  5240. l * a - r * o,
  5241. l * o + r * a,
  5242. 0,
  5243. l * a + r * o,
  5244. h * a + i,
  5245. h * o - r * n,
  5246. 0,
  5247. l * o - r * a,
  5248. h * o + r * n,
  5249. s * o * o + i,
  5250. 0,
  5251. 0,
  5252. 0,
  5253. 0,
  5254. 1
  5255. ),
  5256. this
  5257. );
  5258. }
  5259. makeScale(e, t, i) {
  5260. return this.set(e, 0, 0, 0, 0, t, 0, 0, 0, 0, i, 0, 0, 0, 0, 1), this;
  5261. }
  5262. makeShear(e, t, i, r, s, n) {
  5263. return this.set(1, i, s, 0, e, 1, n, 0, t, r, 1, 0, 0, 0, 0, 1), this;
  5264. }
  5265. compose(e, t, i) {
  5266. let r = this.elements,
  5267. s = t._x,
  5268. n = t._y,
  5269. a = t._z,
  5270. o = t._w,
  5271. l = s + s,
  5272. h = n + n,
  5273. u = a + a,
  5274. c = s * l,
  5275. d = s * h,
  5276. p = s * u,
  5277. f = n * h,
  5278. g = n * u,
  5279. m = a * u,
  5280. v = o * l,
  5281. y = o * h,
  5282. b = o * u,
  5283. x = i.x,
  5284. w = i.y,
  5285. A = i.z;
  5286. return (
  5287. (r[0] = (1 - (f + m)) * x),
  5288. (r[1] = (d + b) * x),
  5289. (r[2] = (p - y) * x),
  5290. (r[3] = 0),
  5291. (r[4] = (d - b) * w),
  5292. (r[5] = (1 - (c + m)) * w),
  5293. (r[6] = (g + v) * w),
  5294. (r[7] = 0),
  5295. (r[8] = (p + y) * A),
  5296. (r[9] = (g - v) * A),
  5297. (r[10] = (1 - (c + f)) * A),
  5298. (r[11] = 0),
  5299. (r[12] = e.x),
  5300. (r[13] = e.y),
  5301. (r[14] = e.z),
  5302. (r[15] = 1),
  5303. this
  5304. );
  5305. }
  5306. decompose(e, t, i) {
  5307. let r = this.elements,
  5308. s = Ua.set(r[0], r[1], r[2]).length(),
  5309. n = Ua.set(r[4], r[5], r[6]).length(),
  5310. a = Ua.set(r[8], r[9], r[10]).length();
  5311. this.determinant() < 0 && (s = -s), (e.x = r[12]), (e.y = r[13]), (e.z = r[14]), Lr.copy(this);
  5312. let o = 1 / s,
  5313. l = 1 / n,
  5314. h = 1 / a;
  5315. return (
  5316. (Lr.elements[0] *= o),
  5317. (Lr.elements[1] *= o),
  5318. (Lr.elements[2] *= o),
  5319. (Lr.elements[4] *= l),
  5320. (Lr.elements[5] *= l),
  5321. (Lr.elements[6] *= l),
  5322. (Lr.elements[8] *= h),
  5323. (Lr.elements[9] *= h),
  5324. (Lr.elements[10] *= h),
  5325. t.setFromRotationMatrix(Lr),
  5326. (i.x = s),
  5327. (i.y = n),
  5328. (i.z = a),
  5329. this
  5330. );
  5331. }
  5332. makePerspective(e, t, i, r, s, n) {
  5333. let a = this.elements,
  5334. o = (2 * s) / (t - e),
  5335. l = (2 * s) / (i - r),
  5336. h = (t + e) / (t - e),
  5337. u = (i + r) / (i - r),
  5338. c = -(n + s) / (n - s),
  5339. d = (-2 * n * s) / (n - s);
  5340. return (
  5341. (a[0] = o),
  5342. (a[4] = 0),
  5343. (a[8] = h),
  5344. (a[12] = 0),
  5345. (a[1] = 0),
  5346. (a[5] = l),
  5347. (a[9] = u),
  5348. (a[13] = 0),
  5349. (a[2] = 0),
  5350. (a[6] = 0),
  5351. (a[10] = c),
  5352. (a[14] = d),
  5353. (a[3] = 0),
  5354. (a[7] = 0),
  5355. (a[11] = -1),
  5356. (a[15] = 0),
  5357. this
  5358. );
  5359. }
  5360. makeOrthographic(e, t, i, r, s, n) {
  5361. let a = this.elements,
  5362. o = 1 / (t - e),
  5363. l = 1 / (i - r),
  5364. h = 1 / (n - s),
  5365. u = (t + e) * o,
  5366. c = (i + r) * l,
  5367. d = (n + s) * h;
  5368. return (
  5369. (a[0] = 2 * o),
  5370. (a[4] = 0),
  5371. (a[8] = 0),
  5372. (a[12] = -u),
  5373. (a[1] = 0),
  5374. (a[5] = 2 * l),
  5375. (a[9] = 0),
  5376. (a[13] = -c),
  5377. (a[2] = 0),
  5378. (a[6] = 0),
  5379. (a[10] = -2 * h),
  5380. (a[14] = -d),
  5381. (a[3] = 0),
  5382. (a[7] = 0),
  5383. (a[11] = 0),
  5384. (a[15] = 1),
  5385. this
  5386. );
  5387. }
  5388. equals(e) {
  5389. let t = this.elements,
  5390. i = e.elements;
  5391. for (let r = 0; r < 16; r++) if (t[r] !== i[r]) return !1;
  5392. return !0;
  5393. }
  5394. fromArray(e, t = 0) {
  5395. for (let i = 0; i < 16; i++) this.elements[i] = e[i + t];
  5396. return this;
  5397. }
  5398. toArray(e = [], t = 0) {
  5399. let i = this.elements;
  5400. return (
  5401. (e[t] = i[0]),
  5402. (e[t + 1] = i[1]),
  5403. (e[t + 2] = i[2]),
  5404. (e[t + 3] = i[3]),
  5405. (e[t + 4] = i[4]),
  5406. (e[t + 5] = i[5]),
  5407. (e[t + 6] = i[6]),
  5408. (e[t + 7] = i[7]),
  5409. (e[t + 8] = i[8]),
  5410. (e[t + 9] = i[9]),
  5411. (e[t + 10] = i[10]),
  5412. (e[t + 11] = i[11]),
  5413. (e[t + 12] = i[12]),
  5414. (e[t + 13] = i[13]),
  5415. (e[t + 14] = i[14]),
  5416. (e[t + 15] = i[15]),
  5417. e
  5418. );
  5419. }
  5420. },
  5421. Ua = new E(),
  5422. Lr = new ve(),
  5423. nE = new E(0, 0, 0),
  5424. aE = new E(1, 1, 1),
  5425. en = new E(),
  5426. Jh = new E(),
  5427. qi = new E(),
  5428. R0 = new ve(),
  5429. B0 = new ct(),
  5430. _i = class {
  5431. constructor(e = 0, t = 0, i = 0, r = _i.DEFAULT_ORDER) {
  5432. (this.isEuler = !0), (this._x = e), (this._y = t), (this._z = i), (this._order = r);
  5433. }
  5434. get x() {
  5435. return this._x;
  5436. }
  5437. set x(e) {
  5438. (this._x = e), this._onChangeCallback();
  5439. }
  5440. get y() {
  5441. return this._y;
  5442. }
  5443. set y(e) {
  5444. (this._y = e), this._onChangeCallback();
  5445. }
  5446. get z() {
  5447. return this._z;
  5448. }
  5449. set z(e) {
  5450. (this._z = e), this._onChangeCallback();
  5451. }
  5452. get order() {
  5453. return this._order;
  5454. }
  5455. set order(e) {
  5456. (this._order = e), this._onChangeCallback();
  5457. }
  5458. set(e, t, i, r = this._order) {
  5459. return (this._x = e), (this._y = t), (this._z = i), (this._order = r), this._onChangeCallback(), this;
  5460. }
  5461. clone() {
  5462. return new this.constructor(this._x, this._y, this._z, this._order);
  5463. }
  5464. copy(e) {
  5465. return (this._x = e._x), (this._y = e._y), (this._z = e._z), (this._order = e._order), this._onChangeCallback(), this;
  5466. }
  5467. setFromRotationMatrix(e, t = this._order, i = !0) {
  5468. let r = e.elements,
  5469. s = r[0],
  5470. n = r[4],
  5471. a = r[8],
  5472. o = r[1],
  5473. l = r[5],
  5474. h = r[9],
  5475. u = r[2],
  5476. c = r[6],
  5477. d = r[10];
  5478. switch (t) {
  5479. case 'XYZ':
  5480. (this._y = Math.asin(ti(a, -1, 1))),
  5481. Math.abs(a) < 0.9999999
  5482. ? ((this._x = Math.atan2(-h, d)), (this._z = Math.atan2(-n, s)))
  5483. : ((this._x = Math.atan2(c, l)), (this._z = 0));
  5484. break;
  5485. case 'YXZ':
  5486. (this._x = Math.asin(-ti(h, -1, 1))),
  5487. Math.abs(h) < 0.9999999
  5488. ? ((this._y = Math.atan2(a, d)), (this._z = Math.atan2(o, l)))
  5489. : ((this._y = Math.atan2(-u, s)), (this._z = 0));
  5490. break;
  5491. case 'ZXY':
  5492. (this._x = Math.asin(ti(c, -1, 1))),
  5493. Math.abs(c) < 0.9999999
  5494. ? ((this._y = Math.atan2(-u, d)), (this._z = Math.atan2(-n, l)))
  5495. : ((this._y = 0), (this._z = Math.atan2(o, s)));
  5496. break;
  5497. case 'ZYX':
  5498. (this._y = Math.asin(-ti(u, -1, 1))),
  5499. Math.abs(u) < 0.9999999
  5500. ? ((this._x = Math.atan2(c, d)), (this._z = Math.atan2(o, s)))
  5501. : ((this._x = 0), (this._z = Math.atan2(-n, l)));
  5502. break;
  5503. case 'YZX':
  5504. (this._z = Math.asin(ti(o, -1, 1))),
  5505. Math.abs(o) < 0.9999999
  5506. ? ((this._x = Math.atan2(-h, l)), (this._y = Math.atan2(-u, s)))
  5507. : ((this._x = 0), (this._y = Math.atan2(a, d)));
  5508. break;
  5509. case 'XZY':
  5510. (this._z = Math.asin(-ti(n, -1, 1))),
  5511. Math.abs(n) < 0.9999999
  5512. ? ((this._x = Math.atan2(c, l)), (this._y = Math.atan2(a, s)))
  5513. : ((this._x = Math.atan2(-h, d)), (this._y = 0));
  5514. break;
  5515. default:
  5516. console.warn('THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + t);
  5517. }
  5518. return (this._order = t), i === !0 && this._onChangeCallback(), this;
  5519. }
  5520. setFromQuaternion(e, t, i) {
  5521. return R0.makeRotationFromQuaternion(e), this.setFromRotationMatrix(R0, t, i);
  5522. }
  5523. setFromVector3(e, t = this._order) {
  5524. return this.set(e.x, e.y, e.z, t);
  5525. }
  5526. reorder(e) {
  5527. return B0.setFromEuler(this), this.setFromQuaternion(B0, e);
  5528. }
  5529. equals(e) {
  5530. return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order;
  5531. }
  5532. fromArray(e) {
  5533. return (this._x = e[0]), (this._y = e[1]), (this._z = e[2]), e[3] !== void 0 && (this._order = e[3]), this._onChangeCallback(), this;
  5534. }
  5535. toArray(e = [], t = 0) {
  5536. return (e[t] = this._x), (e[t + 1] = this._y), (e[t + 2] = this._z), (e[t + 3] = this._order), e;
  5537. }
  5538. _onChange(e) {
  5539. return (this._onChangeCallback = e), this;
  5540. }
  5541. _onChangeCallback() {}
  5542. *[Symbol.iterator]() {
  5543. yield this._x, yield this._y, yield this._z, yield this._order;
  5544. }
  5545. };
  5546. _i.DEFAULT_ORDER = 'XYZ';
  5547. var hg = class {
  5548. constructor() {
  5549. this.mask = 1;
  5550. }
  5551. set(e) {
  5552. this.mask = ((1 << e) | 0) >>> 0;
  5553. }
  5554. enable(e) {
  5555. this.mask |= (1 << e) | 0;
  5556. }
  5557. enableAll() {
  5558. this.mask = -1;
  5559. }
  5560. toggle(e) {
  5561. this.mask ^= (1 << e) | 0;
  5562. }
  5563. disable(e) {
  5564. this.mask &= ~((1 << e) | 0);
  5565. }
  5566. disableAll() {
  5567. this.mask = 0;
  5568. }
  5569. test(e) {
  5570. return (this.mask & e.mask) !== 0;
  5571. }
  5572. isEnabled(e) {
  5573. return (this.mask & ((1 << e) | 0)) !== 0;
  5574. }
  5575. },
  5576. oE = 0,
  5577. z0 = new E(),
  5578. Fa = new ct(),
  5579. Ps = new ve(),
  5580. $h = new E(),
  5581. pl = new E(),
  5582. lE = new E(),
  5583. hE = new ct(),
  5584. N0 = new E(1, 0, 0),
  5585. U0 = new E(0, 1, 0),
  5586. F0 = new E(0, 0, 1),
  5587. cE = { type: 'added' },
  5588. k0 = { type: 'removed' },
  5589. bt = class extends Vi {
  5590. constructor() {
  5591. super(),
  5592. (this.isObject3D = !0),
  5593. Object.defineProperty(this, 'id', { value: oE++ }),
  5594. (this.uuid = ps()),
  5595. (this.name = ''),
  5596. (this.type = 'Object3D'),
  5597. (this.parent = null),
  5598. (this.children = []),
  5599. (this.up = bt.DEFAULT_UP.clone());
  5600. let e = new E(),
  5601. t = new _i(),
  5602. i = new ct(),
  5603. r = new E(1, 1, 1);
  5604. function s() {
  5605. i.setFromEuler(t, !1);
  5606. }
  5607. function n() {
  5608. t.setFromQuaternion(i, void 0, !1);
  5609. }
  5610. t._onChange(s),
  5611. i._onChange(n),
  5612. Object.defineProperties(this, {
  5613. position: { configurable: !0, enumerable: !0, value: e },
  5614. rotation: { configurable: !0, enumerable: !0, value: t },
  5615. quaternion: { configurable: !0, enumerable: !0, value: i },
  5616. scale: { configurable: !0, enumerable: !0, value: r },
  5617. modelViewMatrix: { value: new ve() },
  5618. normalMatrix: { value: new Ai() }
  5619. }),
  5620. (this.matrix = new ve()),
  5621. (this.matrixWorld = new ve()),
  5622. (this.matrixAutoUpdate = bt.DEFAULT_MATRIX_AUTO_UPDATE),
  5623. (this.matrixWorldNeedsUpdate = !1),
  5624. (this.matrixWorldAutoUpdate = bt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE),
  5625. (this.layers = new hg()),
  5626. (this.visible = !0),
  5627. (this.castShadow = !1),
  5628. (this.receiveShadow = !1),
  5629. (this.frustumCulled = !0),
  5630. (this.renderOrder = 0),
  5631. (this.animations = []),
  5632. (this.userData = {});
  5633. }
  5634. onBeforeRender() {}
  5635. onAfterRender() {}
  5636. applyMatrix4(e) {
  5637. this.matrixAutoUpdate && this.updateMatrix(),
  5638. this.matrix.premultiply(e),
  5639. this.matrix.decompose(this.position, this.quaternion, this.scale);
  5640. }
  5641. applyQuaternion(e) {
  5642. return this.quaternion.premultiply(e), this;
  5643. }
  5644. setRotationFromAxisAngle(e, t) {
  5645. this.quaternion.setFromAxisAngle(e, t);
  5646. }
  5647. setRotationFromEuler(e) {
  5648. this.quaternion.setFromEuler(e, !0);
  5649. }
  5650. setRotationFromMatrix(e) {
  5651. this.quaternion.setFromRotationMatrix(e);
  5652. }
  5653. setRotationFromQuaternion(e) {
  5654. this.quaternion.copy(e);
  5655. }
  5656. rotateOnAxis(e, t) {
  5657. return Fa.setFromAxisAngle(e, t), this.quaternion.multiply(Fa), this;
  5658. }
  5659. rotateOnWorldAxis(e, t) {
  5660. return Fa.setFromAxisAngle(e, t), this.quaternion.premultiply(Fa), this;
  5661. }
  5662. rotateX(e) {
  5663. return this.rotateOnAxis(N0, e);
  5664. }
  5665. rotateY(e) {
  5666. return this.rotateOnAxis(U0, e);
  5667. }
  5668. rotateZ(e) {
  5669. return this.rotateOnAxis(F0, e);
  5670. }
  5671. translateOnAxis(e, t) {
  5672. return z0.copy(e).applyQuaternion(this.quaternion), this.position.add(z0.multiplyScalar(t)), this;
  5673. }
  5674. translateX(e) {
  5675. return this.translateOnAxis(N0, e);
  5676. }
  5677. translateY(e) {
  5678. return this.translateOnAxis(U0, e);
  5679. }
  5680. translateZ(e) {
  5681. return this.translateOnAxis(F0, e);
  5682. }
  5683. localToWorld(e) {
  5684. return this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld);
  5685. }
  5686. worldToLocal(e) {
  5687. return this.updateWorldMatrix(!0, !1), e.applyMatrix4(Ps.copy(this.matrixWorld).invert());
  5688. }
  5689. lookAt(e, t, i) {
  5690. e.isVector3 ? $h.copy(e) : $h.set(e, t, i);
  5691. let r = this.parent;
  5692. this.updateWorldMatrix(!0, !1),
  5693. pl.setFromMatrixPosition(this.matrixWorld),
  5694. this.isCamera || this.isLight ? Ps.lookAt(pl, $h, this.up) : Ps.lookAt($h, pl, this.up),
  5695. this.quaternion.setFromRotationMatrix(Ps),
  5696. r && (Ps.extractRotation(r.matrixWorld), Fa.setFromRotationMatrix(Ps), this.quaternion.premultiply(Fa.invert()));
  5697. }
  5698. add(e) {
  5699. if (arguments.length > 1) {
  5700. for (let t = 0; t < arguments.length; t++) this.add(arguments[t]);
  5701. return this;
  5702. }
  5703. return e === this
  5704. ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", e), this)
  5705. : (e && e.isObject3D
  5706. ? (e.parent !== null && e.parent.remove(e), (e.parent = this), this.children.push(e), e.dispatchEvent(cE))
  5707. : console.error('THREE.Object3D.add: object not an instance of THREE.Object3D.', e),
  5708. this);
  5709. }
  5710. remove(e) {
  5711. if (arguments.length > 1) {
  5712. for (let i = 0; i < arguments.length; i++) this.remove(arguments[i]);
  5713. return this;
  5714. }
  5715. let t = this.children.indexOf(e);
  5716. return t !== -1 && ((e.parent = null), this.children.splice(t, 1), e.dispatchEvent(k0)), this;
  5717. }
  5718. removeFromParent() {
  5719. let e = this.parent;
  5720. return e !== null && e.remove(this), this;
  5721. }
  5722. clear() {
  5723. for (let e = 0; e < this.children.length; e++) {
  5724. let t = this.children[e];
  5725. (t.parent = null), t.dispatchEvent(k0);
  5726. }
  5727. return (this.children.length = 0), this;
  5728. }
  5729. attach(e) {
  5730. return (
  5731. this.updateWorldMatrix(!0, !1),
  5732. Ps.copy(this.matrixWorld).invert(),
  5733. e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), Ps.multiply(e.parent.matrixWorld)),
  5734. e.applyMatrix4(Ps),
  5735. this.add(e),
  5736. e.updateWorldMatrix(!1, !0),
  5737. this
  5738. );
  5739. }
  5740. getObjectById(e) {
  5741. return this.getObjectByProperty('id', e);
  5742. }
  5743. getObjectByName(e) {
  5744. return this.getObjectByProperty('name', e);
  5745. }
  5746. getObjectByProperty(e, t) {
  5747. if (this[e] === t) return this;
  5748. for (let i = 0, r = this.children.length; i < r; i++) {
  5749. let s = this.children[i].getObjectByProperty(e, t);
  5750. if (s !== void 0) return s;
  5751. }
  5752. }
  5753. getObjectsByProperty(e, t) {
  5754. let i = [];
  5755. this[e] === t && i.push(this);
  5756. for (let r = 0, s = this.children.length; r < s; r++) {
  5757. let n = this.children[r].getObjectsByProperty(e, t);
  5758. n.length > 0 && (i = i.concat(n));
  5759. }
  5760. return i;
  5761. }
  5762. getWorldPosition(e) {
  5763. return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld);
  5764. }
  5765. getWorldQuaternion(e) {
  5766. return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(pl, e, lE), e;
  5767. }
  5768. getWorldScale(e) {
  5769. return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(pl, hE, e), e;
  5770. }
  5771. getWorldDirection(e) {
  5772. this.updateWorldMatrix(!0, !1);
  5773. let t = this.matrixWorld.elements;
  5774. return e.set(t[8], t[9], t[10]).normalize();
  5775. }
  5776. raycast() {}
  5777. traverse(e) {
  5778. e(this);
  5779. let t = this.children;
  5780. for (let i = 0, r = t.length; i < r; i++) t[i].traverse(e);
  5781. }
  5782. traverseVisible(e) {
  5783. if (this.visible === !1) return;
  5784. e(this);
  5785. let t = this.children;
  5786. for (let i = 0, r = t.length; i < r; i++) t[i].traverseVisible(e);
  5787. }
  5788. traverseAncestors(e) {
  5789. let t = this.parent;
  5790. t !== null && (e(t), t.traverseAncestors(e));
  5791. }
  5792. updateMatrix() {
  5793. this.matrix.compose(this.position, this.quaternion, this.scale), (this.matrixWorldNeedsUpdate = !0);
  5794. }
  5795. updateMatrixWorld(e) {
  5796. this.matrixAutoUpdate && this.updateMatrix(),
  5797. (this.matrixWorldNeedsUpdate || e) &&
  5798. (this.parent === null
  5799. ? this.matrixWorld.copy(this.matrix)
  5800. : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix),
  5801. (this.matrixWorldNeedsUpdate = !1),
  5802. (e = !0));
  5803. let t = this.children;
  5804. for (let i = 0, r = t.length; i < r; i++) {
  5805. let s = t[i];
  5806. (s.matrixWorldAutoUpdate === !0 || e === !0) && s.updateMatrixWorld(e);
  5807. }
  5808. }
  5809. updateWorldMatrix(e, t) {
  5810. let i = this.parent;
  5811. if (
  5812. (e === !0 && i !== null && i.matrixWorldAutoUpdate === !0 && i.updateWorldMatrix(!0, !1),
  5813. this.matrixAutoUpdate && this.updateMatrix(),
  5814. this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix),
  5815. t === !0)
  5816. ) {
  5817. let r = this.children;
  5818. for (let s = 0, n = r.length; s < n; s++) {
  5819. let a = r[s];
  5820. a.matrixWorldAutoUpdate === !0 && a.updateWorldMatrix(!1, !0);
  5821. }
  5822. }
  5823. }
  5824. toJSON(e) {
  5825. let t = e === void 0 || typeof e == 'string',
  5826. i = {};
  5827. t &&
  5828. ((e = { geometries: {}, materials: {}, textures: {}, images: {}, shapes: {}, skeletons: {}, animations: {}, nodes: {} }),
  5829. (i.metadata = { version: 4.5, type: 'Object', generator: 'Object3D.toJSON' }));
  5830. let r = {};
  5831. (r.uuid = this.uuid),
  5832. (r.type = this.type),
  5833. this.name !== '' && (r.name = this.name),
  5834. this.castShadow === !0 && (r.castShadow = !0),
  5835. this.receiveShadow === !0 && (r.receiveShadow = !0),
  5836. this.visible === !1 && (r.visible = !1),
  5837. this.frustumCulled === !1 && (r.frustumCulled = !1),
  5838. this.renderOrder !== 0 && (r.renderOrder = this.renderOrder),
  5839. Object.keys(this.userData).length > 0 && (r.userData = this.userData),
  5840. (r.layers = this.layers.mask),
  5841. (r.matrix = this.matrix.toArray()),
  5842. this.matrixAutoUpdate === !1 && (r.matrixAutoUpdate = !1),
  5843. this.isInstancedMesh &&
  5844. ((r.type = 'InstancedMesh'),
  5845. (r.count = this.count),
  5846. (r.instanceMatrix = this.instanceMatrix.toJSON()),
  5847. this.instanceColor !== null && (r.instanceColor = this.instanceColor.toJSON()));
  5848. function s(a, o) {
  5849. return a[o.uuid] === void 0 && (a[o.uuid] = o.toJSON(e)), o.uuid;
  5850. }
  5851. if (this.isScene)
  5852. this.background &&
  5853. (this.background.isColor
  5854. ? (r.background = this.background.toJSON())
  5855. : this.background.isTexture && (r.background = this.background.toJSON(e).uuid)),
  5856. this.environment &&
  5857. this.environment.isTexture &&
  5858. this.environment.isRenderTargetTexture !== !0 &&
  5859. (r.environment = this.environment.toJSON(e).uuid);
  5860. else if (this.isMesh || this.isLine || this.isPoints) {
  5861. r.geometry = s(e.geometries, this.geometry);
  5862. let a = this.geometry.parameters;
  5863. if (a !== void 0 && a.shapes !== void 0) {
  5864. let o = a.shapes;
  5865. if (Array.isArray(o))
  5866. for (let l = 0, h = o.length; l < h; l++) {
  5867. let u = o[l];
  5868. s(e.shapes, u);
  5869. }
  5870. else s(e.shapes, o);
  5871. }
  5872. }
  5873. if (
  5874. (this.isSkinnedMesh &&
  5875. ((r.bindMode = this.bindMode),
  5876. (r.bindMatrix = this.bindMatrix.toArray()),
  5877. this.skeleton !== void 0 && (s(e.skeletons, this.skeleton), (r.skeleton = this.skeleton.uuid))),
  5878. this.material !== void 0)
  5879. )
  5880. if (Array.isArray(this.material)) {
  5881. let a = [];
  5882. for (let o = 0, l = this.material.length; o < l; o++) a.push(s(e.materials, this.material[o]));
  5883. r.material = a;
  5884. } else r.material = s(e.materials, this.material);
  5885. if (this.children.length > 0) {
  5886. r.children = [];
  5887. for (let a = 0; a < this.children.length; a++) r.children.push(this.children[a].toJSON(e).object);
  5888. }
  5889. if (this.animations.length > 0) {
  5890. r.animations = [];
  5891. for (let a = 0; a < this.animations.length; a++) {
  5892. let o = this.animations[a];
  5893. r.animations.push(s(e.animations, o));
  5894. }
  5895. }
  5896. if (t) {
  5897. let a = n(e.geometries),
  5898. o = n(e.materials),
  5899. l = n(e.textures),
  5900. h = n(e.images),
  5901. u = n(e.shapes),
  5902. c = n(e.skeletons),
  5903. d = n(e.animations),
  5904. p = n(e.nodes);
  5905. a.length > 0 && (i.geometries = a),
  5906. o.length > 0 && (i.materials = o),
  5907. l.length > 0 && (i.textures = l),
  5908. h.length > 0 && (i.images = h),
  5909. u.length > 0 && (i.shapes = u),
  5910. c.length > 0 && (i.skeletons = c),
  5911. d.length > 0 && (i.animations = d),
  5912. p.length > 0 && (i.nodes = p);
  5913. }
  5914. return (i.object = r), i;
  5915. function n(a) {
  5916. let o = [];
  5917. for (let l in a) {
  5918. let h = a[l];
  5919. delete h.metadata, o.push(h);
  5920. }
  5921. return o;
  5922. }
  5923. }
  5924. clone(e) {
  5925. return new this.constructor().copy(this, e);
  5926. }
  5927. copy(e, t = !0) {
  5928. if (
  5929. ((this.name = e.name),
  5930. this.up.copy(e.up),
  5931. this.position.copy(e.position),
  5932. (this.rotation.order = e.rotation.order),
  5933. this.quaternion.copy(e.quaternion),
  5934. this.scale.copy(e.scale),
  5935. this.matrix.copy(e.matrix),
  5936. this.matrixWorld.copy(e.matrixWorld),
  5937. (this.matrixAutoUpdate = e.matrixAutoUpdate),
  5938. (this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate),
  5939. (this.matrixWorldAutoUpdate = e.matrixWorldAutoUpdate),
  5940. (this.layers.mask = e.layers.mask),
  5941. (this.visible = e.visible),
  5942. (this.castShadow = e.castShadow),
  5943. (this.receiveShadow = e.receiveShadow),
  5944. (this.frustumCulled = e.frustumCulled),
  5945. (this.renderOrder = e.renderOrder),
  5946. (this.userData = JSON.parse(JSON.stringify(e.userData))),
  5947. t === !0)
  5948. )
  5949. for (let i = 0; i < e.children.length; i++) {
  5950. let r = e.children[i];
  5951. this.add(r.clone());
  5952. }
  5953. return this;
  5954. }
  5955. };
  5956. bt.DEFAULT_UP = new E(0, 1, 0);
  5957. bt.DEFAULT_MATRIX_AUTO_UPDATE = !0;
  5958. bt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
  5959. var Or = new E(),
  5960. Ds = new E(),
  5961. cp = new E(),
  5962. Ls = new E(),
  5963. ka = new E(),
  5964. ja = new E(),
  5965. j0 = new E(),
  5966. dp = new E(),
  5967. up = new E(),
  5968. pp = new E(),
  5969. Bi = class {
  5970. constructor(e = new E(), t = new E(), i = new E()) {
  5971. (this.a = e), (this.b = t), (this.c = i);
  5972. }
  5973. static getNormal(e, t, i, r) {
  5974. r.subVectors(i, t), Or.subVectors(e, t), r.cross(Or);
  5975. let s = r.lengthSq();
  5976. return s > 0 ? r.multiplyScalar(1 / Math.sqrt(s)) : r.set(0, 0, 0);
  5977. }
  5978. static getBarycoord(e, t, i, r, s) {
  5979. Or.subVectors(r, t), Ds.subVectors(i, t), cp.subVectors(e, t);
  5980. let n = Or.dot(Or),
  5981. a = Or.dot(Ds),
  5982. o = Or.dot(cp),
  5983. l = Ds.dot(Ds),
  5984. h = Ds.dot(cp),
  5985. u = n * l - a * a;
  5986. if (u === 0) return s.set(-2, -1, -1);
  5987. let c = 1 / u,
  5988. d = (l * o - a * h) * c,
  5989. p = (n * h - a * o) * c;
  5990. return s.set(1 - d - p, p, d);
  5991. }
  5992. static containsPoint(e, t, i, r) {
  5993. return this.getBarycoord(e, t, i, r, Ls), Ls.x >= 0 && Ls.y >= 0 && Ls.x + Ls.y <= 1;
  5994. }
  5995. static getUV(e, t, i, r, s, n, a, o) {
  5996. return (
  5997. this.getBarycoord(e, t, i, r, Ls),
  5998. o.set(0, 0),
  5999. o.addScaledVector(s, Ls.x),
  6000. o.addScaledVector(n, Ls.y),
  6001. o.addScaledVector(a, Ls.z),
  6002. o
  6003. );
  6004. }
  6005. static isFrontFacing(e, t, i, r) {
  6006. return Or.subVectors(i, t), Ds.subVectors(e, t), Or.cross(Ds).dot(r) < 0;
  6007. }
  6008. set(e, t, i) {
  6009. return this.a.copy(e), this.b.copy(t), this.c.copy(i), this;
  6010. }
  6011. setFromPointsAndIndices(e, t, i, r) {
  6012. return this.a.copy(e[t]), this.b.copy(e[i]), this.c.copy(e[r]), this;
  6013. }
  6014. setFromAttributeAndIndices(e, t, i, r) {
  6015. return this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, i), this.c.fromBufferAttribute(e, r), this;
  6016. }
  6017. clone() {
  6018. return new this.constructor().copy(this);
  6019. }
  6020. copy(e) {
  6021. return this.a.copy(e.a), this.b.copy(e.b), this.c.copy(e.c), this;
  6022. }
  6023. getArea() {
  6024. return Or.subVectors(this.c, this.b), Ds.subVectors(this.a, this.b), Or.cross(Ds).length() * 0.5;
  6025. }
  6026. getMidpoint(e) {
  6027. return e
  6028. .addVectors(this.a, this.b)
  6029. .add(this.c)
  6030. .multiplyScalar(1 / 3);
  6031. }
  6032. getNormal(e) {
  6033. return Bi.getNormal(this.a, this.b, this.c, e);
  6034. }
  6035. getPlane(e) {
  6036. return e.setFromCoplanarPoints(this.a, this.b, this.c);
  6037. }
  6038. getBarycoord(e, t) {
  6039. return Bi.getBarycoord(e, this.a, this.b, this.c, t);
  6040. }
  6041. getUV(e, t, i, r, s) {
  6042. return Bi.getUV(e, this.a, this.b, this.c, t, i, r, s);
  6043. }
  6044. containsPoint(e) {
  6045. return Bi.containsPoint(e, this.a, this.b, this.c);
  6046. }
  6047. isFrontFacing(e) {
  6048. return Bi.isFrontFacing(this.a, this.b, this.c, e);
  6049. }
  6050. intersectsBox(e) {
  6051. return e.intersectsTriangle(this);
  6052. }
  6053. closestPointToPoint(e, t) {
  6054. let i = this.a,
  6055. r = this.b,
  6056. s = this.c,
  6057. n,
  6058. a;
  6059. ka.subVectors(r, i), ja.subVectors(s, i), dp.subVectors(e, i);
  6060. let o = ka.dot(dp),
  6061. l = ja.dot(dp);
  6062. if (o <= 0 && l <= 0) return t.copy(i);
  6063. up.subVectors(e, r);
  6064. let h = ka.dot(up),
  6065. u = ja.dot(up);
  6066. if (h >= 0 && u <= h) return t.copy(r);
  6067. let c = o * u - h * l;
  6068. if (c <= 0 && o >= 0 && h <= 0) return (n = o / (o - h)), t.copy(i).addScaledVector(ka, n);
  6069. pp.subVectors(e, s);
  6070. let d = ka.dot(pp),
  6071. p = ja.dot(pp);
  6072. if (p >= 0 && d <= p) return t.copy(s);
  6073. let f = d * l - o * p;
  6074. if (f <= 0 && l >= 0 && p <= 0) return (a = l / (l - p)), t.copy(i).addScaledVector(ja, a);
  6075. let g = h * p - d * u;
  6076. if (g <= 0 && u - h >= 0 && d - p >= 0)
  6077. return j0.subVectors(s, r), (a = (u - h) / (u - h + (d - p))), t.copy(r).addScaledVector(j0, a);
  6078. let m = 1 / (g + f + c);
  6079. return (n = f * m), (a = c * m), t.copy(i).addScaledVector(ka, n).addScaledVector(ja, a);
  6080. }
  6081. equals(e) {
  6082. return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c);
  6083. }
  6084. },
  6085. dE = 0,
  6086. Th = class extends Vi {
  6087. constructor() {
  6088. super(),
  6089. (this.isMaterial = !0),
  6090. Object.defineProperty(this, 'id', { value: dE++ }),
  6091. (this.uuid = ps()),
  6092. (this.name = ''),
  6093. (this.type = 'Material'),
  6094. (this.blending = Ao),
  6095. (this.side = Vr),
  6096. (this.vertexColors = !1),
  6097. (this.opacity = 1),
  6098. (this.transparent = !1),
  6099. (this.blendSrc = nw),
  6100. (this.blendDst = aw),
  6101. (this.blendEquation = no),
  6102. (this.blendSrcAlpha = null),
  6103. (this.blendDstAlpha = null),
  6104. (this.blendEquationAlpha = null),
  6105. (this.depthFunc = Bf),
  6106. (this.depthTest = !0),
  6107. (this.depthWrite = !0),
  6108. (this.stencilWriteMask = 255),
  6109. (this.stencilFunc = kM),
  6110. (this.stencilRef = 0),
  6111. (this.stencilFuncMask = 255),
  6112. (this.stencilFail = Ju),
  6113. (this.stencilZFail = Ju),
  6114. (this.stencilZPass = Ju),
  6115. (this.stencilWrite = !1),
  6116. (this.clippingPlanes = null),
  6117. (this.clipIntersection = !1),
  6118. (this.clipShadows = !1),
  6119. (this.shadowSide = null),
  6120. (this.colorWrite = !0),
  6121. (this.precision = null),
  6122. (this.polygonOffset = !1),
  6123. (this.polygonOffsetFactor = 0),
  6124. (this.polygonOffsetUnits = 0),
  6125. (this.dithering = !1),
  6126. (this.alphaToCoverage = !1),
  6127. (this.premultipliedAlpha = !1),
  6128. (this.forceSinglePass = !1),
  6129. (this.visible = !0),
  6130. (this.toneMapped = !0),
  6131. (this.userData = {}),
  6132. (this.version = 0),
  6133. (this._alphaTest = 0);
  6134. }
  6135. get alphaTest() {
  6136. return this._alphaTest;
  6137. }
  6138. set alphaTest(e) {
  6139. this._alphaTest > 0 != e > 0 && this.version++, (this._alphaTest = e);
  6140. }
  6141. onBuild() {}
  6142. onBeforeRender() {}
  6143. onBeforeCompile() {}
  6144. customProgramCacheKey() {
  6145. return this.onBeforeCompile.toString();
  6146. }
  6147. setValues(e) {
  6148. if (e !== void 0)
  6149. for (let t in e) {
  6150. let i = e[t];
  6151. if (i === void 0) {
  6152. console.warn("THREE.Material: '" + t + "' parameter is undefined.");
  6153. continue;
  6154. }
  6155. let r = this[t];
  6156. if (r === void 0) {
  6157. console.warn('THREE.' + this.type + ": '" + t + "' is not a property of this material.");
  6158. continue;
  6159. }
  6160. r && r.isColor ? r.set(i) : r && r.isVector3 && i && i.isVector3 ? r.copy(i) : (this[t] = i);
  6161. }
  6162. }
  6163. toJSON(e) {
  6164. let t = e === void 0 || typeof e == 'string';
  6165. t && (e = { textures: {}, images: {} });
  6166. let i = { metadata: { version: 4.5, type: 'Material', generator: 'Material.toJSON' } };
  6167. (i.uuid = this.uuid),
  6168. (i.type = this.type),
  6169. this.name !== '' && (i.name = this.name),
  6170. this.color && this.color.isColor && (i.color = this.color.getHex()),
  6171. this.roughness !== void 0 && (i.roughness = this.roughness),
  6172. this.metalness !== void 0 && (i.metalness = this.metalness),
  6173. this.sheen !== void 0 && (i.sheen = this.sheen),
  6174. this.sheenColor && this.sheenColor.isColor && (i.sheenColor = this.sheenColor.getHex()),
  6175. this.sheenRoughness !== void 0 && (i.sheenRoughness = this.sheenRoughness),
  6176. this.emissive && this.emissive.isColor && (i.emissive = this.emissive.getHex()),
  6177. this.emissiveIntensity && this.emissiveIntensity !== 1 && (i.emissiveIntensity = this.emissiveIntensity),
  6178. this.specular && this.specular.isColor && (i.specular = this.specular.getHex()),
  6179. this.specularIntensity !== void 0 && (i.specularIntensity = this.specularIntensity),
  6180. this.specularColor && this.specularColor.isColor && (i.specularColor = this.specularColor.getHex()),
  6181. this.shininess !== void 0 && (i.shininess = this.shininess),
  6182. this.clearcoat !== void 0 && (i.clearcoat = this.clearcoat),
  6183. this.clearcoatRoughness !== void 0 && (i.clearcoatRoughness = this.clearcoatRoughness),
  6184. this.clearcoatMap && this.clearcoatMap.isTexture && (i.clearcoatMap = this.clearcoatMap.toJSON(e).uuid),
  6185. this.clearcoatRoughnessMap &&
  6186. this.clearcoatRoughnessMap.isTexture &&
  6187. (i.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid),
  6188. this.clearcoatNormalMap &&
  6189. this.clearcoatNormalMap.isTexture &&
  6190. ((i.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid), (i.clearcoatNormalScale = this.clearcoatNormalScale.toArray())),
  6191. this.iridescence !== void 0 && (i.iridescence = this.iridescence),
  6192. this.iridescenceIOR !== void 0 && (i.iridescenceIOR = this.iridescenceIOR),
  6193. this.iridescenceThicknessRange !== void 0 && (i.iridescenceThicknessRange = this.iridescenceThicknessRange),
  6194. this.iridescenceMap && this.iridescenceMap.isTexture && (i.iridescenceMap = this.iridescenceMap.toJSON(e).uuid),
  6195. this.iridescenceThicknessMap &&
  6196. this.iridescenceThicknessMap.isTexture &&
  6197. (i.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(e).uuid),
  6198. this.map && this.map.isTexture && (i.map = this.map.toJSON(e).uuid),
  6199. this.matcap && this.matcap.isTexture && (i.matcap = this.matcap.toJSON(e).uuid),
  6200. this.alphaMap && this.alphaMap.isTexture && (i.alphaMap = this.alphaMap.toJSON(e).uuid),
  6201. this.lightMap &&
  6202. this.lightMap.isTexture &&
  6203. ((i.lightMap = this.lightMap.toJSON(e).uuid), (i.lightMapIntensity = this.lightMapIntensity)),
  6204. this.aoMap && this.aoMap.isTexture && ((i.aoMap = this.aoMap.toJSON(e).uuid), (i.aoMapIntensity = this.aoMapIntensity)),
  6205. this.bumpMap && this.bumpMap.isTexture && ((i.bumpMap = this.bumpMap.toJSON(e).uuid), (i.bumpScale = this.bumpScale)),
  6206. this.normalMap &&
  6207. this.normalMap.isTexture &&
  6208. ((i.normalMap = this.normalMap.toJSON(e).uuid),
  6209. (i.normalMapType = this.normalMapType),
  6210. (i.normalScale = this.normalScale.toArray())),
  6211. this.displacementMap &&
  6212. this.displacementMap.isTexture &&
  6213. ((i.displacementMap = this.displacementMap.toJSON(e).uuid),
  6214. (i.displacementScale = this.displacementScale),
  6215. (i.displacementBias = this.displacementBias)),
  6216. this.roughnessMap && this.roughnessMap.isTexture && (i.roughnessMap = this.roughnessMap.toJSON(e).uuid),
  6217. this.metalnessMap && this.metalnessMap.isTexture && (i.metalnessMap = this.metalnessMap.toJSON(e).uuid),
  6218. this.emissiveMap && this.emissiveMap.isTexture && (i.emissiveMap = this.emissiveMap.toJSON(e).uuid),
  6219. this.specularMap && this.specularMap.isTexture && (i.specularMap = this.specularMap.toJSON(e).uuid),
  6220. this.specularIntensityMap &&
  6221. this.specularIntensityMap.isTexture &&
  6222. (i.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid),
  6223. this.specularColorMap && this.specularColorMap.isTexture && (i.specularColorMap = this.specularColorMap.toJSON(e).uuid),
  6224. this.envMap &&
  6225. this.envMap.isTexture &&
  6226. ((i.envMap = this.envMap.toJSON(e).uuid), this.combine !== void 0 && (i.combine = this.combine)),
  6227. this.envMapIntensity !== void 0 && (i.envMapIntensity = this.envMapIntensity),
  6228. this.reflectivity !== void 0 && (i.reflectivity = this.reflectivity),
  6229. this.refractionRatio !== void 0 && (i.refractionRatio = this.refractionRatio),
  6230. this.gradientMap && this.gradientMap.isTexture && (i.gradientMap = this.gradientMap.toJSON(e).uuid),
  6231. this.transmission !== void 0 && (i.transmission = this.transmission),
  6232. this.transmissionMap && this.transmissionMap.isTexture && (i.transmissionMap = this.transmissionMap.toJSON(e).uuid),
  6233. this.thickness !== void 0 && (i.thickness = this.thickness),
  6234. this.thicknessMap && this.thicknessMap.isTexture && (i.thicknessMap = this.thicknessMap.toJSON(e).uuid),
  6235. this.attenuationDistance !== void 0 && this.attenuationDistance !== 1 / 0 && (i.attenuationDistance = this.attenuationDistance),
  6236. this.attenuationColor !== void 0 && (i.attenuationColor = this.attenuationColor.getHex()),
  6237. this.size !== void 0 && (i.size = this.size),
  6238. this.shadowSide !== null && (i.shadowSide = this.shadowSide),
  6239. this.sizeAttenuation !== void 0 && (i.sizeAttenuation = this.sizeAttenuation),
  6240. this.blending !== Ao && (i.blending = this.blending),
  6241. this.side !== Vr && (i.side = this.side),
  6242. this.vertexColors && (i.vertexColors = !0),
  6243. this.opacity < 1 && (i.opacity = this.opacity),
  6244. this.transparent === !0 && (i.transparent = this.transparent),
  6245. (i.depthFunc = this.depthFunc),
  6246. (i.depthTest = this.depthTest),
  6247. (i.depthWrite = this.depthWrite),
  6248. (i.colorWrite = this.colorWrite),
  6249. (i.stencilWrite = this.stencilWrite),
  6250. (i.stencilWriteMask = this.stencilWriteMask),
  6251. (i.stencilFunc = this.stencilFunc),
  6252. (i.stencilRef = this.stencilRef),
  6253. (i.stencilFuncMask = this.stencilFuncMask),
  6254. (i.stencilFail = this.stencilFail),
  6255. (i.stencilZFail = this.stencilZFail),
  6256. (i.stencilZPass = this.stencilZPass),
  6257. this.rotation !== void 0 && this.rotation !== 0 && (i.rotation = this.rotation),
  6258. this.polygonOffset === !0 && (i.polygonOffset = !0),
  6259. this.polygonOffsetFactor !== 0 && (i.polygonOffsetFactor = this.polygonOffsetFactor),
  6260. this.polygonOffsetUnits !== 0 && (i.polygonOffsetUnits = this.polygonOffsetUnits),
  6261. this.linewidth !== void 0 && this.linewidth !== 1 && (i.linewidth = this.linewidth),
  6262. this.dashSize !== void 0 && (i.dashSize = this.dashSize),
  6263. this.gapSize !== void 0 && (i.gapSize = this.gapSize),
  6264. this.scale !== void 0 && (i.scale = this.scale),
  6265. this.dithering === !0 && (i.dithering = !0),
  6266. this.alphaTest > 0 && (i.alphaTest = this.alphaTest),
  6267. this.alphaToCoverage === !0 && (i.alphaToCoverage = this.alphaToCoverage),
  6268. this.premultipliedAlpha === !0 && (i.premultipliedAlpha = this.premultipliedAlpha),
  6269. this.forceSinglePass === !0 && (i.forceSinglePass = this.forceSinglePass),
  6270. this.wireframe === !0 && (i.wireframe = this.wireframe),
  6271. this.wireframeLinewidth > 1 && (i.wireframeLinewidth = this.wireframeLinewidth),
  6272. this.wireframeLinecap !== 'round' && (i.wireframeLinecap = this.wireframeLinecap),
  6273. this.wireframeLinejoin !== 'round' && (i.wireframeLinejoin = this.wireframeLinejoin),
  6274. this.flatShading === !0 && (i.flatShading = this.flatShading),
  6275. this.visible === !1 && (i.visible = !1),
  6276. this.toneMapped === !1 && (i.toneMapped = !1),
  6277. this.fog === !1 && (i.fog = !1),
  6278. Object.keys(this.userData).length > 0 && (i.userData = this.userData);
  6279. function r(s) {
  6280. let n = [];
  6281. for (let a in s) {
  6282. let o = s[a];
  6283. delete o.metadata, n.push(o);
  6284. }
  6285. return n;
  6286. }
  6287. if (t) {
  6288. let s = r(e.textures),
  6289. n = r(e.images);
  6290. s.length > 0 && (i.textures = s), n.length > 0 && (i.images = n);
  6291. }
  6292. return i;
  6293. }
  6294. clone() {
  6295. return new this.constructor().copy(this);
  6296. }
  6297. copy(e) {
  6298. (this.name = e.name),
  6299. (this.blending = e.blending),
  6300. (this.side = e.side),
  6301. (this.vertexColors = e.vertexColors),
  6302. (this.opacity = e.opacity),
  6303. (this.transparent = e.transparent),
  6304. (this.blendSrc = e.blendSrc),
  6305. (this.blendDst = e.blendDst),
  6306. (this.blendEquation = e.blendEquation),
  6307. (this.blendSrcAlpha = e.blendSrcAlpha),
  6308. (this.blendDstAlpha = e.blendDstAlpha),
  6309. (this.blendEquationAlpha = e.blendEquationAlpha),
  6310. (this.depthFunc = e.depthFunc),
  6311. (this.depthTest = e.depthTest),
  6312. (this.depthWrite = e.depthWrite),
  6313. (this.stencilWriteMask = e.stencilWriteMask),
  6314. (this.stencilFunc = e.stencilFunc),
  6315. (this.stencilRef = e.stencilRef),
  6316. (this.stencilFuncMask = e.stencilFuncMask),
  6317. (this.stencilFail = e.stencilFail),
  6318. (this.stencilZFail = e.stencilZFail),
  6319. (this.stencilZPass = e.stencilZPass),
  6320. (this.stencilWrite = e.stencilWrite);
  6321. let t = e.clippingPlanes,
  6322. i = null;
  6323. if (t !== null) {
  6324. let r = t.length;
  6325. i = new Array(r);
  6326. for (let s = 0; s !== r; ++s) i[s] = t[s].clone();
  6327. }
  6328. return (
  6329. (this.clippingPlanes = i),
  6330. (this.clipIntersection = e.clipIntersection),
  6331. (this.clipShadows = e.clipShadows),
  6332. (this.shadowSide = e.shadowSide),
  6333. (this.colorWrite = e.colorWrite),
  6334. (this.precision = e.precision),
  6335. (this.polygonOffset = e.polygonOffset),
  6336. (this.polygonOffsetFactor = e.polygonOffsetFactor),
  6337. (this.polygonOffsetUnits = e.polygonOffsetUnits),
  6338. (this.dithering = e.dithering),
  6339. (this.alphaTest = e.alphaTest),
  6340. (this.alphaToCoverage = e.alphaToCoverage),
  6341. (this.premultipliedAlpha = e.premultipliedAlpha),
  6342. (this.forceSinglePass = e.forceSinglePass),
  6343. (this.visible = e.visible),
  6344. (this.toneMapped = e.toneMapped),
  6345. (this.userData = JSON.parse(JSON.stringify(e.userData))),
  6346. this
  6347. );
  6348. }
  6349. dispose() {
  6350. this.dispatchEvent({ type: 'dispose' });
  6351. }
  6352. set needsUpdate(e) {
  6353. e === !0 && this.version++;
  6354. }
  6355. },
  6356. Ph = class extends Th {
  6357. constructor(e) {
  6358. super(),
  6359. (this.isMeshBasicMaterial = !0),
  6360. (this.type = 'MeshBasicMaterial'),
  6361. (this.color = new Ge(16777215)),
  6362. (this.map = null),
  6363. (this.lightMap = null),
  6364. (this.lightMapIntensity = 1),
  6365. (this.aoMap = null),
  6366. (this.aoMapIntensity = 1),
  6367. (this.specularMap = null),
  6368. (this.alphaMap = null),
  6369. (this.envMap = null),
  6370. (this.combine = ow),
  6371. (this.reflectivity = 1),
  6372. (this.refractionRatio = 0.98),
  6373. (this.wireframe = !1),
  6374. (this.wireframeLinewidth = 1),
  6375. (this.wireframeLinecap = 'round'),
  6376. (this.wireframeLinejoin = 'round'),
  6377. (this.fog = !0),
  6378. this.setValues(e);
  6379. }
  6380. copy(e) {
  6381. return (
  6382. super.copy(e),
  6383. this.color.copy(e.color),
  6384. (this.map = e.map),
  6385. (this.lightMap = e.lightMap),
  6386. (this.lightMapIntensity = e.lightMapIntensity),
  6387. (this.aoMap = e.aoMap),
  6388. (this.aoMapIntensity = e.aoMapIntensity),
  6389. (this.specularMap = e.specularMap),
  6390. (this.alphaMap = e.alphaMap),
  6391. (this.envMap = e.envMap),
  6392. (this.combine = e.combine),
  6393. (this.reflectivity = e.reflectivity),
  6394. (this.refractionRatio = e.refractionRatio),
  6395. (this.wireframe = e.wireframe),
  6396. (this.wireframeLinewidth = e.wireframeLinewidth),
  6397. (this.wireframeLinecap = e.wireframeLinecap),
  6398. (this.wireframeLinejoin = e.wireframeLinejoin),
  6399. (this.fog = e.fog),
  6400. this
  6401. );
  6402. }
  6403. },
  6404. Yt = new E(),
  6405. ec = new G(),
  6406. Xe = class {
  6407. constructor(e, t, i = !1) {
  6408. if (Array.isArray(e)) throw new TypeError('THREE.BufferAttribute: array should be a Typed Array.');
  6409. (this.isBufferAttribute = !0),
  6410. (this.name = ''),
  6411. (this.array = e),
  6412. (this.itemSize = t),
  6413. (this.count = e !== void 0 ? e.length / t : 0),
  6414. (this.normalized = i),
  6415. (this.usage = Ff),
  6416. (this.updateRange = { offset: 0, count: -1 }),
  6417. (this.version = 0);
  6418. }
  6419. onUploadCallback() {}
  6420. set needsUpdate(e) {
  6421. e === !0 && this.version++;
  6422. }
  6423. setUsage(e) {
  6424. return (this.usage = e), this;
  6425. }
  6426. copy(e) {
  6427. return (
  6428. (this.name = e.name),
  6429. (this.array = new e.array.constructor(e.array)),
  6430. (this.itemSize = e.itemSize),
  6431. (this.count = e.count),
  6432. (this.normalized = e.normalized),
  6433. (this.usage = e.usage),
  6434. this
  6435. );
  6436. }
  6437. copyAt(e, t, i) {
  6438. (e *= this.itemSize), (i *= t.itemSize);
  6439. for (let r = 0, s = this.itemSize; r < s; r++) this.array[e + r] = t.array[i + r];
  6440. return this;
  6441. }
  6442. copyArray(e) {
  6443. return this.array.set(e), this;
  6444. }
  6445. applyMatrix3(e) {
  6446. if (this.itemSize === 2)
  6447. for (let t = 0, i = this.count; t < i; t++) ec.fromBufferAttribute(this, t), ec.applyMatrix3(e), this.setXY(t, ec.x, ec.y);
  6448. else if (this.itemSize === 3)
  6449. for (let t = 0, i = this.count; t < i; t++) Yt.fromBufferAttribute(this, t), Yt.applyMatrix3(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z);
  6450. return this;
  6451. }
  6452. applyMatrix4(e) {
  6453. for (let t = 0, i = this.count; t < i; t++) Yt.fromBufferAttribute(this, t), Yt.applyMatrix4(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z);
  6454. return this;
  6455. }
  6456. applyNormalMatrix(e) {
  6457. for (let t = 0, i = this.count; t < i; t++)
  6458. Yt.fromBufferAttribute(this, t), Yt.applyNormalMatrix(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z);
  6459. return this;
  6460. }
  6461. transformDirection(e) {
  6462. for (let t = 0, i = this.count; t < i; t++)
  6463. Yt.fromBufferAttribute(this, t), Yt.transformDirection(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z);
  6464. return this;
  6465. }
  6466. set(e, t = 0) {
  6467. return this.array.set(e, t), this;
  6468. }
  6469. getX(e) {
  6470. let t = this.array[e * this.itemSize];
  6471. return this.normalized && (t = ks(t, this.array)), t;
  6472. }
  6473. setX(e, t) {
  6474. return this.normalized && (t = _t(t, this.array)), (this.array[e * this.itemSize] = t), this;
  6475. }
  6476. getY(e) {
  6477. let t = this.array[e * this.itemSize + 1];
  6478. return this.normalized && (t = ks(t, this.array)), t;
  6479. }
  6480. setY(e, t) {
  6481. return this.normalized && (t = _t(t, this.array)), (this.array[e * this.itemSize + 1] = t), this;
  6482. }
  6483. getZ(e) {
  6484. let t = this.array[e * this.itemSize + 2];
  6485. return this.normalized && (t = ks(t, this.array)), t;
  6486. }
  6487. setZ(e, t) {
  6488. return this.normalized && (t = _t(t, this.array)), (this.array[e * this.itemSize + 2] = t), this;
  6489. }
  6490. getW(e) {
  6491. let t = this.array[e * this.itemSize + 3];
  6492. return this.normalized && (t = ks(t, this.array)), t;
  6493. }
  6494. setW(e, t) {
  6495. return this.normalized && (t = _t(t, this.array)), (this.array[e * this.itemSize + 3] = t), this;
  6496. }
  6497. setXY(e, t, i) {
  6498. return (
  6499. (e *= this.itemSize),
  6500. this.normalized && ((t = _t(t, this.array)), (i = _t(i, this.array))),
  6501. (this.array[e + 0] = t),
  6502. (this.array[e + 1] = i),
  6503. this
  6504. );
  6505. }
  6506. setXYZ(e, t, i, r) {
  6507. return (
  6508. (e *= this.itemSize),
  6509. this.normalized && ((t = _t(t, this.array)), (i = _t(i, this.array)), (r = _t(r, this.array))),
  6510. (this.array[e + 0] = t),
  6511. (this.array[e + 1] = i),
  6512. (this.array[e + 2] = r),
  6513. this
  6514. );
  6515. }
  6516. setXYZW(e, t, i, r, s) {
  6517. return (
  6518. (e *= this.itemSize),
  6519. this.normalized && ((t = _t(t, this.array)), (i = _t(i, this.array)), (r = _t(r, this.array)), (s = _t(s, this.array))),
  6520. (this.array[e + 0] = t),
  6521. (this.array[e + 1] = i),
  6522. (this.array[e + 2] = r),
  6523. (this.array[e + 3] = s),
  6524. this
  6525. );
  6526. }
  6527. onUpload(e) {
  6528. return (this.onUploadCallback = e), this;
  6529. }
  6530. clone() {
  6531. return new this.constructor(this.array, this.itemSize).copy(this);
  6532. }
  6533. toJSON() {
  6534. let e = { itemSize: this.itemSize, type: this.array.constructor.name, array: Array.from(this.array), normalized: this.normalized };
  6535. return (
  6536. this.name !== '' && (e.name = this.name),
  6537. this.usage !== Ff && (e.usage = this.usage),
  6538. (this.updateRange.offset !== 0 || this.updateRange.count !== -1) && (e.updateRange = this.updateRange),
  6539. e
  6540. );
  6541. }
  6542. copyColorsArray() {
  6543. console.error('THREE.BufferAttribute: copyColorsArray() was removed in r144.');
  6544. }
  6545. copyVector2sArray() {
  6546. console.error('THREE.BufferAttribute: copyVector2sArray() was removed in r144.');
  6547. }
  6548. copyVector3sArray() {
  6549. console.error('THREE.BufferAttribute: copyVector3sArray() was removed in r144.');
  6550. }
  6551. copyVector4sArray() {
  6552. console.error('THREE.BufferAttribute: copyVector4sArray() was removed in r144.');
  6553. }
  6554. },
  6555. gw = class extends Xe {
  6556. constructor(e, t, i) {
  6557. super(new Uint16Array(e), t, i);
  6558. }
  6559. },
  6560. Kl = class extends Xe {
  6561. constructor(e, t, i) {
  6562. super(new Uint32Array(e), t, i);
  6563. }
  6564. },
  6565. uE = class extends Xe {
  6566. constructor(e, t, i) {
  6567. super(new Uint16Array(e), t, i), (this.isFloat16BufferAttribute = !0);
  6568. }
  6569. },
  6570. Ce = class extends Xe {
  6571. constructor(e, t, i) {
  6572. super(new Float32Array(e), t, i);
  6573. }
  6574. },
  6575. pE = 0,
  6576. cr = new ve(),
  6577. fp = new bt(),
  6578. Ga = new E(),
  6579. Yi = new Kt(),
  6580. fl = new Kt(),
  6581. oi = new E(),
  6582. Ve = class extends Vi {
  6583. constructor() {
  6584. super(),
  6585. (this.isBufferGeometry = !0),
  6586. Object.defineProperty(this, 'id', { value: pE++ }),
  6587. (this.uuid = ps()),
  6588. (this.name = ''),
  6589. (this.type = 'BufferGeometry'),
  6590. (this.index = null),
  6591. (this.attributes = {}),
  6592. (this.morphAttributes = {}),
  6593. (this.morphTargetsRelative = !1),
  6594. (this.groups = []),
  6595. (this.boundingBox = null),
  6596. (this.boundingSphere = null),
  6597. (this.drawRange = { start: 0, count: 1 / 0 }),
  6598. (this.userData = {});
  6599. }
  6600. getIndex() {
  6601. return this.index;
  6602. }
  6603. setIndex(e) {
  6604. return Array.isArray(e) ? (this.index = new (dw(e) ? Kl : gw)(e, 1)) : (this.index = e), this;
  6605. }
  6606. getAttribute(e) {
  6607. return this.attributes[e];
  6608. }
  6609. setAttribute(e, t) {
  6610. return (this.attributes[e] = t), this;
  6611. }
  6612. deleteAttribute(e) {
  6613. return delete this.attributes[e], this;
  6614. }
  6615. hasAttribute(e) {
  6616. return this.attributes[e] !== void 0;
  6617. }
  6618. addGroup(e, t, i = 0) {
  6619. this.groups.push({ start: e, count: t, materialIndex: i });
  6620. }
  6621. clearGroups() {
  6622. this.groups = [];
  6623. }
  6624. setDrawRange(e, t) {
  6625. (this.drawRange.start = e), (this.drawRange.count = t);
  6626. }
  6627. applyMatrix4(e) {
  6628. let t = this.attributes.position;
  6629. t !== void 0 && (t.applyMatrix4(e), (t.needsUpdate = !0));
  6630. let i = this.attributes.normal;
  6631. if (i !== void 0) {
  6632. let s = new Ai().getNormalMatrix(e);
  6633. i.applyNormalMatrix(s), (i.needsUpdate = !0);
  6634. }
  6635. let r = this.attributes.tangent;
  6636. return (
  6637. r !== void 0 && (r.transformDirection(e), (r.needsUpdate = !0)),
  6638. this.boundingBox !== null && this.computeBoundingBox(),
  6639. this.boundingSphere !== null && this.computeBoundingSphere(),
  6640. this
  6641. );
  6642. }
  6643. applyQuaternion(e) {
  6644. return cr.makeRotationFromQuaternion(e), this.applyMatrix4(cr), this;
  6645. }
  6646. rotateX(e) {
  6647. return cr.makeRotationX(e), this.applyMatrix4(cr), this;
  6648. }
  6649. rotateY(e) {
  6650. return cr.makeRotationY(e), this.applyMatrix4(cr), this;
  6651. }
  6652. rotateZ(e) {
  6653. return cr.makeRotationZ(e), this.applyMatrix4(cr), this;
  6654. }
  6655. translate(e, t, i) {
  6656. return cr.makeTranslation(e, t, i), this.applyMatrix4(cr), this;
  6657. }
  6658. scale(e, t, i) {
  6659. return cr.makeScale(e, t, i), this.applyMatrix4(cr), this;
  6660. }
  6661. lookAt(e) {
  6662. return fp.lookAt(e), fp.updateMatrix(), this.applyMatrix4(fp.matrix), this;
  6663. }
  6664. center() {
  6665. return this.computeBoundingBox(), this.boundingBox.getCenter(Ga).negate(), this.translate(Ga.x, Ga.y, Ga.z), this;
  6666. }
  6667. setFromPoints(e) {
  6668. let t = [];
  6669. for (let i = 0, r = e.length; i < r; i++) {
  6670. let s = e[i];
  6671. t.push(s.x, s.y, s.z || 0);
  6672. }
  6673. return this.setAttribute('position', new Ce(t, 3)), this;
  6674. }
  6675. computeBoundingBox() {
  6676. this.boundingBox === null && (this.boundingBox = new Kt());
  6677. let e = this.attributes.position,
  6678. t = this.morphAttributes.position;
  6679. if (e && e.isGLBufferAttribute) {
  6680. console.error(
  6681. 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',
  6682. this
  6683. ),
  6684. this.boundingBox.set(new E(-1 / 0, -1 / 0, -1 / 0), new E(1 / 0, 1 / 0, 1 / 0));
  6685. return;
  6686. }
  6687. if (e !== void 0) {
  6688. if ((this.boundingBox.setFromBufferAttribute(e), t))
  6689. for (let i = 0, r = t.length; i < r; i++) {
  6690. let s = t[i];
  6691. Yi.setFromBufferAttribute(s),
  6692. this.morphTargetsRelative
  6693. ? (oi.addVectors(this.boundingBox.min, Yi.min),
  6694. this.boundingBox.expandByPoint(oi),
  6695. oi.addVectors(this.boundingBox.max, Yi.max),
  6696. this.boundingBox.expandByPoint(oi))
  6697. : (this.boundingBox.expandByPoint(Yi.min), this.boundingBox.expandByPoint(Yi.max));
  6698. }
  6699. } else this.boundingBox.makeEmpty();
  6700. (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) &&
  6701. console.error(
  6702. 'THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',
  6703. this
  6704. );
  6705. }
  6706. computeBoundingSphere() {
  6707. this.boundingSphere === null && (this.boundingSphere = new Mr());
  6708. let e = this.attributes.position,
  6709. t = this.morphAttributes.position;
  6710. if (e && e.isGLBufferAttribute) {
  6711. console.error(
  6712. 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',
  6713. this
  6714. ),
  6715. this.boundingSphere.set(new E(), 1 / 0);
  6716. return;
  6717. }
  6718. if (e) {
  6719. let i = this.boundingSphere.center;
  6720. if ((Yi.setFromBufferAttribute(e), t))
  6721. for (let s = 0, n = t.length; s < n; s++) {
  6722. let a = t[s];
  6723. fl.setFromBufferAttribute(a),
  6724. this.morphTargetsRelative
  6725. ? (oi.addVectors(Yi.min, fl.min), Yi.expandByPoint(oi), oi.addVectors(Yi.max, fl.max), Yi.expandByPoint(oi))
  6726. : (Yi.expandByPoint(fl.min), Yi.expandByPoint(fl.max));
  6727. }
  6728. Yi.getCenter(i);
  6729. let r = 0;
  6730. for (let s = 0, n = e.count; s < n; s++) oi.fromBufferAttribute(e, s), (r = Math.max(r, i.distanceToSquared(oi)));
  6731. if (t)
  6732. for (let s = 0, n = t.length; s < n; s++) {
  6733. let a = t[s],
  6734. o = this.morphTargetsRelative;
  6735. for (let l = 0, h = a.count; l < h; l++)
  6736. oi.fromBufferAttribute(a, l), o && (Ga.fromBufferAttribute(e, l), oi.add(Ga)), (r = Math.max(r, i.distanceToSquared(oi)));
  6737. }
  6738. (this.boundingSphere.radius = Math.sqrt(r)),
  6739. isNaN(this.boundingSphere.radius) &&
  6740. console.error(
  6741. 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',
  6742. this
  6743. );
  6744. }
  6745. }
  6746. computeTangents() {
  6747. let e = this.index,
  6748. t = this.attributes;
  6749. if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) {
  6750. console.error('THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)');
  6751. return;
  6752. }
  6753. let i = e.array,
  6754. r = t.position.array,
  6755. s = t.normal.array,
  6756. n = t.uv.array,
  6757. a = r.length / 3;
  6758. this.hasAttribute('tangent') === !1 && this.setAttribute('tangent', new Xe(new Float32Array(4 * a), 4));
  6759. let o = this.getAttribute('tangent').array,
  6760. l = [],
  6761. h = [];
  6762. for (let M = 0; M < a; M++) (l[M] = new E()), (h[M] = new E());
  6763. let u = new E(),
  6764. c = new E(),
  6765. d = new E(),
  6766. p = new G(),
  6767. f = new G(),
  6768. g = new G(),
  6769. m = new E(),
  6770. v = new E();
  6771. function y(M, C, T) {
  6772. u.fromArray(r, M * 3),
  6773. c.fromArray(r, C * 3),
  6774. d.fromArray(r, T * 3),
  6775. p.fromArray(n, M * 2),
  6776. f.fromArray(n, C * 2),
  6777. g.fromArray(n, T * 2),
  6778. c.sub(u),
  6779. d.sub(u),
  6780. f.sub(p),
  6781. g.sub(p);
  6782. let P = 1 / (f.x * g.y - g.x * f.y);
  6783. !isFinite(P) ||
  6784. (m.copy(c).multiplyScalar(g.y).addScaledVector(d, -f.y).multiplyScalar(P),
  6785. v.copy(d).multiplyScalar(f.x).addScaledVector(c, -g.x).multiplyScalar(P),
  6786. l[M].add(m),
  6787. l[C].add(m),
  6788. l[T].add(m),
  6789. h[M].add(v),
  6790. h[C].add(v),
  6791. h[T].add(v));
  6792. }
  6793. let b = this.groups;
  6794. b.length === 0 && (b = [{ start: 0, count: i.length }]);
  6795. for (let M = 0, C = b.length; M < C; ++M) {
  6796. let T = b[M],
  6797. P = T.start,
  6798. L = T.count;
  6799. for (let D = P, k = P + L; D < k; D += 3) y(i[D + 0], i[D + 1], i[D + 2]);
  6800. }
  6801. let x = new E(),
  6802. w = new E(),
  6803. A = new E(),
  6804. S = new E();
  6805. function _(M) {
  6806. A.fromArray(s, M * 3), S.copy(A);
  6807. let C = l[M];
  6808. x.copy(C), x.sub(A.multiplyScalar(A.dot(C))).normalize(), w.crossVectors(S, C);
  6809. let T = w.dot(h[M]) < 0 ? -1 : 1;
  6810. (o[M * 4] = x.x), (o[M * 4 + 1] = x.y), (o[M * 4 + 2] = x.z), (o[M * 4 + 3] = T);
  6811. }
  6812. for (let M = 0, C = b.length; M < C; ++M) {
  6813. let T = b[M],
  6814. P = T.start,
  6815. L = T.count;
  6816. for (let D = P, k = P + L; D < k; D += 3) _(i[D + 0]), _(i[D + 1]), _(i[D + 2]);
  6817. }
  6818. }
  6819. computeVertexNormals() {
  6820. let e = this.index,
  6821. t = this.getAttribute('position');
  6822. if (t !== void 0) {
  6823. let i = this.getAttribute('normal');
  6824. if (i === void 0) (i = new Xe(new Float32Array(t.count * 3), 3)), this.setAttribute('normal', i);
  6825. else for (let c = 0, d = i.count; c < d; c++) i.setXYZ(c, 0, 0, 0);
  6826. let r = new E(),
  6827. s = new E(),
  6828. n = new E(),
  6829. a = new E(),
  6830. o = new E(),
  6831. l = new E(),
  6832. h = new E(),
  6833. u = new E();
  6834. if (e)
  6835. for (let c = 0, d = e.count; c < d; c += 3) {
  6836. let p = e.getX(c + 0),
  6837. f = e.getX(c + 1),
  6838. g = e.getX(c + 2);
  6839. r.fromBufferAttribute(t, p),
  6840. s.fromBufferAttribute(t, f),
  6841. n.fromBufferAttribute(t, g),
  6842. h.subVectors(n, s),
  6843. u.subVectors(r, s),
  6844. h.cross(u),
  6845. a.fromBufferAttribute(i, p),
  6846. o.fromBufferAttribute(i, f),
  6847. l.fromBufferAttribute(i, g),
  6848. a.add(h),
  6849. o.add(h),
  6850. l.add(h),
  6851. i.setXYZ(p, a.x, a.y, a.z),
  6852. i.setXYZ(f, o.x, o.y, o.z),
  6853. i.setXYZ(g, l.x, l.y, l.z);
  6854. }
  6855. else
  6856. for (let c = 0, d = t.count; c < d; c += 3)
  6857. r.fromBufferAttribute(t, c + 0),
  6858. s.fromBufferAttribute(t, c + 1),
  6859. n.fromBufferAttribute(t, c + 2),
  6860. h.subVectors(n, s),
  6861. u.subVectors(r, s),
  6862. h.cross(u),
  6863. i.setXYZ(c + 0, h.x, h.y, h.z),
  6864. i.setXYZ(c + 1, h.x, h.y, h.z),
  6865. i.setXYZ(c + 2, h.x, h.y, h.z);
  6866. this.normalizeNormals(), (i.needsUpdate = !0);
  6867. }
  6868. }
  6869. merge() {
  6870. return (
  6871. console.error('THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeBufferGeometries() instead.'), this
  6872. );
  6873. }
  6874. normalizeNormals() {
  6875. let e = this.attributes.normal;
  6876. for (let t = 0, i = e.count; t < i; t++) oi.fromBufferAttribute(e, t), oi.normalize(), e.setXYZ(t, oi.x, oi.y, oi.z);
  6877. }
  6878. toNonIndexed() {
  6879. function e(a, o) {
  6880. let l = a.array,
  6881. h = a.itemSize,
  6882. u = a.normalized,
  6883. c = new l.constructor(o.length * h),
  6884. d = 0,
  6885. p = 0;
  6886. for (let f = 0, g = o.length; f < g; f++) {
  6887. a.isInterleavedBufferAttribute ? (d = o[f] * a.data.stride + a.offset) : (d = o[f] * h);
  6888. for (let m = 0; m < h; m++) c[p++] = l[d++];
  6889. }
  6890. return new Xe(c, h, u);
  6891. }
  6892. if (this.index === null) return console.warn('THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.'), this;
  6893. let t = new Ve(),
  6894. i = this.index.array,
  6895. r = this.attributes;
  6896. for (let a in r) {
  6897. let o = r[a],
  6898. l = e(o, i);
  6899. t.setAttribute(a, l);
  6900. }
  6901. let s = this.morphAttributes;
  6902. for (let a in s) {
  6903. let o = [],
  6904. l = s[a];
  6905. for (let h = 0, u = l.length; h < u; h++) {
  6906. let c = l[h],
  6907. d = e(c, i);
  6908. o.push(d);
  6909. }
  6910. t.morphAttributes[a] = o;
  6911. }
  6912. t.morphTargetsRelative = this.morphTargetsRelative;
  6913. let n = this.groups;
  6914. for (let a = 0, o = n.length; a < o; a++) {
  6915. let l = n[a];
  6916. t.addGroup(l.start, l.count, l.materialIndex);
  6917. }
  6918. return t;
  6919. }
  6920. toJSON() {
  6921. let e = { metadata: { version: 4.5, type: 'BufferGeometry', generator: 'BufferGeometry.toJSON' } };
  6922. if (
  6923. ((e.uuid = this.uuid),
  6924. (e.type = this.type),
  6925. this.name !== '' && (e.name = this.name),
  6926. Object.keys(this.userData).length > 0 && (e.userData = this.userData),
  6927. this.parameters !== void 0)
  6928. ) {
  6929. let o = this.parameters;
  6930. for (let l in o) o[l] !== void 0 && (e[l] = o[l]);
  6931. return e;
  6932. }
  6933. e.data = { attributes: {} };
  6934. let t = this.index;
  6935. t !== null && (e.data.index = { type: t.array.constructor.name, array: Array.prototype.slice.call(t.array) });
  6936. let i = this.attributes;
  6937. for (let o in i) {
  6938. let l = i[o];
  6939. e.data.attributes[o] = l.toJSON(e.data);
  6940. }
  6941. let r = {},
  6942. s = !1;
  6943. for (let o in this.morphAttributes) {
  6944. let l = this.morphAttributes[o],
  6945. h = [];
  6946. for (let u = 0, c = l.length; u < c; u++) {
  6947. let d = l[u];
  6948. h.push(d.toJSON(e.data));
  6949. }
  6950. h.length > 0 && ((r[o] = h), (s = !0));
  6951. }
  6952. s && ((e.data.morphAttributes = r), (e.data.morphTargetsRelative = this.morphTargetsRelative));
  6953. let n = this.groups;
  6954. n.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(n)));
  6955. let a = this.boundingSphere;
  6956. return a !== null && (e.data.boundingSphere = { center: a.center.toArray(), radius: a.radius }), e;
  6957. }
  6958. clone() {
  6959. return new this.constructor().copy(this);
  6960. }
  6961. copy(e) {
  6962. (this.index = null),
  6963. (this.attributes = {}),
  6964. (this.morphAttributes = {}),
  6965. (this.groups = []),
  6966. (this.boundingBox = null),
  6967. (this.boundingSphere = null);
  6968. let t = {};
  6969. this.name = e.name;
  6970. let i = e.index;
  6971. i !== null && this.setIndex(i.clone(t));
  6972. let r = e.attributes;
  6973. for (let l in r) {
  6974. let h = r[l];
  6975. this.setAttribute(l, h.clone(t));
  6976. }
  6977. let s = e.morphAttributes;
  6978. for (let l in s) {
  6979. let h = [],
  6980. u = s[l];
  6981. for (let c = 0, d = u.length; c < d; c++) h.push(u[c].clone(t));
  6982. this.morphAttributes[l] = h;
  6983. }
  6984. this.morphTargetsRelative = e.morphTargetsRelative;
  6985. let n = e.groups;
  6986. for (let l = 0, h = n.length; l < h; l++) {
  6987. let u = n[l];
  6988. this.addGroup(u.start, u.count, u.materialIndex);
  6989. }
  6990. let a = e.boundingBox;
  6991. a !== null && (this.boundingBox = a.clone());
  6992. let o = e.boundingSphere;
  6993. return (
  6994. o !== null && (this.boundingSphere = o.clone()),
  6995. (this.drawRange.start = e.drawRange.start),
  6996. (this.drawRange.count = e.drawRange.count),
  6997. (this.userData = e.userData),
  6998. e.parameters !== void 0 && (this.parameters = Object.assign({}, e.parameters)),
  6999. this
  7000. );
  7001. }
  7002. dispose() {
  7003. this.dispatchEvent({ type: 'dispose' });
  7004. }
  7005. },
  7006. G0 = new ve(),
  7007. Va = new Xo(),
  7008. mp = new Mr(),
  7009. ml = new E(),
  7010. gl = new E(),
  7011. vl = new E(),
  7012. gp = new E(),
  7013. tc = new E(),
  7014. ic = new G(),
  7015. rc = new G(),
  7016. sc = new G(),
  7017. vp = new E(),
  7018. nc = new E(),
  7019. tr = class extends bt {
  7020. constructor(e = new Ve(), t = new Ph()) {
  7021. super(), (this.isMesh = !0), (this.type = 'Mesh'), (this.geometry = e), (this.material = t), this.updateMorphTargets();
  7022. }
  7023. copy(e, t) {
  7024. return (
  7025. super.copy(e, t),
  7026. e.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = e.morphTargetInfluences.slice()),
  7027. e.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary)),
  7028. (this.material = e.material),
  7029. (this.geometry = e.geometry),
  7030. this
  7031. );
  7032. }
  7033. updateMorphTargets() {
  7034. let e = this.geometry.morphAttributes,
  7035. t = Object.keys(e);
  7036. if (t.length > 0) {
  7037. let i = e[t[0]];
  7038. if (i !== void 0) {
  7039. (this.morphTargetInfluences = []), (this.morphTargetDictionary = {});
  7040. for (let r = 0, s = i.length; r < s; r++) {
  7041. let n = i[r].name || String(r);
  7042. this.morphTargetInfluences.push(0), (this.morphTargetDictionary[n] = r);
  7043. }
  7044. }
  7045. }
  7046. }
  7047. getVertexPosition(e, t) {
  7048. let i = this.geometry,
  7049. r = i.attributes.position,
  7050. s = i.morphAttributes.position,
  7051. n = i.morphTargetsRelative;
  7052. t.fromBufferAttribute(r, e);
  7053. let a = this.morphTargetInfluences;
  7054. if (s && a) {
  7055. tc.set(0, 0, 0);
  7056. for (let o = 0, l = s.length; o < l; o++) {
  7057. let h = a[o],
  7058. u = s[o];
  7059. h !== 0 && (gp.fromBufferAttribute(u, e), n ? tc.addScaledVector(gp, h) : tc.addScaledVector(gp.sub(t), h));
  7060. }
  7061. t.add(tc);
  7062. }
  7063. return this.isSkinnedMesh && this.boneTransform(e, t), t;
  7064. }
  7065. raycast(e, t) {
  7066. let i = this.geometry,
  7067. r = this.material,
  7068. s = this.matrixWorld;
  7069. if (
  7070. r === void 0 ||
  7071. (i.boundingSphere === null && i.computeBoundingSphere(),
  7072. mp.copy(i.boundingSphere),
  7073. mp.applyMatrix4(s),
  7074. e.ray.intersectsSphere(mp) === !1) ||
  7075. (G0.copy(s).invert(), Va.copy(e.ray).applyMatrix4(G0), i.boundingBox !== null && Va.intersectsBox(i.boundingBox) === !1)
  7076. )
  7077. return;
  7078. let n,
  7079. a = i.index,
  7080. o = i.attributes.position,
  7081. l = i.attributes.uv,
  7082. h = i.attributes.uv2,
  7083. u = i.groups,
  7084. c = i.drawRange;
  7085. if (a !== null)
  7086. if (Array.isArray(r))
  7087. for (let d = 0, p = u.length; d < p; d++) {
  7088. let f = u[d],
  7089. g = r[f.materialIndex],
  7090. m = Math.max(f.start, c.start),
  7091. v = Math.min(a.count, Math.min(f.start + f.count, c.start + c.count));
  7092. for (let y = m, b = v; y < b; y += 3) {
  7093. let x = a.getX(y),
  7094. w = a.getX(y + 1),
  7095. A = a.getX(y + 2);
  7096. (n = ac(this, g, e, Va, l, h, x, w, A)),
  7097. n && ((n.faceIndex = Math.floor(y / 3)), (n.face.materialIndex = f.materialIndex), t.push(n));
  7098. }
  7099. }
  7100. else {
  7101. let d = Math.max(0, c.start),
  7102. p = Math.min(a.count, c.start + c.count);
  7103. for (let f = d, g = p; f < g; f += 3) {
  7104. let m = a.getX(f),
  7105. v = a.getX(f + 1),
  7106. y = a.getX(f + 2);
  7107. (n = ac(this, r, e, Va, l, h, m, v, y)), n && ((n.faceIndex = Math.floor(f / 3)), t.push(n));
  7108. }
  7109. }
  7110. else if (o !== void 0)
  7111. if (Array.isArray(r))
  7112. for (let d = 0, p = u.length; d < p; d++) {
  7113. let f = u[d],
  7114. g = r[f.materialIndex],
  7115. m = Math.max(f.start, c.start),
  7116. v = Math.min(o.count, Math.min(f.start + f.count, c.start + c.count));
  7117. for (let y = m, b = v; y < b; y += 3) {
  7118. let x = y,
  7119. w = y + 1,
  7120. A = y + 2;
  7121. (n = ac(this, g, e, Va, l, h, x, w, A)),
  7122. n && ((n.faceIndex = Math.floor(y / 3)), (n.face.materialIndex = f.materialIndex), t.push(n));
  7123. }
  7124. }
  7125. else {
  7126. let d = Math.max(0, c.start),
  7127. p = Math.min(o.count, c.start + c.count);
  7128. for (let f = d, g = p; f < g; f += 3) {
  7129. let m = f,
  7130. v = f + 1,
  7131. y = f + 2;
  7132. (n = ac(this, r, e, Va, l, h, m, v, y)), n && ((n.faceIndex = Math.floor(f / 3)), t.push(n));
  7133. }
  7134. }
  7135. }
  7136. };
  7137. function fE(e, t, i, r, s, n, a, o) {
  7138. let l;
  7139. if ((t.side === hi ? (l = r.intersectTriangle(a, n, s, !0, o)) : (l = r.intersectTriangle(s, n, a, t.side === Vr, o)), l === null))
  7140. return null;
  7141. nc.copy(o), nc.applyMatrix4(e.matrixWorld);
  7142. let h = i.ray.origin.distanceTo(nc);
  7143. return h < i.near || h > i.far ? null : { distance: h, point: nc.clone(), object: e };
  7144. }
  7145. function ac(e, t, i, r, s, n, a, o, l) {
  7146. e.getVertexPosition(a, ml), e.getVertexPosition(o, gl), e.getVertexPosition(l, vl);
  7147. let h = fE(e, t, i, r, ml, gl, vl, vp);
  7148. if (h) {
  7149. s &&
  7150. (ic.fromBufferAttribute(s, a),
  7151. rc.fromBufferAttribute(s, o),
  7152. sc.fromBufferAttribute(s, l),
  7153. (h.uv = Bi.getUV(vp, ml, gl, vl, ic, rc, sc, new G()))),
  7154. n &&
  7155. (ic.fromBufferAttribute(n, a),
  7156. rc.fromBufferAttribute(n, o),
  7157. sc.fromBufferAttribute(n, l),
  7158. (h.uv2 = Bi.getUV(vp, ml, gl, vl, ic, rc, sc, new G())));
  7159. let u = { a: a, b: o, c: l, normal: new E(), materialIndex: 0 };
  7160. Bi.getNormal(ml, gl, vl, u.normal), (h.face = u);
  7161. }
  7162. return h;
  7163. }
  7164. var vs = class extends Ve {
  7165. constructor(e = 1, t = 1, i = 1, r = 1, s = 1, n = 1) {
  7166. super(),
  7167. (this.type = 'BoxGeometry'),
  7168. (this.parameters = { width: e, height: t, depth: i, widthSegments: r, heightSegments: s, depthSegments: n });
  7169. let a = this;
  7170. (r = Math.floor(r)), (s = Math.floor(s)), (n = Math.floor(n));
  7171. let o = [],
  7172. l = [],
  7173. h = [],
  7174. u = [],
  7175. c = 0,
  7176. d = 0;
  7177. p('z', 'y', 'x', -1, -1, i, t, e, n, s, 0),
  7178. p('z', 'y', 'x', 1, -1, i, t, -e, n, s, 1),
  7179. p('x', 'z', 'y', 1, 1, e, i, t, r, n, 2),
  7180. p('x', 'z', 'y', 1, -1, e, i, -t, r, n, 3),
  7181. p('x', 'y', 'z', 1, -1, e, t, i, r, s, 4),
  7182. p('x', 'y', 'z', -1, -1, e, t, -i, r, s, 5),
  7183. this.setIndex(o),
  7184. this.setAttribute('position', new Ce(l, 3)),
  7185. this.setAttribute('normal', new Ce(h, 3)),
  7186. this.setAttribute('uv', new Ce(u, 2));
  7187. function p(f, g, m, v, y, b, x, w, A, S, _) {
  7188. let M = b / A,
  7189. C = x / S,
  7190. T = b / 2,
  7191. P = x / 2,
  7192. L = w / 2,
  7193. D = A + 1,
  7194. k = S + 1,
  7195. W = 0,
  7196. X = 0,
  7197. z = new E();
  7198. for (let j = 0; j < k; j++) {
  7199. let U = j * C - P;
  7200. for (let N = 0; N < D; N++) {
  7201. let B = N * M - T;
  7202. (z[f] = B * v),
  7203. (z[g] = U * y),
  7204. (z[m] = L),
  7205. l.push(z.x, z.y, z.z),
  7206. (z[f] = 0),
  7207. (z[g] = 0),
  7208. (z[m] = w > 0 ? 1 : -1),
  7209. h.push(z.x, z.y, z.z),
  7210. u.push(N / A),
  7211. u.push(1 - j / S),
  7212. (W += 1);
  7213. }
  7214. }
  7215. for (let j = 0; j < S; j++)
  7216. for (let U = 0; U < A; U++) {
  7217. let N = c + U + D * j,
  7218. B = c + U + D * (j + 1),
  7219. H = c + (U + 1) + D * (j + 1),
  7220. Q = c + (U + 1) + D * j;
  7221. o.push(N, B, Q), o.push(B, H, Q), (X += 6);
  7222. }
  7223. a.addGroup(d, X, _), (d += X), (c += W);
  7224. }
  7225. }
  7226. static fromJSON(e) {
  7227. return new vs(e.width, e.height, e.depth, e.widthSegments, e.heightSegments, e.depthSegments);
  7228. }
  7229. };
  7230. function zo(e) {
  7231. let t = {};
  7232. for (let i in e) {
  7233. t[i] = {};
  7234. for (let r in e[i]) {
  7235. let s = e[i][r];
  7236. s && (s.isColor || s.isMatrix3 || s.isMatrix4 || s.isVector2 || s.isVector3 || s.isVector4 || s.isTexture || s.isQuaternion)
  7237. ? (t[i][r] = s.clone())
  7238. : Array.isArray(s)
  7239. ? (t[i][r] = s.slice())
  7240. : (t[i][r] = s);
  7241. }
  7242. }
  7243. return t;
  7244. }
  7245. function Li(e) {
  7246. let t = {};
  7247. for (let i = 0; i < e.length; i++) {
  7248. let r = zo(e[i]);
  7249. for (let s in r) t[s] = r[s];
  7250. }
  7251. return t;
  7252. }
  7253. function mE(e) {
  7254. let t = [];
  7255. for (let i = 0; i < e.length; i++) t.push(e[i].clone());
  7256. return t;
  7257. }
  7258. function vw(e) {
  7259. return e.getRenderTarget() === null && e.outputEncoding === Ke ? rs : pd;
  7260. }
  7261. var qo = { clone: zo, merge: Li },
  7262. gE = `void main() {
  7263. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  7264. }`,
  7265. vE = `void main() {
  7266. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  7267. }`,
  7268. ri = class extends Th {
  7269. constructor(e) {
  7270. super(),
  7271. (this.isShaderMaterial = !0),
  7272. (this.type = 'ShaderMaterial'),
  7273. (this.defines = {}),
  7274. (this.uniforms = {}),
  7275. (this.uniformsGroups = []),
  7276. (this.vertexShader = gE),
  7277. (this.fragmentShader = vE),
  7278. (this.linewidth = 1),
  7279. (this.wireframe = !1),
  7280. (this.wireframeLinewidth = 1),
  7281. (this.fog = !1),
  7282. (this.lights = !1),
  7283. (this.clipping = !1),
  7284. (this.extensions = { derivatives: !1, fragDepth: !1, drawBuffers: !1, shaderTextureLOD: !1 }),
  7285. (this.defaultAttributeValues = { color: [1, 1, 1], uv: [0, 0], uv2: [0, 0] }),
  7286. (this.index0AttributeName = void 0),
  7287. (this.uniformsNeedUpdate = !1),
  7288. (this.glslVersion = null),
  7289. e !== void 0 && this.setValues(e);
  7290. }
  7291. copy(e) {
  7292. return (
  7293. super.copy(e),
  7294. (this.fragmentShader = e.fragmentShader),
  7295. (this.vertexShader = e.vertexShader),
  7296. (this.uniforms = zo(e.uniforms)),
  7297. (this.uniformsGroups = mE(e.uniformsGroups)),
  7298. (this.defines = Object.assign({}, e.defines)),
  7299. (this.wireframe = e.wireframe),
  7300. (this.wireframeLinewidth = e.wireframeLinewidth),
  7301. (this.fog = e.fog),
  7302. (this.lights = e.lights),
  7303. (this.clipping = e.clipping),
  7304. (this.extensions = Object.assign({}, e.extensions)),
  7305. (this.glslVersion = e.glslVersion),
  7306. this
  7307. );
  7308. }
  7309. toJSON(e) {
  7310. let t = super.toJSON(e);
  7311. (t.glslVersion = this.glslVersion), (t.uniforms = {});
  7312. for (let r in this.uniforms) {
  7313. let s = this.uniforms[r].value;
  7314. s && s.isTexture
  7315. ? (t.uniforms[r] = { type: 't', value: s.toJSON(e).uuid })
  7316. : s && s.isColor
  7317. ? (t.uniforms[r] = { type: 'c', value: s.getHex() })
  7318. : s && s.isVector2
  7319. ? (t.uniforms[r] = { type: 'v2', value: s.toArray() })
  7320. : s && s.isVector3
  7321. ? (t.uniforms[r] = { type: 'v3', value: s.toArray() })
  7322. : s && s.isVector4
  7323. ? (t.uniforms[r] = { type: 'v4', value: s.toArray() })
  7324. : s && s.isMatrix3
  7325. ? (t.uniforms[r] = { type: 'm3', value: s.toArray() })
  7326. : s && s.isMatrix4
  7327. ? (t.uniforms[r] = { type: 'm4', value: s.toArray() })
  7328. : (t.uniforms[r] = { value: s });
  7329. }
  7330. Object.keys(this.defines).length > 0 && (t.defines = this.defines),
  7331. (t.vertexShader = this.vertexShader),
  7332. (t.fragmentShader = this.fragmentShader);
  7333. let i = {};
  7334. for (let r in this.extensions) this.extensions[r] === !0 && (i[r] = !0);
  7335. return Object.keys(i).length > 0 && (t.extensions = i), t;
  7336. }
  7337. },
  7338. Yo = class extends bt {
  7339. constructor() {
  7340. super(),
  7341. (this.isCamera = !0),
  7342. (this.type = 'Camera'),
  7343. (this.matrixWorldInverse = new ve()),
  7344. (this.projectionMatrix = new ve()),
  7345. (this.projectionMatrixInverse = new ve());
  7346. }
  7347. copy(e, t) {
  7348. return (
  7349. super.copy(e, t),
  7350. this.matrixWorldInverse.copy(e.matrixWorldInverse),
  7351. this.projectionMatrix.copy(e.projectionMatrix),
  7352. this.projectionMatrixInverse.copy(e.projectionMatrixInverse),
  7353. this
  7354. );
  7355. }
  7356. getWorldDirection(e) {
  7357. this.updateWorldMatrix(!0, !1);
  7358. let t = this.matrixWorld.elements;
  7359. return e.set(-t[8], -t[9], -t[10]).normalize();
  7360. }
  7361. updateMatrixWorld(e) {
  7362. super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  7363. }
  7364. updateWorldMatrix(e, t) {
  7365. super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  7366. }
  7367. clone() {
  7368. return new this.constructor().copy(this);
  7369. }
  7370. },
  7371. wi = class extends Yo {
  7372. constructor(e = 50, t = 1, i = 0.1, r = 2e3) {
  7373. super(),
  7374. (this.isPerspectiveCamera = !0),
  7375. (this.type = 'PerspectiveCamera'),
  7376. (this.fov = e),
  7377. (this.zoom = 1),
  7378. (this.near = i),
  7379. (this.far = r),
  7380. (this.focus = 10),
  7381. (this.aspect = t),
  7382. (this.view = null),
  7383. (this.filmGauge = 35),
  7384. (this.filmOffset = 0),
  7385. this.updateProjectionMatrix();
  7386. }
  7387. copy(e, t) {
  7388. return (
  7389. super.copy(e, t),
  7390. (this.fov = e.fov),
  7391. (this.zoom = e.zoom),
  7392. (this.near = e.near),
  7393. (this.far = e.far),
  7394. (this.focus = e.focus),
  7395. (this.aspect = e.aspect),
  7396. (this.view = e.view === null ? null : Object.assign({}, e.view)),
  7397. (this.filmGauge = e.filmGauge),
  7398. (this.filmOffset = e.filmOffset),
  7399. this
  7400. );
  7401. }
  7402. setFocalLength(e) {
  7403. let t = (0.5 * this.getFilmHeight()) / e;
  7404. (this.fov = hh * 2 * Math.atan(t)), this.updateProjectionMatrix();
  7405. }
  7406. getFocalLength() {
  7407. let e = Math.tan(Ql * 0.5 * this.fov);
  7408. return (0.5 * this.getFilmHeight()) / e;
  7409. }
  7410. getEffectiveFOV() {
  7411. return hh * 2 * Math.atan(Math.tan(Ql * 0.5 * this.fov) / this.zoom);
  7412. }
  7413. getFilmWidth() {
  7414. return this.filmGauge * Math.min(this.aspect, 1);
  7415. }
  7416. getFilmHeight() {
  7417. return this.filmGauge / Math.max(this.aspect, 1);
  7418. }
  7419. setViewOffset(e, t, i, r, s, n) {
  7420. (this.aspect = e / t),
  7421. this.view === null && (this.view = { enabled: !0, fullWidth: 1, fullHeight: 1, offsetX: 0, offsetY: 0, width: 1, height: 1 }),
  7422. (this.view.enabled = !0),
  7423. (this.view.fullWidth = e),
  7424. (this.view.fullHeight = t),
  7425. (this.view.offsetX = i),
  7426. (this.view.offsetY = r),
  7427. (this.view.width = s),
  7428. (this.view.height = n),
  7429. this.updateProjectionMatrix();
  7430. }
  7431. clearViewOffset() {
  7432. this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
  7433. }
  7434. updateProjectionMatrix() {
  7435. let e = this.near,
  7436. t = (e * Math.tan(Ql * 0.5 * this.fov)) / this.zoom,
  7437. i = 2 * t,
  7438. r = this.aspect * i,
  7439. s = -0.5 * r,
  7440. n = this.view;
  7441. if (this.view !== null && this.view.enabled) {
  7442. let o = n.fullWidth,
  7443. l = n.fullHeight;
  7444. (s += (n.offsetX * r) / o), (t -= (n.offsetY * i) / l), (r *= n.width / o), (i *= n.height / l);
  7445. }
  7446. let a = this.filmOffset;
  7447. a !== 0 && (s += (e * a) / this.getFilmWidth()),
  7448. this.projectionMatrix.makePerspective(s, s + r, t, t - i, e, this.far),
  7449. this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
  7450. }
  7451. toJSON(e) {
  7452. let t = super.toJSON(e);
  7453. return (
  7454. (t.object.fov = this.fov),
  7455. (t.object.zoom = this.zoom),
  7456. (t.object.near = this.near),
  7457. (t.object.far = this.far),
  7458. (t.object.focus = this.focus),
  7459. (t.object.aspect = this.aspect),
  7460. this.view !== null && (t.object.view = Object.assign({}, this.view)),
  7461. (t.object.filmGauge = this.filmGauge),
  7462. (t.object.filmOffset = this.filmOffset),
  7463. t
  7464. );
  7465. }
  7466. },
  7467. Ha = -90,
  7468. Wa = 1,
  7469. yE = class extends bt {
  7470. constructor(e, t, i) {
  7471. super(), (this.type = 'CubeCamera'), (this.renderTarget = i);
  7472. let r = new wi(Ha, Wa, e, t);
  7473. (r.layers = this.layers), r.up.set(0, 1, 0), r.lookAt(1, 0, 0), this.add(r);
  7474. let s = new wi(Ha, Wa, e, t);
  7475. (s.layers = this.layers), s.up.set(0, 1, 0), s.lookAt(-1, 0, 0), this.add(s);
  7476. let n = new wi(Ha, Wa, e, t);
  7477. (n.layers = this.layers), n.up.set(0, 0, -1), n.lookAt(0, 1, 0), this.add(n);
  7478. let a = new wi(Ha, Wa, e, t);
  7479. (a.layers = this.layers), a.up.set(0, 0, 1), a.lookAt(0, -1, 0), this.add(a);
  7480. let o = new wi(Ha, Wa, e, t);
  7481. (o.layers = this.layers), o.up.set(0, 1, 0), o.lookAt(0, 0, 1), this.add(o);
  7482. let l = new wi(Ha, Wa, e, t);
  7483. (l.layers = this.layers), l.up.set(0, 1, 0), l.lookAt(0, 0, -1), this.add(l);
  7484. }
  7485. update(e, t) {
  7486. this.parent === null && this.updateMatrixWorld();
  7487. let i = this.renderTarget,
  7488. [r, s, n, a, o, l] = this.children,
  7489. h = e.getRenderTarget(),
  7490. u = e.toneMapping,
  7491. c = e.xr.enabled;
  7492. (e.toneMapping = Gs), (e.xr.enabled = !1);
  7493. let d = i.texture.generateMipmaps;
  7494. (i.texture.generateMipmaps = !1),
  7495. e.setRenderTarget(i, 0),
  7496. e.render(t, r),
  7497. e.setRenderTarget(i, 1),
  7498. e.render(t, s),
  7499. e.setRenderTarget(i, 2),
  7500. e.render(t, n),
  7501. e.setRenderTarget(i, 3),
  7502. e.render(t, a),
  7503. e.setRenderTarget(i, 4),
  7504. e.render(t, o),
  7505. (i.texture.generateMipmaps = d),
  7506. e.setRenderTarget(i, 5),
  7507. e.render(t, l),
  7508. e.setRenderTarget(h),
  7509. (e.toneMapping = u),
  7510. (e.xr.enabled = c),
  7511. (i.texture.needsPMREMUpdate = !0);
  7512. }
  7513. },
  7514. cg = class extends ci {
  7515. constructor(e, t, i, r, s, n, a, o, l, h) {
  7516. (e = e !== void 0 ? e : []),
  7517. (t = t !== void 0 ? t : ya),
  7518. super(e, t, i, r, s, n, a, o, l, h),
  7519. (this.isCubeTexture = !0),
  7520. (this.flipY = !1);
  7521. }
  7522. get images() {
  7523. return this.image;
  7524. }
  7525. set images(e) {
  7526. this.image = e;
  7527. }
  7528. },
  7529. xE = class extends ii {
  7530. constructor(e = 1, t = {}) {
  7531. super(e, e, t), (this.isWebGLCubeRenderTarget = !0);
  7532. let i = { width: e, height: e, depth: 1 },
  7533. r = [i, i, i, i, i, i];
  7534. (this.texture = new cg(r, t.mapping, t.wrapS, t.wrapT, t.magFilter, t.minFilter, t.format, t.type, t.anisotropy, t.encoding)),
  7535. (this.texture.isRenderTargetTexture = !0),
  7536. (this.texture.generateMipmaps = t.generateMipmaps !== void 0 ? t.generateMipmaps : !1),
  7537. (this.texture.minFilter = t.minFilter !== void 0 ? t.minFilter : mt);
  7538. }
  7539. fromEquirectangularTexture(e, t) {
  7540. (this.texture.type = t.type),
  7541. (this.texture.encoding = t.encoding),
  7542. (this.texture.generateMipmaps = t.generateMipmaps),
  7543. (this.texture.minFilter = t.minFilter),
  7544. (this.texture.magFilter = t.magFilter);
  7545. let i = {
  7546. uniforms: { tEquirect: { value: null } },
  7547. vertexShader: `
  7548. varying vec3 vWorldDirection;
  7549. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  7550. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  7551. }
  7552. void main() {
  7553. vWorldDirection = transformDirection( position, modelMatrix );
  7554. #include <begin_vertex>
  7555. #include <project_vertex>
  7556. }
  7557. `,
  7558. fragmentShader: `
  7559. uniform sampler2D tEquirect;
  7560. varying vec3 vWorldDirection;
  7561. #include <common>
  7562. void main() {
  7563. vec3 direction = normalize( vWorldDirection );
  7564. vec2 sampleUV = equirectUv( direction );
  7565. gl_FragColor = texture2D( tEquirect, sampleUV );
  7566. }
  7567. `
  7568. },
  7569. r = new vs(5, 5, 5),
  7570. s = new ri({
  7571. name: 'CubemapFromEquirect',
  7572. uniforms: zo(i.uniforms),
  7573. vertexShader: i.vertexShader,
  7574. fragmentShader: i.fragmentShader,
  7575. side: hi,
  7576. blending: fi
  7577. });
  7578. s.uniforms.tEquirect.value = t;
  7579. let n = new tr(r, s),
  7580. a = t.minFilter;
  7581. return (
  7582. t.minFilter === Bo && (t.minFilter = mt),
  7583. new yE(1, 10, this).update(e, n),
  7584. (t.minFilter = a),
  7585. n.geometry.dispose(),
  7586. n.material.dispose(),
  7587. this
  7588. );
  7589. }
  7590. clear(e, t, i, r) {
  7591. let s = e.getRenderTarget();
  7592. for (let n = 0; n < 6; n++) e.setRenderTarget(this, n), e.clear(t, i, r);
  7593. e.setRenderTarget(s);
  7594. }
  7595. },
  7596. yp = new E(),
  7597. bE = new E(),
  7598. wE = new Ai(),
  7599. yr = class {
  7600. constructor(e = new E(1, 0, 0), t = 0) {
  7601. (this.isPlane = !0), (this.normal = e), (this.constant = t);
  7602. }
  7603. set(e, t) {
  7604. return this.normal.copy(e), (this.constant = t), this;
  7605. }
  7606. setComponents(e, t, i, r) {
  7607. return this.normal.set(e, t, i), (this.constant = r), this;
  7608. }
  7609. setFromNormalAndCoplanarPoint(e, t) {
  7610. return this.normal.copy(e), (this.constant = -t.dot(this.normal)), this;
  7611. }
  7612. setFromCoplanarPoints(e, t, i) {
  7613. let r = yp.subVectors(i, t).cross(bE.subVectors(e, t)).normalize();
  7614. return this.setFromNormalAndCoplanarPoint(r, e), this;
  7615. }
  7616. copy(e) {
  7617. return this.normal.copy(e.normal), (this.constant = e.constant), this;
  7618. }
  7619. normalize() {
  7620. let e = 1 / this.normal.length();
  7621. return this.normal.multiplyScalar(e), (this.constant *= e), this;
  7622. }
  7623. negate() {
  7624. return (this.constant *= -1), this.normal.negate(), this;
  7625. }
  7626. distanceToPoint(e) {
  7627. return this.normal.dot(e) + this.constant;
  7628. }
  7629. distanceToSphere(e) {
  7630. return this.distanceToPoint(e.center) - e.radius;
  7631. }
  7632. projectPoint(e, t) {
  7633. return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e);
  7634. }
  7635. intersectLine(e, t) {
  7636. let i = e.delta(yp),
  7637. r = this.normal.dot(i);
  7638. if (r === 0) return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null;
  7639. let s = -(e.start.dot(this.normal) + this.constant) / r;
  7640. return s < 0 || s > 1 ? null : t.copy(i).multiplyScalar(s).add(e.start);
  7641. }
  7642. intersectsLine(e) {
  7643. let t = this.distanceToPoint(e.start),
  7644. i = this.distanceToPoint(e.end);
  7645. return (t < 0 && i > 0) || (i < 0 && t > 0);
  7646. }
  7647. intersectsBox(e) {
  7648. return e.intersectsPlane(this);
  7649. }
  7650. intersectsSphere(e) {
  7651. return e.intersectsPlane(this);
  7652. }
  7653. coplanarPoint(e) {
  7654. return e.copy(this.normal).multiplyScalar(-this.constant);
  7655. }
  7656. applyMatrix4(e, t) {
  7657. let i = t || wE.getNormalMatrix(e),
  7658. r = this.coplanarPoint(yp).applyMatrix4(e),
  7659. s = this.normal.applyMatrix3(i).normalize();
  7660. return (this.constant = -r.dot(s)), this;
  7661. }
  7662. translate(e) {
  7663. return (this.constant -= e.dot(this.normal)), this;
  7664. }
  7665. equals(e) {
  7666. return e.normal.equals(this.normal) && e.constant === this.constant;
  7667. }
  7668. clone() {
  7669. return new this.constructor().copy(this);
  7670. }
  7671. },
  7672. Xa = new Mr(),
  7673. oc = new E(),
  7674. dg = class {
  7675. constructor(e = new yr(), t = new yr(), i = new yr(), r = new yr(), s = new yr(), n = new yr()) {
  7676. this.planes = [e, t, i, r, s, n];
  7677. }
  7678. set(e, t, i, r, s, n) {
  7679. let a = this.planes;
  7680. return a[0].copy(e), a[1].copy(t), a[2].copy(i), a[3].copy(r), a[4].copy(s), a[5].copy(n), this;
  7681. }
  7682. copy(e) {
  7683. let t = this.planes;
  7684. for (let i = 0; i < 6; i++) t[i].copy(e.planes[i]);
  7685. return this;
  7686. }
  7687. setFromProjectionMatrix(e) {
  7688. let t = this.planes,
  7689. i = e.elements,
  7690. r = i[0],
  7691. s = i[1],
  7692. n = i[2],
  7693. a = i[3],
  7694. o = i[4],
  7695. l = i[5],
  7696. h = i[6],
  7697. u = i[7],
  7698. c = i[8],
  7699. d = i[9],
  7700. p = i[10],
  7701. f = i[11],
  7702. g = i[12],
  7703. m = i[13],
  7704. v = i[14],
  7705. y = i[15];
  7706. return (
  7707. t[0].setComponents(a - r, u - o, f - c, y - g).normalize(),
  7708. t[1].setComponents(a + r, u + o, f + c, y + g).normalize(),
  7709. t[2].setComponents(a + s, u + l, f + d, y + m).normalize(),
  7710. t[3].setComponents(a - s, u - l, f - d, y - m).normalize(),
  7711. t[4].setComponents(a - n, u - h, f - p, y - v).normalize(),
  7712. t[5].setComponents(a + n, u + h, f + p, y + v).normalize(),
  7713. this
  7714. );
  7715. }
  7716. intersectsObject(e) {
  7717. let t = e.geometry;
  7718. return (
  7719. t.boundingSphere === null && t.computeBoundingSphere(),
  7720. Xa.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),
  7721. this.intersectsSphere(Xa)
  7722. );
  7723. }
  7724. intersectsSprite(e) {
  7725. return Xa.center.set(0, 0, 0), (Xa.radius = 0.7071067811865476), Xa.applyMatrix4(e.matrixWorld), this.intersectsSphere(Xa);
  7726. }
  7727. intersectsSphere(e) {
  7728. let t = this.planes,
  7729. i = e.center,
  7730. r = -e.radius;
  7731. for (let s = 0; s < 6; s++) if (t[s].distanceToPoint(i) < r) return !1;
  7732. return !0;
  7733. }
  7734. intersectsBox(e) {
  7735. let t = this.planes;
  7736. for (let i = 0; i < 6; i++) {
  7737. let r = t[i];
  7738. if (
  7739. ((oc.x = r.normal.x > 0 ? e.max.x : e.min.x),
  7740. (oc.y = r.normal.y > 0 ? e.max.y : e.min.y),
  7741. (oc.z = r.normal.z > 0 ? e.max.z : e.min.z),
  7742. r.distanceToPoint(oc) < 0)
  7743. )
  7744. return !1;
  7745. }
  7746. return !0;
  7747. }
  7748. containsPoint(e) {
  7749. let t = this.planes;
  7750. for (let i = 0; i < 6; i++) if (t[i].distanceToPoint(e) < 0) return !1;
  7751. return !0;
  7752. }
  7753. clone() {
  7754. return new this.constructor().copy(this);
  7755. }
  7756. };
  7757. function yw() {
  7758. let e = null,
  7759. t = !1,
  7760. i = null,
  7761. r = null;
  7762. function s(n, a) {
  7763. i(n, a), (r = e.requestAnimationFrame(s));
  7764. }
  7765. return {
  7766. start: function () {
  7767. t !== !0 && i !== null && ((r = e.requestAnimationFrame(s)), (t = !0));
  7768. },
  7769. stop: function () {
  7770. e.cancelAnimationFrame(r), (t = !1);
  7771. },
  7772. setAnimationLoop: function (n) {
  7773. i = n;
  7774. },
  7775. setContext: function (n) {
  7776. e = n;
  7777. }
  7778. };
  7779. }
  7780. function _E(e, t) {
  7781. let i = t.isWebGL2,
  7782. r = new WeakMap();
  7783. function s(h, u) {
  7784. let c = h.array,
  7785. d = h.usage,
  7786. p = e.createBuffer();
  7787. e.bindBuffer(u, p), e.bufferData(u, c, d), h.onUploadCallback();
  7788. let f;
  7789. if (c instanceof Float32Array) f = 5126;
  7790. else if (c instanceof Uint16Array)
  7791. if (h.isFloat16BufferAttribute)
  7792. if (i) f = 5131;
  7793. else throw new Error('THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.');
  7794. else f = 5123;
  7795. else if (c instanceof Int16Array) f = 5122;
  7796. else if (c instanceof Uint32Array) f = 5125;
  7797. else if (c instanceof Int32Array) f = 5124;
  7798. else if (c instanceof Int8Array) f = 5120;
  7799. else if (c instanceof Uint8Array) f = 5121;
  7800. else if (c instanceof Uint8ClampedArray) f = 5121;
  7801. else throw new Error('THREE.WebGLAttributes: Unsupported buffer data format: ' + c);
  7802. return { buffer: p, type: f, bytesPerElement: c.BYTES_PER_ELEMENT, version: h.version };
  7803. }
  7804. function n(h, u, c) {
  7805. let d = u.array,
  7806. p = u.updateRange;
  7807. e.bindBuffer(c, h),
  7808. p.count === -1
  7809. ? e.bufferSubData(c, 0, d)
  7810. : (i
  7811. ? e.bufferSubData(c, p.offset * d.BYTES_PER_ELEMENT, d, p.offset, p.count)
  7812. : e.bufferSubData(c, p.offset * d.BYTES_PER_ELEMENT, d.subarray(p.offset, p.offset + p.count)),
  7813. (p.count = -1)),
  7814. u.onUploadCallback();
  7815. }
  7816. function a(h) {
  7817. return h.isInterleavedBufferAttribute && (h = h.data), r.get(h);
  7818. }
  7819. function o(h) {
  7820. h.isInterleavedBufferAttribute && (h = h.data);
  7821. let u = r.get(h);
  7822. u && (e.deleteBuffer(u.buffer), r.delete(h));
  7823. }
  7824. function l(h, u) {
  7825. if (h.isGLBufferAttribute) {
  7826. let d = r.get(h);
  7827. (!d || d.version < h.version) && r.set(h, { buffer: h.buffer, type: h.type, bytesPerElement: h.elementSize, version: h.version });
  7828. return;
  7829. }
  7830. h.isInterleavedBufferAttribute && (h = h.data);
  7831. let c = r.get(h);
  7832. c === void 0 ? r.set(h, s(h, u)) : c.version < h.version && (n(c.buffer, h, u), (c.version = h.version));
  7833. }
  7834. return { get: a, remove: o, update: l };
  7835. }
  7836. var ou = class extends Ve {
  7837. constructor(e = 1, t = 1, i = 1, r = 1) {
  7838. super(), (this.type = 'PlaneGeometry'), (this.parameters = { width: e, height: t, widthSegments: i, heightSegments: r });
  7839. let s = e / 2,
  7840. n = t / 2,
  7841. a = Math.floor(i),
  7842. o = Math.floor(r),
  7843. l = a + 1,
  7844. h = o + 1,
  7845. u = e / a,
  7846. c = t / o,
  7847. d = [],
  7848. p = [],
  7849. f = [],
  7850. g = [];
  7851. for (let m = 0; m < h; m++) {
  7852. let v = m * c - n;
  7853. for (let y = 0; y < l; y++) {
  7854. let b = y * u - s;
  7855. p.push(b, -v, 0), f.push(0, 0, 1), g.push(y / a), g.push(1 - m / o);
  7856. }
  7857. }
  7858. for (let m = 0; m < o; m++)
  7859. for (let v = 0; v < a; v++) {
  7860. let y = v + l * m,
  7861. b = v + l * (m + 1),
  7862. x = v + 1 + l * (m + 1),
  7863. w = v + 1 + l * m;
  7864. d.push(y, b, w), d.push(b, x, w);
  7865. }
  7866. this.setIndex(d),
  7867. this.setAttribute('position', new Ce(p, 3)),
  7868. this.setAttribute('normal', new Ce(f, 3)),
  7869. this.setAttribute('uv', new Ce(g, 2));
  7870. }
  7871. static fromJSON(e) {
  7872. return new ou(e.width, e.height, e.widthSegments, e.heightSegments);
  7873. }
  7874. },
  7875. AE = `#ifdef USE_ALPHAMAP
  7876. diffuseColor.a *= texture2D( alphaMap, vUv ).g;
  7877. #endif`,
  7878. SE = `#ifdef USE_ALPHAMAP
  7879. uniform sampler2D alphaMap;
  7880. #endif`,
  7881. ME = `#ifdef USE_ALPHATEST
  7882. if ( diffuseColor.a < alphaTest ) discard;
  7883. #endif`,
  7884. EE = `#ifdef USE_ALPHATEST
  7885. uniform float alphaTest;
  7886. #endif`,
  7887. CE = `#ifdef USE_AOMAP
  7888. float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
  7889. reflectedLight.indirectDiffuse *= ambientOcclusion;
  7890. #if defined( USE_ENVMAP ) && defined( STANDARD )
  7891. float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
  7892. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  7893. #endif
  7894. #endif`,
  7895. TE = `#ifdef USE_AOMAP
  7896. uniform sampler2D aoMap;
  7897. uniform float aoMapIntensity;
  7898. #endif`,
  7899. PE = 'vec3 transformed = vec3( position );',
  7900. DE = `vec3 objectNormal = vec3( normal );
  7901. #ifdef USE_TANGENT
  7902. vec3 objectTangent = vec3( tangent.xyz );
  7903. #endif`,
  7904. LE = `vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  7905. return RECIPROCAL_PI * diffuseColor;
  7906. }
  7907. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  7908. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  7909. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  7910. }
  7911. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  7912. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  7913. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  7914. }
  7915. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  7916. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  7917. float x2 = x * x;
  7918. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  7919. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  7920. }
  7921. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  7922. float a2 = pow2( alpha );
  7923. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  7924. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  7925. return 0.5 / max( gv + gl, EPSILON );
  7926. }
  7927. float D_GGX( const in float alpha, const in float dotNH ) {
  7928. float a2 = pow2( alpha );
  7929. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  7930. return RECIPROCAL_PI * a2 / pow2( denom );
  7931. }
  7932. 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 ) {
  7933. float alpha = pow2( roughness );
  7934. vec3 halfDir = normalize( lightDir + viewDir );
  7935. float dotNL = saturate( dot( normal, lightDir ) );
  7936. float dotNV = saturate( dot( normal, viewDir ) );
  7937. float dotNH = saturate( dot( normal, halfDir ) );
  7938. float dotVH = saturate( dot( viewDir, halfDir ) );
  7939. vec3 F = F_Schlick( f0, f90, dotVH );
  7940. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  7941. float D = D_GGX( alpha, dotNH );
  7942. return F * ( V * D );
  7943. }
  7944. #ifdef USE_IRIDESCENCE
  7945. 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 ) {
  7946. float alpha = pow2( roughness );
  7947. vec3 halfDir = normalize( lightDir + viewDir );
  7948. float dotNL = saturate( dot( normal, lightDir ) );
  7949. float dotNV = saturate( dot( normal, viewDir ) );
  7950. float dotNH = saturate( dot( normal, halfDir ) );
  7951. float dotVH = saturate( dot( viewDir, halfDir ) );
  7952. vec3 F = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );
  7953. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  7954. float D = D_GGX( alpha, dotNH );
  7955. return F * ( V * D );
  7956. }
  7957. #endif
  7958. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  7959. const float LUT_SIZE = 64.0;
  7960. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  7961. const float LUT_BIAS = 0.5 / LUT_SIZE;
  7962. float dotNV = saturate( dot( N, V ) );
  7963. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  7964. uv = uv * LUT_SCALE + LUT_BIAS;
  7965. return uv;
  7966. }
  7967. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  7968. float l = length( f );
  7969. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  7970. }
  7971. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  7972. float x = dot( v1, v2 );
  7973. float y = abs( x );
  7974. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  7975. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  7976. float v = a / b;
  7977. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  7978. return cross( v1, v2 ) * theta_sintheta;
  7979. }
  7980. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  7981. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  7982. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  7983. vec3 lightNormal = cross( v1, v2 );
  7984. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  7985. vec3 T1, T2;
  7986. T1 = normalize( V - N * dot( V, N ) );
  7987. T2 = - cross( N, T1 );
  7988. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  7989. vec3 coords[ 4 ];
  7990. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  7991. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  7992. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  7993. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  7994. coords[ 0 ] = normalize( coords[ 0 ] );
  7995. coords[ 1 ] = normalize( coords[ 1 ] );
  7996. coords[ 2 ] = normalize( coords[ 2 ] );
  7997. coords[ 3 ] = normalize( coords[ 3 ] );
  7998. vec3 vectorFormFactor = vec3( 0.0 );
  7999. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  8000. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  8001. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  8002. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  8003. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  8004. return vec3( result );
  8005. }
  8006. float G_BlinnPhong_Implicit( ) {
  8007. return 0.25;
  8008. }
  8009. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  8010. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  8011. }
  8012. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  8013. vec3 halfDir = normalize( lightDir + viewDir );
  8014. float dotNH = saturate( dot( normal, halfDir ) );
  8015. float dotVH = saturate( dot( viewDir, halfDir ) );
  8016. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  8017. float G = G_BlinnPhong_Implicit( );
  8018. float D = D_BlinnPhong( shininess, dotNH );
  8019. return F * ( G * D );
  8020. }
  8021. #if defined( USE_SHEEN )
  8022. float D_Charlie( float roughness, float dotNH ) {
  8023. float alpha = pow2( roughness );
  8024. float invAlpha = 1.0 / alpha;
  8025. float cos2h = dotNH * dotNH;
  8026. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  8027. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  8028. }
  8029. float V_Neubelt( float dotNV, float dotNL ) {
  8030. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  8031. }
  8032. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  8033. vec3 halfDir = normalize( lightDir + viewDir );
  8034. float dotNL = saturate( dot( normal, lightDir ) );
  8035. float dotNV = saturate( dot( normal, viewDir ) );
  8036. float dotNH = saturate( dot( normal, halfDir ) );
  8037. float D = D_Charlie( sheenRoughness, dotNH );
  8038. float V = V_Neubelt( dotNV, dotNL );
  8039. return sheenColor * ( D * V );
  8040. }
  8041. #endif`,
  8042. OE = `#ifdef USE_IRIDESCENCE
  8043. const mat3 XYZ_TO_REC709 = mat3(
  8044. 3.2404542, -0.9692660, 0.0556434,
  8045. -1.5371385, 1.8760108, -0.2040259,
  8046. -0.4985314, 0.0415560, 1.0572252
  8047. );
  8048. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  8049. vec3 sqrtF0 = sqrt( fresnel0 );
  8050. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  8051. }
  8052. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  8053. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  8054. }
  8055. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  8056. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  8057. }
  8058. vec3 evalSensitivity( float OPD, vec3 shift ) {
  8059. float phase = 2.0 * PI * OPD * 1.0e-9;
  8060. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  8061. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  8062. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  8063. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  8064. 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 ) );
  8065. xyz /= 1.0685e-7;
  8066. vec3 rgb = XYZ_TO_REC709 * xyz;
  8067. return rgb;
  8068. }
  8069. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  8070. vec3 I;
  8071. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  8072. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  8073. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  8074. if ( cosTheta2Sq < 0.0 ) {
  8075. return vec3( 1.0 );
  8076. }
  8077. float cosTheta2 = sqrt( cosTheta2Sq );
  8078. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  8079. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  8080. float R21 = R12;
  8081. float T121 = 1.0 - R12;
  8082. float phi12 = 0.0;
  8083. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  8084. float phi21 = PI - phi12;
  8085. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  8086. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  8087. vec3 phi23 = vec3( 0.0 );
  8088. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  8089. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  8090. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  8091. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  8092. vec3 phi = vec3( phi21 ) + phi23;
  8093. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  8094. vec3 r123 = sqrt( R123 );
  8095. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  8096. vec3 C0 = R12 + Rs;
  8097. I = C0;
  8098. vec3 Cm = Rs - T121;
  8099. for ( int m = 1; m <= 2; ++ m ) {
  8100. Cm *= r123;
  8101. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  8102. I += Cm * Sm;
  8103. }
  8104. return max( I, vec3( 0.0 ) );
  8105. }
  8106. #endif`,
  8107. IE = `#ifdef USE_BUMPMAP
  8108. uniform sampler2D bumpMap;
  8109. uniform float bumpScale;
  8110. vec2 dHdxy_fwd() {
  8111. vec2 dSTdx = dFdx( vUv );
  8112. vec2 dSTdy = dFdy( vUv );
  8113. float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
  8114. float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
  8115. float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
  8116. return vec2( dBx, dBy );
  8117. }
  8118. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  8119. vec3 vSigmaX = dFdx( surf_pos.xyz );
  8120. vec3 vSigmaY = dFdy( surf_pos.xyz );
  8121. vec3 vN = surf_norm;
  8122. vec3 R1 = cross( vSigmaY, vN );
  8123. vec3 R2 = cross( vN, vSigmaX );
  8124. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  8125. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  8126. return normalize( abs( fDet ) * surf_norm - vGrad );
  8127. }
  8128. #endif`,
  8129. RE = `#if NUM_CLIPPING_PLANES > 0
  8130. vec4 plane;
  8131. #pragma unroll_loop_start
  8132. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  8133. plane = clippingPlanes[ i ];
  8134. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  8135. }
  8136. #pragma unroll_loop_end
  8137. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  8138. bool clipped = true;
  8139. #pragma unroll_loop_start
  8140. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  8141. plane = clippingPlanes[ i ];
  8142. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  8143. }
  8144. #pragma unroll_loop_end
  8145. if ( clipped ) discard;
  8146. #endif
  8147. #endif`,
  8148. BE = `#if NUM_CLIPPING_PLANES > 0
  8149. varying vec3 vClipPosition;
  8150. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  8151. #endif`,
  8152. zE = `#if NUM_CLIPPING_PLANES > 0
  8153. varying vec3 vClipPosition;
  8154. #endif`,
  8155. NE = `#if NUM_CLIPPING_PLANES > 0
  8156. vClipPosition = - mvPosition.xyz;
  8157. #endif`,
  8158. UE = `#if defined( USE_COLOR_ALPHA )
  8159. diffuseColor *= vColor;
  8160. #elif defined( USE_COLOR )
  8161. diffuseColor.rgb *= vColor;
  8162. #endif`,
  8163. FE = `#if defined( USE_COLOR_ALPHA )
  8164. varying vec4 vColor;
  8165. #elif defined( USE_COLOR )
  8166. varying vec3 vColor;
  8167. #endif`,
  8168. kE = `#if defined( USE_COLOR_ALPHA )
  8169. varying vec4 vColor;
  8170. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  8171. varying vec3 vColor;
  8172. #endif`,
  8173. jE = `#if defined( USE_COLOR_ALPHA )
  8174. vColor = vec4( 1.0 );
  8175. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  8176. vColor = vec3( 1.0 );
  8177. #endif
  8178. #ifdef USE_COLOR
  8179. vColor *= color;
  8180. #endif
  8181. #ifdef USE_INSTANCING_COLOR
  8182. vColor.xyz *= instanceColor.xyz;
  8183. #endif`,
  8184. GE = `#define PI 3.141592653589793
  8185. #define PI2 6.283185307179586
  8186. #define PI_HALF 1.5707963267948966
  8187. #define RECIPROCAL_PI 0.3183098861837907
  8188. #define RECIPROCAL_PI2 0.15915494309189535
  8189. #define EPSILON 1e-6
  8190. #ifndef saturate
  8191. #define saturate( a ) clamp( a, 0.0, 1.0 )
  8192. #endif
  8193. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  8194. float pow2( const in float x ) { return x*x; }
  8195. vec3 pow2( const in vec3 x ) { return x*x; }
  8196. float pow3( const in float x ) { return x*x*x; }
  8197. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  8198. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  8199. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  8200. highp float rand( const in vec2 uv ) {
  8201. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  8202. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  8203. return fract( sin( sn ) * c );
  8204. }
  8205. #ifdef HIGH_PRECISION
  8206. float precisionSafeLength( vec3 v ) { return length( v ); }
  8207. #else
  8208. float precisionSafeLength( vec3 v ) {
  8209. float maxComponent = max3( abs( v ) );
  8210. return length( v / maxComponent ) * maxComponent;
  8211. }
  8212. #endif
  8213. struct IncidentLight {
  8214. vec3 color;
  8215. vec3 direction;
  8216. bool visible;
  8217. };
  8218. struct ReflectedLight {
  8219. vec3 directDiffuse;
  8220. vec3 directSpecular;
  8221. vec3 indirectDiffuse;
  8222. vec3 indirectSpecular;
  8223. };
  8224. struct GeometricContext {
  8225. vec3 position;
  8226. vec3 normal;
  8227. vec3 viewDir;
  8228. #ifdef USE_CLEARCOAT
  8229. vec3 clearcoatNormal;
  8230. #endif
  8231. };
  8232. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  8233. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  8234. }
  8235. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  8236. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  8237. }
  8238. mat3 transposeMat3( const in mat3 m ) {
  8239. mat3 tmp;
  8240. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  8241. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  8242. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  8243. return tmp;
  8244. }
  8245. float luminance( const in vec3 rgb ) {
  8246. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  8247. return dot( weights, rgb );
  8248. }
  8249. bool isPerspectiveMatrix( mat4 m ) {
  8250. return m[ 2 ][ 3 ] == - 1.0;
  8251. }
  8252. vec2 equirectUv( in vec3 dir ) {
  8253. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  8254. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  8255. return vec2( u, v );
  8256. }`,
  8257. VE = `#ifdef ENVMAP_TYPE_CUBE_UV
  8258. #define cubeUV_minMipLevel 4.0
  8259. #define cubeUV_minTileSize 16.0
  8260. float getFace( vec3 direction ) {
  8261. vec3 absDirection = abs( direction );
  8262. float face = - 1.0;
  8263. if ( absDirection.x > absDirection.z ) {
  8264. if ( absDirection.x > absDirection.y )
  8265. face = direction.x > 0.0 ? 0.0 : 3.0;
  8266. else
  8267. face = direction.y > 0.0 ? 1.0 : 4.0;
  8268. } else {
  8269. if ( absDirection.z > absDirection.y )
  8270. face = direction.z > 0.0 ? 2.0 : 5.0;
  8271. else
  8272. face = direction.y > 0.0 ? 1.0 : 4.0;
  8273. }
  8274. return face;
  8275. }
  8276. vec2 getUV( vec3 direction, float face ) {
  8277. vec2 uv;
  8278. if ( face == 0.0 ) {
  8279. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  8280. } else if ( face == 1.0 ) {
  8281. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  8282. } else if ( face == 2.0 ) {
  8283. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  8284. } else if ( face == 3.0 ) {
  8285. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  8286. } else if ( face == 4.0 ) {
  8287. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  8288. } else {
  8289. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  8290. }
  8291. return 0.5 * ( uv + 1.0 );
  8292. }
  8293. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  8294. float face = getFace( direction );
  8295. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  8296. mipInt = max( mipInt, cubeUV_minMipLevel );
  8297. float faceSize = exp2( mipInt );
  8298. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  8299. if ( face > 2.0 ) {
  8300. uv.y += faceSize;
  8301. face -= 3.0;
  8302. }
  8303. uv.x += face * faceSize;
  8304. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  8305. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  8306. uv.x *= CUBEUV_TEXEL_WIDTH;
  8307. uv.y *= CUBEUV_TEXEL_HEIGHT;
  8308. #ifdef texture2DGradEXT
  8309. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  8310. #else
  8311. return texture2D( envMap, uv ).rgb;
  8312. #endif
  8313. }
  8314. #define cubeUV_r0 1.0
  8315. #define cubeUV_v0 0.339
  8316. #define cubeUV_m0 - 2.0
  8317. #define cubeUV_r1 0.8
  8318. #define cubeUV_v1 0.276
  8319. #define cubeUV_m1 - 1.0
  8320. #define cubeUV_r4 0.4
  8321. #define cubeUV_v4 0.046
  8322. #define cubeUV_m4 2.0
  8323. #define cubeUV_r5 0.305
  8324. #define cubeUV_v5 0.016
  8325. #define cubeUV_m5 3.0
  8326. #define cubeUV_r6 0.21
  8327. #define cubeUV_v6 0.0038
  8328. #define cubeUV_m6 4.0
  8329. float roughnessToMip( float roughness ) {
  8330. float mip = 0.0;
  8331. if ( roughness >= cubeUV_r1 ) {
  8332. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  8333. } else if ( roughness >= cubeUV_r4 ) {
  8334. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  8335. } else if ( roughness >= cubeUV_r5 ) {
  8336. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  8337. } else if ( roughness >= cubeUV_r6 ) {
  8338. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  8339. } else {
  8340. mip = - 2.0 * log2( 1.16 * roughness ); }
  8341. return mip;
  8342. }
  8343. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  8344. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  8345. float mipF = fract( mip );
  8346. float mipInt = floor( mip );
  8347. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  8348. if ( mipF == 0.0 ) {
  8349. return vec4( color0, 1.0 );
  8350. } else {
  8351. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  8352. return vec4( mix( color0, color1, mipF ), 1.0 );
  8353. }
  8354. }
  8355. #endif`,
  8356. HE = `vec3 transformedNormal = objectNormal;
  8357. #ifdef USE_INSTANCING
  8358. mat3 m = mat3( instanceMatrix );
  8359. transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
  8360. transformedNormal = m * transformedNormal;
  8361. #endif
  8362. transformedNormal = normalMatrix * transformedNormal;
  8363. #ifdef FLIP_SIDED
  8364. transformedNormal = - transformedNormal;
  8365. #endif
  8366. #ifdef USE_TANGENT
  8367. vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  8368. #ifdef FLIP_SIDED
  8369. transformedTangent = - transformedTangent;
  8370. #endif
  8371. #endif`,
  8372. WE = `#ifdef USE_DISPLACEMENTMAP
  8373. uniform sampler2D displacementMap;
  8374. uniform float displacementScale;
  8375. uniform float displacementBias;
  8376. #endif`,
  8377. XE = `#ifdef USE_DISPLACEMENTMAP
  8378. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
  8379. #endif`,
  8380. qE = `#ifdef USE_EMISSIVEMAP
  8381. vec4 emissiveColor = texture2D( emissiveMap, vUv );
  8382. totalEmissiveRadiance *= emissiveColor.rgb;
  8383. #endif`,
  8384. YE = `#ifdef USE_EMISSIVEMAP
  8385. uniform sampler2D emissiveMap;
  8386. #endif`,
  8387. QE = 'gl_FragColor = linearToOutputTexel( gl_FragColor );',
  8388. ZE = `vec4 LinearToLinear( in vec4 value ) {
  8389. return value;
  8390. }
  8391. vec4 LinearTosRGB( in vec4 value ) {
  8392. 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 );
  8393. }`,
  8394. KE = `#ifdef USE_ENVMAP
  8395. #ifdef ENV_WORLDPOS
  8396. vec3 cameraToFrag;
  8397. if ( isOrthographic ) {
  8398. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  8399. } else {
  8400. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  8401. }
  8402. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  8403. #ifdef ENVMAP_MODE_REFLECTION
  8404. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  8405. #else
  8406. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  8407. #endif
  8408. #else
  8409. vec3 reflectVec = vReflect;
  8410. #endif
  8411. #ifdef ENVMAP_TYPE_CUBE
  8412. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  8413. #else
  8414. vec4 envColor = vec4( 0.0 );
  8415. #endif
  8416. #ifdef ENVMAP_BLENDING_MULTIPLY
  8417. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  8418. #elif defined( ENVMAP_BLENDING_MIX )
  8419. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  8420. #elif defined( ENVMAP_BLENDING_ADD )
  8421. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  8422. #endif
  8423. #endif`,
  8424. JE = `#ifdef USE_ENVMAP
  8425. uniform float envMapIntensity;
  8426. uniform float flipEnvMap;
  8427. #ifdef ENVMAP_TYPE_CUBE
  8428. uniform samplerCube envMap;
  8429. #else
  8430. uniform sampler2D envMap;
  8431. #endif
  8432. #endif`,
  8433. $E = `#ifdef USE_ENVMAP
  8434. uniform float reflectivity;
  8435. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  8436. #define ENV_WORLDPOS
  8437. #endif
  8438. #ifdef ENV_WORLDPOS
  8439. varying vec3 vWorldPosition;
  8440. uniform float refractionRatio;
  8441. #else
  8442. varying vec3 vReflect;
  8443. #endif
  8444. #endif`,
  8445. eC = `#ifdef USE_ENVMAP
  8446. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  8447. #define ENV_WORLDPOS
  8448. #endif
  8449. #ifdef ENV_WORLDPOS
  8450. varying vec3 vWorldPosition;
  8451. #else
  8452. varying vec3 vReflect;
  8453. uniform float refractionRatio;
  8454. #endif
  8455. #endif`,
  8456. tC = `#ifdef USE_ENVMAP
  8457. #ifdef ENV_WORLDPOS
  8458. vWorldPosition = worldPosition.xyz;
  8459. #else
  8460. vec3 cameraToVertex;
  8461. if ( isOrthographic ) {
  8462. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  8463. } else {
  8464. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  8465. }
  8466. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  8467. #ifdef ENVMAP_MODE_REFLECTION
  8468. vReflect = reflect( cameraToVertex, worldNormal );
  8469. #else
  8470. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  8471. #endif
  8472. #endif
  8473. #endif`,
  8474. iC = `#ifdef USE_FOG
  8475. vFogDepth = - mvPosition.z;
  8476. #endif`,
  8477. rC = `#ifdef USE_FOG
  8478. varying float vFogDepth;
  8479. #endif`,
  8480. sC = `#ifdef USE_FOG
  8481. #ifdef FOG_EXP2
  8482. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  8483. #else
  8484. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  8485. #endif
  8486. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  8487. #endif`,
  8488. nC = `#ifdef USE_FOG
  8489. uniform vec3 fogColor;
  8490. varying float vFogDepth;
  8491. #ifdef FOG_EXP2
  8492. uniform float fogDensity;
  8493. #else
  8494. uniform float fogNear;
  8495. uniform float fogFar;
  8496. #endif
  8497. #endif`,
  8498. aC = `#ifdef USE_GRADIENTMAP
  8499. uniform sampler2D gradientMap;
  8500. #endif
  8501. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  8502. float dotNL = dot( normal, lightDirection );
  8503. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  8504. #ifdef USE_GRADIENTMAP
  8505. return vec3( texture2D( gradientMap, coord ).r );
  8506. #else
  8507. vec2 fw = fwidth( coord ) * 0.5;
  8508. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  8509. #endif
  8510. }`,
  8511. oC = `#ifdef USE_LIGHTMAP
  8512. vec4 lightMapTexel = texture2D( lightMap, vUv2 );
  8513. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  8514. reflectedLight.indirectDiffuse += lightMapIrradiance;
  8515. #endif`,
  8516. lC = `#ifdef USE_LIGHTMAP
  8517. uniform sampler2D lightMap;
  8518. uniform float lightMapIntensity;
  8519. #endif`,
  8520. hC = `LambertMaterial material;
  8521. material.diffuseColor = diffuseColor.rgb;
  8522. material.specularStrength = specularStrength;`,
  8523. cC = `varying vec3 vViewPosition;
  8524. struct LambertMaterial {
  8525. vec3 diffuseColor;
  8526. float specularStrength;
  8527. };
  8528. void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  8529. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  8530. vec3 irradiance = dotNL * directLight.color;
  8531. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  8532. }
  8533. void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  8534. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  8535. }
  8536. #define RE_Direct RE_Direct_Lambert
  8537. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
  8538. dC = `uniform bool receiveShadow;
  8539. uniform vec3 ambientLightColor;
  8540. uniform vec3 lightProbe[ 9 ];
  8541. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  8542. float x = normal.x, y = normal.y, z = normal.z;
  8543. vec3 result = shCoefficients[ 0 ] * 0.886227;
  8544. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  8545. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  8546. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  8547. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  8548. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  8549. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  8550. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  8551. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  8552. return result;
  8553. }
  8554. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  8555. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  8556. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  8557. return irradiance;
  8558. }
  8559. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  8560. vec3 irradiance = ambientLightColor;
  8561. return irradiance;
  8562. }
  8563. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  8564. #if defined ( PHYSICALLY_CORRECT_LIGHTS )
  8565. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  8566. if ( cutoffDistance > 0.0 ) {
  8567. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  8568. }
  8569. return distanceFalloff;
  8570. #else
  8571. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  8572. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  8573. }
  8574. return 1.0;
  8575. #endif
  8576. }
  8577. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  8578. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  8579. }
  8580. #if NUM_DIR_LIGHTS > 0
  8581. struct DirectionalLight {
  8582. vec3 direction;
  8583. vec3 color;
  8584. };
  8585. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  8586. void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {
  8587. light.color = directionalLight.color;
  8588. light.direction = directionalLight.direction;
  8589. light.visible = true;
  8590. }
  8591. #endif
  8592. #if NUM_POINT_LIGHTS > 0
  8593. struct PointLight {
  8594. vec3 position;
  8595. vec3 color;
  8596. float distance;
  8597. float decay;
  8598. };
  8599. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  8600. void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {
  8601. vec3 lVector = pointLight.position - geometry.position;
  8602. light.direction = normalize( lVector );
  8603. float lightDistance = length( lVector );
  8604. light.color = pointLight.color;
  8605. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  8606. light.visible = ( light.color != vec3( 0.0 ) );
  8607. }
  8608. #endif
  8609. #if NUM_SPOT_LIGHTS > 0
  8610. struct SpotLight {
  8611. vec3 position;
  8612. vec3 direction;
  8613. vec3 color;
  8614. float distance;
  8615. float decay;
  8616. float coneCos;
  8617. float penumbraCos;
  8618. };
  8619. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  8620. void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {
  8621. vec3 lVector = spotLight.position - geometry.position;
  8622. light.direction = normalize( lVector );
  8623. float angleCos = dot( light.direction, spotLight.direction );
  8624. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  8625. if ( spotAttenuation > 0.0 ) {
  8626. float lightDistance = length( lVector );
  8627. light.color = spotLight.color * spotAttenuation;
  8628. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  8629. light.visible = ( light.color != vec3( 0.0 ) );
  8630. } else {
  8631. light.color = vec3( 0.0 );
  8632. light.visible = false;
  8633. }
  8634. }
  8635. #endif
  8636. #if NUM_RECT_AREA_LIGHTS > 0
  8637. struct RectAreaLight {
  8638. vec3 color;
  8639. vec3 position;
  8640. vec3 halfWidth;
  8641. vec3 halfHeight;
  8642. };
  8643. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  8644. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  8645. #endif
  8646. #if NUM_HEMI_LIGHTS > 0
  8647. struct HemisphereLight {
  8648. vec3 direction;
  8649. vec3 skyColor;
  8650. vec3 groundColor;
  8651. };
  8652. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  8653. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  8654. float dotNL = dot( normal, hemiLight.direction );
  8655. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  8656. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  8657. return irradiance;
  8658. }
  8659. #endif`,
  8660. uC = `#if defined( USE_ENVMAP )
  8661. vec3 getIBLIrradiance( const in vec3 normal ) {
  8662. #if defined( ENVMAP_TYPE_CUBE_UV )
  8663. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  8664. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  8665. return PI * envMapColor.rgb * envMapIntensity;
  8666. #else
  8667. return vec3( 0.0 );
  8668. #endif
  8669. }
  8670. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  8671. #if defined( ENVMAP_TYPE_CUBE_UV )
  8672. vec3 reflectVec = reflect( - viewDir, normal );
  8673. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  8674. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  8675. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  8676. return envMapColor.rgb * envMapIntensity;
  8677. #else
  8678. return vec3( 0.0 );
  8679. #endif
  8680. }
  8681. #endif`,
  8682. pC = `ToonMaterial material;
  8683. material.diffuseColor = diffuseColor.rgb;`,
  8684. fC = `varying vec3 vViewPosition;
  8685. struct ToonMaterial {
  8686. vec3 diffuseColor;
  8687. };
  8688. void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  8689. vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
  8690. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  8691. }
  8692. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  8693. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  8694. }
  8695. #define RE_Direct RE_Direct_Toon
  8696. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,
  8697. mC = `BlinnPhongMaterial material;
  8698. material.diffuseColor = diffuseColor.rgb;
  8699. material.specularColor = specular;
  8700. material.specularShininess = shininess;
  8701. material.specularStrength = specularStrength;`,
  8702. gC = `varying vec3 vViewPosition;
  8703. struct BlinnPhongMaterial {
  8704. vec3 diffuseColor;
  8705. vec3 specularColor;
  8706. float specularShininess;
  8707. float specularStrength;
  8708. };
  8709. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  8710. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  8711. vec3 irradiance = dotNL * directLight.color;
  8712. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  8713. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
  8714. }
  8715. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  8716. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  8717. }
  8718. #define RE_Direct RE_Direct_BlinnPhong
  8719. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
  8720. vC = `PhysicalMaterial material;
  8721. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  8722. vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
  8723. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  8724. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  8725. material.roughness = min( material.roughness, 1.0 );
  8726. #ifdef IOR
  8727. material.ior = ior;
  8728. #ifdef SPECULAR
  8729. float specularIntensityFactor = specularIntensity;
  8730. vec3 specularColorFactor = specularColor;
  8731. #ifdef USE_SPECULARINTENSITYMAP
  8732. specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;
  8733. #endif
  8734. #ifdef USE_SPECULARCOLORMAP
  8735. specularColorFactor *= texture2D( specularColorMap, vUv ).rgb;
  8736. #endif
  8737. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  8738. #else
  8739. float specularIntensityFactor = 1.0;
  8740. vec3 specularColorFactor = vec3( 1.0 );
  8741. material.specularF90 = 1.0;
  8742. #endif
  8743. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  8744. #else
  8745. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  8746. material.specularF90 = 1.0;
  8747. #endif
  8748. #ifdef USE_CLEARCOAT
  8749. material.clearcoat = clearcoat;
  8750. material.clearcoatRoughness = clearcoatRoughness;
  8751. material.clearcoatF0 = vec3( 0.04 );
  8752. material.clearcoatF90 = 1.0;
  8753. #ifdef USE_CLEARCOATMAP
  8754. material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
  8755. #endif
  8756. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  8757. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;
  8758. #endif
  8759. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  8760. material.clearcoatRoughness += geometryRoughness;
  8761. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  8762. #endif
  8763. #ifdef USE_IRIDESCENCE
  8764. material.iridescence = iridescence;
  8765. material.iridescenceIOR = iridescenceIOR;
  8766. #ifdef USE_IRIDESCENCEMAP
  8767. material.iridescence *= texture2D( iridescenceMap, vUv ).r;
  8768. #endif
  8769. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  8770. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum;
  8771. #else
  8772. material.iridescenceThickness = iridescenceThicknessMaximum;
  8773. #endif
  8774. #endif
  8775. #ifdef USE_SHEEN
  8776. material.sheenColor = sheenColor;
  8777. #ifdef USE_SHEENCOLORMAP
  8778. material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;
  8779. #endif
  8780. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  8781. #ifdef USE_SHEENROUGHNESSMAP
  8782. material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;
  8783. #endif
  8784. #endif`,
  8785. yC = `struct PhysicalMaterial {
  8786. vec3 diffuseColor;
  8787. float roughness;
  8788. vec3 specularColor;
  8789. float specularF90;
  8790. #ifdef USE_CLEARCOAT
  8791. float clearcoat;
  8792. float clearcoatRoughness;
  8793. vec3 clearcoatF0;
  8794. float clearcoatF90;
  8795. #endif
  8796. #ifdef USE_IRIDESCENCE
  8797. float iridescence;
  8798. float iridescenceIOR;
  8799. float iridescenceThickness;
  8800. vec3 iridescenceFresnel;
  8801. vec3 iridescenceF0;
  8802. #endif
  8803. #ifdef USE_SHEEN
  8804. vec3 sheenColor;
  8805. float sheenRoughness;
  8806. #endif
  8807. #ifdef IOR
  8808. float ior;
  8809. #endif
  8810. #ifdef USE_TRANSMISSION
  8811. float transmission;
  8812. float transmissionAlpha;
  8813. float thickness;
  8814. float attenuationDistance;
  8815. vec3 attenuationColor;
  8816. #endif
  8817. };
  8818. vec3 clearcoatSpecular = vec3( 0.0 );
  8819. vec3 sheenSpecular = vec3( 0.0 );
  8820. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  8821. float dotNV = saturate( dot( normal, viewDir ) );
  8822. float r2 = roughness * roughness;
  8823. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  8824. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  8825. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  8826. return saturate( DG * RECIPROCAL_PI );
  8827. }
  8828. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  8829. float dotNV = saturate( dot( normal, viewDir ) );
  8830. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  8831. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  8832. vec4 r = roughness * c0 + c1;
  8833. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  8834. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  8835. return fab;
  8836. }
  8837. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  8838. vec2 fab = DFGApprox( normal, viewDir, roughness );
  8839. return specularColor * fab.x + specularF90 * fab.y;
  8840. }
  8841. #ifdef USE_IRIDESCENCE
  8842. 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 ) {
  8843. #else
  8844. 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 ) {
  8845. #endif
  8846. vec2 fab = DFGApprox( normal, viewDir, roughness );
  8847. #ifdef USE_IRIDESCENCE
  8848. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  8849. #else
  8850. vec3 Fr = specularColor;
  8851. #endif
  8852. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  8853. float Ess = fab.x + fab.y;
  8854. float Ems = 1.0 - Ess;
  8855. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  8856. singleScatter += FssEss;
  8857. multiScatter += Fms * Ems;
  8858. }
  8859. #if NUM_RECT_AREA_LIGHTS > 0
  8860. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  8861. vec3 normal = geometry.normal;
  8862. vec3 viewDir = geometry.viewDir;
  8863. vec3 position = geometry.position;
  8864. vec3 lightPos = rectAreaLight.position;
  8865. vec3 halfWidth = rectAreaLight.halfWidth;
  8866. vec3 halfHeight = rectAreaLight.halfHeight;
  8867. vec3 lightColor = rectAreaLight.color;
  8868. float roughness = material.roughness;
  8869. vec3 rectCoords[ 4 ];
  8870. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  8871. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  8872. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  8873. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  8874. vec4 t1 = texture2D( ltc_1, uv );
  8875. vec4 t2 = texture2D( ltc_2, uv );
  8876. mat3 mInv = mat3(
  8877. vec3( t1.x, 0, t1.y ),
  8878. vec3( 0, 1, 0 ),
  8879. vec3( t1.z, 0, t1.w )
  8880. );
  8881. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  8882. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  8883. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  8884. }
  8885. #endif
  8886. void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  8887. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  8888. vec3 irradiance = dotNL * directLight.color;
  8889. #ifdef USE_CLEARCOAT
  8890. float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
  8891. vec3 ccIrradiance = dotNLcc * directLight.color;
  8892. clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  8893. #endif
  8894. #ifdef USE_SHEEN
  8895. sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
  8896. #endif
  8897. #ifdef USE_IRIDESCENCE
  8898. reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );
  8899. #else
  8900. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );
  8901. #endif
  8902. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  8903. }
  8904. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  8905. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  8906. }
  8907. 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) {
  8908. #ifdef USE_CLEARCOAT
  8909. clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  8910. #endif
  8911. #ifdef USE_SHEEN
  8912. sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
  8913. #endif
  8914. vec3 singleScattering = vec3( 0.0 );
  8915. vec3 multiScattering = vec3( 0.0 );
  8916. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  8917. #ifdef USE_IRIDESCENCE
  8918. computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  8919. #else
  8920. computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  8921. #endif
  8922. vec3 totalScattering = singleScattering + multiScattering;
  8923. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  8924. reflectedLight.indirectSpecular += radiance * singleScattering;
  8925. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  8926. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  8927. }
  8928. #define RE_Direct RE_Direct_Physical
  8929. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  8930. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  8931. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  8932. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  8933. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  8934. }`,
  8935. xC = `
  8936. GeometricContext geometry;
  8937. geometry.position = - vViewPosition;
  8938. geometry.normal = normal;
  8939. geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  8940. #ifdef USE_CLEARCOAT
  8941. geometry.clearcoatNormal = clearcoatNormal;
  8942. #endif
  8943. #ifdef USE_IRIDESCENCE
  8944. float dotNVi = saturate( dot( normal, geometry.viewDir ) );
  8945. if ( material.iridescenceThickness == 0.0 ) {
  8946. material.iridescence = 0.0;
  8947. } else {
  8948. material.iridescence = saturate( material.iridescence );
  8949. }
  8950. if ( material.iridescence > 0.0 ) {
  8951. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  8952. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  8953. }
  8954. #endif
  8955. IncidentLight directLight;
  8956. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  8957. PointLight pointLight;
  8958. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  8959. PointLightShadow pointLightShadow;
  8960. #endif
  8961. #pragma unroll_loop_start
  8962. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  8963. pointLight = pointLights[ i ];
  8964. getPointLightInfo( pointLight, geometry, directLight );
  8965. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  8966. pointLightShadow = pointLightShadows[ i ];
  8967. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  8968. #endif
  8969. RE_Direct( directLight, geometry, material, reflectedLight );
  8970. }
  8971. #pragma unroll_loop_end
  8972. #endif
  8973. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  8974. SpotLight spotLight;
  8975. vec4 spotColor;
  8976. vec3 spotLightCoord;
  8977. bool inSpotLightMap;
  8978. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  8979. SpotLightShadow spotLightShadow;
  8980. #endif
  8981. #pragma unroll_loop_start
  8982. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  8983. spotLight = spotLights[ i ];
  8984. getSpotLightInfo( spotLight, geometry, directLight );
  8985. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  8986. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  8987. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  8988. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  8989. #else
  8990. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  8991. #endif
  8992. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  8993. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  8994. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  8995. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  8996. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  8997. #endif
  8998. #undef SPOT_LIGHT_MAP_INDEX
  8999. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  9000. spotLightShadow = spotLightShadows[ i ];
  9001. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  9002. #endif
  9003. RE_Direct( directLight, geometry, material, reflectedLight );
  9004. }
  9005. #pragma unroll_loop_end
  9006. #endif
  9007. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  9008. DirectionalLight directionalLight;
  9009. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  9010. DirectionalLightShadow directionalLightShadow;
  9011. #endif
  9012. #pragma unroll_loop_start
  9013. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  9014. directionalLight = directionalLights[ i ];
  9015. getDirectionalLightInfo( directionalLight, geometry, directLight );
  9016. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  9017. directionalLightShadow = directionalLightShadows[ i ];
  9018. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  9019. #endif
  9020. RE_Direct( directLight, geometry, material, reflectedLight );
  9021. }
  9022. #pragma unroll_loop_end
  9023. #endif
  9024. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  9025. RectAreaLight rectAreaLight;
  9026. #pragma unroll_loop_start
  9027. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  9028. rectAreaLight = rectAreaLights[ i ];
  9029. RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
  9030. }
  9031. #pragma unroll_loop_end
  9032. #endif
  9033. #if defined( RE_IndirectDiffuse )
  9034. vec3 iblIrradiance = vec3( 0.0 );
  9035. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  9036. irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
  9037. #if ( NUM_HEMI_LIGHTS > 0 )
  9038. #pragma unroll_loop_start
  9039. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  9040. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
  9041. }
  9042. #pragma unroll_loop_end
  9043. #endif
  9044. #endif
  9045. #if defined( RE_IndirectSpecular )
  9046. vec3 radiance = vec3( 0.0 );
  9047. vec3 clearcoatRadiance = vec3( 0.0 );
  9048. #endif`,
  9049. bC = `#if defined( RE_IndirectDiffuse )
  9050. #ifdef USE_LIGHTMAP
  9051. vec4 lightMapTexel = texture2D( lightMap, vUv2 );
  9052. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  9053. irradiance += lightMapIrradiance;
  9054. #endif
  9055. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  9056. iblIrradiance += getIBLIrradiance( geometry.normal );
  9057. #endif
  9058. #endif
  9059. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  9060. radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
  9061. #ifdef USE_CLEARCOAT
  9062. clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
  9063. #endif
  9064. #endif`,
  9065. wC = `#if defined( RE_IndirectDiffuse )
  9066. RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
  9067. #endif
  9068. #if defined( RE_IndirectSpecular )
  9069. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
  9070. #endif`,
  9071. _C = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  9072. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  9073. #endif`,
  9074. AC = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  9075. uniform float logDepthBufFC;
  9076. varying float vFragDepth;
  9077. varying float vIsPerspective;
  9078. #endif`,
  9079. SC = `#ifdef USE_LOGDEPTHBUF
  9080. #ifdef USE_LOGDEPTHBUF_EXT
  9081. varying float vFragDepth;
  9082. varying float vIsPerspective;
  9083. #else
  9084. uniform float logDepthBufFC;
  9085. #endif
  9086. #endif`,
  9087. MC = `#ifdef USE_LOGDEPTHBUF
  9088. #ifdef USE_LOGDEPTHBUF_EXT
  9089. vFragDepth = 1.0 + gl_Position.w;
  9090. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  9091. #else
  9092. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  9093. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  9094. gl_Position.z *= gl_Position.w;
  9095. }
  9096. #endif
  9097. #endif`,
  9098. EC = `#ifdef USE_MAP
  9099. vec4 sampledDiffuseColor = texture2D( map, vUv );
  9100. #ifdef DECODE_VIDEO_TEXTURE
  9101. 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 );
  9102. #endif
  9103. diffuseColor *= sampledDiffuseColor;
  9104. #endif`,
  9105. CC = `#ifdef USE_MAP
  9106. uniform sampler2D map;
  9107. #endif`,
  9108. TC = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  9109. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  9110. #endif
  9111. #ifdef USE_MAP
  9112. diffuseColor *= texture2D( map, uv );
  9113. #endif
  9114. #ifdef USE_ALPHAMAP
  9115. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  9116. #endif`,
  9117. PC = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  9118. uniform mat3 uvTransform;
  9119. #endif
  9120. #ifdef USE_MAP
  9121. uniform sampler2D map;
  9122. #endif
  9123. #ifdef USE_ALPHAMAP
  9124. uniform sampler2D alphaMap;
  9125. #endif`,
  9126. DC = `float metalnessFactor = metalness;
  9127. #ifdef USE_METALNESSMAP
  9128. vec4 texelMetalness = texture2D( metalnessMap, vUv );
  9129. metalnessFactor *= texelMetalness.b;
  9130. #endif`,
  9131. LC = `#ifdef USE_METALNESSMAP
  9132. uniform sampler2D metalnessMap;
  9133. #endif`,
  9134. OC = `#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  9135. vColor *= morphTargetBaseInfluence;
  9136. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  9137. #if defined( USE_COLOR_ALPHA )
  9138. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  9139. #elif defined( USE_COLOR )
  9140. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  9141. #endif
  9142. }
  9143. #endif`,
  9144. IC = `#ifdef USE_MORPHNORMALS
  9145. objectNormal *= morphTargetBaseInfluence;
  9146. #ifdef MORPHTARGETS_TEXTURE
  9147. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  9148. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  9149. }
  9150. #else
  9151. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  9152. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  9153. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  9154. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  9155. #endif
  9156. #endif`,
  9157. RC = `#ifdef USE_MORPHTARGETS
  9158. uniform float morphTargetBaseInfluence;
  9159. #ifdef MORPHTARGETS_TEXTURE
  9160. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  9161. uniform sampler2DArray morphTargetsTexture;
  9162. uniform ivec2 morphTargetsTextureSize;
  9163. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  9164. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  9165. int y = texelIndex / morphTargetsTextureSize.x;
  9166. int x = texelIndex - y * morphTargetsTextureSize.x;
  9167. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  9168. return texelFetch( morphTargetsTexture, morphUV, 0 );
  9169. }
  9170. #else
  9171. #ifndef USE_MORPHNORMALS
  9172. uniform float morphTargetInfluences[ 8 ];
  9173. #else
  9174. uniform float morphTargetInfluences[ 4 ];
  9175. #endif
  9176. #endif
  9177. #endif`,
  9178. BC = `#ifdef USE_MORPHTARGETS
  9179. transformed *= morphTargetBaseInfluence;
  9180. #ifdef MORPHTARGETS_TEXTURE
  9181. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  9182. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  9183. }
  9184. #else
  9185. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  9186. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  9187. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  9188. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  9189. #ifndef USE_MORPHNORMALS
  9190. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  9191. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  9192. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  9193. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  9194. #endif
  9195. #endif
  9196. #endif`,
  9197. zC = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  9198. #ifdef FLAT_SHADED
  9199. vec3 fdx = dFdx( vViewPosition );
  9200. vec3 fdy = dFdy( vViewPosition );
  9201. vec3 normal = normalize( cross( fdx, fdy ) );
  9202. #else
  9203. vec3 normal = normalize( vNormal );
  9204. #ifdef DOUBLE_SIDED
  9205. normal = normal * faceDirection;
  9206. #endif
  9207. #ifdef USE_TANGENT
  9208. vec3 tangent = normalize( vTangent );
  9209. vec3 bitangent = normalize( vBitangent );
  9210. #ifdef DOUBLE_SIDED
  9211. tangent = tangent * faceDirection;
  9212. bitangent = bitangent * faceDirection;
  9213. #endif
  9214. #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
  9215. mat3 vTBN = mat3( tangent, bitangent, normal );
  9216. #endif
  9217. #endif
  9218. #endif
  9219. vec3 geometryNormal = normal;`,
  9220. NC = `#ifdef OBJECTSPACE_NORMALMAP
  9221. normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
  9222. #ifdef FLIP_SIDED
  9223. normal = - normal;
  9224. #endif
  9225. #ifdef DOUBLE_SIDED
  9226. normal = normal * faceDirection;
  9227. #endif
  9228. normal = normalize( normalMatrix * normal );
  9229. #elif defined( TANGENTSPACE_NORMALMAP )
  9230. vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
  9231. mapN.xy *= normalScale;
  9232. #ifdef USE_TANGENT
  9233. normal = normalize( vTBN * mapN );
  9234. #else
  9235. normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );
  9236. #endif
  9237. #elif defined( USE_BUMPMAP )
  9238. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  9239. #endif`,
  9240. UC = `#ifndef FLAT_SHADED
  9241. varying vec3 vNormal;
  9242. #ifdef USE_TANGENT
  9243. varying vec3 vTangent;
  9244. varying vec3 vBitangent;
  9245. #endif
  9246. #endif`,
  9247. FC = `#ifndef FLAT_SHADED
  9248. varying vec3 vNormal;
  9249. #ifdef USE_TANGENT
  9250. varying vec3 vTangent;
  9251. varying vec3 vBitangent;
  9252. #endif
  9253. #endif`,
  9254. kC = `#ifndef FLAT_SHADED
  9255. vNormal = normalize( transformedNormal );
  9256. #ifdef USE_TANGENT
  9257. vTangent = normalize( transformedTangent );
  9258. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  9259. #endif
  9260. #endif`,
  9261. jC = `#ifdef USE_NORMALMAP
  9262. uniform sampler2D normalMap;
  9263. uniform vec2 normalScale;
  9264. #endif
  9265. #ifdef OBJECTSPACE_NORMALMAP
  9266. uniform mat3 normalMatrix;
  9267. #endif
  9268. #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
  9269. vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
  9270. vec3 q0 = dFdx( eye_pos.xyz );
  9271. vec3 q1 = dFdy( eye_pos.xyz );
  9272. vec2 st0 = dFdx( vUv.st );
  9273. vec2 st1 = dFdy( vUv.st );
  9274. vec3 N = surf_norm;
  9275. vec3 q1perp = cross( q1, N );
  9276. vec3 q0perp = cross( N, q0 );
  9277. vec3 T = q1perp * st0.x + q0perp * st1.x;
  9278. vec3 B = q1perp * st0.y + q0perp * st1.y;
  9279. float det = max( dot( T, T ), dot( B, B ) );
  9280. float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );
  9281. return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );
  9282. }
  9283. #endif`,
  9284. GC = `#ifdef USE_CLEARCOAT
  9285. vec3 clearcoatNormal = geometryNormal;
  9286. #endif`,
  9287. VC = `#ifdef USE_CLEARCOAT_NORMALMAP
  9288. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
  9289. clearcoatMapN.xy *= clearcoatNormalScale;
  9290. #ifdef USE_TANGENT
  9291. clearcoatNormal = normalize( vTBN * clearcoatMapN );
  9292. #else
  9293. clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );
  9294. #endif
  9295. #endif`,
  9296. HC = `#ifdef USE_CLEARCOATMAP
  9297. uniform sampler2D clearcoatMap;
  9298. #endif
  9299. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  9300. uniform sampler2D clearcoatRoughnessMap;
  9301. #endif
  9302. #ifdef USE_CLEARCOAT_NORMALMAP
  9303. uniform sampler2D clearcoatNormalMap;
  9304. uniform vec2 clearcoatNormalScale;
  9305. #endif`,
  9306. WC = `#ifdef USE_IRIDESCENCEMAP
  9307. uniform sampler2D iridescenceMap;
  9308. #endif
  9309. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  9310. uniform sampler2D iridescenceThicknessMap;
  9311. #endif`,
  9312. XC = `#ifdef OPAQUE
  9313. diffuseColor.a = 1.0;
  9314. #endif
  9315. #ifdef USE_TRANSMISSION
  9316. diffuseColor.a *= material.transmissionAlpha + 0.1;
  9317. #endif
  9318. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,
  9319. qC = `vec3 packNormalToRGB( const in vec3 normal ) {
  9320. return normalize( normal ) * 0.5 + 0.5;
  9321. }
  9322. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  9323. return 2.0 * rgb.xyz - 1.0;
  9324. }
  9325. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  9326. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  9327. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  9328. const float ShiftRight8 = 1. / 256.;
  9329. vec4 packDepthToRGBA( const in float v ) {
  9330. vec4 r = vec4( fract( v * PackFactors ), v );
  9331. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  9332. }
  9333. float unpackRGBAToDepth( const in vec4 v ) {
  9334. return dot( v, UnpackFactors );
  9335. }
  9336. vec2 packDepthToRG( in highp float v ) {
  9337. return packDepthToRGBA( v ).yx;
  9338. }
  9339. float unpackRGToDepth( const in highp vec2 v ) {
  9340. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  9341. }
  9342. vec4 pack2HalfToRGBA( vec2 v ) {
  9343. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  9344. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  9345. }
  9346. vec2 unpackRGBATo2Half( vec4 v ) {
  9347. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  9348. }
  9349. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  9350. return ( viewZ + near ) / ( near - far );
  9351. }
  9352. float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
  9353. return linearClipZ * ( near - far ) - near;
  9354. }
  9355. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  9356. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  9357. }
  9358. float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
  9359. return ( near * far ) / ( ( far - near ) * invClipZ - far );
  9360. }`,
  9361. YC = `#ifdef PREMULTIPLIED_ALPHA
  9362. gl_FragColor.rgb *= gl_FragColor.a;
  9363. #endif`,
  9364. QC = `vec4 mvPosition = vec4( transformed, 1.0 );
  9365. #ifdef USE_INSTANCING
  9366. mvPosition = instanceMatrix * mvPosition;
  9367. #endif
  9368. mvPosition = modelViewMatrix * mvPosition;
  9369. gl_Position = projectionMatrix * mvPosition;`,
  9370. ZC = `#ifdef DITHERING
  9371. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  9372. #endif`,
  9373. KC = `#ifdef DITHERING
  9374. vec3 dithering( vec3 color ) {
  9375. float grid_position = rand( gl_FragCoord.xy );
  9376. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  9377. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  9378. return color + dither_shift_RGB;
  9379. }
  9380. #endif`,
  9381. JC = `float roughnessFactor = roughness;
  9382. #ifdef USE_ROUGHNESSMAP
  9383. vec4 texelRoughness = texture2D( roughnessMap, vUv );
  9384. roughnessFactor *= texelRoughness.g;
  9385. #endif`,
  9386. $C = `#ifdef USE_ROUGHNESSMAP
  9387. uniform sampler2D roughnessMap;
  9388. #endif`,
  9389. eT = `#if NUM_SPOT_LIGHT_COORDS > 0
  9390. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  9391. #endif
  9392. #if NUM_SPOT_LIGHT_MAPS > 0
  9393. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  9394. #endif
  9395. #ifdef USE_SHADOWMAP
  9396. #if NUM_DIR_LIGHT_SHADOWS > 0
  9397. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  9398. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  9399. struct DirectionalLightShadow {
  9400. float shadowBias;
  9401. float shadowNormalBias;
  9402. float shadowRadius;
  9403. vec2 shadowMapSize;
  9404. };
  9405. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  9406. #endif
  9407. #if NUM_SPOT_LIGHT_SHADOWS > 0
  9408. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  9409. struct SpotLightShadow {
  9410. float shadowBias;
  9411. float shadowNormalBias;
  9412. float shadowRadius;
  9413. vec2 shadowMapSize;
  9414. };
  9415. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  9416. #endif
  9417. #if NUM_POINT_LIGHT_SHADOWS > 0
  9418. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  9419. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  9420. struct PointLightShadow {
  9421. float shadowBias;
  9422. float shadowNormalBias;
  9423. float shadowRadius;
  9424. vec2 shadowMapSize;
  9425. float shadowCameraNear;
  9426. float shadowCameraFar;
  9427. };
  9428. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  9429. #endif
  9430. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  9431. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  9432. }
  9433. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  9434. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  9435. }
  9436. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  9437. float occlusion = 1.0;
  9438. vec2 distribution = texture2DDistribution( shadow, uv );
  9439. float hard_shadow = step( compare , distribution.x );
  9440. if (hard_shadow != 1.0 ) {
  9441. float distance = compare - distribution.x ;
  9442. float variance = max( 0.00000, distribution.y * distribution.y );
  9443. 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 );
  9444. }
  9445. return occlusion;
  9446. }
  9447. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  9448. float shadow = 1.0;
  9449. shadowCoord.xyz /= shadowCoord.w;
  9450. shadowCoord.z += shadowBias;
  9451. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  9452. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  9453. if ( frustumTest ) {
  9454. #if defined( SHADOWMAP_TYPE_PCF )
  9455. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  9456. float dx0 = - texelSize.x * shadowRadius;
  9457. float dy0 = - texelSize.y * shadowRadius;
  9458. float dx1 = + texelSize.x * shadowRadius;
  9459. float dy1 = + texelSize.y * shadowRadius;
  9460. float dx2 = dx0 / 2.0;
  9461. float dy2 = dy0 / 2.0;
  9462. float dx3 = dx1 / 2.0;
  9463. float dy3 = dy1 / 2.0;
  9464. shadow = (
  9465. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  9466. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  9467. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  9468. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  9469. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  9470. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  9471. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  9472. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  9473. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  9474. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  9475. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  9476. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  9477. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  9478. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  9479. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  9480. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  9481. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  9482. ) * ( 1.0 / 17.0 );
  9483. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  9484. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  9485. float dx = texelSize.x;
  9486. float dy = texelSize.y;
  9487. vec2 uv = shadowCoord.xy;
  9488. vec2 f = fract( uv * shadowMapSize + 0.5 );
  9489. uv -= f * texelSize;
  9490. shadow = (
  9491. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  9492. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  9493. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  9494. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  9495. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  9496. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  9497. f.x ) +
  9498. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  9499. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  9500. f.x ) +
  9501. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  9502. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  9503. f.y ) +
  9504. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  9505. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  9506. f.y ) +
  9507. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  9508. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  9509. f.x ),
  9510. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  9511. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  9512. f.x ),
  9513. f.y )
  9514. ) * ( 1.0 / 9.0 );
  9515. #elif defined( SHADOWMAP_TYPE_VSM )
  9516. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  9517. #else
  9518. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  9519. #endif
  9520. }
  9521. return shadow;
  9522. }
  9523. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  9524. vec3 absV = abs( v );
  9525. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  9526. absV *= scaleToCube;
  9527. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  9528. vec2 planar = v.xy;
  9529. float almostATexel = 1.5 * texelSizeY;
  9530. float almostOne = 1.0 - almostATexel;
  9531. if ( absV.z >= almostOne ) {
  9532. if ( v.z > 0.0 )
  9533. planar.x = 4.0 - v.x;
  9534. } else if ( absV.x >= almostOne ) {
  9535. float signX = sign( v.x );
  9536. planar.x = v.z * signX + 2.0 * signX;
  9537. } else if ( absV.y >= almostOne ) {
  9538. float signY = sign( v.y );
  9539. planar.x = v.x + 2.0 * signY + 2.0;
  9540. planar.y = v.z * signY - 2.0;
  9541. }
  9542. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  9543. }
  9544. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  9545. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  9546. vec3 lightToPosition = shadowCoord.xyz;
  9547. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  9548. vec3 bd3D = normalize( lightToPosition );
  9549. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  9550. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  9551. return (
  9552. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  9553. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  9554. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  9555. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  9556. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  9557. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  9558. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  9559. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  9560. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  9561. ) * ( 1.0 / 9.0 );
  9562. #else
  9563. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  9564. #endif
  9565. }
  9566. #endif`,
  9567. tT = `#if NUM_SPOT_LIGHT_COORDS > 0
  9568. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  9569. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  9570. #endif
  9571. #ifdef USE_SHADOWMAP
  9572. #if NUM_DIR_LIGHT_SHADOWS > 0
  9573. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  9574. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  9575. struct DirectionalLightShadow {
  9576. float shadowBias;
  9577. float shadowNormalBias;
  9578. float shadowRadius;
  9579. vec2 shadowMapSize;
  9580. };
  9581. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  9582. #endif
  9583. #if NUM_SPOT_LIGHT_SHADOWS > 0
  9584. struct SpotLightShadow {
  9585. float shadowBias;
  9586. float shadowNormalBias;
  9587. float shadowRadius;
  9588. vec2 shadowMapSize;
  9589. };
  9590. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  9591. #endif
  9592. #if NUM_POINT_LIGHT_SHADOWS > 0
  9593. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  9594. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  9595. struct PointLightShadow {
  9596. float shadowBias;
  9597. float shadowNormalBias;
  9598. float shadowRadius;
  9599. vec2 shadowMapSize;
  9600. float shadowCameraNear;
  9601. float shadowCameraFar;
  9602. };
  9603. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  9604. #endif
  9605. #endif`,
  9606. iT = `#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  9607. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  9608. vec4 shadowWorldPosition;
  9609. #endif
  9610. #if defined( USE_SHADOWMAP )
  9611. #if NUM_DIR_LIGHT_SHADOWS > 0
  9612. #pragma unroll_loop_start
  9613. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  9614. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  9615. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  9616. }
  9617. #pragma unroll_loop_end
  9618. #endif
  9619. #if NUM_POINT_LIGHT_SHADOWS > 0
  9620. #pragma unroll_loop_start
  9621. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  9622. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  9623. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  9624. }
  9625. #pragma unroll_loop_end
  9626. #endif
  9627. #endif
  9628. #if NUM_SPOT_LIGHT_COORDS > 0
  9629. #pragma unroll_loop_start
  9630. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  9631. shadowWorldPosition = worldPosition;
  9632. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  9633. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  9634. #endif
  9635. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  9636. }
  9637. #pragma unroll_loop_end
  9638. #endif`,
  9639. rT = `float getShadowMask() {
  9640. float shadow = 1.0;
  9641. #ifdef USE_SHADOWMAP
  9642. #if NUM_DIR_LIGHT_SHADOWS > 0
  9643. DirectionalLightShadow directionalLight;
  9644. #pragma unroll_loop_start
  9645. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  9646. directionalLight = directionalLightShadows[ i ];
  9647. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  9648. }
  9649. #pragma unroll_loop_end
  9650. #endif
  9651. #if NUM_SPOT_LIGHT_SHADOWS > 0
  9652. SpotLightShadow spotLight;
  9653. #pragma unroll_loop_start
  9654. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  9655. spotLight = spotLightShadows[ i ];
  9656. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  9657. }
  9658. #pragma unroll_loop_end
  9659. #endif
  9660. #if NUM_POINT_LIGHT_SHADOWS > 0
  9661. PointLightShadow pointLight;
  9662. #pragma unroll_loop_start
  9663. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  9664. pointLight = pointLightShadows[ i ];
  9665. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  9666. }
  9667. #pragma unroll_loop_end
  9668. #endif
  9669. #endif
  9670. return shadow;
  9671. }`,
  9672. sT = `#ifdef USE_SKINNING
  9673. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  9674. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  9675. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  9676. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  9677. #endif`,
  9678. nT = `#ifdef USE_SKINNING
  9679. uniform mat4 bindMatrix;
  9680. uniform mat4 bindMatrixInverse;
  9681. uniform highp sampler2D boneTexture;
  9682. uniform int boneTextureSize;
  9683. mat4 getBoneMatrix( const in float i ) {
  9684. float j = i * 4.0;
  9685. float x = mod( j, float( boneTextureSize ) );
  9686. float y = floor( j / float( boneTextureSize ) );
  9687. float dx = 1.0 / float( boneTextureSize );
  9688. float dy = 1.0 / float( boneTextureSize );
  9689. y = dy * ( y + 0.5 );
  9690. vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
  9691. vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
  9692. vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
  9693. vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
  9694. mat4 bone = mat4( v1, v2, v3, v4 );
  9695. return bone;
  9696. }
  9697. #endif`,
  9698. aT = `#ifdef USE_SKINNING
  9699. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  9700. vec4 skinned = vec4( 0.0 );
  9701. skinned += boneMatX * skinVertex * skinWeight.x;
  9702. skinned += boneMatY * skinVertex * skinWeight.y;
  9703. skinned += boneMatZ * skinVertex * skinWeight.z;
  9704. skinned += boneMatW * skinVertex * skinWeight.w;
  9705. transformed = ( bindMatrixInverse * skinned ).xyz;
  9706. #endif`,
  9707. oT = `#ifdef USE_SKINNING
  9708. mat4 skinMatrix = mat4( 0.0 );
  9709. skinMatrix += skinWeight.x * boneMatX;
  9710. skinMatrix += skinWeight.y * boneMatY;
  9711. skinMatrix += skinWeight.z * boneMatZ;
  9712. skinMatrix += skinWeight.w * boneMatW;
  9713. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  9714. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  9715. #ifdef USE_TANGENT
  9716. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  9717. #endif
  9718. #endif`,
  9719. lT = `float specularStrength;
  9720. #ifdef USE_SPECULARMAP
  9721. vec4 texelSpecular = texture2D( specularMap, vUv );
  9722. specularStrength = texelSpecular.r;
  9723. #else
  9724. specularStrength = 1.0;
  9725. #endif`,
  9726. hT = `#ifdef USE_SPECULARMAP
  9727. uniform sampler2D specularMap;
  9728. #endif`,
  9729. cT = `#if defined( TONE_MAPPING )
  9730. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  9731. #endif`,
  9732. dT = `#ifndef saturate
  9733. #define saturate( a ) clamp( a, 0.0, 1.0 )
  9734. #endif
  9735. uniform float toneMappingExposure;
  9736. vec3 LinearToneMapping( vec3 color ) {
  9737. return toneMappingExposure * color;
  9738. }
  9739. vec3 ReinhardToneMapping( vec3 color ) {
  9740. color *= toneMappingExposure;
  9741. return saturate( color / ( vec3( 1.0 ) + color ) );
  9742. }
  9743. vec3 OptimizedCineonToneMapping( vec3 color ) {
  9744. color *= toneMappingExposure;
  9745. color = max( vec3( 0.0 ), color - 0.004 );
  9746. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  9747. }
  9748. vec3 RRTAndODTFit( vec3 v ) {
  9749. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  9750. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  9751. return a / b;
  9752. }
  9753. vec3 ACESFilmicToneMapping( vec3 color ) {
  9754. const mat3 ACESInputMat = mat3(
  9755. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  9756. vec3( 0.04823, 0.01566, 0.83777 )
  9757. );
  9758. const mat3 ACESOutputMat = mat3(
  9759. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  9760. vec3( -0.07367, -0.00605, 1.07602 )
  9761. );
  9762. color *= toneMappingExposure / 0.6;
  9763. color = ACESInputMat * color;
  9764. color = RRTAndODTFit( color );
  9765. color = ACESOutputMat * color;
  9766. return saturate( color );
  9767. }
  9768. vec3 CustomToneMapping( vec3 color ) { return color; }`,
  9769. uT = `#ifdef USE_TRANSMISSION
  9770. material.transmission = transmission;
  9771. material.transmissionAlpha = 1.0;
  9772. material.thickness = thickness;
  9773. material.attenuationDistance = attenuationDistance;
  9774. material.attenuationColor = attenuationColor;
  9775. #ifdef USE_TRANSMISSIONMAP
  9776. material.transmission *= texture2D( transmissionMap, vUv ).r;
  9777. #endif
  9778. #ifdef USE_THICKNESSMAP
  9779. material.thickness *= texture2D( thicknessMap, vUv ).g;
  9780. #endif
  9781. vec3 pos = vWorldPosition;
  9782. vec3 v = normalize( cameraPosition - pos );
  9783. vec3 n = inverseTransformDirection( normal, viewMatrix );
  9784. vec4 transmission = getIBLVolumeRefraction(
  9785. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  9786. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  9787. material.attenuationColor, material.attenuationDistance );
  9788. material.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );
  9789. totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );
  9790. #endif`,
  9791. pT = `#ifdef USE_TRANSMISSION
  9792. uniform float transmission;
  9793. uniform float thickness;
  9794. uniform float attenuationDistance;
  9795. uniform vec3 attenuationColor;
  9796. #ifdef USE_TRANSMISSIONMAP
  9797. uniform sampler2D transmissionMap;
  9798. #endif
  9799. #ifdef USE_THICKNESSMAP
  9800. uniform sampler2D thicknessMap;
  9801. #endif
  9802. uniform vec2 transmissionSamplerSize;
  9803. uniform sampler2D transmissionSamplerMap;
  9804. uniform mat4 modelMatrix;
  9805. uniform mat4 projectionMatrix;
  9806. varying vec3 vWorldPosition;
  9807. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  9808. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  9809. vec3 modelScale;
  9810. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  9811. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  9812. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  9813. return normalize( refractionVector ) * thickness * modelScale;
  9814. }
  9815. float applyIorToRoughness( const in float roughness, const in float ior ) {
  9816. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  9817. }
  9818. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  9819. float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  9820. #ifdef texture2DLodEXT
  9821. return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );
  9822. #else
  9823. return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );
  9824. #endif
  9825. }
  9826. vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  9827. if ( isinf( attenuationDistance ) ) {
  9828. return radiance;
  9829. } else {
  9830. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  9831. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance;
  9832. }
  9833. }
  9834. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  9835. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  9836. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  9837. const in vec3 attenuationColor, const in float attenuationDistance ) {
  9838. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  9839. vec3 refractedRayExit = position + transmissionRay;
  9840. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  9841. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  9842. refractionCoords += 1.0;
  9843. refractionCoords /= 2.0;
  9844. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  9845. vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );
  9846. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  9847. return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );
  9848. }
  9849. #endif`,
  9850. fT = `#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
  9851. varying vec2 vUv;
  9852. #endif`,
  9853. mT = `#ifdef USE_UV
  9854. #ifdef UVS_VERTEX_ONLY
  9855. vec2 vUv;
  9856. #else
  9857. varying vec2 vUv;
  9858. #endif
  9859. uniform mat3 uvTransform;
  9860. #endif`,
  9861. gT = `#ifdef USE_UV
  9862. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  9863. #endif`,
  9864. vT = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  9865. varying vec2 vUv2;
  9866. #endif`,
  9867. yT = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  9868. attribute vec2 uv2;
  9869. varying vec2 vUv2;
  9870. uniform mat3 uv2Transform;
  9871. #endif`,
  9872. xT = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
  9873. vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
  9874. #endif`,
  9875. bT = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  9876. vec4 worldPosition = vec4( transformed, 1.0 );
  9877. #ifdef USE_INSTANCING
  9878. worldPosition = instanceMatrix * worldPosition;
  9879. #endif
  9880. worldPosition = modelMatrix * worldPosition;
  9881. #endif`,
  9882. wT = `varying vec2 vUv;
  9883. uniform mat3 uvTransform;
  9884. void main() {
  9885. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  9886. gl_Position = vec4( position.xy, 1.0, 1.0 );
  9887. }`,
  9888. _T = `uniform sampler2D t2D;
  9889. uniform float backgroundIntensity;
  9890. varying vec2 vUv;
  9891. void main() {
  9892. vec4 texColor = texture2D( t2D, vUv );
  9893. #ifdef DECODE_VIDEO_TEXTURE
  9894. 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 );
  9895. #endif
  9896. texColor.rgb *= backgroundIntensity;
  9897. gl_FragColor = texColor;
  9898. #include <tonemapping_fragment>
  9899. #include <encodings_fragment>
  9900. }`,
  9901. AT = `varying vec3 vWorldDirection;
  9902. #include <common>
  9903. void main() {
  9904. vWorldDirection = transformDirection( position, modelMatrix );
  9905. #include <begin_vertex>
  9906. #include <project_vertex>
  9907. gl_Position.z = gl_Position.w;
  9908. }`,
  9909. ST = `#ifdef ENVMAP_TYPE_CUBE
  9910. uniform samplerCube envMap;
  9911. #elif defined( ENVMAP_TYPE_CUBE_UV )
  9912. uniform sampler2D envMap;
  9913. #endif
  9914. uniform float flipEnvMap;
  9915. uniform float backgroundBlurriness;
  9916. uniform float backgroundIntensity;
  9917. varying vec3 vWorldDirection;
  9918. #include <cube_uv_reflection_fragment>
  9919. void main() {
  9920. #ifdef ENVMAP_TYPE_CUBE
  9921. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  9922. #elif defined( ENVMAP_TYPE_CUBE_UV )
  9923. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  9924. #else
  9925. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  9926. #endif
  9927. texColor.rgb *= backgroundIntensity;
  9928. gl_FragColor = texColor;
  9929. #include <tonemapping_fragment>
  9930. #include <encodings_fragment>
  9931. }`,
  9932. MT = `varying vec3 vWorldDirection;
  9933. #include <common>
  9934. void main() {
  9935. vWorldDirection = transformDirection( position, modelMatrix );
  9936. #include <begin_vertex>
  9937. #include <project_vertex>
  9938. gl_Position.z = gl_Position.w;
  9939. }`,
  9940. ET = `uniform samplerCube tCube;
  9941. uniform float tFlip;
  9942. uniform float opacity;
  9943. varying vec3 vWorldDirection;
  9944. void main() {
  9945. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  9946. gl_FragColor = texColor;
  9947. gl_FragColor.a *= opacity;
  9948. #include <tonemapping_fragment>
  9949. #include <encodings_fragment>
  9950. }`,
  9951. CT = `#include <common>
  9952. #include <uv_pars_vertex>
  9953. #include <displacementmap_pars_vertex>
  9954. #include <morphtarget_pars_vertex>
  9955. #include <skinning_pars_vertex>
  9956. #include <logdepthbuf_pars_vertex>
  9957. #include <clipping_planes_pars_vertex>
  9958. varying vec2 vHighPrecisionZW;
  9959. void main() {
  9960. #include <uv_vertex>
  9961. #include <skinbase_vertex>
  9962. #ifdef USE_DISPLACEMENTMAP
  9963. #include <beginnormal_vertex>
  9964. #include <morphnormal_vertex>
  9965. #include <skinnormal_vertex>
  9966. #endif
  9967. #include <begin_vertex>
  9968. #include <morphtarget_vertex>
  9969. #include <skinning_vertex>
  9970. #include <displacementmap_vertex>
  9971. #include <project_vertex>
  9972. #include <logdepthbuf_vertex>
  9973. #include <clipping_planes_vertex>
  9974. vHighPrecisionZW = gl_Position.zw;
  9975. }`,
  9976. TT = `#if DEPTH_PACKING == 3200
  9977. uniform float opacity;
  9978. #endif
  9979. #include <common>
  9980. #include <packing>
  9981. #include <uv_pars_fragment>
  9982. #include <map_pars_fragment>
  9983. #include <alphamap_pars_fragment>
  9984. #include <alphatest_pars_fragment>
  9985. #include <logdepthbuf_pars_fragment>
  9986. #include <clipping_planes_pars_fragment>
  9987. varying vec2 vHighPrecisionZW;
  9988. void main() {
  9989. #include <clipping_planes_fragment>
  9990. vec4 diffuseColor = vec4( 1.0 );
  9991. #if DEPTH_PACKING == 3200
  9992. diffuseColor.a = opacity;
  9993. #endif
  9994. #include <map_fragment>
  9995. #include <alphamap_fragment>
  9996. #include <alphatest_fragment>
  9997. #include <logdepthbuf_fragment>
  9998. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  9999. #if DEPTH_PACKING == 3200
  10000. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  10001. #elif DEPTH_PACKING == 3201
  10002. gl_FragColor = packDepthToRGBA( fragCoordZ );
  10003. #endif
  10004. }`,
  10005. PT = `#define DISTANCE
  10006. varying vec3 vWorldPosition;
  10007. #include <common>
  10008. #include <uv_pars_vertex>
  10009. #include <displacementmap_pars_vertex>
  10010. #include <morphtarget_pars_vertex>
  10011. #include <skinning_pars_vertex>
  10012. #include <clipping_planes_pars_vertex>
  10013. void main() {
  10014. #include <uv_vertex>
  10015. #include <skinbase_vertex>
  10016. #ifdef USE_DISPLACEMENTMAP
  10017. #include <beginnormal_vertex>
  10018. #include <morphnormal_vertex>
  10019. #include <skinnormal_vertex>
  10020. #endif
  10021. #include <begin_vertex>
  10022. #include <morphtarget_vertex>
  10023. #include <skinning_vertex>
  10024. #include <displacementmap_vertex>
  10025. #include <project_vertex>
  10026. #include <worldpos_vertex>
  10027. #include <clipping_planes_vertex>
  10028. vWorldPosition = worldPosition.xyz;
  10029. }`,
  10030. DT = `#define DISTANCE
  10031. uniform vec3 referencePosition;
  10032. uniform float nearDistance;
  10033. uniform float farDistance;
  10034. varying vec3 vWorldPosition;
  10035. #include <common>
  10036. #include <packing>
  10037. #include <uv_pars_fragment>
  10038. #include <map_pars_fragment>
  10039. #include <alphamap_pars_fragment>
  10040. #include <alphatest_pars_fragment>
  10041. #include <clipping_planes_pars_fragment>
  10042. void main () {
  10043. #include <clipping_planes_fragment>
  10044. vec4 diffuseColor = vec4( 1.0 );
  10045. #include <map_fragment>
  10046. #include <alphamap_fragment>
  10047. #include <alphatest_fragment>
  10048. float dist = length( vWorldPosition - referencePosition );
  10049. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  10050. dist = saturate( dist );
  10051. gl_FragColor = packDepthToRGBA( dist );
  10052. }`,
  10053. LT = `varying vec3 vWorldDirection;
  10054. #include <common>
  10055. void main() {
  10056. vWorldDirection = transformDirection( position, modelMatrix );
  10057. #include <begin_vertex>
  10058. #include <project_vertex>
  10059. }`,
  10060. OT = `uniform sampler2D tEquirect;
  10061. varying vec3 vWorldDirection;
  10062. #include <common>
  10063. void main() {
  10064. vec3 direction = normalize( vWorldDirection );
  10065. vec2 sampleUV = equirectUv( direction );
  10066. gl_FragColor = texture2D( tEquirect, sampleUV );
  10067. #include <tonemapping_fragment>
  10068. #include <encodings_fragment>
  10069. }`,
  10070. IT = `uniform float scale;
  10071. attribute float lineDistance;
  10072. varying float vLineDistance;
  10073. #include <common>
  10074. #include <color_pars_vertex>
  10075. #include <fog_pars_vertex>
  10076. #include <morphtarget_pars_vertex>
  10077. #include <logdepthbuf_pars_vertex>
  10078. #include <clipping_planes_pars_vertex>
  10079. void main() {
  10080. vLineDistance = scale * lineDistance;
  10081. #include <color_vertex>
  10082. #include <morphcolor_vertex>
  10083. #include <begin_vertex>
  10084. #include <morphtarget_vertex>
  10085. #include <project_vertex>
  10086. #include <logdepthbuf_vertex>
  10087. #include <clipping_planes_vertex>
  10088. #include <fog_vertex>
  10089. }`,
  10090. RT = `uniform vec3 diffuse;
  10091. uniform float opacity;
  10092. uniform float dashSize;
  10093. uniform float totalSize;
  10094. varying float vLineDistance;
  10095. #include <common>
  10096. #include <color_pars_fragment>
  10097. #include <fog_pars_fragment>
  10098. #include <logdepthbuf_pars_fragment>
  10099. #include <clipping_planes_pars_fragment>
  10100. void main() {
  10101. #include <clipping_planes_fragment>
  10102. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  10103. discard;
  10104. }
  10105. vec3 outgoingLight = vec3( 0.0 );
  10106. vec4 diffuseColor = vec4( diffuse, opacity );
  10107. #include <logdepthbuf_fragment>
  10108. #include <color_fragment>
  10109. outgoingLight = diffuseColor.rgb;
  10110. #include <output_fragment>
  10111. #include <tonemapping_fragment>
  10112. #include <encodings_fragment>
  10113. #include <fog_fragment>
  10114. #include <premultiplied_alpha_fragment>
  10115. }`,
  10116. BT = `#include <common>
  10117. #include <uv_pars_vertex>
  10118. #include <uv2_pars_vertex>
  10119. #include <envmap_pars_vertex>
  10120. #include <color_pars_vertex>
  10121. #include <fog_pars_vertex>
  10122. #include <morphtarget_pars_vertex>
  10123. #include <skinning_pars_vertex>
  10124. #include <logdepthbuf_pars_vertex>
  10125. #include <clipping_planes_pars_vertex>
  10126. void main() {
  10127. #include <uv_vertex>
  10128. #include <uv2_vertex>
  10129. #include <color_vertex>
  10130. #include <morphcolor_vertex>
  10131. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  10132. #include <beginnormal_vertex>
  10133. #include <morphnormal_vertex>
  10134. #include <skinbase_vertex>
  10135. #include <skinnormal_vertex>
  10136. #include <defaultnormal_vertex>
  10137. #endif
  10138. #include <begin_vertex>
  10139. #include <morphtarget_vertex>
  10140. #include <skinning_vertex>
  10141. #include <project_vertex>
  10142. #include <logdepthbuf_vertex>
  10143. #include <clipping_planes_vertex>
  10144. #include <worldpos_vertex>
  10145. #include <envmap_vertex>
  10146. #include <fog_vertex>
  10147. }`,
  10148. zT = `uniform vec3 diffuse;
  10149. uniform float opacity;
  10150. #ifndef FLAT_SHADED
  10151. varying vec3 vNormal;
  10152. #endif
  10153. #include <common>
  10154. #include <dithering_pars_fragment>
  10155. #include <color_pars_fragment>
  10156. #include <uv_pars_fragment>
  10157. #include <uv2_pars_fragment>
  10158. #include <map_pars_fragment>
  10159. #include <alphamap_pars_fragment>
  10160. #include <alphatest_pars_fragment>
  10161. #include <aomap_pars_fragment>
  10162. #include <lightmap_pars_fragment>
  10163. #include <envmap_common_pars_fragment>
  10164. #include <envmap_pars_fragment>
  10165. #include <fog_pars_fragment>
  10166. #include <specularmap_pars_fragment>
  10167. #include <logdepthbuf_pars_fragment>
  10168. #include <clipping_planes_pars_fragment>
  10169. void main() {
  10170. #include <clipping_planes_fragment>
  10171. vec4 diffuseColor = vec4( diffuse, opacity );
  10172. #include <logdepthbuf_fragment>
  10173. #include <map_fragment>
  10174. #include <color_fragment>
  10175. #include <alphamap_fragment>
  10176. #include <alphatest_fragment>
  10177. #include <specularmap_fragment>
  10178. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  10179. #ifdef USE_LIGHTMAP
  10180. vec4 lightMapTexel = texture2D( lightMap, vUv2 );
  10181. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  10182. #else
  10183. reflectedLight.indirectDiffuse += vec3( 1.0 );
  10184. #endif
  10185. #include <aomap_fragment>
  10186. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  10187. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  10188. #include <envmap_fragment>
  10189. #include <output_fragment>
  10190. #include <tonemapping_fragment>
  10191. #include <encodings_fragment>
  10192. #include <fog_fragment>
  10193. #include <premultiplied_alpha_fragment>
  10194. #include <dithering_fragment>
  10195. }`,
  10196. NT = `#define LAMBERT
  10197. varying vec3 vViewPosition;
  10198. #include <common>
  10199. #include <uv_pars_vertex>
  10200. #include <uv2_pars_vertex>
  10201. #include <displacementmap_pars_vertex>
  10202. #include <envmap_pars_vertex>
  10203. #include <color_pars_vertex>
  10204. #include <fog_pars_vertex>
  10205. #include <normal_pars_vertex>
  10206. #include <morphtarget_pars_vertex>
  10207. #include <skinning_pars_vertex>
  10208. #include <shadowmap_pars_vertex>
  10209. #include <logdepthbuf_pars_vertex>
  10210. #include <clipping_planes_pars_vertex>
  10211. void main() {
  10212. #include <uv_vertex>
  10213. #include <uv2_vertex>
  10214. #include <color_vertex>
  10215. #include <morphcolor_vertex>
  10216. #include <beginnormal_vertex>
  10217. #include <morphnormal_vertex>
  10218. #include <skinbase_vertex>
  10219. #include <skinnormal_vertex>
  10220. #include <defaultnormal_vertex>
  10221. #include <normal_vertex>
  10222. #include <begin_vertex>
  10223. #include <morphtarget_vertex>
  10224. #include <skinning_vertex>
  10225. #include <displacementmap_vertex>
  10226. #include <project_vertex>
  10227. #include <logdepthbuf_vertex>
  10228. #include <clipping_planes_vertex>
  10229. vViewPosition = - mvPosition.xyz;
  10230. #include <worldpos_vertex>
  10231. #include <envmap_vertex>
  10232. #include <shadowmap_vertex>
  10233. #include <fog_vertex>
  10234. }`,
  10235. UT = `#define LAMBERT
  10236. uniform vec3 diffuse;
  10237. uniform vec3 emissive;
  10238. uniform float opacity;
  10239. #include <common>
  10240. #include <packing>
  10241. #include <dithering_pars_fragment>
  10242. #include <color_pars_fragment>
  10243. #include <uv_pars_fragment>
  10244. #include <uv2_pars_fragment>
  10245. #include <map_pars_fragment>
  10246. #include <alphamap_pars_fragment>
  10247. #include <alphatest_pars_fragment>
  10248. #include <aomap_pars_fragment>
  10249. #include <lightmap_pars_fragment>
  10250. #include <emissivemap_pars_fragment>
  10251. #include <envmap_common_pars_fragment>
  10252. #include <envmap_pars_fragment>
  10253. #include <fog_pars_fragment>
  10254. #include <bsdfs>
  10255. #include <lights_pars_begin>
  10256. #include <normal_pars_fragment>
  10257. #include <lights_lambert_pars_fragment>
  10258. #include <shadowmap_pars_fragment>
  10259. #include <bumpmap_pars_fragment>
  10260. #include <normalmap_pars_fragment>
  10261. #include <specularmap_pars_fragment>
  10262. #include <logdepthbuf_pars_fragment>
  10263. #include <clipping_planes_pars_fragment>
  10264. void main() {
  10265. #include <clipping_planes_fragment>
  10266. vec4 diffuseColor = vec4( diffuse, opacity );
  10267. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  10268. vec3 totalEmissiveRadiance = emissive;
  10269. #include <logdepthbuf_fragment>
  10270. #include <map_fragment>
  10271. #include <color_fragment>
  10272. #include <alphamap_fragment>
  10273. #include <alphatest_fragment>
  10274. #include <specularmap_fragment>
  10275. #include <normal_fragment_begin>
  10276. #include <normal_fragment_maps>
  10277. #include <emissivemap_fragment>
  10278. #include <lights_lambert_fragment>
  10279. #include <lights_fragment_begin>
  10280. #include <lights_fragment_maps>
  10281. #include <lights_fragment_end>
  10282. #include <aomap_fragment>
  10283. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  10284. #include <envmap_fragment>
  10285. #include <output_fragment>
  10286. #include <tonemapping_fragment>
  10287. #include <encodings_fragment>
  10288. #include <fog_fragment>
  10289. #include <premultiplied_alpha_fragment>
  10290. #include <dithering_fragment>
  10291. }`,
  10292. FT = `#define MATCAP
  10293. varying vec3 vViewPosition;
  10294. #include <common>
  10295. #include <uv_pars_vertex>
  10296. #include <color_pars_vertex>
  10297. #include <displacementmap_pars_vertex>
  10298. #include <fog_pars_vertex>
  10299. #include <normal_pars_vertex>
  10300. #include <morphtarget_pars_vertex>
  10301. #include <skinning_pars_vertex>
  10302. #include <logdepthbuf_pars_vertex>
  10303. #include <clipping_planes_pars_vertex>
  10304. void main() {
  10305. #include <uv_vertex>
  10306. #include <color_vertex>
  10307. #include <morphcolor_vertex>
  10308. #include <beginnormal_vertex>
  10309. #include <morphnormal_vertex>
  10310. #include <skinbase_vertex>
  10311. #include <skinnormal_vertex>
  10312. #include <defaultnormal_vertex>
  10313. #include <normal_vertex>
  10314. #include <begin_vertex>
  10315. #include <morphtarget_vertex>
  10316. #include <skinning_vertex>
  10317. #include <displacementmap_vertex>
  10318. #include <project_vertex>
  10319. #include <logdepthbuf_vertex>
  10320. #include <clipping_planes_vertex>
  10321. #include <fog_vertex>
  10322. vViewPosition = - mvPosition.xyz;
  10323. }`,
  10324. kT = `#define MATCAP
  10325. uniform vec3 diffuse;
  10326. uniform float opacity;
  10327. uniform sampler2D matcap;
  10328. varying vec3 vViewPosition;
  10329. #include <common>
  10330. #include <dithering_pars_fragment>
  10331. #include <color_pars_fragment>
  10332. #include <uv_pars_fragment>
  10333. #include <map_pars_fragment>
  10334. #include <alphamap_pars_fragment>
  10335. #include <alphatest_pars_fragment>
  10336. #include <fog_pars_fragment>
  10337. #include <normal_pars_fragment>
  10338. #include <bumpmap_pars_fragment>
  10339. #include <normalmap_pars_fragment>
  10340. #include <logdepthbuf_pars_fragment>
  10341. #include <clipping_planes_pars_fragment>
  10342. void main() {
  10343. #include <clipping_planes_fragment>
  10344. vec4 diffuseColor = vec4( diffuse, opacity );
  10345. #include <logdepthbuf_fragment>
  10346. #include <map_fragment>
  10347. #include <color_fragment>
  10348. #include <alphamap_fragment>
  10349. #include <alphatest_fragment>
  10350. #include <normal_fragment_begin>
  10351. #include <normal_fragment_maps>
  10352. vec3 viewDir = normalize( vViewPosition );
  10353. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  10354. vec3 y = cross( viewDir, x );
  10355. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  10356. #ifdef USE_MATCAP
  10357. vec4 matcapColor = texture2D( matcap, uv );
  10358. #else
  10359. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  10360. #endif
  10361. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  10362. #include <output_fragment>
  10363. #include <tonemapping_fragment>
  10364. #include <encodings_fragment>
  10365. #include <fog_fragment>
  10366. #include <premultiplied_alpha_fragment>
  10367. #include <dithering_fragment>
  10368. }`,
  10369. jT = `#define NORMAL
  10370. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  10371. varying vec3 vViewPosition;
  10372. #endif
  10373. #include <common>
  10374. #include <uv_pars_vertex>
  10375. #include <displacementmap_pars_vertex>
  10376. #include <normal_pars_vertex>
  10377. #include <morphtarget_pars_vertex>
  10378. #include <skinning_pars_vertex>
  10379. #include <logdepthbuf_pars_vertex>
  10380. #include <clipping_planes_pars_vertex>
  10381. void main() {
  10382. #include <uv_vertex>
  10383. #include <beginnormal_vertex>
  10384. #include <morphnormal_vertex>
  10385. #include <skinbase_vertex>
  10386. #include <skinnormal_vertex>
  10387. #include <defaultnormal_vertex>
  10388. #include <normal_vertex>
  10389. #include <begin_vertex>
  10390. #include <morphtarget_vertex>
  10391. #include <skinning_vertex>
  10392. #include <displacementmap_vertex>
  10393. #include <project_vertex>
  10394. #include <logdepthbuf_vertex>
  10395. #include <clipping_planes_vertex>
  10396. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  10397. vViewPosition = - mvPosition.xyz;
  10398. #endif
  10399. }`,
  10400. GT = `#define NORMAL
  10401. uniform float opacity;
  10402. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
  10403. varying vec3 vViewPosition;
  10404. #endif
  10405. #include <packing>
  10406. #include <uv_pars_fragment>
  10407. #include <normal_pars_fragment>
  10408. #include <bumpmap_pars_fragment>
  10409. #include <normalmap_pars_fragment>
  10410. #include <logdepthbuf_pars_fragment>
  10411. #include <clipping_planes_pars_fragment>
  10412. void main() {
  10413. #include <clipping_planes_fragment>
  10414. #include <logdepthbuf_fragment>
  10415. #include <normal_fragment_begin>
  10416. #include <normal_fragment_maps>
  10417. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  10418. #ifdef OPAQUE
  10419. gl_FragColor.a = 1.0;
  10420. #endif
  10421. }`,
  10422. VT = `#define PHONG
  10423. varying vec3 vViewPosition;
  10424. #include <common>
  10425. #include <uv_pars_vertex>
  10426. #include <uv2_pars_vertex>
  10427. #include <displacementmap_pars_vertex>
  10428. #include <envmap_pars_vertex>
  10429. #include <color_pars_vertex>
  10430. #include <fog_pars_vertex>
  10431. #include <normal_pars_vertex>
  10432. #include <morphtarget_pars_vertex>
  10433. #include <skinning_pars_vertex>
  10434. #include <shadowmap_pars_vertex>
  10435. #include <logdepthbuf_pars_vertex>
  10436. #include <clipping_planes_pars_vertex>
  10437. void main() {
  10438. #include <uv_vertex>
  10439. #include <uv2_vertex>
  10440. #include <color_vertex>
  10441. #include <morphcolor_vertex>
  10442. #include <beginnormal_vertex>
  10443. #include <morphnormal_vertex>
  10444. #include <skinbase_vertex>
  10445. #include <skinnormal_vertex>
  10446. #include <defaultnormal_vertex>
  10447. #include <normal_vertex>
  10448. #include <begin_vertex>
  10449. #include <morphtarget_vertex>
  10450. #include <skinning_vertex>
  10451. #include <displacementmap_vertex>
  10452. #include <project_vertex>
  10453. #include <logdepthbuf_vertex>
  10454. #include <clipping_planes_vertex>
  10455. vViewPosition = - mvPosition.xyz;
  10456. #include <worldpos_vertex>
  10457. #include <envmap_vertex>
  10458. #include <shadowmap_vertex>
  10459. #include <fog_vertex>
  10460. }`,
  10461. HT = `#define PHONG
  10462. uniform vec3 diffuse;
  10463. uniform vec3 emissive;
  10464. uniform vec3 specular;
  10465. uniform float shininess;
  10466. uniform float opacity;
  10467. #include <common>
  10468. #include <packing>
  10469. #include <dithering_pars_fragment>
  10470. #include <color_pars_fragment>
  10471. #include <uv_pars_fragment>
  10472. #include <uv2_pars_fragment>
  10473. #include <map_pars_fragment>
  10474. #include <alphamap_pars_fragment>
  10475. #include <alphatest_pars_fragment>
  10476. #include <aomap_pars_fragment>
  10477. #include <lightmap_pars_fragment>
  10478. #include <emissivemap_pars_fragment>
  10479. #include <envmap_common_pars_fragment>
  10480. #include <envmap_pars_fragment>
  10481. #include <fog_pars_fragment>
  10482. #include <bsdfs>
  10483. #include <lights_pars_begin>
  10484. #include <normal_pars_fragment>
  10485. #include <lights_phong_pars_fragment>
  10486. #include <shadowmap_pars_fragment>
  10487. #include <bumpmap_pars_fragment>
  10488. #include <normalmap_pars_fragment>
  10489. #include <specularmap_pars_fragment>
  10490. #include <logdepthbuf_pars_fragment>
  10491. #include <clipping_planes_pars_fragment>
  10492. void main() {
  10493. #include <clipping_planes_fragment>
  10494. vec4 diffuseColor = vec4( diffuse, opacity );
  10495. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  10496. vec3 totalEmissiveRadiance = emissive;
  10497. #include <logdepthbuf_fragment>
  10498. #include <map_fragment>
  10499. #include <color_fragment>
  10500. #include <alphamap_fragment>
  10501. #include <alphatest_fragment>
  10502. #include <specularmap_fragment>
  10503. #include <normal_fragment_begin>
  10504. #include <normal_fragment_maps>
  10505. #include <emissivemap_fragment>
  10506. #include <lights_phong_fragment>
  10507. #include <lights_fragment_begin>
  10508. #include <lights_fragment_maps>
  10509. #include <lights_fragment_end>
  10510. #include <aomap_fragment>
  10511. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  10512. #include <envmap_fragment>
  10513. #include <output_fragment>
  10514. #include <tonemapping_fragment>
  10515. #include <encodings_fragment>
  10516. #include <fog_fragment>
  10517. #include <premultiplied_alpha_fragment>
  10518. #include <dithering_fragment>
  10519. }`,
  10520. WT = `#define STANDARD
  10521. varying vec3 vViewPosition;
  10522. #ifdef USE_TRANSMISSION
  10523. varying vec3 vWorldPosition;
  10524. #endif
  10525. #include <common>
  10526. #include <uv_pars_vertex>
  10527. #include <uv2_pars_vertex>
  10528. #include <displacementmap_pars_vertex>
  10529. #include <color_pars_vertex>
  10530. #include <fog_pars_vertex>
  10531. #include <normal_pars_vertex>
  10532. #include <morphtarget_pars_vertex>
  10533. #include <skinning_pars_vertex>
  10534. #include <shadowmap_pars_vertex>
  10535. #include <logdepthbuf_pars_vertex>
  10536. #include <clipping_planes_pars_vertex>
  10537. void main() {
  10538. #include <uv_vertex>
  10539. #include <uv2_vertex>
  10540. #include <color_vertex>
  10541. #include <morphcolor_vertex>
  10542. #include <beginnormal_vertex>
  10543. #include <morphnormal_vertex>
  10544. #include <skinbase_vertex>
  10545. #include <skinnormal_vertex>
  10546. #include <defaultnormal_vertex>
  10547. #include <normal_vertex>
  10548. #include <begin_vertex>
  10549. #include <morphtarget_vertex>
  10550. #include <skinning_vertex>
  10551. #include <displacementmap_vertex>
  10552. #include <project_vertex>
  10553. #include <logdepthbuf_vertex>
  10554. #include <clipping_planes_vertex>
  10555. vViewPosition = - mvPosition.xyz;
  10556. #include <worldpos_vertex>
  10557. #include <shadowmap_vertex>
  10558. #include <fog_vertex>
  10559. #ifdef USE_TRANSMISSION
  10560. vWorldPosition = worldPosition.xyz;
  10561. #endif
  10562. }`,
  10563. XT = `#define STANDARD
  10564. #ifdef PHYSICAL
  10565. #define IOR
  10566. #define SPECULAR
  10567. #endif
  10568. uniform vec3 diffuse;
  10569. uniform vec3 emissive;
  10570. uniform float roughness;
  10571. uniform float metalness;
  10572. uniform float opacity;
  10573. #ifdef IOR
  10574. uniform float ior;
  10575. #endif
  10576. #ifdef SPECULAR
  10577. uniform float specularIntensity;
  10578. uniform vec3 specularColor;
  10579. #ifdef USE_SPECULARINTENSITYMAP
  10580. uniform sampler2D specularIntensityMap;
  10581. #endif
  10582. #ifdef USE_SPECULARCOLORMAP
  10583. uniform sampler2D specularColorMap;
  10584. #endif
  10585. #endif
  10586. #ifdef USE_CLEARCOAT
  10587. uniform float clearcoat;
  10588. uniform float clearcoatRoughness;
  10589. #endif
  10590. #ifdef USE_IRIDESCENCE
  10591. uniform float iridescence;
  10592. uniform float iridescenceIOR;
  10593. uniform float iridescenceThicknessMinimum;
  10594. uniform float iridescenceThicknessMaximum;
  10595. #endif
  10596. #ifdef USE_SHEEN
  10597. uniform vec3 sheenColor;
  10598. uniform float sheenRoughness;
  10599. #ifdef USE_SHEENCOLORMAP
  10600. uniform sampler2D sheenColorMap;
  10601. #endif
  10602. #ifdef USE_SHEENROUGHNESSMAP
  10603. uniform sampler2D sheenRoughnessMap;
  10604. #endif
  10605. #endif
  10606. varying vec3 vViewPosition;
  10607. #include <common>
  10608. #include <packing>
  10609. #include <dithering_pars_fragment>
  10610. #include <color_pars_fragment>
  10611. #include <uv_pars_fragment>
  10612. #include <uv2_pars_fragment>
  10613. #include <map_pars_fragment>
  10614. #include <alphamap_pars_fragment>
  10615. #include <alphatest_pars_fragment>
  10616. #include <aomap_pars_fragment>
  10617. #include <lightmap_pars_fragment>
  10618. #include <emissivemap_pars_fragment>
  10619. #include <bsdfs>
  10620. #include <iridescence_fragment>
  10621. #include <cube_uv_reflection_fragment>
  10622. #include <envmap_common_pars_fragment>
  10623. #include <envmap_physical_pars_fragment>
  10624. #include <fog_pars_fragment>
  10625. #include <lights_pars_begin>
  10626. #include <normal_pars_fragment>
  10627. #include <lights_physical_pars_fragment>
  10628. #include <transmission_pars_fragment>
  10629. #include <shadowmap_pars_fragment>
  10630. #include <bumpmap_pars_fragment>
  10631. #include <normalmap_pars_fragment>
  10632. #include <clearcoat_pars_fragment>
  10633. #include <iridescence_pars_fragment>
  10634. #include <roughnessmap_pars_fragment>
  10635. #include <metalnessmap_pars_fragment>
  10636. #include <logdepthbuf_pars_fragment>
  10637. #include <clipping_planes_pars_fragment>
  10638. void main() {
  10639. #include <clipping_planes_fragment>
  10640. vec4 diffuseColor = vec4( diffuse, opacity );
  10641. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  10642. vec3 totalEmissiveRadiance = emissive;
  10643. #include <logdepthbuf_fragment>
  10644. #include <map_fragment>
  10645. #include <color_fragment>
  10646. #include <alphamap_fragment>
  10647. #include <alphatest_fragment>
  10648. #include <roughnessmap_fragment>
  10649. #include <metalnessmap_fragment>
  10650. #include <normal_fragment_begin>
  10651. #include <normal_fragment_maps>
  10652. #include <clearcoat_normal_fragment_begin>
  10653. #include <clearcoat_normal_fragment_maps>
  10654. #include <emissivemap_fragment>
  10655. #include <lights_physical_fragment>
  10656. #include <lights_fragment_begin>
  10657. #include <lights_fragment_maps>
  10658. #include <lights_fragment_end>
  10659. #include <aomap_fragment>
  10660. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  10661. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  10662. #include <transmission_fragment>
  10663. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  10664. #ifdef USE_SHEEN
  10665. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  10666. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
  10667. #endif
  10668. #ifdef USE_CLEARCOAT
  10669. float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
  10670. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  10671. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;
  10672. #endif
  10673. #include <output_fragment>
  10674. #include <tonemapping_fragment>
  10675. #include <encodings_fragment>
  10676. #include <fog_fragment>
  10677. #include <premultiplied_alpha_fragment>
  10678. #include <dithering_fragment>
  10679. }`,
  10680. qT = `#define TOON
  10681. varying vec3 vViewPosition;
  10682. #include <common>
  10683. #include <uv_pars_vertex>
  10684. #include <uv2_pars_vertex>
  10685. #include <displacementmap_pars_vertex>
  10686. #include <color_pars_vertex>
  10687. #include <fog_pars_vertex>
  10688. #include <normal_pars_vertex>
  10689. #include <morphtarget_pars_vertex>
  10690. #include <skinning_pars_vertex>
  10691. #include <shadowmap_pars_vertex>
  10692. #include <logdepthbuf_pars_vertex>
  10693. #include <clipping_planes_pars_vertex>
  10694. void main() {
  10695. #include <uv_vertex>
  10696. #include <uv2_vertex>
  10697. #include <color_vertex>
  10698. #include <morphcolor_vertex>
  10699. #include <beginnormal_vertex>
  10700. #include <morphnormal_vertex>
  10701. #include <skinbase_vertex>
  10702. #include <skinnormal_vertex>
  10703. #include <defaultnormal_vertex>
  10704. #include <normal_vertex>
  10705. #include <begin_vertex>
  10706. #include <morphtarget_vertex>
  10707. #include <skinning_vertex>
  10708. #include <displacementmap_vertex>
  10709. #include <project_vertex>
  10710. #include <logdepthbuf_vertex>
  10711. #include <clipping_planes_vertex>
  10712. vViewPosition = - mvPosition.xyz;
  10713. #include <worldpos_vertex>
  10714. #include <shadowmap_vertex>
  10715. #include <fog_vertex>
  10716. }`,
  10717. YT = `#define TOON
  10718. uniform vec3 diffuse;
  10719. uniform vec3 emissive;
  10720. uniform float opacity;
  10721. #include <common>
  10722. #include <packing>
  10723. #include <dithering_pars_fragment>
  10724. #include <color_pars_fragment>
  10725. #include <uv_pars_fragment>
  10726. #include <uv2_pars_fragment>
  10727. #include <map_pars_fragment>
  10728. #include <alphamap_pars_fragment>
  10729. #include <alphatest_pars_fragment>
  10730. #include <aomap_pars_fragment>
  10731. #include <lightmap_pars_fragment>
  10732. #include <emissivemap_pars_fragment>
  10733. #include <gradientmap_pars_fragment>
  10734. #include <fog_pars_fragment>
  10735. #include <bsdfs>
  10736. #include <lights_pars_begin>
  10737. #include <normal_pars_fragment>
  10738. #include <lights_toon_pars_fragment>
  10739. #include <shadowmap_pars_fragment>
  10740. #include <bumpmap_pars_fragment>
  10741. #include <normalmap_pars_fragment>
  10742. #include <logdepthbuf_pars_fragment>
  10743. #include <clipping_planes_pars_fragment>
  10744. void main() {
  10745. #include <clipping_planes_fragment>
  10746. vec4 diffuseColor = vec4( diffuse, opacity );
  10747. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  10748. vec3 totalEmissiveRadiance = emissive;
  10749. #include <logdepthbuf_fragment>
  10750. #include <map_fragment>
  10751. #include <color_fragment>
  10752. #include <alphamap_fragment>
  10753. #include <alphatest_fragment>
  10754. #include <normal_fragment_begin>
  10755. #include <normal_fragment_maps>
  10756. #include <emissivemap_fragment>
  10757. #include <lights_toon_fragment>
  10758. #include <lights_fragment_begin>
  10759. #include <lights_fragment_maps>
  10760. #include <lights_fragment_end>
  10761. #include <aomap_fragment>
  10762. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  10763. #include <output_fragment>
  10764. #include <tonemapping_fragment>
  10765. #include <encodings_fragment>
  10766. #include <fog_fragment>
  10767. #include <premultiplied_alpha_fragment>
  10768. #include <dithering_fragment>
  10769. }`,
  10770. QT = `uniform float size;
  10771. uniform float scale;
  10772. #include <common>
  10773. #include <color_pars_vertex>
  10774. #include <fog_pars_vertex>
  10775. #include <morphtarget_pars_vertex>
  10776. #include <logdepthbuf_pars_vertex>
  10777. #include <clipping_planes_pars_vertex>
  10778. void main() {
  10779. #include <color_vertex>
  10780. #include <morphcolor_vertex>
  10781. #include <begin_vertex>
  10782. #include <morphtarget_vertex>
  10783. #include <project_vertex>
  10784. gl_PointSize = size;
  10785. #ifdef USE_SIZEATTENUATION
  10786. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  10787. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  10788. #endif
  10789. #include <logdepthbuf_vertex>
  10790. #include <clipping_planes_vertex>
  10791. #include <worldpos_vertex>
  10792. #include <fog_vertex>
  10793. }`,
  10794. ZT = `uniform vec3 diffuse;
  10795. uniform float opacity;
  10796. #include <common>
  10797. #include <color_pars_fragment>
  10798. #include <map_particle_pars_fragment>
  10799. #include <alphatest_pars_fragment>
  10800. #include <fog_pars_fragment>
  10801. #include <logdepthbuf_pars_fragment>
  10802. #include <clipping_planes_pars_fragment>
  10803. void main() {
  10804. #include <clipping_planes_fragment>
  10805. vec3 outgoingLight = vec3( 0.0 );
  10806. vec4 diffuseColor = vec4( diffuse, opacity );
  10807. #include <logdepthbuf_fragment>
  10808. #include <map_particle_fragment>
  10809. #include <color_fragment>
  10810. #include <alphatest_fragment>
  10811. outgoingLight = diffuseColor.rgb;
  10812. #include <output_fragment>
  10813. #include <tonemapping_fragment>
  10814. #include <encodings_fragment>
  10815. #include <fog_fragment>
  10816. #include <premultiplied_alpha_fragment>
  10817. }`,
  10818. KT = `#include <common>
  10819. #include <fog_pars_vertex>
  10820. #include <morphtarget_pars_vertex>
  10821. #include <skinning_pars_vertex>
  10822. #include <shadowmap_pars_vertex>
  10823. void main() {
  10824. #include <beginnormal_vertex>
  10825. #include <morphnormal_vertex>
  10826. #include <skinbase_vertex>
  10827. #include <skinnormal_vertex>
  10828. #include <defaultnormal_vertex>
  10829. #include <begin_vertex>
  10830. #include <morphtarget_vertex>
  10831. #include <skinning_vertex>
  10832. #include <project_vertex>
  10833. #include <worldpos_vertex>
  10834. #include <shadowmap_vertex>
  10835. #include <fog_vertex>
  10836. }`,
  10837. JT = `uniform vec3 color;
  10838. uniform float opacity;
  10839. #include <common>
  10840. #include <packing>
  10841. #include <fog_pars_fragment>
  10842. #include <bsdfs>
  10843. #include <lights_pars_begin>
  10844. #include <shadowmap_pars_fragment>
  10845. #include <shadowmask_pars_fragment>
  10846. void main() {
  10847. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  10848. #include <tonemapping_fragment>
  10849. #include <encodings_fragment>
  10850. #include <fog_fragment>
  10851. }`,
  10852. $T = `uniform float rotation;
  10853. uniform vec2 center;
  10854. #include <common>
  10855. #include <uv_pars_vertex>
  10856. #include <fog_pars_vertex>
  10857. #include <logdepthbuf_pars_vertex>
  10858. #include <clipping_planes_pars_vertex>
  10859. void main() {
  10860. #include <uv_vertex>
  10861. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  10862. vec2 scale;
  10863. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  10864. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  10865. #ifndef USE_SIZEATTENUATION
  10866. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  10867. if ( isPerspective ) scale *= - mvPosition.z;
  10868. #endif
  10869. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  10870. vec2 rotatedPosition;
  10871. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  10872. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  10873. mvPosition.xy += rotatedPosition;
  10874. gl_Position = projectionMatrix * mvPosition;
  10875. #include <logdepthbuf_vertex>
  10876. #include <clipping_planes_vertex>
  10877. #include <fog_vertex>
  10878. }`,
  10879. e3 = `uniform vec3 diffuse;
  10880. uniform float opacity;
  10881. #include <common>
  10882. #include <uv_pars_fragment>
  10883. #include <map_pars_fragment>
  10884. #include <alphamap_pars_fragment>
  10885. #include <alphatest_pars_fragment>
  10886. #include <fog_pars_fragment>
  10887. #include <logdepthbuf_pars_fragment>
  10888. #include <clipping_planes_pars_fragment>
  10889. void main() {
  10890. #include <clipping_planes_fragment>
  10891. vec3 outgoingLight = vec3( 0.0 );
  10892. vec4 diffuseColor = vec4( diffuse, opacity );
  10893. #include <logdepthbuf_fragment>
  10894. #include <map_fragment>
  10895. #include <alphamap_fragment>
  10896. #include <alphatest_fragment>
  10897. outgoingLight = diffuseColor.rgb;
  10898. #include <output_fragment>
  10899. #include <tonemapping_fragment>
  10900. #include <encodings_fragment>
  10901. #include <fog_fragment>
  10902. }`,
  10903. Ze = {
  10904. alphamap_fragment: AE,
  10905. alphamap_pars_fragment: SE,
  10906. alphatest_fragment: ME,
  10907. alphatest_pars_fragment: EE,
  10908. aomap_fragment: CE,
  10909. aomap_pars_fragment: TE,
  10910. begin_vertex: PE,
  10911. beginnormal_vertex: DE,
  10912. bsdfs: LE,
  10913. iridescence_fragment: OE,
  10914. bumpmap_pars_fragment: IE,
  10915. clipping_planes_fragment: RE,
  10916. clipping_planes_pars_fragment: BE,
  10917. clipping_planes_pars_vertex: zE,
  10918. clipping_planes_vertex: NE,
  10919. color_fragment: UE,
  10920. color_pars_fragment: FE,
  10921. color_pars_vertex: kE,
  10922. color_vertex: jE,
  10923. common: GE,
  10924. cube_uv_reflection_fragment: VE,
  10925. defaultnormal_vertex: HE,
  10926. displacementmap_pars_vertex: WE,
  10927. displacementmap_vertex: XE,
  10928. emissivemap_fragment: qE,
  10929. emissivemap_pars_fragment: YE,
  10930. encodings_fragment: QE,
  10931. encodings_pars_fragment: ZE,
  10932. envmap_fragment: KE,
  10933. envmap_common_pars_fragment: JE,
  10934. envmap_pars_fragment: $E,
  10935. envmap_pars_vertex: eC,
  10936. envmap_physical_pars_fragment: uC,
  10937. envmap_vertex: tC,
  10938. fog_vertex: iC,
  10939. fog_pars_vertex: rC,
  10940. fog_fragment: sC,
  10941. fog_pars_fragment: nC,
  10942. gradientmap_pars_fragment: aC,
  10943. lightmap_fragment: oC,
  10944. lightmap_pars_fragment: lC,
  10945. lights_lambert_fragment: hC,
  10946. lights_lambert_pars_fragment: cC,
  10947. lights_pars_begin: dC,
  10948. lights_toon_fragment: pC,
  10949. lights_toon_pars_fragment: fC,
  10950. lights_phong_fragment: mC,
  10951. lights_phong_pars_fragment: gC,
  10952. lights_physical_fragment: vC,
  10953. lights_physical_pars_fragment: yC,
  10954. lights_fragment_begin: xC,
  10955. lights_fragment_maps: bC,
  10956. lights_fragment_end: wC,
  10957. logdepthbuf_fragment: _C,
  10958. logdepthbuf_pars_fragment: AC,
  10959. logdepthbuf_pars_vertex: SC,
  10960. logdepthbuf_vertex: MC,
  10961. map_fragment: EC,
  10962. map_pars_fragment: CC,
  10963. map_particle_fragment: TC,
  10964. map_particle_pars_fragment: PC,
  10965. metalnessmap_fragment: DC,
  10966. metalnessmap_pars_fragment: LC,
  10967. morphcolor_vertex: OC,
  10968. morphnormal_vertex: IC,
  10969. morphtarget_pars_vertex: RC,
  10970. morphtarget_vertex: BC,
  10971. normal_fragment_begin: zC,
  10972. normal_fragment_maps: NC,
  10973. normal_pars_fragment: UC,
  10974. normal_pars_vertex: FC,
  10975. normal_vertex: kC,
  10976. normalmap_pars_fragment: jC,
  10977. clearcoat_normal_fragment_begin: GC,
  10978. clearcoat_normal_fragment_maps: VC,
  10979. clearcoat_pars_fragment: HC,
  10980. iridescence_pars_fragment: WC,
  10981. output_fragment: XC,
  10982. packing: qC,
  10983. premultiplied_alpha_fragment: YC,
  10984. project_vertex: QC,
  10985. dithering_fragment: ZC,
  10986. dithering_pars_fragment: KC,
  10987. roughnessmap_fragment: JC,
  10988. roughnessmap_pars_fragment: $C,
  10989. shadowmap_pars_fragment: eT,
  10990. shadowmap_pars_vertex: tT,
  10991. shadowmap_vertex: iT,
  10992. shadowmask_pars_fragment: rT,
  10993. skinbase_vertex: sT,
  10994. skinning_pars_vertex: nT,
  10995. skinning_vertex: aT,
  10996. skinnormal_vertex: oT,
  10997. specularmap_fragment: lT,
  10998. specularmap_pars_fragment: hT,
  10999. tonemapping_fragment: cT,
  11000. tonemapping_pars_fragment: dT,
  11001. transmission_fragment: uT,
  11002. transmission_pars_fragment: pT,
  11003. uv_pars_fragment: fT,
  11004. uv_pars_vertex: mT,
  11005. uv_vertex: gT,
  11006. uv2_pars_fragment: vT,
  11007. uv2_pars_vertex: yT,
  11008. uv2_vertex: xT,
  11009. worldpos_vertex: bT,
  11010. background_vert: wT,
  11011. background_frag: _T,
  11012. backgroundCube_vert: AT,
  11013. backgroundCube_frag: ST,
  11014. cube_vert: MT,
  11015. cube_frag: ET,
  11016. depth_vert: CT,
  11017. depth_frag: TT,
  11018. distanceRGBA_vert: PT,
  11019. distanceRGBA_frag: DT,
  11020. equirect_vert: LT,
  11021. equirect_frag: OT,
  11022. linedashed_vert: IT,
  11023. linedashed_frag: RT,
  11024. meshbasic_vert: BT,
  11025. meshbasic_frag: zT,
  11026. meshlambert_vert: NT,
  11027. meshlambert_frag: UT,
  11028. meshmatcap_vert: FT,
  11029. meshmatcap_frag: kT,
  11030. meshnormal_vert: jT,
  11031. meshnormal_frag: GT,
  11032. meshphong_vert: VT,
  11033. meshphong_frag: HT,
  11034. meshphysical_vert: WT,
  11035. meshphysical_frag: XT,
  11036. meshtoon_vert: qT,
  11037. meshtoon_frag: YT,
  11038. points_vert: QT,
  11039. points_frag: ZT,
  11040. shadow_vert: KT,
  11041. shadow_frag: JT,
  11042. sprite_vert: $T,
  11043. sprite_frag: e3
  11044. },
  11045. ge = {
  11046. common: {
  11047. diffuse: { value: new Ge(16777215) },
  11048. opacity: { value: 1 },
  11049. map: { value: null },
  11050. uvTransform: { value: new Ai() },
  11051. uv2Transform: { value: new Ai() },
  11052. alphaMap: { value: null },
  11053. alphaTest: { value: 0 }
  11054. },
  11055. specularmap: { specularMap: { value: null } },
  11056. envmap: {
  11057. envMap: { value: null },
  11058. flipEnvMap: { value: -1 },
  11059. reflectivity: { value: 1 },
  11060. ior: { value: 1.5 },
  11061. refractionRatio: { value: 0.98 }
  11062. },
  11063. aomap: { aoMap: { value: null }, aoMapIntensity: { value: 1 } },
  11064. lightmap: { lightMap: { value: null }, lightMapIntensity: { value: 1 } },
  11065. emissivemap: { emissiveMap: { value: null } },
  11066. bumpmap: { bumpMap: { value: null }, bumpScale: { value: 1 } },
  11067. normalmap: { normalMap: { value: null }, normalScale: { value: new G(1, 1) } },
  11068. displacementmap: { displacementMap: { value: null }, displacementScale: { value: 1 }, displacementBias: { value: 0 } },
  11069. roughnessmap: { roughnessMap: { value: null } },
  11070. metalnessmap: { metalnessMap: { value: null } },
  11071. gradientmap: { gradientMap: { value: null } },
  11072. fog: { fogDensity: { value: 25e-5 }, fogNear: { value: 1 }, fogFar: { value: 2e3 }, fogColor: { value: new Ge(16777215) } },
  11073. lights: {
  11074. ambientLightColor: { value: [] },
  11075. lightProbe: { value: [] },
  11076. directionalLights: { value: [], properties: { direction: {}, color: {} } },
  11077. directionalLightShadows: { value: [], properties: { shadowBias: {}, shadowNormalBias: {}, shadowRadius: {}, shadowMapSize: {} } },
  11078. directionalShadowMap: { value: [] },
  11079. directionalShadowMatrix: { value: [] },
  11080. spotLights: {
  11081. value: [],
  11082. properties: { color: {}, position: {}, direction: {}, distance: {}, coneCos: {}, penumbraCos: {}, decay: {} }
  11083. },
  11084. spotLightShadows: { value: [], properties: { shadowBias: {}, shadowNormalBias: {}, shadowRadius: {}, shadowMapSize: {} } },
  11085. spotLightMap: { value: [] },
  11086. spotShadowMap: { value: [] },
  11087. spotLightMatrix: { value: [] },
  11088. pointLights: { value: [], properties: { color: {}, position: {}, decay: {}, distance: {} } },
  11089. pointLightShadows: {
  11090. value: [],
  11091. properties: { shadowBias: {}, shadowNormalBias: {}, shadowRadius: {}, shadowMapSize: {}, shadowCameraNear: {}, shadowCameraFar: {} }
  11092. },
  11093. pointShadowMap: { value: [] },
  11094. pointShadowMatrix: { value: [] },
  11095. hemisphereLights: { value: [], properties: { direction: {}, skyColor: {}, groundColor: {} } },
  11096. rectAreaLights: { value: [], properties: { color: {}, position: {}, width: {}, height: {} } },
  11097. ltc_1: { value: null },
  11098. ltc_2: { value: null }
  11099. },
  11100. points: {
  11101. diffuse: { value: new Ge(16777215) },
  11102. opacity: { value: 1 },
  11103. size: { value: 1 },
  11104. scale: { value: 1 },
  11105. map: { value: null },
  11106. alphaMap: { value: null },
  11107. alphaTest: { value: 0 },
  11108. uvTransform: { value: new Ai() }
  11109. },
  11110. sprite: {
  11111. diffuse: { value: new Ge(16777215) },
  11112. opacity: { value: 1 },
  11113. center: { value: new G(0.5, 0.5) },
  11114. rotation: { value: 0 },
  11115. map: { value: null },
  11116. alphaMap: { value: null },
  11117. alphaTest: { value: 0 },
  11118. uvTransform: { value: new Ai() }
  11119. }
  11120. },
  11121. ss = {
  11122. basic: {
  11123. uniforms: Li([ge.common, ge.specularmap, ge.envmap, ge.aomap, ge.lightmap, ge.fog]),
  11124. vertexShader: Ze.meshbasic_vert,
  11125. fragmentShader: Ze.meshbasic_frag
  11126. },
  11127. lambert: {
  11128. uniforms: Li([
  11129. ge.common,
  11130. ge.specularmap,
  11131. ge.envmap,
  11132. ge.aomap,
  11133. ge.lightmap,
  11134. ge.emissivemap,
  11135. ge.bumpmap,
  11136. ge.normalmap,
  11137. ge.displacementmap,
  11138. ge.fog,
  11139. ge.lights,
  11140. { emissive: { value: new Ge(0) } }
  11141. ]),
  11142. vertexShader: Ze.meshlambert_vert,
  11143. fragmentShader: Ze.meshlambert_frag
  11144. },
  11145. phong: {
  11146. uniforms: Li([
  11147. ge.common,
  11148. ge.specularmap,
  11149. ge.envmap,
  11150. ge.aomap,
  11151. ge.lightmap,
  11152. ge.emissivemap,
  11153. ge.bumpmap,
  11154. ge.normalmap,
  11155. ge.displacementmap,
  11156. ge.fog,
  11157. ge.lights,
  11158. { emissive: { value: new Ge(0) }, specular: { value: new Ge(1118481) }, shininess: { value: 30 } }
  11159. ]),
  11160. vertexShader: Ze.meshphong_vert,
  11161. fragmentShader: Ze.meshphong_frag
  11162. },
  11163. standard: {
  11164. uniforms: Li([
  11165. ge.common,
  11166. ge.envmap,
  11167. ge.aomap,
  11168. ge.lightmap,
  11169. ge.emissivemap,
  11170. ge.bumpmap,
  11171. ge.normalmap,
  11172. ge.displacementmap,
  11173. ge.roughnessmap,
  11174. ge.metalnessmap,
  11175. ge.fog,
  11176. ge.lights,
  11177. { emissive: { value: new Ge(0) }, roughness: { value: 1 }, metalness: { value: 0 }, envMapIntensity: { value: 1 } }
  11178. ]),
  11179. vertexShader: Ze.meshphysical_vert,
  11180. fragmentShader: Ze.meshphysical_frag
  11181. },
  11182. toon: {
  11183. uniforms: Li([
  11184. ge.common,
  11185. ge.aomap,
  11186. ge.lightmap,
  11187. ge.emissivemap,
  11188. ge.bumpmap,
  11189. ge.normalmap,
  11190. ge.displacementmap,
  11191. ge.gradientmap,
  11192. ge.fog,
  11193. ge.lights,
  11194. { emissive: { value: new Ge(0) } }
  11195. ]),
  11196. vertexShader: Ze.meshtoon_vert,
  11197. fragmentShader: Ze.meshtoon_frag
  11198. },
  11199. matcap: {
  11200. uniforms: Li([ge.common, ge.bumpmap, ge.normalmap, ge.displacementmap, ge.fog, { matcap: { value: null } }]),
  11201. vertexShader: Ze.meshmatcap_vert,
  11202. fragmentShader: Ze.meshmatcap_frag
  11203. },
  11204. points: { uniforms: Li([ge.points, ge.fog]), vertexShader: Ze.points_vert, fragmentShader: Ze.points_frag },
  11205. dashed: {
  11206. uniforms: Li([ge.common, ge.fog, { scale: { value: 1 }, dashSize: { value: 1 }, totalSize: { value: 2 } }]),
  11207. vertexShader: Ze.linedashed_vert,
  11208. fragmentShader: Ze.linedashed_frag
  11209. },
  11210. depth: { uniforms: Li([ge.common, ge.displacementmap]), vertexShader: Ze.depth_vert, fragmentShader: Ze.depth_frag },
  11211. normal: {
  11212. uniforms: Li([ge.common, ge.bumpmap, ge.normalmap, ge.displacementmap, { opacity: { value: 1 } }]),
  11213. vertexShader: Ze.meshnormal_vert,
  11214. fragmentShader: Ze.meshnormal_frag
  11215. },
  11216. sprite: { uniforms: Li([ge.sprite, ge.fog]), vertexShader: Ze.sprite_vert, fragmentShader: Ze.sprite_frag },
  11217. background: {
  11218. uniforms: { uvTransform: { value: new Ai() }, t2D: { value: null }, backgroundIntensity: { value: 1 } },
  11219. vertexShader: Ze.background_vert,
  11220. fragmentShader: Ze.background_frag
  11221. },
  11222. backgroundCube: {
  11223. uniforms: {
  11224. envMap: { value: null },
  11225. flipEnvMap: { value: -1 },
  11226. backgroundBlurriness: { value: 0 },
  11227. backgroundIntensity: { value: 1 }
  11228. },
  11229. vertexShader: Ze.backgroundCube_vert,
  11230. fragmentShader: Ze.backgroundCube_frag
  11231. },
  11232. cube: {
  11233. uniforms: { tCube: { value: null }, tFlip: { value: -1 }, opacity: { value: 1 } },
  11234. vertexShader: Ze.cube_vert,
  11235. fragmentShader: Ze.cube_frag
  11236. },
  11237. equirect: { uniforms: { tEquirect: { value: null } }, vertexShader: Ze.equirect_vert, fragmentShader: Ze.equirect_frag },
  11238. distanceRGBA: {
  11239. uniforms: Li([
  11240. ge.common,
  11241. ge.displacementmap,
  11242. { referencePosition: { value: new E() }, nearDistance: { value: 1 }, farDistance: { value: 1e3 } }
  11243. ]),
  11244. vertexShader: Ze.distanceRGBA_vert,
  11245. fragmentShader: Ze.distanceRGBA_frag
  11246. },
  11247. shadow: {
  11248. uniforms: Li([ge.lights, ge.fog, { color: { value: new Ge(0) }, opacity: { value: 1 } }]),
  11249. vertexShader: Ze.shadow_vert,
  11250. fragmentShader: Ze.shadow_frag
  11251. }
  11252. };
  11253. ss.physical = {
  11254. uniforms: Li([
  11255. ss.standard.uniforms,
  11256. {
  11257. clearcoat: { value: 0 },
  11258. clearcoatMap: { value: null },
  11259. clearcoatRoughness: { value: 0 },
  11260. clearcoatRoughnessMap: { value: null },
  11261. clearcoatNormalScale: { value: new G(1, 1) },
  11262. clearcoatNormalMap: { value: null },
  11263. iridescence: { value: 0 },
  11264. iridescenceMap: { value: null },
  11265. iridescenceIOR: { value: 1.3 },
  11266. iridescenceThicknessMinimum: { value: 100 },
  11267. iridescenceThicknessMaximum: { value: 400 },
  11268. iridescenceThicknessMap: { value: null },
  11269. sheen: { value: 0 },
  11270. sheenColor: { value: new Ge(0) },
  11271. sheenColorMap: { value: null },
  11272. sheenRoughness: { value: 1 },
  11273. sheenRoughnessMap: { value: null },
  11274. transmission: { value: 0 },
  11275. transmissionMap: { value: null },
  11276. transmissionSamplerSize: { value: new G() },
  11277. transmissionSamplerMap: { value: null },
  11278. thickness: { value: 0 },
  11279. thicknessMap: { value: null },
  11280. attenuationDistance: { value: 0 },
  11281. attenuationColor: { value: new Ge(0) },
  11282. specularIntensity: { value: 1 },
  11283. specularIntensityMap: { value: null },
  11284. specularColor: { value: new Ge(1, 1, 1) },
  11285. specularColorMap: { value: null }
  11286. }
  11287. ]),
  11288. vertexShader: Ze.meshphysical_vert,
  11289. fragmentShader: Ze.meshphysical_frag
  11290. };
  11291. var lc = { r: 0, b: 0, g: 0 };
  11292. function t3(e, t, i, r, s, n, a) {
  11293. let o = new Ge(0),
  11294. l = n === !0 ? 0 : 1,
  11295. h,
  11296. u,
  11297. c = null,
  11298. d = 0,
  11299. p = null;
  11300. function f(m, v) {
  11301. let y = !1,
  11302. b = v.isScene === !0 ? v.background : null;
  11303. b && b.isTexture && (b = (v.backgroundBlurriness > 0 ? i : t).get(b));
  11304. let x = e.xr,
  11305. w = x.getSession && x.getSession();
  11306. w && w.environmentBlendMode === 'additive' && (b = null),
  11307. b === null ? g(o, l) : b && b.isColor && (g(b, 1), (y = !0)),
  11308. (e.autoClear || y) && e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil),
  11309. b && (b.isCubeTexture || b.mapping === Ch)
  11310. ? (u === void 0 &&
  11311. ((u = new tr(
  11312. new vs(1, 1, 1),
  11313. new ri({
  11314. name: 'BackgroundCubeMaterial',
  11315. uniforms: zo(ss.backgroundCube.uniforms),
  11316. vertexShader: ss.backgroundCube.vertexShader,
  11317. fragmentShader: ss.backgroundCube.fragmentShader,
  11318. side: hi,
  11319. depthTest: !1,
  11320. depthWrite: !1,
  11321. fog: !1
  11322. })
  11323. )),
  11324. u.geometry.deleteAttribute('normal'),
  11325. u.geometry.deleteAttribute('uv'),
  11326. (u.onBeforeRender = function (A, S, _) {
  11327. this.matrixWorld.copyPosition(_.matrixWorld);
  11328. }),
  11329. Object.defineProperty(u.material, 'envMap', {
  11330. get: function () {
  11331. return this.uniforms.envMap.value;
  11332. }
  11333. }),
  11334. s.update(u)),
  11335. (u.material.uniforms.envMap.value = b),
  11336. (u.material.uniforms.flipEnvMap.value = b.isCubeTexture && b.isRenderTargetTexture === !1 ? -1 : 1),
  11337. (u.material.uniforms.backgroundBlurriness.value = v.backgroundBlurriness),
  11338. (u.material.uniforms.backgroundIntensity.value = v.backgroundIntensity),
  11339. (u.material.toneMapped = b.encoding !== Ke),
  11340. (c !== b || d !== b.version || p !== e.toneMapping) &&
  11341. ((u.material.needsUpdate = !0), (c = b), (d = b.version), (p = e.toneMapping)),
  11342. u.layers.enableAll(),
  11343. m.unshift(u, u.geometry, u.material, 0, 0, null))
  11344. : b &&
  11345. b.isTexture &&
  11346. (h === void 0 &&
  11347. ((h = new tr(
  11348. new ou(2, 2),
  11349. new ri({
  11350. name: 'BackgroundMaterial',
  11351. uniforms: zo(ss.background.uniforms),
  11352. vertexShader: ss.background.vertexShader,
  11353. fragmentShader: ss.background.fragmentShader,
  11354. side: Vr,
  11355. depthTest: !1,
  11356. depthWrite: !1,
  11357. fog: !1
  11358. })
  11359. )),
  11360. h.geometry.deleteAttribute('normal'),
  11361. Object.defineProperty(h.material, 'map', {
  11362. get: function () {
  11363. return this.uniforms.t2D.value;
  11364. }
  11365. }),
  11366. s.update(h)),
  11367. (h.material.uniforms.t2D.value = b),
  11368. (h.material.uniforms.backgroundIntensity.value = v.backgroundIntensity),
  11369. (h.material.toneMapped = b.encoding !== Ke),
  11370. b.matrixAutoUpdate === !0 && b.updateMatrix(),
  11371. h.material.uniforms.uvTransform.value.copy(b.matrix),
  11372. (c !== b || d !== b.version || p !== e.toneMapping) &&
  11373. ((h.material.needsUpdate = !0), (c = b), (d = b.version), (p = e.toneMapping)),
  11374. h.layers.enableAll(),
  11375. m.unshift(h, h.geometry, h.material, 0, 0, null));
  11376. }
  11377. function g(m, v) {
  11378. m.getRGB(lc, vw(e)), r.buffers.color.setClear(lc.r, lc.g, lc.b, v, a);
  11379. }
  11380. return {
  11381. getClearColor: function () {
  11382. return o;
  11383. },
  11384. setClearColor: function (m, v = 1) {
  11385. o.set(m), (l = v), g(o, l);
  11386. },
  11387. getClearAlpha: function () {
  11388. return l;
  11389. },
  11390. setClearAlpha: function (m) {
  11391. (l = m), g(o, l);
  11392. },
  11393. render: f
  11394. };
  11395. }
  11396. function i3(e, t, i, r) {
  11397. let s = e.getParameter(34921),
  11398. n = r.isWebGL2 ? null : t.get('OES_vertex_array_object'),
  11399. a = r.isWebGL2 || n !== null,
  11400. o = {},
  11401. l = m(null),
  11402. h = l,
  11403. u = !1;
  11404. function c(D, k, W, X, z) {
  11405. let j = !1;
  11406. if (a) {
  11407. let U = g(X, W, k);
  11408. h !== U && ((h = U), p(h.object)), (j = v(D, X, W, z)), j && y(D, X, W, z);
  11409. } else {
  11410. let U = k.wireframe === !0;
  11411. (h.geometry !== X.id || h.program !== W.id || h.wireframe !== U) &&
  11412. ((h.geometry = X.id), (h.program = W.id), (h.wireframe = U), (j = !0));
  11413. }
  11414. z !== null && i.update(z, 34963), (j || u) && ((u = !1), _(D, k, W, X), z !== null && e.bindBuffer(34963, i.get(z).buffer));
  11415. }
  11416. function d() {
  11417. return r.isWebGL2 ? e.createVertexArray() : n.createVertexArrayOES();
  11418. }
  11419. function p(D) {
  11420. return r.isWebGL2 ? e.bindVertexArray(D) : n.bindVertexArrayOES(D);
  11421. }
  11422. function f(D) {
  11423. return r.isWebGL2 ? e.deleteVertexArray(D) : n.deleteVertexArrayOES(D);
  11424. }
  11425. function g(D, k, W) {
  11426. let X = W.wireframe === !0,
  11427. z = o[D.id];
  11428. z === void 0 && ((z = {}), (o[D.id] = z));
  11429. let j = z[k.id];
  11430. j === void 0 && ((j = {}), (z[k.id] = j));
  11431. let U = j[X];
  11432. return U === void 0 && ((U = m(d())), (j[X] = U)), U;
  11433. }
  11434. function m(D) {
  11435. let k = [],
  11436. W = [],
  11437. X = [];
  11438. for (let z = 0; z < s; z++) (k[z] = 0), (W[z] = 0), (X[z] = 0);
  11439. return {
  11440. geometry: null,
  11441. program: null,
  11442. wireframe: !1,
  11443. newAttributes: k,
  11444. enabledAttributes: W,
  11445. attributeDivisors: X,
  11446. object: D,
  11447. attributes: {},
  11448. index: null
  11449. };
  11450. }
  11451. function v(D, k, W, X) {
  11452. let z = h.attributes,
  11453. j = k.attributes,
  11454. U = 0,
  11455. N = W.getAttributes();
  11456. for (let B in N)
  11457. if (N[B].location >= 0) {
  11458. let H = z[B],
  11459. Q = j[B];
  11460. if (
  11461. (Q === void 0 &&
  11462. (B === 'instanceMatrix' && D.instanceMatrix && (Q = D.instanceMatrix),
  11463. B === 'instanceColor' && D.instanceColor && (Q = D.instanceColor)),
  11464. H === void 0 || H.attribute !== Q || (Q && H.data !== Q.data))
  11465. )
  11466. return !0;
  11467. U++;
  11468. }
  11469. return h.attributesNum !== U || h.index !== X;
  11470. }
  11471. function y(D, k, W, X) {
  11472. let z = {},
  11473. j = k.attributes,
  11474. U = 0,
  11475. N = W.getAttributes();
  11476. for (let B in N)
  11477. if (N[B].location >= 0) {
  11478. let H = j[B];
  11479. H === void 0 &&
  11480. (B === 'instanceMatrix' && D.instanceMatrix && (H = D.instanceMatrix),
  11481. B === 'instanceColor' && D.instanceColor && (H = D.instanceColor));
  11482. let Q = {};
  11483. (Q.attribute = H), H && H.data && (Q.data = H.data), (z[B] = Q), U++;
  11484. }
  11485. (h.attributes = z), (h.attributesNum = U), (h.index = X);
  11486. }
  11487. function b() {
  11488. let D = h.newAttributes;
  11489. for (let k = 0, W = D.length; k < W; k++) D[k] = 0;
  11490. }
  11491. function x(D) {
  11492. w(D, 0);
  11493. }
  11494. function w(D, k) {
  11495. let W = h.newAttributes,
  11496. X = h.enabledAttributes,
  11497. z = h.attributeDivisors;
  11498. (W[D] = 1),
  11499. X[D] === 0 && (e.enableVertexAttribArray(D), (X[D] = 1)),
  11500. z[D] !== k &&
  11501. ((r.isWebGL2 ? e : t.get('ANGLE_instanced_arrays'))[r.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE'](D, k),
  11502. (z[D] = k));
  11503. }
  11504. function A() {
  11505. let D = h.newAttributes,
  11506. k = h.enabledAttributes;
  11507. for (let W = 0, X = k.length; W < X; W++) k[W] !== D[W] && (e.disableVertexAttribArray(W), (k[W] = 0));
  11508. }
  11509. function S(D, k, W, X, z, j) {
  11510. r.isWebGL2 === !0 && (W === 5124 || W === 5125) ? e.vertexAttribIPointer(D, k, W, z, j) : e.vertexAttribPointer(D, k, W, X, z, j);
  11511. }
  11512. function _(D, k, W, X) {
  11513. if (r.isWebGL2 === !1 && (D.isInstancedMesh || X.isInstancedBufferGeometry) && t.get('ANGLE_instanced_arrays') === null) return;
  11514. b();
  11515. let z = X.attributes,
  11516. j = W.getAttributes(),
  11517. U = k.defaultAttributeValues;
  11518. for (let N in j) {
  11519. let B = j[N];
  11520. if (B.location >= 0) {
  11521. let H = z[N];
  11522. if (
  11523. (H === void 0 &&
  11524. (N === 'instanceMatrix' && D.instanceMatrix && (H = D.instanceMatrix),
  11525. N === 'instanceColor' && D.instanceColor && (H = D.instanceColor)),
  11526. H !== void 0)
  11527. ) {
  11528. let Q = H.normalized,
  11529. Y = H.itemSize,
  11530. F = i.get(H);
  11531. if (F === void 0) continue;
  11532. let se = F.buffer,
  11533. V = F.type,
  11534. ee = F.bytesPerElement;
  11535. if (H.isInterleavedBufferAttribute) {
  11536. let J = H.data,
  11537. fe = J.stride,
  11538. re = H.offset;
  11539. if (J.isInstancedInterleavedBuffer) {
  11540. for (let oe = 0; oe < B.locationSize; oe++) w(B.location + oe, J.meshPerAttribute);
  11541. D.isInstancedMesh !== !0 && X._maxInstanceCount === void 0 && (X._maxInstanceCount = J.meshPerAttribute * J.count);
  11542. } else for (let oe = 0; oe < B.locationSize; oe++) x(B.location + oe);
  11543. e.bindBuffer(34962, se);
  11544. for (let oe = 0; oe < B.locationSize; oe++)
  11545. S(B.location + oe, Y / B.locationSize, V, Q, fe * ee, (re + (Y / B.locationSize) * oe) * ee);
  11546. } else {
  11547. if (H.isInstancedBufferAttribute) {
  11548. for (let J = 0; J < B.locationSize; J++) w(B.location + J, H.meshPerAttribute);
  11549. D.isInstancedMesh !== !0 && X._maxInstanceCount === void 0 && (X._maxInstanceCount = H.meshPerAttribute * H.count);
  11550. } else for (let J = 0; J < B.locationSize; J++) x(B.location + J);
  11551. e.bindBuffer(34962, se);
  11552. for (let J = 0; J < B.locationSize; J++) S(B.location + J, Y / B.locationSize, V, Q, Y * ee, (Y / B.locationSize) * J * ee);
  11553. }
  11554. } else if (U !== void 0) {
  11555. let Q = U[N];
  11556. if (Q !== void 0)
  11557. switch (Q.length) {
  11558. case 2:
  11559. e.vertexAttrib2fv(B.location, Q);
  11560. break;
  11561. case 3:
  11562. e.vertexAttrib3fv(B.location, Q);
  11563. break;
  11564. case 4:
  11565. e.vertexAttrib4fv(B.location, Q);
  11566. break;
  11567. default:
  11568. e.vertexAttrib1fv(B.location, Q);
  11569. }
  11570. }
  11571. }
  11572. }
  11573. A();
  11574. }
  11575. function M() {
  11576. P();
  11577. for (let D in o) {
  11578. let k = o[D];
  11579. for (let W in k) {
  11580. let X = k[W];
  11581. for (let z in X) f(X[z].object), delete X[z];
  11582. delete k[W];
  11583. }
  11584. delete o[D];
  11585. }
  11586. }
  11587. function C(D) {
  11588. if (o[D.id] === void 0) return;
  11589. let k = o[D.id];
  11590. for (let W in k) {
  11591. let X = k[W];
  11592. for (let z in X) f(X[z].object), delete X[z];
  11593. delete k[W];
  11594. }
  11595. delete o[D.id];
  11596. }
  11597. function T(D) {
  11598. for (let k in o) {
  11599. let W = o[k];
  11600. if (W[D.id] === void 0) continue;
  11601. let X = W[D.id];
  11602. for (let z in X) f(X[z].object), delete X[z];
  11603. delete W[D.id];
  11604. }
  11605. }
  11606. function P() {
  11607. L(), (u = !0), h !== l && ((h = l), p(h.object));
  11608. }
  11609. function L() {
  11610. (l.geometry = null), (l.program = null), (l.wireframe = !1);
  11611. }
  11612. return {
  11613. setup: c,
  11614. reset: P,
  11615. resetDefaultState: L,
  11616. dispose: M,
  11617. releaseStatesOfGeometry: C,
  11618. releaseStatesOfProgram: T,
  11619. initAttributes: b,
  11620. enableAttribute: x,
  11621. disableUnusedAttributes: A
  11622. };
  11623. }
  11624. function r3(e, t, i, r) {
  11625. let s = r.isWebGL2,
  11626. n;
  11627. function a(h) {
  11628. n = h;
  11629. }
  11630. function o(h, u) {
  11631. e.drawArrays(n, h, u), i.update(u, n, 1);
  11632. }
  11633. function l(h, u, c) {
  11634. if (c === 0) return;
  11635. let d, p;
  11636. if (s) (d = e), (p = 'drawArraysInstanced');
  11637. else if (((d = t.get('ANGLE_instanced_arrays')), (p = 'drawArraysInstancedANGLE'), d === null)) {
  11638. console.error(
  11639. 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.'
  11640. );
  11641. return;
  11642. }
  11643. d[p](n, h, u, c), i.update(u, n, c);
  11644. }
  11645. (this.setMode = a), (this.render = o), (this.renderInstances = l);
  11646. }
  11647. function s3(e, t, i) {
  11648. let r;
  11649. function s() {
  11650. if (r !== void 0) return r;
  11651. if (t.has('EXT_texture_filter_anisotropic') === !0) {
  11652. let S = t.get('EXT_texture_filter_anisotropic');
  11653. r = e.getParameter(S.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
  11654. } else r = 0;
  11655. return r;
  11656. }
  11657. function n(S) {
  11658. if (S === 'highp') {
  11659. if (e.getShaderPrecisionFormat(35633, 36338).precision > 0 && e.getShaderPrecisionFormat(35632, 36338).precision > 0) return 'highp';
  11660. S = 'mediump';
  11661. }
  11662. return S === 'mediump' &&
  11663. e.getShaderPrecisionFormat(35633, 36337).precision > 0 &&
  11664. e.getShaderPrecisionFormat(35632, 36337).precision > 0
  11665. ? 'mediump'
  11666. : 'lowp';
  11667. }
  11668. let a = typeof WebGL2RenderingContext < 'u' && e instanceof WebGL2RenderingContext,
  11669. o = i.precision !== void 0 ? i.precision : 'highp',
  11670. l = n(o);
  11671. l !== o && (console.warn('THREE.WebGLRenderer:', o, 'not supported, using', l, 'instead.'), (o = l));
  11672. let h = a || t.has('WEBGL_draw_buffers'),
  11673. u = i.logarithmicDepthBuffer === !0,
  11674. c = e.getParameter(34930),
  11675. d = e.getParameter(35660),
  11676. p = e.getParameter(3379),
  11677. f = e.getParameter(34076),
  11678. g = e.getParameter(34921),
  11679. m = e.getParameter(36347),
  11680. v = e.getParameter(36348),
  11681. y = e.getParameter(36349),
  11682. b = d > 0,
  11683. x = a || t.has('OES_texture_float'),
  11684. w = b && x,
  11685. A = a ? e.getParameter(36183) : 0;
  11686. return {
  11687. isWebGL2: a,
  11688. drawBuffers: h,
  11689. getMaxAnisotropy: s,
  11690. getMaxPrecision: n,
  11691. precision: o,
  11692. logarithmicDepthBuffer: u,
  11693. maxTextures: c,
  11694. maxVertexTextures: d,
  11695. maxTextureSize: p,
  11696. maxCubemapSize: f,
  11697. maxAttributes: g,
  11698. maxVertexUniforms: m,
  11699. maxVaryings: v,
  11700. maxFragmentUniforms: y,
  11701. vertexTextures: b,
  11702. floatFragmentTextures: x,
  11703. floatVertexTextures: w,
  11704. maxSamples: A
  11705. };
  11706. }
  11707. function n3(e) {
  11708. let t = this,
  11709. i = null,
  11710. r = 0,
  11711. s = !1,
  11712. n = !1,
  11713. a = new yr(),
  11714. o = new Ai(),
  11715. l = { value: null, needsUpdate: !1 };
  11716. (this.uniform = l),
  11717. (this.numPlanes = 0),
  11718. (this.numIntersection = 0),
  11719. (this.init = function (c, d) {
  11720. let p = c.length !== 0 || d || r !== 0 || s;
  11721. return (s = d), (r = c.length), p;
  11722. }),
  11723. (this.beginShadows = function () {
  11724. (n = !0), u(null);
  11725. }),
  11726. (this.endShadows = function () {
  11727. n = !1;
  11728. }),
  11729. (this.setGlobalState = function (c, d) {
  11730. i = u(c, d, 0);
  11731. }),
  11732. (this.setState = function (c, d, p) {
  11733. let f = c.clippingPlanes,
  11734. g = c.clipIntersection,
  11735. m = c.clipShadows,
  11736. v = e.get(c);
  11737. if (!s || f === null || f.length === 0 || (n && !m)) n ? u(null) : h();
  11738. else {
  11739. let y = n ? 0 : r,
  11740. b = y * 4,
  11741. x = v.clippingState || null;
  11742. (l.value = x), (x = u(f, d, b, p));
  11743. for (let w = 0; w !== b; ++w) x[w] = i[w];
  11744. (v.clippingState = x), (this.numIntersection = g ? this.numPlanes : 0), (this.numPlanes += y);
  11745. }
  11746. });
  11747. function h() {
  11748. l.value !== i && ((l.value = i), (l.needsUpdate = r > 0)), (t.numPlanes = r), (t.numIntersection = 0);
  11749. }
  11750. function u(c, d, p, f) {
  11751. let g = c !== null ? c.length : 0,
  11752. m = null;
  11753. if (g !== 0) {
  11754. if (((m = l.value), f !== !0 || m === null)) {
  11755. let v = p + g * 4,
  11756. y = d.matrixWorldInverse;
  11757. o.getNormalMatrix(y), (m === null || m.length < v) && (m = new Float32Array(v));
  11758. for (let b = 0, x = p; b !== g; ++b, x += 4) a.copy(c[b]).applyMatrix4(y, o), a.normal.toArray(m, x), (m[x + 3] = a.constant);
  11759. }
  11760. (l.value = m), (l.needsUpdate = !0);
  11761. }
  11762. return (t.numPlanes = g), (t.numIntersection = 0), m;
  11763. }
  11764. }
  11765. function a3(e) {
  11766. let t = new WeakMap();
  11767. function i(a, o) {
  11768. return o === zf ? (a.mapping = ya) : o === Nf && (a.mapping = xa), a;
  11769. }
  11770. function r(a) {
  11771. if (a && a.isTexture && a.isRenderTargetTexture === !1) {
  11772. let o = a.mapping;
  11773. if (o === zf || o === Nf)
  11774. if (t.has(a)) {
  11775. let l = t.get(a).texture;
  11776. return i(l, a.mapping);
  11777. } else {
  11778. let l = a.image;
  11779. if (l && l.height > 0) {
  11780. let h = new xE(l.height / 2);
  11781. return h.fromEquirectangularTexture(e, a), t.set(a, h), a.addEventListener('dispose', s), i(h.texture, a.mapping);
  11782. } else return null;
  11783. }
  11784. }
  11785. return a;
  11786. }
  11787. function s(a) {
  11788. let o = a.target;
  11789. o.removeEventListener('dispose', s);
  11790. let l = t.get(o);
  11791. l !== void 0 && (t.delete(o), l.dispose());
  11792. }
  11793. function n() {
  11794. t = new WeakMap();
  11795. }
  11796. return { get: r, dispose: n };
  11797. }
  11798. var gd = class extends Yo {
  11799. constructor(e = -1, t = 1, i = 1, r = -1, s = 0.1, n = 2e3) {
  11800. super(),
  11801. (this.isOrthographicCamera = !0),
  11802. (this.type = 'OrthographicCamera'),
  11803. (this.zoom = 1),
  11804. (this.view = null),
  11805. (this.left = e),
  11806. (this.right = t),
  11807. (this.top = i),
  11808. (this.bottom = r),
  11809. (this.near = s),
  11810. (this.far = n),
  11811. this.updateProjectionMatrix();
  11812. }
  11813. copy(e, t) {
  11814. return (
  11815. super.copy(e, t),
  11816. (this.left = e.left),
  11817. (this.right = e.right),
  11818. (this.top = e.top),
  11819. (this.bottom = e.bottom),
  11820. (this.near = e.near),
  11821. (this.far = e.far),
  11822. (this.zoom = e.zoom),
  11823. (this.view = e.view === null ? null : Object.assign({}, e.view)),
  11824. this
  11825. );
  11826. }
  11827. setViewOffset(e, t, i, r, s, n) {
  11828. this.view === null && (this.view = { enabled: !0, fullWidth: 1, fullHeight: 1, offsetX: 0, offsetY: 0, width: 1, height: 1 }),
  11829. (this.view.enabled = !0),
  11830. (this.view.fullWidth = e),
  11831. (this.view.fullHeight = t),
  11832. (this.view.offsetX = i),
  11833. (this.view.offsetY = r),
  11834. (this.view.width = s),
  11835. (this.view.height = n),
  11836. this.updateProjectionMatrix();
  11837. }
  11838. clearViewOffset() {
  11839. this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
  11840. }
  11841. updateProjectionMatrix() {
  11842. let e = (this.right - this.left) / (2 * this.zoom),
  11843. t = (this.top - this.bottom) / (2 * this.zoom),
  11844. i = (this.right + this.left) / 2,
  11845. r = (this.top + this.bottom) / 2,
  11846. s = i - e,
  11847. n = i + e,
  11848. a = r + t,
  11849. o = r - t;
  11850. if (this.view !== null && this.view.enabled) {
  11851. let l = (this.right - this.left) / this.view.fullWidth / this.zoom,
  11852. h = (this.top - this.bottom) / this.view.fullHeight / this.zoom;
  11853. (s += l * this.view.offsetX), (n = s + l * this.view.width), (a -= h * this.view.offsetY), (o = a - h * this.view.height);
  11854. }
  11855. this.projectionMatrix.makeOrthographic(s, n, a, o, this.near, this.far),
  11856. this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
  11857. }
  11858. toJSON(e) {
  11859. let t = super.toJSON(e);
  11860. return (
  11861. (t.object.zoom = this.zoom),
  11862. (t.object.left = this.left),
  11863. (t.object.right = this.right),
  11864. (t.object.top = this.top),
  11865. (t.object.bottom = this.bottom),
  11866. (t.object.near = this.near),
  11867. (t.object.far = this.far),
  11868. this.view !== null && (t.object.view = Object.assign({}, this.view)),
  11869. t
  11870. );
  11871. }
  11872. },
  11873. uo = 4,
  11874. V0 = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582],
  11875. ia = 20,
  11876. xp = new gd(),
  11877. H0 = new Ge(),
  11878. bp = null,
  11879. Jn = (1 + Math.sqrt(5)) / 2,
  11880. qa = 1 / Jn,
  11881. W0 = [
  11882. new E(1, 1, 1),
  11883. new E(-1, 1, 1),
  11884. new E(1, 1, -1),
  11885. new E(-1, 1, -1),
  11886. new E(0, Jn, qa),
  11887. new E(0, Jn, -qa),
  11888. new E(qa, 0, Jn),
  11889. new E(-qa, 0, Jn),
  11890. new E(Jn, qa, 0),
  11891. new E(-Jn, qa, 0)
  11892. ],
  11893. X0 = class {
  11894. constructor(e) {
  11895. (this._renderer = e),
  11896. (this._pingPongRenderTarget = null),
  11897. (this._lodMax = 0),
  11898. (this._cubeSize = 0),
  11899. (this._lodPlanes = []),
  11900. (this._sizeLods = []),
  11901. (this._sigmas = []),
  11902. (this._blurMaterial = null),
  11903. (this._cubemapMaterial = null),
  11904. (this._equirectMaterial = null),
  11905. this._compileMaterial(this._blurMaterial);
  11906. }
  11907. fromScene(e, t = 0, i = 0.1, r = 100) {
  11908. (bp = this._renderer.getRenderTarget()), this._setSize(256);
  11909. let s = this._allocateTargets();
  11910. return (
  11911. (s.depthBuffer = !0), this._sceneToCubeUV(e, i, r, s), t > 0 && this._blur(s, 0, 0, t), this._applyPMREM(s), this._cleanup(s), s
  11912. );
  11913. }
  11914. fromEquirectangular(e, t = null) {
  11915. return this._fromTexture(e, t);
  11916. }
  11917. fromCubemap(e, t = null) {
  11918. return this._fromTexture(e, t);
  11919. }
  11920. compileCubemapShader() {
  11921. this._cubemapMaterial === null && ((this._cubemapMaterial = Q0()), this._compileMaterial(this._cubemapMaterial));
  11922. }
  11923. compileEquirectangularShader() {
  11924. this._equirectMaterial === null && ((this._equirectMaterial = Y0()), this._compileMaterial(this._equirectMaterial));
  11925. }
  11926. dispose() {
  11927. this._dispose(),
  11928. this._cubemapMaterial !== null && this._cubemapMaterial.dispose(),
  11929. this._equirectMaterial !== null && this._equirectMaterial.dispose();
  11930. }
  11931. _setSize(e) {
  11932. (this._lodMax = Math.floor(Math.log2(e))), (this._cubeSize = Math.pow(2, this._lodMax));
  11933. }
  11934. _dispose() {
  11935. this._blurMaterial !== null && this._blurMaterial.dispose(),
  11936. this._pingPongRenderTarget !== null && this._pingPongRenderTarget.dispose();
  11937. for (let e = 0; e < this._lodPlanes.length; e++) this._lodPlanes[e].dispose();
  11938. }
  11939. _cleanup(e) {
  11940. this._renderer.setRenderTarget(bp), (e.scissorTest = !1), hc(e, 0, 0, e.width, e.height);
  11941. }
  11942. _fromTexture(e, t) {
  11943. e.mapping === ya || e.mapping === xa
  11944. ? this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width)
  11945. : this._setSize(e.image.width / 4),
  11946. (bp = this._renderer.getRenderTarget());
  11947. let i = t || this._allocateTargets();
  11948. return this._textureToCubeUV(e, i), this._applyPMREM(i), this._cleanup(i), i;
  11949. }
  11950. _allocateTargets() {
  11951. let e = 3 * Math.max(this._cubeSize, 112),
  11952. t = 4 * this._cubeSize,
  11953. i = { magFilter: mt, minFilter: mt, generateMipmaps: !1, type: lh, format: Ur, encoding: gs, depthBuffer: !1 },
  11954. r = q0(e, t, i);
  11955. if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== e || this._pingPongRenderTarget.height !== t) {
  11956. this._pingPongRenderTarget !== null && this._dispose(), (this._pingPongRenderTarget = q0(e, t, i));
  11957. let { _lodMax: s } = this;
  11958. ({ sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = o3(s)), (this._blurMaterial = l3(s, e, t));
  11959. }
  11960. return r;
  11961. }
  11962. _compileMaterial(e) {
  11963. let t = new tr(this._lodPlanes[0], e);
  11964. this._renderer.compile(t, xp);
  11965. }
  11966. _sceneToCubeUV(e, t, i, r) {
  11967. let s = new wi(90, 1, t, i),
  11968. n = [1, -1, 1, 1, 1, 1],
  11969. a = [1, 1, 1, -1, -1, -1],
  11970. o = this._renderer,
  11971. l = o.autoClear,
  11972. h = o.toneMapping;
  11973. o.getClearColor(H0), (o.toneMapping = Gs), (o.autoClear = !1);
  11974. let u = new Ph({ name: 'PMREM.Background', side: hi, depthWrite: !1, depthTest: !1 }),
  11975. c = new tr(new vs(), u),
  11976. d = !1,
  11977. p = e.background;
  11978. p ? p.isColor && (u.color.copy(p), (e.background = null), (d = !0)) : (u.color.copy(H0), (d = !0));
  11979. for (let f = 0; f < 6; f++) {
  11980. let g = f % 3;
  11981. g === 0
  11982. ? (s.up.set(0, n[f], 0), s.lookAt(a[f], 0, 0))
  11983. : g === 1
  11984. ? (s.up.set(0, 0, n[f]), s.lookAt(0, a[f], 0))
  11985. : (s.up.set(0, n[f], 0), s.lookAt(0, 0, a[f]));
  11986. let m = this._cubeSize;
  11987. hc(r, g * m, f > 2 ? m : 0, m, m), o.setRenderTarget(r), d && o.render(c, s), o.render(e, s);
  11988. }
  11989. c.geometry.dispose(), c.material.dispose(), (o.toneMapping = h), (o.autoClear = l), (e.background = p);
  11990. }
  11991. _textureToCubeUV(e, t) {
  11992. let i = this._renderer,
  11993. r = e.mapping === ya || e.mapping === xa;
  11994. r
  11995. ? (this._cubemapMaterial === null && (this._cubemapMaterial = Q0()),
  11996. (this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1))
  11997. : this._equirectMaterial === null && (this._equirectMaterial = Y0());
  11998. let s = r ? this._cubemapMaterial : this._equirectMaterial,
  11999. n = new tr(this._lodPlanes[0], s),
  12000. a = s.uniforms;
  12001. a.envMap.value = e;
  12002. let o = this._cubeSize;
  12003. hc(t, 0, 0, 3 * o, 2 * o), i.setRenderTarget(t), i.render(n, xp);
  12004. }
  12005. _applyPMREM(e) {
  12006. let t = this._renderer,
  12007. i = t.autoClear;
  12008. t.autoClear = !1;
  12009. for (let r = 1; r < this._lodPlanes.length; r++) {
  12010. let s = Math.sqrt(this._sigmas[r] * this._sigmas[r] - this._sigmas[r - 1] * this._sigmas[r - 1]),
  12011. n = W0[(r - 1) % W0.length];
  12012. this._blur(e, r - 1, r, s, n);
  12013. }
  12014. t.autoClear = i;
  12015. }
  12016. _blur(e, t, i, r, s) {
  12017. let n = this._pingPongRenderTarget;
  12018. this._halfBlur(e, n, t, i, r, 'latitudinal', s), this._halfBlur(n, e, i, i, r, 'longitudinal', s);
  12019. }
  12020. _halfBlur(e, t, i, r, s, n, a) {
  12021. let o = this._renderer,
  12022. l = this._blurMaterial;
  12023. n !== 'latitudinal' && n !== 'longitudinal' && console.error('blur direction must be either latitudinal or longitudinal!');
  12024. let h = 3,
  12025. u = new tr(this._lodPlanes[r], l),
  12026. c = l.uniforms,
  12027. d = this._sizeLods[i] - 1,
  12028. p = isFinite(s) ? Math.PI / (2 * d) : (2 * Math.PI) / (2 * ia - 1),
  12029. f = s / p,
  12030. g = isFinite(s) ? 1 + Math.floor(h * f) : ia;
  12031. g > ia &&
  12032. console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${ia}`);
  12033. let m = [],
  12034. v = 0;
  12035. for (let A = 0; A < ia; ++A) {
  12036. let S = A / f,
  12037. _ = Math.exp((-S * S) / 2);
  12038. m.push(_), A === 0 ? (v += _) : A < g && (v += 2 * _);
  12039. }
  12040. for (let A = 0; A < m.length; A++) m[A] = m[A] / v;
  12041. (c.envMap.value = e.texture),
  12042. (c.samples.value = g),
  12043. (c.weights.value = m),
  12044. (c.latitudinal.value = n === 'latitudinal'),
  12045. a && (c.poleAxis.value = a);
  12046. let { _lodMax: y } = this;
  12047. (c.dTheta.value = p), (c.mipInt.value = y - i);
  12048. let b = this._sizeLods[r],
  12049. x = 3 * b * (r > y - uo ? r - y + uo : 0),
  12050. w = 4 * (this._cubeSize - b);
  12051. hc(t, x, w, 3 * b, 2 * b), o.setRenderTarget(t), o.render(u, xp);
  12052. }
  12053. };
  12054. function o3(e) {
  12055. let t = [],
  12056. i = [],
  12057. r = [],
  12058. s = e,
  12059. n = e - uo + 1 + V0.length;
  12060. for (let a = 0; a < n; a++) {
  12061. let o = Math.pow(2, s);
  12062. i.push(o);
  12063. let l = 1 / o;
  12064. a > e - uo ? (l = V0[a - e + uo - 1]) : a === 0 && (l = 0), r.push(l);
  12065. let h = 1 / (o - 2),
  12066. u = -h,
  12067. c = 1 + h,
  12068. d = [u, u, c, u, c, c, u, u, c, c, u, c],
  12069. p = 6,
  12070. f = 6,
  12071. g = 3,
  12072. m = 2,
  12073. v = 1,
  12074. y = new Float32Array(g * f * p),
  12075. b = new Float32Array(m * f * p),
  12076. x = new Float32Array(v * f * p);
  12077. for (let A = 0; A < p; A++) {
  12078. let S = ((A % 3) * 2) / 3 - 1,
  12079. _ = A > 2 ? 0 : -1,
  12080. M = [S, _, 0, S + 2 / 3, _, 0, S + 2 / 3, _ + 1, 0, S, _, 0, S + 2 / 3, _ + 1, 0, S, _ + 1, 0];
  12081. y.set(M, g * f * A), b.set(d, m * f * A);
  12082. let C = [A, A, A, A, A, A];
  12083. x.set(C, v * f * A);
  12084. }
  12085. let w = new Ve();
  12086. w.setAttribute('position', new Xe(y, g)),
  12087. w.setAttribute('uv', new Xe(b, m)),
  12088. w.setAttribute('faceIndex', new Xe(x, v)),
  12089. t.push(w),
  12090. s > uo && s--;
  12091. }
  12092. return { lodPlanes: t, sizeLods: i, sigmas: r };
  12093. }
  12094. function q0(e, t, i) {
  12095. let r = new ii(e, t, i);
  12096. return (r.texture.mapping = Ch), (r.texture.name = 'PMREM.cubeUv'), (r.scissorTest = !0), r;
  12097. }
  12098. function hc(e, t, i, r, s) {
  12099. e.viewport.set(t, i, r, s), e.scissor.set(t, i, r, s);
  12100. }
  12101. function l3(e, t, i) {
  12102. let r = new Float32Array(ia),
  12103. s = new E(0, 1, 0);
  12104. return new ri({
  12105. name: 'SphericalGaussianBlur',
  12106. defines: { n: ia, CUBEUV_TEXEL_WIDTH: 1 / t, CUBEUV_TEXEL_HEIGHT: 1 / i, CUBEUV_MAX_MIP: `${e}.0` },
  12107. uniforms: {
  12108. envMap: { value: null },
  12109. samples: { value: 1 },
  12110. weights: { value: r },
  12111. latitudinal: { value: !1 },
  12112. dTheta: { value: 0 },
  12113. mipInt: { value: 0 },
  12114. poleAxis: { value: s }
  12115. },
  12116. vertexShader: ug(),
  12117. fragmentShader: `
  12118. precision mediump float;
  12119. precision mediump int;
  12120. varying vec3 vOutputDirection;
  12121. uniform sampler2D envMap;
  12122. uniform int samples;
  12123. uniform float weights[ n ];
  12124. uniform bool latitudinal;
  12125. uniform float dTheta;
  12126. uniform float mipInt;
  12127. uniform vec3 poleAxis;
  12128. #define ENVMAP_TYPE_CUBE_UV
  12129. #include <cube_uv_reflection_fragment>
  12130. vec3 getSample( float theta, vec3 axis ) {
  12131. float cosTheta = cos( theta );
  12132. // Rodrigues' axis-angle rotation
  12133. vec3 sampleDirection = vOutputDirection * cosTheta
  12134. + cross( axis, vOutputDirection ) * sin( theta )
  12135. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  12136. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  12137. }
  12138. void main() {
  12139. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  12140. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  12141. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  12142. }
  12143. axis = normalize( axis );
  12144. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  12145. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  12146. for ( int i = 1; i < n; i++ ) {
  12147. if ( i >= samples ) {
  12148. break;
  12149. }
  12150. float theta = dTheta * float( i );
  12151. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  12152. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  12153. }
  12154. }
  12155. `,
  12156. blending: fi,
  12157. depthTest: !1,
  12158. depthWrite: !1
  12159. });
  12160. }
  12161. function Y0() {
  12162. return new ri({
  12163. name: 'EquirectangularToCubeUV',
  12164. uniforms: { envMap: { value: null } },
  12165. vertexShader: ug(),
  12166. fragmentShader: `
  12167. precision mediump float;
  12168. precision mediump int;
  12169. varying vec3 vOutputDirection;
  12170. uniform sampler2D envMap;
  12171. #include <common>
  12172. void main() {
  12173. vec3 outputDirection = normalize( vOutputDirection );
  12174. vec2 uv = equirectUv( outputDirection );
  12175. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  12176. }
  12177. `,
  12178. blending: fi,
  12179. depthTest: !1,
  12180. depthWrite: !1
  12181. });
  12182. }
  12183. function Q0() {
  12184. return new ri({
  12185. name: 'CubemapToCubeUV',
  12186. uniforms: { envMap: { value: null }, flipEnvMap: { value: -1 } },
  12187. vertexShader: ug(),
  12188. fragmentShader: `
  12189. precision mediump float;
  12190. precision mediump int;
  12191. uniform float flipEnvMap;
  12192. varying vec3 vOutputDirection;
  12193. uniform samplerCube envMap;
  12194. void main() {
  12195. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  12196. }
  12197. `,
  12198. blending: fi,
  12199. depthTest: !1,
  12200. depthWrite: !1
  12201. });
  12202. }
  12203. function ug() {
  12204. return `
  12205. precision mediump float;
  12206. precision mediump int;
  12207. attribute float faceIndex;
  12208. varying vec3 vOutputDirection;
  12209. // RH coordinate system; PMREM face-indexing convention
  12210. vec3 getDirection( vec2 uv, float face ) {
  12211. uv = 2.0 * uv - 1.0;
  12212. vec3 direction = vec3( uv, 1.0 );
  12213. if ( face == 0.0 ) {
  12214. direction = direction.zyx; // ( 1, v, u ) pos x
  12215. } else if ( face == 1.0 ) {
  12216. direction = direction.xzy;
  12217. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  12218. } else if ( face == 2.0 ) {
  12219. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  12220. } else if ( face == 3.0 ) {
  12221. direction = direction.zyx;
  12222. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  12223. } else if ( face == 4.0 ) {
  12224. direction = direction.xzy;
  12225. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  12226. } else if ( face == 5.0 ) {
  12227. direction.z *= -1.0; // ( u, v, -1 ) neg z
  12228. }
  12229. return direction;
  12230. }
  12231. void main() {
  12232. vOutputDirection = getDirection( uv, faceIndex );
  12233. gl_Position = vec4( position, 1.0 );
  12234. }
  12235. `;
  12236. }
  12237. function h3(e) {
  12238. let t = new WeakMap(),
  12239. i = null;
  12240. function r(o) {
  12241. if (o && o.isTexture) {
  12242. let l = o.mapping,
  12243. h = l === zf || l === Nf,
  12244. u = l === ya || l === xa;
  12245. if (h || u)
  12246. if (o.isRenderTargetTexture && o.needsPMREMUpdate === !0) {
  12247. o.needsPMREMUpdate = !1;
  12248. let c = t.get(o);
  12249. return i === null && (i = new X0(e)), (c = h ? i.fromEquirectangular(o, c) : i.fromCubemap(o, c)), t.set(o, c), c.texture;
  12250. } else {
  12251. if (t.has(o)) return t.get(o).texture;
  12252. {
  12253. let c = o.image;
  12254. if ((h && c && c.height > 0) || (u && c && s(c))) {
  12255. i === null && (i = new X0(e));
  12256. let d = h ? i.fromEquirectangular(o) : i.fromCubemap(o);
  12257. return t.set(o, d), o.addEventListener('dispose', n), d.texture;
  12258. } else return null;
  12259. }
  12260. }
  12261. }
  12262. return o;
  12263. }
  12264. function s(o) {
  12265. let l = 0,
  12266. h = 6;
  12267. for (let u = 0; u < h; u++) o[u] !== void 0 && l++;
  12268. return l === h;
  12269. }
  12270. function n(o) {
  12271. let l = o.target;
  12272. l.removeEventListener('dispose', n);
  12273. let h = t.get(l);
  12274. h !== void 0 && (t.delete(l), h.dispose());
  12275. }
  12276. function a() {
  12277. (t = new WeakMap()), i !== null && (i.dispose(), (i = null));
  12278. }
  12279. return { get: r, dispose: a };
  12280. }
  12281. function c3(e) {
  12282. let t = {};
  12283. function i(r) {
  12284. if (t[r] !== void 0) return t[r];
  12285. let s;
  12286. switch (r) {
  12287. case 'WEBGL_depth_texture':
  12288. s =
  12289. e.getExtension('WEBGL_depth_texture') ||
  12290. e.getExtension('MOZ_WEBGL_depth_texture') ||
  12291. e.getExtension('WEBKIT_WEBGL_depth_texture');
  12292. break;
  12293. case 'EXT_texture_filter_anisotropic':
  12294. s =
  12295. e.getExtension('EXT_texture_filter_anisotropic') ||
  12296. e.getExtension('MOZ_EXT_texture_filter_anisotropic') ||
  12297. e.getExtension('WEBKIT_EXT_texture_filter_anisotropic');
  12298. break;
  12299. case 'WEBGL_compressed_texture_s3tc':
  12300. s =
  12301. e.getExtension('WEBGL_compressed_texture_s3tc') ||
  12302. e.getExtension('MOZ_WEBGL_compressed_texture_s3tc') ||
  12303. e.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  12304. break;
  12305. case 'WEBGL_compressed_texture_pvrtc':
  12306. s = e.getExtension('WEBGL_compressed_texture_pvrtc') || e.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  12307. break;
  12308. default:
  12309. s = e.getExtension(r);
  12310. }
  12311. return (t[r] = s), s;
  12312. }
  12313. return {
  12314. has: function (r) {
  12315. return i(r) !== null;
  12316. },
  12317. init: function (r) {
  12318. r.isWebGL2
  12319. ? i('EXT_color_buffer_float')
  12320. : (i('WEBGL_depth_texture'),
  12321. i('OES_texture_float'),
  12322. i('OES_texture_half_float'),
  12323. i('OES_texture_half_float_linear'),
  12324. i('OES_standard_derivatives'),
  12325. i('OES_element_index_uint'),
  12326. i('OES_vertex_array_object'),
  12327. i('ANGLE_instanced_arrays')),
  12328. i('OES_texture_float_linear'),
  12329. i('EXT_color_buffer_half_float'),
  12330. i('WEBGL_multisampled_render_to_texture');
  12331. },
  12332. get: function (r) {
  12333. let s = i(r);
  12334. return s === null && console.warn('THREE.WebGLRenderer: ' + r + ' extension not supported.'), s;
  12335. }
  12336. };
  12337. }
  12338. function d3(e, t, i, r) {
  12339. let s = {},
  12340. n = new WeakMap();
  12341. function a(c) {
  12342. let d = c.target;
  12343. d.index !== null && t.remove(d.index);
  12344. for (let f in d.attributes) t.remove(d.attributes[f]);
  12345. d.removeEventListener('dispose', a), delete s[d.id];
  12346. let p = n.get(d);
  12347. p && (t.remove(p), n.delete(d)),
  12348. r.releaseStatesOfGeometry(d),
  12349. d.isInstancedBufferGeometry === !0 && delete d._maxInstanceCount,
  12350. i.memory.geometries--;
  12351. }
  12352. function o(c, d) {
  12353. return s[d.id] === !0 || (d.addEventListener('dispose', a), (s[d.id] = !0), i.memory.geometries++), d;
  12354. }
  12355. function l(c) {
  12356. let d = c.attributes;
  12357. for (let f in d) t.update(d[f], 34962);
  12358. let p = c.morphAttributes;
  12359. for (let f in p) {
  12360. let g = p[f];
  12361. for (let m = 0, v = g.length; m < v; m++) t.update(g[m], 34962);
  12362. }
  12363. }
  12364. function h(c) {
  12365. let d = [],
  12366. p = c.index,
  12367. f = c.attributes.position,
  12368. g = 0;
  12369. if (p !== null) {
  12370. let y = p.array;
  12371. g = p.version;
  12372. for (let b = 0, x = y.length; b < x; b += 3) {
  12373. let w = y[b + 0],
  12374. A = y[b + 1],
  12375. S = y[b + 2];
  12376. d.push(w, A, A, S, S, w);
  12377. }
  12378. } else {
  12379. let y = f.array;
  12380. g = f.version;
  12381. for (let b = 0, x = y.length / 3 - 1; b < x; b += 3) {
  12382. let w = b + 0,
  12383. A = b + 1,
  12384. S = b + 2;
  12385. d.push(w, A, A, S, S, w);
  12386. }
  12387. }
  12388. let m = new (dw(d) ? Kl : gw)(d, 1);
  12389. m.version = g;
  12390. let v = n.get(c);
  12391. v && t.remove(v), n.set(c, m);
  12392. }
  12393. function u(c) {
  12394. let d = n.get(c);
  12395. if (d) {
  12396. let p = c.index;
  12397. p !== null && d.version < p.version && h(c);
  12398. } else h(c);
  12399. return n.get(c);
  12400. }
  12401. return { get: o, update: l, getWireframeAttribute: u };
  12402. }
  12403. function u3(e, t, i, r) {
  12404. let s = r.isWebGL2,
  12405. n;
  12406. function a(d) {
  12407. n = d;
  12408. }
  12409. let o, l;
  12410. function h(d) {
  12411. (o = d.type), (l = d.bytesPerElement);
  12412. }
  12413. function u(d, p) {
  12414. e.drawElements(n, p, o, d * l), i.update(p, n, 1);
  12415. }
  12416. function c(d, p, f) {
  12417. if (f === 0) return;
  12418. let g, m;
  12419. if (s) (g = e), (m = 'drawElementsInstanced');
  12420. else if (((g = t.get('ANGLE_instanced_arrays')), (m = 'drawElementsInstancedANGLE'), g === null)) {
  12421. console.error(
  12422. 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.'
  12423. );
  12424. return;
  12425. }
  12426. g[m](n, p, o, d * l, f), i.update(p, n, f);
  12427. }
  12428. (this.setMode = a), (this.setIndex = h), (this.render = u), (this.renderInstances = c);
  12429. }
  12430. function p3(e) {
  12431. let t = { geometries: 0, textures: 0 },
  12432. i = { frame: 0, calls: 0, triangles: 0, points: 0, lines: 0 };
  12433. function r(n, a, o) {
  12434. switch ((i.calls++, a)) {
  12435. case 4:
  12436. i.triangles += o * (n / 3);
  12437. break;
  12438. case 1:
  12439. i.lines += o * (n / 2);
  12440. break;
  12441. case 3:
  12442. i.lines += o * (n - 1);
  12443. break;
  12444. case 2:
  12445. i.lines += o * n;
  12446. break;
  12447. case 0:
  12448. i.points += o * n;
  12449. break;
  12450. default:
  12451. console.error('THREE.WebGLInfo: Unknown draw mode:', a);
  12452. break;
  12453. }
  12454. }
  12455. function s() {
  12456. i.frame++, (i.calls = 0), (i.triangles = 0), (i.points = 0), (i.lines = 0);
  12457. }
  12458. return { memory: t, render: i, programs: null, autoReset: !0, reset: s, update: r };
  12459. }
  12460. function f3(e, t) {
  12461. return e[0] - t[0];
  12462. }
  12463. function m3(e, t) {
  12464. return Math.abs(t[1]) - Math.abs(e[1]);
  12465. }
  12466. function g3(e, t, i) {
  12467. let r = {},
  12468. s = new Float32Array(8),
  12469. n = new WeakMap(),
  12470. a = new $e(),
  12471. o = [];
  12472. for (let h = 0; h < 8; h++) o[h] = [h, 0];
  12473. function l(h, u, c, d) {
  12474. let p = h.morphTargetInfluences;
  12475. if (t.isWebGL2 === !0) {
  12476. let f = u.morphAttributes.position || u.morphAttributes.normal || u.morphAttributes.color,
  12477. g = f !== void 0 ? f.length : 0,
  12478. m = n.get(u);
  12479. if (m === void 0 || m.count !== g) {
  12480. let b = function () {
  12481. D.dispose(), n.delete(u), u.removeEventListener('dispose', b);
  12482. };
  12483. m !== void 0 && m.texture.dispose();
  12484. let x = u.morphAttributes.position !== void 0,
  12485. w = u.morphAttributes.normal !== void 0,
  12486. A = u.morphAttributes.color !== void 0,
  12487. S = u.morphAttributes.position || [],
  12488. _ = u.morphAttributes.normal || [],
  12489. M = u.morphAttributes.color || [],
  12490. C = 0;
  12491. x === !0 && (C = 1), w === !0 && (C = 2), A === !0 && (C = 3);
  12492. let T = u.attributes.position.count * C,
  12493. P = 1;
  12494. T > t.maxTextureSize && ((P = Math.ceil(T / t.maxTextureSize)), (T = t.maxTextureSize));
  12495. let L = new Float32Array(T * P * 4 * g),
  12496. D = new mw(L, T, P, g);
  12497. (D.type = vn), (D.needsUpdate = !0);
  12498. let k = C * 4;
  12499. for (let W = 0; W < g; W++) {
  12500. let X = S[W],
  12501. z = _[W],
  12502. j = M[W],
  12503. U = T * P * 4 * W;
  12504. for (let N = 0; N < X.count; N++) {
  12505. let B = N * k;
  12506. x === !0 && (a.fromBufferAttribute(X, N), (L[U + B + 0] = a.x), (L[U + B + 1] = a.y), (L[U + B + 2] = a.z), (L[U + B + 3] = 0)),
  12507. w === !0 &&
  12508. (a.fromBufferAttribute(z, N), (L[U + B + 4] = a.x), (L[U + B + 5] = a.y), (L[U + B + 6] = a.z), (L[U + B + 7] = 0)),
  12509. A === !0 &&
  12510. (a.fromBufferAttribute(j, N),
  12511. (L[U + B + 8] = a.x),
  12512. (L[U + B + 9] = a.y),
  12513. (L[U + B + 10] = a.z),
  12514. (L[U + B + 11] = j.itemSize === 4 ? a.w : 1));
  12515. }
  12516. }
  12517. (m = { count: g, texture: D, size: new G(T, P) }), n.set(u, m), u.addEventListener('dispose', b);
  12518. }
  12519. let v = 0;
  12520. for (let b = 0; b < p.length; b++) v += p[b];
  12521. let y = u.morphTargetsRelative ? 1 : 1 - v;
  12522. d.getUniforms().setValue(e, 'morphTargetBaseInfluence', y),
  12523. d.getUniforms().setValue(e, 'morphTargetInfluences', p),
  12524. d.getUniforms().setValue(e, 'morphTargetsTexture', m.texture, i),
  12525. d.getUniforms().setValue(e, 'morphTargetsTextureSize', m.size);
  12526. } else {
  12527. let f = p === void 0 ? 0 : p.length,
  12528. g = r[u.id];
  12529. if (g === void 0 || g.length !== f) {
  12530. g = [];
  12531. for (let x = 0; x < f; x++) g[x] = [x, 0];
  12532. r[u.id] = g;
  12533. }
  12534. for (let x = 0; x < f; x++) {
  12535. let w = g[x];
  12536. (w[0] = x), (w[1] = p[x]);
  12537. }
  12538. g.sort(m3);
  12539. for (let x = 0; x < 8; x++)
  12540. x < f && g[x][1] ? ((o[x][0] = g[x][0]), (o[x][1] = g[x][1])) : ((o[x][0] = Number.MAX_SAFE_INTEGER), (o[x][1] = 0));
  12541. o.sort(f3);
  12542. let m = u.morphAttributes.position,
  12543. v = u.morphAttributes.normal,
  12544. y = 0;
  12545. for (let x = 0; x < 8; x++) {
  12546. let w = o[x],
  12547. A = w[0],
  12548. S = w[1];
  12549. A !== Number.MAX_SAFE_INTEGER && S
  12550. ? (m && u.getAttribute('morphTarget' + x) !== m[A] && u.setAttribute('morphTarget' + x, m[A]),
  12551. v && u.getAttribute('morphNormal' + x) !== v[A] && u.setAttribute('morphNormal' + x, v[A]),
  12552. (s[x] = S),
  12553. (y += S))
  12554. : (m && u.hasAttribute('morphTarget' + x) === !0 && u.deleteAttribute('morphTarget' + x),
  12555. v && u.hasAttribute('morphNormal' + x) === !0 && u.deleteAttribute('morphNormal' + x),
  12556. (s[x] = 0));
  12557. }
  12558. let b = u.morphTargetsRelative ? 1 : 1 - y;
  12559. d.getUniforms().setValue(e, 'morphTargetBaseInfluence', b), d.getUniforms().setValue(e, 'morphTargetInfluences', s);
  12560. }
  12561. }
  12562. return { update: l };
  12563. }
  12564. function v3(e, t, i, r) {
  12565. let s = new WeakMap();
  12566. function n(l) {
  12567. let h = r.render.frame,
  12568. u = l.geometry,
  12569. c = t.get(l, u);
  12570. return (
  12571. s.get(c) !== h && (t.update(c), s.set(c, h)),
  12572. l.isInstancedMesh &&
  12573. (l.hasEventListener('dispose', o) === !1 && l.addEventListener('dispose', o),
  12574. i.update(l.instanceMatrix, 34962),
  12575. l.instanceColor !== null && i.update(l.instanceColor, 34962)),
  12576. c
  12577. );
  12578. }
  12579. function a() {
  12580. s = new WeakMap();
  12581. }
  12582. function o(l) {
  12583. let h = l.target;
  12584. h.removeEventListener('dispose', o), i.remove(h.instanceMatrix), h.instanceColor !== null && i.remove(h.instanceColor);
  12585. }
  12586. return { update: n, dispose: a };
  12587. }
  12588. var xw = new ci(),
  12589. bw = new mw(),
  12590. ww = new rE(),
  12591. _w = new cg(),
  12592. Z0 = [],
  12593. K0 = [],
  12594. J0 = new Float32Array(16),
  12595. $0 = new Float32Array(9),
  12596. ey = new Float32Array(4);
  12597. function Qo(e, t, i) {
  12598. let r = e[0];
  12599. if (r <= 0 || r > 0) return e;
  12600. let s = t * i,
  12601. n = Z0[s];
  12602. if ((n === void 0 && ((n = new Float32Array(s)), (Z0[s] = n)), t !== 0)) {
  12603. r.toArray(n, 0);
  12604. for (let a = 1, o = 0; a !== t; ++a) (o += i), e[a].toArray(n, o);
  12605. }
  12606. return n;
  12607. }
  12608. function si(e, t) {
  12609. if (e.length !== t.length) return !1;
  12610. for (let i = 0, r = e.length; i < r; i++) if (e[i] !== t[i]) return !1;
  12611. return !0;
  12612. }
  12613. function ni(e, t) {
  12614. for (let i = 0, r = t.length; i < r; i++) e[i] = t[i];
  12615. }
  12616. function lu(e, t) {
  12617. let i = K0[t];
  12618. i === void 0 && ((i = new Int32Array(t)), (K0[t] = i));
  12619. for (let r = 0; r !== t; ++r) i[r] = e.allocateTextureUnit();
  12620. return i;
  12621. }
  12622. function y3(e, t) {
  12623. let i = this.cache;
  12624. i[0] !== t && (e.uniform1f(this.addr, t), (i[0] = t));
  12625. }
  12626. function x3(e, t) {
  12627. let i = this.cache;
  12628. 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));
  12629. else {
  12630. if (si(i, t)) return;
  12631. e.uniform2fv(this.addr, t), ni(i, t);
  12632. }
  12633. }
  12634. function b3(e, t) {
  12635. let i = this.cache;
  12636. if (t.x !== void 0)
  12637. (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));
  12638. else if (t.r !== void 0)
  12639. (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));
  12640. else {
  12641. if (si(i, t)) return;
  12642. e.uniform3fv(this.addr, t), ni(i, t);
  12643. }
  12644. }
  12645. function w3(e, t) {
  12646. let i = this.cache;
  12647. if (t.x !== void 0)
  12648. (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z || i[3] !== t.w) &&
  12649. (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));
  12650. else {
  12651. if (si(i, t)) return;
  12652. e.uniform4fv(this.addr, t), ni(i, t);
  12653. }
  12654. }
  12655. function _3(e, t) {
  12656. let i = this.cache,
  12657. r = t.elements;
  12658. if (r === void 0) {
  12659. if (si(i, t)) return;
  12660. e.uniformMatrix2fv(this.addr, !1, t), ni(i, t);
  12661. } else {
  12662. if (si(i, r)) return;
  12663. ey.set(r), e.uniformMatrix2fv(this.addr, !1, ey), ni(i, r);
  12664. }
  12665. }
  12666. function A3(e, t) {
  12667. let i = this.cache,
  12668. r = t.elements;
  12669. if (r === void 0) {
  12670. if (si(i, t)) return;
  12671. e.uniformMatrix3fv(this.addr, !1, t), ni(i, t);
  12672. } else {
  12673. if (si(i, r)) return;
  12674. $0.set(r), e.uniformMatrix3fv(this.addr, !1, $0), ni(i, r);
  12675. }
  12676. }
  12677. function S3(e, t) {
  12678. let i = this.cache,
  12679. r = t.elements;
  12680. if (r === void 0) {
  12681. if (si(i, t)) return;
  12682. e.uniformMatrix4fv(this.addr, !1, t), ni(i, t);
  12683. } else {
  12684. if (si(i, r)) return;
  12685. J0.set(r), e.uniformMatrix4fv(this.addr, !1, J0), ni(i, r);
  12686. }
  12687. }
  12688. function M3(e, t) {
  12689. let i = this.cache;
  12690. i[0] !== t && (e.uniform1i(this.addr, t), (i[0] = t));
  12691. }
  12692. function E3(e, t) {
  12693. let i = this.cache;
  12694. 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));
  12695. else {
  12696. if (si(i, t)) return;
  12697. e.uniform2iv(this.addr, t), ni(i, t);
  12698. }
  12699. }
  12700. function C3(e, t) {
  12701. let i = this.cache;
  12702. if (t.x !== void 0)
  12703. (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));
  12704. else {
  12705. if (si(i, t)) return;
  12706. e.uniform3iv(this.addr, t), ni(i, t);
  12707. }
  12708. }
  12709. function T3(e, t) {
  12710. let i = this.cache;
  12711. if (t.x !== void 0)
  12712. (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z || i[3] !== t.w) &&
  12713. (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));
  12714. else {
  12715. if (si(i, t)) return;
  12716. e.uniform4iv(this.addr, t), ni(i, t);
  12717. }
  12718. }
  12719. function P3(e, t) {
  12720. let i = this.cache;
  12721. i[0] !== t && (e.uniform1ui(this.addr, t), (i[0] = t));
  12722. }
  12723. function D3(e, t) {
  12724. let i = this.cache;
  12725. 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));
  12726. else {
  12727. if (si(i, t)) return;
  12728. e.uniform2uiv(this.addr, t), ni(i, t);
  12729. }
  12730. }
  12731. function L3(e, t) {
  12732. let i = this.cache;
  12733. if (t.x !== void 0)
  12734. (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));
  12735. else {
  12736. if (si(i, t)) return;
  12737. e.uniform3uiv(this.addr, t), ni(i, t);
  12738. }
  12739. }
  12740. function O3(e, t) {
  12741. let i = this.cache;
  12742. if (t.x !== void 0)
  12743. (i[0] !== t.x || i[1] !== t.y || i[2] !== t.z || i[3] !== t.w) &&
  12744. (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));
  12745. else {
  12746. if (si(i, t)) return;
  12747. e.uniform4uiv(this.addr, t), ni(i, t);
  12748. }
  12749. }
  12750. function I3(e, t, i) {
  12751. let r = this.cache,
  12752. s = i.allocateTextureUnit();
  12753. r[0] !== s && (e.uniform1i(this.addr, s), (r[0] = s)), i.setTexture2D(t || xw, s);
  12754. }
  12755. function R3(e, t, i) {
  12756. let r = this.cache,
  12757. s = i.allocateTextureUnit();
  12758. r[0] !== s && (e.uniform1i(this.addr, s), (r[0] = s)), i.setTexture3D(t || ww, s);
  12759. }
  12760. function B3(e, t, i) {
  12761. let r = this.cache,
  12762. s = i.allocateTextureUnit();
  12763. r[0] !== s && (e.uniform1i(this.addr, s), (r[0] = s)), i.setTextureCube(t || _w, s);
  12764. }
  12765. function z3(e, t, i) {
  12766. let r = this.cache,
  12767. s = i.allocateTextureUnit();
  12768. r[0] !== s && (e.uniform1i(this.addr, s), (r[0] = s)), i.setTexture2DArray(t || bw, s);
  12769. }
  12770. function N3(e) {
  12771. switch (e) {
  12772. case 5126:
  12773. return y3;
  12774. case 35664:
  12775. return x3;
  12776. case 35665:
  12777. return b3;
  12778. case 35666:
  12779. return w3;
  12780. case 35674:
  12781. return _3;
  12782. case 35675:
  12783. return A3;
  12784. case 35676:
  12785. return S3;
  12786. case 5124:
  12787. case 35670:
  12788. return M3;
  12789. case 35667:
  12790. case 35671:
  12791. return E3;
  12792. case 35668:
  12793. case 35672:
  12794. return C3;
  12795. case 35669:
  12796. case 35673:
  12797. return T3;
  12798. case 5125:
  12799. return P3;
  12800. case 36294:
  12801. return D3;
  12802. case 36295:
  12803. return L3;
  12804. case 36296:
  12805. return O3;
  12806. case 35678:
  12807. case 36198:
  12808. case 36298:
  12809. case 36306:
  12810. case 35682:
  12811. return I3;
  12812. case 35679:
  12813. case 36299:
  12814. case 36307:
  12815. return R3;
  12816. case 35680:
  12817. case 36300:
  12818. case 36308:
  12819. case 36293:
  12820. return B3;
  12821. case 36289:
  12822. case 36303:
  12823. case 36311:
  12824. case 36292:
  12825. return z3;
  12826. }
  12827. }
  12828. function U3(e, t) {
  12829. e.uniform1fv(this.addr, t);
  12830. }
  12831. function F3(e, t) {
  12832. let i = Qo(t, this.size, 2);
  12833. e.uniform2fv(this.addr, i);
  12834. }
  12835. function k3(e, t) {
  12836. let i = Qo(t, this.size, 3);
  12837. e.uniform3fv(this.addr, i);
  12838. }
  12839. function j3(e, t) {
  12840. let i = Qo(t, this.size, 4);
  12841. e.uniform4fv(this.addr, i);
  12842. }
  12843. function G3(e, t) {
  12844. let i = Qo(t, this.size, 4);
  12845. e.uniformMatrix2fv(this.addr, !1, i);
  12846. }
  12847. function V3(e, t) {
  12848. let i = Qo(t, this.size, 9);
  12849. e.uniformMatrix3fv(this.addr, !1, i);
  12850. }
  12851. function H3(e, t) {
  12852. let i = Qo(t, this.size, 16);
  12853. e.uniformMatrix4fv(this.addr, !1, i);
  12854. }
  12855. function W3(e, t) {
  12856. e.uniform1iv(this.addr, t);
  12857. }
  12858. function X3(e, t) {
  12859. e.uniform2iv(this.addr, t);
  12860. }
  12861. function q3(e, t) {
  12862. e.uniform3iv(this.addr, t);
  12863. }
  12864. function Y3(e, t) {
  12865. e.uniform4iv(this.addr, t);
  12866. }
  12867. function Q3(e, t) {
  12868. e.uniform1uiv(this.addr, t);
  12869. }
  12870. function Z3(e, t) {
  12871. e.uniform2uiv(this.addr, t);
  12872. }
  12873. function K3(e, t) {
  12874. e.uniform3uiv(this.addr, t);
  12875. }
  12876. function J3(e, t) {
  12877. e.uniform4uiv(this.addr, t);
  12878. }
  12879. function $3(e, t, i) {
  12880. let r = this.cache,
  12881. s = t.length,
  12882. n = lu(i, s);
  12883. si(r, n) || (e.uniform1iv(this.addr, n), ni(r, n));
  12884. for (let a = 0; a !== s; ++a) i.setTexture2D(t[a] || xw, n[a]);
  12885. }
  12886. function eP(e, t, i) {
  12887. let r = this.cache,
  12888. s = t.length,
  12889. n = lu(i, s);
  12890. si(r, n) || (e.uniform1iv(this.addr, n), ni(r, n));
  12891. for (let a = 0; a !== s; ++a) i.setTexture3D(t[a] || ww, n[a]);
  12892. }
  12893. function tP(e, t, i) {
  12894. let r = this.cache,
  12895. s = t.length,
  12896. n = lu(i, s);
  12897. si(r, n) || (e.uniform1iv(this.addr, n), ni(r, n));
  12898. for (let a = 0; a !== s; ++a) i.setTextureCube(t[a] || _w, n[a]);
  12899. }
  12900. function iP(e, t, i) {
  12901. let r = this.cache,
  12902. s = t.length,
  12903. n = lu(i, s);
  12904. si(r, n) || (e.uniform1iv(this.addr, n), ni(r, n));
  12905. for (let a = 0; a !== s; ++a) i.setTexture2DArray(t[a] || bw, n[a]);
  12906. }
  12907. function rP(e) {
  12908. switch (e) {
  12909. case 5126:
  12910. return U3;
  12911. case 35664:
  12912. return F3;
  12913. case 35665:
  12914. return k3;
  12915. case 35666:
  12916. return j3;
  12917. case 35674:
  12918. return G3;
  12919. case 35675:
  12920. return V3;
  12921. case 35676:
  12922. return H3;
  12923. case 5124:
  12924. case 35670:
  12925. return W3;
  12926. case 35667:
  12927. case 35671:
  12928. return X3;
  12929. case 35668:
  12930. case 35672:
  12931. return q3;
  12932. case 35669:
  12933. case 35673:
  12934. return Y3;
  12935. case 5125:
  12936. return Q3;
  12937. case 36294:
  12938. return Z3;
  12939. case 36295:
  12940. return K3;
  12941. case 36296:
  12942. return J3;
  12943. case 35678:
  12944. case 36198:
  12945. case 36298:
  12946. case 36306:
  12947. case 35682:
  12948. return $3;
  12949. case 35679:
  12950. case 36299:
  12951. case 36307:
  12952. return eP;
  12953. case 35680:
  12954. case 36300:
  12955. case 36308:
  12956. case 36293:
  12957. return tP;
  12958. case 36289:
  12959. case 36303:
  12960. case 36311:
  12961. case 36292:
  12962. return iP;
  12963. }
  12964. }
  12965. var sP = class {
  12966. constructor(e, t, i) {
  12967. (this.id = e), (this.addr = i), (this.cache = []), (this.setValue = N3(t.type));
  12968. }
  12969. },
  12970. nP = class {
  12971. constructor(e, t, i) {
  12972. (this.id = e), (this.addr = i), (this.cache = []), (this.size = t.size), (this.setValue = rP(t.type));
  12973. }
  12974. },
  12975. aP = class {
  12976. constructor(e) {
  12977. (this.id = e), (this.seq = []), (this.map = {});
  12978. }
  12979. setValue(e, t, i) {
  12980. let r = this.seq;
  12981. for (let s = 0, n = r.length; s !== n; ++s) {
  12982. let a = r[s];
  12983. a.setValue(e, t[a.id], i);
  12984. }
  12985. }
  12986. },
  12987. wp = /(\w+)(\])?(\[|\.)?/g;
  12988. function ty(e, t) {
  12989. e.seq.push(t), (e.map[t.id] = t);
  12990. }
  12991. function oP(e, t, i) {
  12992. let r = e.name,
  12993. s = r.length;
  12994. for (wp.lastIndex = 0; ; ) {
  12995. let n = wp.exec(r),
  12996. a = wp.lastIndex,
  12997. o = n[1],
  12998. l = n[2] === ']',
  12999. h = n[3];
  13000. if ((l && (o = o | 0), h === void 0 || (h === '[' && a + 2 === s))) {
  13001. ty(i, h === void 0 ? new sP(o, e, t) : new nP(o, e, t));
  13002. break;
  13003. } else {
  13004. let u = i.map[o];
  13005. u === void 0 && ((u = new aP(o)), ty(i, u)), (i = u);
  13006. }
  13007. }
  13008. }
  13009. var Jc = class {
  13010. constructor(e, t) {
  13011. (this.seq = []), (this.map = {});
  13012. let i = e.getProgramParameter(t, 35718);
  13013. for (let r = 0; r < i; ++r) {
  13014. let s = e.getActiveUniform(t, r),
  13015. n = e.getUniformLocation(t, s.name);
  13016. oP(s, n, this);
  13017. }
  13018. }
  13019. setValue(e, t, i, r) {
  13020. let s = this.map[t];
  13021. s !== void 0 && s.setValue(e, i, r);
  13022. }
  13023. setOptional(e, t, i) {
  13024. let r = t[i];
  13025. r !== void 0 && this.setValue(e, i, r);
  13026. }
  13027. static upload(e, t, i, r) {
  13028. for (let s = 0, n = t.length; s !== n; ++s) {
  13029. let a = t[s],
  13030. o = i[a.id];
  13031. o.needsUpdate !== !1 && a.setValue(e, o.value, r);
  13032. }
  13033. }
  13034. static seqWithValue(e, t) {
  13035. let i = [];
  13036. for (let r = 0, s = e.length; r !== s; ++r) {
  13037. let n = e[r];
  13038. n.id in t && i.push(n);
  13039. }
  13040. return i;
  13041. }
  13042. };
  13043. function iy(e, t, i) {
  13044. let r = e.createShader(t);
  13045. return e.shaderSource(r, i), e.compileShader(r), r;
  13046. }
  13047. var lP = 0;
  13048. function hP(e, t) {
  13049. let i = e.split(`
  13050. `),
  13051. r = [],
  13052. s = Math.max(t - 6, 0),
  13053. n = Math.min(t + 6, i.length);
  13054. for (let a = s; a < n; a++) {
  13055. let o = a + 1;
  13056. r.push(`${o === t ? '>' : ' '} ${o}: ${i[a]}`);
  13057. }
  13058. return r.join(`
  13059. `);
  13060. }
  13061. function cP(e) {
  13062. switch (e) {
  13063. case gs:
  13064. return ['Linear', '( value )'];
  13065. case Ke:
  13066. return ['sRGB', '( value )'];
  13067. default:
  13068. return console.warn('THREE.WebGLProgram: Unsupported encoding:', e), ['Linear', '( value )'];
  13069. }
  13070. }
  13071. function ry(e, t, i) {
  13072. let r = e.getShaderParameter(t, 35713),
  13073. s = e.getShaderInfoLog(t).trim();
  13074. if (r && s === '') return '';
  13075. let n = /ERROR: 0:(\d+)/.exec(s);
  13076. if (n) {
  13077. let a = parseInt(n[1]);
  13078. return (
  13079. i.toUpperCase() +
  13080. `
  13081. ` +
  13082. s +
  13083. `
  13084. ` +
  13085. hP(e.getShaderSource(t), a)
  13086. );
  13087. } else return s;
  13088. }
  13089. function dP(e, t) {
  13090. let i = cP(t);
  13091. return 'vec4 ' + e + '( vec4 value ) { return LinearTo' + i[0] + i[1] + '; }';
  13092. }
  13093. function uP(e, t) {
  13094. let i;
  13095. switch (t) {
  13096. case vM:
  13097. i = 'Linear';
  13098. break;
  13099. case yM:
  13100. i = 'Reinhard';
  13101. break;
  13102. case xM:
  13103. i = 'OptimizedCineon';
  13104. break;
  13105. case bM:
  13106. i = 'ACESFilmic';
  13107. break;
  13108. case wM:
  13109. i = 'Custom';
  13110. break;
  13111. default:
  13112. console.warn('THREE.WebGLProgram: Unsupported toneMapping:', t), (i = 'Linear');
  13113. }
  13114. return 'vec3 ' + e + '( vec3 color ) { return ' + i + 'ToneMapping( color ); }';
  13115. }
  13116. function pP(e) {
  13117. return [
  13118. e.extensionDerivatives ||
  13119. !!e.envMapCubeUVHeight ||
  13120. e.bumpMap ||
  13121. e.tangentSpaceNormalMap ||
  13122. e.clearcoatNormalMap ||
  13123. e.flatShading ||
  13124. e.shaderID === 'physical'
  13125. ? '#extension GL_OES_standard_derivatives : enable'
  13126. : '',
  13127. (e.extensionFragDepth || e.logarithmicDepthBuffer) && e.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '',
  13128. e.extensionDrawBuffers && e.rendererExtensionDrawBuffers ? '#extension GL_EXT_draw_buffers : require' : '',
  13129. (e.extensionShaderTextureLOD || e.envMap || e.transmission) && e.rendererExtensionShaderTextureLod
  13130. ? '#extension GL_EXT_shader_texture_lod : enable'
  13131. : ''
  13132. ].filter(Gl).join(`
  13133. `);
  13134. }
  13135. function fP(e) {
  13136. let t = [];
  13137. for (let i in e) {
  13138. let r = e[i];
  13139. r !== !1 && t.push('#define ' + i + ' ' + r);
  13140. }
  13141. return t.join(`
  13142. `);
  13143. }
  13144. function mP(e, t) {
  13145. let i = {},
  13146. r = e.getProgramParameter(t, 35721);
  13147. for (let s = 0; s < r; s++) {
  13148. let n = e.getActiveAttrib(t, s),
  13149. a = n.name,
  13150. o = 1;
  13151. n.type === 35674 && (o = 2),
  13152. n.type === 35675 && (o = 3),
  13153. n.type === 35676 && (o = 4),
  13154. (i[a] = { type: n.type, location: e.getAttribLocation(t, a), locationSize: o });
  13155. }
  13156. return i;
  13157. }
  13158. function Gl(e) {
  13159. return e !== '';
  13160. }
  13161. function sy(e, t) {
  13162. let i = t.numSpotLightShadows + t.numSpotLightMaps - t.numSpotLightShadowsWithMaps;
  13163. return e
  13164. .replace(/NUM_DIR_LIGHTS/g, t.numDirLights)
  13165. .replace(/NUM_SPOT_LIGHTS/g, t.numSpotLights)
  13166. .replace(/NUM_SPOT_LIGHT_MAPS/g, t.numSpotLightMaps)
  13167. .replace(/NUM_SPOT_LIGHT_COORDS/g, i)
  13168. .replace(/NUM_RECT_AREA_LIGHTS/g, t.numRectAreaLights)
  13169. .replace(/NUM_POINT_LIGHTS/g, t.numPointLights)
  13170. .replace(/NUM_HEMI_LIGHTS/g, t.numHemiLights)
  13171. .replace(/NUM_DIR_LIGHT_SHADOWS/g, t.numDirLightShadows)
  13172. .replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, t.numSpotLightShadowsWithMaps)
  13173. .replace(/NUM_SPOT_LIGHT_SHADOWS/g, t.numSpotLightShadows)
  13174. .replace(/NUM_POINT_LIGHT_SHADOWS/g, t.numPointLightShadows);
  13175. }
  13176. function ny(e, t) {
  13177. return e
  13178. .replace(/NUM_CLIPPING_PLANES/g, t.numClippingPlanes)
  13179. .replace(/UNION_CLIPPING_PLANES/g, t.numClippingPlanes - t.numClipIntersection);
  13180. }
  13181. var gP = /^[ \t]*#include +<([\w\d./]+)>/gm;
  13182. function Gf(e) {
  13183. return e.replace(gP, vP);
  13184. }
  13185. function vP(e, t) {
  13186. let i = Ze[t];
  13187. if (i === void 0) throw new Error('Can not resolve #include <' + t + '>');
  13188. return Gf(i);
  13189. }
  13190. var yP =
  13191. /#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;
  13192. function ay(e) {
  13193. return e.replace(yP, xP);
  13194. }
  13195. function xP(e, t, i, r) {
  13196. let s = '';
  13197. for (let n = parseInt(t); n < parseInt(i); n++) s += r.replace(/\[\s*i\s*\]/g, '[ ' + n + ' ]').replace(/UNROLLED_LOOP_INDEX/g, n);
  13198. return s;
  13199. }
  13200. function oy(e) {
  13201. let t =
  13202. 'precision ' +
  13203. e.precision +
  13204. ` float;
  13205. precision ` +
  13206. e.precision +
  13207. ' int;';
  13208. return (
  13209. e.precision === 'highp'
  13210. ? (t += `
  13211. #define HIGH_PRECISION`)
  13212. : e.precision === 'mediump'
  13213. ? (t += `
  13214. #define MEDIUM_PRECISION`)
  13215. : e.precision === 'lowp' &&
  13216. (t += `
  13217. #define LOW_PRECISION`),
  13218. t
  13219. );
  13220. }
  13221. function bP(e) {
  13222. let t = 'SHADOWMAP_TYPE_BASIC';
  13223. return (
  13224. e.shadowMapType === og
  13225. ? (t = 'SHADOWMAP_TYPE_PCF')
  13226. : e.shadowMapType === sw
  13227. ? (t = 'SHADOWMAP_TYPE_PCF_SOFT')
  13228. : e.shadowMapType === jl && (t = 'SHADOWMAP_TYPE_VSM'),
  13229. t
  13230. );
  13231. }
  13232. function wP(e) {
  13233. let t = 'ENVMAP_TYPE_CUBE';
  13234. if (e.envMap)
  13235. switch (e.envMapMode) {
  13236. case ya:
  13237. case xa:
  13238. t = 'ENVMAP_TYPE_CUBE';
  13239. break;
  13240. case Ch:
  13241. t = 'ENVMAP_TYPE_CUBE_UV';
  13242. break;
  13243. }
  13244. return t;
  13245. }
  13246. function _P(e) {
  13247. let t = 'ENVMAP_MODE_REFLECTION';
  13248. if (e.envMap)
  13249. switch (e.envMapMode) {
  13250. case xa:
  13251. t = 'ENVMAP_MODE_REFRACTION';
  13252. break;
  13253. }
  13254. return t;
  13255. }
  13256. function AP(e) {
  13257. let t = 'ENVMAP_BLENDING_NONE';
  13258. if (e.envMap)
  13259. switch (e.combine) {
  13260. case ow:
  13261. t = 'ENVMAP_BLENDING_MULTIPLY';
  13262. break;
  13263. case mM:
  13264. t = 'ENVMAP_BLENDING_MIX';
  13265. break;
  13266. case gM:
  13267. t = 'ENVMAP_BLENDING_ADD';
  13268. break;
  13269. }
  13270. return t;
  13271. }
  13272. function SP(e) {
  13273. let t = e.envMapCubeUVHeight;
  13274. if (t === null) return null;
  13275. let i = Math.log2(t) - 2,
  13276. r = 1 / t;
  13277. return { texelWidth: 1 / (3 * Math.max(Math.pow(2, i), 7 * 16)), texelHeight: r, maxMip: i };
  13278. }
  13279. function MP(e, t, i, r) {
  13280. let s = e.getContext(),
  13281. n = i.defines,
  13282. a = i.vertexShader,
  13283. o = i.fragmentShader,
  13284. l = bP(i),
  13285. h = wP(i),
  13286. u = _P(i),
  13287. c = AP(i),
  13288. d = SP(i),
  13289. p = i.isWebGL2 ? '' : pP(i),
  13290. f = fP(n),
  13291. g = s.createProgram(),
  13292. m,
  13293. v,
  13294. y = i.glslVersion
  13295. ? '#version ' +
  13296. i.glslVersion +
  13297. `
  13298. `
  13299. : '';
  13300. i.isRawShaderMaterial
  13301. ? ((m = [f].filter(Gl).join(`
  13302. `)),
  13303. m.length > 0 &&
  13304. (m += `
  13305. `),
  13306. (v = [p, f].filter(Gl).join(`
  13307. `)),
  13308. v.length > 0 &&
  13309. (v += `
  13310. `))
  13311. : ((m = [
  13312. oy(i),
  13313. '#define SHADER_NAME ' + i.shaderName,
  13314. f,
  13315. i.instancing ? '#define USE_INSTANCING' : '',
  13316. i.instancingColor ? '#define USE_INSTANCING_COLOR' : '',
  13317. i.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '',
  13318. i.useFog && i.fog ? '#define USE_FOG' : '',
  13319. i.useFog && i.fogExp2 ? '#define FOG_EXP2' : '',
  13320. i.map ? '#define USE_MAP' : '',
  13321. i.envMap ? '#define USE_ENVMAP' : '',
  13322. i.envMap ? '#define ' + u : '',
  13323. i.lightMap ? '#define USE_LIGHTMAP' : '',
  13324. i.aoMap ? '#define USE_AOMAP' : '',
  13325. i.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
  13326. i.bumpMap ? '#define USE_BUMPMAP' : '',
  13327. i.normalMap ? '#define USE_NORMALMAP' : '',
  13328. i.normalMap && i.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '',
  13329. i.normalMap && i.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '',
  13330. i.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
  13331. i.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
  13332. i.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
  13333. i.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '',
  13334. i.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '',
  13335. i.displacementMap && i.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '',
  13336. i.specularMap ? '#define USE_SPECULARMAP' : '',
  13337. i.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '',
  13338. i.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '',
  13339. i.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',
  13340. i.metalnessMap ? '#define USE_METALNESSMAP' : '',
  13341. i.alphaMap ? '#define USE_ALPHAMAP' : '',
  13342. i.transmission ? '#define USE_TRANSMISSION' : '',
  13343. i.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '',
  13344. i.thicknessMap ? '#define USE_THICKNESSMAP' : '',
  13345. i.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '',
  13346. i.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '',
  13347. i.vertexTangents ? '#define USE_TANGENT' : '',
  13348. i.vertexColors ? '#define USE_COLOR' : '',
  13349. i.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',
  13350. i.vertexUvs ? '#define USE_UV' : '',
  13351. i.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '',
  13352. i.flatShading ? '#define FLAT_SHADED' : '',
  13353. i.skinning ? '#define USE_SKINNING' : '',
  13354. i.morphTargets ? '#define USE_MORPHTARGETS' : '',
  13355. i.morphNormals && i.flatShading === !1 ? '#define USE_MORPHNORMALS' : '',
  13356. i.morphColors && i.isWebGL2 ? '#define USE_MORPHCOLORS' : '',
  13357. i.morphTargetsCount > 0 && i.isWebGL2 ? '#define MORPHTARGETS_TEXTURE' : '',
  13358. i.morphTargetsCount > 0 && i.isWebGL2 ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + i.morphTextureStride : '',
  13359. i.morphTargetsCount > 0 && i.isWebGL2 ? '#define MORPHTARGETS_COUNT ' + i.morphTargetsCount : '',
  13360. i.doubleSided ? '#define DOUBLE_SIDED' : '',
  13361. i.flipSided ? '#define FLIP_SIDED' : '',
  13362. i.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',
  13363. i.shadowMapEnabled ? '#define ' + l : '',
  13364. i.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '',
  13365. i.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
  13366. i.logarithmicDepthBuffer && i.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '',
  13367. 'uniform mat4 modelMatrix;',
  13368. 'uniform mat4 modelViewMatrix;',
  13369. 'uniform mat4 projectionMatrix;',
  13370. 'uniform mat4 viewMatrix;',
  13371. 'uniform mat3 normalMatrix;',
  13372. 'uniform vec3 cameraPosition;',
  13373. 'uniform bool isOrthographic;',
  13374. '#ifdef USE_INSTANCING',
  13375. '\tattribute mat4 instanceMatrix;',
  13376. '#endif',
  13377. '#ifdef USE_INSTANCING_COLOR',
  13378. '\tattribute vec3 instanceColor;',
  13379. '#endif',
  13380. 'attribute vec3 position;',
  13381. 'attribute vec3 normal;',
  13382. 'attribute vec2 uv;',
  13383. '#ifdef USE_TANGENT',
  13384. '\tattribute vec4 tangent;',
  13385. '#endif',
  13386. '#if defined( USE_COLOR_ALPHA )',
  13387. '\tattribute vec4 color;',
  13388. '#elif defined( USE_COLOR )',
  13389. '\tattribute vec3 color;',
  13390. '#endif',
  13391. '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )',
  13392. '\tattribute vec3 morphTarget0;',
  13393. '\tattribute vec3 morphTarget1;',
  13394. '\tattribute vec3 morphTarget2;',
  13395. '\tattribute vec3 morphTarget3;',
  13396. '\t#ifdef USE_MORPHNORMALS',
  13397. '\t\tattribute vec3 morphNormal0;',
  13398. '\t\tattribute vec3 morphNormal1;',
  13399. '\t\tattribute vec3 morphNormal2;',
  13400. '\t\tattribute vec3 morphNormal3;',
  13401. '\t#else',
  13402. '\t\tattribute vec3 morphTarget4;',
  13403. '\t\tattribute vec3 morphTarget5;',
  13404. '\t\tattribute vec3 morphTarget6;',
  13405. '\t\tattribute vec3 morphTarget7;',
  13406. '\t#endif',
  13407. '#endif',
  13408. '#ifdef USE_SKINNING',
  13409. '\tattribute vec4 skinIndex;',
  13410. '\tattribute vec4 skinWeight;',
  13411. '#endif',
  13412. `
  13413. `
  13414. ].filter(Gl).join(`
  13415. `)),
  13416. (v = [
  13417. p,
  13418. oy(i),
  13419. '#define SHADER_NAME ' + i.shaderName,
  13420. f,
  13421. i.useFog && i.fog ? '#define USE_FOG' : '',
  13422. i.useFog && i.fogExp2 ? '#define FOG_EXP2' : '',
  13423. i.map ? '#define USE_MAP' : '',
  13424. i.matcap ? '#define USE_MATCAP' : '',
  13425. i.envMap ? '#define USE_ENVMAP' : '',
  13426. i.envMap ? '#define ' + h : '',
  13427. i.envMap ? '#define ' + u : '',
  13428. i.envMap ? '#define ' + c : '',
  13429. d ? '#define CUBEUV_TEXEL_WIDTH ' + d.texelWidth : '',
  13430. d ? '#define CUBEUV_TEXEL_HEIGHT ' + d.texelHeight : '',
  13431. d ? '#define CUBEUV_MAX_MIP ' + d.maxMip + '.0' : '',
  13432. i.lightMap ? '#define USE_LIGHTMAP' : '',
  13433. i.aoMap ? '#define USE_AOMAP' : '',
  13434. i.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
  13435. i.bumpMap ? '#define USE_BUMPMAP' : '',
  13436. i.normalMap ? '#define USE_NORMALMAP' : '',
  13437. i.normalMap && i.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '',
  13438. i.normalMap && i.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '',
  13439. i.clearcoat ? '#define USE_CLEARCOAT' : '',
  13440. i.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
  13441. i.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
  13442. i.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
  13443. i.iridescence ? '#define USE_IRIDESCENCE' : '',
  13444. i.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '',
  13445. i.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '',
  13446. i.specularMap ? '#define USE_SPECULARMAP' : '',
  13447. i.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '',
  13448. i.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '',
  13449. i.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',
  13450. i.metalnessMap ? '#define USE_METALNESSMAP' : '',
  13451. i.alphaMap ? '#define USE_ALPHAMAP' : '',
  13452. i.alphaTest ? '#define USE_ALPHATEST' : '',
  13453. i.sheen ? '#define USE_SHEEN' : '',
  13454. i.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '',
  13455. i.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '',
  13456. i.transmission ? '#define USE_TRANSMISSION' : '',
  13457. i.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '',
  13458. i.thicknessMap ? '#define USE_THICKNESSMAP' : '',
  13459. i.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
  13460. i.vertexTangents ? '#define USE_TANGENT' : '',
  13461. i.vertexColors || i.instancingColor ? '#define USE_COLOR' : '',
  13462. i.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',
  13463. i.vertexUvs ? '#define USE_UV' : '',
  13464. i.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '',
  13465. i.gradientMap ? '#define USE_GRADIENTMAP' : '',
  13466. i.flatShading ? '#define FLAT_SHADED' : '',
  13467. i.doubleSided ? '#define DOUBLE_SIDED' : '',
  13468. i.flipSided ? '#define FLIP_SIDED' : '',
  13469. i.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',
  13470. i.shadowMapEnabled ? '#define ' + l : '',
  13471. i.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '',
  13472. i.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '',
  13473. i.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
  13474. i.logarithmicDepthBuffer && i.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '',
  13475. 'uniform mat4 viewMatrix;',
  13476. 'uniform vec3 cameraPosition;',
  13477. 'uniform bool isOrthographic;',
  13478. i.toneMapping !== Gs ? '#define TONE_MAPPING' : '',
  13479. i.toneMapping !== Gs ? Ze.tonemapping_pars_fragment : '',
  13480. i.toneMapping !== Gs ? uP('toneMapping', i.toneMapping) : '',
  13481. i.dithering ? '#define DITHERING' : '',
  13482. i.opaque ? '#define OPAQUE' : '',
  13483. Ze.encodings_pars_fragment,
  13484. dP('linearToOutputTexel', i.outputEncoding),
  13485. i.useDepthPacking ? '#define DEPTH_PACKING ' + i.depthPacking : '',
  13486. `
  13487. `
  13488. ].filter(Gl).join(`
  13489. `))),
  13490. (a = Gf(a)),
  13491. (a = sy(a, i)),
  13492. (a = ny(a, i)),
  13493. (o = Gf(o)),
  13494. (o = sy(o, i)),
  13495. (o = ny(o, i)),
  13496. (a = ay(a)),
  13497. (o = ay(o)),
  13498. i.isWebGL2 &&
  13499. i.isRawShaderMaterial !== !0 &&
  13500. ((y = `#version 300 es
  13501. `),
  13502. (m =
  13503. ['precision mediump sampler2DArray;', '#define attribute in', '#define varying out', '#define texture2D texture'].join(`
  13504. `) +
  13505. `
  13506. ` +
  13507. m),
  13508. (v =
  13509. [
  13510. '#define varying in',
  13511. i.glslVersion === L0 ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;',
  13512. i.glslVersion === L0 ? '' : '#define gl_FragColor pc_fragColor',
  13513. '#define gl_FragDepthEXT gl_FragDepth',
  13514. '#define texture2D texture',
  13515. '#define textureCube texture',
  13516. '#define texture2DProj textureProj',
  13517. '#define texture2DLodEXT textureLod',
  13518. '#define texture2DProjLodEXT textureProjLod',
  13519. '#define textureCubeLodEXT textureLod',
  13520. '#define texture2DGradEXT textureGrad',
  13521. '#define texture2DProjGradEXT textureProjGrad',
  13522. '#define textureCubeGradEXT textureGrad'
  13523. ].join(`
  13524. `) +
  13525. `
  13526. ` +
  13527. v));
  13528. let b = y + m + a,
  13529. x = y + v + o,
  13530. w = iy(s, 35633, b),
  13531. A = iy(s, 35632, x);
  13532. if (
  13533. (s.attachShader(g, w),
  13534. s.attachShader(g, A),
  13535. i.index0AttributeName !== void 0
  13536. ? s.bindAttribLocation(g, 0, i.index0AttributeName)
  13537. : i.morphTargets === !0 && s.bindAttribLocation(g, 0, 'position'),
  13538. s.linkProgram(g),
  13539. e.debug.checkShaderErrors)
  13540. ) {
  13541. let M = s.getProgramInfoLog(g).trim(),
  13542. C = s.getShaderInfoLog(w).trim(),
  13543. T = s.getShaderInfoLog(A).trim(),
  13544. P = !0,
  13545. L = !0;
  13546. if (s.getProgramParameter(g, 35714) === !1) {
  13547. P = !1;
  13548. let D = ry(s, w, 'vertex'),
  13549. k = ry(s, A, 'fragment');
  13550. console.error(
  13551. 'THREE.WebGLProgram: Shader Error ' +
  13552. s.getError() +
  13553. ' - VALIDATE_STATUS ' +
  13554. s.getProgramParameter(g, 35715) +
  13555. `
  13556. Program Info Log: ` +
  13557. M +
  13558. `
  13559. ` +
  13560. D +
  13561. `
  13562. ` +
  13563. k
  13564. );
  13565. } else M !== '' ? console.warn('THREE.WebGLProgram: Program Info Log:', M) : (C === '' || T === '') && (L = !1);
  13566. L && (this.diagnostics = { runnable: P, programLog: M, vertexShader: { log: C, prefix: m }, fragmentShader: { log: T, prefix: v } });
  13567. }
  13568. s.deleteShader(w), s.deleteShader(A);
  13569. let S;
  13570. this.getUniforms = function () {
  13571. return S === void 0 && (S = new Jc(s, g)), S;
  13572. };
  13573. let _;
  13574. return (
  13575. (this.getAttributes = function () {
  13576. return _ === void 0 && (_ = mP(s, g)), _;
  13577. }),
  13578. (this.destroy = function () {
  13579. r.releaseStatesOfProgram(this), s.deleteProgram(g), (this.program = void 0);
  13580. }),
  13581. (this.name = i.shaderName),
  13582. (this.id = lP++),
  13583. (this.cacheKey = t),
  13584. (this.usedTimes = 1),
  13585. (this.program = g),
  13586. (this.vertexShader = w),
  13587. (this.fragmentShader = A),
  13588. this
  13589. );
  13590. }
  13591. var EP = 0,
  13592. CP = class {
  13593. constructor() {
  13594. (this.shaderCache = new Map()), (this.materialCache = new Map());
  13595. }
  13596. update(e) {
  13597. let t = e.vertexShader,
  13598. i = e.fragmentShader,
  13599. r = this._getShaderStage(t),
  13600. s = this._getShaderStage(i),
  13601. n = this._getShaderCacheForMaterial(e);
  13602. return n.has(r) === !1 && (n.add(r), r.usedTimes++), n.has(s) === !1 && (n.add(s), s.usedTimes++), this;
  13603. }
  13604. remove(e) {
  13605. let t = this.materialCache.get(e);
  13606. for (let i of t) i.usedTimes--, i.usedTimes === 0 && this.shaderCache.delete(i.code);
  13607. return this.materialCache.delete(e), this;
  13608. }
  13609. getVertexShaderID(e) {
  13610. return this._getShaderStage(e.vertexShader).id;
  13611. }
  13612. getFragmentShaderID(e) {
  13613. return this._getShaderStage(e.fragmentShader).id;
  13614. }
  13615. dispose() {
  13616. this.shaderCache.clear(), this.materialCache.clear();
  13617. }
  13618. _getShaderCacheForMaterial(e) {
  13619. let t = this.materialCache,
  13620. i = t.get(e);
  13621. return i === void 0 && ((i = new Set()), t.set(e, i)), i;
  13622. }
  13623. _getShaderStage(e) {
  13624. let t = this.shaderCache,
  13625. i = t.get(e);
  13626. return i === void 0 && ((i = new TP(e)), t.set(e, i)), i;
  13627. }
  13628. },
  13629. TP = class {
  13630. constructor(e) {
  13631. (this.id = EP++), (this.code = e), (this.usedTimes = 0);
  13632. }
  13633. };
  13634. function PP(e, t, i, r, s, n, a) {
  13635. let o = new hg(),
  13636. l = new CP(),
  13637. h = [],
  13638. u = s.isWebGL2,
  13639. c = s.logarithmicDepthBuffer,
  13640. d = s.vertexTextures,
  13641. p = s.precision,
  13642. f = {
  13643. MeshDepthMaterial: 'depth',
  13644. MeshDistanceMaterial: 'distanceRGBA',
  13645. MeshNormalMaterial: 'normal',
  13646. MeshBasicMaterial: 'basic',
  13647. MeshLambertMaterial: 'lambert',
  13648. MeshPhongMaterial: 'phong',
  13649. MeshToonMaterial: 'toon',
  13650. MeshStandardMaterial: 'physical',
  13651. MeshPhysicalMaterial: 'physical',
  13652. MeshMatcapMaterial: 'matcap',
  13653. LineBasicMaterial: 'basic',
  13654. LineDashedMaterial: 'dashed',
  13655. PointsMaterial: 'points',
  13656. ShadowMaterial: 'shadow',
  13657. SpriteMaterial: 'sprite'
  13658. };
  13659. function g(_, M, C, T, P) {
  13660. let L = T.fog,
  13661. D = P.geometry,
  13662. k = _.isMeshStandardMaterial ? T.environment : null,
  13663. W = (_.isMeshStandardMaterial ? i : t).get(_.envMap || k),
  13664. X = !!W && W.mapping === Ch ? W.image.height : null,
  13665. z = f[_.type];
  13666. _.precision !== null &&
  13667. ((p = s.getMaxPrecision(_.precision)),
  13668. p !== _.precision && console.warn('THREE.WebGLProgram.getParameters:', _.precision, 'not supported, using', p, 'instead.'));
  13669. let j = D.morphAttributes.position || D.morphAttributes.normal || D.morphAttributes.color,
  13670. U = j !== void 0 ? j.length : 0,
  13671. N = 0;
  13672. D.morphAttributes.position !== void 0 && (N = 1),
  13673. D.morphAttributes.normal !== void 0 && (N = 2),
  13674. D.morphAttributes.color !== void 0 && (N = 3);
  13675. let B, H, Q, Y;
  13676. if (z) {
  13677. let J = ss[z];
  13678. (B = J.vertexShader), (H = J.fragmentShader);
  13679. } else (B = _.vertexShader), (H = _.fragmentShader), l.update(_), (Q = l.getVertexShaderID(_)), (Y = l.getFragmentShaderID(_));
  13680. let F = e.getRenderTarget(),
  13681. se = _.alphaTest > 0,
  13682. V = _.clearcoat > 0,
  13683. ee = _.iridescence > 0;
  13684. return {
  13685. isWebGL2: u,
  13686. shaderID: z,
  13687. shaderName: _.type,
  13688. vertexShader: B,
  13689. fragmentShader: H,
  13690. defines: _.defines,
  13691. customVertexShaderID: Q,
  13692. customFragmentShaderID: Y,
  13693. isRawShaderMaterial: _.isRawShaderMaterial === !0,
  13694. glslVersion: _.glslVersion,
  13695. precision: p,
  13696. instancing: P.isInstancedMesh === !0,
  13697. instancingColor: P.isInstancedMesh === !0 && P.instanceColor !== null,
  13698. supportsVertexTextures: d,
  13699. outputEncoding: F === null ? e.outputEncoding : F.isXRRenderTarget === !0 ? F.texture.encoding : gs,
  13700. map: !!_.map,
  13701. matcap: !!_.matcap,
  13702. envMap: !!W,
  13703. envMapMode: W && W.mapping,
  13704. envMapCubeUVHeight: X,
  13705. lightMap: !!_.lightMap,
  13706. aoMap: !!_.aoMap,
  13707. emissiveMap: !!_.emissiveMap,
  13708. bumpMap: !!_.bumpMap,
  13709. normalMap: !!_.normalMap,
  13710. objectSpaceNormalMap: _.normalMapType === FM,
  13711. tangentSpaceNormalMap: _.normalMapType === UM,
  13712. decodeVideoTexture: !!_.map && _.map.isVideoTexture === !0 && _.map.encoding === Ke,
  13713. clearcoat: V,
  13714. clearcoatMap: V && !!_.clearcoatMap,
  13715. clearcoatRoughnessMap: V && !!_.clearcoatRoughnessMap,
  13716. clearcoatNormalMap: V && !!_.clearcoatNormalMap,
  13717. iridescence: ee,
  13718. iridescenceMap: ee && !!_.iridescenceMap,
  13719. iridescenceThicknessMap: ee && !!_.iridescenceThicknessMap,
  13720. displacementMap: !!_.displacementMap,
  13721. roughnessMap: !!_.roughnessMap,
  13722. metalnessMap: !!_.metalnessMap,
  13723. specularMap: !!_.specularMap,
  13724. specularIntensityMap: !!_.specularIntensityMap,
  13725. specularColorMap: !!_.specularColorMap,
  13726. opaque: _.transparent === !1 && _.blending === Ao,
  13727. alphaMap: !!_.alphaMap,
  13728. alphaTest: se,
  13729. gradientMap: !!_.gradientMap,
  13730. sheen: _.sheen > 0,
  13731. sheenColorMap: !!_.sheenColorMap,
  13732. sheenRoughnessMap: !!_.sheenRoughnessMap,
  13733. transmission: _.transmission > 0,
  13734. transmissionMap: !!_.transmissionMap,
  13735. thicknessMap: !!_.thicknessMap,
  13736. combine: _.combine,
  13737. vertexTangents: !!_.normalMap && !!D.attributes.tangent,
  13738. vertexColors: _.vertexColors,
  13739. vertexAlphas: _.vertexColors === !0 && !!D.attributes.color && D.attributes.color.itemSize === 4,
  13740. vertexUvs:
  13741. !!_.map ||
  13742. !!_.bumpMap ||
  13743. !!_.normalMap ||
  13744. !!_.specularMap ||
  13745. !!_.alphaMap ||
  13746. !!_.emissiveMap ||
  13747. !!_.roughnessMap ||
  13748. !!_.metalnessMap ||
  13749. !!_.clearcoatMap ||
  13750. !!_.clearcoatRoughnessMap ||
  13751. !!_.clearcoatNormalMap ||
  13752. !!_.iridescenceMap ||
  13753. !!_.iridescenceThicknessMap ||
  13754. !!_.displacementMap ||
  13755. !!_.transmissionMap ||
  13756. !!_.thicknessMap ||
  13757. !!_.specularIntensityMap ||
  13758. !!_.specularColorMap ||
  13759. !!_.sheenColorMap ||
  13760. !!_.sheenRoughnessMap,
  13761. uvsVertexOnly:
  13762. !(
  13763. !!_.map ||
  13764. !!_.bumpMap ||
  13765. !!_.normalMap ||
  13766. !!_.specularMap ||
  13767. !!_.alphaMap ||
  13768. !!_.emissiveMap ||
  13769. !!_.roughnessMap ||
  13770. !!_.metalnessMap ||
  13771. !!_.clearcoatNormalMap ||
  13772. !!_.iridescenceMap ||
  13773. !!_.iridescenceThicknessMap ||
  13774. _.transmission > 0 ||
  13775. !!_.transmissionMap ||
  13776. !!_.thicknessMap ||
  13777. !!_.specularIntensityMap ||
  13778. !!_.specularColorMap ||
  13779. _.sheen > 0 ||
  13780. !!_.sheenColorMap ||
  13781. !!_.sheenRoughnessMap
  13782. ) && !!_.displacementMap,
  13783. fog: !!L,
  13784. useFog: _.fog === !0,
  13785. fogExp2: L && L.isFogExp2,
  13786. flatShading: !!_.flatShading,
  13787. sizeAttenuation: _.sizeAttenuation,
  13788. logarithmicDepthBuffer: c,
  13789. skinning: P.isSkinnedMesh === !0,
  13790. morphTargets: D.morphAttributes.position !== void 0,
  13791. morphNormals: D.morphAttributes.normal !== void 0,
  13792. morphColors: D.morphAttributes.color !== void 0,
  13793. morphTargetsCount: U,
  13794. morphTextureStride: N,
  13795. numDirLights: M.directional.length,
  13796. numPointLights: M.point.length,
  13797. numSpotLights: M.spot.length,
  13798. numSpotLightMaps: M.spotLightMap.length,
  13799. numRectAreaLights: M.rectArea.length,
  13800. numHemiLights: M.hemi.length,
  13801. numDirLightShadows: M.directionalShadowMap.length,
  13802. numPointLightShadows: M.pointShadowMap.length,
  13803. numSpotLightShadows: M.spotShadowMap.length,
  13804. numSpotLightShadowsWithMaps: M.numSpotLightShadowsWithMaps,
  13805. numClippingPlanes: a.numPlanes,
  13806. numClipIntersection: a.numIntersection,
  13807. dithering: _.dithering,
  13808. shadowMapEnabled: e.shadowMap.enabled && C.length > 0,
  13809. shadowMapType: e.shadowMap.type,
  13810. toneMapping: _.toneMapped ? e.toneMapping : Gs,
  13811. physicallyCorrectLights: e.physicallyCorrectLights,
  13812. premultipliedAlpha: _.premultipliedAlpha,
  13813. doubleSided: _.side === er,
  13814. flipSided: _.side === hi,
  13815. useDepthPacking: !!_.depthPacking,
  13816. depthPacking: _.depthPacking || 0,
  13817. index0AttributeName: _.index0AttributeName,
  13818. extensionDerivatives: _.extensions && _.extensions.derivatives,
  13819. extensionFragDepth: _.extensions && _.extensions.fragDepth,
  13820. extensionDrawBuffers: _.extensions && _.extensions.drawBuffers,
  13821. extensionShaderTextureLOD: _.extensions && _.extensions.shaderTextureLOD,
  13822. rendererExtensionFragDepth: u || r.has('EXT_frag_depth'),
  13823. rendererExtensionDrawBuffers: u || r.has('WEBGL_draw_buffers'),
  13824. rendererExtensionShaderTextureLod: u || r.has('EXT_shader_texture_lod'),
  13825. customProgramCacheKey: _.customProgramCacheKey()
  13826. };
  13827. }
  13828. function m(_) {
  13829. let M = [];
  13830. if ((_.shaderID ? M.push(_.shaderID) : (M.push(_.customVertexShaderID), M.push(_.customFragmentShaderID)), _.defines !== void 0))
  13831. for (let C in _.defines) M.push(C), M.push(_.defines[C]);
  13832. return _.isRawShaderMaterial === !1 && (v(M, _), y(M, _), M.push(e.outputEncoding)), M.push(_.customProgramCacheKey), M.join();
  13833. }
  13834. function v(_, M) {
  13835. _.push(M.precision),
  13836. _.push(M.outputEncoding),
  13837. _.push(M.envMapMode),
  13838. _.push(M.envMapCubeUVHeight),
  13839. _.push(M.combine),
  13840. _.push(M.vertexUvs),
  13841. _.push(M.fogExp2),
  13842. _.push(M.sizeAttenuation),
  13843. _.push(M.morphTargetsCount),
  13844. _.push(M.morphAttributeCount),
  13845. _.push(M.numDirLights),
  13846. _.push(M.numPointLights),
  13847. _.push(M.numSpotLights),
  13848. _.push(M.numSpotLightMaps),
  13849. _.push(M.numHemiLights),
  13850. _.push(M.numRectAreaLights),
  13851. _.push(M.numDirLightShadows),
  13852. _.push(M.numPointLightShadows),
  13853. _.push(M.numSpotLightShadows),
  13854. _.push(M.numSpotLightShadowsWithMaps),
  13855. _.push(M.shadowMapType),
  13856. _.push(M.toneMapping),
  13857. _.push(M.numClippingPlanes),
  13858. _.push(M.numClipIntersection),
  13859. _.push(M.depthPacking);
  13860. }
  13861. function y(_, M) {
  13862. o.disableAll(),
  13863. M.isWebGL2 && o.enable(0),
  13864. M.supportsVertexTextures && o.enable(1),
  13865. M.instancing && o.enable(2),
  13866. M.instancingColor && o.enable(3),
  13867. M.map && o.enable(4),
  13868. M.matcap && o.enable(5),
  13869. M.envMap && o.enable(6),
  13870. M.lightMap && o.enable(7),
  13871. M.aoMap && o.enable(8),
  13872. M.emissiveMap && o.enable(9),
  13873. M.bumpMap && o.enable(10),
  13874. M.normalMap && o.enable(11),
  13875. M.objectSpaceNormalMap && o.enable(12),
  13876. M.tangentSpaceNormalMap && o.enable(13),
  13877. M.clearcoat && o.enable(14),
  13878. M.clearcoatMap && o.enable(15),
  13879. M.clearcoatRoughnessMap && o.enable(16),
  13880. M.clearcoatNormalMap && o.enable(17),
  13881. M.iridescence && o.enable(18),
  13882. M.iridescenceMap && o.enable(19),
  13883. M.iridescenceThicknessMap && o.enable(20),
  13884. M.displacementMap && o.enable(21),
  13885. M.specularMap && o.enable(22),
  13886. M.roughnessMap && o.enable(23),
  13887. M.metalnessMap && o.enable(24),
  13888. M.gradientMap && o.enable(25),
  13889. M.alphaMap && o.enable(26),
  13890. M.alphaTest && o.enable(27),
  13891. M.vertexColors && o.enable(28),
  13892. M.vertexAlphas && o.enable(29),
  13893. M.vertexUvs && o.enable(30),
  13894. M.vertexTangents && o.enable(31),
  13895. M.uvsVertexOnly && o.enable(32),
  13896. _.push(o.mask),
  13897. o.disableAll(),
  13898. M.fog && o.enable(0),
  13899. M.useFog && o.enable(1),
  13900. M.flatShading && o.enable(2),
  13901. M.logarithmicDepthBuffer && o.enable(3),
  13902. M.skinning && o.enable(4),
  13903. M.morphTargets && o.enable(5),
  13904. M.morphNormals && o.enable(6),
  13905. M.morphColors && o.enable(7),
  13906. M.premultipliedAlpha && o.enable(8),
  13907. M.shadowMapEnabled && o.enable(9),
  13908. M.physicallyCorrectLights && o.enable(10),
  13909. M.doubleSided && o.enable(11),
  13910. M.flipSided && o.enable(12),
  13911. M.useDepthPacking && o.enable(13),
  13912. M.dithering && o.enable(14),
  13913. M.specularIntensityMap && o.enable(15),
  13914. M.specularColorMap && o.enable(16),
  13915. M.transmission && o.enable(17),
  13916. M.transmissionMap && o.enable(18),
  13917. M.thicknessMap && o.enable(19),
  13918. M.sheen && o.enable(20),
  13919. M.sheenColorMap && o.enable(21),
  13920. M.sheenRoughnessMap && o.enable(22),
  13921. M.decodeVideoTexture && o.enable(23),
  13922. M.opaque && o.enable(24),
  13923. _.push(o.mask);
  13924. }
  13925. function b(_) {
  13926. let M = f[_.type],
  13927. C;
  13928. if (M) {
  13929. let T = ss[M];
  13930. C = qo.clone(T.uniforms);
  13931. } else C = _.uniforms;
  13932. return C;
  13933. }
  13934. function x(_, M) {
  13935. let C;
  13936. for (let T = 0, P = h.length; T < P; T++) {
  13937. let L = h[T];
  13938. if (L.cacheKey === M) {
  13939. (C = L), ++C.usedTimes;
  13940. break;
  13941. }
  13942. }
  13943. return C === void 0 && ((C = new MP(e, M, _, n)), h.push(C)), C;
  13944. }
  13945. function w(_) {
  13946. if (--_.usedTimes === 0) {
  13947. let M = h.indexOf(_);
  13948. (h[M] = h[h.length - 1]), h.pop(), _.destroy();
  13949. }
  13950. }
  13951. function A(_) {
  13952. l.remove(_);
  13953. }
  13954. function S() {
  13955. l.dispose();
  13956. }
  13957. return {
  13958. getParameters: g,
  13959. getProgramCacheKey: m,
  13960. getUniforms: b,
  13961. acquireProgram: x,
  13962. releaseProgram: w,
  13963. releaseShaderCache: A,
  13964. programs: h,
  13965. dispose: S
  13966. };
  13967. }
  13968. function DP() {
  13969. let e = new WeakMap();
  13970. function t(n) {
  13971. let a = e.get(n);
  13972. return a === void 0 && ((a = {}), e.set(n, a)), a;
  13973. }
  13974. function i(n) {
  13975. e.delete(n);
  13976. }
  13977. function r(n, a, o) {
  13978. e.get(n)[a] = o;
  13979. }
  13980. function s() {
  13981. e = new WeakMap();
  13982. }
  13983. return { get: t, remove: i, update: r, dispose: s };
  13984. }
  13985. function LP(e, t) {
  13986. return e.groupOrder !== t.groupOrder
  13987. ? e.groupOrder - t.groupOrder
  13988. : e.renderOrder !== t.renderOrder
  13989. ? e.renderOrder - t.renderOrder
  13990. : e.material.id !== t.material.id
  13991. ? e.material.id - t.material.id
  13992. : e.z !== t.z
  13993. ? e.z - t.z
  13994. : e.id - t.id;
  13995. }
  13996. function ly(e, t) {
  13997. return e.groupOrder !== t.groupOrder
  13998. ? e.groupOrder - t.groupOrder
  13999. : e.renderOrder !== t.renderOrder
  14000. ? e.renderOrder - t.renderOrder
  14001. : e.z !== t.z
  14002. ? t.z - e.z
  14003. : e.id - t.id;
  14004. }
  14005. function hy() {
  14006. let e = [],
  14007. t = 0,
  14008. i = [],
  14009. r = [],
  14010. s = [];
  14011. function n() {
  14012. (t = 0), (i.length = 0), (r.length = 0), (s.length = 0);
  14013. }
  14014. function a(c, d, p, f, g, m) {
  14015. let v = e[t];
  14016. return (
  14017. v === void 0
  14018. ? ((v = { id: c.id, object: c, geometry: d, material: p, groupOrder: f, renderOrder: c.renderOrder, z: g, group: m }), (e[t] = v))
  14019. : ((v.id = c.id),
  14020. (v.object = c),
  14021. (v.geometry = d),
  14022. (v.material = p),
  14023. (v.groupOrder = f),
  14024. (v.renderOrder = c.renderOrder),
  14025. (v.z = g),
  14026. (v.group = m)),
  14027. t++,
  14028. v
  14029. );
  14030. }
  14031. function o(c, d, p, f, g, m) {
  14032. let v = a(c, d, p, f, g, m);
  14033. p.transmission > 0 ? r.push(v) : p.transparent === !0 ? s.push(v) : i.push(v);
  14034. }
  14035. function l(c, d, p, f, g, m) {
  14036. let v = a(c, d, p, f, g, m);
  14037. p.transmission > 0 ? r.unshift(v) : p.transparent === !0 ? s.unshift(v) : i.unshift(v);
  14038. }
  14039. function h(c, d) {
  14040. i.length > 1 && i.sort(c || LP), r.length > 1 && r.sort(d || ly), s.length > 1 && s.sort(d || ly);
  14041. }
  14042. function u() {
  14043. for (let c = t, d = e.length; c < d; c++) {
  14044. let p = e[c];
  14045. if (p.id === null) break;
  14046. (p.id = null), (p.object = null), (p.geometry = null), (p.material = null), (p.group = null);
  14047. }
  14048. }
  14049. return { opaque: i, transmissive: r, transparent: s, init: n, push: o, unshift: l, finish: u, sort: h };
  14050. }
  14051. function OP() {
  14052. let e = new WeakMap();
  14053. function t(r, s) {
  14054. let n = e.get(r),
  14055. a;
  14056. return n === void 0 ? ((a = new hy()), e.set(r, [a])) : s >= n.length ? ((a = new hy()), n.push(a)) : (a = n[s]), a;
  14057. }
  14058. function i() {
  14059. e = new WeakMap();
  14060. }
  14061. return { get: t, dispose: i };
  14062. }
  14063. function IP() {
  14064. let e = {};
  14065. return {
  14066. get: function (t) {
  14067. if (e[t.id] !== void 0) return e[t.id];
  14068. let i;
  14069. switch (t.type) {
  14070. case 'DirectionalLight':
  14071. i = { direction: new E(), color: new Ge() };
  14072. break;
  14073. case 'SpotLight':
  14074. i = { position: new E(), direction: new E(), color: new Ge(), distance: 0, coneCos: 0, penumbraCos: 0, decay: 0 };
  14075. break;
  14076. case 'PointLight':
  14077. i = { position: new E(), color: new Ge(), distance: 0, decay: 0 };
  14078. break;
  14079. case 'HemisphereLight':
  14080. i = { direction: new E(), skyColor: new Ge(), groundColor: new Ge() };
  14081. break;
  14082. case 'RectAreaLight':
  14083. i = { color: new Ge(), position: new E(), halfWidth: new E(), halfHeight: new E() };
  14084. break;
  14085. }
  14086. return (e[t.id] = i), i;
  14087. }
  14088. };
  14089. }
  14090. function RP() {
  14091. let e = {};
  14092. return {
  14093. get: function (t) {
  14094. if (e[t.id] !== void 0) return e[t.id];
  14095. let i;
  14096. switch (t.type) {
  14097. case 'DirectionalLight':
  14098. i = { shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, shadowMapSize: new G() };
  14099. break;
  14100. case 'SpotLight':
  14101. i = { shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, shadowMapSize: new G() };
  14102. break;
  14103. case 'PointLight':
  14104. i = { shadowBias: 0, shadowNormalBias: 0, shadowRadius: 1, shadowMapSize: new G(), shadowCameraNear: 1, shadowCameraFar: 1e3 };
  14105. break;
  14106. }
  14107. return (e[t.id] = i), i;
  14108. }
  14109. };
  14110. }
  14111. var BP = 0;
  14112. function zP(e, t) {
  14113. return (t.castShadow ? 2 : 0) - (e.castShadow ? 2 : 0) + (t.map ? 1 : 0) - (e.map ? 1 : 0);
  14114. }
  14115. function NP(e, t) {
  14116. let i = new IP(),
  14117. r = RP(),
  14118. s = {
  14119. version: 0,
  14120. hash: {
  14121. directionalLength: -1,
  14122. pointLength: -1,
  14123. spotLength: -1,
  14124. rectAreaLength: -1,
  14125. hemiLength: -1,
  14126. numDirectionalShadows: -1,
  14127. numPointShadows: -1,
  14128. numSpotShadows: -1,
  14129. numSpotMaps: -1
  14130. },
  14131. ambient: [0, 0, 0],
  14132. probe: [],
  14133. directional: [],
  14134. directionalShadow: [],
  14135. directionalShadowMap: [],
  14136. directionalShadowMatrix: [],
  14137. spot: [],
  14138. spotLightMap: [],
  14139. spotShadow: [],
  14140. spotShadowMap: [],
  14141. spotLightMatrix: [],
  14142. rectArea: [],
  14143. rectAreaLTC1: null,
  14144. rectAreaLTC2: null,
  14145. point: [],
  14146. pointShadow: [],
  14147. pointShadowMap: [],
  14148. pointShadowMatrix: [],
  14149. hemi: [],
  14150. numSpotLightShadowsWithMaps: 0
  14151. };
  14152. for (let u = 0; u < 9; u++) s.probe.push(new E());
  14153. let n = new E(),
  14154. a = new ve(),
  14155. o = new ve();
  14156. function l(u, c) {
  14157. let d = 0,
  14158. p = 0,
  14159. f = 0;
  14160. for (let T = 0; T < 9; T++) s.probe[T].set(0, 0, 0);
  14161. let g = 0,
  14162. m = 0,
  14163. v = 0,
  14164. y = 0,
  14165. b = 0,
  14166. x = 0,
  14167. w = 0,
  14168. A = 0,
  14169. S = 0,
  14170. _ = 0;
  14171. u.sort(zP);
  14172. let M = c !== !0 ? Math.PI : 1;
  14173. for (let T = 0, P = u.length; T < P; T++) {
  14174. let L = u[T],
  14175. D = L.color,
  14176. k = L.intensity,
  14177. W = L.distance,
  14178. X = L.shadow && L.shadow.map ? L.shadow.map.texture : null;
  14179. if (L.isAmbientLight) (d += D.r * k * M), (p += D.g * k * M), (f += D.b * k * M);
  14180. else if (L.isLightProbe) for (let z = 0; z < 9; z++) s.probe[z].addScaledVector(L.sh.coefficients[z], k);
  14181. else if (L.isDirectionalLight) {
  14182. let z = i.get(L);
  14183. if ((z.color.copy(L.color).multiplyScalar(L.intensity * M), L.castShadow)) {
  14184. let j = L.shadow,
  14185. U = r.get(L);
  14186. (U.shadowBias = j.bias),
  14187. (U.shadowNormalBias = j.normalBias),
  14188. (U.shadowRadius = j.radius),
  14189. (U.shadowMapSize = j.mapSize),
  14190. (s.directionalShadow[g] = U),
  14191. (s.directionalShadowMap[g] = X),
  14192. (s.directionalShadowMatrix[g] = L.shadow.matrix),
  14193. x++;
  14194. }
  14195. (s.directional[g] = z), g++;
  14196. } else if (L.isSpotLight) {
  14197. let z = i.get(L);
  14198. z.position.setFromMatrixPosition(L.matrixWorld),
  14199. z.color.copy(D).multiplyScalar(k * M),
  14200. (z.distance = W),
  14201. (z.coneCos = Math.cos(L.angle)),
  14202. (z.penumbraCos = Math.cos(L.angle * (1 - L.penumbra))),
  14203. (z.decay = L.decay),
  14204. (s.spot[v] = z);
  14205. let j = L.shadow;
  14206. if (
  14207. (L.map && ((s.spotLightMap[S] = L.map), S++, j.updateMatrices(L), L.castShadow && _++),
  14208. (s.spotLightMatrix[v] = j.matrix),
  14209. L.castShadow)
  14210. ) {
  14211. let U = r.get(L);
  14212. (U.shadowBias = j.bias),
  14213. (U.shadowNormalBias = j.normalBias),
  14214. (U.shadowRadius = j.radius),
  14215. (U.shadowMapSize = j.mapSize),
  14216. (s.spotShadow[v] = U),
  14217. (s.spotShadowMap[v] = X),
  14218. A++;
  14219. }
  14220. v++;
  14221. } else if (L.isRectAreaLight) {
  14222. let z = i.get(L);
  14223. z.color.copy(D).multiplyScalar(k),
  14224. z.halfWidth.set(L.width * 0.5, 0, 0),
  14225. z.halfHeight.set(0, L.height * 0.5, 0),
  14226. (s.rectArea[y] = z),
  14227. y++;
  14228. } else if (L.isPointLight) {
  14229. let z = i.get(L);
  14230. if ((z.color.copy(L.color).multiplyScalar(L.intensity * M), (z.distance = L.distance), (z.decay = L.decay), L.castShadow)) {
  14231. let j = L.shadow,
  14232. U = r.get(L);
  14233. (U.shadowBias = j.bias),
  14234. (U.shadowNormalBias = j.normalBias),
  14235. (U.shadowRadius = j.radius),
  14236. (U.shadowMapSize = j.mapSize),
  14237. (U.shadowCameraNear = j.camera.near),
  14238. (U.shadowCameraFar = j.camera.far),
  14239. (s.pointShadow[m] = U),
  14240. (s.pointShadowMap[m] = X),
  14241. (s.pointShadowMatrix[m] = L.shadow.matrix),
  14242. w++;
  14243. }
  14244. (s.point[m] = z), m++;
  14245. } else if (L.isHemisphereLight) {
  14246. let z = i.get(L);
  14247. z.skyColor.copy(L.color).multiplyScalar(k * M), z.groundColor.copy(L.groundColor).multiplyScalar(k * M), (s.hemi[b] = z), b++;
  14248. }
  14249. }
  14250. y > 0 &&
  14251. (t.isWebGL2 || e.has('OES_texture_float_linear') === !0
  14252. ? ((s.rectAreaLTC1 = ge.LTC_FLOAT_1), (s.rectAreaLTC2 = ge.LTC_FLOAT_2))
  14253. : e.has('OES_texture_half_float_linear') === !0
  14254. ? ((s.rectAreaLTC1 = ge.LTC_HALF_1), (s.rectAreaLTC2 = ge.LTC_HALF_2))
  14255. : console.error('THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.')),
  14256. (s.ambient[0] = d),
  14257. (s.ambient[1] = p),
  14258. (s.ambient[2] = f);
  14259. let C = s.hash;
  14260. (C.directionalLength !== g ||
  14261. C.pointLength !== m ||
  14262. C.spotLength !== v ||
  14263. C.rectAreaLength !== y ||
  14264. C.hemiLength !== b ||
  14265. C.numDirectionalShadows !== x ||
  14266. C.numPointShadows !== w ||
  14267. C.numSpotShadows !== A ||
  14268. C.numSpotMaps !== S) &&
  14269. ((s.directional.length = g),
  14270. (s.spot.length = v),
  14271. (s.rectArea.length = y),
  14272. (s.point.length = m),
  14273. (s.hemi.length = b),
  14274. (s.directionalShadow.length = x),
  14275. (s.directionalShadowMap.length = x),
  14276. (s.pointShadow.length = w),
  14277. (s.pointShadowMap.length = w),
  14278. (s.spotShadow.length = A),
  14279. (s.spotShadowMap.length = A),
  14280. (s.directionalShadowMatrix.length = x),
  14281. (s.pointShadowMatrix.length = w),
  14282. (s.spotLightMatrix.length = A + S - _),
  14283. (s.spotLightMap.length = S),
  14284. (s.numSpotLightShadowsWithMaps = _),
  14285. (C.directionalLength = g),
  14286. (C.pointLength = m),
  14287. (C.spotLength = v),
  14288. (C.rectAreaLength = y),
  14289. (C.hemiLength = b),
  14290. (C.numDirectionalShadows = x),
  14291. (C.numPointShadows = w),
  14292. (C.numSpotShadows = A),
  14293. (C.numSpotMaps = S),
  14294. (s.version = BP++));
  14295. }
  14296. function h(u, c) {
  14297. let d = 0,
  14298. p = 0,
  14299. f = 0,
  14300. g = 0,
  14301. m = 0,
  14302. v = c.matrixWorldInverse;
  14303. for (let y = 0, b = u.length; y < b; y++) {
  14304. let x = u[y];
  14305. if (x.isDirectionalLight) {
  14306. let w = s.directional[d];
  14307. w.direction.setFromMatrixPosition(x.matrixWorld),
  14308. n.setFromMatrixPosition(x.target.matrixWorld),
  14309. w.direction.sub(n),
  14310. w.direction.transformDirection(v),
  14311. d++;
  14312. } else if (x.isSpotLight) {
  14313. let w = s.spot[f];
  14314. w.position.setFromMatrixPosition(x.matrixWorld),
  14315. w.position.applyMatrix4(v),
  14316. w.direction.setFromMatrixPosition(x.matrixWorld),
  14317. n.setFromMatrixPosition(x.target.matrixWorld),
  14318. w.direction.sub(n),
  14319. w.direction.transformDirection(v),
  14320. f++;
  14321. } else if (x.isRectAreaLight) {
  14322. let w = s.rectArea[g];
  14323. w.position.setFromMatrixPosition(x.matrixWorld),
  14324. w.position.applyMatrix4(v),
  14325. o.identity(),
  14326. a.copy(x.matrixWorld),
  14327. a.premultiply(v),
  14328. o.extractRotation(a),
  14329. w.halfWidth.set(x.width * 0.5, 0, 0),
  14330. w.halfHeight.set(0, x.height * 0.5, 0),
  14331. w.halfWidth.applyMatrix4(o),
  14332. w.halfHeight.applyMatrix4(o),
  14333. g++;
  14334. } else if (x.isPointLight) {
  14335. let w = s.point[p];
  14336. w.position.setFromMatrixPosition(x.matrixWorld), w.position.applyMatrix4(v), p++;
  14337. } else if (x.isHemisphereLight) {
  14338. let w = s.hemi[m];
  14339. w.direction.setFromMatrixPosition(x.matrixWorld), w.direction.transformDirection(v), m++;
  14340. }
  14341. }
  14342. }
  14343. return { setup: l, setupView: h, state: s };
  14344. }
  14345. function cy(e, t) {
  14346. let i = new NP(e, t),
  14347. r = [],
  14348. s = [];
  14349. function n() {
  14350. (r.length = 0), (s.length = 0);
  14351. }
  14352. function a(u) {
  14353. r.push(u);
  14354. }
  14355. function o(u) {
  14356. s.push(u);
  14357. }
  14358. function l(u) {
  14359. i.setup(r, u);
  14360. }
  14361. function h(u) {
  14362. i.setupView(r, u);
  14363. }
  14364. return {
  14365. init: n,
  14366. state: { lightsArray: r, shadowsArray: s, lights: i },
  14367. setupLights: l,
  14368. setupLightsView: h,
  14369. pushLight: a,
  14370. pushShadow: o
  14371. };
  14372. }
  14373. function UP(e, t) {
  14374. let i = new WeakMap();
  14375. function r(n, a = 0) {
  14376. let o = i.get(n),
  14377. l;
  14378. return o === void 0 ? ((l = new cy(e, t)), i.set(n, [l])) : a >= o.length ? ((l = new cy(e, t)), o.push(l)) : (l = o[a]), l;
  14379. }
  14380. function s() {
  14381. i = new WeakMap();
  14382. }
  14383. return { get: r, dispose: s };
  14384. }
  14385. var Aw = class extends Th {
  14386. constructor(e) {
  14387. super(),
  14388. (this.isMeshDepthMaterial = !0),
  14389. (this.type = 'MeshDepthMaterial'),
  14390. (this.depthPacking = qs),
  14391. (this.map = null),
  14392. (this.alphaMap = null),
  14393. (this.displacementMap = null),
  14394. (this.displacementScale = 1),
  14395. (this.displacementBias = 0),
  14396. (this.wireframe = !1),
  14397. (this.wireframeLinewidth = 1),
  14398. this.setValues(e);
  14399. }
  14400. copy(e) {
  14401. return (
  14402. super.copy(e),
  14403. (this.depthPacking = e.depthPacking),
  14404. (this.map = e.map),
  14405. (this.alphaMap = e.alphaMap),
  14406. (this.displacementMap = e.displacementMap),
  14407. (this.displacementScale = e.displacementScale),
  14408. (this.displacementBias = e.displacementBias),
  14409. (this.wireframe = e.wireframe),
  14410. (this.wireframeLinewidth = e.wireframeLinewidth),
  14411. this
  14412. );
  14413. }
  14414. },
  14415. FP = class extends Th {
  14416. constructor(e) {
  14417. super(),
  14418. (this.isMeshDistanceMaterial = !0),
  14419. (this.type = 'MeshDistanceMaterial'),
  14420. (this.referencePosition = new E()),
  14421. (this.nearDistance = 1),
  14422. (this.farDistance = 1e3),
  14423. (this.map = null),
  14424. (this.alphaMap = null),
  14425. (this.displacementMap = null),
  14426. (this.displacementScale = 1),
  14427. (this.displacementBias = 0),
  14428. this.setValues(e);
  14429. }
  14430. copy(e) {
  14431. return (
  14432. super.copy(e),
  14433. this.referencePosition.copy(e.referencePosition),
  14434. (this.nearDistance = e.nearDistance),
  14435. (this.farDistance = e.farDistance),
  14436. (this.map = e.map),
  14437. (this.alphaMap = e.alphaMap),
  14438. (this.displacementMap = e.displacementMap),
  14439. (this.displacementScale = e.displacementScale),
  14440. (this.displacementBias = e.displacementBias),
  14441. this
  14442. );
  14443. }
  14444. },
  14445. kP = `void main() {
  14446. gl_Position = vec4( position, 1.0 );
  14447. }`,
  14448. jP = `uniform sampler2D shadow_pass;
  14449. uniform vec2 resolution;
  14450. uniform float radius;
  14451. #include <packing>
  14452. void main() {
  14453. const float samples = float( VSM_SAMPLES );
  14454. float mean = 0.0;
  14455. float squared_mean = 0.0;
  14456. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  14457. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  14458. for ( float i = 0.0; i < samples; i ++ ) {
  14459. float uvOffset = uvStart + i * uvStride;
  14460. #ifdef HORIZONTAL_PASS
  14461. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  14462. mean += distribution.x;
  14463. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  14464. #else
  14465. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  14466. mean += depth;
  14467. squared_mean += depth * depth;
  14468. #endif
  14469. }
  14470. mean = mean / samples;
  14471. squared_mean = squared_mean / samples;
  14472. float std_dev = sqrt( squared_mean - mean * mean );
  14473. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  14474. }`;
  14475. function GP(e, t, i) {
  14476. let r = new dg(),
  14477. s = new G(),
  14478. n = new G(),
  14479. a = new $e(),
  14480. o = new Aw({ depthPacking: cw }),
  14481. l = new FP(),
  14482. h = {},
  14483. u = i.maxTextureSize,
  14484. c = { [Vr]: hi, [hi]: Vr, [er]: er },
  14485. d = new ri({
  14486. defines: { VSM_SAMPLES: 8 },
  14487. uniforms: { shadow_pass: { value: null }, resolution: { value: new G() }, radius: { value: 4 } },
  14488. vertexShader: kP,
  14489. fragmentShader: jP
  14490. }),
  14491. p = d.clone();
  14492. p.defines.HORIZONTAL_PASS = 1;
  14493. let f = new Ve();
  14494. f.setAttribute('position', new Xe(new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]), 3));
  14495. let g = new tr(f, d),
  14496. m = this;
  14497. (this.enabled = !1),
  14498. (this.autoUpdate = !0),
  14499. (this.needsUpdate = !1),
  14500. (this.type = og),
  14501. (this.render = function (x, w, A) {
  14502. if (m.enabled === !1 || (m.autoUpdate === !1 && m.needsUpdate === !1) || x.length === 0) return;
  14503. let S = e.getRenderTarget(),
  14504. _ = e.getActiveCubeFace(),
  14505. M = e.getActiveMipmapLevel(),
  14506. C = e.state;
  14507. C.setBlending(fi), C.buffers.color.setClear(1, 1, 1, 1), C.buffers.depth.setTest(!0), C.setScissorTest(!1);
  14508. for (let T = 0, P = x.length; T < P; T++) {
  14509. let L = x[T],
  14510. D = L.shadow;
  14511. if (D === void 0) {
  14512. console.warn('THREE.WebGLShadowMap:', L, 'has no shadow.');
  14513. continue;
  14514. }
  14515. if (D.autoUpdate === !1 && D.needsUpdate === !1) continue;
  14516. s.copy(D.mapSize);
  14517. let k = D.getFrameExtents();
  14518. if (
  14519. (s.multiply(k),
  14520. n.copy(D.mapSize),
  14521. (s.x > u || s.y > u) &&
  14522. (s.x > u && ((n.x = Math.floor(u / k.x)), (s.x = n.x * k.x), (D.mapSize.x = n.x)),
  14523. s.y > u && ((n.y = Math.floor(u / k.y)), (s.y = n.y * k.y), (D.mapSize.y = n.y))),
  14524. D.map === null)
  14525. ) {
  14526. let X = this.type !== jl ? { minFilter: Ot, magFilter: Ot } : {};
  14527. (D.map = new ii(s.x, s.y, X)), (D.map.texture.name = L.name + '.shadowMap'), D.camera.updateProjectionMatrix();
  14528. }
  14529. e.setRenderTarget(D.map), e.clear();
  14530. let W = D.getViewportCount();
  14531. for (let X = 0; X < W; X++) {
  14532. let z = D.getViewport(X);
  14533. a.set(n.x * z.x, n.y * z.y, n.x * z.z, n.y * z.w),
  14534. C.viewport(a),
  14535. D.updateMatrices(L, X),
  14536. (r = D.getFrustum()),
  14537. b(w, A, D.camera, L, this.type);
  14538. }
  14539. D.isPointLightShadow !== !0 && this.type === jl && v(D, A), (D.needsUpdate = !1);
  14540. }
  14541. (m.needsUpdate = !1), e.setRenderTarget(S, _, M);
  14542. });
  14543. function v(x, w) {
  14544. let A = t.update(g);
  14545. d.defines.VSM_SAMPLES !== x.blurSamples &&
  14546. ((d.defines.VSM_SAMPLES = x.blurSamples), (p.defines.VSM_SAMPLES = x.blurSamples), (d.needsUpdate = !0), (p.needsUpdate = !0)),
  14547. x.mapPass === null && (x.mapPass = new ii(s.x, s.y)),
  14548. (d.uniforms.shadow_pass.value = x.map.texture),
  14549. (d.uniforms.resolution.value = x.mapSize),
  14550. (d.uniforms.radius.value = x.radius),
  14551. e.setRenderTarget(x.mapPass),
  14552. e.clear(),
  14553. e.renderBufferDirect(w, null, A, d, g, null),
  14554. (p.uniforms.shadow_pass.value = x.mapPass.texture),
  14555. (p.uniforms.resolution.value = x.mapSize),
  14556. (p.uniforms.radius.value = x.radius),
  14557. e.setRenderTarget(x.map),
  14558. e.clear(),
  14559. e.renderBufferDirect(w, null, A, p, g, null);
  14560. }
  14561. function y(x, w, A, S, _, M) {
  14562. let C = null,
  14563. T = A.isPointLight === !0 ? x.customDistanceMaterial : x.customDepthMaterial;
  14564. if (T !== void 0) C = T;
  14565. else if (
  14566. ((C = A.isPointLight === !0 ? l : o),
  14567. (e.localClippingEnabled && w.clipShadows === !0 && Array.isArray(w.clippingPlanes) && w.clippingPlanes.length !== 0) ||
  14568. (w.displacementMap && w.displacementScale !== 0) ||
  14569. (w.alphaMap && w.alphaTest > 0) ||
  14570. (w.map && w.alphaTest > 0))
  14571. ) {
  14572. let P = C.uuid,
  14573. L = w.uuid,
  14574. D = h[P];
  14575. D === void 0 && ((D = {}), (h[P] = D));
  14576. let k = D[L];
  14577. k === void 0 && ((k = C.clone()), (D[L] = k)), (C = k);
  14578. }
  14579. return (
  14580. (C.visible = w.visible),
  14581. (C.wireframe = w.wireframe),
  14582. M === jl ? (C.side = w.shadowSide !== null ? w.shadowSide : w.side) : (C.side = w.shadowSide !== null ? w.shadowSide : c[w.side]),
  14583. (C.alphaMap = w.alphaMap),
  14584. (C.alphaTest = w.alphaTest),
  14585. (C.map = w.map),
  14586. (C.clipShadows = w.clipShadows),
  14587. (C.clippingPlanes = w.clippingPlanes),
  14588. (C.clipIntersection = w.clipIntersection),
  14589. (C.displacementMap = w.displacementMap),
  14590. (C.displacementScale = w.displacementScale),
  14591. (C.displacementBias = w.displacementBias),
  14592. (C.wireframeLinewidth = w.wireframeLinewidth),
  14593. (C.linewidth = w.linewidth),
  14594. A.isPointLight === !0 &&
  14595. C.isMeshDistanceMaterial === !0 &&
  14596. (C.referencePosition.setFromMatrixPosition(A.matrixWorld), (C.nearDistance = S), (C.farDistance = _)),
  14597. C
  14598. );
  14599. }
  14600. function b(x, w, A, S, _) {
  14601. if (x.visible === !1) return;
  14602. if (
  14603. x.layers.test(w.layers) &&
  14604. (x.isMesh || x.isLine || x.isPoints) &&
  14605. (x.castShadow || (x.receiveShadow && _ === jl)) &&
  14606. (!x.frustumCulled || r.intersectsObject(x))
  14607. ) {
  14608. x.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse, x.matrixWorld);
  14609. let C = t.update(x),
  14610. T = x.material;
  14611. if (Array.isArray(T)) {
  14612. let P = C.groups;
  14613. for (let L = 0, D = P.length; L < D; L++) {
  14614. let k = P[L],
  14615. W = T[k.materialIndex];
  14616. if (W && W.visible) {
  14617. let X = y(x, W, S, A.near, A.far, _);
  14618. e.renderBufferDirect(A, null, C, X, x, k);
  14619. }
  14620. }
  14621. } else if (T.visible) {
  14622. let P = y(x, T, S, A.near, A.far, _);
  14623. e.renderBufferDirect(A, null, C, P, x, null);
  14624. }
  14625. }
  14626. let M = x.children;
  14627. for (let C = 0, T = M.length; C < T; C++) b(M[C], w, A, S, _);
  14628. }
  14629. }
  14630. function VP(e, t, i) {
  14631. let r = i.isWebGL2;
  14632. function s() {
  14633. let q = !1,
  14634. ne = new $e(),
  14635. de = null,
  14636. Ae = new $e(0, 0, 0, 0);
  14637. return {
  14638. setMask: function (De) {
  14639. de !== De && !q && (e.colorMask(De, De, De, De), (de = De));
  14640. },
  14641. setLocked: function (De) {
  14642. q = De;
  14643. },
  14644. setClear: function (De, ot, Xt, Ft, kn) {
  14645. kn === !0 && ((De *= Ft), (ot *= Ft), (Xt *= Ft)),
  14646. ne.set(De, ot, Xt, Ft),
  14647. Ae.equals(ne) === !1 && (e.clearColor(De, ot, Xt, Ft), Ae.copy(ne));
  14648. },
  14649. reset: function () {
  14650. (q = !1), (de = null), Ae.set(-1, 0, 0, 0);
  14651. }
  14652. };
  14653. }
  14654. function n() {
  14655. let q = !1,
  14656. ne = null,
  14657. de = null,
  14658. Ae = null;
  14659. return {
  14660. setTest: function (De) {
  14661. De ? se(2929) : V(2929);
  14662. },
  14663. setMask: function (De) {
  14664. ne !== De && !q && (e.depthMask(De), (ne = De));
  14665. },
  14666. setFunc: function (De) {
  14667. if (de !== De) {
  14668. switch (De) {
  14669. case lM:
  14670. e.depthFunc(512);
  14671. break;
  14672. case hM:
  14673. e.depthFunc(519);
  14674. break;
  14675. case cM:
  14676. e.depthFunc(513);
  14677. break;
  14678. case Bf:
  14679. e.depthFunc(515);
  14680. break;
  14681. case dM:
  14682. e.depthFunc(514);
  14683. break;
  14684. case uM:
  14685. e.depthFunc(518);
  14686. break;
  14687. case pM:
  14688. e.depthFunc(516);
  14689. break;
  14690. case fM:
  14691. e.depthFunc(517);
  14692. break;
  14693. default:
  14694. e.depthFunc(515);
  14695. }
  14696. de = De;
  14697. }
  14698. },
  14699. setLocked: function (De) {
  14700. q = De;
  14701. },
  14702. setClear: function (De) {
  14703. Ae !== De && (e.clearDepth(De), (Ae = De));
  14704. },
  14705. reset: function () {
  14706. (q = !1), (ne = null), (de = null), (Ae = null);
  14707. }
  14708. };
  14709. }
  14710. function a() {
  14711. let q = !1,
  14712. ne = null,
  14713. de = null,
  14714. Ae = null,
  14715. De = null,
  14716. ot = null,
  14717. Xt = null,
  14718. Ft = null,
  14719. kn = null;
  14720. return {
  14721. setTest: function (Dt) {
  14722. q || (Dt ? se(2960) : V(2960));
  14723. },
  14724. setMask: function (Dt) {
  14725. ne !== Dt && !q && (e.stencilMask(Dt), (ne = Dt));
  14726. },
  14727. setFunc: function (Dt, Ms, lr) {
  14728. (de !== Dt || Ae !== Ms || De !== lr) && (e.stencilFunc(Dt, Ms, lr), (de = Dt), (Ae = Ms), (De = lr));
  14729. },
  14730. setOp: function (Dt, Ms, lr) {
  14731. (ot !== Dt || Xt !== Ms || Ft !== lr) && (e.stencilOp(Dt, Ms, lr), (ot = Dt), (Xt = Ms), (Ft = lr));
  14732. },
  14733. setLocked: function (Dt) {
  14734. q = Dt;
  14735. },
  14736. setClear: function (Dt) {
  14737. kn !== Dt && (e.clearStencil(Dt), (kn = Dt));
  14738. },
  14739. reset: function () {
  14740. (q = !1), (ne = null), (de = null), (Ae = null), (De = null), (ot = null), (Xt = null), (Ft = null), (kn = null);
  14741. }
  14742. };
  14743. }
  14744. let o = new s(),
  14745. l = new n(),
  14746. h = new a(),
  14747. u = new WeakMap(),
  14748. c = new WeakMap(),
  14749. d = {},
  14750. p = {},
  14751. f = new WeakMap(),
  14752. g = [],
  14753. m = null,
  14754. v = !1,
  14755. y = null,
  14756. b = null,
  14757. x = null,
  14758. w = null,
  14759. A = null,
  14760. S = null,
  14761. _ = null,
  14762. M = !1,
  14763. C = null,
  14764. T = null,
  14765. P = null,
  14766. L = null,
  14767. D = null,
  14768. k = e.getParameter(35661),
  14769. W = !1,
  14770. X = 0,
  14771. z = e.getParameter(7938);
  14772. z.indexOf('WebGL') !== -1
  14773. ? ((X = parseFloat(/^WebGL (\d)/.exec(z)[1])), (W = X >= 1))
  14774. : z.indexOf('OpenGL ES') !== -1 && ((X = parseFloat(/^OpenGL ES (\d)/.exec(z)[1])), (W = X >= 2));
  14775. let j = null,
  14776. U = {},
  14777. N = e.getParameter(3088),
  14778. B = e.getParameter(2978),
  14779. H = new $e().fromArray(N),
  14780. Q = new $e().fromArray(B);
  14781. function Y(q, ne, de) {
  14782. let Ae = new Uint8Array(4),
  14783. De = e.createTexture();
  14784. e.bindTexture(q, De), e.texParameteri(q, 10241, 9728), e.texParameteri(q, 10240, 9728);
  14785. for (let ot = 0; ot < de; ot++) e.texImage2D(ne + ot, 0, 6408, 1, 1, 0, 6408, 5121, Ae);
  14786. return De;
  14787. }
  14788. let F = {};
  14789. (F[3553] = Y(3553, 3553, 1)),
  14790. (F[34067] = Y(34067, 34069, 6)),
  14791. o.setClear(0, 0, 0, 1),
  14792. l.setClear(1),
  14793. h.setClear(0),
  14794. se(2929),
  14795. l.setFunc(Bf),
  14796. Te(!1),
  14797. xe(Jv),
  14798. se(2884),
  14799. ue(fi);
  14800. function se(q) {
  14801. d[q] !== !0 && (e.enable(q), (d[q] = !0));
  14802. }
  14803. function V(q) {
  14804. d[q] !== !1 && (e.disable(q), (d[q] = !1));
  14805. }
  14806. function ee(q, ne) {
  14807. return p[q] !== ne
  14808. ? (e.bindFramebuffer(q, ne), (p[q] = ne), r && (q === 36009 && (p[36160] = ne), q === 36160 && (p[36009] = ne)), !0)
  14809. : !1;
  14810. }
  14811. function J(q, ne) {
  14812. let de = g,
  14813. Ae = !1;
  14814. if (q)
  14815. if (((de = f.get(ne)), de === void 0 && ((de = []), f.set(ne, de)), q.isWebGLMultipleRenderTargets)) {
  14816. let De = q.texture;
  14817. if (de.length !== De.length || de[0] !== 36064) {
  14818. for (let ot = 0, Xt = De.length; ot < Xt; ot++) de[ot] = 36064 + ot;
  14819. (de.length = De.length), (Ae = !0);
  14820. }
  14821. } else de[0] !== 36064 && ((de[0] = 36064), (Ae = !0));
  14822. else de[0] !== 1029 && ((de[0] = 1029), (Ae = !0));
  14823. Ae && (i.isWebGL2 ? e.drawBuffers(de) : t.get('WEBGL_draw_buffers').drawBuffersWEBGL(de));
  14824. }
  14825. function fe(q) {
  14826. return m !== q ? (e.useProgram(q), (m = q), !0) : !1;
  14827. }
  14828. let re = { [no]: 32774, [K2]: 32778, [J2]: 32779 };
  14829. if (r) (re[i0] = 32775), (re[r0] = 32776);
  14830. else {
  14831. let q = t.get('EXT_blend_minmax');
  14832. q !== null && ((re[i0] = q.MIN_EXT), (re[r0] = q.MAX_EXT));
  14833. }
  14834. let oe = { [$2]: 0, [eM]: 1, [tM]: 768, [nw]: 770, [oM]: 776, [nM]: 774, [rM]: 772, [iM]: 769, [aw]: 771, [aM]: 775, [sM]: 773 };
  14835. function ue(q, ne, de, Ae, De, ot, Xt, Ft) {
  14836. if (q === fi) {
  14837. v === !0 && (V(3042), (v = !1));
  14838. return;
  14839. }
  14840. if ((v === !1 && (se(3042), (v = !0)), q !== Z2)) {
  14841. if (q !== y || Ft !== M) {
  14842. if (((b !== no || A !== no) && (e.blendEquation(32774), (b = no), (A = no)), Ft))
  14843. switch (q) {
  14844. case Ao:
  14845. e.blendFuncSeparate(1, 771, 1, 771);
  14846. break;
  14847. case $v:
  14848. e.blendFunc(1, 1);
  14849. break;
  14850. case e0:
  14851. e.blendFuncSeparate(0, 769, 0, 1);
  14852. break;
  14853. case t0:
  14854. e.blendFuncSeparate(0, 768, 0, 770);
  14855. break;
  14856. default:
  14857. console.error('THREE.WebGLState: Invalid blending: ', q);
  14858. break;
  14859. }
  14860. else
  14861. switch (q) {
  14862. case Ao:
  14863. e.blendFuncSeparate(770, 771, 1, 771);
  14864. break;
  14865. case $v:
  14866. e.blendFunc(770, 1);
  14867. break;
  14868. case e0:
  14869. e.blendFuncSeparate(0, 769, 0, 1);
  14870. break;
  14871. case t0:
  14872. e.blendFunc(0, 768);
  14873. break;
  14874. default:
  14875. console.error('THREE.WebGLState: Invalid blending: ', q);
  14876. break;
  14877. }
  14878. (x = null), (w = null), (S = null), (_ = null), (y = q), (M = Ft);
  14879. }
  14880. return;
  14881. }
  14882. (De = De || ne),
  14883. (ot = ot || de),
  14884. (Xt = Xt || Ae),
  14885. (ne !== b || De !== A) && (e.blendEquationSeparate(re[ne], re[De]), (b = ne), (A = De)),
  14886. (de !== x || Ae !== w || ot !== S || Xt !== _) &&
  14887. (e.blendFuncSeparate(oe[de], oe[Ae], oe[ot], oe[Xt]), (x = de), (w = Ae), (S = ot), (_ = Xt)),
  14888. (y = q),
  14889. (M = !1);
  14890. }
  14891. function ye(q, ne) {
  14892. q.side === er ? V(2884) : se(2884);
  14893. let de = q.side === hi;
  14894. ne && (de = !de),
  14895. Te(de),
  14896. q.blending === Ao && q.transparent === !1
  14897. ? ue(fi)
  14898. : ue(
  14899. q.blending,
  14900. q.blendEquation,
  14901. q.blendSrc,
  14902. q.blendDst,
  14903. q.blendEquationAlpha,
  14904. q.blendSrcAlpha,
  14905. q.blendDstAlpha,
  14906. q.premultipliedAlpha
  14907. ),
  14908. l.setFunc(q.depthFunc),
  14909. l.setTest(q.depthTest),
  14910. l.setMask(q.depthWrite),
  14911. o.setMask(q.colorWrite);
  14912. let Ae = q.stencilWrite;
  14913. h.setTest(Ae),
  14914. Ae &&
  14915. (h.setMask(q.stencilWriteMask),
  14916. h.setFunc(q.stencilFunc, q.stencilRef, q.stencilFuncMask),
  14917. h.setOp(q.stencilFail, q.stencilZFail, q.stencilZPass)),
  14918. Ie(q.polygonOffset, q.polygonOffsetFactor, q.polygonOffsetUnits),
  14919. q.alphaToCoverage === !0 ? se(32926) : V(32926);
  14920. }
  14921. function Te(q) {
  14922. C !== q && (q ? e.frontFace(2304) : e.frontFace(2305), (C = q));
  14923. }
  14924. function xe(q) {
  14925. q !== Y2 ? (se(2884), q !== T && (q === Jv ? e.cullFace(1029) : q === Q2 ? e.cullFace(1028) : e.cullFace(1032))) : V(2884), (T = q);
  14926. }
  14927. function we(q) {
  14928. q !== P && (W && e.lineWidth(q), (P = q));
  14929. }
  14930. function Ie(q, ne, de) {
  14931. q ? (se(32823), (L !== ne || D !== de) && (e.polygonOffset(ne, de), (L = ne), (D = de))) : V(32823);
  14932. }
  14933. function He(q) {
  14934. q ? se(3089) : V(3089);
  14935. }
  14936. function dt(q) {
  14937. q === void 0 && (q = 33984 + k - 1), j !== q && (e.activeTexture(q), (j = q));
  14938. }
  14939. function I(q, ne, de) {
  14940. de === void 0 && (j === null ? (de = 33984 + k - 1) : (de = j));
  14941. let Ae = U[de];
  14942. Ae === void 0 && ((Ae = { type: void 0, texture: void 0 }), (U[de] = Ae)),
  14943. (Ae.type !== q || Ae.texture !== ne) &&
  14944. (j !== de && (e.activeTexture(de), (j = de)), e.bindTexture(q, ne || F[q]), (Ae.type = q), (Ae.texture = ne));
  14945. }
  14946. function O() {
  14947. let q = U[j];
  14948. q !== void 0 && q.type !== void 0 && (e.bindTexture(q.type, null), (q.type = void 0), (q.texture = void 0));
  14949. }
  14950. function ie() {
  14951. try {
  14952. e.compressedTexImage2D.apply(e, arguments);
  14953. } catch (q) {
  14954. console.error('THREE.WebGLState:', q);
  14955. }
  14956. }
  14957. function pe() {
  14958. try {
  14959. e.compressedTexImage3D.apply(e, arguments);
  14960. } catch (q) {
  14961. console.error('THREE.WebGLState:', q);
  14962. }
  14963. }
  14964. function me() {
  14965. try {
  14966. e.texSubImage2D.apply(e, arguments);
  14967. } catch (q) {
  14968. console.error('THREE.WebGLState:', q);
  14969. }
  14970. }
  14971. function be() {
  14972. try {
  14973. e.texSubImage3D.apply(e, arguments);
  14974. } catch (q) {
  14975. console.error('THREE.WebGLState:', q);
  14976. }
  14977. }
  14978. function We() {
  14979. try {
  14980. e.compressedTexSubImage2D.apply(e, arguments);
  14981. } catch (q) {
  14982. console.error('THREE.WebGLState:', q);
  14983. }
  14984. }
  14985. function Me() {
  14986. try {
  14987. e.compressedTexSubImage3D.apply(e, arguments);
  14988. } catch (q) {
  14989. console.error('THREE.WebGLState:', q);
  14990. }
  14991. }
  14992. function ce() {
  14993. try {
  14994. e.texStorage2D.apply(e, arguments);
  14995. } catch (q) {
  14996. console.error('THREE.WebGLState:', q);
  14997. }
  14998. }
  14999. function Fe() {
  15000. try {
  15001. e.texStorage3D.apply(e, arguments);
  15002. } catch (q) {
  15003. console.error('THREE.WebGLState:', q);
  15004. }
  15005. }
  15006. function Ee() {
  15007. try {
  15008. e.texImage2D.apply(e, arguments);
  15009. } catch (q) {
  15010. console.error('THREE.WebGLState:', q);
  15011. }
  15012. }
  15013. function _e() {
  15014. try {
  15015. e.texImage3D.apply(e, arguments);
  15016. } catch (q) {
  15017. console.error('THREE.WebGLState:', q);
  15018. }
  15019. }
  15020. function Le(q) {
  15021. H.equals(q) === !1 && (e.scissor(q.x, q.y, q.z, q.w), H.copy(q));
  15022. }
  15023. function Ne(q) {
  15024. Q.equals(q) === !1 && (e.viewport(q.x, q.y, q.z, q.w), Q.copy(q));
  15025. }
  15026. function at(q, ne) {
  15027. let de = c.get(ne);
  15028. de === void 0 && ((de = new WeakMap()), c.set(ne, de));
  15029. let Ae = de.get(q);
  15030. Ae === void 0 && ((Ae = e.getUniformBlockIndex(ne, q.name)), de.set(q, Ae));
  15031. }
  15032. function Mt(q, ne) {
  15033. let de = c.get(ne).get(q);
  15034. u.get(ne) !== de && (e.uniformBlockBinding(ne, de, q.__bindingPointIndex), u.set(ne, de));
  15035. }
  15036. function Wt() {
  15037. e.disable(3042),
  15038. e.disable(2884),
  15039. e.disable(2929),
  15040. e.disable(32823),
  15041. e.disable(3089),
  15042. e.disable(2960),
  15043. e.disable(32926),
  15044. e.blendEquation(32774),
  15045. e.blendFunc(1, 0),
  15046. e.blendFuncSeparate(1, 0, 1, 0),
  15047. e.colorMask(!0, !0, !0, !0),
  15048. e.clearColor(0, 0, 0, 0),
  15049. e.depthMask(!0),
  15050. e.depthFunc(513),
  15051. e.clearDepth(1),
  15052. e.stencilMask(4294967295),
  15053. e.stencilFunc(519, 0, 4294967295),
  15054. e.stencilOp(7680, 7680, 7680),
  15055. e.clearStencil(0),
  15056. e.cullFace(1029),
  15057. e.frontFace(2305),
  15058. e.polygonOffset(0, 0),
  15059. e.activeTexture(33984),
  15060. e.bindFramebuffer(36160, null),
  15061. r === !0 && (e.bindFramebuffer(36009, null), e.bindFramebuffer(36008, null)),
  15062. e.useProgram(null),
  15063. e.lineWidth(1),
  15064. e.scissor(0, 0, e.canvas.width, e.canvas.height),
  15065. e.viewport(0, 0, e.canvas.width, e.canvas.height),
  15066. (d = {}),
  15067. (j = null),
  15068. (U = {}),
  15069. (p = {}),
  15070. (f = new WeakMap()),
  15071. (g = []),
  15072. (m = null),
  15073. (v = !1),
  15074. (y = null),
  15075. (b = null),
  15076. (x = null),
  15077. (w = null),
  15078. (A = null),
  15079. (S = null),
  15080. (_ = null),
  15081. (M = !1),
  15082. (C = null),
  15083. (T = null),
  15084. (P = null),
  15085. (L = null),
  15086. (D = null),
  15087. H.set(0, 0, e.canvas.width, e.canvas.height),
  15088. Q.set(0, 0, e.canvas.width, e.canvas.height),
  15089. o.reset(),
  15090. l.reset(),
  15091. h.reset();
  15092. }
  15093. return {
  15094. buffers: { color: o, depth: l, stencil: h },
  15095. enable: se,
  15096. disable: V,
  15097. bindFramebuffer: ee,
  15098. drawBuffers: J,
  15099. useProgram: fe,
  15100. setBlending: ue,
  15101. setMaterial: ye,
  15102. setFlipSided: Te,
  15103. setCullFace: xe,
  15104. setLineWidth: we,
  15105. setPolygonOffset: Ie,
  15106. setScissorTest: He,
  15107. activeTexture: dt,
  15108. bindTexture: I,
  15109. unbindTexture: O,
  15110. compressedTexImage2D: ie,
  15111. compressedTexImage3D: pe,
  15112. texImage2D: Ee,
  15113. texImage3D: _e,
  15114. updateUBOMapping: at,
  15115. uniformBlockBinding: Mt,
  15116. texStorage2D: ce,
  15117. texStorage3D: Fe,
  15118. texSubImage2D: me,
  15119. texSubImage3D: be,
  15120. compressedTexSubImage2D: We,
  15121. compressedTexSubImage3D: Me,
  15122. scissor: Le,
  15123. viewport: Ne,
  15124. reset: Wt
  15125. };
  15126. }
  15127. function HP(e, t, i, r, s, n, a) {
  15128. let o = s.isWebGL2,
  15129. l = s.maxTextures,
  15130. h = s.maxCubemapSize,
  15131. u = s.maxTextureSize,
  15132. c = s.maxSamples,
  15133. d = t.has('WEBGL_multisampled_render_to_texture') ? t.get('WEBGL_multisampled_render_to_texture') : null,
  15134. p = typeof navigator > 'u' ? !1 : /OculusBrowser/g.test(navigator.userAgent),
  15135. f = new WeakMap(),
  15136. g,
  15137. m = new WeakMap(),
  15138. v = !1;
  15139. try {
  15140. v = typeof OffscreenCanvas < 'u' && new OffscreenCanvas(1, 1).getContext('2d') !== null;
  15141. } catch {}
  15142. function y(I, O) {
  15143. return v ? new OffscreenCanvas(I, O) : md('canvas');
  15144. }
  15145. function b(I, O, ie, pe) {
  15146. let me = 1;
  15147. if (((I.width > pe || I.height > pe) && (me = pe / Math.max(I.width, I.height)), me < 1 || O === !0))
  15148. if (
  15149. (typeof HTMLImageElement < 'u' && I instanceof HTMLImageElement) ||
  15150. (typeof HTMLCanvasElement < 'u' && I instanceof HTMLCanvasElement) ||
  15151. (typeof ImageBitmap < 'u' && I instanceof ImageBitmap)
  15152. ) {
  15153. let be = O ? fd : Math.floor,
  15154. We = be(me * I.width),
  15155. Me = be(me * I.height);
  15156. g === void 0 && (g = y(We, Me));
  15157. let ce = ie ? y(We, Me) : g;
  15158. return (
  15159. (ce.width = We),
  15160. (ce.height = Me),
  15161. ce.getContext('2d').drawImage(I, 0, 0, We, Me),
  15162. console.warn('THREE.WebGLRenderer: Texture has been resized from (' + I.width + 'x' + I.height + ') to (' + We + 'x' + Me + ').'),
  15163. ce
  15164. );
  15165. } else
  15166. return 'data' in I && console.warn('THREE.WebGLRenderer: Image in DataTexture is too big (' + I.width + 'x' + I.height + ').'), I;
  15167. return I;
  15168. }
  15169. function x(I) {
  15170. return jf(I.width) && jf(I.height);
  15171. }
  15172. function w(I) {
  15173. return o ? !1 : I.wrapS !== Ji || I.wrapT !== Ji || (I.minFilter !== Ot && I.minFilter !== mt);
  15174. }
  15175. function A(I, O) {
  15176. return I.generateMipmaps && O && I.minFilter !== Ot && I.minFilter !== mt;
  15177. }
  15178. function S(I) {
  15179. e.generateMipmap(I);
  15180. }
  15181. function _(I, O, ie, pe, me = !1) {
  15182. if (o === !1) return O;
  15183. if (I !== null) {
  15184. if (e[I] !== void 0) return e[I];
  15185. console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + I + "'");
  15186. }
  15187. let be = O;
  15188. return (
  15189. O === 6403 && (ie === 5126 && (be = 33326), ie === 5131 && (be = 33325), ie === 5121 && (be = 33321)),
  15190. O === 33319 && (ie === 5126 && (be = 33328), ie === 5131 && (be = 33327), ie === 5121 && (be = 33323)),
  15191. O === 6408 &&
  15192. (ie === 5126 && (be = 34836),
  15193. ie === 5131 && (be = 34842),
  15194. ie === 5121 && (be = pe === Ke && me === !1 ? 35907 : 32856),
  15195. ie === 32819 && (be = 32854),
  15196. ie === 32820 && (be = 32855)),
  15197. (be === 33325 || be === 33326 || be === 33327 || be === 33328 || be === 34842 || be === 34836) && t.get('EXT_color_buffer_float'),
  15198. be
  15199. );
  15200. }
  15201. function M(I, O, ie) {
  15202. return A(I, ie) === !0 || (I.isFramebufferTexture && I.minFilter !== Ot && I.minFilter !== mt)
  15203. ? Math.log2(Math.max(O.width, O.height)) + 1
  15204. : I.mipmaps !== void 0 && I.mipmaps.length > 0
  15205. ? I.mipmaps.length
  15206. : I.isCompressedTexture && Array.isArray(I.image)
  15207. ? O.mipmaps.length
  15208. : 1;
  15209. }
  15210. function C(I) {
  15211. return I === Ot || I === s0 || I === Wu ? 9728 : 9729;
  15212. }
  15213. function T(I) {
  15214. let O = I.target;
  15215. O.removeEventListener('dispose', T), L(O), O.isVideoTexture && f.delete(O);
  15216. }
  15217. function P(I) {
  15218. let O = I.target;
  15219. O.removeEventListener('dispose', P), k(O);
  15220. }
  15221. function L(I) {
  15222. let O = r.get(I);
  15223. if (O.__webglInit === void 0) return;
  15224. let ie = I.source,
  15225. pe = m.get(ie);
  15226. if (pe) {
  15227. let me = pe[O.__cacheKey];
  15228. me.usedTimes--, me.usedTimes === 0 && D(I), Object.keys(pe).length === 0 && m.delete(ie);
  15229. }
  15230. r.remove(I);
  15231. }
  15232. function D(I) {
  15233. let O = r.get(I);
  15234. e.deleteTexture(O.__webglTexture);
  15235. let ie = I.source,
  15236. pe = m.get(ie);
  15237. delete pe[O.__cacheKey], a.memory.textures--;
  15238. }
  15239. function k(I) {
  15240. let O = I.texture,
  15241. ie = r.get(I),
  15242. pe = r.get(O);
  15243. if (
  15244. (pe.__webglTexture !== void 0 && (e.deleteTexture(pe.__webglTexture), a.memory.textures--),
  15245. I.depthTexture && I.depthTexture.dispose(),
  15246. I.isWebGLCubeRenderTarget)
  15247. )
  15248. for (let me = 0; me < 6; me++)
  15249. e.deleteFramebuffer(ie.__webglFramebuffer[me]), ie.__webglDepthbuffer && e.deleteRenderbuffer(ie.__webglDepthbuffer[me]);
  15250. else {
  15251. if (
  15252. (e.deleteFramebuffer(ie.__webglFramebuffer),
  15253. ie.__webglDepthbuffer && e.deleteRenderbuffer(ie.__webglDepthbuffer),
  15254. ie.__webglMultisampledFramebuffer && e.deleteFramebuffer(ie.__webglMultisampledFramebuffer),
  15255. ie.__webglColorRenderbuffer)
  15256. )
  15257. for (let me = 0; me < ie.__webglColorRenderbuffer.length; me++)
  15258. ie.__webglColorRenderbuffer[me] && e.deleteRenderbuffer(ie.__webglColorRenderbuffer[me]);
  15259. ie.__webglDepthRenderbuffer && e.deleteRenderbuffer(ie.__webglDepthRenderbuffer);
  15260. }
  15261. if (I.isWebGLMultipleRenderTargets)
  15262. for (let me = 0, be = O.length; me < be; me++) {
  15263. let We = r.get(O[me]);
  15264. We.__webglTexture && (e.deleteTexture(We.__webglTexture), a.memory.textures--), r.remove(O[me]);
  15265. }
  15266. r.remove(O), r.remove(I);
  15267. }
  15268. let W = 0;
  15269. function X() {
  15270. W = 0;
  15271. }
  15272. function z() {
  15273. let I = W;
  15274. return (
  15275. I >= l && console.warn('THREE.WebGLTextures: Trying to use ' + I + ' texture units while this GPU supports only ' + l), (W += 1), I
  15276. );
  15277. }
  15278. function j(I) {
  15279. let O = [];
  15280. return (
  15281. O.push(I.wrapS),
  15282. O.push(I.wrapT),
  15283. O.push(I.wrapR || 0),
  15284. O.push(I.magFilter),
  15285. O.push(I.minFilter),
  15286. O.push(I.anisotropy),
  15287. O.push(I.internalFormat),
  15288. O.push(I.format),
  15289. O.push(I.type),
  15290. O.push(I.generateMipmaps),
  15291. O.push(I.premultiplyAlpha),
  15292. O.push(I.flipY),
  15293. O.push(I.unpackAlignment),
  15294. O.push(I.encoding),
  15295. O.join()
  15296. );
  15297. }
  15298. function U(I, O) {
  15299. let ie = r.get(I);
  15300. if ((I.isVideoTexture && He(I), I.isRenderTargetTexture === !1 && I.version > 0 && ie.__version !== I.version)) {
  15301. let pe = I.image;
  15302. if (pe === null) console.warn('THREE.WebGLRenderer: Texture marked for update but no image data found.');
  15303. else if (pe.complete === !1) console.warn('THREE.WebGLRenderer: Texture marked for update but image is incomplete');
  15304. else {
  15305. V(ie, I, O);
  15306. return;
  15307. }
  15308. }
  15309. i.bindTexture(3553, ie.__webglTexture, 33984 + O);
  15310. }
  15311. function N(I, O) {
  15312. let ie = r.get(I);
  15313. if (I.version > 0 && ie.__version !== I.version) {
  15314. V(ie, I, O);
  15315. return;
  15316. }
  15317. i.bindTexture(35866, ie.__webglTexture, 33984 + O);
  15318. }
  15319. function B(I, O) {
  15320. let ie = r.get(I);
  15321. if (I.version > 0 && ie.__version !== I.version) {
  15322. V(ie, I, O);
  15323. return;
  15324. }
  15325. i.bindTexture(32879, ie.__webglTexture, 33984 + O);
  15326. }
  15327. function H(I, O) {
  15328. let ie = r.get(I);
  15329. if (I.version > 0 && ie.__version !== I.version) {
  15330. ee(ie, I, O);
  15331. return;
  15332. }
  15333. i.bindTexture(34067, ie.__webglTexture, 33984 + O);
  15334. }
  15335. let Q = { [oh]: 10497, [Ji]: 33071, [Uf]: 33648 },
  15336. Y = { [Ot]: 9728, [s0]: 9984, [Wu]: 9986, [mt]: 9729, [_M]: 9985, [Bo]: 9987 };
  15337. function F(I, O, ie) {
  15338. if (
  15339. (ie
  15340. ? (e.texParameteri(I, 10242, Q[O.wrapS]),
  15341. e.texParameteri(I, 10243, Q[O.wrapT]),
  15342. (I === 32879 || I === 35866) && e.texParameteri(I, 32882, Q[O.wrapR]),
  15343. e.texParameteri(I, 10240, Y[O.magFilter]),
  15344. e.texParameteri(I, 10241, Y[O.minFilter]))
  15345. : (e.texParameteri(I, 10242, 33071),
  15346. e.texParameteri(I, 10243, 33071),
  15347. (I === 32879 || I === 35866) && e.texParameteri(I, 32882, 33071),
  15348. (O.wrapS !== Ji || O.wrapT !== Ji) &&
  15349. console.warn(
  15350. 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.'
  15351. ),
  15352. e.texParameteri(I, 10240, C(O.magFilter)),
  15353. e.texParameteri(I, 10241, C(O.minFilter)),
  15354. O.minFilter !== Ot &&
  15355. O.minFilter !== mt &&
  15356. console.warn(
  15357. 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.'
  15358. )),
  15359. t.has('EXT_texture_filter_anisotropic') === !0)
  15360. ) {
  15361. let pe = t.get('EXT_texture_filter_anisotropic');
  15362. if (
  15363. O.magFilter === Ot ||
  15364. (O.minFilter !== Wu && O.minFilter !== Bo) ||
  15365. (O.type === vn && t.has('OES_texture_float_linear') === !1) ||
  15366. (o === !1 && O.type === lh && t.has('OES_texture_half_float_linear') === !1)
  15367. )
  15368. return;
  15369. (O.anisotropy > 1 || r.get(O).__currentAnisotropy) &&
  15370. (e.texParameterf(I, pe.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(O.anisotropy, s.getMaxAnisotropy())),
  15371. (r.get(O).__currentAnisotropy = O.anisotropy));
  15372. }
  15373. }
  15374. function se(I, O) {
  15375. let ie = !1;
  15376. I.__webglInit === void 0 && ((I.__webglInit = !0), O.addEventListener('dispose', T));
  15377. let pe = O.source,
  15378. me = m.get(pe);
  15379. me === void 0 && ((me = {}), m.set(pe, me));
  15380. let be = j(O);
  15381. if (be !== I.__cacheKey) {
  15382. me[be] === void 0 && ((me[be] = { texture: e.createTexture(), usedTimes: 0 }), a.memory.textures++, (ie = !0)), me[be].usedTimes++;
  15383. let We = me[I.__cacheKey];
  15384. We !== void 0 && (me[I.__cacheKey].usedTimes--, We.usedTimes === 0 && D(O)), (I.__cacheKey = be), (I.__webglTexture = me[be].texture);
  15385. }
  15386. return ie;
  15387. }
  15388. function V(I, O, ie) {
  15389. let pe = 3553;
  15390. (O.isDataArrayTexture || O.isCompressedArrayTexture) && (pe = 35866), O.isData3DTexture && (pe = 32879);
  15391. let me = se(I, O),
  15392. be = O.source;
  15393. i.bindTexture(pe, I.__webglTexture, 33984 + ie);
  15394. let We = r.get(be);
  15395. if (be.version !== We.__version || me === !0) {
  15396. i.activeTexture(33984 + ie),
  15397. e.pixelStorei(37440, O.flipY),
  15398. e.pixelStorei(37441, O.premultiplyAlpha),
  15399. e.pixelStorei(3317, O.unpackAlignment),
  15400. e.pixelStorei(37443, 0);
  15401. let Me = w(O) && x(O.image) === !1,
  15402. ce = b(O.image, Me, !1, u);
  15403. ce = dt(O, ce);
  15404. let Fe = x(ce) || o,
  15405. Ee = n.convert(O.format, O.encoding),
  15406. _e = n.convert(O.type),
  15407. Le = _(O.internalFormat, Ee, _e, O.encoding, O.isVideoTexture);
  15408. F(pe, O, Fe);
  15409. let Ne,
  15410. at = O.mipmaps,
  15411. Mt = o && O.isVideoTexture !== !0,
  15412. Wt = We.__version === void 0 || me === !0,
  15413. q = M(O, ce, Fe);
  15414. if (O.isDepthTexture)
  15415. (Le = 6402),
  15416. o
  15417. ? O.type === vn
  15418. ? (Le = 36012)
  15419. : O.type === gn
  15420. ? (Le = 33190)
  15421. : O.type === ca
  15422. ? (Le = 35056)
  15423. : (Le = 33189)
  15424. : O.type === vn && console.error('WebGLRenderer: Floating point depth texture requires WebGL2.'),
  15425. O.format === da &&
  15426. Le === 6402 &&
  15427. O.type !== hw &&
  15428. O.type !== gn &&
  15429. (console.warn('THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.'),
  15430. (O.type = gn),
  15431. (_e = n.convert(O.type))),
  15432. O.format === ba &&
  15433. Le === 6402 &&
  15434. ((Le = 34041),
  15435. O.type !== ca &&
  15436. (console.warn('THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.'),
  15437. (O.type = ca),
  15438. (_e = n.convert(O.type)))),
  15439. Wt && (Mt ? i.texStorage2D(3553, 1, Le, ce.width, ce.height) : i.texImage2D(3553, 0, Le, ce.width, ce.height, 0, Ee, _e, null));
  15440. else if (O.isDataTexture)
  15441. if (at.length > 0 && Fe) {
  15442. Mt && Wt && i.texStorage2D(3553, q, Le, at[0].width, at[0].height);
  15443. for (let ne = 0, de = at.length; ne < de; ne++)
  15444. (Ne = at[ne]),
  15445. Mt
  15446. ? i.texSubImage2D(3553, ne, 0, 0, Ne.width, Ne.height, Ee, _e, Ne.data)
  15447. : i.texImage2D(3553, ne, Le, Ne.width, Ne.height, 0, Ee, _e, Ne.data);
  15448. O.generateMipmaps = !1;
  15449. } else
  15450. Mt
  15451. ? (Wt && i.texStorage2D(3553, q, Le, ce.width, ce.height), i.texSubImage2D(3553, 0, 0, 0, ce.width, ce.height, Ee, _e, ce.data))
  15452. : i.texImage2D(3553, 0, Le, ce.width, ce.height, 0, Ee, _e, ce.data);
  15453. else if (O.isCompressedTexture)
  15454. if (O.isCompressedArrayTexture) {
  15455. Mt && Wt && i.texStorage3D(35866, q, Le, at[0].width, at[0].height, ce.depth);
  15456. for (let ne = 0, de = at.length; ne < de; ne++)
  15457. (Ne = at[ne]),
  15458. O.format !== Ur
  15459. ? Ee !== null
  15460. ? Mt
  15461. ? i.compressedTexSubImage3D(35866, ne, 0, 0, 0, Ne.width, Ne.height, ce.depth, Ee, Ne.data, 0, 0)
  15462. : i.compressedTexImage3D(35866, ne, Le, Ne.width, Ne.height, ce.depth, 0, Ne.data, 0, 0)
  15463. : console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()')
  15464. : Mt
  15465. ? i.texSubImage3D(35866, ne, 0, 0, 0, Ne.width, Ne.height, ce.depth, Ee, _e, Ne.data)
  15466. : i.texImage3D(35866, ne, Le, Ne.width, Ne.height, ce.depth, 0, Ee, _e, Ne.data);
  15467. } else {
  15468. Mt && Wt && i.texStorage2D(3553, q, Le, at[0].width, at[0].height);
  15469. for (let ne = 0, de = at.length; ne < de; ne++)
  15470. (Ne = at[ne]),
  15471. O.format !== Ur
  15472. ? Ee !== null
  15473. ? Mt
  15474. ? i.compressedTexSubImage2D(3553, ne, 0, 0, Ne.width, Ne.height, Ee, Ne.data)
  15475. : i.compressedTexImage2D(3553, ne, Le, Ne.width, Ne.height, 0, Ne.data)
  15476. : console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()')
  15477. : Mt
  15478. ? i.texSubImage2D(3553, ne, 0, 0, Ne.width, Ne.height, Ee, _e, Ne.data)
  15479. : i.texImage2D(3553, ne, Le, Ne.width, Ne.height, 0, Ee, _e, Ne.data);
  15480. }
  15481. else if (O.isDataArrayTexture)
  15482. Mt
  15483. ? (Wt && i.texStorage3D(35866, q, Le, ce.width, ce.height, ce.depth),
  15484. i.texSubImage3D(35866, 0, 0, 0, 0, ce.width, ce.height, ce.depth, Ee, _e, ce.data))
  15485. : i.texImage3D(35866, 0, Le, ce.width, ce.height, ce.depth, 0, Ee, _e, ce.data);
  15486. else if (O.isData3DTexture)
  15487. Mt
  15488. ? (Wt && i.texStorage3D(32879, q, Le, ce.width, ce.height, ce.depth),
  15489. i.texSubImage3D(32879, 0, 0, 0, 0, ce.width, ce.height, ce.depth, Ee, _e, ce.data))
  15490. : i.texImage3D(32879, 0, Le, ce.width, ce.height, ce.depth, 0, Ee, _e, ce.data);
  15491. else if (O.isFramebufferTexture) {
  15492. if (Wt)
  15493. if (Mt) i.texStorage2D(3553, q, Le, ce.width, ce.height);
  15494. else {
  15495. let ne = ce.width,
  15496. de = ce.height;
  15497. for (let Ae = 0; Ae < q; Ae++) i.texImage2D(3553, Ae, Le, ne, de, 0, Ee, _e, null), (ne >>= 1), (de >>= 1);
  15498. }
  15499. } else if (at.length > 0 && Fe) {
  15500. Mt && Wt && i.texStorage2D(3553, q, Le, at[0].width, at[0].height);
  15501. for (let ne = 0, de = at.length; ne < de; ne++)
  15502. (Ne = at[ne]), Mt ? i.texSubImage2D(3553, ne, 0, 0, Ee, _e, Ne) : i.texImage2D(3553, ne, Le, Ee, _e, Ne);
  15503. O.generateMipmaps = !1;
  15504. } else
  15505. Mt
  15506. ? (Wt && i.texStorage2D(3553, q, Le, ce.width, ce.height), i.texSubImage2D(3553, 0, 0, 0, Ee, _e, ce))
  15507. : i.texImage2D(3553, 0, Le, Ee, _e, ce);
  15508. A(O, Fe) && S(pe), (We.__version = be.version), O.onUpdate && O.onUpdate(O);
  15509. }
  15510. I.__version = O.version;
  15511. }
  15512. function ee(I, O, ie) {
  15513. if (O.image.length !== 6) return;
  15514. let pe = se(I, O),
  15515. me = O.source;
  15516. i.bindTexture(34067, I.__webglTexture, 33984 + ie);
  15517. let be = r.get(me);
  15518. if (me.version !== be.__version || pe === !0) {
  15519. i.activeTexture(33984 + ie),
  15520. e.pixelStorei(37440, O.flipY),
  15521. e.pixelStorei(37441, O.premultiplyAlpha),
  15522. e.pixelStorei(3317, O.unpackAlignment),
  15523. e.pixelStorei(37443, 0);
  15524. let We = O.isCompressedTexture || O.image[0].isCompressedTexture,
  15525. Me = O.image[0] && O.image[0].isDataTexture,
  15526. ce = [];
  15527. for (let ne = 0; ne < 6; ne++)
  15528. !We && !Me ? (ce[ne] = b(O.image[ne], !1, !0, h)) : (ce[ne] = Me ? O.image[ne].image : O.image[ne]), (ce[ne] = dt(O, ce[ne]));
  15529. let Fe = ce[0],
  15530. Ee = x(Fe) || o,
  15531. _e = n.convert(O.format, O.encoding),
  15532. Le = n.convert(O.type),
  15533. Ne = _(O.internalFormat, _e, Le, O.encoding),
  15534. at = o && O.isVideoTexture !== !0,
  15535. Mt = be.__version === void 0 || pe === !0,
  15536. Wt = M(O, Fe, Ee);
  15537. F(34067, O, Ee);
  15538. let q;
  15539. if (We) {
  15540. at && Mt && i.texStorage2D(34067, Wt, Ne, Fe.width, Fe.height);
  15541. for (let ne = 0; ne < 6; ne++) {
  15542. q = ce[ne].mipmaps;
  15543. for (let de = 0; de < q.length; de++) {
  15544. let Ae = q[de];
  15545. O.format !== Ur
  15546. ? _e !== null
  15547. ? at
  15548. ? i.compressedTexSubImage2D(34069 + ne, de, 0, 0, Ae.width, Ae.height, _e, Ae.data)
  15549. : i.compressedTexImage2D(34069 + ne, de, Ne, Ae.width, Ae.height, 0, Ae.data)
  15550. : console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()')
  15551. : at
  15552. ? i.texSubImage2D(34069 + ne, de, 0, 0, Ae.width, Ae.height, _e, Le, Ae.data)
  15553. : i.texImage2D(34069 + ne, de, Ne, Ae.width, Ae.height, 0, _e, Le, Ae.data);
  15554. }
  15555. }
  15556. } else {
  15557. (q = O.mipmaps), at && Mt && (q.length > 0 && Wt++, i.texStorage2D(34067, Wt, Ne, ce[0].width, ce[0].height));
  15558. for (let ne = 0; ne < 6; ne++)
  15559. if (Me) {
  15560. at
  15561. ? i.texSubImage2D(34069 + ne, 0, 0, 0, ce[ne].width, ce[ne].height, _e, Le, ce[ne].data)
  15562. : i.texImage2D(34069 + ne, 0, Ne, ce[ne].width, ce[ne].height, 0, _e, Le, ce[ne].data);
  15563. for (let de = 0; de < q.length; de++) {
  15564. let Ae = q[de].image[ne].image;
  15565. at
  15566. ? i.texSubImage2D(34069 + ne, de + 1, 0, 0, Ae.width, Ae.height, _e, Le, Ae.data)
  15567. : i.texImage2D(34069 + ne, de + 1, Ne, Ae.width, Ae.height, 0, _e, Le, Ae.data);
  15568. }
  15569. } else {
  15570. at ? i.texSubImage2D(34069 + ne, 0, 0, 0, _e, Le, ce[ne]) : i.texImage2D(34069 + ne, 0, Ne, _e, Le, ce[ne]);
  15571. for (let de = 0; de < q.length; de++) {
  15572. let Ae = q[de];
  15573. at
  15574. ? i.texSubImage2D(34069 + ne, de + 1, 0, 0, _e, Le, Ae.image[ne])
  15575. : i.texImage2D(34069 + ne, de + 1, Ne, _e, Le, Ae.image[ne]);
  15576. }
  15577. }
  15578. }
  15579. A(O, Ee) && S(34067), (be.__version = me.version), O.onUpdate && O.onUpdate(O);
  15580. }
  15581. I.__version = O.version;
  15582. }
  15583. function J(I, O, ie, pe, me) {
  15584. let be = n.convert(ie.format, ie.encoding),
  15585. We = n.convert(ie.type),
  15586. Me = _(ie.internalFormat, be, We, ie.encoding);
  15587. r.get(O).__hasExternalTextures ||
  15588. (me === 32879 || me === 35866
  15589. ? i.texImage3D(me, 0, Me, O.width, O.height, O.depth, 0, be, We, null)
  15590. : i.texImage2D(me, 0, Me, O.width, O.height, 0, be, We, null)),
  15591. i.bindFramebuffer(36160, I),
  15592. Ie(O)
  15593. ? d.framebufferTexture2DMultisampleEXT(36160, pe, me, r.get(ie).__webglTexture, 0, we(O))
  15594. : (me === 3553 || (me >= 34069 && me <= 34074)) && e.framebufferTexture2D(36160, pe, me, r.get(ie).__webglTexture, 0),
  15595. i.bindFramebuffer(36160, null);
  15596. }
  15597. function fe(I, O, ie) {
  15598. if ((e.bindRenderbuffer(36161, I), O.depthBuffer && !O.stencilBuffer)) {
  15599. let pe = 33189;
  15600. if (ie || Ie(O)) {
  15601. let me = O.depthTexture;
  15602. me && me.isDepthTexture && (me.type === vn ? (pe = 36012) : me.type === gn && (pe = 33190));
  15603. let be = we(O);
  15604. Ie(O)
  15605. ? d.renderbufferStorageMultisampleEXT(36161, be, pe, O.width, O.height)
  15606. : e.renderbufferStorageMultisample(36161, be, pe, O.width, O.height);
  15607. } else e.renderbufferStorage(36161, pe, O.width, O.height);
  15608. e.framebufferRenderbuffer(36160, 36096, 36161, I);
  15609. } else if (O.depthBuffer && O.stencilBuffer) {
  15610. let pe = we(O);
  15611. ie && Ie(O) === !1
  15612. ? e.renderbufferStorageMultisample(36161, pe, 35056, O.width, O.height)
  15613. : Ie(O)
  15614. ? d.renderbufferStorageMultisampleEXT(36161, pe, 35056, O.width, O.height)
  15615. : e.renderbufferStorage(36161, 34041, O.width, O.height),
  15616. e.framebufferRenderbuffer(36160, 33306, 36161, I);
  15617. } else {
  15618. let pe = O.isWebGLMultipleRenderTargets === !0 ? O.texture : [O.texture];
  15619. for (let me = 0; me < pe.length; me++) {
  15620. let be = pe[me],
  15621. We = n.convert(be.format, be.encoding),
  15622. Me = n.convert(be.type),
  15623. ce = _(be.internalFormat, We, Me, be.encoding),
  15624. Fe = we(O);
  15625. ie && Ie(O) === !1
  15626. ? e.renderbufferStorageMultisample(36161, Fe, ce, O.width, O.height)
  15627. : Ie(O)
  15628. ? d.renderbufferStorageMultisampleEXT(36161, Fe, ce, O.width, O.height)
  15629. : e.renderbufferStorage(36161, ce, O.width, O.height);
  15630. }
  15631. }
  15632. e.bindRenderbuffer(36161, null);
  15633. }
  15634. function re(I, O) {
  15635. if (O && O.isWebGLCubeRenderTarget) throw new Error('Depth Texture with cube render targets is not supported');
  15636. if ((i.bindFramebuffer(36160, I), !(O.depthTexture && O.depthTexture.isDepthTexture)))
  15637. throw new Error('renderTarget.depthTexture must be an instance of THREE.DepthTexture');
  15638. (!r.get(O.depthTexture).__webglTexture || O.depthTexture.image.width !== O.width || O.depthTexture.image.height !== O.height) &&
  15639. ((O.depthTexture.image.width = O.width), (O.depthTexture.image.height = O.height), (O.depthTexture.needsUpdate = !0)),
  15640. U(O.depthTexture, 0);
  15641. let ie = r.get(O.depthTexture).__webglTexture,
  15642. pe = we(O);
  15643. if (O.depthTexture.format === da)
  15644. Ie(O) ? d.framebufferTexture2DMultisampleEXT(36160, 36096, 3553, ie, 0, pe) : e.framebufferTexture2D(36160, 36096, 3553, ie, 0);
  15645. else if (O.depthTexture.format === ba)
  15646. Ie(O) ? d.framebufferTexture2DMultisampleEXT(36160, 33306, 3553, ie, 0, pe) : e.framebufferTexture2D(36160, 33306, 3553, ie, 0);
  15647. else throw new Error('Unknown depthTexture format');
  15648. }
  15649. function oe(I) {
  15650. let O = r.get(I),
  15651. ie = I.isWebGLCubeRenderTarget === !0;
  15652. if (I.depthTexture && !O.__autoAllocateDepthBuffer) {
  15653. if (ie) throw new Error('target.depthTexture not supported in Cube render targets');
  15654. re(O.__webglFramebuffer, I);
  15655. } else if (ie) {
  15656. O.__webglDepthbuffer = [];
  15657. for (let pe = 0; pe < 6; pe++)
  15658. i.bindFramebuffer(36160, O.__webglFramebuffer[pe]),
  15659. (O.__webglDepthbuffer[pe] = e.createRenderbuffer()),
  15660. fe(O.__webglDepthbuffer[pe], I, !1);
  15661. } else i.bindFramebuffer(36160, O.__webglFramebuffer), (O.__webglDepthbuffer = e.createRenderbuffer()), fe(O.__webglDepthbuffer, I, !1);
  15662. i.bindFramebuffer(36160, null);
  15663. }
  15664. function ue(I, O, ie) {
  15665. let pe = r.get(I);
  15666. O !== void 0 && J(pe.__webglFramebuffer, I, I.texture, 36064, 3553), ie !== void 0 && oe(I);
  15667. }
  15668. function ye(I) {
  15669. let O = I.texture,
  15670. ie = r.get(I),
  15671. pe = r.get(O);
  15672. I.addEventListener('dispose', P),
  15673. I.isWebGLMultipleRenderTargets !== !0 &&
  15674. (pe.__webglTexture === void 0 && (pe.__webglTexture = e.createTexture()), (pe.__version = O.version), a.memory.textures++);
  15675. let me = I.isWebGLCubeRenderTarget === !0,
  15676. be = I.isWebGLMultipleRenderTargets === !0,
  15677. We = x(I) || o;
  15678. if (me) {
  15679. ie.__webglFramebuffer = [];
  15680. for (let Me = 0; Me < 6; Me++) ie.__webglFramebuffer[Me] = e.createFramebuffer();
  15681. } else {
  15682. if (((ie.__webglFramebuffer = e.createFramebuffer()), be))
  15683. if (s.drawBuffers) {
  15684. let Me = I.texture;
  15685. for (let ce = 0, Fe = Me.length; ce < Fe; ce++) {
  15686. let Ee = r.get(Me[ce]);
  15687. Ee.__webglTexture === void 0 && ((Ee.__webglTexture = e.createTexture()), a.memory.textures++);
  15688. }
  15689. } else
  15690. console.warn('THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.');
  15691. if (o && I.samples > 0 && Ie(I) === !1) {
  15692. let Me = be ? O : [O];
  15693. (ie.__webglMultisampledFramebuffer = e.createFramebuffer()),
  15694. (ie.__webglColorRenderbuffer = []),
  15695. i.bindFramebuffer(36160, ie.__webglMultisampledFramebuffer);
  15696. for (let ce = 0; ce < Me.length; ce++) {
  15697. let Fe = Me[ce];
  15698. (ie.__webglColorRenderbuffer[ce] = e.createRenderbuffer()), e.bindRenderbuffer(36161, ie.__webglColorRenderbuffer[ce]);
  15699. let Ee = n.convert(Fe.format, Fe.encoding),
  15700. _e = n.convert(Fe.type),
  15701. Le = _(Fe.internalFormat, Ee, _e, Fe.encoding, I.isXRRenderTarget === !0),
  15702. Ne = we(I);
  15703. e.renderbufferStorageMultisample(36161, Ne, Le, I.width, I.height),
  15704. e.framebufferRenderbuffer(36160, 36064 + ce, 36161, ie.__webglColorRenderbuffer[ce]);
  15705. }
  15706. e.bindRenderbuffer(36161, null),
  15707. I.depthBuffer && ((ie.__webglDepthRenderbuffer = e.createRenderbuffer()), fe(ie.__webglDepthRenderbuffer, I, !0)),
  15708. i.bindFramebuffer(36160, null);
  15709. }
  15710. }
  15711. if (me) {
  15712. i.bindTexture(34067, pe.__webglTexture), F(34067, O, We);
  15713. for (let Me = 0; Me < 6; Me++) J(ie.__webglFramebuffer[Me], I, O, 36064, 34069 + Me);
  15714. A(O, We) && S(34067), i.unbindTexture();
  15715. } else if (be) {
  15716. let Me = I.texture;
  15717. for (let ce = 0, Fe = Me.length; ce < Fe; ce++) {
  15718. let Ee = Me[ce],
  15719. _e = r.get(Ee);
  15720. i.bindTexture(3553, _e.__webglTexture), F(3553, Ee, We), J(ie.__webglFramebuffer, I, Ee, 36064 + ce, 3553), A(Ee, We) && S(3553);
  15721. }
  15722. i.unbindTexture();
  15723. } else {
  15724. let Me = 3553;
  15725. (I.isWebGL3DRenderTarget || I.isWebGLArrayRenderTarget) &&
  15726. (o
  15727. ? (Me = I.isWebGL3DRenderTarget ? 32879 : 35866)
  15728. : console.error('THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.')),
  15729. i.bindTexture(Me, pe.__webglTexture),
  15730. F(Me, O, We),
  15731. J(ie.__webglFramebuffer, I, O, 36064, Me),
  15732. A(O, We) && S(Me),
  15733. i.unbindTexture();
  15734. }
  15735. I.depthBuffer && oe(I);
  15736. }
  15737. function Te(I) {
  15738. let O = x(I) || o,
  15739. ie = I.isWebGLMultipleRenderTargets === !0 ? I.texture : [I.texture];
  15740. for (let pe = 0, me = ie.length; pe < me; pe++) {
  15741. let be = ie[pe];
  15742. if (A(be, O)) {
  15743. let We = I.isWebGLCubeRenderTarget ? 34067 : 3553,
  15744. Me = r.get(be).__webglTexture;
  15745. i.bindTexture(We, Me), S(We), i.unbindTexture();
  15746. }
  15747. }
  15748. }
  15749. function xe(I) {
  15750. if (o && I.samples > 0 && Ie(I) === !1) {
  15751. let O = I.isWebGLMultipleRenderTargets ? I.texture : [I.texture],
  15752. ie = I.width,
  15753. pe = I.height,
  15754. me = 16384,
  15755. be = [],
  15756. We = I.stencilBuffer ? 33306 : 36096,
  15757. Me = r.get(I),
  15758. ce = I.isWebGLMultipleRenderTargets === !0;
  15759. if (ce)
  15760. for (let Fe = 0; Fe < O.length; Fe++)
  15761. i.bindFramebuffer(36160, Me.__webglMultisampledFramebuffer),
  15762. e.framebufferRenderbuffer(36160, 36064 + Fe, 36161, null),
  15763. i.bindFramebuffer(36160, Me.__webglFramebuffer),
  15764. e.framebufferTexture2D(36009, 36064 + Fe, 3553, null, 0);
  15765. i.bindFramebuffer(36008, Me.__webglMultisampledFramebuffer), i.bindFramebuffer(36009, Me.__webglFramebuffer);
  15766. for (let Fe = 0; Fe < O.length; Fe++) {
  15767. be.push(36064 + Fe), I.depthBuffer && be.push(We);
  15768. let Ee = Me.__ignoreDepthValues !== void 0 ? Me.__ignoreDepthValues : !1;
  15769. if (
  15770. (Ee === !1 && (I.depthBuffer && (me |= 256), I.stencilBuffer && (me |= 1024)),
  15771. ce && e.framebufferRenderbuffer(36008, 36064, 36161, Me.__webglColorRenderbuffer[Fe]),
  15772. Ee === !0 && (e.invalidateFramebuffer(36008, [We]), e.invalidateFramebuffer(36009, [We])),
  15773. ce)
  15774. ) {
  15775. let _e = r.get(O[Fe]).__webglTexture;
  15776. e.framebufferTexture2D(36009, 36064, 3553, _e, 0);
  15777. }
  15778. e.blitFramebuffer(0, 0, ie, pe, 0, 0, ie, pe, me, 9728), p && e.invalidateFramebuffer(36008, be);
  15779. }
  15780. if ((i.bindFramebuffer(36008, null), i.bindFramebuffer(36009, null), ce))
  15781. for (let Fe = 0; Fe < O.length; Fe++) {
  15782. i.bindFramebuffer(36160, Me.__webglMultisampledFramebuffer),
  15783. e.framebufferRenderbuffer(36160, 36064 + Fe, 36161, Me.__webglColorRenderbuffer[Fe]);
  15784. let Ee = r.get(O[Fe]).__webglTexture;
  15785. i.bindFramebuffer(36160, Me.__webglFramebuffer), e.framebufferTexture2D(36009, 36064 + Fe, 3553, Ee, 0);
  15786. }
  15787. i.bindFramebuffer(36009, Me.__webglMultisampledFramebuffer);
  15788. }
  15789. }
  15790. function we(I) {
  15791. return Math.min(c, I.samples);
  15792. }
  15793. function Ie(I) {
  15794. let O = r.get(I);
  15795. return o && I.samples > 0 && t.has('WEBGL_multisampled_render_to_texture') === !0 && O.__useRenderToTexture !== !1;
  15796. }
  15797. function He(I) {
  15798. let O = a.render.frame;
  15799. f.get(I) !== O && (f.set(I, O), I.update());
  15800. }
  15801. function dt(I, O) {
  15802. let ie = I.encoding,
  15803. pe = I.format,
  15804. me = I.type;
  15805. return (
  15806. I.isCompressedTexture === !0 ||
  15807. I.isVideoTexture === !0 ||
  15808. I.format === kf ||
  15809. (ie !== gs &&
  15810. (ie === Ke
  15811. ? o === !1
  15812. ? t.has('EXT_sRGB') === !0 && pe === Ur
  15813. ? ((I.format = kf), (I.minFilter = mt), (I.generateMipmaps = !1))
  15814. : (O = pw.sRGBToLinear(O))
  15815. : (pe !== Ur || me !== Mi) &&
  15816. console.warn('THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.')
  15817. : console.error('THREE.WebGLTextures: Unsupported texture encoding:', ie))),
  15818. O
  15819. );
  15820. }
  15821. (this.allocateTextureUnit = z),
  15822. (this.resetTextureUnits = X),
  15823. (this.setTexture2D = U),
  15824. (this.setTexture2DArray = N),
  15825. (this.setTexture3D = B),
  15826. (this.setTextureCube = H),
  15827. (this.rebindTextures = ue),
  15828. (this.setupRenderTarget = ye),
  15829. (this.updateRenderTargetMipmap = Te),
  15830. (this.updateMultisampleRenderTarget = xe),
  15831. (this.setupDepthRenderbuffer = oe),
  15832. (this.setupFrameBufferTexture = J),
  15833. (this.useMultisampledRTT = Ie);
  15834. }
  15835. function WP(e, t, i) {
  15836. let r = i.isWebGL2;
  15837. function s(n, a = null) {
  15838. let o;
  15839. if (n === Mi) return 5121;
  15840. if (n === EM) return 32819;
  15841. if (n === CM) return 32820;
  15842. if (n === AM) return 5120;
  15843. if (n === SM) return 5122;
  15844. if (n === hw) return 5123;
  15845. if (n === MM) return 5124;
  15846. if (n === gn) return 5125;
  15847. if (n === vn) return 5126;
  15848. if (n === lh) return r ? 5131 : ((o = t.get('OES_texture_half_float')), o !== null ? o.HALF_FLOAT_OES : null);
  15849. if (n === TM) return 6406;
  15850. if (n === Ur) return 6408;
  15851. if (n === PM) return 6409;
  15852. if (n === DM) return 6410;
  15853. if (n === da) return 6402;
  15854. if (n === ba) return 34041;
  15855. if (n === kf) return (o = t.get('EXT_sRGB')), o !== null ? o.SRGB_ALPHA_EXT : null;
  15856. if (n === LM) return 6403;
  15857. if (n === OM) return 36244;
  15858. if (n === IM) return 33319;
  15859. if (n === RM) return 33320;
  15860. if (n === BM) return 36249;
  15861. if (n === Xu || n === qu || n === Yu || n === Qu)
  15862. if (a === Ke)
  15863. if (((o = t.get('WEBGL_compressed_texture_s3tc_srgb')), o !== null)) {
  15864. if (n === Xu) return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;
  15865. if (n === qu) return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
  15866. if (n === Yu) return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
  15867. if (n === Qu) return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
  15868. } else return null;
  15869. else if (((o = t.get('WEBGL_compressed_texture_s3tc')), o !== null)) {
  15870. if (n === Xu) return o.COMPRESSED_RGB_S3TC_DXT1_EXT;
  15871. if (n === qu) return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  15872. if (n === Yu) return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  15873. if (n === Qu) return o.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  15874. } else return null;
  15875. if (n === n0 || n === a0 || n === o0 || n === l0)
  15876. if (((o = t.get('WEBGL_compressed_texture_pvrtc')), o !== null)) {
  15877. if (n === n0) return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
  15878. if (n === a0) return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
  15879. if (n === o0) return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
  15880. if (n === l0) return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
  15881. } else return null;
  15882. if (n === zM) return (o = t.get('WEBGL_compressed_texture_etc1')), o !== null ? o.COMPRESSED_RGB_ETC1_WEBGL : null;
  15883. if (n === h0 || n === c0)
  15884. if (((o = t.get('WEBGL_compressed_texture_etc')), o !== null)) {
  15885. if (n === h0) return a === Ke ? o.COMPRESSED_SRGB8_ETC2 : o.COMPRESSED_RGB8_ETC2;
  15886. if (n === c0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : o.COMPRESSED_RGBA8_ETC2_EAC;
  15887. } else return null;
  15888. if (
  15889. n === d0 ||
  15890. n === u0 ||
  15891. n === p0 ||
  15892. n === f0 ||
  15893. n === m0 ||
  15894. n === g0 ||
  15895. n === v0 ||
  15896. n === y0 ||
  15897. n === x0 ||
  15898. n === b0 ||
  15899. n === w0 ||
  15900. n === _0 ||
  15901. n === A0 ||
  15902. n === S0
  15903. )
  15904. if (((o = t.get('WEBGL_compressed_texture_astc')), o !== null)) {
  15905. if (n === d0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : o.COMPRESSED_RGBA_ASTC_4x4_KHR;
  15906. if (n === u0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : o.COMPRESSED_RGBA_ASTC_5x4_KHR;
  15907. if (n === p0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : o.COMPRESSED_RGBA_ASTC_5x5_KHR;
  15908. if (n === f0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : o.COMPRESSED_RGBA_ASTC_6x5_KHR;
  15909. if (n === m0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : o.COMPRESSED_RGBA_ASTC_6x6_KHR;
  15910. if (n === g0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : o.COMPRESSED_RGBA_ASTC_8x5_KHR;
  15911. if (n === v0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : o.COMPRESSED_RGBA_ASTC_8x6_KHR;
  15912. if (n === y0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : o.COMPRESSED_RGBA_ASTC_8x8_KHR;
  15913. if (n === x0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : o.COMPRESSED_RGBA_ASTC_10x5_KHR;
  15914. if (n === b0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : o.COMPRESSED_RGBA_ASTC_10x6_KHR;
  15915. if (n === w0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : o.COMPRESSED_RGBA_ASTC_10x8_KHR;
  15916. if (n === _0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : o.COMPRESSED_RGBA_ASTC_10x10_KHR;
  15917. if (n === A0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : o.COMPRESSED_RGBA_ASTC_12x10_KHR;
  15918. if (n === S0) return a === Ke ? o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : o.COMPRESSED_RGBA_ASTC_12x12_KHR;
  15919. } else return null;
  15920. if (n === Zu)
  15921. if (((o = t.get('EXT_texture_compression_bptc')), o !== null)) {
  15922. if (n === Zu) return a === Ke ? o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : o.COMPRESSED_RGBA_BPTC_UNORM_EXT;
  15923. } else return null;
  15924. if (n === NM || n === M0 || n === E0 || n === C0)
  15925. if (((o = t.get('EXT_texture_compression_rgtc')), o !== null)) {
  15926. if (n === Zu) return o.COMPRESSED_RED_RGTC1_EXT;
  15927. if (n === M0) return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;
  15928. if (n === E0) return o.COMPRESSED_RED_GREEN_RGTC2_EXT;
  15929. if (n === C0) return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
  15930. } else return null;
  15931. return n === ca
  15932. ? r
  15933. ? 34042
  15934. : ((o = t.get('WEBGL_depth_texture')), o !== null ? o.UNSIGNED_INT_24_8_WEBGL : null)
  15935. : e[n] !== void 0
  15936. ? e[n]
  15937. : null;
  15938. }
  15939. return { convert: s };
  15940. }
  15941. var XP = class extends wi {
  15942. constructor(e = []) {
  15943. super(), (this.isArrayCamera = !0), (this.cameras = e);
  15944. }
  15945. },
  15946. po = class extends bt {
  15947. constructor() {
  15948. super(), (this.isGroup = !0), (this.type = 'Group');
  15949. }
  15950. },
  15951. qP = { type: 'move' },
  15952. _p = class {
  15953. constructor() {
  15954. (this._targetRay = null), (this._grip = null), (this._hand = null);
  15955. }
  15956. getHandSpace() {
  15957. return (
  15958. this._hand === null &&
  15959. ((this._hand = new po()),
  15960. (this._hand.matrixAutoUpdate = !1),
  15961. (this._hand.visible = !1),
  15962. (this._hand.joints = {}),
  15963. (this._hand.inputState = { pinching: !1 })),
  15964. this._hand
  15965. );
  15966. }
  15967. getTargetRaySpace() {
  15968. return (
  15969. this._targetRay === null &&
  15970. ((this._targetRay = new po()),
  15971. (this._targetRay.matrixAutoUpdate = !1),
  15972. (this._targetRay.visible = !1),
  15973. (this._targetRay.hasLinearVelocity = !1),
  15974. (this._targetRay.linearVelocity = new E()),
  15975. (this._targetRay.hasAngularVelocity = !1),
  15976. (this._targetRay.angularVelocity = new E())),
  15977. this._targetRay
  15978. );
  15979. }
  15980. getGripSpace() {
  15981. return (
  15982. this._grip === null &&
  15983. ((this._grip = new po()),
  15984. (this._grip.matrixAutoUpdate = !1),
  15985. (this._grip.visible = !1),
  15986. (this._grip.hasLinearVelocity = !1),
  15987. (this._grip.linearVelocity = new E()),
  15988. (this._grip.hasAngularVelocity = !1),
  15989. (this._grip.angularVelocity = new E())),
  15990. this._grip
  15991. );
  15992. }
  15993. dispatchEvent(e) {
  15994. return (
  15995. this._targetRay !== null && this._targetRay.dispatchEvent(e),
  15996. this._grip !== null && this._grip.dispatchEvent(e),
  15997. this._hand !== null && this._hand.dispatchEvent(e),
  15998. this
  15999. );
  16000. }
  16001. connect(e) {
  16002. if (e && e.hand) {
  16003. let t = this._hand;
  16004. if (t) for (let i of e.hand.values()) this._getHandJoint(t, i);
  16005. }
  16006. return this.dispatchEvent({ type: 'connected', data: e }), this;
  16007. }
  16008. disconnect(e) {
  16009. return (
  16010. this.dispatchEvent({ type: 'disconnected', data: e }),
  16011. this._targetRay !== null && (this._targetRay.visible = !1),
  16012. this._grip !== null && (this._grip.visible = !1),
  16013. this._hand !== null && (this._hand.visible = !1),
  16014. this
  16015. );
  16016. }
  16017. update(e, t, i) {
  16018. let r = null,
  16019. s = null,
  16020. n = null,
  16021. a = this._targetRay,
  16022. o = this._grip,
  16023. l = this._hand;
  16024. if (e && t.session.visibilityState !== 'visible-blurred') {
  16025. if (l && e.hand) {
  16026. n = !0;
  16027. for (let f of e.hand.values()) {
  16028. let g = t.getJointPose(f, i),
  16029. m = this._getHandJoint(l, f);
  16030. g !== null &&
  16031. (m.matrix.fromArray(g.transform.matrix), m.matrix.decompose(m.position, m.rotation, m.scale), (m.jointRadius = g.radius)),
  16032. (m.visible = g !== null);
  16033. }
  16034. let h = l.joints['index-finger-tip'],
  16035. u = l.joints['thumb-tip'],
  16036. c = h.position.distanceTo(u.position),
  16037. d = 0.02,
  16038. p = 0.005;
  16039. l.inputState.pinching && c > d + p
  16040. ? ((l.inputState.pinching = !1), this.dispatchEvent({ type: 'pinchend', handedness: e.handedness, target: this }))
  16041. : !l.inputState.pinching &&
  16042. c <= d - p &&
  16043. ((l.inputState.pinching = !0), this.dispatchEvent({ type: 'pinchstart', handedness: e.handedness, target: this }));
  16044. } else
  16045. o !== null &&
  16046. e.gripSpace &&
  16047. ((s = t.getPose(e.gripSpace, i)),
  16048. s !== null &&
  16049. (o.matrix.fromArray(s.transform.matrix),
  16050. o.matrix.decompose(o.position, o.rotation, o.scale),
  16051. s.linearVelocity ? ((o.hasLinearVelocity = !0), o.linearVelocity.copy(s.linearVelocity)) : (o.hasLinearVelocity = !1),
  16052. s.angularVelocity ? ((o.hasAngularVelocity = !0), o.angularVelocity.copy(s.angularVelocity)) : (o.hasAngularVelocity = !1)));
  16053. a !== null &&
  16054. ((r = t.getPose(e.targetRaySpace, i)),
  16055. r === null && s !== null && (r = s),
  16056. r !== null &&
  16057. (a.matrix.fromArray(r.transform.matrix),
  16058. a.matrix.decompose(a.position, a.rotation, a.scale),
  16059. r.linearVelocity ? ((a.hasLinearVelocity = !0), a.linearVelocity.copy(r.linearVelocity)) : (a.hasLinearVelocity = !1),
  16060. r.angularVelocity ? ((a.hasAngularVelocity = !0), a.angularVelocity.copy(r.angularVelocity)) : (a.hasAngularVelocity = !1),
  16061. this.dispatchEvent(qP)));
  16062. }
  16063. return a !== null && (a.visible = r !== null), o !== null && (o.visible = s !== null), l !== null && (l.visible = n !== null), this;
  16064. }
  16065. _getHandJoint(e, t) {
  16066. if (e.joints[t.jointName] === void 0) {
  16067. let i = new po();
  16068. (i.matrixAutoUpdate = !1), (i.visible = !1), (e.joints[t.jointName] = i), e.add(i);
  16069. }
  16070. return e.joints[t.jointName];
  16071. }
  16072. },
  16073. pg = class extends ci {
  16074. constructor(e, t, i, r, s, n, a, o, l, h) {
  16075. if (((h = h !== void 0 ? h : da), h !== da && h !== ba))
  16076. throw new Error('DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat');
  16077. i === void 0 && h === da && (i = gn),
  16078. i === void 0 && h === ba && (i = ca),
  16079. super(null, r, s, n, a, o, h, i, l),
  16080. (this.isDepthTexture = !0),
  16081. (this.image = { width: e, height: t }),
  16082. (this.magFilter = a !== void 0 ? a : Ot),
  16083. (this.minFilter = o !== void 0 ? o : Ot),
  16084. (this.flipY = !1),
  16085. (this.generateMipmaps = !1);
  16086. }
  16087. },
  16088. YP = class extends Vi {
  16089. constructor(e, t) {
  16090. super();
  16091. let i = this,
  16092. r = null,
  16093. s = 1,
  16094. n = null,
  16095. a = 'local-floor',
  16096. o = 1,
  16097. l = null,
  16098. h = null,
  16099. u = null,
  16100. c = null,
  16101. d = null,
  16102. p = null,
  16103. f = t.getContextAttributes(),
  16104. g = null,
  16105. m = null,
  16106. v = [],
  16107. y = [],
  16108. b = new Set(),
  16109. x = new Map(),
  16110. w = new wi();
  16111. w.layers.enable(1), (w.viewport = new $e());
  16112. let A = new wi();
  16113. A.layers.enable(2), (A.viewport = new $e());
  16114. let S = [w, A],
  16115. _ = new XP();
  16116. _.layers.enable(1), _.layers.enable(2);
  16117. let M = null,
  16118. C = null;
  16119. (this.cameraAutoUpdate = !0),
  16120. (this.enabled = !1),
  16121. (this.isPresenting = !1),
  16122. (this.getController = function (N) {
  16123. let B = v[N];
  16124. return B === void 0 && ((B = new _p()), (v[N] = B)), B.getTargetRaySpace();
  16125. }),
  16126. (this.getControllerGrip = function (N) {
  16127. let B = v[N];
  16128. return B === void 0 && ((B = new _p()), (v[N] = B)), B.getGripSpace();
  16129. }),
  16130. (this.getHand = function (N) {
  16131. let B = v[N];
  16132. return B === void 0 && ((B = new _p()), (v[N] = B)), B.getHandSpace();
  16133. });
  16134. function T(N) {
  16135. let B = y.indexOf(N.inputSource);
  16136. if (B === -1) return;
  16137. let H = v[B];
  16138. H !== void 0 && H.dispatchEvent({ type: N.type, data: N.inputSource });
  16139. }
  16140. function P() {
  16141. r.removeEventListener('select', T),
  16142. r.removeEventListener('selectstart', T),
  16143. r.removeEventListener('selectend', T),
  16144. r.removeEventListener('squeeze', T),
  16145. r.removeEventListener('squeezestart', T),
  16146. r.removeEventListener('squeezeend', T),
  16147. r.removeEventListener('end', P),
  16148. r.removeEventListener('inputsourceschange', L);
  16149. for (let N = 0; N < v.length; N++) {
  16150. let B = y[N];
  16151. B !== null && ((y[N] = null), v[N].disconnect(B));
  16152. }
  16153. (M = null),
  16154. (C = null),
  16155. e.setRenderTarget(g),
  16156. (d = null),
  16157. (c = null),
  16158. (u = null),
  16159. (r = null),
  16160. (m = null),
  16161. U.stop(),
  16162. (i.isPresenting = !1),
  16163. i.dispatchEvent({ type: 'sessionend' });
  16164. }
  16165. (this.setFramebufferScaleFactor = function (N) {
  16166. (s = N), i.isPresenting === !0 && console.warn('THREE.WebXRManager: Cannot change framebuffer scale while presenting.');
  16167. }),
  16168. (this.setReferenceSpaceType = function (N) {
  16169. (a = N), i.isPresenting === !0 && console.warn('THREE.WebXRManager: Cannot change reference space type while presenting.');
  16170. }),
  16171. (this.getReferenceSpace = function () {
  16172. return l || n;
  16173. }),
  16174. (this.setReferenceSpace = function (N) {
  16175. l = N;
  16176. }),
  16177. (this.getBaseLayer = function () {
  16178. return c !== null ? c : d;
  16179. }),
  16180. (this.getBinding = function () {
  16181. return u;
  16182. }),
  16183. (this.getFrame = function () {
  16184. return p;
  16185. }),
  16186. (this.getSession = function () {
  16187. return r;
  16188. }),
  16189. (this.setSession = async function (N) {
  16190. if (((r = N), r !== null)) {
  16191. if (
  16192. ((g = e.getRenderTarget()),
  16193. r.addEventListener('select', T),
  16194. r.addEventListener('selectstart', T),
  16195. r.addEventListener('selectend', T),
  16196. r.addEventListener('squeeze', T),
  16197. r.addEventListener('squeezestart', T),
  16198. r.addEventListener('squeezeend', T),
  16199. r.addEventListener('end', P),
  16200. r.addEventListener('inputsourceschange', L),
  16201. f.xrCompatible !== !0 && (await t.makeXRCompatible()),
  16202. r.renderState.layers === void 0 || e.capabilities.isWebGL2 === !1)
  16203. ) {
  16204. let B = {
  16205. antialias: r.renderState.layers === void 0 ? f.antialias : !0,
  16206. alpha: f.alpha,
  16207. depth: f.depth,
  16208. stencil: f.stencil,
  16209. framebufferScaleFactor: s
  16210. };
  16211. (d = new XRWebGLLayer(r, t, B)),
  16212. r.updateRenderState({ baseLayer: d }),
  16213. (m = new ii(d.framebufferWidth, d.framebufferHeight, {
  16214. format: Ur,
  16215. type: Mi,
  16216. encoding: e.outputEncoding,
  16217. stencilBuffer: f.stencil
  16218. }));
  16219. } else {
  16220. let B = null,
  16221. H = null,
  16222. Q = null;
  16223. f.depth && ((Q = f.stencil ? 35056 : 33190), (B = f.stencil ? ba : da), (H = f.stencil ? ca : gn));
  16224. let Y = { colorFormat: 32856, depthFormat: Q, scaleFactor: s };
  16225. (u = new XRWebGLBinding(r, t)),
  16226. (c = u.createProjectionLayer(Y)),
  16227. r.updateRenderState({ layers: [c] }),
  16228. (m = new ii(c.textureWidth, c.textureHeight, {
  16229. format: Ur,
  16230. type: Mi,
  16231. depthTexture: new pg(c.textureWidth, c.textureHeight, H, void 0, void 0, void 0, void 0, void 0, void 0, B),
  16232. stencilBuffer: f.stencil,
  16233. encoding: e.outputEncoding,
  16234. samples: f.antialias ? 4 : 0
  16235. }));
  16236. let F = e.properties.get(m);
  16237. F.__ignoreDepthValues = c.ignoreDepthValues;
  16238. }
  16239. (m.isXRRenderTarget = !0),
  16240. this.setFoveation(o),
  16241. (l = null),
  16242. (n = await r.requestReferenceSpace(a)),
  16243. U.setContext(r),
  16244. U.start(),
  16245. (i.isPresenting = !0),
  16246. i.dispatchEvent({ type: 'sessionstart' });
  16247. }
  16248. });
  16249. function L(N) {
  16250. for (let B = 0; B < N.removed.length; B++) {
  16251. let H = N.removed[B],
  16252. Q = y.indexOf(H);
  16253. Q >= 0 && ((y[Q] = null), v[Q].disconnect(H));
  16254. }
  16255. for (let B = 0; B < N.added.length; B++) {
  16256. let H = N.added[B],
  16257. Q = y.indexOf(H);
  16258. if (Q === -1) {
  16259. for (let F = 0; F < v.length; F++)
  16260. if (F >= y.length) {
  16261. y.push(H), (Q = F);
  16262. break;
  16263. } else if (y[F] === null) {
  16264. (y[F] = H), (Q = F);
  16265. break;
  16266. }
  16267. if (Q === -1) break;
  16268. }
  16269. let Y = v[Q];
  16270. Y && Y.connect(H);
  16271. }
  16272. }
  16273. let D = new E(),
  16274. k = new E();
  16275. function W(N, B, H) {
  16276. D.setFromMatrixPosition(B.matrixWorld), k.setFromMatrixPosition(H.matrixWorld);
  16277. let Q = D.distanceTo(k),
  16278. Y = B.projectionMatrix.elements,
  16279. F = H.projectionMatrix.elements,
  16280. se = Y[14] / (Y[10] - 1),
  16281. V = Y[14] / (Y[10] + 1),
  16282. ee = (Y[9] + 1) / Y[5],
  16283. J = (Y[9] - 1) / Y[5],
  16284. fe = (Y[8] - 1) / Y[0],
  16285. re = (F[8] + 1) / F[0],
  16286. oe = se * fe,
  16287. ue = se * re,
  16288. ye = Q / (-fe + re),
  16289. Te = ye * -fe;
  16290. B.matrixWorld.decompose(N.position, N.quaternion, N.scale),
  16291. N.translateX(Te),
  16292. N.translateZ(ye),
  16293. N.matrixWorld.compose(N.position, N.quaternion, N.scale),
  16294. N.matrixWorldInverse.copy(N.matrixWorld).invert();
  16295. let xe = se + ye,
  16296. we = V + ye,
  16297. Ie = oe - Te,
  16298. He = ue + (Q - Te),
  16299. dt = ((ee * V) / we) * xe,
  16300. I = ((J * V) / we) * xe;
  16301. N.projectionMatrix.makePerspective(Ie, He, dt, I, xe, we);
  16302. }
  16303. function X(N, B) {
  16304. B === null ? N.matrixWorld.copy(N.matrix) : N.matrixWorld.multiplyMatrices(B.matrixWorld, N.matrix),
  16305. N.matrixWorldInverse.copy(N.matrixWorld).invert();
  16306. }
  16307. (this.updateCamera = function (N) {
  16308. if (r === null) return;
  16309. (_.near = A.near = w.near = N.near),
  16310. (_.far = A.far = w.far = N.far),
  16311. (M !== _.near || C !== _.far) && (r.updateRenderState({ depthNear: _.near, depthFar: _.far }), (M = _.near), (C = _.far));
  16312. let B = N.parent,
  16313. H = _.cameras;
  16314. X(_, B);
  16315. for (let Y = 0; Y < H.length; Y++) X(H[Y], B);
  16316. _.matrixWorld.decompose(_.position, _.quaternion, _.scale),
  16317. N.matrix.copy(_.matrix),
  16318. N.matrix.decompose(N.position, N.quaternion, N.scale);
  16319. let Q = N.children;
  16320. for (let Y = 0, F = Q.length; Y < F; Y++) Q[Y].updateMatrixWorld(!0);
  16321. H.length === 2 ? W(_, w, A) : _.projectionMatrix.copy(w.projectionMatrix);
  16322. }),
  16323. (this.getCamera = function () {
  16324. return _;
  16325. }),
  16326. (this.getFoveation = function () {
  16327. if (!(c === null && d === null)) return o;
  16328. }),
  16329. (this.setFoveation = function (N) {
  16330. (o = N), c !== null && (c.fixedFoveation = N), d !== null && d.fixedFoveation !== void 0 && (d.fixedFoveation = N);
  16331. }),
  16332. (this.getPlanes = function () {
  16333. return b;
  16334. });
  16335. let z = null;
  16336. function j(N, B) {
  16337. if (((h = B.getViewerPose(l || n)), (p = B), h !== null)) {
  16338. let H = h.views;
  16339. d !== null && (e.setRenderTargetFramebuffer(m, d.framebuffer), e.setRenderTarget(m));
  16340. let Q = !1;
  16341. H.length !== _.cameras.length && ((_.cameras.length = 0), (Q = !0));
  16342. for (let Y = 0; Y < H.length; Y++) {
  16343. let F = H[Y],
  16344. se = null;
  16345. if (d !== null) se = d.getViewport(F);
  16346. else {
  16347. let ee = u.getViewSubImage(c, F);
  16348. (se = ee.viewport),
  16349. Y === 0 &&
  16350. (e.setRenderTargetTextures(m, ee.colorTexture, c.ignoreDepthValues ? void 0 : ee.depthStencilTexture),
  16351. e.setRenderTarget(m));
  16352. }
  16353. let V = S[Y];
  16354. V === void 0 && ((V = new wi()), V.layers.enable(Y), (V.viewport = new $e()), (S[Y] = V)),
  16355. V.matrix.fromArray(F.transform.matrix),
  16356. V.projectionMatrix.fromArray(F.projectionMatrix),
  16357. V.viewport.set(se.x, se.y, se.width, se.height),
  16358. Y === 0 && _.matrix.copy(V.matrix),
  16359. Q === !0 && _.cameras.push(V);
  16360. }
  16361. }
  16362. for (let H = 0; H < v.length; H++) {
  16363. let Q = y[H],
  16364. Y = v[H];
  16365. Q !== null && Y !== void 0 && Y.update(Q, B, l || n);
  16366. }
  16367. if ((z && z(N, B), B.detectedPlanes)) {
  16368. i.dispatchEvent({ type: 'planesdetected', data: B.detectedPlanes });
  16369. let H = null;
  16370. for (let Q of b) B.detectedPlanes.has(Q) || (H === null && (H = []), H.push(Q));
  16371. if (H !== null) for (let Q of H) b.delete(Q), x.delete(Q), i.dispatchEvent({ type: 'planeremoved', data: Q });
  16372. for (let Q of B.detectedPlanes)
  16373. if (!b.has(Q)) b.add(Q), x.set(Q, B.lastChangedTime), i.dispatchEvent({ type: 'planeadded', data: Q });
  16374. else {
  16375. let Y = x.get(Q);
  16376. Q.lastChangedTime > Y && (x.set(Q, Q.lastChangedTime), i.dispatchEvent({ type: 'planechanged', data: Q }));
  16377. }
  16378. }
  16379. p = null;
  16380. }
  16381. let U = new yw();
  16382. U.setAnimationLoop(j),
  16383. (this.setAnimationLoop = function (N) {
  16384. z = N;
  16385. }),
  16386. (this.dispose = function () {});
  16387. }
  16388. };
  16389. function QP(e, t) {
  16390. function i(g, m) {
  16391. m.color.getRGB(g.fogColor.value, vw(e)),
  16392. m.isFog ? ((g.fogNear.value = m.near), (g.fogFar.value = m.far)) : m.isFogExp2 && (g.fogDensity.value = m.density);
  16393. }
  16394. function r(g, m, v, y, b) {
  16395. m.isMeshBasicMaterial || m.isMeshLambertMaterial
  16396. ? s(g, m)
  16397. : m.isMeshToonMaterial
  16398. ? (s(g, m), u(g, m))
  16399. : m.isMeshPhongMaterial
  16400. ? (s(g, m), h(g, m))
  16401. : m.isMeshStandardMaterial
  16402. ? (s(g, m), c(g, m), m.isMeshPhysicalMaterial && d(g, m, b))
  16403. : m.isMeshMatcapMaterial
  16404. ? (s(g, m), p(g, m))
  16405. : m.isMeshDepthMaterial
  16406. ? s(g, m)
  16407. : m.isMeshDistanceMaterial
  16408. ? (s(g, m), f(g, m))
  16409. : m.isMeshNormalMaterial
  16410. ? s(g, m)
  16411. : m.isLineBasicMaterial
  16412. ? (n(g, m), m.isLineDashedMaterial && a(g, m))
  16413. : m.isPointsMaterial
  16414. ? o(g, m, v, y)
  16415. : m.isSpriteMaterial
  16416. ? l(g, m)
  16417. : m.isShadowMaterial
  16418. ? (g.color.value.copy(m.color), (g.opacity.value = m.opacity))
  16419. : m.isShaderMaterial && (m.uniformsNeedUpdate = !1);
  16420. }
  16421. function s(g, m) {
  16422. (g.opacity.value = m.opacity),
  16423. m.color && g.diffuse.value.copy(m.color),
  16424. m.emissive && g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),
  16425. m.map && (g.map.value = m.map),
  16426. m.alphaMap && (g.alphaMap.value = m.alphaMap),
  16427. m.bumpMap && ((g.bumpMap.value = m.bumpMap), (g.bumpScale.value = m.bumpScale), m.side === hi && (g.bumpScale.value *= -1)),
  16428. m.displacementMap &&
  16429. ((g.displacementMap.value = m.displacementMap),
  16430. (g.displacementScale.value = m.displacementScale),
  16431. (g.displacementBias.value = m.displacementBias)),
  16432. m.emissiveMap && (g.emissiveMap.value = m.emissiveMap),
  16433. m.normalMap &&
  16434. ((g.normalMap.value = m.normalMap), g.normalScale.value.copy(m.normalScale), m.side === hi && g.normalScale.value.negate()),
  16435. m.specularMap && (g.specularMap.value = m.specularMap),
  16436. m.alphaTest > 0 && (g.alphaTest.value = m.alphaTest);
  16437. let v = t.get(m).envMap;
  16438. if (
  16439. (v &&
  16440. ((g.envMap.value = v),
  16441. (g.flipEnvMap.value = v.isCubeTexture && v.isRenderTargetTexture === !1 ? -1 : 1),
  16442. (g.reflectivity.value = m.reflectivity),
  16443. (g.ior.value = m.ior),
  16444. (g.refractionRatio.value = m.refractionRatio)),
  16445. m.lightMap)
  16446. ) {
  16447. g.lightMap.value = m.lightMap;
  16448. let x = e.physicallyCorrectLights !== !0 ? Math.PI : 1;
  16449. g.lightMapIntensity.value = m.lightMapIntensity * x;
  16450. }
  16451. m.aoMap && ((g.aoMap.value = m.aoMap), (g.aoMapIntensity.value = m.aoMapIntensity));
  16452. let y;
  16453. m.map
  16454. ? (y = m.map)
  16455. : m.specularMap
  16456. ? (y = m.specularMap)
  16457. : m.displacementMap
  16458. ? (y = m.displacementMap)
  16459. : m.normalMap
  16460. ? (y = m.normalMap)
  16461. : m.bumpMap
  16462. ? (y = m.bumpMap)
  16463. : m.roughnessMap
  16464. ? (y = m.roughnessMap)
  16465. : m.metalnessMap
  16466. ? (y = m.metalnessMap)
  16467. : m.alphaMap
  16468. ? (y = m.alphaMap)
  16469. : m.emissiveMap
  16470. ? (y = m.emissiveMap)
  16471. : m.clearcoatMap
  16472. ? (y = m.clearcoatMap)
  16473. : m.clearcoatNormalMap
  16474. ? (y = m.clearcoatNormalMap)
  16475. : m.clearcoatRoughnessMap
  16476. ? (y = m.clearcoatRoughnessMap)
  16477. : m.iridescenceMap
  16478. ? (y = m.iridescenceMap)
  16479. : m.iridescenceThicknessMap
  16480. ? (y = m.iridescenceThicknessMap)
  16481. : m.specularIntensityMap
  16482. ? (y = m.specularIntensityMap)
  16483. : m.specularColorMap
  16484. ? (y = m.specularColorMap)
  16485. : m.transmissionMap
  16486. ? (y = m.transmissionMap)
  16487. : m.thicknessMap
  16488. ? (y = m.thicknessMap)
  16489. : m.sheenColorMap
  16490. ? (y = m.sheenColorMap)
  16491. : m.sheenRoughnessMap && (y = m.sheenRoughnessMap),
  16492. y !== void 0 &&
  16493. (y.isWebGLRenderTarget && (y = y.texture), y.matrixAutoUpdate === !0 && y.updateMatrix(), g.uvTransform.value.copy(y.matrix));
  16494. let b;
  16495. m.aoMap ? (b = m.aoMap) : m.lightMap && (b = m.lightMap),
  16496. b !== void 0 &&
  16497. (b.isWebGLRenderTarget && (b = b.texture), b.matrixAutoUpdate === !0 && b.updateMatrix(), g.uv2Transform.value.copy(b.matrix));
  16498. }
  16499. function n(g, m) {
  16500. g.diffuse.value.copy(m.color), (g.opacity.value = m.opacity);
  16501. }
  16502. function a(g, m) {
  16503. (g.dashSize.value = m.dashSize), (g.totalSize.value = m.dashSize + m.gapSize), (g.scale.value = m.scale);
  16504. }
  16505. function o(g, m, v, y) {
  16506. g.diffuse.value.copy(m.color),
  16507. (g.opacity.value = m.opacity),
  16508. (g.size.value = m.size * v),
  16509. (g.scale.value = y * 0.5),
  16510. m.map && (g.map.value = m.map),
  16511. m.alphaMap && (g.alphaMap.value = m.alphaMap),
  16512. m.alphaTest > 0 && (g.alphaTest.value = m.alphaTest);
  16513. let b;
  16514. m.map ? (b = m.map) : m.alphaMap && (b = m.alphaMap),
  16515. b !== void 0 && (b.matrixAutoUpdate === !0 && b.updateMatrix(), g.uvTransform.value.copy(b.matrix));
  16516. }
  16517. function l(g, m) {
  16518. g.diffuse.value.copy(m.color),
  16519. (g.opacity.value = m.opacity),
  16520. (g.rotation.value = m.rotation),
  16521. m.map && (g.map.value = m.map),
  16522. m.alphaMap && (g.alphaMap.value = m.alphaMap),
  16523. m.alphaTest > 0 && (g.alphaTest.value = m.alphaTest);
  16524. let v;
  16525. m.map ? (v = m.map) : m.alphaMap && (v = m.alphaMap),
  16526. v !== void 0 && (v.matrixAutoUpdate === !0 && v.updateMatrix(), g.uvTransform.value.copy(v.matrix));
  16527. }
  16528. function h(g, m) {
  16529. g.specular.value.copy(m.specular), (g.shininess.value = Math.max(m.shininess, 1e-4));
  16530. }
  16531. function u(g, m) {
  16532. m.gradientMap && (g.gradientMap.value = m.gradientMap);
  16533. }
  16534. function c(g, m) {
  16535. (g.roughness.value = m.roughness),
  16536. (g.metalness.value = m.metalness),
  16537. m.roughnessMap && (g.roughnessMap.value = m.roughnessMap),
  16538. m.metalnessMap && (g.metalnessMap.value = m.metalnessMap),
  16539. t.get(m).envMap && (g.envMapIntensity.value = m.envMapIntensity);
  16540. }
  16541. function d(g, m, v) {
  16542. (g.ior.value = m.ior),
  16543. m.sheen > 0 &&
  16544. (g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),
  16545. (g.sheenRoughness.value = m.sheenRoughness),
  16546. m.sheenColorMap && (g.sheenColorMap.value = m.sheenColorMap),
  16547. m.sheenRoughnessMap && (g.sheenRoughnessMap.value = m.sheenRoughnessMap)),
  16548. m.clearcoat > 0 &&
  16549. ((g.clearcoat.value = m.clearcoat),
  16550. (g.clearcoatRoughness.value = m.clearcoatRoughness),
  16551. m.clearcoatMap && (g.clearcoatMap.value = m.clearcoatMap),
  16552. m.clearcoatRoughnessMap && (g.clearcoatRoughnessMap.value = m.clearcoatRoughnessMap),
  16553. m.clearcoatNormalMap &&
  16554. (g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),
  16555. (g.clearcoatNormalMap.value = m.clearcoatNormalMap),
  16556. m.side === hi && g.clearcoatNormalScale.value.negate())),
  16557. m.iridescence > 0 &&
  16558. ((g.iridescence.value = m.iridescence),
  16559. (g.iridescenceIOR.value = m.iridescenceIOR),
  16560. (g.iridescenceThicknessMinimum.value = m.iridescenceThicknessRange[0]),
  16561. (g.iridescenceThicknessMaximum.value = m.iridescenceThicknessRange[1]),
  16562. m.iridescenceMap && (g.iridescenceMap.value = m.iridescenceMap),
  16563. m.iridescenceThicknessMap && (g.iridescenceThicknessMap.value = m.iridescenceThicknessMap)),
  16564. m.transmission > 0 &&
  16565. ((g.transmission.value = m.transmission),
  16566. (g.transmissionSamplerMap.value = v.texture),
  16567. g.transmissionSamplerSize.value.set(v.width, v.height),
  16568. m.transmissionMap && (g.transmissionMap.value = m.transmissionMap),
  16569. (g.thickness.value = m.thickness),
  16570. m.thicknessMap && (g.thicknessMap.value = m.thicknessMap),
  16571. (g.attenuationDistance.value = m.attenuationDistance),
  16572. g.attenuationColor.value.copy(m.attenuationColor)),
  16573. (g.specularIntensity.value = m.specularIntensity),
  16574. g.specularColor.value.copy(m.specularColor),
  16575. m.specularIntensityMap && (g.specularIntensityMap.value = m.specularIntensityMap),
  16576. m.specularColorMap && (g.specularColorMap.value = m.specularColorMap);
  16577. }
  16578. function p(g, m) {
  16579. m.matcap && (g.matcap.value = m.matcap);
  16580. }
  16581. function f(g, m) {
  16582. g.referencePosition.value.copy(m.referencePosition), (g.nearDistance.value = m.nearDistance), (g.farDistance.value = m.farDistance);
  16583. }
  16584. return { refreshFogUniforms: i, refreshMaterialUniforms: r };
  16585. }
  16586. function ZP(e, t, i, r) {
  16587. let s = {},
  16588. n = {},
  16589. a = [],
  16590. o = i.isWebGL2 ? e.getParameter(35375) : 0;
  16591. function l(y, b) {
  16592. let x = b.program;
  16593. r.uniformBlockBinding(y, x);
  16594. }
  16595. function h(y, b) {
  16596. let x = s[y.id];
  16597. x === void 0 && (f(y), (x = u(y)), (s[y.id] = x), y.addEventListener('dispose', m));
  16598. let w = b.program;
  16599. r.updateUBOMapping(y, w);
  16600. let A = t.render.frame;
  16601. n[y.id] !== A && (d(y), (n[y.id] = A));
  16602. }
  16603. function u(y) {
  16604. let b = c();
  16605. y.__bindingPointIndex = b;
  16606. let x = e.createBuffer(),
  16607. w = y.__size,
  16608. A = y.usage;
  16609. return e.bindBuffer(35345, x), e.bufferData(35345, w, A), e.bindBuffer(35345, null), e.bindBufferBase(35345, b, x), x;
  16610. }
  16611. function c() {
  16612. for (let y = 0; y < o; y++) if (a.indexOf(y) === -1) return a.push(y), y;
  16613. return console.error('THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.'), 0;
  16614. }
  16615. function d(y) {
  16616. let b = s[y.id],
  16617. x = y.uniforms,
  16618. w = y.__cache;
  16619. e.bindBuffer(35345, b);
  16620. for (let A = 0, S = x.length; A < S; A++) {
  16621. let _ = x[A];
  16622. if (p(_, A, w) === !0) {
  16623. let M = _.__offset,
  16624. C = Array.isArray(_.value) ? _.value : [_.value],
  16625. T = 0;
  16626. for (let P = 0; P < C.length; P++) {
  16627. let L = C[P],
  16628. D = g(L);
  16629. typeof L == 'number'
  16630. ? ((_.__data[0] = L), e.bufferSubData(35345, M + T, _.__data))
  16631. : L.isMatrix3
  16632. ? ((_.__data[0] = L.elements[0]),
  16633. (_.__data[1] = L.elements[1]),
  16634. (_.__data[2] = L.elements[2]),
  16635. (_.__data[3] = L.elements[0]),
  16636. (_.__data[4] = L.elements[3]),
  16637. (_.__data[5] = L.elements[4]),
  16638. (_.__data[6] = L.elements[5]),
  16639. (_.__data[7] = L.elements[0]),
  16640. (_.__data[8] = L.elements[6]),
  16641. (_.__data[9] = L.elements[7]),
  16642. (_.__data[10] = L.elements[8]),
  16643. (_.__data[11] = L.elements[0]))
  16644. : (L.toArray(_.__data, T), (T += D.storage / Float32Array.BYTES_PER_ELEMENT));
  16645. }
  16646. e.bufferSubData(35345, M, _.__data);
  16647. }
  16648. }
  16649. e.bindBuffer(35345, null);
  16650. }
  16651. function p(y, b, x) {
  16652. let w = y.value;
  16653. if (x[b] === void 0) {
  16654. if (typeof w == 'number') x[b] = w;
  16655. else {
  16656. let A = Array.isArray(w) ? w : [w],
  16657. S = [];
  16658. for (let _ = 0; _ < A.length; _++) S.push(A[_].clone());
  16659. x[b] = S;
  16660. }
  16661. return !0;
  16662. } else if (typeof w == 'number') {
  16663. if (x[b] !== w) return (x[b] = w), !0;
  16664. } else {
  16665. let A = Array.isArray(x[b]) ? x[b] : [x[b]],
  16666. S = Array.isArray(w) ? w : [w];
  16667. for (let _ = 0; _ < A.length; _++) {
  16668. let M = A[_];
  16669. if (M.equals(S[_]) === !1) return M.copy(S[_]), !0;
  16670. }
  16671. }
  16672. return !1;
  16673. }
  16674. function f(y) {
  16675. let b = y.uniforms,
  16676. x = 0,
  16677. w = 16,
  16678. A = 0;
  16679. for (let S = 0, _ = b.length; S < _; S++) {
  16680. let M = b[S],
  16681. C = { boundary: 0, storage: 0 },
  16682. T = Array.isArray(M.value) ? M.value : [M.value];
  16683. for (let P = 0, L = T.length; P < L; P++) {
  16684. let D = T[P],
  16685. k = g(D);
  16686. (C.boundary += k.boundary), (C.storage += k.storage);
  16687. }
  16688. if (((M.__data = new Float32Array(C.storage / Float32Array.BYTES_PER_ELEMENT)), (M.__offset = x), S > 0)) {
  16689. A = x % w;
  16690. let P = w - A;
  16691. A !== 0 && P - C.boundary < 0 && ((x += w - A), (M.__offset = x));
  16692. }
  16693. x += C.storage;
  16694. }
  16695. return (A = x % w), A > 0 && (x += w - A), (y.__size = x), (y.__cache = {}), this;
  16696. }
  16697. function g(y) {
  16698. let b = { boundary: 0, storage: 0 };
  16699. return (
  16700. typeof y == 'number'
  16701. ? ((b.boundary = 4), (b.storage = 4))
  16702. : y.isVector2
  16703. ? ((b.boundary = 8), (b.storage = 8))
  16704. : y.isVector3 || y.isColor
  16705. ? ((b.boundary = 16), (b.storage = 12))
  16706. : y.isVector4
  16707. ? ((b.boundary = 16), (b.storage = 16))
  16708. : y.isMatrix3
  16709. ? ((b.boundary = 48), (b.storage = 48))
  16710. : y.isMatrix4
  16711. ? ((b.boundary = 64), (b.storage = 64))
  16712. : y.isTexture
  16713. ? console.warn('THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.')
  16714. : console.warn('THREE.WebGLRenderer: Unsupported uniform value type.', y),
  16715. b
  16716. );
  16717. }
  16718. function m(y) {
  16719. let b = y.target;
  16720. b.removeEventListener('dispose', m);
  16721. let x = a.indexOf(b.__bindingPointIndex);
  16722. a.splice(x, 1), e.deleteBuffer(s[b.id]), delete s[b.id], delete n[b.id];
  16723. }
  16724. function v() {
  16725. for (let y in s) e.deleteBuffer(s[y]);
  16726. (a = []), (s = {}), (n = {});
  16727. }
  16728. return { bind: l, update: h, dispose: v };
  16729. }
  16730. function KP() {
  16731. let e = md('canvas');
  16732. return (e.style.display = 'block'), e;
  16733. }
  16734. function Sw(e = {}) {
  16735. this.isWebGLRenderer = !0;
  16736. let t = e.canvas !== void 0 ? e.canvas : KP(),
  16737. i = e.context !== void 0 ? e.context : null,
  16738. r = e.depth !== void 0 ? e.depth : !0,
  16739. s = e.stencil !== void 0 ? e.stencil : !0,
  16740. n = e.antialias !== void 0 ? e.antialias : !1,
  16741. a = e.premultipliedAlpha !== void 0 ? e.premultipliedAlpha : !0,
  16742. o = e.preserveDrawingBuffer !== void 0 ? e.preserveDrawingBuffer : !1,
  16743. l = e.powerPreference !== void 0 ? e.powerPreference : 'default',
  16744. h = e.failIfMajorPerformanceCaveat !== void 0 ? e.failIfMajorPerformanceCaveat : !1,
  16745. u;
  16746. i !== null ? (u = i.getContextAttributes().alpha) : (u = e.alpha !== void 0 ? e.alpha : !1);
  16747. let c = null,
  16748. d = null,
  16749. p = [],
  16750. f = [];
  16751. (this.domElement = t),
  16752. (this.debug = { checkShaderErrors: !0 }),
  16753. (this.autoClear = !0),
  16754. (this.autoClearColor = !0),
  16755. (this.autoClearDepth = !0),
  16756. (this.autoClearStencil = !0),
  16757. (this.sortObjects = !0),
  16758. (this.clippingPlanes = []),
  16759. (this.localClippingEnabled = !1),
  16760. (this.outputEncoding = gs),
  16761. (this.physicallyCorrectLights = !1),
  16762. (this.toneMapping = Gs),
  16763. (this.toneMappingExposure = 1);
  16764. let g = this,
  16765. m = !1,
  16766. v = 0,
  16767. y = 0,
  16768. b = null,
  16769. x = -1,
  16770. w = null,
  16771. A = new $e(),
  16772. S = new $e(),
  16773. _ = null,
  16774. M = t.width,
  16775. C = t.height,
  16776. T = 1,
  16777. P = null,
  16778. L = null,
  16779. D = new $e(0, 0, M, C),
  16780. k = new $e(0, 0, M, C),
  16781. W = !1,
  16782. X = new dg(),
  16783. z = !1,
  16784. j = !1,
  16785. U = null,
  16786. N = new ve(),
  16787. B = new G(),
  16788. H = new E(),
  16789. Q = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: !0 };
  16790. function Y() {
  16791. return b === null ? T : 1;
  16792. }
  16793. let F = i;
  16794. function se(R, $) {
  16795. for (let ae = 0; ae < R.length; ae++) {
  16796. let K = R[ae],
  16797. he = t.getContext(K, $);
  16798. if (he !== null) return he;
  16799. }
  16800. return null;
  16801. }
  16802. try {
  16803. let R = {
  16804. alpha: !0,
  16805. depth: r,
  16806. stencil: s,
  16807. antialias: n,
  16808. premultipliedAlpha: a,
  16809. preserveDrawingBuffer: o,
  16810. powerPreference: l,
  16811. failIfMajorPerformanceCaveat: h
  16812. };
  16813. if (
  16814. ('setAttribute' in t && t.setAttribute('data-engine', `three.js r${Wo}`),
  16815. t.addEventListener('webglcontextlost', Le, !1),
  16816. t.addEventListener('webglcontextrestored', Ne, !1),
  16817. t.addEventListener('webglcontextcreationerror', at, !1),
  16818. F === null)
  16819. ) {
  16820. let $ = ['webgl2', 'webgl', 'experimental-webgl'];
  16821. if ((g.isWebGL1Renderer === !0 && $.shift(), (F = se($, R)), F === null))
  16822. throw se($) ? new Error('Error creating WebGL context with your selected attributes.') : new Error('Error creating WebGL context.');
  16823. }
  16824. F.getShaderPrecisionFormat === void 0 &&
  16825. (F.getShaderPrecisionFormat = function () {
  16826. return { rangeMin: 1, rangeMax: 1, precision: 1 };
  16827. });
  16828. } catch (R) {
  16829. throw (console.error('THREE.WebGLRenderer: ' + R.message), R);
  16830. }
  16831. let V, ee, J, fe, re, oe, ue, ye, Te, xe, we, Ie, He, dt, I, O, ie, pe, me, be, We, Me, ce, Fe;
  16832. function Ee() {
  16833. (V = new c3(F)),
  16834. (ee = new s3(F, V, e)),
  16835. V.init(ee),
  16836. (Me = new WP(F, V, ee)),
  16837. (J = new VP(F, V, ee)),
  16838. (fe = new p3()),
  16839. (re = new DP()),
  16840. (oe = new HP(F, V, J, re, ee, Me, fe)),
  16841. (ue = new a3(g)),
  16842. (ye = new h3(g)),
  16843. (Te = new _E(F, ee)),
  16844. (ce = new i3(F, V, Te, ee)),
  16845. (xe = new d3(F, Te, fe, ce)),
  16846. (we = new v3(F, xe, Te, fe)),
  16847. (me = new g3(F, ee, oe)),
  16848. (O = new n3(re)),
  16849. (Ie = new PP(g, ue, ye, V, ee, ce, O)),
  16850. (He = new QP(g, re)),
  16851. (dt = new OP()),
  16852. (I = new UP(V, ee)),
  16853. (pe = new t3(g, ue, ye, J, we, u, a)),
  16854. (ie = new GP(g, we, ee)),
  16855. (Fe = new ZP(F, fe, ee, J)),
  16856. (be = new r3(F, V, fe, ee)),
  16857. (We = new u3(F, V, fe, ee)),
  16858. (fe.programs = Ie.programs),
  16859. (g.capabilities = ee),
  16860. (g.extensions = V),
  16861. (g.properties = re),
  16862. (g.renderLists = dt),
  16863. (g.shadowMap = ie),
  16864. (g.state = J),
  16865. (g.info = fe);
  16866. }
  16867. Ee();
  16868. let _e = new YP(g, F);
  16869. (this.xr = _e),
  16870. (this.getContext = function () {
  16871. return F;
  16872. }),
  16873. (this.getContextAttributes = function () {
  16874. return F.getContextAttributes();
  16875. }),
  16876. (this.forceContextLoss = function () {
  16877. let R = V.get('WEBGL_lose_context');
  16878. R && R.loseContext();
  16879. }),
  16880. (this.forceContextRestore = function () {
  16881. let R = V.get('WEBGL_lose_context');
  16882. R && R.restoreContext();
  16883. }),
  16884. (this.getPixelRatio = function () {
  16885. return T;
  16886. }),
  16887. (this.setPixelRatio = function (R) {
  16888. R !== void 0 && ((T = R), this.setSize(M, C, !1));
  16889. }),
  16890. (this.getSize = function (R) {
  16891. return R.set(M, C);
  16892. }),
  16893. (this.setSize = function (R, $, ae) {
  16894. if (_e.isPresenting) {
  16895. console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");
  16896. return;
  16897. }
  16898. (M = R),
  16899. (C = $),
  16900. (t.width = Math.floor(R * T)),
  16901. (t.height = Math.floor($ * T)),
  16902. ae !== !1 && ((t.style.width = R + 'px'), (t.style.height = $ + 'px')),
  16903. this.setViewport(0, 0, R, $);
  16904. }),
  16905. (this.getDrawingBufferSize = function (R) {
  16906. return R.set(M * T, C * T).floor();
  16907. }),
  16908. (this.setDrawingBufferSize = function (R, $, ae) {
  16909. (M = R), (C = $), (T = ae), (t.width = Math.floor(R * ae)), (t.height = Math.floor($ * ae)), this.setViewport(0, 0, R, $);
  16910. }),
  16911. (this.getCurrentViewport = function (R) {
  16912. return R.copy(A);
  16913. }),
  16914. (this.getViewport = function (R) {
  16915. return R.copy(D);
  16916. }),
  16917. (this.setViewport = function (R, $, ae, K) {
  16918. R.isVector4 ? D.set(R.x, R.y, R.z, R.w) : D.set(R, $, ae, K), J.viewport(A.copy(D).multiplyScalar(T).floor());
  16919. }),
  16920. (this.getScissor = function (R) {
  16921. return R.copy(k);
  16922. }),
  16923. (this.setScissor = function (R, $, ae, K) {
  16924. R.isVector4 ? k.set(R.x, R.y, R.z, R.w) : k.set(R, $, ae, K), J.scissor(S.copy(k).multiplyScalar(T).floor());
  16925. }),
  16926. (this.getScissorTest = function () {
  16927. return W;
  16928. }),
  16929. (this.setScissorTest = function (R) {
  16930. J.setScissorTest((W = R));
  16931. }),
  16932. (this.setOpaqueSort = function (R) {
  16933. P = R;
  16934. }),
  16935. (this.setTransparentSort = function (R) {
  16936. L = R;
  16937. }),
  16938. (this.getClearColor = function (R) {
  16939. return R.copy(pe.getClearColor());
  16940. }),
  16941. (this.setClearColor = function () {
  16942. pe.setClearColor.apply(pe, arguments);
  16943. }),
  16944. (this.getClearAlpha = function () {
  16945. return pe.getClearAlpha();
  16946. }),
  16947. (this.setClearAlpha = function () {
  16948. pe.setClearAlpha.apply(pe, arguments);
  16949. }),
  16950. (this.clear = function (R = !0, $ = !0, ae = !0) {
  16951. let K = 0;
  16952. R && (K |= 16384), $ && (K |= 256), ae && (K |= 1024), F.clear(K);
  16953. }),
  16954. (this.clearColor = function () {
  16955. this.clear(!0, !1, !1);
  16956. }),
  16957. (this.clearDepth = function () {
  16958. this.clear(!1, !0, !1);
  16959. }),
  16960. (this.clearStencil = function () {
  16961. this.clear(!1, !1, !0);
  16962. }),
  16963. (this.dispose = function () {
  16964. t.removeEventListener('webglcontextlost', Le, !1),
  16965. t.removeEventListener('webglcontextrestored', Ne, !1),
  16966. t.removeEventListener('webglcontextcreationerror', at, !1),
  16967. dt.dispose(),
  16968. I.dispose(),
  16969. re.dispose(),
  16970. ue.dispose(),
  16971. ye.dispose(),
  16972. we.dispose(),
  16973. ce.dispose(),
  16974. Fe.dispose(),
  16975. Ie.dispose(),
  16976. _e.dispose(),
  16977. _e.removeEventListener('sessionstart', Ae),
  16978. _e.removeEventListener('sessionend', De),
  16979. U && (U.dispose(), (U = null)),
  16980. ot.stop();
  16981. });
  16982. function Le(R) {
  16983. R.preventDefault(), console.log('THREE.WebGLRenderer: Context Lost.'), (m = !0);
  16984. }
  16985. function Ne() {
  16986. console.log('THREE.WebGLRenderer: Context Restored.'), (m = !1);
  16987. let R = fe.autoReset,
  16988. $ = ie.enabled,
  16989. ae = ie.autoUpdate,
  16990. K = ie.needsUpdate,
  16991. he = ie.type;
  16992. Ee(), (fe.autoReset = R), (ie.enabled = $), (ie.autoUpdate = ae), (ie.needsUpdate = K), (ie.type = he);
  16993. }
  16994. function at(R) {
  16995. console.error('THREE.WebGLRenderer: A WebGL context could not be created. Reason: ', R.statusMessage);
  16996. }
  16997. function Mt(R) {
  16998. let $ = R.target;
  16999. $.removeEventListener('dispose', Mt), Wt($);
  17000. }
  17001. function Wt(R) {
  17002. q(R), re.remove(R);
  17003. }
  17004. function q(R) {
  17005. let $ = re.get(R).programs;
  17006. $ !== void 0 &&
  17007. ($.forEach(function (ae) {
  17008. Ie.releaseProgram(ae);
  17009. }),
  17010. R.isShaderMaterial && Ie.releaseShaderCache(R));
  17011. }
  17012. (this.renderBufferDirect = function (R, $, ae, K, he, Be) {
  17013. $ === null && ($ = Q);
  17014. let Je = he.isMesh && he.matrixWorld.determinant() < 0,
  17015. et = O2(R, $, ae, K, he);
  17016. J.setMaterial(K, Je);
  17017. let st = ae.index,
  17018. wt = 1;
  17019. K.wireframe === !0 && ((st = xe.getWireframeAttribute(ae)), (wt = 2));
  17020. let ut = ae.drawRange,
  17021. lt = ae.attributes.position,
  17022. vi = ut.start * wt,
  17023. Wi = (ut.start + ut.count) * wt;
  17024. Be !== null && ((vi = Math.max(vi, Be.start * wt)), (Wi = Math.min(Wi, (Be.start + Be.count) * wt))),
  17025. st !== null
  17026. ? ((vi = Math.max(vi, 0)), (Wi = Math.min(Wi, st.count)))
  17027. : lt != null && ((vi = Math.max(vi, 0)), (Wi = Math.min(Wi, lt.count)));
  17028. let Es = Wi - vi;
  17029. if (Es < 0 || Es === 1 / 0) return;
  17030. ce.setup(he, K, et, ae, st);
  17031. let jn,
  17032. qt = be;
  17033. if ((st !== null && ((jn = Te.get(st)), (qt = We), qt.setIndex(jn)), he.isMesh))
  17034. K.wireframe === !0 ? (J.setLineWidth(K.wireframeLinewidth * Y()), qt.setMode(1)) : qt.setMode(4);
  17035. else if (he.isLine) {
  17036. let ht = K.linewidth;
  17037. ht === void 0 && (ht = 1),
  17038. J.setLineWidth(ht * Y()),
  17039. he.isLineSegments ? qt.setMode(1) : he.isLineLoop ? qt.setMode(2) : qt.setMode(3);
  17040. } else he.isPoints ? qt.setMode(0) : he.isSprite && qt.setMode(4);
  17041. if (he.isInstancedMesh) qt.renderInstances(vi, Es, he.count);
  17042. else if (ae.isInstancedBufferGeometry) {
  17043. let ht = ae._maxInstanceCount !== void 0 ? ae._maxInstanceCount : 1 / 0,
  17044. ku = Math.min(ae.instanceCount, ht);
  17045. qt.renderInstances(vi, Es, ku);
  17046. } else qt.render(vi, Es);
  17047. }),
  17048. (this.compile = function (R, $) {
  17049. function ae(K, he, Be) {
  17050. K.transparent === !0 && K.side === er && K.forceSinglePass === !1
  17051. ? ((K.side = hi), (K.needsUpdate = !0), lr(K, he, Be), (K.side = Vr), (K.needsUpdate = !0), lr(K, he, Be), (K.side = er))
  17052. : lr(K, he, Be);
  17053. }
  17054. (d = I.get(R)),
  17055. d.init(),
  17056. f.push(d),
  17057. R.traverseVisible(function (K) {
  17058. K.isLight && K.layers.test($.layers) && (d.pushLight(K), K.castShadow && d.pushShadow(K));
  17059. }),
  17060. d.setupLights(g.physicallyCorrectLights),
  17061. R.traverse(function (K) {
  17062. let he = K.material;
  17063. if (he)
  17064. if (Array.isArray(he))
  17065. for (let Be = 0; Be < he.length; Be++) {
  17066. let Je = he[Be];
  17067. ae(Je, R, K);
  17068. }
  17069. else ae(he, R, K);
  17070. }),
  17071. f.pop(),
  17072. (d = null);
  17073. });
  17074. let ne = null;
  17075. function de(R) {
  17076. ne && ne(R);
  17077. }
  17078. function Ae() {
  17079. ot.stop();
  17080. }
  17081. function De() {
  17082. ot.start();
  17083. }
  17084. let ot = new yw();
  17085. ot.setAnimationLoop(de),
  17086. typeof self < 'u' && ot.setContext(self),
  17087. (this.setAnimationLoop = function (R) {
  17088. (ne = R), _e.setAnimationLoop(R), R === null ? ot.stop() : ot.start();
  17089. }),
  17090. _e.addEventListener('sessionstart', Ae),
  17091. _e.addEventListener('sessionend', De),
  17092. (this.render = function (R, $) {
  17093. if ($ !== void 0 && $.isCamera !== !0) {
  17094. console.error('THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.');
  17095. return;
  17096. }
  17097. if (m === !0) return;
  17098. R.matrixWorldAutoUpdate === !0 && R.updateMatrixWorld(),
  17099. $.parent === null && $.matrixWorldAutoUpdate === !0 && $.updateMatrixWorld(),
  17100. _e.enabled === !0 && _e.isPresenting === !0 && (_e.cameraAutoUpdate === !0 && _e.updateCamera($), ($ = _e.getCamera())),
  17101. R.isScene === !0 && R.onBeforeRender(g, R, $, b),
  17102. (d = I.get(R, f.length)),
  17103. d.init(),
  17104. f.push(d),
  17105. N.multiplyMatrices($.projectionMatrix, $.matrixWorldInverse),
  17106. X.setFromProjectionMatrix(N),
  17107. (j = this.localClippingEnabled),
  17108. (z = O.init(this.clippingPlanes, j)),
  17109. (c = dt.get(R, p.length)),
  17110. c.init(),
  17111. p.push(c),
  17112. Xt(R, $, 0, g.sortObjects),
  17113. c.finish(),
  17114. g.sortObjects === !0 && c.sort(P, L),
  17115. z === !0 && O.beginShadows();
  17116. let ae = d.state.shadowsArray;
  17117. if (
  17118. (ie.render(ae, R, $),
  17119. z === !0 && O.endShadows(),
  17120. this.info.autoReset === !0 && this.info.reset(),
  17121. pe.render(c, R),
  17122. d.setupLights(g.physicallyCorrectLights),
  17123. $.isArrayCamera)
  17124. ) {
  17125. let K = $.cameras;
  17126. for (let he = 0, Be = K.length; he < Be; he++) {
  17127. let Je = K[he];
  17128. Ft(c, R, Je, Je.viewport);
  17129. }
  17130. } else Ft(c, R, $);
  17131. b !== null && (oe.updateMultisampleRenderTarget(b), oe.updateRenderTargetMipmap(b)),
  17132. R.isScene === !0 && R.onAfterRender(g, R, $),
  17133. ce.resetDefaultState(),
  17134. (x = -1),
  17135. (w = null),
  17136. f.pop(),
  17137. f.length > 0 ? (d = f[f.length - 1]) : (d = null),
  17138. p.pop(),
  17139. p.length > 0 ? (c = p[p.length - 1]) : (c = null);
  17140. });
  17141. function Xt(R, $, ae, K) {
  17142. if (R.visible === !1) return;
  17143. if (R.layers.test($.layers)) {
  17144. if (R.isGroup) ae = R.renderOrder;
  17145. else if (R.isLOD) R.autoUpdate === !0 && R.update($);
  17146. else if (R.isLight) d.pushLight(R), R.castShadow && d.pushShadow(R);
  17147. else if (R.isSprite) {
  17148. if (!R.frustumCulled || X.intersectsSprite(R)) {
  17149. K && H.setFromMatrixPosition(R.matrixWorld).applyMatrix4(N);
  17150. let Be = we.update(R),
  17151. Je = R.material;
  17152. Je.visible && c.push(R, Be, Je, ae, H.z, null);
  17153. }
  17154. } else if (
  17155. (R.isMesh || R.isLine || R.isPoints) &&
  17156. (R.isSkinnedMesh && R.skeleton.frame !== fe.render.frame && (R.skeleton.update(), (R.skeleton.frame = fe.render.frame)),
  17157. !R.frustumCulled || X.intersectsObject(R))
  17158. ) {
  17159. K && H.setFromMatrixPosition(R.matrixWorld).applyMatrix4(N);
  17160. let Be = we.update(R),
  17161. Je = R.material;
  17162. if (Array.isArray(Je)) {
  17163. let et = Be.groups;
  17164. for (let st = 0, wt = et.length; st < wt; st++) {
  17165. let ut = et[st],
  17166. lt = Je[ut.materialIndex];
  17167. lt && lt.visible && c.push(R, Be, lt, ae, H.z, ut);
  17168. }
  17169. } else Je.visible && c.push(R, Be, Je, ae, H.z, null);
  17170. }
  17171. }
  17172. let he = R.children;
  17173. for (let Be = 0, Je = he.length; Be < Je; Be++) Xt(he[Be], $, ae, K);
  17174. }
  17175. function Ft(R, $, ae, K) {
  17176. let he = R.opaque,
  17177. Be = R.transmissive,
  17178. Je = R.transparent;
  17179. d.setupLightsView(ae),
  17180. z === !0 && O.setGlobalState(g.clippingPlanes, ae),
  17181. Be.length > 0 && kn(he, $, ae),
  17182. K && J.viewport(A.copy(K)),
  17183. he.length > 0 && Dt(he, $, ae),
  17184. Be.length > 0 && Dt(Be, $, ae),
  17185. Je.length > 0 && Dt(Je, $, ae),
  17186. J.buffers.depth.setTest(!0),
  17187. J.buffers.depth.setMask(!0),
  17188. J.buffers.color.setMask(!0),
  17189. J.setPolygonOffset(!1);
  17190. }
  17191. function kn(R, $, ae) {
  17192. let K = ee.isWebGL2;
  17193. U === null &&
  17194. (U = new ii(1, 1, {
  17195. generateMipmaps: !0,
  17196. type: V.has('EXT_color_buffer_half_float') ? lh : Mi,
  17197. minFilter: Bo,
  17198. samples: K && n === !0 ? 4 : 0
  17199. })),
  17200. g.getDrawingBufferSize(B),
  17201. K ? U.setSize(B.x, B.y) : U.setSize(fd(B.x), fd(B.y));
  17202. let he = g.getRenderTarget();
  17203. g.setRenderTarget(U), g.clear();
  17204. let Be = g.toneMapping;
  17205. (g.toneMapping = Gs),
  17206. Dt(R, $, ae),
  17207. (g.toneMapping = Be),
  17208. oe.updateMultisampleRenderTarget(U),
  17209. oe.updateRenderTargetMipmap(U),
  17210. g.setRenderTarget(he);
  17211. }
  17212. function Dt(R, $, ae) {
  17213. let K = $.isScene === !0 ? $.overrideMaterial : null;
  17214. for (let he = 0, Be = R.length; he < Be; he++) {
  17215. let Je = R[he],
  17216. et = Je.object,
  17217. st = Je.geometry,
  17218. wt = K === null ? Je.material : K,
  17219. ut = Je.group;
  17220. et.layers.test(ae.layers) && Ms(et, $, ae, st, wt, ut);
  17221. }
  17222. }
  17223. function Ms(R, $, ae, K, he, Be) {
  17224. R.onBeforeRender(g, $, ae, K, he, Be),
  17225. R.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse, R.matrixWorld),
  17226. R.normalMatrix.getNormalMatrix(R.modelViewMatrix),
  17227. he.onBeforeRender(g, $, ae, K, R, Be),
  17228. he.transparent === !0 && he.side === er && he.forceSinglePass === !1
  17229. ? ((he.side = hi),
  17230. (he.needsUpdate = !0),
  17231. g.renderBufferDirect(ae, $, K, he, R, Be),
  17232. (he.side = Vr),
  17233. (he.needsUpdate = !0),
  17234. g.renderBufferDirect(ae, $, K, he, R, Be),
  17235. (he.side = er))
  17236. : g.renderBufferDirect(ae, $, K, he, R, Be),
  17237. R.onAfterRender(g, $, ae, K, he, Be);
  17238. }
  17239. function lr(R, $, ae) {
  17240. $.isScene !== !0 && ($ = Q);
  17241. let K = re.get(R),
  17242. he = d.state.lights,
  17243. Be = d.state.shadowsArray,
  17244. Je = he.state.version,
  17245. et = Ie.getParameters(R, he.state, Be, $, ae),
  17246. st = Ie.getProgramCacheKey(et),
  17247. wt = K.programs;
  17248. (K.environment = R.isMeshStandardMaterial ? $.environment : null),
  17249. (K.fog = $.fog),
  17250. (K.envMap = (R.isMeshStandardMaterial ? ye : ue).get(R.envMap || K.environment)),
  17251. wt === void 0 && (R.addEventListener('dispose', Mt), (wt = new Map()), (K.programs = wt));
  17252. let ut = wt.get(st);
  17253. if (ut !== void 0) {
  17254. if (K.currentProgram === ut && K.lightsStateVersion === Je) return Qv(R, et), ut;
  17255. } else
  17256. (et.uniforms = Ie.getUniforms(R)),
  17257. R.onBuild(ae, et, g),
  17258. R.onBeforeCompile(et, g),
  17259. (ut = Ie.acquireProgram(et, st)),
  17260. wt.set(st, ut),
  17261. (K.uniforms = et.uniforms);
  17262. let lt = K.uniforms;
  17263. ((!R.isShaderMaterial && !R.isRawShaderMaterial) || R.clipping === !0) && (lt.clippingPlanes = O.uniform),
  17264. Qv(R, et),
  17265. (K.needsLights = R2(R)),
  17266. (K.lightsStateVersion = Je),
  17267. K.needsLights &&
  17268. ((lt.ambientLightColor.value = he.state.ambient),
  17269. (lt.lightProbe.value = he.state.probe),
  17270. (lt.directionalLights.value = he.state.directional),
  17271. (lt.directionalLightShadows.value = he.state.directionalShadow),
  17272. (lt.spotLights.value = he.state.spot),
  17273. (lt.spotLightShadows.value = he.state.spotShadow),
  17274. (lt.rectAreaLights.value = he.state.rectArea),
  17275. (lt.ltc_1.value = he.state.rectAreaLTC1),
  17276. (lt.ltc_2.value = he.state.rectAreaLTC2),
  17277. (lt.pointLights.value = he.state.point),
  17278. (lt.pointLightShadows.value = he.state.pointShadow),
  17279. (lt.hemisphereLights.value = he.state.hemi),
  17280. (lt.directionalShadowMap.value = he.state.directionalShadowMap),
  17281. (lt.directionalShadowMatrix.value = he.state.directionalShadowMatrix),
  17282. (lt.spotShadowMap.value = he.state.spotShadowMap),
  17283. (lt.spotLightMatrix.value = he.state.spotLightMatrix),
  17284. (lt.spotLightMap.value = he.state.spotLightMap),
  17285. (lt.pointShadowMap.value = he.state.pointShadowMap),
  17286. (lt.pointShadowMatrix.value = he.state.pointShadowMatrix));
  17287. let vi = ut.getUniforms(),
  17288. Wi = Jc.seqWithValue(vi.seq, lt);
  17289. return (K.currentProgram = ut), (K.uniformsList = Wi), ut;
  17290. }
  17291. function Qv(R, $) {
  17292. let ae = re.get(R);
  17293. (ae.outputEncoding = $.outputEncoding),
  17294. (ae.instancing = $.instancing),
  17295. (ae.skinning = $.skinning),
  17296. (ae.morphTargets = $.morphTargets),
  17297. (ae.morphNormals = $.morphNormals),
  17298. (ae.morphColors = $.morphColors),
  17299. (ae.morphTargetsCount = $.morphTargetsCount),
  17300. (ae.numClippingPlanes = $.numClippingPlanes),
  17301. (ae.numIntersection = $.numClipIntersection),
  17302. (ae.vertexAlphas = $.vertexAlphas),
  17303. (ae.vertexTangents = $.vertexTangents),
  17304. (ae.toneMapping = $.toneMapping);
  17305. }
  17306. function O2(R, $, ae, K, he) {
  17307. $.isScene !== !0 && ($ = Q), oe.resetTextureUnits();
  17308. let Be = $.fog,
  17309. Je = K.isMeshStandardMaterial ? $.environment : null,
  17310. et = b === null ? g.outputEncoding : b.isXRRenderTarget === !0 ? b.texture.encoding : gs,
  17311. st = (K.isMeshStandardMaterial ? ye : ue).get(K.envMap || Je),
  17312. wt = K.vertexColors === !0 && !!ae.attributes.color && ae.attributes.color.itemSize === 4,
  17313. ut = !!K.normalMap && !!ae.attributes.tangent,
  17314. lt = !!ae.morphAttributes.position,
  17315. vi = !!ae.morphAttributes.normal,
  17316. Wi = !!ae.morphAttributes.color,
  17317. Es = K.toneMapped ? g.toneMapping : Gs,
  17318. jn = ae.morphAttributes.position || ae.morphAttributes.normal || ae.morphAttributes.color,
  17319. qt = jn !== void 0 ? jn.length : 0,
  17320. ht = re.get(K),
  17321. ku = d.state.lights;
  17322. if (z === !0 && (j === !0 || R !== w)) {
  17323. let Xi = R === w && K.id === x;
  17324. O.setState(K, R, Xi);
  17325. }
  17326. let ju = !1;
  17327. K.version === ht.__version
  17328. ? ((ht.needsLights && ht.lightsStateVersion !== ku.state.version) ||
  17329. ht.outputEncoding !== et ||
  17330. (he.isInstancedMesh && ht.instancing === !1) ||
  17331. (!he.isInstancedMesh && ht.instancing === !0) ||
  17332. (he.isSkinnedMesh && ht.skinning === !1) ||
  17333. (!he.isSkinnedMesh && ht.skinning === !0) ||
  17334. ht.envMap !== st ||
  17335. (K.fog === !0 && ht.fog !== Be) ||
  17336. (ht.numClippingPlanes !== void 0 && (ht.numClippingPlanes !== O.numPlanes || ht.numIntersection !== O.numIntersection)) ||
  17337. ht.vertexAlphas !== wt ||
  17338. ht.vertexTangents !== ut ||
  17339. ht.morphTargets !== lt ||
  17340. ht.morphNormals !== vi ||
  17341. ht.morphColors !== Wi ||
  17342. ht.toneMapping !== Es ||
  17343. (ee.isWebGL2 === !0 && ht.morphTargetsCount !== qt)) &&
  17344. (ju = !0)
  17345. : ((ju = !0), (ht.__version = K.version));
  17346. let Gn = ht.currentProgram;
  17347. ju === !0 && (Gn = lr(K, $, he));
  17348. let Zv = !1,
  17349. cl = !1,
  17350. Gu = !1,
  17351. Ei = Gn.getUniforms(),
  17352. Vn = ht.uniforms;
  17353. if ((J.useProgram(Gn.program) && ((Zv = !0), (cl = !0), (Gu = !0)), K.id !== x && ((x = K.id), (cl = !0)), Zv || w !== R)) {
  17354. if (
  17355. (Ei.setValue(F, 'projectionMatrix', R.projectionMatrix),
  17356. ee.logarithmicDepthBuffer && Ei.setValue(F, 'logDepthBufFC', 2 / (Math.log(R.far + 1) / Math.LN2)),
  17357. w !== R && ((w = R), (cl = !0), (Gu = !0)),
  17358. K.isShaderMaterial || K.isMeshPhongMaterial || K.isMeshToonMaterial || K.isMeshStandardMaterial || K.envMap)
  17359. ) {
  17360. let Xi = Ei.map.cameraPosition;
  17361. Xi !== void 0 && Xi.setValue(F, H.setFromMatrixPosition(R.matrixWorld));
  17362. }
  17363. (K.isMeshPhongMaterial ||
  17364. K.isMeshToonMaterial ||
  17365. K.isMeshLambertMaterial ||
  17366. K.isMeshBasicMaterial ||
  17367. K.isMeshStandardMaterial ||
  17368. K.isShaderMaterial) &&
  17369. Ei.setValue(F, 'isOrthographic', R.isOrthographicCamera === !0),
  17370. (K.isMeshPhongMaterial ||
  17371. K.isMeshToonMaterial ||
  17372. K.isMeshLambertMaterial ||
  17373. K.isMeshBasicMaterial ||
  17374. K.isMeshStandardMaterial ||
  17375. K.isShaderMaterial ||
  17376. K.isShadowMaterial ||
  17377. he.isSkinnedMesh) &&
  17378. Ei.setValue(F, 'viewMatrix', R.matrixWorldInverse);
  17379. }
  17380. if (he.isSkinnedMesh) {
  17381. Ei.setOptional(F, he, 'bindMatrix'), Ei.setOptional(F, he, 'bindMatrixInverse');
  17382. let Xi = he.skeleton;
  17383. Xi &&
  17384. (ee.floatVertexTextures
  17385. ? (Xi.boneTexture === null && Xi.computeBoneTexture(),
  17386. Ei.setValue(F, 'boneTexture', Xi.boneTexture, oe),
  17387. Ei.setValue(F, 'boneTextureSize', Xi.boneTextureSize))
  17388. : console.warn(
  17389. 'THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.'
  17390. ));
  17391. }
  17392. let Vu = ae.morphAttributes;
  17393. if (
  17394. ((Vu.position !== void 0 || Vu.normal !== void 0 || (Vu.color !== void 0 && ee.isWebGL2 === !0)) && me.update(he, ae, K, Gn),
  17395. (cl || ht.receiveShadow !== he.receiveShadow) &&
  17396. ((ht.receiveShadow = he.receiveShadow), Ei.setValue(F, 'receiveShadow', he.receiveShadow)),
  17397. K.isMeshGouraudMaterial &&
  17398. K.envMap !== null &&
  17399. ((Vn.envMap.value = st), (Vn.flipEnvMap.value = st.isCubeTexture && st.isRenderTargetTexture === !1 ? -1 : 1)),
  17400. cl &&
  17401. (Ei.setValue(F, 'toneMappingExposure', g.toneMappingExposure),
  17402. ht.needsLights && I2(Vn, Gu),
  17403. Be && K.fog === !0 && He.refreshFogUniforms(Vn, Be),
  17404. He.refreshMaterialUniforms(Vn, K, T, C, U),
  17405. Jc.upload(F, ht.uniformsList, Vn, oe)),
  17406. K.isShaderMaterial && K.uniformsNeedUpdate === !0 && (Jc.upload(F, ht.uniformsList, Vn, oe), (K.uniformsNeedUpdate = !1)),
  17407. K.isSpriteMaterial && Ei.setValue(F, 'center', he.center),
  17408. Ei.setValue(F, 'modelViewMatrix', he.modelViewMatrix),
  17409. Ei.setValue(F, 'normalMatrix', he.normalMatrix),
  17410. Ei.setValue(F, 'modelMatrix', he.matrixWorld),
  17411. K.isShaderMaterial || K.isRawShaderMaterial)
  17412. ) {
  17413. let Xi = K.uniformsGroups;
  17414. for (let Hu = 0, B2 = Xi.length; Hu < B2; Hu++)
  17415. if (ee.isWebGL2) {
  17416. let Kv = Xi[Hu];
  17417. Fe.update(Kv, Gn), Fe.bind(Kv, Gn);
  17418. } else console.warn('THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.');
  17419. }
  17420. return Gn;
  17421. }
  17422. function I2(R, $) {
  17423. (R.ambientLightColor.needsUpdate = $),
  17424. (R.lightProbe.needsUpdate = $),
  17425. (R.directionalLights.needsUpdate = $),
  17426. (R.directionalLightShadows.needsUpdate = $),
  17427. (R.pointLights.needsUpdate = $),
  17428. (R.pointLightShadows.needsUpdate = $),
  17429. (R.spotLights.needsUpdate = $),
  17430. (R.spotLightShadows.needsUpdate = $),
  17431. (R.rectAreaLights.needsUpdate = $),
  17432. (R.hemisphereLights.needsUpdate = $);
  17433. }
  17434. function R2(R) {
  17435. return (
  17436. R.isMeshLambertMaterial ||
  17437. R.isMeshToonMaterial ||
  17438. R.isMeshPhongMaterial ||
  17439. R.isMeshStandardMaterial ||
  17440. R.isShadowMaterial ||
  17441. (R.isShaderMaterial && R.lights === !0)
  17442. );
  17443. }
  17444. (this.getActiveCubeFace = function () {
  17445. return v;
  17446. }),
  17447. (this.getActiveMipmapLevel = function () {
  17448. return y;
  17449. }),
  17450. (this.getRenderTarget = function () {
  17451. return b;
  17452. }),
  17453. (this.setRenderTargetTextures = function (R, $, ae) {
  17454. (re.get(R.texture).__webglTexture = $), (re.get(R.depthTexture).__webglTexture = ae);
  17455. let K = re.get(R);
  17456. (K.__hasExternalTextures = !0),
  17457. K.__hasExternalTextures &&
  17458. ((K.__autoAllocateDepthBuffer = ae === void 0),
  17459. K.__autoAllocateDepthBuffer ||
  17460. (V.has('WEBGL_multisampled_render_to_texture') === !0 &&
  17461. (console.warn('THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided'),
  17462. (K.__useRenderToTexture = !1))));
  17463. }),
  17464. (this.setRenderTargetFramebuffer = function (R, $) {
  17465. let ae = re.get(R);
  17466. (ae.__webglFramebuffer = $), (ae.__useDefaultFramebuffer = $ === void 0);
  17467. }),
  17468. (this.setRenderTarget = function (R, $ = 0, ae = 0) {
  17469. (b = R), (v = $), (y = ae);
  17470. let K = !0,
  17471. he = null,
  17472. Be = !1,
  17473. Je = !1;
  17474. if (R) {
  17475. let et = re.get(R);
  17476. et.__useDefaultFramebuffer !== void 0
  17477. ? (J.bindFramebuffer(36160, null), (K = !1))
  17478. : et.__webglFramebuffer === void 0
  17479. ? oe.setupRenderTarget(R)
  17480. : et.__hasExternalTextures && oe.rebindTextures(R, re.get(R.texture).__webglTexture, re.get(R.depthTexture).__webglTexture);
  17481. let st = R.texture;
  17482. (st.isData3DTexture || st.isDataArrayTexture || st.isCompressedArrayTexture) && (Je = !0);
  17483. let wt = re.get(R).__webglFramebuffer;
  17484. R.isWebGLCubeRenderTarget
  17485. ? ((he = wt[$]), (Be = !0))
  17486. : ee.isWebGL2 && R.samples > 0 && oe.useMultisampledRTT(R) === !1
  17487. ? (he = re.get(R).__webglMultisampledFramebuffer)
  17488. : (he = wt),
  17489. A.copy(R.viewport),
  17490. S.copy(R.scissor),
  17491. (_ = R.scissorTest);
  17492. } else A.copy(D).multiplyScalar(T).floor(), S.copy(k).multiplyScalar(T).floor(), (_ = W);
  17493. if (
  17494. (J.bindFramebuffer(36160, he) && ee.drawBuffers && K && J.drawBuffers(R, he), J.viewport(A), J.scissor(S), J.setScissorTest(_), Be)
  17495. ) {
  17496. let et = re.get(R.texture);
  17497. F.framebufferTexture2D(36160, 36064, 34069 + $, et.__webglTexture, ae);
  17498. } else if (Je) {
  17499. let et = re.get(R.texture),
  17500. st = $ || 0;
  17501. F.framebufferTextureLayer(36160, 36064, et.__webglTexture, ae || 0, st);
  17502. }
  17503. x = -1;
  17504. }),
  17505. (this.readRenderTargetPixels = function (R, $, ae, K, he, Be, Je) {
  17506. if (!(R && R.isWebGLRenderTarget)) {
  17507. console.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.');
  17508. return;
  17509. }
  17510. let et = re.get(R).__webglFramebuffer;
  17511. if ((R.isWebGLCubeRenderTarget && Je !== void 0 && (et = et[Je]), et)) {
  17512. J.bindFramebuffer(36160, et);
  17513. try {
  17514. let st = R.texture,
  17515. wt = st.format,
  17516. ut = st.type;
  17517. if (wt !== Ur && Me.convert(wt) !== F.getParameter(35739)) {
  17518. console.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.');
  17519. return;
  17520. }
  17521. let lt = ut === lh && (V.has('EXT_color_buffer_half_float') || (ee.isWebGL2 && V.has('EXT_color_buffer_float')));
  17522. if (
  17523. ut !== Mi &&
  17524. Me.convert(ut) !== F.getParameter(35738) &&
  17525. !(ut === vn && (ee.isWebGL2 || V.has('OES_texture_float') || V.has('WEBGL_color_buffer_float'))) &&
  17526. !lt
  17527. ) {
  17528. console.error(
  17529. 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.'
  17530. );
  17531. return;
  17532. }
  17533. $ >= 0 && $ <= R.width - K && ae >= 0 && ae <= R.height - he && F.readPixels($, ae, K, he, Me.convert(wt), Me.convert(ut), Be);
  17534. } finally {
  17535. let st = b !== null ? re.get(b).__webglFramebuffer : null;
  17536. J.bindFramebuffer(36160, st);
  17537. }
  17538. }
  17539. }),
  17540. (this.copyFramebufferToTexture = function (R, $, ae = 0) {
  17541. let K = Math.pow(2, -ae),
  17542. he = Math.floor($.image.width * K),
  17543. Be = Math.floor($.image.height * K);
  17544. oe.setTexture2D($, 0), F.copyTexSubImage2D(3553, ae, 0, 0, R.x, R.y, he, Be), J.unbindTexture();
  17545. }),
  17546. (this.copyTextureToTexture = function (R, $, ae, K = 0) {
  17547. let he = $.image.width,
  17548. Be = $.image.height,
  17549. Je = Me.convert(ae.format),
  17550. et = Me.convert(ae.type);
  17551. oe.setTexture2D(ae, 0),
  17552. F.pixelStorei(37440, ae.flipY),
  17553. F.pixelStorei(37441, ae.premultiplyAlpha),
  17554. F.pixelStorei(3317, ae.unpackAlignment),
  17555. $.isDataTexture
  17556. ? F.texSubImage2D(3553, K, R.x, R.y, he, Be, Je, et, $.image.data)
  17557. : $.isCompressedTexture
  17558. ? F.compressedTexSubImage2D(3553, K, R.x, R.y, $.mipmaps[0].width, $.mipmaps[0].height, Je, $.mipmaps[0].data)
  17559. : F.texSubImage2D(3553, K, R.x, R.y, Je, et, $.image),
  17560. K === 0 && ae.generateMipmaps && F.generateMipmap(3553),
  17561. J.unbindTexture();
  17562. }),
  17563. (this.copyTextureToTexture3D = function (R, $, ae, K, he = 0) {
  17564. if (g.isWebGL1Renderer) {
  17565. console.warn('THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.');
  17566. return;
  17567. }
  17568. let Be = R.max.x - R.min.x + 1,
  17569. Je = R.max.y - R.min.y + 1,
  17570. et = R.max.z - R.min.z + 1,
  17571. st = Me.convert(K.format),
  17572. wt = Me.convert(K.type),
  17573. ut;
  17574. if (K.isData3DTexture) oe.setTexture3D(K, 0), (ut = 32879);
  17575. else if (K.isDataArrayTexture) oe.setTexture2DArray(K, 0), (ut = 35866);
  17576. else {
  17577. console.warn('THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.');
  17578. return;
  17579. }
  17580. F.pixelStorei(37440, K.flipY), F.pixelStorei(37441, K.premultiplyAlpha), F.pixelStorei(3317, K.unpackAlignment);
  17581. let lt = F.getParameter(3314),
  17582. vi = F.getParameter(32878),
  17583. Wi = F.getParameter(3316),
  17584. Es = F.getParameter(3315),
  17585. jn = F.getParameter(32877),
  17586. qt = ae.isCompressedTexture ? ae.mipmaps[0] : ae.image;
  17587. F.pixelStorei(3314, qt.width),
  17588. F.pixelStorei(32878, qt.height),
  17589. F.pixelStorei(3316, R.min.x),
  17590. F.pixelStorei(3315, R.min.y),
  17591. F.pixelStorei(32877, R.min.z),
  17592. ae.isDataTexture || ae.isData3DTexture
  17593. ? F.texSubImage3D(ut, he, $.x, $.y, $.z, Be, Je, et, st, wt, qt.data)
  17594. : ae.isCompressedArrayTexture
  17595. ? (console.warn('THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.'),
  17596. F.compressedTexSubImage3D(ut, he, $.x, $.y, $.z, Be, Je, et, st, qt.data))
  17597. : F.texSubImage3D(ut, he, $.x, $.y, $.z, Be, Je, et, st, wt, qt),
  17598. F.pixelStorei(3314, lt),
  17599. F.pixelStorei(32878, vi),
  17600. F.pixelStorei(3316, Wi),
  17601. F.pixelStorei(3315, Es),
  17602. F.pixelStorei(32877, jn),
  17603. he === 0 && K.generateMipmaps && F.generateMipmap(ut),
  17604. J.unbindTexture();
  17605. }),
  17606. (this.initTexture = function (R) {
  17607. R.isCubeTexture
  17608. ? oe.setTextureCube(R, 0)
  17609. : R.isData3DTexture
  17610. ? oe.setTexture3D(R, 0)
  17611. : R.isDataArrayTexture || R.isCompressedArrayTexture
  17612. ? oe.setTexture2DArray(R, 0)
  17613. : oe.setTexture2D(R, 0),
  17614. J.unbindTexture();
  17615. }),
  17616. (this.resetState = function () {
  17617. (v = 0), (y = 0), (b = null), J.reset(), ce.reset();
  17618. }),
  17619. typeof __THREE_DEVTOOLS__ < 'u' && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', { detail: this }));
  17620. }
  17621. var JP = class extends Sw {};
  17622. JP.prototype.isWebGL1Renderer = !0;
  17623. var Mw = class {
  17624. constructor(e, t = 1, i = 1e3) {
  17625. (this.isFog = !0), (this.name = ''), (this.color = new Ge(e)), (this.near = t), (this.far = i);
  17626. }
  17627. clone() {
  17628. return new Mw(this.color, this.near, this.far);
  17629. }
  17630. toJSON() {
  17631. return { type: 'Fog', color: this.color.getHex(), near: this.near, far: this.far };
  17632. }
  17633. },
  17634. pa = class extends bt {
  17635. constructor() {
  17636. super(),
  17637. (this.isScene = !0),
  17638. (this.type = 'Scene'),
  17639. (this.background = null),
  17640. (this.environment = null),
  17641. (this.fog = null),
  17642. (this.backgroundBlurriness = 0),
  17643. (this.backgroundIntensity = 1),
  17644. (this.overrideMaterial = null),
  17645. typeof __THREE_DEVTOOLS__ < 'u' && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', { detail: this }));
  17646. }
  17647. copy(e, t) {
  17648. return (
  17649. super.copy(e, t),
  17650. e.background !== null && (this.background = e.background.clone()),
  17651. e.environment !== null && (this.environment = e.environment.clone()),
  17652. e.fog !== null && (this.fog = e.fog.clone()),
  17653. (this.backgroundBlurriness = e.backgroundBlurriness),
  17654. (this.backgroundIntensity = e.backgroundIntensity),
  17655. e.overrideMaterial !== null && (this.overrideMaterial = e.overrideMaterial.clone()),
  17656. (this.matrixAutoUpdate = e.matrixAutoUpdate),
  17657. this
  17658. );
  17659. }
  17660. toJSON(e) {
  17661. let t = super.toJSON(e);
  17662. return (
  17663. this.fog !== null && (t.object.fog = this.fog.toJSON()),
  17664. this.backgroundBlurriness > 0 && (t.object.backgroundBlurriness = this.backgroundBlurriness),
  17665. this.backgroundIntensity !== 1 && (t.object.backgroundIntensity = this.backgroundIntensity),
  17666. t
  17667. );
  17668. }
  17669. get autoUpdate() {
  17670. return console.warn('THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144.'), this.matrixWorldAutoUpdate;
  17671. }
  17672. set autoUpdate(e) {
  17673. console.warn('THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144.'), (this.matrixWorldAutoUpdate = e);
  17674. }
  17675. },
  17676. $P = class {
  17677. constructor(e, t) {
  17678. (this.isInterleavedBuffer = !0),
  17679. (this.array = e),
  17680. (this.stride = t),
  17681. (this.count = e !== void 0 ? e.length / t : 0),
  17682. (this.usage = Ff),
  17683. (this.updateRange = { offset: 0, count: -1 }),
  17684. (this.version = 0),
  17685. (this.uuid = ps());
  17686. }
  17687. onUploadCallback() {}
  17688. set needsUpdate(e) {
  17689. e === !0 && this.version++;
  17690. }
  17691. setUsage(e) {
  17692. return (this.usage = e), this;
  17693. }
  17694. copy(e) {
  17695. return (
  17696. (this.array = new e.array.constructor(e.array)), (this.count = e.count), (this.stride = e.stride), (this.usage = e.usage), this
  17697. );
  17698. }
  17699. copyAt(e, t, i) {
  17700. (e *= this.stride), (i *= t.stride);
  17701. for (let r = 0, s = this.stride; r < s; r++) this.array[e + r] = t.array[i + r];
  17702. return this;
  17703. }
  17704. set(e, t = 0) {
  17705. return this.array.set(e, t), this;
  17706. }
  17707. clone(e) {
  17708. e.arrayBuffers === void 0 && (e.arrayBuffers = {}),
  17709. this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = ps()),
  17710. e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer);
  17711. let t = new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),
  17712. i = new this.constructor(t, this.stride);
  17713. return i.setUsage(this.usage), i;
  17714. }
  17715. onUpload(e) {
  17716. return (this.onUploadCallback = e), this;
  17717. }
  17718. toJSON(e) {
  17719. return (
  17720. e.arrayBuffers === void 0 && (e.arrayBuffers = {}),
  17721. this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = ps()),
  17722. e.arrayBuffers[this.array.buffer._uuid] === void 0 &&
  17723. (e.arrayBuffers[this.array.buffer._uuid] = Array.from(new Uint32Array(this.array.buffer))),
  17724. { uuid: this.uuid, buffer: this.array.buffer._uuid, type: this.array.constructor.name, stride: this.stride }
  17725. );
  17726. }
  17727. },
  17728. Ti = new E(),
  17729. Vf = class {
  17730. constructor(e, t, i, r = !1) {
  17731. (this.isInterleavedBufferAttribute = !0),
  17732. (this.name = ''),
  17733. (this.data = e),
  17734. (this.itemSize = t),
  17735. (this.offset = i),
  17736. (this.normalized = r);
  17737. }
  17738. get count() {
  17739. return this.data.count;
  17740. }
  17741. get array() {
  17742. return this.data.array;
  17743. }
  17744. set needsUpdate(e) {
  17745. this.data.needsUpdate = e;
  17746. }
  17747. applyMatrix4(e) {
  17748. for (let t = 0, i = this.data.count; t < i; t++)
  17749. Ti.fromBufferAttribute(this, t), Ti.applyMatrix4(e), this.setXYZ(t, Ti.x, Ti.y, Ti.z);
  17750. return this;
  17751. }
  17752. applyNormalMatrix(e) {
  17753. for (let t = 0, i = this.count; t < i; t++)
  17754. Ti.fromBufferAttribute(this, t), Ti.applyNormalMatrix(e), this.setXYZ(t, Ti.x, Ti.y, Ti.z);
  17755. return this;
  17756. }
  17757. transformDirection(e) {
  17758. for (let t = 0, i = this.count; t < i; t++)
  17759. Ti.fromBufferAttribute(this, t), Ti.transformDirection(e), this.setXYZ(t, Ti.x, Ti.y, Ti.z);
  17760. return this;
  17761. }
  17762. setX(e, t) {
  17763. return this.normalized && (t = _t(t, this.array)), (this.data.array[e * this.data.stride + this.offset] = t), this;
  17764. }
  17765. setY(e, t) {
  17766. return this.normalized && (t = _t(t, this.array)), (this.data.array[e * this.data.stride + this.offset + 1] = t), this;
  17767. }
  17768. setZ(e, t) {
  17769. return this.normalized && (t = _t(t, this.array)), (this.data.array[e * this.data.stride + this.offset + 2] = t), this;
  17770. }
  17771. setW(e, t) {
  17772. return this.normalized && (t = _t(t, this.array)), (this.data.array[e * this.data.stride + this.offset + 3] = t), this;
  17773. }
  17774. getX(e) {
  17775. let t = this.data.array[e * this.data.stride + this.offset];
  17776. return this.normalized && (t = ks(t, this.array)), t;
  17777. }
  17778. getY(e) {
  17779. let t = this.data.array[e * this.data.stride + this.offset + 1];
  17780. return this.normalized && (t = ks(t, this.array)), t;
  17781. }
  17782. getZ(e) {
  17783. let t = this.data.array[e * this.data.stride + this.offset + 2];
  17784. return this.normalized && (t = ks(t, this.array)), t;
  17785. }
  17786. getW(e) {
  17787. let t = this.data.array[e * this.data.stride + this.offset + 3];
  17788. return this.normalized && (t = ks(t, this.array)), t;
  17789. }
  17790. setXY(e, t, i) {
  17791. return (
  17792. (e = e * this.data.stride + this.offset),
  17793. this.normalized && ((t = _t(t, this.array)), (i = _t(i, this.array))),
  17794. (this.data.array[e + 0] = t),
  17795. (this.data.array[e + 1] = i),
  17796. this
  17797. );
  17798. }
  17799. setXYZ(e, t, i, r) {
  17800. return (
  17801. (e = e * this.data.stride + this.offset),
  17802. this.normalized && ((t = _t(t, this.array)), (i = _t(i, this.array)), (r = _t(r, this.array))),
  17803. (this.data.array[e + 0] = t),
  17804. (this.data.array[e + 1] = i),
  17805. (this.data.array[e + 2] = r),
  17806. this
  17807. );
  17808. }
  17809. setXYZW(e, t, i, r, s) {
  17810. return (
  17811. (e = e * this.data.stride + this.offset),
  17812. this.normalized && ((t = _t(t, this.array)), (i = _t(i, this.array)), (r = _t(r, this.array)), (s = _t(s, this.array))),
  17813. (this.data.array[e + 0] = t),
  17814. (this.data.array[e + 1] = i),
  17815. (this.data.array[e + 2] = r),
  17816. (this.data.array[e + 3] = s),
  17817. this
  17818. );
  17819. }
  17820. clone(e) {
  17821. if (e === void 0) {
  17822. console.log('THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.');
  17823. let t = [];
  17824. for (let i = 0; i < this.count; i++) {
  17825. let r = i * this.data.stride + this.offset;
  17826. for (let s = 0; s < this.itemSize; s++) t.push(this.data.array[r + s]);
  17827. }
  17828. return new Xe(new this.array.constructor(t), this.itemSize, this.normalized);
  17829. } else
  17830. return (
  17831. e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}),
  17832. e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.clone(e)),
  17833. new Vf(e.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized)
  17834. );
  17835. }
  17836. toJSON(e) {
  17837. if (e === void 0) {
  17838. console.log(
  17839. 'THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.'
  17840. );
  17841. let t = [];
  17842. for (let i = 0; i < this.count; i++) {
  17843. let r = i * this.data.stride + this.offset;
  17844. for (let s = 0; s < this.itemSize; s++) t.push(this.data.array[r + s]);
  17845. }
  17846. return { itemSize: this.itemSize, type: this.array.constructor.name, array: t, normalized: this.normalized };
  17847. } else
  17848. return (
  17849. e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}),
  17850. e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.toJSON(e)),
  17851. {
  17852. isInterleavedBufferAttribute: !0,
  17853. itemSize: this.itemSize,
  17854. data: this.data.uuid,
  17855. offset: this.offset,
  17856. normalized: this.normalized
  17857. }
  17858. );
  17859. }
  17860. },
  17861. eD = class extends Xe {
  17862. constructor(e, t, i, r = 1) {
  17863. super(e, t, i), (this.isInstancedBufferAttribute = !0), (this.meshPerAttribute = r);
  17864. }
  17865. copy(e) {
  17866. return super.copy(e), (this.meshPerAttribute = e.meshPerAttribute), this;
  17867. }
  17868. toJSON() {
  17869. let e = super.toJSON();
  17870. return (e.meshPerAttribute = this.meshPerAttribute), (e.isInstancedBufferAttribute = !0), e;
  17871. }
  17872. },
  17873. Rn = class extends Th {
  17874. constructor(e) {
  17875. super(),
  17876. (this.isLineBasicMaterial = !0),
  17877. (this.type = 'LineBasicMaterial'),
  17878. (this.color = new Ge(16777215)),
  17879. (this.linewidth = 1),
  17880. (this.linecap = 'round'),
  17881. (this.linejoin = 'round'),
  17882. (this.fog = !0),
  17883. this.setValues(e);
  17884. }
  17885. copy(e) {
  17886. return (
  17887. super.copy(e),
  17888. this.color.copy(e.color),
  17889. (this.linewidth = e.linewidth),
  17890. (this.linecap = e.linecap),
  17891. (this.linejoin = e.linejoin),
  17892. (this.fog = e.fog),
  17893. this
  17894. );
  17895. }
  17896. },
  17897. dy = new E(),
  17898. uy = new E(),
  17899. py = new ve(),
  17900. Ap = new Xo(),
  17901. cc = new Mr(),
  17902. vd = class extends bt {
  17903. constructor(e = new Ve(), t = new Rn()) {
  17904. super(), (this.isLine = !0), (this.type = 'Line'), (this.geometry = e), (this.material = t), this.updateMorphTargets();
  17905. }
  17906. copy(e, t) {
  17907. return super.copy(e, t), (this.material = e.material), (this.geometry = e.geometry), this;
  17908. }
  17909. computeLineDistances() {
  17910. let e = this.geometry;
  17911. if (e.index === null) {
  17912. let t = e.attributes.position,
  17913. i = [0];
  17914. for (let r = 1, s = t.count; r < s; r++)
  17915. dy.fromBufferAttribute(t, r - 1), uy.fromBufferAttribute(t, r), (i[r] = i[r - 1]), (i[r] += dy.distanceTo(uy));
  17916. e.setAttribute('lineDistance', new Ce(i, 1));
  17917. } else console.warn('THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.');
  17918. return this;
  17919. }
  17920. raycast(e, t) {
  17921. let i = this.geometry,
  17922. r = this.matrixWorld,
  17923. s = e.params.Line.threshold,
  17924. n = i.drawRange;
  17925. if (
  17926. (i.boundingSphere === null && i.computeBoundingSphere(),
  17927. cc.copy(i.boundingSphere),
  17928. cc.applyMatrix4(r),
  17929. (cc.radius += s),
  17930. e.ray.intersectsSphere(cc) === !1)
  17931. )
  17932. return;
  17933. py.copy(r).invert(), Ap.copy(e.ray).applyMatrix4(py);
  17934. let a = s / ((this.scale.x + this.scale.y + this.scale.z) / 3),
  17935. o = a * a,
  17936. l = new E(),
  17937. h = new E(),
  17938. u = new E(),
  17939. c = new E(),
  17940. d = this.isLineSegments ? 2 : 1,
  17941. p = i.index,
  17942. f = i.attributes.position;
  17943. if (p !== null) {
  17944. let g = Math.max(0, n.start),
  17945. m = Math.min(p.count, n.start + n.count);
  17946. for (let v = g, y = m - 1; v < y; v += d) {
  17947. let b = p.getX(v),
  17948. x = p.getX(v + 1);
  17949. if ((l.fromBufferAttribute(f, b), h.fromBufferAttribute(f, x), Ap.distanceSqToSegment(l, h, c, u) > o)) continue;
  17950. c.applyMatrix4(this.matrixWorld);
  17951. let w = e.ray.origin.distanceTo(c);
  17952. w < e.near ||
  17953. w > e.far ||
  17954. t.push({ distance: w, point: u.clone().applyMatrix4(this.matrixWorld), index: v, face: null, faceIndex: null, object: this });
  17955. }
  17956. } else {
  17957. let g = Math.max(0, n.start),
  17958. m = Math.min(f.count, n.start + n.count);
  17959. for (let v = g, y = m - 1; v < y; v += d) {
  17960. if ((l.fromBufferAttribute(f, v), h.fromBufferAttribute(f, v + 1), Ap.distanceSqToSegment(l, h, c, u) > o)) continue;
  17961. c.applyMatrix4(this.matrixWorld);
  17962. let b = e.ray.origin.distanceTo(c);
  17963. b < e.near ||
  17964. b > e.far ||
  17965. t.push({ distance: b, point: u.clone().applyMatrix4(this.matrixWorld), index: v, face: null, faceIndex: null, object: this });
  17966. }
  17967. }
  17968. }
  17969. updateMorphTargets() {
  17970. let e = this.geometry.morphAttributes,
  17971. t = Object.keys(e);
  17972. if (t.length > 0) {
  17973. let i = e[t[0]];
  17974. if (i !== void 0) {
  17975. (this.morphTargetInfluences = []), (this.morphTargetDictionary = {});
  17976. for (let r = 0, s = i.length; r < s; r++) {
  17977. let n = i[r].name || String(r);
  17978. this.morphTargetInfluences.push(0), (this.morphTargetDictionary[n] = r);
  17979. }
  17980. }
  17981. }
  17982. }
  17983. },
  17984. fy = new E(),
  17985. my = new E(),
  17986. Dh = class extends vd {
  17987. constructor(e, t) {
  17988. super(e, t), (this.isLineSegments = !0), (this.type = 'LineSegments');
  17989. }
  17990. computeLineDistances() {
  17991. let e = this.geometry;
  17992. if (e.index === null) {
  17993. let t = e.attributes.position,
  17994. i = [];
  17995. for (let r = 0, s = t.count; r < s; r += 2)
  17996. fy.fromBufferAttribute(t, r),
  17997. my.fromBufferAttribute(t, r + 1),
  17998. (i[r] = r === 0 ? 0 : i[r - 1]),
  17999. (i[r + 1] = i[r] + fy.distanceTo(my));
  18000. e.setAttribute('lineDistance', new Ce(i, 1));
  18001. } else console.warn('THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.');
  18002. return this;
  18003. }
  18004. },
  18005. tD = class extends ci {
  18006. constructor(e, t, i, r, s, n, a, o, l) {
  18007. super(e, t, i, r, s, n, a, o, l),
  18008. (this.isVideoTexture = !0),
  18009. (this.minFilter = n !== void 0 ? n : mt),
  18010. (this.magFilter = s !== void 0 ? s : mt),
  18011. (this.generateMipmaps = !1);
  18012. let h = this;
  18013. function u() {
  18014. (h.needsUpdate = !0), e.requestVideoFrameCallback(u);
  18015. }
  18016. 'requestVideoFrameCallback' in e && e.requestVideoFrameCallback(u);
  18017. }
  18018. clone() {
  18019. return new this.constructor(this.image).copy(this);
  18020. }
  18021. update() {
  18022. let e = this.image;
  18023. !('requestVideoFrameCallback' in e) && e.readyState >= e.HAVE_CURRENT_DATA && (this.needsUpdate = !0);
  18024. }
  18025. },
  18026. _s = class {
  18027. constructor() {
  18028. (this.type = 'Curve'), (this.arcLengthDivisions = 200);
  18029. }
  18030. getPoint() {
  18031. return console.warn('THREE.Curve: .getPoint() not implemented.'), null;
  18032. }
  18033. getPointAt(e, t) {
  18034. let i = this.getUtoTmapping(e);
  18035. return this.getPoint(i, t);
  18036. }
  18037. getPoints(e = 5) {
  18038. let t = [];
  18039. for (let i = 0; i <= e; i++) t.push(this.getPoint(i / e));
  18040. return t;
  18041. }
  18042. getSpacedPoints(e = 5) {
  18043. let t = [];
  18044. for (let i = 0; i <= e; i++) t.push(this.getPointAt(i / e));
  18045. return t;
  18046. }
  18047. getLength() {
  18048. let e = this.getLengths();
  18049. return e[e.length - 1];
  18050. }
  18051. getLengths(e = this.arcLengthDivisions) {
  18052. if (this.cacheArcLengths && this.cacheArcLengths.length === e + 1 && !this.needsUpdate) return this.cacheArcLengths;
  18053. this.needsUpdate = !1;
  18054. let t = [],
  18055. i,
  18056. r = this.getPoint(0),
  18057. s = 0;
  18058. t.push(0);
  18059. for (let n = 1; n <= e; n++) (i = this.getPoint(n / e)), (s += i.distanceTo(r)), t.push(s), (r = i);
  18060. return (this.cacheArcLengths = t), t;
  18061. }
  18062. updateArcLengths() {
  18063. (this.needsUpdate = !0), this.getLengths();
  18064. }
  18065. getUtoTmapping(e, t) {
  18066. let i = this.getLengths(),
  18067. r = 0,
  18068. s = i.length,
  18069. n;
  18070. t ? (n = t) : (n = e * i[s - 1]);
  18071. let a = 0,
  18072. o = s - 1,
  18073. l;
  18074. for (; a <= o; )
  18075. if (((r = Math.floor(a + (o - a) / 2)), (l = i[r] - n), l < 0)) a = r + 1;
  18076. else if (l > 0) o = r - 1;
  18077. else {
  18078. o = r;
  18079. break;
  18080. }
  18081. if (((r = o), i[r] === n)) return r / (s - 1);
  18082. let h = i[r],
  18083. u = i[r + 1] - h,
  18084. c = (n - h) / u;
  18085. return (r + c) / (s - 1);
  18086. }
  18087. getTangent(e, t) {
  18088. let i = e - 1e-4,
  18089. r = e + 1e-4;
  18090. i < 0 && (i = 0), r > 1 && (r = 1);
  18091. let s = this.getPoint(i),
  18092. n = this.getPoint(r),
  18093. a = t || (s.isVector2 ? new G() : new E());
  18094. return a.copy(n).sub(s).normalize(), a;
  18095. }
  18096. getTangentAt(e, t) {
  18097. let i = this.getUtoTmapping(e);
  18098. return this.getTangent(i, t);
  18099. }
  18100. computeFrenetFrames(e, t) {
  18101. let i = new E(),
  18102. r = [],
  18103. s = [],
  18104. n = [],
  18105. a = new E(),
  18106. o = new ve();
  18107. for (let d = 0; d <= e; d++) {
  18108. let p = d / e;
  18109. r[d] = this.getTangentAt(p, new E());
  18110. }
  18111. (s[0] = new E()), (n[0] = new E());
  18112. let l = Number.MAX_VALUE,
  18113. h = Math.abs(r[0].x),
  18114. u = Math.abs(r[0].y),
  18115. c = Math.abs(r[0].z);
  18116. h <= l && ((l = h), i.set(1, 0, 0)),
  18117. u <= l && ((l = u), i.set(0, 1, 0)),
  18118. c <= l && i.set(0, 0, 1),
  18119. a.crossVectors(r[0], i).normalize(),
  18120. s[0].crossVectors(r[0], a),
  18121. n[0].crossVectors(r[0], s[0]);
  18122. for (let d = 1; d <= e; d++) {
  18123. if (((s[d] = s[d - 1].clone()), (n[d] = n[d - 1].clone()), a.crossVectors(r[d - 1], r[d]), a.length() > Number.EPSILON)) {
  18124. a.normalize();
  18125. let p = Math.acos(ti(r[d - 1].dot(r[d]), -1, 1));
  18126. s[d].applyMatrix4(o.makeRotationAxis(a, p));
  18127. }
  18128. n[d].crossVectors(r[d], s[d]);
  18129. }
  18130. if (t === !0) {
  18131. let d = Math.acos(ti(s[0].dot(s[e]), -1, 1));
  18132. (d /= e), r[0].dot(a.crossVectors(s[0], s[e])) > 0 && (d = -d);
  18133. for (let p = 1; p <= e; p++) s[p].applyMatrix4(o.makeRotationAxis(r[p], d * p)), n[p].crossVectors(r[p], s[p]);
  18134. }
  18135. return { tangents: r, normals: s, binormals: n };
  18136. }
  18137. clone() {
  18138. return new this.constructor().copy(this);
  18139. }
  18140. copy(e) {
  18141. return (this.arcLengthDivisions = e.arcLengthDivisions), this;
  18142. }
  18143. toJSON() {
  18144. let e = { metadata: { version: 4.5, type: 'Curve', generator: 'Curve.toJSON' } };
  18145. return (e.arcLengthDivisions = this.arcLengthDivisions), (e.type = this.type), e;
  18146. }
  18147. fromJSON(e) {
  18148. return (this.arcLengthDivisions = e.arcLengthDivisions), this;
  18149. }
  18150. },
  18151. hu = class extends _s {
  18152. constructor(e = 0, t = 0, i = 1, r = 1, s = 0, n = Math.PI * 2, a = !1, o = 0) {
  18153. super(),
  18154. (this.isEllipseCurve = !0),
  18155. (this.type = 'EllipseCurve'),
  18156. (this.aX = e),
  18157. (this.aY = t),
  18158. (this.xRadius = i),
  18159. (this.yRadius = r),
  18160. (this.aStartAngle = s),
  18161. (this.aEndAngle = n),
  18162. (this.aClockwise = a),
  18163. (this.aRotation = o);
  18164. }
  18165. getPoint(e, t) {
  18166. let i = t || new G(),
  18167. r = Math.PI * 2,
  18168. s = this.aEndAngle - this.aStartAngle,
  18169. n = Math.abs(s) < Number.EPSILON;
  18170. for (; s < 0; ) s += r;
  18171. for (; s > r; ) s -= r;
  18172. s < Number.EPSILON && (n ? (s = 0) : (s = r)), this.aClockwise === !0 && !n && (s === r ? (s = -r) : (s = s - r));
  18173. let a = this.aStartAngle + e * s,
  18174. o = this.aX + this.xRadius * Math.cos(a),
  18175. l = this.aY + this.yRadius * Math.sin(a);
  18176. if (this.aRotation !== 0) {
  18177. let h = Math.cos(this.aRotation),
  18178. u = Math.sin(this.aRotation),
  18179. c = o - this.aX,
  18180. d = l - this.aY;
  18181. (o = c * h - d * u + this.aX), (l = c * u + d * h + this.aY);
  18182. }
  18183. return i.set(o, l);
  18184. }
  18185. copy(e) {
  18186. return (
  18187. super.copy(e),
  18188. (this.aX = e.aX),
  18189. (this.aY = e.aY),
  18190. (this.xRadius = e.xRadius),
  18191. (this.yRadius = e.yRadius),
  18192. (this.aStartAngle = e.aStartAngle),
  18193. (this.aEndAngle = e.aEndAngle),
  18194. (this.aClockwise = e.aClockwise),
  18195. (this.aRotation = e.aRotation),
  18196. this
  18197. );
  18198. }
  18199. toJSON() {
  18200. let e = super.toJSON();
  18201. return (
  18202. (e.aX = this.aX),
  18203. (e.aY = this.aY),
  18204. (e.xRadius = this.xRadius),
  18205. (e.yRadius = this.yRadius),
  18206. (e.aStartAngle = this.aStartAngle),
  18207. (e.aEndAngle = this.aEndAngle),
  18208. (e.aClockwise = this.aClockwise),
  18209. (e.aRotation = this.aRotation),
  18210. e
  18211. );
  18212. }
  18213. fromJSON(e) {
  18214. return (
  18215. super.fromJSON(e),
  18216. (this.aX = e.aX),
  18217. (this.aY = e.aY),
  18218. (this.xRadius = e.xRadius),
  18219. (this.yRadius = e.yRadius),
  18220. (this.aStartAngle = e.aStartAngle),
  18221. (this.aEndAngle = e.aEndAngle),
  18222. (this.aClockwise = e.aClockwise),
  18223. (this.aRotation = e.aRotation),
  18224. this
  18225. );
  18226. }
  18227. },
  18228. iD = class extends hu {
  18229. constructor(e, t, i, r, s, n) {
  18230. super(e, t, i, i, r, s, n), (this.isArcCurve = !0), (this.type = 'ArcCurve');
  18231. }
  18232. };
  18233. function fg() {
  18234. let e = 0,
  18235. t = 0,
  18236. i = 0,
  18237. r = 0;
  18238. function s(n, a, o, l) {
  18239. (e = n), (t = o), (i = -3 * n + 3 * a - 2 * o - l), (r = 2 * n - 2 * a + o + l);
  18240. }
  18241. return {
  18242. initCatmullRom: function (n, a, o, l, h) {
  18243. s(a, o, h * (o - n), h * (l - a));
  18244. },
  18245. initNonuniformCatmullRom: function (n, a, o, l, h, u, c) {
  18246. let d = (a - n) / h - (o - n) / (h + u) + (o - a) / u,
  18247. p = (o - a) / u - (l - a) / (u + c) + (l - o) / c;
  18248. (d *= u), (p *= u), s(a, o, d, p);
  18249. },
  18250. calc: function (n) {
  18251. let a = n * n,
  18252. o = a * n;
  18253. return e + t * n + i * a + r * o;
  18254. }
  18255. };
  18256. }
  18257. var dc = new E(),
  18258. Sp = new fg(),
  18259. Mp = new fg(),
  18260. Ep = new fg(),
  18261. rD = class extends _s {
  18262. constructor(e = [], t = !1, i = 'centripetal', r = 0.5) {
  18263. super(),
  18264. (this.isCatmullRomCurve3 = !0),
  18265. (this.type = 'CatmullRomCurve3'),
  18266. (this.points = e),
  18267. (this.closed = t),
  18268. (this.curveType = i),
  18269. (this.tension = r);
  18270. }
  18271. getPoint(e, t = new E()) {
  18272. let i = t,
  18273. r = this.points,
  18274. s = r.length,
  18275. n = (s - (this.closed ? 0 : 1)) * e,
  18276. a = Math.floor(n),
  18277. o = n - a;
  18278. this.closed ? (a += a > 0 ? 0 : (Math.floor(Math.abs(a) / s) + 1) * s) : o === 0 && a === s - 1 && ((a = s - 2), (o = 1));
  18279. let l, h;
  18280. this.closed || a > 0 ? (l = r[(a - 1) % s]) : (dc.subVectors(r[0], r[1]).add(r[0]), (l = dc));
  18281. let u = r[a % s],
  18282. c = r[(a + 1) % s];
  18283. if (
  18284. (this.closed || a + 2 < s ? (h = r[(a + 2) % s]) : (dc.subVectors(r[s - 1], r[s - 2]).add(r[s - 1]), (h = dc)),
  18285. this.curveType === 'centripetal' || this.curveType === 'chordal')
  18286. ) {
  18287. let d = this.curveType === 'chordal' ? 0.5 : 0.25,
  18288. p = Math.pow(l.distanceToSquared(u), d),
  18289. f = Math.pow(u.distanceToSquared(c), d),
  18290. g = Math.pow(c.distanceToSquared(h), d);
  18291. f < 1e-4 && (f = 1),
  18292. p < 1e-4 && (p = f),
  18293. g < 1e-4 && (g = f),
  18294. Sp.initNonuniformCatmullRom(l.x, u.x, c.x, h.x, p, f, g),
  18295. Mp.initNonuniformCatmullRom(l.y, u.y, c.y, h.y, p, f, g),
  18296. Ep.initNonuniformCatmullRom(l.z, u.z, c.z, h.z, p, f, g);
  18297. } else
  18298. this.curveType === 'catmullrom' &&
  18299. (Sp.initCatmullRom(l.x, u.x, c.x, h.x, this.tension),
  18300. Mp.initCatmullRom(l.y, u.y, c.y, h.y, this.tension),
  18301. Ep.initCatmullRom(l.z, u.z, c.z, h.z, this.tension));
  18302. return i.set(Sp.calc(o), Mp.calc(o), Ep.calc(o)), i;
  18303. }
  18304. copy(e) {
  18305. super.copy(e), (this.points = []);
  18306. for (let t = 0, i = e.points.length; t < i; t++) {
  18307. let r = e.points[t];
  18308. this.points.push(r.clone());
  18309. }
  18310. return (this.closed = e.closed), (this.curveType = e.curveType), (this.tension = e.tension), this;
  18311. }
  18312. toJSON() {
  18313. let e = super.toJSON();
  18314. e.points = [];
  18315. for (let t = 0, i = this.points.length; t < i; t++) {
  18316. let r = this.points[t];
  18317. e.points.push(r.toArray());
  18318. }
  18319. return (e.closed = this.closed), (e.curveType = this.curveType), (e.tension = this.tension), e;
  18320. }
  18321. fromJSON(e) {
  18322. super.fromJSON(e), (this.points = []);
  18323. for (let t = 0, i = e.points.length; t < i; t++) {
  18324. let r = e.points[t];
  18325. this.points.push(new E().fromArray(r));
  18326. }
  18327. return (this.closed = e.closed), (this.curveType = e.curveType), (this.tension = e.tension), this;
  18328. }
  18329. };
  18330. function gy(e, t, i, r, s) {
  18331. let n = (r - t) * 0.5,
  18332. a = (s - i) * 0.5,
  18333. o = e * e,
  18334. l = e * o;
  18335. return (2 * i - 2 * r + n + a) * l + (-3 * i + 3 * r - 2 * n - a) * o + n * e + i;
  18336. }
  18337. function sD(e, t) {
  18338. let i = 1 - e;
  18339. return i * i * t;
  18340. }
  18341. function nD(e, t) {
  18342. return 2 * (1 - e) * e * t;
  18343. }
  18344. function aD(e, t) {
  18345. return e * e * t;
  18346. }
  18347. function Jl(e, t, i, r) {
  18348. return sD(e, t) + nD(e, i) + aD(e, r);
  18349. }
  18350. function oD(e, t) {
  18351. let i = 1 - e;
  18352. return i * i * i * t;
  18353. }
  18354. function lD(e, t) {
  18355. let i = 1 - e;
  18356. return 3 * i * i * e * t;
  18357. }
  18358. function hD(e, t) {
  18359. return 3 * (1 - e) * e * e * t;
  18360. }
  18361. function cD(e, t) {
  18362. return e * e * e * t;
  18363. }
  18364. function $l(e, t, i, r, s) {
  18365. return oD(e, t) + lD(e, i) + hD(e, r) + cD(e, s);
  18366. }
  18367. var Fr = class extends _s {
  18368. constructor(e = new G(), t = new G(), i = new G(), r = new G()) {
  18369. super(), (this.isCubicBezierCurve = !0), (this.type = 'CubicBezierCurve'), (this.v0 = e), (this.v1 = t), (this.v2 = i), (this.v3 = r);
  18370. }
  18371. getPoint(e, t = new G()) {
  18372. let i = t,
  18373. r = this.v0,
  18374. s = this.v1,
  18375. n = this.v2,
  18376. a = this.v3;
  18377. return i.set($l(e, r.x, s.x, n.x, a.x), $l(e, r.y, s.y, n.y, a.y)), i;
  18378. }
  18379. copy(e) {
  18380. 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;
  18381. }
  18382. toJSON() {
  18383. let e = super.toJSON();
  18384. return (e.v0 = this.v0.toArray()), (e.v1 = this.v1.toArray()), (e.v2 = this.v2.toArray()), (e.v3 = this.v3.toArray()), e;
  18385. }
  18386. fromJSON(e) {
  18387. 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;
  18388. }
  18389. },
  18390. $c = class extends _s {
  18391. constructor(e = new E(), t = new E(), i = new E(), r = new E()) {
  18392. super(),
  18393. (this.isCubicBezierCurve3 = !0),
  18394. (this.type = 'CubicBezierCurve3'),
  18395. (this.v0 = e),
  18396. (this.v1 = t),
  18397. (this.v2 = i),
  18398. (this.v3 = r);
  18399. }
  18400. getPoint(e, t = new E()) {
  18401. let i = t,
  18402. r = this.v0,
  18403. s = this.v1,
  18404. n = this.v2,
  18405. a = this.v3;
  18406. return i.set($l(e, r.x, s.x, n.x, a.x), $l(e, r.y, s.y, n.y, a.y), $l(e, r.z, s.z, n.z, a.z)), i;
  18407. }
  18408. copy(e) {
  18409. 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;
  18410. }
  18411. toJSON() {
  18412. let e = super.toJSON();
  18413. return (e.v0 = this.v0.toArray()), (e.v1 = this.v1.toArray()), (e.v2 = this.v2.toArray()), (e.v3 = this.v3.toArray()), e;
  18414. }
  18415. fromJSON(e) {
  18416. 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;
  18417. }
  18418. },
  18419. Gr = class extends _s {
  18420. constructor(e = new G(), t = new G()) {
  18421. super(), (this.isLineCurve = !0), (this.type = 'LineCurve'), (this.v1 = e), (this.v2 = t);
  18422. }
  18423. getPoint(e, t = new G()) {
  18424. let i = t;
  18425. return e === 1 ? i.copy(this.v2) : (i.copy(this.v2).sub(this.v1), i.multiplyScalar(e).add(this.v1)), i;
  18426. }
  18427. getPointAt(e, t) {
  18428. return this.getPoint(e, t);
  18429. }
  18430. getTangent(e, t) {
  18431. let i = t || new G();
  18432. return i.copy(this.v2).sub(this.v1).normalize(), i;
  18433. }
  18434. copy(e) {
  18435. return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this;
  18436. }
  18437. toJSON() {
  18438. let e = super.toJSON();
  18439. return (e.v1 = this.v1.toArray()), (e.v2 = this.v2.toArray()), e;
  18440. }
  18441. fromJSON(e) {
  18442. return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this;
  18443. }
  18444. },
  18445. Ew = class extends _s {
  18446. constructor(e = new E(), t = new E()) {
  18447. super(), (this.isLineCurve3 = !0), (this.type = 'LineCurve3'), (this.v1 = e), (this.v2 = t);
  18448. }
  18449. getPoint(e, t = new E()) {
  18450. let i = t;
  18451. return e === 1 ? i.copy(this.v2) : (i.copy(this.v2).sub(this.v1), i.multiplyScalar(e).add(this.v1)), i;
  18452. }
  18453. getPointAt(e, t) {
  18454. return this.getPoint(e, t);
  18455. }
  18456. copy(e) {
  18457. return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this;
  18458. }
  18459. toJSON() {
  18460. let e = super.toJSON();
  18461. return (e.v1 = this.v1.toArray()), (e.v2 = this.v2.toArray()), e;
  18462. }
  18463. fromJSON(e) {
  18464. return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this;
  18465. }
  18466. },
  18467. Pn = class extends _s {
  18468. constructor(e = new G(), t = new G(), i = new G()) {
  18469. super(), (this.isQuadraticBezierCurve = !0), (this.type = 'QuadraticBezierCurve'), (this.v0 = e), (this.v1 = t), (this.v2 = i);
  18470. }
  18471. getPoint(e, t = new G()) {
  18472. let i = t,
  18473. r = this.v0,
  18474. s = this.v1,
  18475. n = this.v2;
  18476. return i.set(Jl(e, r.x, s.x, n.x), Jl(e, r.y, s.y, n.y)), i;
  18477. }
  18478. copy(e) {
  18479. return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this;
  18480. }
  18481. toJSON() {
  18482. let e = super.toJSON();
  18483. return (e.v0 = this.v0.toArray()), (e.v1 = this.v1.toArray()), (e.v2 = this.v2.toArray()), e;
  18484. }
  18485. fromJSON(e) {
  18486. return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this;
  18487. }
  18488. },
  18489. dD = class extends _s {
  18490. constructor(e = new E(), t = new E(), i = new E()) {
  18491. super(), (this.isQuadraticBezierCurve3 = !0), (this.type = 'QuadraticBezierCurve3'), (this.v0 = e), (this.v1 = t), (this.v2 = i);
  18492. }
  18493. getPoint(e, t = new E()) {
  18494. let i = t,
  18495. r = this.v0,
  18496. s = this.v1,
  18497. n = this.v2;
  18498. return i.set(Jl(e, r.x, s.x, n.x), Jl(e, r.y, s.y, n.y), Jl(e, r.z, s.z, n.z)), i;
  18499. }
  18500. copy(e) {
  18501. return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this;
  18502. }
  18503. toJSON() {
  18504. let e = super.toJSON();
  18505. return (e.v0 = this.v0.toArray()), (e.v1 = this.v1.toArray()), (e.v2 = this.v2.toArray()), e;
  18506. }
  18507. fromJSON(e) {
  18508. return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this;
  18509. }
  18510. },
  18511. mg = class extends _s {
  18512. constructor(e = []) {
  18513. super(), (this.isSplineCurve = !0), (this.type = 'SplineCurve'), (this.points = e);
  18514. }
  18515. getPoint(e, t = new G()) {
  18516. let i = t,
  18517. r = this.points,
  18518. s = (r.length - 1) * e,
  18519. n = Math.floor(s),
  18520. a = s - n,
  18521. o = r[n === 0 ? n : n - 1],
  18522. l = r[n],
  18523. h = r[n > r.length - 2 ? r.length - 1 : n + 1],
  18524. u = r[n > r.length - 3 ? r.length - 1 : n + 2];
  18525. return i.set(gy(a, o.x, l.x, h.x, u.x), gy(a, o.y, l.y, h.y, u.y)), i;
  18526. }
  18527. copy(e) {
  18528. super.copy(e), (this.points = []);
  18529. for (let t = 0, i = e.points.length; t < i; t++) {
  18530. let r = e.points[t];
  18531. this.points.push(r.clone());
  18532. }
  18533. return this;
  18534. }
  18535. toJSON() {
  18536. let e = super.toJSON();
  18537. e.points = [];
  18538. for (let t = 0, i = this.points.length; t < i; t++) {
  18539. let r = this.points[t];
  18540. e.points.push(r.toArray());
  18541. }
  18542. return e;
  18543. }
  18544. fromJSON(e) {
  18545. super.fromJSON(e), (this.points = []);
  18546. for (let t = 0, i = e.points.length; t < i; t++) {
  18547. let r = e.points[t];
  18548. this.points.push(new G().fromArray(r));
  18549. }
  18550. return this;
  18551. }
  18552. },
  18553. uD = Object.freeze({
  18554. __proto__: null,
  18555. ArcCurve: iD,
  18556. CatmullRomCurve3: rD,
  18557. CubicBezierCurve: Fr,
  18558. CubicBezierCurve3: $c,
  18559. EllipseCurve: hu,
  18560. LineCurve: Gr,
  18561. LineCurve3: Ew,
  18562. QuadraticBezierCurve: Pn,
  18563. QuadraticBezierCurve3: dD,
  18564. SplineCurve: mg
  18565. }),
  18566. Cw = class extends _s {
  18567. constructor() {
  18568. super(), (this.type = 'CurvePath'), (this.curves = []), (this.autoClose = !1);
  18569. }
  18570. add(e) {
  18571. this.curves.push(e);
  18572. }
  18573. closePath() {
  18574. let e = this.curves[0].getPoint(0),
  18575. t = this.curves[this.curves.length - 1].getPoint(1);
  18576. e.equals(t) || this.curves.push(new Gr(t, e));
  18577. }
  18578. getPoint(e, t) {
  18579. let i = e * this.getLength(),
  18580. r = this.getCurveLengths(),
  18581. s = 0;
  18582. for (; s < r.length; ) {
  18583. if (r[s] >= i) {
  18584. let n = r[s] - i,
  18585. a = this.curves[s],
  18586. o = a.getLength(),
  18587. l = o === 0 ? 0 : 1 - n / o;
  18588. return a.getPointAt(l, t);
  18589. }
  18590. s++;
  18591. }
  18592. return null;
  18593. }
  18594. getLength() {
  18595. let e = this.getCurveLengths();
  18596. return e[e.length - 1];
  18597. }
  18598. updateArcLengths() {
  18599. (this.needsUpdate = !0), (this.cacheLengths = null), this.getCurveLengths();
  18600. }
  18601. getCurveLengths() {
  18602. if (this.cacheLengths && this.cacheLengths.length === this.curves.length) return this.cacheLengths;
  18603. let e = [],
  18604. t = 0;
  18605. for (let i = 0, r = this.curves.length; i < r; i++) (t += this.curves[i].getLength()), e.push(t);
  18606. return (this.cacheLengths = e), e;
  18607. }
  18608. getSpacedPoints(e = 40) {
  18609. let t = [];
  18610. for (let i = 0; i <= e; i++) t.push(this.getPoint(i / e));
  18611. return this.autoClose && t.push(t[0]), t;
  18612. }
  18613. getPoints(e = 12) {
  18614. let t = [],
  18615. i;
  18616. for (let r = 0, s = this.curves; r < s.length; r++) {
  18617. let n = s[r],
  18618. a = n.isEllipseCurve ? e * 2 : n.isLineCurve || n.isLineCurve3 ? 1 : n.isSplineCurve ? e * n.points.length : e,
  18619. o = n.getPoints(a);
  18620. for (let l = 0; l < o.length; l++) {
  18621. let h = o[l];
  18622. (i && i.equals(h)) || (t.push(h), (i = h));
  18623. }
  18624. }
  18625. return this.autoClose && t.length > 1 && !t[t.length - 1].equals(t[0]) && t.push(t[0]), t;
  18626. }
  18627. copy(e) {
  18628. super.copy(e), (this.curves = []);
  18629. for (let t = 0, i = e.curves.length; t < i; t++) {
  18630. let r = e.curves[t];
  18631. this.curves.push(r.clone());
  18632. }
  18633. return (this.autoClose = e.autoClose), this;
  18634. }
  18635. toJSON() {
  18636. let e = super.toJSON();
  18637. (e.autoClose = this.autoClose), (e.curves = []);
  18638. for (let t = 0, i = this.curves.length; t < i; t++) {
  18639. let r = this.curves[t];
  18640. e.curves.push(r.toJSON());
  18641. }
  18642. return e;
  18643. }
  18644. fromJSON(e) {
  18645. super.fromJSON(e), (this.autoClose = e.autoClose), (this.curves = []);
  18646. for (let t = 0, i = e.curves.length; t < i; t++) {
  18647. let r = e.curves[t];
  18648. this.curves.push(new uD[r.type]().fromJSON(r));
  18649. }
  18650. return this;
  18651. }
  18652. },
  18653. yd = class extends Cw {
  18654. constructor(e) {
  18655. super(), (this.type = 'Path'), (this.currentPoint = new G()), e && this.setFromPoints(e);
  18656. }
  18657. setFromPoints(e) {
  18658. this.moveTo(e[0].x, e[0].y);
  18659. for (let t = 1, i = e.length; t < i; t++) this.lineTo(e[t].x, e[t].y);
  18660. return this;
  18661. }
  18662. moveTo(e, t) {
  18663. return this.currentPoint.set(e, t), this;
  18664. }
  18665. lineTo(e, t) {
  18666. let i = new Gr(this.currentPoint.clone(), new G(e, t));
  18667. return this.curves.push(i), this.currentPoint.set(e, t), this;
  18668. }
  18669. quadraticCurveTo(e, t, i, r) {
  18670. let s = new Pn(this.currentPoint.clone(), new G(e, t), new G(i, r));
  18671. return this.curves.push(s), this.currentPoint.set(i, r), this;
  18672. }
  18673. bezierCurveTo(e, t, i, r, s, n) {
  18674. let a = new Fr(this.currentPoint.clone(), new G(e, t), new G(i, r), new G(s, n));
  18675. return this.curves.push(a), this.currentPoint.set(s, n), this;
  18676. }
  18677. splineThru(e) {
  18678. let t = [this.currentPoint.clone()].concat(e),
  18679. i = new mg(t);
  18680. return this.curves.push(i), this.currentPoint.copy(e[e.length - 1]), this;
  18681. }
  18682. arc(e, t, i, r, s, n) {
  18683. let a = this.currentPoint.x,
  18684. o = this.currentPoint.y;
  18685. return this.absarc(e + a, t + o, i, r, s, n), this;
  18686. }
  18687. absarc(e, t, i, r, s, n) {
  18688. return this.absellipse(e, t, i, i, r, s, n), this;
  18689. }
  18690. ellipse(e, t, i, r, s, n, a, o) {
  18691. let l = this.currentPoint.x,
  18692. h = this.currentPoint.y;
  18693. return this.absellipse(e + l, t + h, i, r, s, n, a, o), this;
  18694. }
  18695. absellipse(e, t, i, r, s, n, a, o) {
  18696. let l = new hu(e, t, i, r, s, n, a, o);
  18697. if (this.curves.length > 0) {
  18698. let u = l.getPoint(0);
  18699. u.equals(this.currentPoint) || this.lineTo(u.x, u.y);
  18700. }
  18701. this.curves.push(l);
  18702. let h = l.getPoint(1);
  18703. return this.currentPoint.copy(h), this;
  18704. }
  18705. copy(e) {
  18706. return super.copy(e), this.currentPoint.copy(e.currentPoint), this;
  18707. }
  18708. toJSON() {
  18709. let e = super.toJSON();
  18710. return (e.currentPoint = this.currentPoint.toArray()), e;
  18711. }
  18712. fromJSON(e) {
  18713. return super.fromJSON(e), this.currentPoint.fromArray(e.currentPoint), this;
  18714. }
  18715. },
  18716. Tw = class extends Ve {
  18717. constructor(e = [new G(0, -0.5), new G(0.5, 0), new G(0, 0.5)], t = 12, i = 0, r = Math.PI * 2) {
  18718. super(),
  18719. (this.type = 'LatheGeometry'),
  18720. (this.parameters = { points: e, segments: t, phiStart: i, phiLength: r }),
  18721. (t = Math.floor(t)),
  18722. (r = ti(r, 0, Math.PI * 2));
  18723. let s = [],
  18724. n = [],
  18725. a = [],
  18726. o = [],
  18727. l = [],
  18728. h = 1 / t,
  18729. u = new E(),
  18730. c = new G(),
  18731. d = new E(),
  18732. p = new E(),
  18733. f = new E(),
  18734. g = 0,
  18735. m = 0;
  18736. for (let v = 0; v <= e.length - 1; v++)
  18737. switch (v) {
  18738. case 0:
  18739. (g = e[v + 1].x - e[v].x),
  18740. (m = e[v + 1].y - e[v].y),
  18741. (d.x = m * 1),
  18742. (d.y = -g),
  18743. (d.z = m * 0),
  18744. f.copy(d),
  18745. d.normalize(),
  18746. o.push(d.x, d.y, d.z);
  18747. break;
  18748. case e.length - 1:
  18749. o.push(f.x, f.y, f.z);
  18750. break;
  18751. default:
  18752. (g = e[v + 1].x - e[v].x),
  18753. (m = e[v + 1].y - e[v].y),
  18754. (d.x = m * 1),
  18755. (d.y = -g),
  18756. (d.z = m * 0),
  18757. p.copy(d),
  18758. (d.x += f.x),
  18759. (d.y += f.y),
  18760. (d.z += f.z),
  18761. d.normalize(),
  18762. o.push(d.x, d.y, d.z),
  18763. f.copy(p);
  18764. }
  18765. for (let v = 0; v <= t; v++) {
  18766. let y = i + v * h * r,
  18767. b = Math.sin(y),
  18768. x = Math.cos(y);
  18769. for (let w = 0; w <= e.length - 1; w++) {
  18770. (u.x = e[w].x * b),
  18771. (u.y = e[w].y),
  18772. (u.z = e[w].x * x),
  18773. n.push(u.x, u.y, u.z),
  18774. (c.x = v / t),
  18775. (c.y = w / (e.length - 1)),
  18776. a.push(c.x, c.y);
  18777. let A = o[3 * w + 0] * b,
  18778. S = o[3 * w + 1],
  18779. _ = o[3 * w + 0] * x;
  18780. l.push(A, S, _);
  18781. }
  18782. }
  18783. for (let v = 0; v < t; v++)
  18784. for (let y = 0; y < e.length - 1; y++) {
  18785. let b = y + v * e.length,
  18786. x = b,
  18787. w = b + e.length,
  18788. A = b + e.length + 1,
  18789. S = b + 1;
  18790. s.push(x, w, S), s.push(A, S, w);
  18791. }
  18792. this.setIndex(s),
  18793. this.setAttribute('position', new Ce(n, 3)),
  18794. this.setAttribute('uv', new Ce(a, 2)),
  18795. this.setAttribute('normal', new Ce(l, 3));
  18796. }
  18797. static fromJSON(e) {
  18798. return new Tw(e.points, e.segments, e.phiStart, e.phiLength);
  18799. }
  18800. },
  18801. gg = class extends Ve {
  18802. constructor(e = 1, t = 1, i = 1, r = 32, s = 1, n = !1, a = 0, o = Math.PI * 2) {
  18803. super(),
  18804. (this.type = 'CylinderGeometry'),
  18805. (this.parameters = {
  18806. radiusTop: e,
  18807. radiusBottom: t,
  18808. height: i,
  18809. radialSegments: r,
  18810. heightSegments: s,
  18811. openEnded: n,
  18812. thetaStart: a,
  18813. thetaLength: o
  18814. });
  18815. let l = this;
  18816. (r = Math.floor(r)), (s = Math.floor(s));
  18817. let h = [],
  18818. u = [],
  18819. c = [],
  18820. d = [],
  18821. p = 0,
  18822. f = [],
  18823. g = i / 2,
  18824. m = 0;
  18825. v(),
  18826. n === !1 && (e > 0 && y(!0), t > 0 && y(!1)),
  18827. this.setIndex(h),
  18828. this.setAttribute('position', new Ce(u, 3)),
  18829. this.setAttribute('normal', new Ce(c, 3)),
  18830. this.setAttribute('uv', new Ce(d, 2));
  18831. function v() {
  18832. let b = new E(),
  18833. x = new E(),
  18834. w = 0,
  18835. A = (t - e) / i;
  18836. for (let S = 0; S <= s; S++) {
  18837. let _ = [],
  18838. M = S / s,
  18839. C = M * (t - e) + e;
  18840. for (let T = 0; T <= r; T++) {
  18841. let P = T / r,
  18842. L = P * o + a,
  18843. D = Math.sin(L),
  18844. k = Math.cos(L);
  18845. (x.x = C * D),
  18846. (x.y = -M * i + g),
  18847. (x.z = C * k),
  18848. u.push(x.x, x.y, x.z),
  18849. b.set(D, A, k).normalize(),
  18850. c.push(b.x, b.y, b.z),
  18851. d.push(P, 1 - M),
  18852. _.push(p++);
  18853. }
  18854. f.push(_);
  18855. }
  18856. for (let S = 0; S < r; S++)
  18857. for (let _ = 0; _ < s; _++) {
  18858. let M = f[_][S],
  18859. C = f[_ + 1][S],
  18860. T = f[_ + 1][S + 1],
  18861. P = f[_][S + 1];
  18862. h.push(M, C, P), h.push(C, T, P), (w += 6);
  18863. }
  18864. l.addGroup(m, w, 0), (m += w);
  18865. }
  18866. function y(b) {
  18867. let x = p,
  18868. w = new G(),
  18869. A = new E(),
  18870. S = 0,
  18871. _ = b === !0 ? e : t,
  18872. M = b === !0 ? 1 : -1;
  18873. for (let T = 1; T <= r; T++) u.push(0, g * M, 0), c.push(0, M, 0), d.push(0.5, 0.5), p++;
  18874. let C = p;
  18875. for (let T = 0; T <= r; T++) {
  18876. let P = (T / r) * o + a,
  18877. L = Math.cos(P),
  18878. D = Math.sin(P);
  18879. (A.x = _ * D),
  18880. (A.y = g * M),
  18881. (A.z = _ * L),
  18882. u.push(A.x, A.y, A.z),
  18883. c.push(0, M, 0),
  18884. (w.x = L * 0.5 + 0.5),
  18885. (w.y = D * 0.5 * M + 0.5),
  18886. d.push(w.x, w.y),
  18887. p++;
  18888. }
  18889. for (let T = 0; T < r; T++) {
  18890. let P = x + T,
  18891. L = C + T;
  18892. b === !0 ? h.push(L, L + 1, P) : h.push(L + 1, L, P), (S += 3);
  18893. }
  18894. l.addGroup(m, S, b === !0 ? 1 : 2), (m += S);
  18895. }
  18896. }
  18897. static fromJSON(e) {
  18898. return new gg(e.radiusTop, e.radiusBottom, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength);
  18899. }
  18900. },
  18901. Pw = class extends gg {
  18902. constructor(e = 1, t = 1, i = 32, r = 1, s = !1, n = 0, a = Math.PI * 2) {
  18903. super(0, e, t, i, r, s, n, a),
  18904. (this.type = 'ConeGeometry'),
  18905. (this.parameters = { radius: e, height: t, radialSegments: i, heightSegments: r, openEnded: s, thetaStart: n, thetaLength: a });
  18906. }
  18907. static fromJSON(e) {
  18908. return new Pw(e.radius, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength);
  18909. }
  18910. },
  18911. vg = class extends Ve {
  18912. constructor(e = [], t = [], i = 1, r = 0) {
  18913. super(), (this.type = 'PolyhedronGeometry'), (this.parameters = { vertices: e, indices: t, radius: i, detail: r });
  18914. let s = [],
  18915. n = [];
  18916. a(r),
  18917. l(i),
  18918. h(),
  18919. this.setAttribute('position', new Ce(s, 3)),
  18920. this.setAttribute('normal', new Ce(s.slice(), 3)),
  18921. this.setAttribute('uv', new Ce(n, 2)),
  18922. r === 0 ? this.computeVertexNormals() : this.normalizeNormals();
  18923. function a(v) {
  18924. let y = new E(),
  18925. b = new E(),
  18926. x = new E();
  18927. for (let w = 0; w < t.length; w += 3) d(t[w + 0], y), d(t[w + 1], b), d(t[w + 2], x), o(y, b, x, v);
  18928. }
  18929. function o(v, y, b, x) {
  18930. let w = x + 1,
  18931. A = [];
  18932. for (let S = 0; S <= w; S++) {
  18933. A[S] = [];
  18934. let _ = v.clone().lerp(b, S / w),
  18935. M = y.clone().lerp(b, S / w),
  18936. C = w - S;
  18937. for (let T = 0; T <= C; T++) T === 0 && S === w ? (A[S][T] = _) : (A[S][T] = _.clone().lerp(M, T / C));
  18938. }
  18939. for (let S = 0; S < w; S++)
  18940. for (let _ = 0; _ < 2 * (w - S) - 1; _++) {
  18941. let M = Math.floor(_ / 2);
  18942. _ % 2 === 0 ? (c(A[S][M + 1]), c(A[S + 1][M]), c(A[S][M])) : (c(A[S][M + 1]), c(A[S + 1][M + 1]), c(A[S + 1][M]));
  18943. }
  18944. }
  18945. function l(v) {
  18946. let y = new E();
  18947. for (let b = 0; b < s.length; b += 3)
  18948. (y.x = s[b + 0]),
  18949. (y.y = s[b + 1]),
  18950. (y.z = s[b + 2]),
  18951. y.normalize().multiplyScalar(v),
  18952. (s[b + 0] = y.x),
  18953. (s[b + 1] = y.y),
  18954. (s[b + 2] = y.z);
  18955. }
  18956. function h() {
  18957. let v = new E();
  18958. for (let y = 0; y < s.length; y += 3) {
  18959. (v.x = s[y + 0]), (v.y = s[y + 1]), (v.z = s[y + 2]);
  18960. let b = g(v) / 2 / Math.PI + 0.5,
  18961. x = m(v) / Math.PI + 0.5;
  18962. n.push(b, 1 - x);
  18963. }
  18964. p(), u();
  18965. }
  18966. function u() {
  18967. for (let v = 0; v < n.length; v += 6) {
  18968. let y = n[v + 0],
  18969. b = n[v + 2],
  18970. x = n[v + 4],
  18971. w = Math.max(y, b, x),
  18972. A = Math.min(y, b, x);
  18973. w > 0.9 && A < 0.1 && (y < 0.2 && (n[v + 0] += 1), b < 0.2 && (n[v + 2] += 1), x < 0.2 && (n[v + 4] += 1));
  18974. }
  18975. }
  18976. function c(v) {
  18977. s.push(v.x, v.y, v.z);
  18978. }
  18979. function d(v, y) {
  18980. let b = v * 3;
  18981. (y.x = e[b + 0]), (y.y = e[b + 1]), (y.z = e[b + 2]);
  18982. }
  18983. function p() {
  18984. let v = new E(),
  18985. y = new E(),
  18986. b = new E(),
  18987. x = new E(),
  18988. w = new G(),
  18989. A = new G(),
  18990. S = new G();
  18991. for (let _ = 0, M = 0; _ < s.length; _ += 9, M += 6) {
  18992. v.set(s[_ + 0], s[_ + 1], s[_ + 2]),
  18993. y.set(s[_ + 3], s[_ + 4], s[_ + 5]),
  18994. b.set(s[_ + 6], s[_ + 7], s[_ + 8]),
  18995. w.set(n[M + 0], n[M + 1]),
  18996. A.set(n[M + 2], n[M + 3]),
  18997. S.set(n[M + 4], n[M + 5]),
  18998. x.copy(v).add(y).add(b).divideScalar(3);
  18999. let C = g(x);
  19000. f(w, M + 0, v, C), f(A, M + 2, y, C), f(S, M + 4, b, C);
  19001. }
  19002. }
  19003. function f(v, y, b, x) {
  19004. x < 0 && v.x === 1 && (n[y] = v.x - 1), b.x === 0 && b.z === 0 && (n[y] = x / 2 / Math.PI + 0.5);
  19005. }
  19006. function g(v) {
  19007. return Math.atan2(v.z, -v.x);
  19008. }
  19009. function m(v) {
  19010. return Math.atan2(-v.y, Math.sqrt(v.x * v.x + v.z * v.z));
  19011. }
  19012. }
  19013. static fromJSON(e) {
  19014. return new vg(e.vertices, e.indices, e.radius, e.details);
  19015. }
  19016. },
  19017. Dw = class extends vg {
  19018. constructor(e = 1, t = 0) {
  19019. let i = (1 + Math.sqrt(5)) / 2,
  19020. r = 1 / i,
  19021. s = [
  19022. -1,
  19023. -1,
  19024. -1,
  19025. -1,
  19026. -1,
  19027. 1,
  19028. -1,
  19029. 1,
  19030. -1,
  19031. -1,
  19032. 1,
  19033. 1,
  19034. 1,
  19035. -1,
  19036. -1,
  19037. 1,
  19038. -1,
  19039. 1,
  19040. 1,
  19041. 1,
  19042. -1,
  19043. 1,
  19044. 1,
  19045. 1,
  19046. 0,
  19047. -r,
  19048. -i,
  19049. 0,
  19050. -r,
  19051. i,
  19052. 0,
  19053. r,
  19054. -i,
  19055. 0,
  19056. r,
  19057. i,
  19058. -r,
  19059. -i,
  19060. 0,
  19061. -r,
  19062. i,
  19063. 0,
  19064. r,
  19065. -i,
  19066. 0,
  19067. r,
  19068. i,
  19069. 0,
  19070. -i,
  19071. 0,
  19072. -r,
  19073. i,
  19074. 0,
  19075. -r,
  19076. -i,
  19077. 0,
  19078. r,
  19079. i,
  19080. 0,
  19081. r
  19082. ],
  19083. n = [
  19084. 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,
  19085. 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,
  19086. 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
  19087. ];
  19088. super(s, n, e, t), (this.type = 'DodecahedronGeometry'), (this.parameters = { radius: e, detail: t });
  19089. }
  19090. static fromJSON(e) {
  19091. return new Dw(e.radius, e.detail);
  19092. }
  19093. },
  19094. xd = class extends yd {
  19095. constructor(e) {
  19096. super(e), (this.uuid = ps()), (this.type = 'Shape'), (this.holes = []);
  19097. }
  19098. getPointsHoles(e) {
  19099. let t = [];
  19100. for (let i = 0, r = this.holes.length; i < r; i++) t[i] = this.holes[i].getPoints(e);
  19101. return t;
  19102. }
  19103. extractPoints(e) {
  19104. return { shape: this.getPoints(e), holes: this.getPointsHoles(e) };
  19105. }
  19106. copy(e) {
  19107. super.copy(e), (this.holes = []);
  19108. for (let t = 0, i = e.holes.length; t < i; t++) {
  19109. let r = e.holes[t];
  19110. this.holes.push(r.clone());
  19111. }
  19112. return this;
  19113. }
  19114. toJSON() {
  19115. let e = super.toJSON();
  19116. (e.uuid = this.uuid), (e.holes = []);
  19117. for (let t = 0, i = this.holes.length; t < i; t++) {
  19118. let r = this.holes[t];
  19119. e.holes.push(r.toJSON());
  19120. }
  19121. return e;
  19122. }
  19123. fromJSON(e) {
  19124. super.fromJSON(e), (this.uuid = e.uuid), (this.holes = []);
  19125. for (let t = 0, i = e.holes.length; t < i; t++) {
  19126. let r = e.holes[t];
  19127. this.holes.push(new yd().fromJSON(r));
  19128. }
  19129. return this;
  19130. }
  19131. },
  19132. pD = {
  19133. triangulate: function (e, t, i = 2) {
  19134. let r = t && t.length,
  19135. s = r ? t[0] * i : e.length,
  19136. n = Lw(e, 0, s, i, !0),
  19137. a = [];
  19138. if (!n || n.next === n.prev) return a;
  19139. let o, l, h, u, c, d, p;
  19140. if ((r && (n = yD(e, t, n, i)), e.length > 80 * i)) {
  19141. (o = h = e[0]), (l = u = e[1]);
  19142. for (let f = i; f < s; f += i) (c = e[f]), (d = e[f + 1]), c < o && (o = c), d < l && (l = d), c > h && (h = c), d > u && (u = d);
  19143. (p = Math.max(h - o, u - l)), (p = p !== 0 ? 32767 / p : 0);
  19144. }
  19145. return ch(n, a, i, o, l, p, 0), a;
  19146. }
  19147. };
  19148. function Lw(e, t, i, r, s) {
  19149. let n, a;
  19150. if (s === PD(e, t, i, r) > 0) for (n = t; n < i; n += r) a = vy(n, e[n], e[n + 1], a);
  19151. else for (n = i - r; n >= t; n -= r) a = vy(n, e[n], e[n + 1], a);
  19152. return a && cu(a, a.next) && (uh(a), (a = a.next)), a;
  19153. }
  19154. function wa(e, t) {
  19155. if (!e) return e;
  19156. t || (t = e);
  19157. let i = e,
  19158. r;
  19159. do {
  19160. if (((r = !1), !i.steiner && (cu(i, i.next) || It(i.prev, i, i.next) === 0))) {
  19161. if ((uh(i), (i = t = i.prev), i === i.next)) break;
  19162. r = !0;
  19163. } else i = i.next;
  19164. } while (r || i !== t);
  19165. return t;
  19166. }
  19167. function ch(e, t, i, r, s, n, a) {
  19168. if (!e) return;
  19169. !a && n && AD(e, r, s, n);
  19170. let o = e,
  19171. l,
  19172. h;
  19173. for (; e.prev !== e.next; ) {
  19174. if (((l = e.prev), (h = e.next), n ? mD(e, r, s, n) : fD(e))) {
  19175. t.push((l.i / i) | 0), t.push((e.i / i) | 0), t.push((h.i / i) | 0), uh(e), (e = h.next), (o = h.next);
  19176. continue;
  19177. }
  19178. if (((e = h), e === o)) {
  19179. a ? (a === 1 ? ((e = gD(wa(e), t, i)), ch(e, t, i, r, s, n, 2)) : a === 2 && vD(e, t, i, r, s, n)) : ch(wa(e), t, i, r, s, n, 1);
  19180. break;
  19181. }
  19182. }
  19183. }
  19184. function fD(e) {
  19185. let t = e.prev,
  19186. i = e,
  19187. r = e.next;
  19188. if (It(t, i, r) >= 0) return !1;
  19189. let s = t.x,
  19190. n = i.x,
  19191. a = r.x,
  19192. o = t.y,
  19193. l = i.y,
  19194. h = r.y,
  19195. u = s < n ? (s < a ? s : a) : n < a ? n : a,
  19196. c = o < l ? (o < h ? o : h) : l < h ? l : h,
  19197. d = s > n ? (s > a ? s : a) : n > a ? n : a,
  19198. p = o > l ? (o > h ? o : h) : l > h ? l : h,
  19199. f = r.next;
  19200. for (; f !== t; ) {
  19201. if (f.x >= u && f.x <= d && f.y >= c && f.y <= p && fo(s, o, n, l, a, h, f.x, f.y) && It(f.prev, f, f.next) >= 0) return !1;
  19202. f = f.next;
  19203. }
  19204. return !0;
  19205. }
  19206. function mD(e, t, i, r) {
  19207. let s = e.prev,
  19208. n = e,
  19209. a = e.next;
  19210. if (It(s, n, a) >= 0) return !1;
  19211. let o = s.x,
  19212. l = n.x,
  19213. h = a.x,
  19214. u = s.y,
  19215. c = n.y,
  19216. d = a.y,
  19217. p = o < l ? (o < h ? o : h) : l < h ? l : h,
  19218. f = u < c ? (u < d ? u : d) : c < d ? c : d,
  19219. g = o > l ? (o > h ? o : h) : l > h ? l : h,
  19220. m = u > c ? (u > d ? u : d) : c > d ? c : d,
  19221. v = Hf(p, f, t, i, r),
  19222. y = Hf(g, m, t, i, r),
  19223. b = e.prevZ,
  19224. x = e.nextZ;
  19225. for (; b && b.z >= v && x && x.z <= y; ) {
  19226. if (
  19227. (b.x >= p &&
  19228. b.x <= g &&
  19229. b.y >= f &&
  19230. b.y <= m &&
  19231. b !== s &&
  19232. b !== a &&
  19233. fo(o, u, l, c, h, d, b.x, b.y) &&
  19234. It(b.prev, b, b.next) >= 0) ||
  19235. ((b = b.prevZ),
  19236. x.x >= p && x.x <= g && x.y >= f && x.y <= m && x !== s && x !== a && fo(o, u, l, c, h, d, x.x, x.y) && It(x.prev, x, x.next) >= 0)
  19237. )
  19238. return !1;
  19239. x = x.nextZ;
  19240. }
  19241. for (; b && b.z >= v; ) {
  19242. if (b.x >= p && b.x <= g && b.y >= f && b.y <= m && b !== s && b !== a && fo(o, u, l, c, h, d, b.x, b.y) && It(b.prev, b, b.next) >= 0)
  19243. return !1;
  19244. b = b.prevZ;
  19245. }
  19246. for (; x && x.z <= y; ) {
  19247. if (x.x >= p && x.x <= g && x.y >= f && x.y <= m && x !== s && x !== a && fo(o, u, l, c, h, d, x.x, x.y) && It(x.prev, x, x.next) >= 0)
  19248. return !1;
  19249. x = x.nextZ;
  19250. }
  19251. return !0;
  19252. }
  19253. function gD(e, t, i) {
  19254. let r = e;
  19255. do {
  19256. let s = r.prev,
  19257. n = r.next.next;
  19258. !cu(s, n) &&
  19259. Ow(s, r, r.next, n) &&
  19260. dh(s, n) &&
  19261. dh(n, s) &&
  19262. (t.push((s.i / i) | 0), t.push((r.i / i) | 0), t.push((n.i / i) | 0), uh(r), uh(r.next), (r = e = n)),
  19263. (r = r.next);
  19264. } while (r !== e);
  19265. return wa(r);
  19266. }
  19267. function vD(e, t, i, r, s, n) {
  19268. let a = e;
  19269. do {
  19270. let o = a.next.next;
  19271. for (; o !== a.prev; ) {
  19272. if (a.i !== o.i && ED(a, o)) {
  19273. let l = Iw(a, o);
  19274. (a = wa(a, a.next)), (l = wa(l, l.next)), ch(a, t, i, r, s, n, 0), ch(l, t, i, r, s, n, 0);
  19275. return;
  19276. }
  19277. o = o.next;
  19278. }
  19279. a = a.next;
  19280. } while (a !== e);
  19281. }
  19282. function yD(e, t, i, r) {
  19283. let s = [],
  19284. n,
  19285. a,
  19286. o,
  19287. l,
  19288. h;
  19289. for (n = 0, a = t.length; n < a; n++)
  19290. (o = t[n] * r), (l = n < a - 1 ? t[n + 1] * r : e.length), (h = Lw(e, o, l, r, !1)), h === h.next && (h.steiner = !0), s.push(MD(h));
  19291. for (s.sort(xD), n = 0; n < s.length; n++) i = bD(s[n], i);
  19292. return i;
  19293. }
  19294. function xD(e, t) {
  19295. return e.x - t.x;
  19296. }
  19297. function bD(e, t) {
  19298. let i = wD(e, t);
  19299. if (!i) return t;
  19300. let r = Iw(i, e);
  19301. return wa(r, r.next), wa(i, i.next);
  19302. }
  19303. function wD(e, t) {
  19304. let i = t,
  19305. r = -1 / 0,
  19306. s,
  19307. n = e.x,
  19308. a = e.y;
  19309. do {
  19310. if (a <= i.y && a >= i.next.y && i.next.y !== i.y) {
  19311. let d = i.x + ((a - i.y) * (i.next.x - i.x)) / (i.next.y - i.y);
  19312. if (d <= n && d > r && ((r = d), (s = i.x < i.next.x ? i : i.next), d === n)) return s;
  19313. }
  19314. i = i.next;
  19315. } while (i !== t);
  19316. if (!s) return null;
  19317. let o = s,
  19318. l = s.x,
  19319. h = s.y,
  19320. u = 1 / 0,
  19321. c;
  19322. i = s;
  19323. do {
  19324. n >= i.x &&
  19325. i.x >= l &&
  19326. n !== i.x &&
  19327. fo(a < h ? n : r, a, l, h, a < h ? r : n, a, i.x, i.y) &&
  19328. ((c = Math.abs(a - i.y) / (n - i.x)),
  19329. dh(i, e) && (c < u || (c === u && (i.x > s.x || (i.x === s.x && _D(s, i))))) && ((s = i), (u = c))),
  19330. (i = i.next);
  19331. } while (i !== o);
  19332. return s;
  19333. }
  19334. function _D(e, t) {
  19335. return It(e.prev, e, t.prev) < 0 && It(t.next, e, e.next) < 0;
  19336. }
  19337. function AD(e, t, i, r) {
  19338. let s = e;
  19339. do {
  19340. s.z === 0 && (s.z = Hf(s.x, s.y, t, i, r)), (s.prevZ = s.prev), (s.nextZ = s.next), (s = s.next);
  19341. } while (s !== e);
  19342. (s.prevZ.nextZ = null), (s.prevZ = null), SD(s);
  19343. }
  19344. function SD(e) {
  19345. let t,
  19346. i,
  19347. r,
  19348. s,
  19349. n,
  19350. a,
  19351. o,
  19352. l,
  19353. h = 1;
  19354. do {
  19355. for (i = e, e = null, n = null, a = 0; i; ) {
  19356. for (a++, r = i, o = 0, t = 0; t < h && (o++, (r = r.nextZ), !!r); t++);
  19357. for (l = h; o > 0 || (l > 0 && r); )
  19358. o !== 0 && (l === 0 || !r || i.z <= r.z) ? ((s = i), (i = i.nextZ), o--) : ((s = r), (r = r.nextZ), l--),
  19359. n ? (n.nextZ = s) : (e = s),
  19360. (s.prevZ = n),
  19361. (n = s);
  19362. i = r;
  19363. }
  19364. (n.nextZ = null), (h *= 2);
  19365. } while (a > 1);
  19366. return e;
  19367. }
  19368. function Hf(e, t, i, r, s) {
  19369. return (
  19370. (e = ((e - i) * s) | 0),
  19371. (t = ((t - r) * s) | 0),
  19372. (e = (e | (e << 8)) & 16711935),
  19373. (e = (e | (e << 4)) & 252645135),
  19374. (e = (e | (e << 2)) & 858993459),
  19375. (e = (e | (e << 1)) & 1431655765),
  19376. (t = (t | (t << 8)) & 16711935),
  19377. (t = (t | (t << 4)) & 252645135),
  19378. (t = (t | (t << 2)) & 858993459),
  19379. (t = (t | (t << 1)) & 1431655765),
  19380. e | (t << 1)
  19381. );
  19382. }
  19383. function MD(e) {
  19384. let t = e,
  19385. i = e;
  19386. do {
  19387. (t.x < i.x || (t.x === i.x && t.y < i.y)) && (i = t), (t = t.next);
  19388. } while (t !== e);
  19389. return i;
  19390. }
  19391. function fo(e, t, i, r, s, n, a, o) {
  19392. return (s - a) * (t - o) >= (e - a) * (n - o) && (e - a) * (r - o) >= (i - a) * (t - o) && (i - a) * (n - o) >= (s - a) * (r - o);
  19393. }
  19394. function ED(e, t) {
  19395. return (
  19396. e.next.i !== t.i &&
  19397. e.prev.i !== t.i &&
  19398. !CD(e, t) &&
  19399. ((dh(e, t) && dh(t, e) && TD(e, t) && (It(e.prev, e, t.prev) || It(e, t.prev, t))) ||
  19400. (cu(e, t) && It(e.prev, e, e.next) > 0 && It(t.prev, t, t.next) > 0))
  19401. );
  19402. }
  19403. function It(e, t, i) {
  19404. return (t.y - e.y) * (i.x - t.x) - (t.x - e.x) * (i.y - t.y);
  19405. }
  19406. function cu(e, t) {
  19407. return e.x === t.x && e.y === t.y;
  19408. }
  19409. function Ow(e, t, i, r) {
  19410. let s = pc(It(e, t, i)),
  19411. n = pc(It(e, t, r)),
  19412. a = pc(It(i, r, e)),
  19413. o = pc(It(i, r, t));
  19414. return !!(
  19415. (s !== n && a !== o) ||
  19416. (s === 0 && uc(e, i, t)) ||
  19417. (n === 0 && uc(e, r, t)) ||
  19418. (a === 0 && uc(i, e, r)) ||
  19419. (o === 0 && uc(i, t, r))
  19420. );
  19421. }
  19422. function uc(e, t, i) {
  19423. 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);
  19424. }
  19425. function pc(e) {
  19426. return e > 0 ? 1 : e < 0 ? -1 : 0;
  19427. }
  19428. function CD(e, t) {
  19429. let i = e;
  19430. do {
  19431. if (i.i !== e.i && i.next.i !== e.i && i.i !== t.i && i.next.i !== t.i && Ow(i, i.next, e, t)) return !0;
  19432. i = i.next;
  19433. } while (i !== e);
  19434. return !1;
  19435. }
  19436. function dh(e, t) {
  19437. return It(e.prev, e, e.next) < 0 ? It(e, t, e.next) >= 0 && It(e, e.prev, t) >= 0 : It(e, t, e.prev) < 0 || It(e, e.next, t) < 0;
  19438. }
  19439. function TD(e, t) {
  19440. let i = e,
  19441. r = !1,
  19442. s = (e.x + t.x) / 2,
  19443. n = (e.y + t.y) / 2;
  19444. do {
  19445. i.y > n != i.next.y > n && i.next.y !== i.y && s < ((i.next.x - i.x) * (n - i.y)) / (i.next.y - i.y) + i.x && (r = !r), (i = i.next);
  19446. } while (i !== e);
  19447. return r;
  19448. }
  19449. function Iw(e, t) {
  19450. let i = new Wf(e.i, e.x, e.y),
  19451. r = new Wf(t.i, t.x, t.y),
  19452. s = e.next,
  19453. n = t.prev;
  19454. return (e.next = t), (t.prev = e), (i.next = s), (s.prev = i), (r.next = i), (i.prev = r), (n.next = r), (r.prev = n), r;
  19455. }
  19456. function vy(e, t, i, r) {
  19457. let s = new Wf(e, t, i);
  19458. return r ? ((s.next = r.next), (s.prev = r), (r.next.prev = s), (r.next = s)) : ((s.prev = s), (s.next = s)), s;
  19459. }
  19460. function uh(e) {
  19461. (e.next.prev = e.prev), (e.prev.next = e.next), e.prevZ && (e.prevZ.nextZ = e.nextZ), e.nextZ && (e.nextZ.prevZ = e.prevZ);
  19462. }
  19463. function Wf(e, t, i) {
  19464. (this.i = e),
  19465. (this.x = t),
  19466. (this.y = i),
  19467. (this.prev = null),
  19468. (this.next = null),
  19469. (this.z = 0),
  19470. (this.prevZ = null),
  19471. (this.nextZ = null),
  19472. (this.steiner = !1);
  19473. }
  19474. function PD(e, t, i, r) {
  19475. let s = 0;
  19476. for (let n = t, a = i - r; n < i; n += r) (s += (e[a] - e[n]) * (e[n + 1] + e[a + 1])), (a = n);
  19477. return s;
  19478. }
  19479. var Rw = class {
  19480. static area(e) {
  19481. let t = e.length,
  19482. i = 0;
  19483. for (let r = t - 1, s = 0; s < t; r = s++) i += e[r].x * e[s].y - e[s].x * e[r].y;
  19484. return i * 0.5;
  19485. }
  19486. static isClockWise(e) {
  19487. return Rw.area(e) < 0;
  19488. }
  19489. static triangulateShape(e, t) {
  19490. let i = [],
  19491. r = [],
  19492. s = [];
  19493. yy(e), xy(i, e);
  19494. let n = e.length;
  19495. t.forEach(yy);
  19496. for (let o = 0; o < t.length; o++) r.push(n), (n += t[o].length), xy(i, t[o]);
  19497. let a = pD.triangulate(i, r);
  19498. for (let o = 0; o < a.length; o += 3) s.push(a.slice(o, o + 3));
  19499. return s;
  19500. }
  19501. };
  19502. function yy(e) {
  19503. let t = e.length;
  19504. t > 2 && e[t - 1].equals(e[0]) && e.pop();
  19505. }
  19506. function xy(e, t) {
  19507. for (let i = 0; i < t.length; i++) e.push(t[i].x), e.push(t[i].y);
  19508. }
  19509. var Bw = class extends vg {
  19510. constructor(e = 1, t = 0) {
  19511. let i = (1 + Math.sqrt(5)) / 2,
  19512. 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],
  19513. s = [
  19514. 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,
  19515. 8, 3, 8, 9, 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1
  19516. ];
  19517. super(r, s, e, t), (this.type = 'IcosahedronGeometry'), (this.parameters = { radius: e, detail: t });
  19518. }
  19519. static fromJSON(e) {
  19520. return new Bw(e.radius, e.detail);
  19521. }
  19522. },
  19523. yg = class extends Ve {
  19524. constructor(e = 1, t = 32, i = 16, r = 0, s = Math.PI * 2, n = 0, a = Math.PI) {
  19525. super(),
  19526. (this.type = 'SphereGeometry'),
  19527. (this.parameters = { radius: e, widthSegments: t, heightSegments: i, phiStart: r, phiLength: s, thetaStart: n, thetaLength: a }),
  19528. (t = Math.max(3, Math.floor(t))),
  19529. (i = Math.max(2, Math.floor(i)));
  19530. let o = Math.min(n + a, Math.PI),
  19531. l = 0,
  19532. h = [],
  19533. u = new E(),
  19534. c = new E(),
  19535. d = [],
  19536. p = [],
  19537. f = [],
  19538. g = [];
  19539. for (let m = 0; m <= i; m++) {
  19540. let v = [],
  19541. y = m / i,
  19542. b = 0;
  19543. m == 0 && n == 0 ? (b = 0.5 / t) : m == i && o == Math.PI && (b = -0.5 / t);
  19544. for (let x = 0; x <= t; x++) {
  19545. let w = x / t;
  19546. (u.x = -e * Math.cos(r + w * s) * Math.sin(n + y * a)),
  19547. (u.y = e * Math.cos(n + y * a)),
  19548. (u.z = e * Math.sin(r + w * s) * Math.sin(n + y * a)),
  19549. p.push(u.x, u.y, u.z),
  19550. c.copy(u).normalize(),
  19551. f.push(c.x, c.y, c.z),
  19552. g.push(w + b, 1 - y),
  19553. v.push(l++);
  19554. }
  19555. h.push(v);
  19556. }
  19557. for (let m = 0; m < i; m++)
  19558. for (let v = 0; v < t; v++) {
  19559. let y = h[m][v + 1],
  19560. b = h[m][v],
  19561. x = h[m + 1][v],
  19562. w = h[m + 1][v + 1];
  19563. (m !== 0 || n > 0) && d.push(y, b, w), (m !== i - 1 || o < Math.PI) && d.push(b, x, w);
  19564. }
  19565. this.setIndex(d),
  19566. this.setAttribute('position', new Ce(p, 3)),
  19567. this.setAttribute('normal', new Ce(f, 3)),
  19568. this.setAttribute('uv', new Ce(g, 2));
  19569. }
  19570. static fromJSON(e) {
  19571. return new yg(e.radius, e.widthSegments, e.heightSegments, e.phiStart, e.phiLength, e.thetaStart, e.thetaLength);
  19572. }
  19573. },
  19574. zw = class extends Ve {
  19575. constructor(e = 1, t = 0.4, i = 64, r = 8, s = 2, n = 3) {
  19576. super(),
  19577. (this.type = 'TorusKnotGeometry'),
  19578. (this.parameters = { radius: e, tube: t, tubularSegments: i, radialSegments: r, p: s, q: n }),
  19579. (i = Math.floor(i)),
  19580. (r = Math.floor(r));
  19581. let a = [],
  19582. o = [],
  19583. l = [],
  19584. h = [],
  19585. u = new E(),
  19586. c = new E(),
  19587. d = new E(),
  19588. p = new E(),
  19589. f = new E(),
  19590. g = new E(),
  19591. m = new E();
  19592. for (let y = 0; y <= i; ++y) {
  19593. let b = (y / i) * s * Math.PI * 2;
  19594. v(b, s, n, e, d),
  19595. v(b + 0.01, s, n, e, p),
  19596. g.subVectors(p, d),
  19597. m.addVectors(p, d),
  19598. f.crossVectors(g, m),
  19599. m.crossVectors(f, g),
  19600. f.normalize(),
  19601. m.normalize();
  19602. for (let x = 0; x <= r; ++x) {
  19603. let w = (x / r) * Math.PI * 2,
  19604. A = -t * Math.cos(w),
  19605. S = t * Math.sin(w);
  19606. (u.x = d.x + (A * m.x + S * f.x)),
  19607. (u.y = d.y + (A * m.y + S * f.y)),
  19608. (u.z = d.z + (A * m.z + S * f.z)),
  19609. o.push(u.x, u.y, u.z),
  19610. c.subVectors(u, d).normalize(),
  19611. l.push(c.x, c.y, c.z),
  19612. h.push(y / i),
  19613. h.push(x / r);
  19614. }
  19615. }
  19616. for (let y = 1; y <= i; y++)
  19617. for (let b = 1; b <= r; b++) {
  19618. let x = (r + 1) * (y - 1) + (b - 1),
  19619. w = (r + 1) * y + (b - 1),
  19620. A = (r + 1) * y + b,
  19621. S = (r + 1) * (y - 1) + b;
  19622. a.push(x, w, S), a.push(w, A, S);
  19623. }
  19624. this.setIndex(a),
  19625. this.setAttribute('position', new Ce(o, 3)),
  19626. this.setAttribute('normal', new Ce(l, 3)),
  19627. this.setAttribute('uv', new Ce(h, 2));
  19628. function v(y, b, x, w, A) {
  19629. let S = Math.cos(y),
  19630. _ = Math.sin(y),
  19631. M = (x / b) * y,
  19632. C = Math.cos(M);
  19633. (A.x = w * (2 + C) * 0.5 * S), (A.y = w * (2 + C) * _ * 0.5), (A.z = w * Math.sin(M) * 0.5);
  19634. }
  19635. }
  19636. static fromJSON(e) {
  19637. return new zw(e.radius, e.tube, e.tubularSegments, e.radialSegments, e.p, e.q);
  19638. }
  19639. };
  19640. function tn(e, t, i) {
  19641. return Nw(e) ? new e.constructor(e.subarray(t, i !== void 0 ? i : e.length)) : e.slice(t, i);
  19642. }
  19643. function fc(e, t, i) {
  19644. return !e || (!i && e.constructor === t) ? e : typeof t.BYTES_PER_ELEMENT == 'number' ? new t(e) : Array.prototype.slice.call(e);
  19645. }
  19646. function Nw(e) {
  19647. return ArrayBuffer.isView(e) && !(e instanceof DataView);
  19648. }
  19649. var du = class {
  19650. constructor(e, t, i, r) {
  19651. (this.parameterPositions = e),
  19652. (this._cachedIndex = 0),
  19653. (this.resultBuffer = r !== void 0 ? r : new t.constructor(i)),
  19654. (this.sampleValues = t),
  19655. (this.valueSize = i),
  19656. (this.settings = null),
  19657. (this.DefaultSettings_ = {});
  19658. }
  19659. evaluate(e) {
  19660. let t = this.parameterPositions,
  19661. i = this._cachedIndex,
  19662. r = t[i],
  19663. s = t[i - 1];
  19664. i: {
  19665. e: {
  19666. let n;
  19667. t: {
  19668. r: if (!(e < r)) {
  19669. for (let a = i + 2; ; ) {
  19670. if (r === void 0) {
  19671. if (e < s) break r;
  19672. return (i = t.length), (this._cachedIndex = i), this.copySampleValue_(i - 1);
  19673. }
  19674. if (i === a) break;
  19675. if (((s = r), (r = t[++i]), e < r)) break e;
  19676. }
  19677. n = t.length;
  19678. break t;
  19679. }
  19680. if (!(e >= s)) {
  19681. let a = t[1];
  19682. e < a && ((i = 2), (s = a));
  19683. for (let o = i - 2; ; ) {
  19684. if (s === void 0) return (this._cachedIndex = 0), this.copySampleValue_(0);
  19685. if (i === o) break;
  19686. if (((r = s), (s = t[--i - 1]), e >= s)) break e;
  19687. }
  19688. (n = i), (i = 0);
  19689. break t;
  19690. }
  19691. break i;
  19692. }
  19693. for (; i < n; ) {
  19694. let a = (i + n) >>> 1;
  19695. e < t[a] ? (n = a) : (i = a + 1);
  19696. }
  19697. if (((r = t[i]), (s = t[i - 1]), s === void 0)) return (this._cachedIndex = 0), this.copySampleValue_(0);
  19698. if (r === void 0) return (i = t.length), (this._cachedIndex = i), this.copySampleValue_(i - 1);
  19699. }
  19700. (this._cachedIndex = i), this.intervalChanged_(i, s, r);
  19701. }
  19702. return this.interpolate_(i, s, e, r);
  19703. }
  19704. getSettings_() {
  19705. return this.settings || this.DefaultSettings_;
  19706. }
  19707. copySampleValue_(e) {
  19708. let t = this.resultBuffer,
  19709. i = this.sampleValues,
  19710. r = this.valueSize,
  19711. s = e * r;
  19712. for (let n = 0; n !== r; ++n) t[n] = i[s + n];
  19713. return t;
  19714. }
  19715. interpolate_() {
  19716. throw new Error('call to abstract method');
  19717. }
  19718. intervalChanged_() {}
  19719. },
  19720. DD = class extends du {
  19721. constructor(e, t, i, r) {
  19722. super(e, t, i, r),
  19723. (this._weightPrev = -0),
  19724. (this._offsetPrev = -0),
  19725. (this._weightNext = -0),
  19726. (this._offsetNext = -0),
  19727. (this.DefaultSettings_ = { endingStart: T0, endingEnd: T0 });
  19728. }
  19729. intervalChanged_(e, t, i) {
  19730. let r = this.parameterPositions,
  19731. s = e - 2,
  19732. n = e + 1,
  19733. a = r[s],
  19734. o = r[n];
  19735. if (a === void 0)
  19736. switch (this.getSettings_().endingStart) {
  19737. case P0:
  19738. (s = e), (a = 2 * t - i);
  19739. break;
  19740. case D0:
  19741. (s = r.length - 2), (a = t + r[s] - r[s + 1]);
  19742. break;
  19743. default:
  19744. (s = e), (a = i);
  19745. }
  19746. if (o === void 0)
  19747. switch (this.getSettings_().endingEnd) {
  19748. case P0:
  19749. (n = e), (o = 2 * i - t);
  19750. break;
  19751. case D0:
  19752. (n = 1), (o = i + r[1] - r[0]);
  19753. break;
  19754. default:
  19755. (n = e - 1), (o = t);
  19756. }
  19757. let l = (i - t) * 0.5,
  19758. h = this.valueSize;
  19759. (this._weightPrev = l / (t - a)), (this._weightNext = l / (o - i)), (this._offsetPrev = s * h), (this._offsetNext = n * h);
  19760. }
  19761. interpolate_(e, t, i, r) {
  19762. let s = this.resultBuffer,
  19763. n = this.sampleValues,
  19764. a = this.valueSize,
  19765. o = e * a,
  19766. l = o - a,
  19767. h = this._offsetPrev,
  19768. u = this._offsetNext,
  19769. c = this._weightPrev,
  19770. d = this._weightNext,
  19771. p = (i - t) / (r - t),
  19772. f = p * p,
  19773. g = f * p,
  19774. m = -c * g + 2 * c * f - c * p,
  19775. v = (1 + c) * g + (-1.5 - 2 * c) * f + (-0.5 + c) * p + 1,
  19776. y = (-1 - d) * g + (1.5 + d) * f + 0.5 * p,
  19777. b = d * g - d * f;
  19778. for (let x = 0; x !== a; ++x) s[x] = m * n[h + x] + v * n[l + x] + y * n[o + x] + b * n[u + x];
  19779. return s;
  19780. }
  19781. },
  19782. LD = class extends du {
  19783. constructor(e, t, i, r) {
  19784. super(e, t, i, r);
  19785. }
  19786. interpolate_(e, t, i, r) {
  19787. let s = this.resultBuffer,
  19788. n = this.sampleValues,
  19789. a = this.valueSize,
  19790. o = e * a,
  19791. l = o - a,
  19792. h = (i - t) / (r - t),
  19793. u = 1 - h;
  19794. for (let c = 0; c !== a; ++c) s[c] = n[l + c] * u + n[o + c] * h;
  19795. return s;
  19796. }
  19797. },
  19798. OD = class extends du {
  19799. constructor(e, t, i, r) {
  19800. super(e, t, i, r);
  19801. }
  19802. interpolate_(e) {
  19803. return this.copySampleValue_(e - 1);
  19804. }
  19805. },
  19806. Ys = class {
  19807. constructor(e, t, i, r) {
  19808. if (e === void 0) throw new Error('THREE.KeyframeTrack: track name is undefined');
  19809. if (t === void 0 || t.length === 0) throw new Error('THREE.KeyframeTrack: no keyframes in track named ' + e);
  19810. (this.name = e),
  19811. (this.times = fc(t, this.TimeBufferType)),
  19812. (this.values = fc(i, this.ValueBufferType)),
  19813. this.setInterpolation(r || this.DefaultInterpolation);
  19814. }
  19815. static toJSON(e) {
  19816. let t = e.constructor,
  19817. i;
  19818. if (t.toJSON !== this.toJSON) i = t.toJSON(e);
  19819. else {
  19820. i = { name: e.name, times: fc(e.times, Array), values: fc(e.values, Array) };
  19821. let r = e.getInterpolation();
  19822. r !== e.DefaultInterpolation && (i.interpolation = r);
  19823. }
  19824. return (i.type = e.ValueTypeName), i;
  19825. }
  19826. InterpolantFactoryMethodDiscrete(e) {
  19827. return new OD(this.times, this.values, this.getValueSize(), e);
  19828. }
  19829. InterpolantFactoryMethodLinear(e) {
  19830. return new LD(this.times, this.values, this.getValueSize(), e);
  19831. }
  19832. InterpolantFactoryMethodSmooth(e) {
  19833. return new DD(this.times, this.values, this.getValueSize(), e);
  19834. }
  19835. setInterpolation(e) {
  19836. let t;
  19837. switch (e) {
  19838. case dd:
  19839. t = this.InterpolantFactoryMethodDiscrete;
  19840. break;
  19841. case ud:
  19842. t = this.InterpolantFactoryMethodLinear;
  19843. break;
  19844. case Ku:
  19845. t = this.InterpolantFactoryMethodSmooth;
  19846. break;
  19847. }
  19848. if (t === void 0) {
  19849. let i = 'unsupported interpolation for ' + this.ValueTypeName + ' keyframe track named ' + this.name;
  19850. if (this.createInterpolant === void 0)
  19851. if (e !== this.DefaultInterpolation) this.setInterpolation(this.DefaultInterpolation);
  19852. else throw new Error(i);
  19853. return console.warn('THREE.KeyframeTrack:', i), this;
  19854. }
  19855. return (this.createInterpolant = t), this;
  19856. }
  19857. getInterpolation() {
  19858. switch (this.createInterpolant) {
  19859. case this.InterpolantFactoryMethodDiscrete:
  19860. return dd;
  19861. case this.InterpolantFactoryMethodLinear:
  19862. return ud;
  19863. case this.InterpolantFactoryMethodSmooth:
  19864. return Ku;
  19865. }
  19866. }
  19867. getValueSize() {
  19868. return this.values.length / this.times.length;
  19869. }
  19870. shift(e) {
  19871. if (e !== 0) {
  19872. let t = this.times;
  19873. for (let i = 0, r = t.length; i !== r; ++i) t[i] += e;
  19874. }
  19875. return this;
  19876. }
  19877. scale(e) {
  19878. if (e !== 1) {
  19879. let t = this.times;
  19880. for (let i = 0, r = t.length; i !== r; ++i) t[i] *= e;
  19881. }
  19882. return this;
  19883. }
  19884. trim(e, t) {
  19885. let i = this.times,
  19886. r = i.length,
  19887. s = 0,
  19888. n = r - 1;
  19889. for (; s !== r && i[s] < e; ) ++s;
  19890. for (; n !== -1 && i[n] > t; ) --n;
  19891. if ((++n, s !== 0 || n !== r)) {
  19892. s >= n && ((n = Math.max(n, 1)), (s = n - 1));
  19893. let a = this.getValueSize();
  19894. (this.times = tn(i, s, n)), (this.values = tn(this.values, s * a, n * a));
  19895. }
  19896. return this;
  19897. }
  19898. validate() {
  19899. let e = !0,
  19900. t = this.getValueSize();
  19901. t - Math.floor(t) !== 0 && (console.error('THREE.KeyframeTrack: Invalid value size in track.', this), (e = !1));
  19902. let i = this.times,
  19903. r = this.values,
  19904. s = i.length;
  19905. s === 0 && (console.error('THREE.KeyframeTrack: Track is empty.', this), (e = !1));
  19906. let n = null;
  19907. for (let a = 0; a !== s; a++) {
  19908. let o = i[a];
  19909. if (typeof o == 'number' && isNaN(o)) {
  19910. console.error('THREE.KeyframeTrack: Time is not a valid number.', this, a, o), (e = !1);
  19911. break;
  19912. }
  19913. if (n !== null && n > o) {
  19914. console.error('THREE.KeyframeTrack: Out of order keys.', this, a, o, n), (e = !1);
  19915. break;
  19916. }
  19917. n = o;
  19918. }
  19919. if (r !== void 0 && Nw(r))
  19920. for (let a = 0, o = r.length; a !== o; ++a) {
  19921. let l = r[a];
  19922. if (isNaN(l)) {
  19923. console.error('THREE.KeyframeTrack: Value is not a valid number.', this, a, l), (e = !1);
  19924. break;
  19925. }
  19926. }
  19927. return e;
  19928. }
  19929. optimize() {
  19930. let e = tn(this.times),
  19931. t = tn(this.values),
  19932. i = this.getValueSize(),
  19933. r = this.getInterpolation() === Ku,
  19934. s = e.length - 1,
  19935. n = 1;
  19936. for (let a = 1; a < s; ++a) {
  19937. let o = !1,
  19938. l = e[a],
  19939. h = e[a + 1];
  19940. if (l !== h && (a !== 1 || l !== e[0]))
  19941. if (r) o = !0;
  19942. else {
  19943. let u = a * i,
  19944. c = u - i,
  19945. d = u + i;
  19946. for (let p = 0; p !== i; ++p) {
  19947. let f = t[u + p];
  19948. if (f !== t[c + p] || f !== t[d + p]) {
  19949. o = !0;
  19950. break;
  19951. }
  19952. }
  19953. }
  19954. if (o) {
  19955. if (a !== n) {
  19956. e[n] = e[a];
  19957. let u = a * i,
  19958. c = n * i;
  19959. for (let d = 0; d !== i; ++d) t[c + d] = t[u + d];
  19960. }
  19961. ++n;
  19962. }
  19963. }
  19964. if (s > 0) {
  19965. e[n] = e[s];
  19966. for (let a = s * i, o = n * i, l = 0; l !== i; ++l) t[o + l] = t[a + l];
  19967. ++n;
  19968. }
  19969. return n !== e.length ? ((this.times = tn(e, 0, n)), (this.values = tn(t, 0, n * i))) : ((this.times = e), (this.values = t)), this;
  19970. }
  19971. clone() {
  19972. let e = tn(this.times, 0),
  19973. t = tn(this.values, 0),
  19974. i = this.constructor,
  19975. r = new i(this.name, e, t);
  19976. return (r.createInterpolant = this.createInterpolant), r;
  19977. }
  19978. };
  19979. Ys.prototype.TimeBufferType = Float32Array;
  19980. Ys.prototype.ValueBufferType = Float32Array;
  19981. Ys.prototype.DefaultInterpolation = ud;
  19982. var Lh = class extends Ys {};
  19983. Lh.prototype.ValueTypeName = 'bool';
  19984. Lh.prototype.ValueBufferType = Array;
  19985. Lh.prototype.DefaultInterpolation = dd;
  19986. Lh.prototype.InterpolantFactoryMethodLinear = void 0;
  19987. Lh.prototype.InterpolantFactoryMethodSmooth = void 0;
  19988. var ID = class extends Ys {};
  19989. ID.prototype.ValueTypeName = 'color';
  19990. var RD = class extends Ys {};
  19991. RD.prototype.ValueTypeName = 'number';
  19992. var BD = class extends du {
  19993. constructor(e, t, i, r) {
  19994. super(e, t, i, r);
  19995. }
  19996. interpolate_(e, t, i, r) {
  19997. let s = this.resultBuffer,
  19998. n = this.sampleValues,
  19999. a = this.valueSize,
  20000. o = (i - t) / (r - t),
  20001. l = e * a;
  20002. for (let h = l + a; l !== h; l += 4) ct.slerpFlat(s, 0, n, l - a, n, l, o);
  20003. return s;
  20004. }
  20005. },
  20006. xg = class extends Ys {
  20007. InterpolantFactoryMethodLinear(e) {
  20008. return new BD(this.times, this.values, this.getValueSize(), e);
  20009. }
  20010. };
  20011. xg.prototype.ValueTypeName = 'quaternion';
  20012. xg.prototype.DefaultInterpolation = ud;
  20013. xg.prototype.InterpolantFactoryMethodSmooth = void 0;
  20014. var Oh = class extends Ys {};
  20015. Oh.prototype.ValueTypeName = 'string';
  20016. Oh.prototype.ValueBufferType = Array;
  20017. Oh.prototype.DefaultInterpolation = dd;
  20018. Oh.prototype.InterpolantFactoryMethodLinear = void 0;
  20019. Oh.prototype.InterpolantFactoryMethodSmooth = void 0;
  20020. var zD = class extends Ys {};
  20021. zD.prototype.ValueTypeName = 'vector';
  20022. var by = {
  20023. enabled: !1,
  20024. files: {},
  20025. add: function (e, t) {
  20026. this.enabled !== !1 && (this.files[e] = t);
  20027. },
  20028. get: function (e) {
  20029. if (this.enabled !== !1) return this.files[e];
  20030. },
  20031. remove: function (e) {
  20032. delete this.files[e];
  20033. },
  20034. clear: function () {
  20035. this.files = {};
  20036. }
  20037. },
  20038. Uw = class {
  20039. constructor(e, t, i) {
  20040. let r = this,
  20041. s = !1,
  20042. n = 0,
  20043. a = 0,
  20044. o,
  20045. l = [];
  20046. (this.onStart = void 0),
  20047. (this.onLoad = e),
  20048. (this.onProgress = t),
  20049. (this.onError = i),
  20050. (this.itemStart = function (h) {
  20051. a++, s === !1 && r.onStart !== void 0 && r.onStart(h, n, a), (s = !0);
  20052. }),
  20053. (this.itemEnd = function (h) {
  20054. n++, r.onProgress !== void 0 && r.onProgress(h, n, a), n === a && ((s = !1), r.onLoad !== void 0 && r.onLoad());
  20055. }),
  20056. (this.itemError = function (h) {
  20057. r.onError !== void 0 && r.onError(h);
  20058. }),
  20059. (this.resolveURL = function (h) {
  20060. return o ? o(h) : h;
  20061. }),
  20062. (this.setURLModifier = function (h) {
  20063. return (o = h), this;
  20064. }),
  20065. (this.addHandler = function (h, u) {
  20066. return l.push(h, u), this;
  20067. }),
  20068. (this.removeHandler = function (h) {
  20069. let u = l.indexOf(h);
  20070. return u !== -1 && l.splice(u, 2), this;
  20071. }),
  20072. (this.getHandler = function (h) {
  20073. for (let u = 0, c = l.length; u < c; u += 2) {
  20074. let d = l[u],
  20075. p = l[u + 1];
  20076. if ((d.global && (d.lastIndex = 0), d.test(h))) return p;
  20077. }
  20078. return null;
  20079. });
  20080. }
  20081. },
  20082. ND = new Uw(),
  20083. bg = class {
  20084. constructor(e) {
  20085. (this.manager = e !== void 0 ? e : ND),
  20086. (this.crossOrigin = 'anonymous'),
  20087. (this.withCredentials = !1),
  20088. (this.path = ''),
  20089. (this.resourcePath = ''),
  20090. (this.requestHeader = {});
  20091. }
  20092. load() {}
  20093. loadAsync(e, t) {
  20094. let i = this;
  20095. return new Promise(function (r, s) {
  20096. i.load(e, r, t, s);
  20097. });
  20098. }
  20099. parse() {}
  20100. setCrossOrigin(e) {
  20101. return (this.crossOrigin = e), this;
  20102. }
  20103. setWithCredentials(e) {
  20104. return (this.withCredentials = e), this;
  20105. }
  20106. setPath(e) {
  20107. return (this.path = e), this;
  20108. }
  20109. setResourcePath(e) {
  20110. return (this.resourcePath = e), this;
  20111. }
  20112. setRequestHeader(e) {
  20113. return (this.requestHeader = e), this;
  20114. }
  20115. },
  20116. Os = {},
  20117. UD = class extends Error {
  20118. constructor(e, t) {
  20119. super(e), (this.response = t);
  20120. }
  20121. },
  20122. Xf = class extends bg {
  20123. constructor(e) {
  20124. super(e);
  20125. }
  20126. load(e, t, i, r) {
  20127. e === void 0 && (e = ''), this.path !== void 0 && (e = this.path + e), (e = this.manager.resolveURL(e));
  20128. let s = by.get(e);
  20129. if (s !== void 0)
  20130. return (
  20131. this.manager.itemStart(e),
  20132. setTimeout(() => {
  20133. t && t(s), this.manager.itemEnd(e);
  20134. }, 0),
  20135. s
  20136. );
  20137. if (Os[e] !== void 0) {
  20138. Os[e].push({ onLoad: t, onProgress: i, onError: r });
  20139. return;
  20140. }
  20141. (Os[e] = []), Os[e].push({ onLoad: t, onProgress: i, onError: r });
  20142. let n = new Request(e, { headers: new Headers(this.requestHeader), credentials: this.withCredentials ? 'include' : 'same-origin' }),
  20143. a = this.mimeType,
  20144. o = this.responseType;
  20145. fetch(n)
  20146. .then((l) => {
  20147. if (l.status === 200 || l.status === 0) {
  20148. if (
  20149. (l.status === 0 && console.warn('THREE.FileLoader: HTTP Status 0 received.'),
  20150. typeof ReadableStream > 'u' || l.body === void 0 || l.body.getReader === void 0)
  20151. )
  20152. return l;
  20153. let h = Os[e],
  20154. u = l.body.getReader(),
  20155. c = l.headers.get('Content-Length') || l.headers.get('X-File-Size'),
  20156. d = c ? parseInt(c) : 0,
  20157. p = d !== 0,
  20158. f = 0,
  20159. g = new ReadableStream({
  20160. start(m) {
  20161. v();
  20162. function v() {
  20163. u.read().then(({ done: y, value: b }) => {
  20164. if (y) m.close();
  20165. else {
  20166. f += b.byteLength;
  20167. let x = new ProgressEvent('progress', { lengthComputable: p, loaded: f, total: d });
  20168. for (let w = 0, A = h.length; w < A; w++) {
  20169. let S = h[w];
  20170. S.onProgress && S.onProgress(x);
  20171. }
  20172. m.enqueue(b), v();
  20173. }
  20174. });
  20175. }
  20176. }
  20177. });
  20178. return new Response(g);
  20179. } else throw new UD(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`, l);
  20180. })
  20181. .then((l) => {
  20182. switch (o) {
  20183. case 'arraybuffer':
  20184. return l.arrayBuffer();
  20185. case 'blob':
  20186. return l.blob();
  20187. case 'document':
  20188. return l.text().then((h) => new DOMParser().parseFromString(h, a));
  20189. case 'json':
  20190. return l.json();
  20191. default:
  20192. if (a === void 0) return l.text();
  20193. {
  20194. let h = /charset="?([^;"\s]*)"?/i.exec(a),
  20195. u = h && h[1] ? h[1].toLowerCase() : void 0,
  20196. c = new TextDecoder(u);
  20197. return l.arrayBuffer().then((d) => c.decode(d));
  20198. }
  20199. }
  20200. })
  20201. .then((l) => {
  20202. by.add(e, l);
  20203. let h = Os[e];
  20204. delete Os[e];
  20205. for (let u = 0, c = h.length; u < c; u++) {
  20206. let d = h[u];
  20207. d.onLoad && d.onLoad(l);
  20208. }
  20209. })
  20210. .catch((l) => {
  20211. let h = Os[e];
  20212. if (h === void 0) throw (this.manager.itemError(e), l);
  20213. delete Os[e];
  20214. for (let u = 0, c = h.length; u < c; u++) {
  20215. let d = h[u];
  20216. d.onError && d.onError(l);
  20217. }
  20218. this.manager.itemError(e);
  20219. })
  20220. .finally(() => {
  20221. this.manager.itemEnd(e);
  20222. }),
  20223. this.manager.itemStart(e);
  20224. }
  20225. setResponseType(e) {
  20226. return (this.responseType = e), this;
  20227. }
  20228. setMimeType(e) {
  20229. return (this.mimeType = e), this;
  20230. }
  20231. },
  20232. Ih = class extends bt {
  20233. constructor(e, t = 1) {
  20234. super(), (this.isLight = !0), (this.type = 'Light'), (this.color = new Ge(e)), (this.intensity = t);
  20235. }
  20236. dispose() {}
  20237. copy(e, t) {
  20238. return super.copy(e, t), this.color.copy(e.color), (this.intensity = e.intensity), this;
  20239. }
  20240. toJSON(e) {
  20241. let t = super.toJSON(e);
  20242. return (
  20243. (t.object.color = this.color.getHex()),
  20244. (t.object.intensity = this.intensity),
  20245. this.groundColor !== void 0 && (t.object.groundColor = this.groundColor.getHex()),
  20246. this.distance !== void 0 && (t.object.distance = this.distance),
  20247. this.angle !== void 0 && (t.object.angle = this.angle),
  20248. this.decay !== void 0 && (t.object.decay = this.decay),
  20249. this.penumbra !== void 0 && (t.object.penumbra = this.penumbra),
  20250. this.shadow !== void 0 && (t.object.shadow = this.shadow.toJSON()),
  20251. t
  20252. );
  20253. }
  20254. },
  20255. FD = class extends Ih {
  20256. constructor(e, t, i) {
  20257. super(e, i),
  20258. (this.isHemisphereLight = !0),
  20259. (this.type = 'HemisphereLight'),
  20260. this.position.copy(bt.DEFAULT_UP),
  20261. this.updateMatrix(),
  20262. (this.groundColor = new Ge(t));
  20263. }
  20264. copy(e, t) {
  20265. return super.copy(e, t), this.groundColor.copy(e.groundColor), this;
  20266. }
  20267. },
  20268. Cp = new ve(),
  20269. wy = new E(),
  20270. _y = new E(),
  20271. wg = class {
  20272. constructor(e) {
  20273. (this.camera = e),
  20274. (this.bias = 0),
  20275. (this.normalBias = 0),
  20276. (this.radius = 1),
  20277. (this.blurSamples = 8),
  20278. (this.mapSize = new G(512, 512)),
  20279. (this.map = null),
  20280. (this.mapPass = null),
  20281. (this.matrix = new ve()),
  20282. (this.autoUpdate = !0),
  20283. (this.needsUpdate = !1),
  20284. (this._frustum = new dg()),
  20285. (this._frameExtents = new G(1, 1)),
  20286. (this._viewportCount = 1),
  20287. (this._viewports = [new $e(0, 0, 1, 1)]);
  20288. }
  20289. getViewportCount() {
  20290. return this._viewportCount;
  20291. }
  20292. getFrustum() {
  20293. return this._frustum;
  20294. }
  20295. updateMatrices(e) {
  20296. let t = this.camera,
  20297. i = this.matrix;
  20298. wy.setFromMatrixPosition(e.matrixWorld),
  20299. t.position.copy(wy),
  20300. _y.setFromMatrixPosition(e.target.matrixWorld),
  20301. t.lookAt(_y),
  20302. t.updateMatrixWorld(),
  20303. Cp.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse),
  20304. this._frustum.setFromProjectionMatrix(Cp),
  20305. i.set(0.5, 0, 0, 0.5, 0, 0.5, 0, 0.5, 0, 0, 0.5, 0.5, 0, 0, 0, 1),
  20306. i.multiply(Cp);
  20307. }
  20308. getViewport(e) {
  20309. return this._viewports[e];
  20310. }
  20311. getFrameExtents() {
  20312. return this._frameExtents;
  20313. }
  20314. dispose() {
  20315. this.map && this.map.dispose(), this.mapPass && this.mapPass.dispose();
  20316. }
  20317. copy(e) {
  20318. return (this.camera = e.camera.clone()), (this.bias = e.bias), (this.radius = e.radius), this.mapSize.copy(e.mapSize), this;
  20319. }
  20320. clone() {
  20321. return new this.constructor().copy(this);
  20322. }
  20323. toJSON() {
  20324. let e = {};
  20325. return (
  20326. this.bias !== 0 && (e.bias = this.bias),
  20327. this.normalBias !== 0 && (e.normalBias = this.normalBias),
  20328. this.radius !== 1 && (e.radius = this.radius),
  20329. (this.mapSize.x !== 512 || this.mapSize.y !== 512) && (e.mapSize = this.mapSize.toArray()),
  20330. (e.camera = this.camera.toJSON(!1).object),
  20331. delete e.camera.matrix,
  20332. e
  20333. );
  20334. }
  20335. },
  20336. kD = class extends wg {
  20337. constructor() {
  20338. super(new wi(50, 1, 0.5, 500)), (this.isSpotLightShadow = !0), (this.focus = 1);
  20339. }
  20340. updateMatrices(e) {
  20341. let t = this.camera,
  20342. i = hh * 2 * e.angle * this.focus,
  20343. r = this.mapSize.width / this.mapSize.height,
  20344. s = e.distance || t.far;
  20345. (i !== t.fov || r !== t.aspect || s !== t.far) && ((t.fov = i), (t.aspect = r), (t.far = s), t.updateProjectionMatrix()),
  20346. super.updateMatrices(e);
  20347. }
  20348. copy(e) {
  20349. return super.copy(e), (this.focus = e.focus), this;
  20350. }
  20351. },
  20352. jD = class extends Ih {
  20353. constructor(e, t, i = 0, r = Math.PI / 3, s = 0, n = 2) {
  20354. super(e, t),
  20355. (this.isSpotLight = !0),
  20356. (this.type = 'SpotLight'),
  20357. this.position.copy(bt.DEFAULT_UP),
  20358. this.updateMatrix(),
  20359. (this.target = new bt()),
  20360. (this.distance = i),
  20361. (this.angle = r),
  20362. (this.penumbra = s),
  20363. (this.decay = n),
  20364. (this.map = null),
  20365. (this.shadow = new kD());
  20366. }
  20367. get power() {
  20368. return this.intensity * Math.PI;
  20369. }
  20370. set power(e) {
  20371. this.intensity = e / Math.PI;
  20372. }
  20373. dispose() {
  20374. this.shadow.dispose();
  20375. }
  20376. copy(e, t) {
  20377. return (
  20378. super.copy(e, t),
  20379. (this.distance = e.distance),
  20380. (this.angle = e.angle),
  20381. (this.penumbra = e.penumbra),
  20382. (this.decay = e.decay),
  20383. (this.target = e.target.clone()),
  20384. (this.shadow = e.shadow.clone()),
  20385. this
  20386. );
  20387. }
  20388. },
  20389. Ay = new ve(),
  20390. yl = new E(),
  20391. Tp = new E(),
  20392. GD = class extends wg {
  20393. constructor() {
  20394. super(new wi(90, 1, 0.5, 500)),
  20395. (this.isPointLightShadow = !0),
  20396. (this._frameExtents = new G(4, 2)),
  20397. (this._viewportCount = 6),
  20398. (this._viewports = [
  20399. new $e(2, 1, 1, 1),
  20400. new $e(0, 1, 1, 1),
  20401. new $e(3, 1, 1, 1),
  20402. new $e(1, 1, 1, 1),
  20403. new $e(3, 0, 1, 1),
  20404. new $e(1, 0, 1, 1)
  20405. ]),
  20406. (this._cubeDirections = [new E(1, 0, 0), new E(-1, 0, 0), new E(0, 0, 1), new E(0, 0, -1), new E(0, 1, 0), new E(0, -1, 0)]),
  20407. (this._cubeUps = [new E(0, 1, 0), new E(0, 1, 0), new E(0, 1, 0), new E(0, 1, 0), new E(0, 0, 1), new E(0, 0, -1)]);
  20408. }
  20409. updateMatrices(e, t = 0) {
  20410. let i = this.camera,
  20411. r = this.matrix,
  20412. s = e.distance || i.far;
  20413. s !== i.far && ((i.far = s), i.updateProjectionMatrix()),
  20414. yl.setFromMatrixPosition(e.matrixWorld),
  20415. i.position.copy(yl),
  20416. Tp.copy(i.position),
  20417. Tp.add(this._cubeDirections[t]),
  20418. i.up.copy(this._cubeUps[t]),
  20419. i.lookAt(Tp),
  20420. i.updateMatrixWorld(),
  20421. r.makeTranslation(-yl.x, -yl.y, -yl.z),
  20422. Ay.multiplyMatrices(i.projectionMatrix, i.matrixWorldInverse),
  20423. this._frustum.setFromProjectionMatrix(Ay);
  20424. }
  20425. },
  20426. VD = class extends Ih {
  20427. constructor(e, t, i = 0, r = 2) {
  20428. super(e, t), (this.isPointLight = !0), (this.type = 'PointLight'), (this.distance = i), (this.decay = r), (this.shadow = new GD());
  20429. }
  20430. get power() {
  20431. return this.intensity * 4 * Math.PI;
  20432. }
  20433. set power(e) {
  20434. this.intensity = e / (4 * Math.PI);
  20435. }
  20436. dispose() {
  20437. this.shadow.dispose();
  20438. }
  20439. copy(e, t) {
  20440. return super.copy(e, t), (this.distance = e.distance), (this.decay = e.decay), (this.shadow = e.shadow.clone()), this;
  20441. }
  20442. },
  20443. HD = class extends wg {
  20444. constructor() {
  20445. super(new gd(-5, 5, 5, -5, 0.5, 500)), (this.isDirectionalLightShadow = !0);
  20446. }
  20447. },
  20448. WD = class extends Ih {
  20449. constructor(e, t) {
  20450. super(e, t),
  20451. (this.isDirectionalLight = !0),
  20452. (this.type = 'DirectionalLight'),
  20453. this.position.copy(bt.DEFAULT_UP),
  20454. this.updateMatrix(),
  20455. (this.target = new bt()),
  20456. (this.shadow = new HD());
  20457. }
  20458. dispose() {
  20459. this.shadow.dispose();
  20460. }
  20461. copy(e) {
  20462. return super.copy(e), (this.target = e.target.clone()), (this.shadow = e.shadow.clone()), this;
  20463. }
  20464. },
  20465. XD = class extends Ve {
  20466. constructor() {
  20467. super(), (this.isInstancedBufferGeometry = !0), (this.type = 'InstancedBufferGeometry'), (this.instanceCount = 1 / 0);
  20468. }
  20469. copy(e) {
  20470. return super.copy(e), (this.instanceCount = e.instanceCount), this;
  20471. }
  20472. toJSON() {
  20473. let e = super.toJSON();
  20474. return (e.instanceCount = this.instanceCount), (e.isInstancedBufferGeometry = !0), e;
  20475. }
  20476. },
  20477. Fw = class extends bg {
  20478. constructor(e) {
  20479. super(e);
  20480. }
  20481. load(e, t, i, r) {
  20482. let s = this,
  20483. n = new Xf(s.manager);
  20484. n.setPath(s.path),
  20485. n.setRequestHeader(s.requestHeader),
  20486. n.setWithCredentials(s.withCredentials),
  20487. n.load(
  20488. e,
  20489. function (a) {
  20490. try {
  20491. t(s.parse(JSON.parse(a)));
  20492. } catch (o) {
  20493. r ? r(o) : console.error(o), s.manager.itemError(e);
  20494. }
  20495. },
  20496. i,
  20497. r
  20498. );
  20499. }
  20500. parse(e) {
  20501. let t = {},
  20502. i = {};
  20503. function r(c, d) {
  20504. if (t[d] !== void 0) return t[d];
  20505. let p = c.interleavedBuffers[d],
  20506. f = s(c, p.buffer),
  20507. g = Wh(p.type, f),
  20508. m = new $P(g, p.stride);
  20509. return (m.uuid = p.uuid), (t[d] = m), m;
  20510. }
  20511. function s(c, d) {
  20512. if (i[d] !== void 0) return i[d];
  20513. let p = c.arrayBuffers[d],
  20514. f = new Uint32Array(p).buffer;
  20515. return (i[d] = f), f;
  20516. }
  20517. let n = e.isInstancedBufferGeometry ? new XD() : new Ve(),
  20518. a = e.data.index;
  20519. if (a !== void 0) {
  20520. let c = Wh(a.type, a.array);
  20521. n.setIndex(new Xe(c, 1));
  20522. }
  20523. let o = e.data.attributes;
  20524. for (let c in o) {
  20525. let d = o[c],
  20526. p;
  20527. if (d.isInterleavedBufferAttribute) {
  20528. let f = r(e.data, d.data);
  20529. p = new Vf(f, d.itemSize, d.offset, d.normalized);
  20530. } else {
  20531. let f = Wh(d.type, d.array),
  20532. g = d.isInstancedBufferAttribute ? eD : Xe;
  20533. p = new g(f, d.itemSize, d.normalized);
  20534. }
  20535. d.name !== void 0 && (p.name = d.name),
  20536. d.usage !== void 0 && p.setUsage(d.usage),
  20537. d.updateRange !== void 0 && ((p.updateRange.offset = d.updateRange.offset), (p.updateRange.count = d.updateRange.count)),
  20538. n.setAttribute(c, p);
  20539. }
  20540. let l = e.data.morphAttributes;
  20541. if (l)
  20542. for (let c in l) {
  20543. let d = l[c],
  20544. p = [];
  20545. for (let f = 0, g = d.length; f < g; f++) {
  20546. let m = d[f],
  20547. v;
  20548. if (m.isInterleavedBufferAttribute) {
  20549. let y = r(e.data, m.data);
  20550. v = new Vf(y, m.itemSize, m.offset, m.normalized);
  20551. } else {
  20552. let y = Wh(m.type, m.array);
  20553. v = new Xe(y, m.itemSize, m.normalized);
  20554. }
  20555. m.name !== void 0 && (v.name = m.name), p.push(v);
  20556. }
  20557. n.morphAttributes[c] = p;
  20558. }
  20559. e.data.morphTargetsRelative && (n.morphTargetsRelative = !0);
  20560. let h = e.data.groups || e.data.drawcalls || e.data.offsets;
  20561. if (h !== void 0)
  20562. for (let c = 0, d = h.length; c !== d; ++c) {
  20563. let p = h[c];
  20564. n.addGroup(p.start, p.count, p.materialIndex);
  20565. }
  20566. let u = e.data.boundingSphere;
  20567. if (u !== void 0) {
  20568. let c = new E();
  20569. u.center !== void 0 && c.fromArray(u.center), (n.boundingSphere = new Mr(c, u.radius));
  20570. }
  20571. return e.name && (n.name = e.name), e.userData && (n.userData = e.userData), n;
  20572. }
  20573. },
  20574. qD = class {
  20575. constructor(e = !0) {
  20576. (this.autoStart = e), (this.startTime = 0), (this.oldTime = 0), (this.elapsedTime = 0), (this.running = !1);
  20577. }
  20578. start() {
  20579. (this.startTime = Sy()), (this.oldTime = this.startTime), (this.elapsedTime = 0), (this.running = !0);
  20580. }
  20581. stop() {
  20582. this.getElapsedTime(), (this.running = !1), (this.autoStart = !1);
  20583. }
  20584. getElapsedTime() {
  20585. return this.getDelta(), this.elapsedTime;
  20586. }
  20587. getDelta() {
  20588. let e = 0;
  20589. if (this.autoStart && !this.running) return this.start(), 0;
  20590. if (this.running) {
  20591. let t = Sy();
  20592. (e = (t - this.oldTime) / 1e3), (this.oldTime = t), (this.elapsedTime += e);
  20593. }
  20594. return e;
  20595. }
  20596. };
  20597. function Sy() {
  20598. return (typeof performance > 'u' ? Date : performance).now();
  20599. }
  20600. var _g = '\\[\\]\\.:\\/',
  20601. YD = new RegExp('[' + _g + ']', 'g'),
  20602. Ag = '[^' + _g + ']',
  20603. QD = '[^' + _g.replace('\\.', '') + ']',
  20604. ZD = /((?:WC+[\/:])*)/.source.replace('WC', Ag),
  20605. KD = /(WCOD+)?/.source.replace('WCOD', QD),
  20606. JD = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace('WC', Ag),
  20607. $D = /\.(WC+)(?:\[(.+)\])?/.source.replace('WC', Ag),
  20608. eL = new RegExp('^' + ZD + KD + JD + $D + '$'),
  20609. tL = ['material', 'materials', 'bones', 'map'],
  20610. iL = class {
  20611. constructor(e, t, i) {
  20612. let r = i || At.parseTrackName(t);
  20613. (this._targetGroup = e), (this._bindings = e.subscribe_(t, r));
  20614. }
  20615. getValue(e, t) {
  20616. this.bind();
  20617. let i = this._targetGroup.nCachedObjects_,
  20618. r = this._bindings[i];
  20619. r !== void 0 && r.getValue(e, t);
  20620. }
  20621. setValue(e, t) {
  20622. let i = this._bindings;
  20623. for (let r = this._targetGroup.nCachedObjects_, s = i.length; r !== s; ++r) i[r].setValue(e, t);
  20624. }
  20625. bind() {
  20626. let e = this._bindings;
  20627. for (let t = this._targetGroup.nCachedObjects_, i = e.length; t !== i; ++t) e[t].bind();
  20628. }
  20629. unbind() {
  20630. let e = this._bindings;
  20631. for (let t = this._targetGroup.nCachedObjects_, i = e.length; t !== i; ++t) e[t].unbind();
  20632. }
  20633. },
  20634. At = class {
  20635. constructor(e, t, i) {
  20636. (this.path = t),
  20637. (this.parsedPath = i || At.parseTrackName(t)),
  20638. (this.node = At.findNode(e, this.parsedPath.nodeName) || e),
  20639. (this.rootNode = e),
  20640. (this.getValue = this._getValue_unbound),
  20641. (this.setValue = this._setValue_unbound);
  20642. }
  20643. static create(e, t, i) {
  20644. return e && e.isAnimationObjectGroup ? new At.Composite(e, t, i) : new At(e, t, i);
  20645. }
  20646. static sanitizeNodeName(e) {
  20647. return e.replace(/\s/g, '_').replace(YD, '');
  20648. }
  20649. static parseTrackName(e) {
  20650. let t = eL.exec(e);
  20651. if (t === null) throw new Error('PropertyBinding: Cannot parse trackName: ' + e);
  20652. let i = { nodeName: t[2], objectName: t[3], objectIndex: t[4], propertyName: t[5], propertyIndex: t[6] },
  20653. r = i.nodeName && i.nodeName.lastIndexOf('.');
  20654. if (r !== void 0 && r !== -1) {
  20655. let s = i.nodeName.substring(r + 1);
  20656. tL.indexOf(s) !== -1 && ((i.nodeName = i.nodeName.substring(0, r)), (i.objectName = s));
  20657. }
  20658. if (i.propertyName === null || i.propertyName.length === 0)
  20659. throw new Error('PropertyBinding: can not parse propertyName from trackName: ' + e);
  20660. return i;
  20661. }
  20662. static findNode(e, t) {
  20663. if (t === void 0 || t === '' || t === '.' || t === -1 || t === e.name || t === e.uuid) return e;
  20664. if (e.skeleton) {
  20665. let i = e.skeleton.getBoneByName(t);
  20666. if (i !== void 0) return i;
  20667. }
  20668. if (e.children) {
  20669. let i = function (s) {
  20670. for (let n = 0; n < s.length; n++) {
  20671. let a = s[n];
  20672. if (a.name === t || a.uuid === t) return a;
  20673. let o = i(a.children);
  20674. if (o) return o;
  20675. }
  20676. return null;
  20677. },
  20678. r = i(e.children);
  20679. if (r) return r;
  20680. }
  20681. return null;
  20682. }
  20683. _getValue_unavailable() {}
  20684. _setValue_unavailable() {}
  20685. _getValue_direct(e, t) {
  20686. e[t] = this.targetObject[this.propertyName];
  20687. }
  20688. _getValue_array(e, t) {
  20689. let i = this.resolvedProperty;
  20690. for (let r = 0, s = i.length; r !== s; ++r) e[t++] = i[r];
  20691. }
  20692. _getValue_arrayElement(e, t) {
  20693. e[t] = this.resolvedProperty[this.propertyIndex];
  20694. }
  20695. _getValue_toArray(e, t) {
  20696. this.resolvedProperty.toArray(e, t);
  20697. }
  20698. _setValue_direct(e, t) {
  20699. this.targetObject[this.propertyName] = e[t];
  20700. }
  20701. _setValue_direct_setNeedsUpdate(e, t) {
  20702. (this.targetObject[this.propertyName] = e[t]), (this.targetObject.needsUpdate = !0);
  20703. }
  20704. _setValue_direct_setMatrixWorldNeedsUpdate(e, t) {
  20705. (this.targetObject[this.propertyName] = e[t]), (this.targetObject.matrixWorldNeedsUpdate = !0);
  20706. }
  20707. _setValue_array(e, t) {
  20708. let i = this.resolvedProperty;
  20709. for (let r = 0, s = i.length; r !== s; ++r) i[r] = e[t++];
  20710. }
  20711. _setValue_array_setNeedsUpdate(e, t) {
  20712. let i = this.resolvedProperty;
  20713. for (let r = 0, s = i.length; r !== s; ++r) i[r] = e[t++];
  20714. this.targetObject.needsUpdate = !0;
  20715. }
  20716. _setValue_array_setMatrixWorldNeedsUpdate(e, t) {
  20717. let i = this.resolvedProperty;
  20718. for (let r = 0, s = i.length; r !== s; ++r) i[r] = e[t++];
  20719. this.targetObject.matrixWorldNeedsUpdate = !0;
  20720. }
  20721. _setValue_arrayElement(e, t) {
  20722. this.resolvedProperty[this.propertyIndex] = e[t];
  20723. }
  20724. _setValue_arrayElement_setNeedsUpdate(e, t) {
  20725. (this.resolvedProperty[this.propertyIndex] = e[t]), (this.targetObject.needsUpdate = !0);
  20726. }
  20727. _setValue_arrayElement_setMatrixWorldNeedsUpdate(e, t) {
  20728. (this.resolvedProperty[this.propertyIndex] = e[t]), (this.targetObject.matrixWorldNeedsUpdate = !0);
  20729. }
  20730. _setValue_fromArray(e, t) {
  20731. this.resolvedProperty.fromArray(e, t);
  20732. }
  20733. _setValue_fromArray_setNeedsUpdate(e, t) {
  20734. this.resolvedProperty.fromArray(e, t), (this.targetObject.needsUpdate = !0);
  20735. }
  20736. _setValue_fromArray_setMatrixWorldNeedsUpdate(e, t) {
  20737. this.resolvedProperty.fromArray(e, t), (this.targetObject.matrixWorldNeedsUpdate = !0);
  20738. }
  20739. _getValue_unbound(e, t) {
  20740. this.bind(), this.getValue(e, t);
  20741. }
  20742. _setValue_unbound(e, t) {
  20743. this.bind(), this.setValue(e, t);
  20744. }
  20745. bind() {
  20746. let e = this.node,
  20747. t = this.parsedPath,
  20748. i = t.objectName,
  20749. r = t.propertyName,
  20750. s = t.propertyIndex;
  20751. if (
  20752. (e || ((e = At.findNode(this.rootNode, t.nodeName) || this.rootNode), (this.node = e)),
  20753. (this.getValue = this._getValue_unavailable),
  20754. (this.setValue = this._setValue_unavailable),
  20755. !e)
  20756. ) {
  20757. console.error('THREE.PropertyBinding: Trying to update node for track: ' + this.path + " but it wasn't found.");
  20758. return;
  20759. }
  20760. if (i) {
  20761. let l = t.objectIndex;
  20762. switch (i) {
  20763. case 'materials':
  20764. if (!e.material) {
  20765. console.error('THREE.PropertyBinding: Can not bind to material as node does not have a material.', this);
  20766. return;
  20767. }
  20768. if (!e.material.materials) {
  20769. console.error(
  20770. 'THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.',
  20771. this
  20772. );
  20773. return;
  20774. }
  20775. e = e.material.materials;
  20776. break;
  20777. case 'bones':
  20778. if (!e.skeleton) {
  20779. console.error('THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.', this);
  20780. return;
  20781. }
  20782. e = e.skeleton.bones;
  20783. for (let h = 0; h < e.length; h++)
  20784. if (e[h].name === l) {
  20785. l = h;
  20786. break;
  20787. }
  20788. break;
  20789. case 'map':
  20790. if ('map' in e) {
  20791. e = e.map;
  20792. break;
  20793. }
  20794. if (!e.material) {
  20795. console.error('THREE.PropertyBinding: Can not bind to material as node does not have a material.', this);
  20796. return;
  20797. }
  20798. if (!e.material.map) {
  20799. console.error('THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.', this);
  20800. return;
  20801. }
  20802. e = e.material.map;
  20803. break;
  20804. default:
  20805. if (e[i] === void 0) {
  20806. console.error('THREE.PropertyBinding: Can not bind to objectName of node undefined.', this);
  20807. return;
  20808. }
  20809. e = e[i];
  20810. }
  20811. if (l !== void 0) {
  20812. if (e[l] === void 0) {
  20813. console.error('THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.', this, e);
  20814. return;
  20815. }
  20816. e = e[l];
  20817. }
  20818. }
  20819. let n = e[r];
  20820. if (n === void 0) {
  20821. let l = t.nodeName;
  20822. console.error('THREE.PropertyBinding: Trying to update property for track: ' + l + '.' + r + " but it wasn't found.", e);
  20823. return;
  20824. }
  20825. let a = this.Versioning.None;
  20826. (this.targetObject = e),
  20827. e.needsUpdate !== void 0
  20828. ? (a = this.Versioning.NeedsUpdate)
  20829. : e.matrixWorldNeedsUpdate !== void 0 && (a = this.Versioning.MatrixWorldNeedsUpdate);
  20830. let o = this.BindingType.Direct;
  20831. if (s !== void 0) {
  20832. if (r === 'morphTargetInfluences') {
  20833. if (!e.geometry) {
  20834. console.error('THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.', this);
  20835. return;
  20836. }
  20837. if (!e.geometry.morphAttributes) {
  20838. console.error(
  20839. 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.',
  20840. this
  20841. );
  20842. return;
  20843. }
  20844. e.morphTargetDictionary[s] !== void 0 && (s = e.morphTargetDictionary[s]);
  20845. }
  20846. (o = this.BindingType.ArrayElement), (this.resolvedProperty = n), (this.propertyIndex = s);
  20847. } else
  20848. n.fromArray !== void 0 && n.toArray !== void 0
  20849. ? ((o = this.BindingType.HasFromToArray), (this.resolvedProperty = n))
  20850. : Array.isArray(n)
  20851. ? ((o = this.BindingType.EntireArray), (this.resolvedProperty = n))
  20852. : (this.propertyName = r);
  20853. (this.getValue = this.GetterByBindingType[o]), (this.setValue = this.SetterByBindingTypeAndVersioning[o][a]);
  20854. }
  20855. unbind() {
  20856. (this.node = null), (this.getValue = this._getValue_unbound), (this.setValue = this._setValue_unbound);
  20857. }
  20858. };
  20859. At.Composite = iL;
  20860. At.prototype.BindingType = { Direct: 0, EntireArray: 1, ArrayElement: 2, HasFromToArray: 3 };
  20861. At.prototype.Versioning = { None: 0, NeedsUpdate: 1, MatrixWorldNeedsUpdate: 2 };
  20862. At.prototype.GetterByBindingType = [
  20863. At.prototype._getValue_direct,
  20864. At.prototype._getValue_array,
  20865. At.prototype._getValue_arrayElement,
  20866. At.prototype._getValue_toArray
  20867. ];
  20868. At.prototype.SetterByBindingTypeAndVersioning = [
  20869. [At.prototype._setValue_direct, At.prototype._setValue_direct_setNeedsUpdate, At.prototype._setValue_direct_setMatrixWorldNeedsUpdate],
  20870. [At.prototype._setValue_array, At.prototype._setValue_array_setNeedsUpdate, At.prototype._setValue_array_setMatrixWorldNeedsUpdate],
  20871. [
  20872. At.prototype._setValue_arrayElement,
  20873. At.prototype._setValue_arrayElement_setNeedsUpdate,
  20874. At.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate
  20875. ],
  20876. [
  20877. At.prototype._setValue_fromArray,
  20878. At.prototype._setValue_fromArray_setNeedsUpdate,
  20879. At.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate
  20880. ]
  20881. ];
  20882. var p9 = new Float32Array(1),
  20883. Oe = class {
  20884. constructor(e) {
  20885. this.value = e;
  20886. }
  20887. clone() {
  20888. return new Oe(this.value.clone === void 0 ? this.value : this.value.clone());
  20889. }
  20890. },
  20891. kw = class {
  20892. constructor(e, t, i = 0, r = 1 / 0) {
  20893. (this.ray = new Xo(e, t)),
  20894. (this.near = i),
  20895. (this.far = r),
  20896. (this.camera = null),
  20897. (this.layers = new hg()),
  20898. (this.params = { Mesh: {}, Line: { threshold: 1 }, LOD: {}, Points: { threshold: 1 }, Sprite: {} });
  20899. }
  20900. set(e, t) {
  20901. this.ray.set(e, t);
  20902. }
  20903. setFromCamera(e, t) {
  20904. t.isPerspectiveCamera
  20905. ? (this.ray.origin.setFromMatrixPosition(t.matrixWorld),
  20906. this.ray.direction.set(e.x, e.y, 0.5).unproject(t).sub(this.ray.origin).normalize(),
  20907. (this.camera = t))
  20908. : t.isOrthographicCamera
  20909. ? (this.ray.origin.set(e.x, e.y, (t.near + t.far) / (t.near - t.far)).unproject(t),
  20910. this.ray.direction.set(0, 0, -1).transformDirection(t.matrixWorld),
  20911. (this.camera = t))
  20912. : console.error('THREE.Raycaster: Unsupported camera type: ' + t.type);
  20913. }
  20914. intersectObject(e, t = !0, i = []) {
  20915. return qf(e, this, i, t), i.sort(My), i;
  20916. }
  20917. intersectObjects(e, t = !0, i = []) {
  20918. for (let r = 0, s = e.length; r < s; r++) qf(e[r], this, i, t);
  20919. return i.sort(My), i;
  20920. }
  20921. };
  20922. function My(e, t) {
  20923. return e.distance - t.distance;
  20924. }
  20925. function qf(e, t, i, r) {
  20926. if ((e.layers.test(t.layers) && e.raycast(t, i), r === !0)) {
  20927. let s = e.children;
  20928. for (let n = 0, a = s.length; n < a; n++) qf(s[n], t, i, !0);
  20929. }
  20930. }
  20931. var Ey = class {
  20932. constructor(e = 1, t = 0, i = 0) {
  20933. return (this.radius = e), (this.phi = t), (this.theta = i), this;
  20934. }
  20935. set(e, t, i) {
  20936. return (this.radius = e), (this.phi = t), (this.theta = i), this;
  20937. }
  20938. copy(e) {
  20939. return (this.radius = e.radius), (this.phi = e.phi), (this.theta = e.theta), this;
  20940. }
  20941. makeSafe() {
  20942. return (this.phi = Math.max(1e-6, Math.min(Math.PI - 1e-6, this.phi))), this;
  20943. }
  20944. setFromVector3(e) {
  20945. return this.setFromCartesianCoords(e.x, e.y, e.z);
  20946. }
  20947. setFromCartesianCoords(e, t, i) {
  20948. return (
  20949. (this.radius = Math.sqrt(e * e + t * t + i * i)),
  20950. this.radius === 0
  20951. ? ((this.theta = 0), (this.phi = 0))
  20952. : ((this.theta = Math.atan2(e, i)), (this.phi = Math.acos(ti(t / this.radius, -1, 1)))),
  20953. this
  20954. );
  20955. }
  20956. clone() {
  20957. return new this.constructor().copy(this);
  20958. }
  20959. },
  20960. Cy = new G(),
  20961. rL = class {
  20962. constructor(e = new G(1 / 0, 1 / 0), t = new G(-1 / 0, -1 / 0)) {
  20963. (this.isBox2 = !0), (this.min = e), (this.max = t);
  20964. }
  20965. set(e, t) {
  20966. return this.min.copy(e), this.max.copy(t), this;
  20967. }
  20968. setFromPoints(e) {
  20969. this.makeEmpty();
  20970. for (let t = 0, i = e.length; t < i; t++) this.expandByPoint(e[t]);
  20971. return this;
  20972. }
  20973. setFromCenterAndSize(e, t) {
  20974. let i = Cy.copy(t).multiplyScalar(0.5);
  20975. return this.min.copy(e).sub(i), this.max.copy(e).add(i), this;
  20976. }
  20977. clone() {
  20978. return new this.constructor().copy(this);
  20979. }
  20980. copy(e) {
  20981. return this.min.copy(e.min), this.max.copy(e.max), this;
  20982. }
  20983. makeEmpty() {
  20984. return (this.min.x = this.min.y = 1 / 0), (this.max.x = this.max.y = -1 / 0), this;
  20985. }
  20986. isEmpty() {
  20987. return this.max.x < this.min.x || this.max.y < this.min.y;
  20988. }
  20989. getCenter(e) {
  20990. return this.isEmpty() ? e.set(0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5);
  20991. }
  20992. getSize(e) {
  20993. return this.isEmpty() ? e.set(0, 0) : e.subVectors(this.max, this.min);
  20994. }
  20995. expandByPoint(e) {
  20996. return this.min.min(e), this.max.max(e), this;
  20997. }
  20998. expandByVector(e) {
  20999. return this.min.sub(e), this.max.add(e), this;
  21000. }
  21001. expandByScalar(e) {
  21002. return this.min.addScalar(-e), this.max.addScalar(e), this;
  21003. }
  21004. containsPoint(e) {
  21005. return !(e.x < this.min.x || e.x > this.max.x || e.y < this.min.y || e.y > this.max.y);
  21006. }
  21007. containsBox(e) {
  21008. 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;
  21009. }
  21010. getParameter(e, t) {
  21011. 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));
  21012. }
  21013. intersectsBox(e) {
  21014. 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);
  21015. }
  21016. clampPoint(e, t) {
  21017. return t.copy(e).clamp(this.min, this.max);
  21018. }
  21019. distanceToPoint(e) {
  21020. return Cy.copy(e).clamp(this.min, this.max).sub(e).length();
  21021. }
  21022. intersect(e) {
  21023. return this.min.max(e.min), this.max.min(e.max), this;
  21024. }
  21025. union(e) {
  21026. return this.min.min(e.min), this.max.max(e.max), this;
  21027. }
  21028. translate(e) {
  21029. return this.min.add(e), this.max.add(e), this;
  21030. }
  21031. equals(e) {
  21032. return e.min.equals(this.min) && e.max.equals(this.max);
  21033. }
  21034. },
  21035. Ty = new E(),
  21036. mc = new E(),
  21037. _r = class {
  21038. constructor(e = new E(), t = new E()) {
  21039. (this.start = e), (this.end = t);
  21040. }
  21041. set(e, t) {
  21042. return this.start.copy(e), this.end.copy(t), this;
  21043. }
  21044. copy(e) {
  21045. return this.start.copy(e.start), this.end.copy(e.end), this;
  21046. }
  21047. getCenter(e) {
  21048. return e.addVectors(this.start, this.end).multiplyScalar(0.5);
  21049. }
  21050. delta(e) {
  21051. return e.subVectors(this.end, this.start);
  21052. }
  21053. distanceSq() {
  21054. return this.start.distanceToSquared(this.end);
  21055. }
  21056. distance() {
  21057. return this.start.distanceTo(this.end);
  21058. }
  21059. at(e, t) {
  21060. return this.delta(t).multiplyScalar(e).add(this.start);
  21061. }
  21062. closestPointToPointParameter(e, t) {
  21063. Ty.subVectors(e, this.start), mc.subVectors(this.end, this.start);
  21064. let i = mc.dot(mc),
  21065. r = mc.dot(Ty) / i;
  21066. return t && (r = ti(r, 0, 1)), r;
  21067. }
  21068. closestPointToPoint(e, t, i) {
  21069. let r = this.closestPointToPointParameter(e, t);
  21070. return this.delta(i).multiplyScalar(r).add(this.start);
  21071. }
  21072. applyMatrix4(e) {
  21073. return this.start.applyMatrix4(e), this.end.applyMatrix4(e), this;
  21074. }
  21075. equals(e) {
  21076. return e.start.equals(this.start) && e.end.equals(this.end);
  21077. }
  21078. clone() {
  21079. return new this.constructor().copy(this);
  21080. }
  21081. },
  21082. Py = new E(),
  21083. sL = class extends bt {
  21084. constructor(e, t) {
  21085. super(),
  21086. (this.light = e),
  21087. (this.matrix = e.matrixWorld),
  21088. (this.matrixAutoUpdate = !1),
  21089. (this.color = t),
  21090. (this.type = 'SpotLightHelper');
  21091. let i = new Ve(),
  21092. 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];
  21093. for (let n = 0, a = 1, o = 32; n < o; n++, a++) {
  21094. let l = (n / o) * Math.PI * 2,
  21095. h = (a / o) * Math.PI * 2;
  21096. r.push(Math.cos(l), Math.sin(l), 1, Math.cos(h), Math.sin(h), 1);
  21097. }
  21098. i.setAttribute('position', new Ce(r, 3));
  21099. let s = new Rn({ fog: !1, toneMapped: !1 });
  21100. (this.cone = new Dh(i, s)), this.add(this.cone), this.update();
  21101. }
  21102. dispose() {
  21103. this.cone.geometry.dispose(), this.cone.material.dispose();
  21104. }
  21105. update() {
  21106. this.light.updateWorldMatrix(!0, !1), this.light.target.updateWorldMatrix(!0, !1);
  21107. let e = this.light.distance ? this.light.distance : 1e3,
  21108. t = e * Math.tan(this.light.angle);
  21109. this.cone.scale.set(t, t, e),
  21110. Py.setFromMatrixPosition(this.light.target.matrixWorld),
  21111. this.cone.lookAt(Py),
  21112. this.color !== void 0 ? this.cone.material.color.set(this.color) : this.cone.material.color.copy(this.light.color);
  21113. }
  21114. },
  21115. nL = class extends tr {
  21116. constructor(e, t, i) {
  21117. let r = new yg(t, 4, 2),
  21118. s = new Ph({ wireframe: !0, fog: !1, toneMapped: !1 });
  21119. super(r, s),
  21120. (this.light = e),
  21121. (this.color = i),
  21122. (this.type = 'PointLightHelper'),
  21123. (this.matrix = this.light.matrixWorld),
  21124. (this.matrixAutoUpdate = !1),
  21125. this.update();
  21126. }
  21127. dispose() {
  21128. this.geometry.dispose(), this.material.dispose();
  21129. }
  21130. update() {
  21131. this.light.updateWorldMatrix(!0, !1),
  21132. this.color !== void 0 ? this.material.color.set(this.color) : this.material.color.copy(this.light.color);
  21133. }
  21134. },
  21135. Dy = new E(),
  21136. gc = new E(),
  21137. Ly = new E(),
  21138. aL = class extends bt {
  21139. constructor(e, t, i) {
  21140. super(),
  21141. (this.light = e),
  21142. (this.matrix = e.matrixWorld),
  21143. (this.matrixAutoUpdate = !1),
  21144. (this.color = i),
  21145. (this.type = 'DirectionalLightHelper'),
  21146. t === void 0 && (t = 1);
  21147. let r = new Ve();
  21148. r.setAttribute('position', new Ce([-t, t, 0, t, t, 0, t, -t, 0, -t, -t, 0, -t, t, 0], 3));
  21149. let s = new Rn({ fog: !1, toneMapped: !1 });
  21150. (this.lightPlane = new vd(r, s)),
  21151. this.add(this.lightPlane),
  21152. (r = new Ve()),
  21153. r.setAttribute('position', new Ce([0, 0, 0, 0, 0, 1], 3)),
  21154. (this.targetLine = new vd(r, s)),
  21155. this.add(this.targetLine),
  21156. this.update();
  21157. }
  21158. dispose() {
  21159. this.lightPlane.geometry.dispose(),
  21160. this.lightPlane.material.dispose(),
  21161. this.targetLine.geometry.dispose(),
  21162. this.targetLine.material.dispose();
  21163. }
  21164. update() {
  21165. this.light.updateWorldMatrix(!0, !1),
  21166. this.light.target.updateWorldMatrix(!0, !1),
  21167. Dy.setFromMatrixPosition(this.light.matrixWorld),
  21168. gc.setFromMatrixPosition(this.light.target.matrixWorld),
  21169. Ly.subVectors(gc, Dy),
  21170. this.lightPlane.lookAt(gc),
  21171. this.color !== void 0
  21172. ? (this.lightPlane.material.color.set(this.color), this.targetLine.material.color.set(this.color))
  21173. : (this.lightPlane.material.color.copy(this.light.color), this.targetLine.material.color.copy(this.light.color)),
  21174. this.targetLine.lookAt(gc),
  21175. (this.targetLine.scale.z = Ly.length());
  21176. }
  21177. },
  21178. vc = new E(),
  21179. Rt = new Yo(),
  21180. bd = class extends Dh {
  21181. constructor(e) {
  21182. let t = new Ve(),
  21183. i = new Rn({ color: 16777215, vertexColors: !0, toneMapped: !1 }),
  21184. r = [],
  21185. s = [],
  21186. n = {};
  21187. a('n1', 'n2'),
  21188. a('n2', 'n4'),
  21189. a('n4', 'n3'),
  21190. a('n3', 'n1'),
  21191. a('f1', 'f2'),
  21192. a('f2', 'f4'),
  21193. a('f4', 'f3'),
  21194. a('f3', 'f1'),
  21195. a('n1', 'f1'),
  21196. a('n2', 'f2'),
  21197. a('n3', 'f3'),
  21198. a('n4', 'f4'),
  21199. a('p', 'n1'),
  21200. a('p', 'n2'),
  21201. a('p', 'n3'),
  21202. a('p', 'n4'),
  21203. a('u1', 'u2'),
  21204. a('u2', 'u3'),
  21205. a('u3', 'u1'),
  21206. a('c', 't'),
  21207. a('p', 'c'),
  21208. a('cn1', 'cn2'),
  21209. a('cn3', 'cn4'),
  21210. a('cf1', 'cf2'),
  21211. a('cf3', 'cf4');
  21212. function a(p, f) {
  21213. o(p), o(f);
  21214. }
  21215. function o(p) {
  21216. r.push(0, 0, 0), s.push(0, 0, 0), n[p] === void 0 && (n[p] = []), n[p].push(r.length / 3 - 1);
  21217. }
  21218. t.setAttribute('position', new Ce(r, 3)),
  21219. t.setAttribute('color', new Ce(s, 3)),
  21220. super(t, i),
  21221. (this.type = 'CameraHelper'),
  21222. (this.camera = e),
  21223. this.camera.updateProjectionMatrix && this.camera.updateProjectionMatrix(),
  21224. (this.matrix = e.matrixWorld),
  21225. (this.matrixAutoUpdate = !1),
  21226. (this.pointMap = n),
  21227. this.update();
  21228. let l = new Ge(16755200),
  21229. h = new Ge(16711680),
  21230. u = new Ge(43775),
  21231. c = new Ge(16777215),
  21232. d = new Ge(3355443);
  21233. this.setColors(l, h, u, c, d);
  21234. }
  21235. setColors(e, t, i, r, s) {
  21236. let n = this.geometry.getAttribute('color');
  21237. n.setXYZ(0, e.r, e.g, e.b),
  21238. n.setXYZ(1, e.r, e.g, e.b),
  21239. n.setXYZ(2, e.r, e.g, e.b),
  21240. n.setXYZ(3, e.r, e.g, e.b),
  21241. n.setXYZ(4, e.r, e.g, e.b),
  21242. n.setXYZ(5, e.r, e.g, e.b),
  21243. n.setXYZ(6, e.r, e.g, e.b),
  21244. n.setXYZ(7, e.r, e.g, e.b),
  21245. n.setXYZ(8, e.r, e.g, e.b),
  21246. n.setXYZ(9, e.r, e.g, e.b),
  21247. n.setXYZ(10, e.r, e.g, e.b),
  21248. n.setXYZ(11, e.r, e.g, e.b),
  21249. n.setXYZ(12, e.r, e.g, e.b),
  21250. n.setXYZ(13, e.r, e.g, e.b),
  21251. n.setXYZ(14, e.r, e.g, e.b),
  21252. n.setXYZ(15, e.r, e.g, e.b),
  21253. n.setXYZ(16, e.r, e.g, e.b),
  21254. n.setXYZ(17, e.r, e.g, e.b),
  21255. n.setXYZ(18, e.r, e.g, e.b),
  21256. n.setXYZ(19, e.r, e.g, e.b),
  21257. n.setXYZ(20, e.r, e.g, e.b),
  21258. n.setXYZ(21, e.r, e.g, e.b),
  21259. n.setXYZ(22, e.r, e.g, e.b),
  21260. n.setXYZ(23, e.r, e.g, e.b),
  21261. n.setXYZ(24, t.r, t.g, t.b),
  21262. n.setXYZ(25, t.r, t.g, t.b),
  21263. n.setXYZ(26, t.r, t.g, t.b),
  21264. n.setXYZ(27, t.r, t.g, t.b),
  21265. n.setXYZ(28, t.r, t.g, t.b),
  21266. n.setXYZ(29, t.r, t.g, t.b),
  21267. n.setXYZ(30, t.r, t.g, t.b),
  21268. n.setXYZ(31, t.r, t.g, t.b),
  21269. n.setXYZ(32, i.r, i.g, i.b),
  21270. n.setXYZ(33, i.r, i.g, i.b),
  21271. n.setXYZ(34, i.r, i.g, i.b),
  21272. n.setXYZ(35, i.r, i.g, i.b),
  21273. n.setXYZ(36, i.r, i.g, i.b),
  21274. n.setXYZ(37, i.r, i.g, i.b),
  21275. n.setXYZ(38, r.r, r.g, r.b),
  21276. n.setXYZ(39, r.r, r.g, r.b),
  21277. n.setXYZ(40, s.r, s.g, s.b),
  21278. n.setXYZ(41, s.r, s.g, s.b),
  21279. n.setXYZ(42, s.r, s.g, s.b),
  21280. n.setXYZ(43, s.r, s.g, s.b),
  21281. n.setXYZ(44, s.r, s.g, s.b),
  21282. n.setXYZ(45, s.r, s.g, s.b),
  21283. n.setXYZ(46, s.r, s.g, s.b),
  21284. n.setXYZ(47, s.r, s.g, s.b),
  21285. n.setXYZ(48, s.r, s.g, s.b),
  21286. n.setXYZ(49, s.r, s.g, s.b),
  21287. (n.needsUpdate = !0);
  21288. }
  21289. update() {
  21290. let e = this.geometry,
  21291. t = this.pointMap,
  21292. i = 1,
  21293. r = 1;
  21294. Rt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),
  21295. kt('c', t, e, Rt, 0, 0, -1),
  21296. kt('t', t, e, Rt, 0, 0, 1),
  21297. kt('n1', t, e, Rt, -i, -r, -1),
  21298. kt('n2', t, e, Rt, i, -r, -1),
  21299. kt('n3', t, e, Rt, -i, r, -1),
  21300. kt('n4', t, e, Rt, i, r, -1),
  21301. kt('f1', t, e, Rt, -i, -r, 1),
  21302. kt('f2', t, e, Rt, i, -r, 1),
  21303. kt('f3', t, e, Rt, -i, r, 1),
  21304. kt('f4', t, e, Rt, i, r, 1),
  21305. kt('u1', t, e, Rt, i * 0.7, r * 1.1, -1),
  21306. kt('u2', t, e, Rt, -i * 0.7, r * 1.1, -1),
  21307. kt('u3', t, e, Rt, 0, r * 2, -1),
  21308. kt('cf1', t, e, Rt, -i, 0, 1),
  21309. kt('cf2', t, e, Rt, i, 0, 1),
  21310. kt('cf3', t, e, Rt, 0, -r, 1),
  21311. kt('cf4', t, e, Rt, 0, r, 1),
  21312. kt('cn1', t, e, Rt, -i, 0, -1),
  21313. kt('cn2', t, e, Rt, i, 0, -1),
  21314. kt('cn3', t, e, Rt, 0, -r, -1),
  21315. kt('cn4', t, e, Rt, 0, r, -1),
  21316. (e.getAttribute('position').needsUpdate = !0);
  21317. }
  21318. dispose() {
  21319. this.geometry.dispose(), this.material.dispose();
  21320. }
  21321. };
  21322. function kt(e, t, i, r, s, n, a) {
  21323. vc.set(s, n, a).unproject(r);
  21324. let o = t[e];
  21325. if (o !== void 0) {
  21326. let l = i.getAttribute('position');
  21327. for (let h = 0, u = o.length; h < u; h++) l.setXYZ(o[h], vc.x, vc.y, vc.z);
  21328. }
  21329. }
  21330. var wd = class extends Dh {
  21331. constructor(e, t = 16776960) {
  21332. 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]),
  21333. 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],
  21334. s = new Ve();
  21335. s.setIndex(new Xe(i, 1)),
  21336. s.setAttribute('position', new Ce(r, 3)),
  21337. super(s, new Rn({ color: t, toneMapped: !1 })),
  21338. (this.box = e),
  21339. (this.type = 'Box3Helper'),
  21340. this.geometry.computeBoundingSphere();
  21341. }
  21342. updateMatrixWorld(e) {
  21343. let t = this.box;
  21344. t.isEmpty() || (t.getCenter(this.position), t.getSize(this.scale), this.scale.multiplyScalar(0.5), super.updateMatrixWorld(e));
  21345. }
  21346. dispose() {
  21347. this.geometry.dispose(), this.material.dispose();
  21348. }
  21349. },
  21350. oL = class extends Dh {
  21351. constructor(e = 1) {
  21352. let t = [0, 0, 0, e, 0, 0, 0, 0, 0, 0, e, 0, 0, 0, 0, 0, 0, e],
  21353. i = [1, 0, 0, 1, 0.6, 0, 0, 1, 0, 0.6, 1, 0, 0, 0, 1, 0, 0.6, 1],
  21354. r = new Ve();
  21355. r.setAttribute('position', new Ce(t, 3)), r.setAttribute('color', new Ce(i, 3));
  21356. let s = new Rn({ vertexColors: !0, toneMapped: !1 });
  21357. super(r, s), (this.type = 'AxesHelper');
  21358. }
  21359. setColors(e, t, i) {
  21360. let r = new Ge(),
  21361. s = this.geometry.attributes.color.array;
  21362. return (
  21363. r.set(e),
  21364. r.toArray(s, 0),
  21365. r.toArray(s, 3),
  21366. r.set(t),
  21367. r.toArray(s, 6),
  21368. r.toArray(s, 9),
  21369. r.set(i),
  21370. r.toArray(s, 12),
  21371. r.toArray(s, 15),
  21372. (this.geometry.attributes.color.needsUpdate = !0),
  21373. this
  21374. );
  21375. }
  21376. dispose() {
  21377. this.geometry.dispose(), this.material.dispose();
  21378. }
  21379. };
  21380. typeof __THREE_DEVTOOLS__ < 'u' && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('register', { detail: { revision: Wo } }));
  21381. typeof window < 'u' &&
  21382. (window.__THREE__ ? console.warn('WARNING: Multiple instances of Three.js being imported.') : (window.__THREE__ = Wo));
  21383. var xl = '.',
  21384. Sg = Symbol('target'),
  21385. jw = Symbol('unsubscribe');
  21386. function Yf(e) {
  21387. return e instanceof Date || e instanceof Set || e instanceof Map || e instanceof WeakSet || e instanceof WeakMap || ArrayBuffer.isView(e);
  21388. }
  21389. function lL(e) {
  21390. return (typeof e == 'object' ? e === null : typeof e != 'function') || e instanceof RegExp;
  21391. }
  21392. var as = Array.isArray;
  21393. function Mg(e) {
  21394. return typeof e == 'symbol';
  21395. }
  21396. var hL = {
  21397. after: (e, t) => (as(e) ? e.slice(t.length) : t === '' ? e : e.slice(t.length + 1)),
  21398. concat: (e, t) =>
  21399. as(e)
  21400. ? ((e = [...e]), t && e.push(t), e)
  21401. : t && t.toString !== void 0
  21402. ? (e !== '' && (e += xl), Mg(t) ? e + t.toString() : e + t)
  21403. : e,
  21404. initial: (e) => {
  21405. if (as(e)) return e.slice(0, -1);
  21406. if (e === '') return e;
  21407. let t = e.lastIndexOf(xl);
  21408. return t === -1 ? '' : e.slice(0, t);
  21409. },
  21410. last: (e) => {
  21411. if (as(e)) return e[e.length - 1] || '';
  21412. if (e === '') return e;
  21413. let t = e.lastIndexOf(xl);
  21414. return t === -1 ? e : e.slice(t + 1);
  21415. },
  21416. walk: (e, t) => {
  21417. if (as(e)) for (let i of e) t(i);
  21418. else if (e !== '') {
  21419. let i = 0,
  21420. r = e.indexOf(xl);
  21421. if (r === -1) t(e);
  21422. else for (; i < e.length; ) r === -1 && (r = e.length), t(e.slice(i, r)), (i = r + 1), (r = e.indexOf(xl, i));
  21423. }
  21424. },
  21425. get(e, t) {
  21426. return (
  21427. this.walk(t, (i) => {
  21428. e && (e = e[i]);
  21429. }),
  21430. e
  21431. );
  21432. }
  21433. },
  21434. mr = hL;
  21435. function cL(e) {
  21436. return typeof e == 'object' && typeof e.next == 'function';
  21437. }
  21438. function dL(e, t, i, r, s) {
  21439. let n = e.next;
  21440. if (t.name === 'entries')
  21441. e.next = function () {
  21442. let a = n.call(this);
  21443. return a.done === !1 && ((a.value[0] = s(a.value[0], t, a.value[0], r)), (a.value[1] = s(a.value[1], t, a.value[0], r))), a;
  21444. };
  21445. else if (t.name === 'values') {
  21446. let a = i[Sg].keys();
  21447. e.next = function () {
  21448. let o = n.call(this);
  21449. return o.done === !1 && (o.value = s(o.value, t, a.next().value, r)), o;
  21450. };
  21451. } else
  21452. e.next = function () {
  21453. let a = n.call(this);
  21454. return a.done === !1 && (a.value = s(a.value, t, a.value, r)), a;
  21455. };
  21456. return e;
  21457. }
  21458. function Oy(e, t, i) {
  21459. return (
  21460. e.isUnsubscribed ||
  21461. (t.ignoreSymbols && Mg(i)) ||
  21462. (t.ignoreUnderscores && i.charAt(0) === '_') ||
  21463. ('ignoreKeys' in t && t.ignoreKeys.includes(i))
  21464. );
  21465. }
  21466. var uL = class {
  21467. constructor(e) {
  21468. (this._equals = e), (this._proxyCache = new WeakMap()), (this._pathCache = new WeakMap()), (this.isUnsubscribed = !1);
  21469. }
  21470. _getDescriptorCache() {
  21471. return this._descriptorCache === void 0 && (this._descriptorCache = new WeakMap()), this._descriptorCache;
  21472. }
  21473. _getProperties(e) {
  21474. let t = this._getDescriptorCache(),
  21475. i = t.get(e);
  21476. return i === void 0 && ((i = {}), t.set(e, i)), i;
  21477. }
  21478. _getOwnPropertyDescriptor(e, t) {
  21479. if (this.isUnsubscribed) return Reflect.getOwnPropertyDescriptor(e, t);
  21480. let i = this._getProperties(e),
  21481. r = i[t];
  21482. return r === void 0 && ((r = Reflect.getOwnPropertyDescriptor(e, t)), (i[t] = r)), r;
  21483. }
  21484. getProxy(e, t, i, r) {
  21485. if (this.isUnsubscribed) return e;
  21486. let s = e[r],
  21487. n = s || e;
  21488. this._pathCache.set(n, t);
  21489. let a = this._proxyCache.get(n);
  21490. return a === void 0 && ((a = s === void 0 ? new Proxy(e, i) : e), this._proxyCache.set(n, a)), a;
  21491. }
  21492. getPath(e) {
  21493. return this.isUnsubscribed ? void 0 : this._pathCache.get(e);
  21494. }
  21495. isDetached(e, t) {
  21496. return !Object.is(e, mr.get(t, this.getPath(e)));
  21497. }
  21498. defineProperty(e, t, i) {
  21499. return Reflect.defineProperty(e, t, i) ? (this.isUnsubscribed || (this._getProperties(e)[t] = i), !0) : !1;
  21500. }
  21501. setProperty(e, t, i, r, s) {
  21502. if (!this._equals(s, i) || !(t in e)) {
  21503. let n = this._getOwnPropertyDescriptor(e, t);
  21504. return n !== void 0 && 'set' in n ? Reflect.set(e, t, i, r) : Reflect.set(e, t, i);
  21505. }
  21506. return !0;
  21507. }
  21508. deleteProperty(e, t, i) {
  21509. if (Reflect.deleteProperty(e, t)) {
  21510. if (!this.isUnsubscribed) {
  21511. let r = this._getDescriptorCache().get(e);
  21512. r && (delete r[t], this._pathCache.delete(i));
  21513. }
  21514. return !0;
  21515. }
  21516. return !1;
  21517. }
  21518. isSameDescriptor(e, t, i) {
  21519. let r = this._getOwnPropertyDescriptor(t, i);
  21520. return (
  21521. e !== void 0 &&
  21522. r !== void 0 &&
  21523. Object.is(e.value, r.value) &&
  21524. (e.writable || !1) === (r.writable || !1) &&
  21525. (e.enumerable || !1) === (r.enumerable || !1) &&
  21526. (e.configurable || !1) === (r.configurable || !1) &&
  21527. e.get === r.get &&
  21528. e.set === r.set
  21529. );
  21530. }
  21531. isGetInvariant(e, t) {
  21532. let i = this._getOwnPropertyDescriptor(e, t);
  21533. return i !== void 0 && i.configurable !== !0 && i.writable !== !0;
  21534. }
  21535. unsubscribe() {
  21536. (this._descriptorCache = null), (this._pathCache = null), (this._proxyCache = null), (this.isUnsubscribed = !0);
  21537. }
  21538. };
  21539. function Qf(e) {
  21540. return toString.call(e) === '[object Object]';
  21541. }
  21542. function yc() {
  21543. return !0;
  21544. }
  21545. function Ya(e, t) {
  21546. return e.length !== t.length || e.some((i, r) => t[r] !== i);
  21547. }
  21548. var Gw = new Set(['hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']),
  21549. pL = new Set(['concat', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf']),
  21550. Vw = { push: yc, pop: yc, shift: yc, unshift: yc, copyWithin: Ya, reverse: Ya, sort: Ya, splice: Ya, flat: Ya, fill: Ya },
  21551. fL = new Set([...Gw, ...pL, ...Object.keys(Vw)]);
  21552. function xc(e, t) {
  21553. if (e.size !== t.size) return !0;
  21554. for (let i of e) if (!t.has(i)) return !0;
  21555. return !1;
  21556. }
  21557. var Hw = ['keys', 'values', 'entries'],
  21558. Ww = new Set(['has', 'toString']),
  21559. Xw = { add: xc, clear: xc, delete: xc, forEach: xc },
  21560. mL = new Set([...Ww, ...Object.keys(Xw), ...Hw]);
  21561. function bc(e, t) {
  21562. if (e.size !== t.size) return !0;
  21563. let i;
  21564. for (let [r, s] of e) if (((i = t.get(r)), i !== s || (i === void 0 && !t.has(r)))) return !0;
  21565. return !1;
  21566. }
  21567. var gL = new Set([...Ww, 'get']),
  21568. qw = { set: bc, clear: bc, delete: bc, forEach: bc },
  21569. vL = new Set([...gL, ...Object.keys(qw), ...Hw]),
  21570. Dn = class {
  21571. constructor(e, t, i, r) {
  21572. (this._path = t),
  21573. (this._isChanged = !1),
  21574. (this._clonedCache = new Set()),
  21575. (this._hasOnValidate = r),
  21576. (this._changes = r ? [] : null),
  21577. (this.clone = t === void 0 ? e : this._shallowClone(e));
  21578. }
  21579. static isHandledMethod(e) {
  21580. return Gw.has(e);
  21581. }
  21582. _shallowClone(e) {
  21583. let t = e;
  21584. if (Qf(e)) t = { ...e };
  21585. else if (as(e)) t = [...e];
  21586. else if (e instanceof Date) t = new Date(e);
  21587. else if (e instanceof Set) t = new Set([...e].map((i) => this._shallowClone(i)));
  21588. else if (e instanceof Map) {
  21589. t = new Map();
  21590. for (let [i, r] of e.entries()) t.set(i, this._shallowClone(r));
  21591. }
  21592. return this._clonedCache.add(t), t;
  21593. }
  21594. preferredThisArg(e, t, i, r) {
  21595. return e
  21596. ? (as(r)
  21597. ? (this._onIsChanged = Vw[t])
  21598. : r instanceof Set
  21599. ? (this._onIsChanged = Xw[t])
  21600. : r instanceof Map && (this._onIsChanged = qw[t]),
  21601. r)
  21602. : i;
  21603. }
  21604. update(e, t, i) {
  21605. let r = mr.after(e, this._path);
  21606. if (t !== 'length') {
  21607. let s = this.clone;
  21608. mr.walk(r, (n) => {
  21609. s && s[n] && (this._clonedCache.has(s[n]) || (s[n] = this._shallowClone(s[n])), (s = s[n]));
  21610. }),
  21611. this._hasOnValidate && this._changes.push({ path: r, property: t, previous: i }),
  21612. s && s[t] && (s[t] = i);
  21613. }
  21614. this._isChanged = !0;
  21615. }
  21616. undo(e) {
  21617. let t;
  21618. for (let i = this._changes.length - 1; i !== -1; i--) (t = this._changes[i]), (mr.get(e, t.path)[t.property] = t.previous);
  21619. }
  21620. isChanged(e) {
  21621. return this._onIsChanged === void 0 ? this._isChanged : this._onIsChanged(this.clone, e);
  21622. }
  21623. },
  21624. Iy = class extends Dn {
  21625. static isHandledMethod(e) {
  21626. return fL.has(e);
  21627. }
  21628. },
  21629. yL = class extends Dn {
  21630. undo(e) {
  21631. e.setTime(this.clone.getTime());
  21632. }
  21633. isChanged(e, t) {
  21634. return !t(this.clone.valueOf(), e.valueOf());
  21635. }
  21636. },
  21637. Ry = class extends Dn {
  21638. static isHandledMethod(e) {
  21639. return mL.has(e);
  21640. }
  21641. undo(e) {
  21642. for (let t of this.clone) e.add(t);
  21643. for (let t of e) this.clone.has(t) || e.delete(t);
  21644. }
  21645. },
  21646. By = class extends Dn {
  21647. static isHandledMethod(e) {
  21648. return vL.has(e);
  21649. }
  21650. undo(e) {
  21651. for (let [t, i] of this.clone.entries()) e.set(t, i);
  21652. for (let t of e.keys()) this.clone.has(t) || e.delete(t);
  21653. }
  21654. },
  21655. xL = class extends Dn {
  21656. constructor(e, t, i, r) {
  21657. super(void 0, t, i, r), (this._arg1 = i[0]), (this._weakValue = e.has(this._arg1));
  21658. }
  21659. isChanged(e) {
  21660. return this._weakValue !== e.has(this._arg1);
  21661. }
  21662. undo(e) {
  21663. this._weakValue && !e.has(this._arg1) ? e.add(this._arg1) : e.delete(this._arg1);
  21664. }
  21665. },
  21666. bL = class extends Dn {
  21667. constructor(e, t, i, r) {
  21668. super(void 0, t, i, r), (this._weakKey = i[0]), (this._weakHas = e.has(this._weakKey)), (this._weakValue = e.get(this._weakKey));
  21669. }
  21670. isChanged(e) {
  21671. return this._weakValue !== e.get(this._weakKey);
  21672. }
  21673. undo(e) {
  21674. let t = e.has(this._weakKey);
  21675. this._weakHas && !t
  21676. ? e.set(this._weakKey, this._weakValue)
  21677. : !this._weakHas && t
  21678. ? e.delete(this._weakKey)
  21679. : this._weakValue !== e.get(this._weakKey) && e.set(this._weakKey, this._weakValue);
  21680. }
  21681. },
  21682. ao = class {
  21683. constructor(e) {
  21684. (this._stack = []), (this._hasOnValidate = e);
  21685. }
  21686. static isHandledType(e) {
  21687. return Qf(e) || as(e) || Yf(e);
  21688. }
  21689. static isHandledMethod(e, t) {
  21690. return Qf(e)
  21691. ? Dn.isHandledMethod(t)
  21692. : as(e)
  21693. ? Iy.isHandledMethod(t)
  21694. : e instanceof Set
  21695. ? Ry.isHandledMethod(t)
  21696. : e instanceof Map
  21697. ? By.isHandledMethod(t)
  21698. : Yf(e);
  21699. }
  21700. get isCloning() {
  21701. return this._stack.length > 0;
  21702. }
  21703. start(e, t, i) {
  21704. let r = Dn;
  21705. as(e)
  21706. ? (r = Iy)
  21707. : e instanceof Date
  21708. ? (r = yL)
  21709. : e instanceof Set
  21710. ? (r = Ry)
  21711. : e instanceof Map
  21712. ? (r = By)
  21713. : e instanceof WeakSet
  21714. ? (r = xL)
  21715. : e instanceof WeakMap && (r = bL),
  21716. this._stack.push(new r(e, t, i, this._hasOnValidate));
  21717. }
  21718. update(e, t, i) {
  21719. this._stack[this._stack.length - 1].update(e, t, i);
  21720. }
  21721. preferredThisArg(e, t, i) {
  21722. let { name: r } = e,
  21723. s = ao.isHandledMethod(i, r);
  21724. return this._stack[this._stack.length - 1].preferredThisArg(s, r, t, i);
  21725. }
  21726. isChanged(e, t, i) {
  21727. return this._stack[this._stack.length - 1].isChanged(e, t, i);
  21728. }
  21729. undo(e) {
  21730. this._previousClone !== void 0 && this._previousClone.undo(e);
  21731. }
  21732. stop() {
  21733. return (this._previousClone = this._stack.pop()), this._previousClone.clone;
  21734. }
  21735. },
  21736. wL = { equals: Object.is, isShallow: !1, pathAsArray: !1, ignoreSymbols: !1, ignoreUnderscores: !1, ignoreDetached: !1, details: !1 },
  21737. Eg = (e, t, i = {}) => {
  21738. i = { ...wL, ...i };
  21739. let r = Symbol('ProxyTarget'),
  21740. { equals: s, isShallow: n, ignoreDetached: a, details: o } = i,
  21741. l = new uL(s),
  21742. h = typeof i.onValidate == 'function',
  21743. u = new ao(h),
  21744. c = (y, b, x, w, A) => !h || u.isCloning || i.onValidate(mr.concat(l.getPath(y), b), x, w, A) === !0,
  21745. d = (y, b, x, w) => {
  21746. !Oy(l, i, b) && !(a && l.isDetached(y, e)) && p(l.getPath(y), b, x, w);
  21747. },
  21748. p = (y, b, x, w, A) => {
  21749. u.isCloning ? u.update(y, b, w) : t(mr.concat(y, b), x, w, A);
  21750. },
  21751. f = (y) => y && (y[r] || y),
  21752. g = (y, b, x, w) =>
  21753. lL(y) ||
  21754. x === 'constructor' ||
  21755. (n && !ao.isHandledMethod(b, x)) ||
  21756. Oy(l, i, x) ||
  21757. l.isGetInvariant(b, x) ||
  21758. (a && l.isDetached(b, e))
  21759. ? y
  21760. : (w === void 0 && (w = l.getPath(b)), l.getProxy(y, mr.concat(w, x), m, r)),
  21761. m = {
  21762. get(y, b, x) {
  21763. if (Mg(b)) {
  21764. if (b === r || b === Sg) return y;
  21765. if (b === jw && !l.isUnsubscribed && l.getPath(y).length === 0) return l.unsubscribe(), y;
  21766. }
  21767. let w = Yf(y) ? Reflect.get(y, b) : Reflect.get(y, b, x);
  21768. return g(w, y, b);
  21769. },
  21770. set(y, b, x, w) {
  21771. x = f(x);
  21772. let A = y[r] || y,
  21773. S = A[b];
  21774. if (s(S, x) && b in y) return !0;
  21775. let _ = c(y, b, x, S);
  21776. return _ && l.setProperty(A, b, x, w, S) ? (d(y, b, y[b], S), !0) : !_;
  21777. },
  21778. defineProperty(y, b, x) {
  21779. if (!l.isSameDescriptor(x, y, b)) {
  21780. let w = y[b];
  21781. c(y, b, x.value, w) && l.defineProperty(y, b, x, w) && d(y, b, x.value, w);
  21782. }
  21783. return !0;
  21784. },
  21785. deleteProperty(y, b) {
  21786. if (!Reflect.has(y, b)) return !0;
  21787. let x = Reflect.get(y, b),
  21788. w = c(y, b, void 0, x);
  21789. return w && l.deleteProperty(y, b, x) ? (d(y, b, void 0, x), !0) : !w;
  21790. },
  21791. apply(y, b, x) {
  21792. let w = b[r] || b;
  21793. if (l.isUnsubscribed) return Reflect.apply(y, w, x);
  21794. if ((o === !1 || (o !== !0 && !o.includes(y.name))) && ao.isHandledType(w)) {
  21795. let A = mr.initial(l.getPath(y)),
  21796. S = ao.isHandledMethod(w, y.name);
  21797. u.start(w, A, x);
  21798. let _ = Reflect.apply(y, u.preferredThisArg(y, b, w), S ? x.map((T) => f(T)) : x),
  21799. M = u.isChanged(w, s),
  21800. C = u.stop();
  21801. if (
  21802. (ao.isHandledType(_) && S && (b instanceof Map && y.name === 'get' && (A = mr.concat(A, x[0])), (_ = l.getProxy(_, A, m))), M)
  21803. ) {
  21804. let T = { name: y.name, args: x, result: _ },
  21805. P = u.isCloning ? mr.initial(A) : A,
  21806. L = u.isCloning ? mr.last(A) : '';
  21807. c(mr.get(e, P), L, w, C, T) ? p(P, L, w, C, T) : u.undo(w);
  21808. }
  21809. return (b instanceof Map || b instanceof Set) && cL(_) ? dL(_, y, b, A, g) : _;
  21810. }
  21811. return Reflect.apply(y, b, x);
  21812. }
  21813. },
  21814. v = l.getProxy(e, i.pathAsArray ? [] : '', m);
  21815. return (t = t.bind(v)), h && (i.onValidate = i.onValidate.bind(v)), v;
  21816. };
  21817. Eg.target = (e) => (e && e[Sg]) || e;
  21818. Eg.unsubscribe = (e) => e[jw] || e;
  21819. var zy = Eg,
  21820. _L = typeof global == 'object' && global && global.Object === Object && global,
  21821. Yw = _L,
  21822. AL = typeof self == 'object' && self && self.Object === Object && self,
  21823. SL = Yw || AL || Function('return this')(),
  21824. Hr = SL,
  21825. ML = Hr.Symbol,
  21826. Er = ML,
  21827. Qw = Object.prototype,
  21828. EL = Qw.hasOwnProperty,
  21829. CL = Qw.toString,
  21830. bl = Er ? Er.toStringTag : void 0;
  21831. function TL(e) {
  21832. var t = EL.call(e, bl),
  21833. i = e[bl];
  21834. try {
  21835. e[bl] = void 0;
  21836. var r = !0;
  21837. } catch {}
  21838. var s = CL.call(e);
  21839. return r && (t ? (e[bl] = i) : delete e[bl]), s;
  21840. }
  21841. var PL = TL,
  21842. DL = Object.prototype,
  21843. LL = DL.toString;
  21844. function OL(e) {
  21845. return LL.call(e);
  21846. }
  21847. var IL = OL,
  21848. RL = '[object Null]',
  21849. BL = '[object Undefined]',
  21850. Ny = Er ? Er.toStringTag : void 0;
  21851. function zL(e) {
  21852. return e == null ? (e === void 0 ? BL : RL) : Ny && Ny in Object(e) ? PL(e) : IL(e);
  21853. }
  21854. var Ma = zL;
  21855. function NL(e) {
  21856. return e != null && typeof e == 'object';
  21857. }
  21858. var Ws = NL,
  21859. UL = '[object Symbol]';
  21860. function FL(e) {
  21861. return typeof e == 'symbol' || (Ws(e) && Ma(e) == UL);
  21862. }
  21863. var uu = FL;
  21864. function kL(e, t) {
  21865. for (var i = -1, r = e == null ? 0 : e.length, s = Array(r); ++i < r; ) s[i] = t(e[i], i, e);
  21866. return s;
  21867. }
  21868. var Zw = kL,
  21869. jL = Array.isArray,
  21870. ys = jL,
  21871. GL = 1 / 0,
  21872. Uy = Er ? Er.prototype : void 0,
  21873. Fy = Uy ? Uy.toString : void 0;
  21874. function Kw(e) {
  21875. if (typeof e == 'string') return e;
  21876. if (ys(e)) return Zw(e, Kw) + '';
  21877. if (uu(e)) return Fy ? Fy.call(e) : '';
  21878. var t = e + '';
  21879. return t == '0' && 1 / e == -GL ? '-0' : t;
  21880. }
  21881. var VL = Kw,
  21882. HL = /\s/;
  21883. function WL(e) {
  21884. for (var t = e.length; t-- && HL.test(e.charAt(t)); );
  21885. return t;
  21886. }
  21887. var XL = WL,
  21888. qL = /^\s+/;
  21889. function YL(e) {
  21890. return e && e.slice(0, XL(e) + 1).replace(qL, '');
  21891. }
  21892. var QL = YL;
  21893. function ZL(e) {
  21894. var t = typeof e;
  21895. return e != null && (t == 'object' || t == 'function');
  21896. }
  21897. var xs = ZL,
  21898. ky = 0 / 0,
  21899. KL = /^[-+]0x[0-9a-f]+$/i,
  21900. JL = /^0b[01]+$/i,
  21901. $L = /^0o[0-7]+$/i,
  21902. eO = parseInt;
  21903. function tO(e) {
  21904. if (typeof e == 'number') return e;
  21905. if (uu(e)) return ky;
  21906. if (xs(e)) {
  21907. var t = typeof e.valueOf == 'function' ? e.valueOf() : e;
  21908. e = xs(t) ? t + '' : t;
  21909. }
  21910. if (typeof e != 'string') return e === 0 ? e : +e;
  21911. e = QL(e);
  21912. var i = JL.test(e);
  21913. return i || $L.test(e) ? eO(e.slice(2), i ? 2 : 8) : KL.test(e) ? ky : +e;
  21914. }
  21915. var jy = tO;
  21916. function iO(e) {
  21917. return e;
  21918. }
  21919. var rO = iO,
  21920. sO = '[object AsyncFunction]',
  21921. nO = '[object Function]',
  21922. aO = '[object GeneratorFunction]',
  21923. oO = '[object Proxy]';
  21924. function lO(e) {
  21925. if (!xs(e)) return !1;
  21926. var t = Ma(e);
  21927. return t == nO || t == aO || t == sO || t == oO;
  21928. }
  21929. var Jw = lO,
  21930. hO = Hr['__core-js_shared__'],
  21931. Pp = hO,
  21932. Gy = (function () {
  21933. var e = /[^.]+$/.exec((Pp && Pp.keys && Pp.keys.IE_PROTO) || '');
  21934. return e ? 'Symbol(src)_1.' + e : '';
  21935. })();
  21936. function cO(e) {
  21937. return !!Gy && Gy in e;
  21938. }
  21939. var dO = cO,
  21940. uO = Function.prototype,
  21941. pO = uO.toString;
  21942. function fO(e) {
  21943. if (e != null) {
  21944. try {
  21945. return pO.call(e);
  21946. } catch {}
  21947. try {
  21948. return e + '';
  21949. } catch {}
  21950. }
  21951. return '';
  21952. }
  21953. var Ea = fO,
  21954. mO = /[\\^$.*+?()[\]{}|]/g,
  21955. gO = /^\[object .+?Constructor\]$/,
  21956. vO = Function.prototype,
  21957. yO = Object.prototype,
  21958. xO = vO.toString,
  21959. bO = yO.hasOwnProperty,
  21960. wO = RegExp(
  21961. '^' +
  21962. xO
  21963. .call(bO)
  21964. .replace(mO, '\\$&')
  21965. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') +
  21966. '$'
  21967. );
  21968. function _O(e) {
  21969. if (!xs(e) || dO(e)) return !1;
  21970. var t = Jw(e) ? wO : gO;
  21971. return t.test(Ea(e));
  21972. }
  21973. var AO = _O;
  21974. function SO(e, t) {
  21975. return e?.[t];
  21976. }
  21977. var MO = SO;
  21978. function EO(e, t) {
  21979. var i = MO(e, t);
  21980. return AO(i) ? i : void 0;
  21981. }
  21982. var Ca = EO,
  21983. CO = Ca(Hr, 'WeakMap'),
  21984. Zf = CO,
  21985. Vy = Object.create,
  21986. TO = (function () {
  21987. function e() {}
  21988. return function (t) {
  21989. if (!xs(t)) return {};
  21990. if (Vy) return Vy(t);
  21991. e.prototype = t;
  21992. var i = new e();
  21993. return (e.prototype = void 0), i;
  21994. };
  21995. })(),
  21996. PO = TO;
  21997. function DO(e, t, i) {
  21998. switch (i.length) {
  21999. case 0:
  22000. return e.call(t);
  22001. case 1:
  22002. return e.call(t, i[0]);
  22003. case 2:
  22004. return e.call(t, i[0], i[1]);
  22005. case 3:
  22006. return e.call(t, i[0], i[1], i[2]);
  22007. }
  22008. return e.apply(t, i);
  22009. }
  22010. var LO = DO;
  22011. function OO(e, t) {
  22012. var i = -1,
  22013. r = e.length;
  22014. for (t || (t = Array(r)); ++i < r; ) t[i] = e[i];
  22015. return t;
  22016. }
  22017. var IO = OO,
  22018. RO = 800,
  22019. BO = 16,
  22020. zO = Date.now;
  22021. function NO(e) {
  22022. var t = 0,
  22023. i = 0;
  22024. return function () {
  22025. var r = zO(),
  22026. s = BO - (r - i);
  22027. if (((i = r), s > 0)) {
  22028. if (++t >= RO) return arguments[0];
  22029. } else t = 0;
  22030. return e.apply(void 0, arguments);
  22031. };
  22032. }
  22033. var UO = NO;
  22034. function FO(e) {
  22035. return function () {
  22036. return e;
  22037. };
  22038. }
  22039. var kO = FO,
  22040. jO = (function () {
  22041. try {
  22042. var e = Ca(Object, 'defineProperty');
  22043. return e({}, '', {}), e;
  22044. } catch {}
  22045. })(),
  22046. _d = jO,
  22047. GO = _d
  22048. ? function (e, t) {
  22049. return _d(e, 'toString', { configurable: !0, enumerable: !1, value: kO(t), writable: !0 });
  22050. }
  22051. : rO,
  22052. VO = GO,
  22053. HO = UO(VO),
  22054. WO = HO;
  22055. function XO(e, t) {
  22056. for (var i = -1, r = e == null ? 0 : e.length; ++i < r && t(e[i], i, e) !== !1; );
  22057. return e;
  22058. }
  22059. var qO = XO,
  22060. YO = 9007199254740991,
  22061. QO = /^(?:0|[1-9]\d*)$/;
  22062. function ZO(e, t) {
  22063. var i = typeof e;
  22064. return (t = t ?? YO), !!t && (i == 'number' || (i != 'symbol' && QO.test(e))) && e > -1 && e % 1 == 0 && e < t;
  22065. }
  22066. var Cg = ZO;
  22067. function KO(e, t, i) {
  22068. t == '__proto__' && _d ? _d(e, t, { configurable: !0, enumerable: !0, value: i, writable: !0 }) : (e[t] = i);
  22069. }
  22070. var $w = KO;
  22071. function JO(e, t) {
  22072. return e === t || (e !== e && t !== t);
  22073. }
  22074. var Tg = JO,
  22075. $O = Object.prototype,
  22076. eI = $O.hasOwnProperty;
  22077. function tI(e, t, i) {
  22078. var r = e[t];
  22079. (!(eI.call(e, t) && Tg(r, i)) || (i === void 0 && !(t in e))) && $w(e, t, i);
  22080. }
  22081. var Pg = tI;
  22082. function iI(e, t, i, r) {
  22083. var s = !i;
  22084. i || (i = {});
  22085. for (var n = -1, a = t.length; ++n < a; ) {
  22086. var o = t[n],
  22087. l = r ? r(i[o], e[o], o, i, e) : void 0;
  22088. l === void 0 && (l = e[o]), s ? $w(i, o, l) : Pg(i, o, l);
  22089. }
  22090. return i;
  22091. }
  22092. var Rh = iI,
  22093. Hy = Math.max;
  22094. function rI(e, t, i) {
  22095. return (
  22096. (t = Hy(t === void 0 ? e.length - 1 : t, 0)),
  22097. function () {
  22098. for (var r = arguments, s = -1, n = Hy(r.length - t, 0), a = Array(n); ++s < n; ) a[s] = r[t + s];
  22099. s = -1;
  22100. for (var o = Array(t + 1); ++s < t; ) o[s] = r[s];
  22101. return (o[t] = i(a)), LO(e, this, o);
  22102. }
  22103. );
  22104. }
  22105. var sI = rI,
  22106. nI = 9007199254740991;
  22107. function aI(e) {
  22108. return typeof e == 'number' && e > -1 && e % 1 == 0 && e <= nI;
  22109. }
  22110. var Dg = aI;
  22111. function oI(e) {
  22112. return e != null && Dg(e.length) && !Jw(e);
  22113. }
  22114. var e_ = oI,
  22115. lI = Object.prototype;
  22116. function hI(e) {
  22117. var t = e && e.constructor,
  22118. i = (typeof t == 'function' && t.prototype) || lI;
  22119. return e === i;
  22120. }
  22121. var Lg = hI;
  22122. function cI(e, t) {
  22123. for (var i = -1, r = Array(e); ++i < e; ) r[i] = t(i);
  22124. return r;
  22125. }
  22126. var dI = cI,
  22127. uI = '[object Arguments]';
  22128. function pI(e) {
  22129. return Ws(e) && Ma(e) == uI;
  22130. }
  22131. var Wy = pI,
  22132. t_ = Object.prototype,
  22133. fI = t_.hasOwnProperty,
  22134. mI = t_.propertyIsEnumerable,
  22135. gI = Wy(
  22136. (function () {
  22137. return arguments;
  22138. })()
  22139. )
  22140. ? Wy
  22141. : function (e) {
  22142. return Ws(e) && fI.call(e, 'callee') && !mI.call(e, 'callee');
  22143. },
  22144. Og = gI;
  22145. function vI() {
  22146. return !1;
  22147. }
  22148. var yI = vI,
  22149. i_ = typeof exports == 'object' && exports && !exports.nodeType && exports,
  22150. Xy = i_ && typeof module == 'object' && module && !module.nodeType && module,
  22151. xI = Xy && Xy.exports === i_,
  22152. qy = xI ? Hr.Buffer : void 0,
  22153. bI = qy ? qy.isBuffer : void 0,
  22154. wI = bI || yI,
  22155. Ad = wI,
  22156. _I = '[object Arguments]',
  22157. AI = '[object Array]',
  22158. SI = '[object Boolean]',
  22159. MI = '[object Date]',
  22160. EI = '[object Error]',
  22161. CI = '[object Function]',
  22162. TI = '[object Map]',
  22163. PI = '[object Number]',
  22164. DI = '[object Object]',
  22165. LI = '[object RegExp]',
  22166. OI = '[object Set]',
  22167. II = '[object String]',
  22168. RI = '[object WeakMap]',
  22169. BI = '[object ArrayBuffer]',
  22170. zI = '[object DataView]',
  22171. NI = '[object Float32Array]',
  22172. UI = '[object Float64Array]',
  22173. FI = '[object Int8Array]',
  22174. kI = '[object Int16Array]',
  22175. jI = '[object Int32Array]',
  22176. GI = '[object Uint8Array]',
  22177. VI = '[object Uint8ClampedArray]',
  22178. HI = '[object Uint16Array]',
  22179. WI = '[object Uint32Array]',
  22180. Tt = {};
  22181. Tt[NI] = Tt[UI] = Tt[FI] = Tt[kI] = Tt[jI] = Tt[GI] = Tt[VI] = Tt[HI] = Tt[WI] = !0;
  22182. Tt[_I] = Tt[AI] = Tt[BI] = Tt[SI] = Tt[zI] = Tt[MI] = Tt[EI] = Tt[CI] = Tt[TI] = Tt[PI] = Tt[DI] = Tt[LI] = Tt[OI] = Tt[II] = Tt[RI] = !1;
  22183. function XI(e) {
  22184. return Ws(e) && Dg(e.length) && !!Tt[Ma(e)];
  22185. }
  22186. var qI = XI;
  22187. function YI(e) {
  22188. return function (t) {
  22189. return e(t);
  22190. };
  22191. }
  22192. var Ig = YI,
  22193. r_ = typeof exports == 'object' && exports && !exports.nodeType && exports,
  22194. eh = r_ && typeof module == 'object' && module && !module.nodeType && module,
  22195. QI = eh && eh.exports === r_,
  22196. Dp = QI && Yw.process,
  22197. ZI = (function () {
  22198. try {
  22199. var e = eh && eh.require && eh.require('util').types;
  22200. return e || (Dp && Dp.binding && Dp.binding('util'));
  22201. } catch {}
  22202. })(),
  22203. No = ZI,
  22204. Yy = No && No.isTypedArray,
  22205. KI = Yy ? Ig(Yy) : qI,
  22206. s_ = KI,
  22207. JI = Object.prototype,
  22208. $I = JI.hasOwnProperty;
  22209. function e4(e, t) {
  22210. var i = ys(e),
  22211. r = !i && Og(e),
  22212. s = !i && !r && Ad(e),
  22213. n = !i && !r && !s && s_(e),
  22214. a = i || r || s || n,
  22215. o = a ? dI(e.length, String) : [],
  22216. l = o.length;
  22217. for (var h in e)
  22218. (t || $I.call(e, h)) &&
  22219. !(
  22220. a &&
  22221. (h == 'length' ||
  22222. (s && (h == 'offset' || h == 'parent')) ||
  22223. (n && (h == 'buffer' || h == 'byteLength' || h == 'byteOffset')) ||
  22224. Cg(h, l))
  22225. ) &&
  22226. o.push(h);
  22227. return o;
  22228. }
  22229. var n_ = e4;
  22230. function t4(e, t) {
  22231. return function (i) {
  22232. return e(t(i));
  22233. };
  22234. }
  22235. var a_ = t4,
  22236. i4 = a_(Object.keys, Object),
  22237. r4 = i4,
  22238. s4 = Object.prototype,
  22239. n4 = s4.hasOwnProperty;
  22240. function a4(e) {
  22241. if (!Lg(e)) return r4(e);
  22242. var t = [];
  22243. for (var i in Object(e)) n4.call(e, i) && i != 'constructor' && t.push(i);
  22244. return t;
  22245. }
  22246. var o4 = a4;
  22247. function l4(e) {
  22248. return e_(e) ? n_(e) : o4(e);
  22249. }
  22250. var Rg = l4;
  22251. function h4(e) {
  22252. var t = [];
  22253. if (e != null) for (var i in Object(e)) t.push(i);
  22254. return t;
  22255. }
  22256. var c4 = h4,
  22257. d4 = Object.prototype,
  22258. u4 = d4.hasOwnProperty;
  22259. function p4(e) {
  22260. if (!xs(e)) return c4(e);
  22261. var t = Lg(e),
  22262. i = [];
  22263. for (var r in e) (r == 'constructor' && (t || !u4.call(e, r))) || i.push(r);
  22264. return i;
  22265. }
  22266. var f4 = p4;
  22267. function m4(e) {
  22268. return e_(e) ? n_(e, !0) : f4(e);
  22269. }
  22270. var Bg = m4,
  22271. g4 = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  22272. v4 = /^\w*$/;
  22273. function y4(e, t) {
  22274. if (ys(e)) return !1;
  22275. var i = typeof e;
  22276. return i == 'number' || i == 'symbol' || i == 'boolean' || e == null || uu(e)
  22277. ? !0
  22278. : v4.test(e) || !g4.test(e) || (t != null && e in Object(t));
  22279. }
  22280. var x4 = y4,
  22281. b4 = Ca(Object, 'create'),
  22282. ph = b4;
  22283. function w4() {
  22284. (this.__data__ = ph ? ph(null) : {}), (this.size = 0);
  22285. }
  22286. var _4 = w4;
  22287. function A4(e) {
  22288. var t = this.has(e) && delete this.__data__[e];
  22289. return (this.size -= t ? 1 : 0), t;
  22290. }
  22291. var S4 = A4,
  22292. M4 = '__lodash_hash_undefined__',
  22293. E4 = Object.prototype,
  22294. C4 = E4.hasOwnProperty;
  22295. function T4(e) {
  22296. var t = this.__data__;
  22297. if (ph) {
  22298. var i = t[e];
  22299. return i === M4 ? void 0 : i;
  22300. }
  22301. return C4.call(t, e) ? t[e] : void 0;
  22302. }
  22303. var P4 = T4,
  22304. D4 = Object.prototype,
  22305. L4 = D4.hasOwnProperty;
  22306. function O4(e) {
  22307. var t = this.__data__;
  22308. return ph ? t[e] !== void 0 : L4.call(t, e);
  22309. }
  22310. var I4 = O4,
  22311. R4 = '__lodash_hash_undefined__';
  22312. function B4(e, t) {
  22313. var i = this.__data__;
  22314. return (this.size += this.has(e) ? 0 : 1), (i[e] = ph && t === void 0 ? R4 : t), this;
  22315. }
  22316. var z4 = B4;
  22317. function Zo(e) {
  22318. var t = -1,
  22319. i = e == null ? 0 : e.length;
  22320. for (this.clear(); ++t < i; ) {
  22321. var r = e[t];
  22322. this.set(r[0], r[1]);
  22323. }
  22324. }
  22325. Zo.prototype.clear = _4;
  22326. Zo.prototype.delete = S4;
  22327. Zo.prototype.get = P4;
  22328. Zo.prototype.has = I4;
  22329. Zo.prototype.set = z4;
  22330. var Qy = Zo;
  22331. function N4() {
  22332. (this.__data__ = []), (this.size = 0);
  22333. }
  22334. var U4 = N4;
  22335. function F4(e, t) {
  22336. for (var i = e.length; i--; ) if (Tg(e[i][0], t)) return i;
  22337. return -1;
  22338. }
  22339. var pu = F4,
  22340. k4 = Array.prototype,
  22341. j4 = k4.splice;
  22342. function G4(e) {
  22343. var t = this.__data__,
  22344. i = pu(t, e);
  22345. if (i < 0) return !1;
  22346. var r = t.length - 1;
  22347. return i == r ? t.pop() : j4.call(t, i, 1), --this.size, !0;
  22348. }
  22349. var V4 = G4;
  22350. function H4(e) {
  22351. var t = this.__data__,
  22352. i = pu(t, e);
  22353. return i < 0 ? void 0 : t[i][1];
  22354. }
  22355. var W4 = H4;
  22356. function X4(e) {
  22357. return pu(this.__data__, e) > -1;
  22358. }
  22359. var q4 = X4;
  22360. function Y4(e, t) {
  22361. var i = this.__data__,
  22362. r = pu(i, e);
  22363. return r < 0 ? (++this.size, i.push([e, t])) : (i[r][1] = t), this;
  22364. }
  22365. var Q4 = Y4;
  22366. function Ko(e) {
  22367. var t = -1,
  22368. i = e == null ? 0 : e.length;
  22369. for (this.clear(); ++t < i; ) {
  22370. var r = e[t];
  22371. this.set(r[0], r[1]);
  22372. }
  22373. }
  22374. Ko.prototype.clear = U4;
  22375. Ko.prototype.delete = V4;
  22376. Ko.prototype.get = W4;
  22377. Ko.prototype.has = q4;
  22378. Ko.prototype.set = Q4;
  22379. var fu = Ko,
  22380. Z4 = Ca(Hr, 'Map'),
  22381. fh = Z4;
  22382. function K4() {
  22383. (this.size = 0), (this.__data__ = { hash: new Qy(), map: new (fh || fu)(), string: new Qy() });
  22384. }
  22385. var J4 = K4;
  22386. function $4(e) {
  22387. var t = typeof e;
  22388. return t == 'string' || t == 'number' || t == 'symbol' || t == 'boolean' ? e !== '__proto__' : e === null;
  22389. }
  22390. var eR = $4;
  22391. function tR(e, t) {
  22392. var i = e.__data__;
  22393. return eR(t) ? i[typeof t == 'string' ? 'string' : 'hash'] : i.map;
  22394. }
  22395. var mu = tR;
  22396. function iR(e) {
  22397. var t = mu(this, e).delete(e);
  22398. return (this.size -= t ? 1 : 0), t;
  22399. }
  22400. var rR = iR;
  22401. function sR(e) {
  22402. return mu(this, e).get(e);
  22403. }
  22404. var nR = sR;
  22405. function aR(e) {
  22406. return mu(this, e).has(e);
  22407. }
  22408. var oR = aR;
  22409. function lR(e, t) {
  22410. var i = mu(this, e),
  22411. r = i.size;
  22412. return i.set(e, t), (this.size += i.size == r ? 0 : 1), this;
  22413. }
  22414. var hR = lR;
  22415. function Jo(e) {
  22416. var t = -1,
  22417. i = e == null ? 0 : e.length;
  22418. for (this.clear(); ++t < i; ) {
  22419. var r = e[t];
  22420. this.set(r[0], r[1]);
  22421. }
  22422. }
  22423. Jo.prototype.clear = J4;
  22424. Jo.prototype.delete = rR;
  22425. Jo.prototype.get = nR;
  22426. Jo.prototype.has = oR;
  22427. Jo.prototype.set = hR;
  22428. var gu = Jo,
  22429. cR = 'Expected a function';
  22430. function zg(e, t) {
  22431. if (typeof e != 'function' || (t != null && typeof t != 'function')) throw new TypeError(cR);
  22432. var i = function () {
  22433. var r = arguments,
  22434. s = t ? t.apply(this, r) : r[0],
  22435. n = i.cache;
  22436. if (n.has(s)) return n.get(s);
  22437. var a = e.apply(this, r);
  22438. return (i.cache = n.set(s, a) || n), a;
  22439. };
  22440. return (i.cache = new (zg.Cache || gu)()), i;
  22441. }
  22442. zg.Cache = gu;
  22443. var dR = zg,
  22444. uR = 500;
  22445. function pR(e) {
  22446. var t = dR(e, function (r) {
  22447. return i.size === uR && i.clear(), r;
  22448. }),
  22449. i = t.cache;
  22450. return t;
  22451. }
  22452. var fR = pR,
  22453. mR = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,
  22454. gR = /\\(\\)?/g,
  22455. vR = fR(function (e) {
  22456. var t = [];
  22457. return (
  22458. e.charCodeAt(0) === 46 && t.push(''),
  22459. e.replace(mR, function (i, r, s, n) {
  22460. t.push(s ? n.replace(gR, '$1') : r || i);
  22461. }),
  22462. t
  22463. );
  22464. }),
  22465. yR = vR;
  22466. function xR(e) {
  22467. return e == null ? '' : VL(e);
  22468. }
  22469. var bR = xR;
  22470. function wR(e, t) {
  22471. return ys(e) ? e : x4(e, t) ? [e] : yR(bR(e));
  22472. }
  22473. var $o = wR,
  22474. _R = 1 / 0;
  22475. function AR(e) {
  22476. if (typeof e == 'string' || uu(e)) return e;
  22477. var t = e + '';
  22478. return t == '0' && 1 / e == -_R ? '-0' : t;
  22479. }
  22480. var vu = AR;
  22481. function SR(e, t) {
  22482. t = $o(t, e);
  22483. for (var i = 0, r = t.length; e != null && i < r; ) e = e[vu(t[i++])];
  22484. return i && i == r ? e : void 0;
  22485. }
  22486. var o_ = SR;
  22487. function MR(e, t) {
  22488. for (var i = -1, r = t.length, s = e.length; ++i < r; ) e[s + i] = t[i];
  22489. return e;
  22490. }
  22491. var Ng = MR,
  22492. Zy = Er ? Er.isConcatSpreadable : void 0;
  22493. function ER(e) {
  22494. return ys(e) || Og(e) || !!(Zy && e && e[Zy]);
  22495. }
  22496. var CR = ER;
  22497. function l_(e, t, i, r, s) {
  22498. var n = -1,
  22499. a = e.length;
  22500. for (i || (i = CR), s || (s = []); ++n < a; ) {
  22501. var o = e[n];
  22502. t > 0 && i(o) ? (t > 1 ? l_(o, t - 1, i, r, s) : Ng(s, o)) : r || (s[s.length] = o);
  22503. }
  22504. return s;
  22505. }
  22506. var TR = l_;
  22507. function PR(e) {
  22508. var t = e == null ? 0 : e.length;
  22509. return t ? TR(e, 1) : [];
  22510. }
  22511. var DR = PR;
  22512. function LR(e) {
  22513. return WO(sI(e, void 0, DR), e + '');
  22514. }
  22515. var h_ = LR,
  22516. OR = a_(Object.getPrototypeOf, Object),
  22517. Ug = OR,
  22518. IR = '[object Object]',
  22519. RR = Function.prototype,
  22520. BR = Object.prototype,
  22521. c_ = RR.toString,
  22522. zR = BR.hasOwnProperty,
  22523. NR = c_.call(Object);
  22524. function UR(e) {
  22525. if (!Ws(e) || Ma(e) != IR) return !1;
  22526. var t = Ug(e);
  22527. if (t === null) return !0;
  22528. var i = zR.call(t, 'constructor') && t.constructor;
  22529. return typeof i == 'function' && i instanceof i && c_.call(i) == NR;
  22530. }
  22531. var FR = UR;
  22532. function kR(e, t, i) {
  22533. var r = -1,
  22534. s = e.length;
  22535. 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);
  22536. for (var n = Array(s); ++r < s; ) n[r] = e[r + t];
  22537. return n;
  22538. }
  22539. var jR = kR;
  22540. function GR() {
  22541. (this.__data__ = new fu()), (this.size = 0);
  22542. }
  22543. var VR = GR;
  22544. function HR(e) {
  22545. var t = this.__data__,
  22546. i = t.delete(e);
  22547. return (this.size = t.size), i;
  22548. }
  22549. var WR = HR;
  22550. function XR(e) {
  22551. return this.__data__.get(e);
  22552. }
  22553. var qR = XR;
  22554. function YR(e) {
  22555. return this.__data__.has(e);
  22556. }
  22557. var QR = YR,
  22558. ZR = 200;
  22559. function KR(e, t) {
  22560. var i = this.__data__;
  22561. if (i instanceof fu) {
  22562. var r = i.__data__;
  22563. if (!fh || r.length < ZR - 1) return r.push([e, t]), (this.size = ++i.size), this;
  22564. i = this.__data__ = new gu(r);
  22565. }
  22566. return i.set(e, t), (this.size = i.size), this;
  22567. }
  22568. var JR = KR;
  22569. function el(e) {
  22570. var t = (this.__data__ = new fu(e));
  22571. this.size = t.size;
  22572. }
  22573. el.prototype.clear = VR;
  22574. el.prototype.delete = WR;
  22575. el.prototype.get = qR;
  22576. el.prototype.has = QR;
  22577. el.prototype.set = JR;
  22578. var ed = el;
  22579. function $R(e, t) {
  22580. return e && Rh(t, Rg(t), e);
  22581. }
  22582. var eB = $R;
  22583. function tB(e, t) {
  22584. return e && Rh(t, Bg(t), e);
  22585. }
  22586. var iB = tB,
  22587. d_ = typeof exports == 'object' && exports && !exports.nodeType && exports,
  22588. Ky = d_ && typeof module == 'object' && module && !module.nodeType && module,
  22589. rB = Ky && Ky.exports === d_,
  22590. Jy = rB ? Hr.Buffer : void 0,
  22591. $y = Jy ? Jy.allocUnsafe : void 0;
  22592. function sB(e, t) {
  22593. if (t) return e.slice();
  22594. var i = e.length,
  22595. r = $y ? $y(i) : new e.constructor(i);
  22596. return e.copy(r), r;
  22597. }
  22598. var nB = sB;
  22599. function aB(e, t) {
  22600. for (var i = -1, r = e == null ? 0 : e.length, s = 0, n = []; ++i < r; ) {
  22601. var a = e[i];
  22602. t(a, i, e) && (n[s++] = a);
  22603. }
  22604. return n;
  22605. }
  22606. var oB = aB;
  22607. function lB() {
  22608. return [];
  22609. }
  22610. var u_ = lB,
  22611. hB = Object.prototype,
  22612. cB = hB.propertyIsEnumerable,
  22613. e1 = Object.getOwnPropertySymbols,
  22614. dB = e1
  22615. ? function (e) {
  22616. return e == null
  22617. ? []
  22618. : ((e = Object(e)),
  22619. oB(e1(e), function (t) {
  22620. return cB.call(e, t);
  22621. }));
  22622. }
  22623. : u_,
  22624. Fg = dB;
  22625. function uB(e, t) {
  22626. return Rh(e, Fg(e), t);
  22627. }
  22628. var pB = uB,
  22629. fB = Object.getOwnPropertySymbols,
  22630. mB = fB
  22631. ? function (e) {
  22632. for (var t = []; e; ) Ng(t, Fg(e)), (e = Ug(e));
  22633. return t;
  22634. }
  22635. : u_,
  22636. p_ = mB;
  22637. function gB(e, t) {
  22638. return Rh(e, p_(e), t);
  22639. }
  22640. var vB = gB;
  22641. function yB(e, t, i) {
  22642. var r = t(e);
  22643. return ys(e) ? r : Ng(r, i(e));
  22644. }
  22645. var f_ = yB;
  22646. function xB(e) {
  22647. return f_(e, Rg, Fg);
  22648. }
  22649. var Kf = xB;
  22650. function bB(e) {
  22651. return f_(e, Bg, p_);
  22652. }
  22653. var m_ = bB,
  22654. wB = Ca(Hr, 'DataView'),
  22655. Jf = wB,
  22656. _B = Ca(Hr, 'Promise'),
  22657. $f = _B,
  22658. AB = Ca(Hr, 'Set'),
  22659. em = AB,
  22660. t1 = '[object Map]',
  22661. SB = '[object Object]',
  22662. i1 = '[object Promise]',
  22663. r1 = '[object Set]',
  22664. s1 = '[object WeakMap]',
  22665. n1 = '[object DataView]',
  22666. MB = Ea(Jf),
  22667. EB = Ea(fh),
  22668. CB = Ea($f),
  22669. TB = Ea(em),
  22670. PB = Ea(Zf),
  22671. $n = Ma;
  22672. ((Jf && $n(new Jf(new ArrayBuffer(1))) != n1) ||
  22673. (fh && $n(new fh()) != t1) ||
  22674. ($f && $n($f.resolve()) != i1) ||
  22675. (em && $n(new em()) != r1) ||
  22676. (Zf && $n(new Zf()) != s1)) &&
  22677. ($n = function (e) {
  22678. var t = Ma(e),
  22679. i = t == SB ? e.constructor : void 0,
  22680. r = i ? Ea(i) : '';
  22681. if (r)
  22682. switch (r) {
  22683. case MB:
  22684. return n1;
  22685. case EB:
  22686. return t1;
  22687. case CB:
  22688. return i1;
  22689. case TB:
  22690. return r1;
  22691. case PB:
  22692. return s1;
  22693. }
  22694. return t;
  22695. });
  22696. var mh = $n,
  22697. DB = Object.prototype,
  22698. LB = DB.hasOwnProperty;
  22699. function OB(e) {
  22700. var t = e.length,
  22701. i = new e.constructor(t);
  22702. return t && typeof e[0] == 'string' && LB.call(e, 'index') && ((i.index = e.index), (i.input = e.input)), i;
  22703. }
  22704. var IB = OB,
  22705. RB = Hr.Uint8Array,
  22706. Sd = RB;
  22707. function BB(e) {
  22708. var t = new e.constructor(e.byteLength);
  22709. return new Sd(t).set(new Sd(e)), t;
  22710. }
  22711. var kg = BB;
  22712. function zB(e, t) {
  22713. var i = t ? kg(e.buffer) : e.buffer;
  22714. return new e.constructor(i, e.byteOffset, e.byteLength);
  22715. }
  22716. var NB = zB,
  22717. UB = /\w*$/;
  22718. function FB(e) {
  22719. var t = new e.constructor(e.source, UB.exec(e));
  22720. return (t.lastIndex = e.lastIndex), t;
  22721. }
  22722. var kB = FB,
  22723. a1 = Er ? Er.prototype : void 0,
  22724. o1 = a1 ? a1.valueOf : void 0;
  22725. function jB(e) {
  22726. return o1 ? Object(o1.call(e)) : {};
  22727. }
  22728. var GB = jB;
  22729. function VB(e, t) {
  22730. var i = t ? kg(e.buffer) : e.buffer;
  22731. return new e.constructor(i, e.byteOffset, e.length);
  22732. }
  22733. var HB = VB,
  22734. WB = '[object Boolean]',
  22735. XB = '[object Date]',
  22736. qB = '[object Map]',
  22737. YB = '[object Number]',
  22738. QB = '[object RegExp]',
  22739. ZB = '[object Set]',
  22740. KB = '[object String]',
  22741. JB = '[object Symbol]',
  22742. $B = '[object ArrayBuffer]',
  22743. e5 = '[object DataView]',
  22744. t5 = '[object Float32Array]',
  22745. i5 = '[object Float64Array]',
  22746. r5 = '[object Int8Array]',
  22747. s5 = '[object Int16Array]',
  22748. n5 = '[object Int32Array]',
  22749. a5 = '[object Uint8Array]',
  22750. o5 = '[object Uint8ClampedArray]',
  22751. l5 = '[object Uint16Array]',
  22752. h5 = '[object Uint32Array]';
  22753. function c5(e, t, i) {
  22754. var r = e.constructor;
  22755. switch (t) {
  22756. case $B:
  22757. return kg(e);
  22758. case WB:
  22759. case XB:
  22760. return new r(+e);
  22761. case e5:
  22762. return NB(e, i);
  22763. case t5:
  22764. case i5:
  22765. case r5:
  22766. case s5:
  22767. case n5:
  22768. case a5:
  22769. case o5:
  22770. case l5:
  22771. case h5:
  22772. return HB(e, i);
  22773. case qB:
  22774. return new r();
  22775. case YB:
  22776. case KB:
  22777. return new r(e);
  22778. case QB:
  22779. return kB(e);
  22780. case ZB:
  22781. return new r();
  22782. case JB:
  22783. return GB(e);
  22784. }
  22785. }
  22786. var d5 = c5;
  22787. function u5(e) {
  22788. return typeof e.constructor == 'function' && !Lg(e) ? PO(Ug(e)) : {};
  22789. }
  22790. var p5 = u5,
  22791. f5 = '[object Map]';
  22792. function m5(e) {
  22793. return Ws(e) && mh(e) == f5;
  22794. }
  22795. var g5 = m5,
  22796. l1 = No && No.isMap,
  22797. v5 = l1 ? Ig(l1) : g5,
  22798. y5 = v5,
  22799. x5 = '[object Set]';
  22800. function b5(e) {
  22801. return Ws(e) && mh(e) == x5;
  22802. }
  22803. var w5 = b5,
  22804. h1 = No && No.isSet,
  22805. _5 = h1 ? Ig(h1) : w5,
  22806. A5 = _5,
  22807. S5 = 1,
  22808. M5 = 2,
  22809. E5 = 4,
  22810. g_ = '[object Arguments]',
  22811. C5 = '[object Array]',
  22812. T5 = '[object Boolean]',
  22813. P5 = '[object Date]',
  22814. D5 = '[object Error]',
  22815. v_ = '[object Function]',
  22816. L5 = '[object GeneratorFunction]',
  22817. O5 = '[object Map]',
  22818. I5 = '[object Number]',
  22819. y_ = '[object Object]',
  22820. R5 = '[object RegExp]',
  22821. B5 = '[object Set]',
  22822. z5 = '[object String]',
  22823. N5 = '[object Symbol]',
  22824. U5 = '[object WeakMap]',
  22825. F5 = '[object ArrayBuffer]',
  22826. k5 = '[object DataView]',
  22827. j5 = '[object Float32Array]',
  22828. G5 = '[object Float64Array]',
  22829. V5 = '[object Int8Array]',
  22830. H5 = '[object Int16Array]',
  22831. W5 = '[object Int32Array]',
  22832. X5 = '[object Uint8Array]',
  22833. q5 = '[object Uint8ClampedArray]',
  22834. Y5 = '[object Uint16Array]',
  22835. Q5 = '[object Uint32Array]',
  22836. Et = {};
  22837. Et[g_] =
  22838. Et[C5] =
  22839. Et[F5] =
  22840. Et[k5] =
  22841. Et[T5] =
  22842. Et[P5] =
  22843. Et[j5] =
  22844. Et[G5] =
  22845. Et[V5] =
  22846. Et[H5] =
  22847. Et[W5] =
  22848. Et[O5] =
  22849. Et[I5] =
  22850. Et[y_] =
  22851. Et[R5] =
  22852. Et[B5] =
  22853. Et[z5] =
  22854. Et[N5] =
  22855. Et[X5] =
  22856. Et[q5] =
  22857. Et[Y5] =
  22858. Et[Q5] =
  22859. !0;
  22860. Et[D5] = Et[v_] = Et[U5] = !1;
  22861. function td(e, t, i, r, s, n) {
  22862. var a,
  22863. o = t & S5,
  22864. l = t & M5,
  22865. h = t & E5;
  22866. if ((i && (a = s ? i(e, r, s, n) : i(e)), a !== void 0)) return a;
  22867. if (!xs(e)) return e;
  22868. var u = ys(e);
  22869. if (u) {
  22870. if (((a = IB(e)), !o)) return IO(e, a);
  22871. } else {
  22872. var c = mh(e),
  22873. d = c == v_ || c == L5;
  22874. if (Ad(e)) return nB(e, o);
  22875. if (c == y_ || c == g_ || (d && !s)) {
  22876. if (((a = l || d ? {} : p5(e)), !o)) return l ? vB(e, iB(a, e)) : pB(e, eB(a, e));
  22877. } else {
  22878. if (!Et[c]) return s ? e : {};
  22879. a = d5(e, c, o);
  22880. }
  22881. }
  22882. n || (n = new ed());
  22883. var p = n.get(e);
  22884. if (p) return p;
  22885. n.set(e, a),
  22886. A5(e)
  22887. ? e.forEach(function (m) {
  22888. a.add(td(m, t, i, m, e, n));
  22889. })
  22890. : y5(e) &&
  22891. e.forEach(function (m, v) {
  22892. a.set(v, td(m, t, i, v, e, n));
  22893. });
  22894. var f = h ? (l ? m_ : Kf) : l ? Bg : Rg,
  22895. g = u ? void 0 : f(e);
  22896. return (
  22897. qO(g || e, function (m, v) {
  22898. g && ((v = m), (m = e[v])), Pg(a, v, td(m, t, i, v, e, n));
  22899. }),
  22900. a
  22901. );
  22902. }
  22903. var x_ = td,
  22904. Z5 = 1,
  22905. K5 = 4;
  22906. function J5(e) {
  22907. return x_(e, Z5 | K5);
  22908. }
  22909. var yu = J5,
  22910. $5 = '__lodash_hash_undefined__';
  22911. function ez(e) {
  22912. return this.__data__.set(e, $5), this;
  22913. }
  22914. var tz = ez;
  22915. function iz(e) {
  22916. return this.__data__.has(e);
  22917. }
  22918. var rz = iz;
  22919. function Md(e) {
  22920. var t = -1,
  22921. i = e == null ? 0 : e.length;
  22922. for (this.__data__ = new gu(); ++t < i; ) this.add(e[t]);
  22923. }
  22924. Md.prototype.add = Md.prototype.push = tz;
  22925. Md.prototype.has = rz;
  22926. var sz = Md;
  22927. function nz(e, t) {
  22928. for (var i = -1, r = e == null ? 0 : e.length; ++i < r; ) if (t(e[i], i, e)) return !0;
  22929. return !1;
  22930. }
  22931. var az = nz;
  22932. function oz(e, t) {
  22933. return e.has(t);
  22934. }
  22935. var lz = oz,
  22936. hz = 1,
  22937. cz = 2;
  22938. function dz(e, t, i, r, s, n) {
  22939. var a = i & hz,
  22940. o = e.length,
  22941. l = t.length;
  22942. if (o != l && !(a && l > o)) return !1;
  22943. var h = n.get(e),
  22944. u = n.get(t);
  22945. if (h && u) return h == t && u == e;
  22946. var c = -1,
  22947. d = !0,
  22948. p = i & cz ? new sz() : void 0;
  22949. for (n.set(e, t), n.set(t, e); ++c < o; ) {
  22950. var f = e[c],
  22951. g = t[c];
  22952. if (r) var m = a ? r(g, f, c, t, e, n) : r(f, g, c, e, t, n);
  22953. if (m !== void 0) {
  22954. if (m) continue;
  22955. d = !1;
  22956. break;
  22957. }
  22958. if (p) {
  22959. if (
  22960. !az(t, function (v, y) {
  22961. if (!lz(p, y) && (f === v || s(f, v, i, r, n))) return p.push(y);
  22962. })
  22963. ) {
  22964. d = !1;
  22965. break;
  22966. }
  22967. } else if (!(f === g || s(f, g, i, r, n))) {
  22968. d = !1;
  22969. break;
  22970. }
  22971. }
  22972. return n.delete(e), n.delete(t), d;
  22973. }
  22974. var b_ = dz;
  22975. function uz(e) {
  22976. var t = -1,
  22977. i = Array(e.size);
  22978. return (
  22979. e.forEach(function (r, s) {
  22980. i[++t] = [s, r];
  22981. }),
  22982. i
  22983. );
  22984. }
  22985. var pz = uz;
  22986. function fz(e) {
  22987. var t = -1,
  22988. i = Array(e.size);
  22989. return (
  22990. e.forEach(function (r) {
  22991. i[++t] = r;
  22992. }),
  22993. i
  22994. );
  22995. }
  22996. var mz = fz,
  22997. gz = 1,
  22998. vz = 2,
  22999. yz = '[object Boolean]',
  23000. xz = '[object Date]',
  23001. bz = '[object Error]',
  23002. wz = '[object Map]',
  23003. _z = '[object Number]',
  23004. Az = '[object RegExp]',
  23005. Sz = '[object Set]',
  23006. Mz = '[object String]',
  23007. Ez = '[object Symbol]',
  23008. Cz = '[object ArrayBuffer]',
  23009. Tz = '[object DataView]',
  23010. c1 = Er ? Er.prototype : void 0,
  23011. Lp = c1 ? c1.valueOf : void 0;
  23012. function Pz(e, t, i, r, s, n, a) {
  23013. switch (i) {
  23014. case Tz:
  23015. if (e.byteLength != t.byteLength || e.byteOffset != t.byteOffset) return !1;
  23016. (e = e.buffer), (t = t.buffer);
  23017. case Cz:
  23018. return !(e.byteLength != t.byteLength || !n(new Sd(e), new Sd(t)));
  23019. case yz:
  23020. case xz:
  23021. case _z:
  23022. return Tg(+e, +t);
  23023. case bz:
  23024. return e.name == t.name && e.message == t.message;
  23025. case Az:
  23026. case Mz:
  23027. return e == t + '';
  23028. case wz:
  23029. var o = pz;
  23030. case Sz:
  23031. var l = r & gz;
  23032. if ((o || (o = mz), e.size != t.size && !l)) return !1;
  23033. var h = a.get(e);
  23034. if (h) return h == t;
  23035. (r |= vz), a.set(e, t);
  23036. var u = b_(o(e), o(t), r, s, n, a);
  23037. return a.delete(e), u;
  23038. case Ez:
  23039. if (Lp) return Lp.call(e) == Lp.call(t);
  23040. }
  23041. return !1;
  23042. }
  23043. var Dz = Pz,
  23044. Lz = 1,
  23045. Oz = Object.prototype,
  23046. Iz = Oz.hasOwnProperty;
  23047. function Rz(e, t, i, r, s, n) {
  23048. var a = i & Lz,
  23049. o = Kf(e),
  23050. l = o.length,
  23051. h = Kf(t),
  23052. u = h.length;
  23053. if (l != u && !a) return !1;
  23054. for (var c = l; c--; ) {
  23055. var d = o[c];
  23056. if (!(a ? d in t : Iz.call(t, d))) return !1;
  23057. }
  23058. var p = n.get(e),
  23059. f = n.get(t);
  23060. if (p && f) return p == t && f == e;
  23061. var g = !0;
  23062. n.set(e, t), n.set(t, e);
  23063. for (var m = a; ++c < l; ) {
  23064. d = o[c];
  23065. var v = e[d],
  23066. y = t[d];
  23067. if (r) var b = a ? r(y, v, d, t, e, n) : r(v, y, d, e, t, n);
  23068. if (!(b === void 0 ? v === y || s(v, y, i, r, n) : b)) {
  23069. g = !1;
  23070. break;
  23071. }
  23072. m || (m = d == 'constructor');
  23073. }
  23074. if (g && !m) {
  23075. var x = e.constructor,
  23076. w = t.constructor;
  23077. x != w &&
  23078. 'constructor' in e &&
  23079. 'constructor' in t &&
  23080. !(typeof x == 'function' && x instanceof x && typeof w == 'function' && w instanceof w) &&
  23081. (g = !1);
  23082. }
  23083. return n.delete(e), n.delete(t), g;
  23084. }
  23085. var Bz = Rz,
  23086. zz = 1,
  23087. d1 = '[object Arguments]',
  23088. u1 = '[object Array]',
  23089. wc = '[object Object]',
  23090. Nz = Object.prototype,
  23091. p1 = Nz.hasOwnProperty;
  23092. function Uz(e, t, i, r, s, n) {
  23093. var a = ys(e),
  23094. o = ys(t),
  23095. l = a ? u1 : mh(e),
  23096. h = o ? u1 : mh(t);
  23097. (l = l == d1 ? wc : l), (h = h == d1 ? wc : h);
  23098. var u = l == wc,
  23099. c = h == wc,
  23100. d = l == h;
  23101. if (d && Ad(e)) {
  23102. if (!Ad(t)) return !1;
  23103. (a = !0), (u = !1);
  23104. }
  23105. if (d && !u) return n || (n = new ed()), a || s_(e) ? b_(e, t, i, r, s, n) : Dz(e, t, l, i, r, s, n);
  23106. if (!(i & zz)) {
  23107. var p = u && p1.call(e, '__wrapped__'),
  23108. f = c && p1.call(t, '__wrapped__');
  23109. if (p || f) {
  23110. var g = p ? e.value() : e,
  23111. m = f ? t.value() : t;
  23112. return n || (n = new ed()), s(g, m, i, r, n);
  23113. }
  23114. }
  23115. return d ? (n || (n = new ed()), Bz(e, t, i, r, s, n)) : !1;
  23116. }
  23117. var Fz = Uz;
  23118. function w_(e, t, i, r, s) {
  23119. return e === t ? !0 : e == null || t == null || (!Ws(e) && !Ws(t)) ? e !== e && t !== t : Fz(e, t, i, r, w_, s);
  23120. }
  23121. var kz = w_;
  23122. function jz(e, t) {
  23123. return e != null && t in Object(e);
  23124. }
  23125. var Gz = jz;
  23126. function Vz(e, t, i) {
  23127. t = $o(t, e);
  23128. for (var r = -1, s = t.length, n = !1; ++r < s; ) {
  23129. var a = vu(t[r]);
  23130. if (!(n = e != null && i(e, a))) break;
  23131. e = e[a];
  23132. }
  23133. return n || ++r != s ? n : ((s = e == null ? 0 : e.length), !!s && Dg(s) && Cg(a, s) && (ys(e) || Og(e)));
  23134. }
  23135. var Hz = Vz;
  23136. function Wz(e, t) {
  23137. return e != null && Hz(e, t, Gz);
  23138. }
  23139. var Xz = Wz,
  23140. qz = function () {
  23141. return Hr.Date.now();
  23142. },
  23143. Op = qz,
  23144. Yz = 'Expected a function',
  23145. Qz = Math.max,
  23146. Zz = Math.min;
  23147. function Kz(e, t, i) {
  23148. var r,
  23149. s,
  23150. n,
  23151. a,
  23152. o,
  23153. l,
  23154. h = 0,
  23155. u = !1,
  23156. c = !1,
  23157. d = !0;
  23158. if (typeof e != 'function') throw new TypeError(Yz);
  23159. (t = jy(t) || 0),
  23160. xs(i) && ((u = !!i.leading), (c = 'maxWait' in i), (n = c ? Qz(jy(i.maxWait) || 0, t) : n), (d = 'trailing' in i ? !!i.trailing : d));
  23161. function p(A) {
  23162. var S = r,
  23163. _ = s;
  23164. return (r = s = void 0), (h = A), (a = e.apply(_, S)), a;
  23165. }
  23166. function f(A) {
  23167. return (h = A), (o = setTimeout(v, t)), u ? p(A) : a;
  23168. }
  23169. function g(A) {
  23170. var S = A - l,
  23171. _ = A - h,
  23172. M = t - S;
  23173. return c ? Zz(M, n - _) : M;
  23174. }
  23175. function m(A) {
  23176. var S = A - l,
  23177. _ = A - h;
  23178. return l === void 0 || S >= t || S < 0 || (c && _ >= n);
  23179. }
  23180. function v() {
  23181. var A = Op();
  23182. if (m(A)) return y(A);
  23183. o = setTimeout(v, g(A));
  23184. }
  23185. function y(A) {
  23186. return (o = void 0), d && r ? p(A) : ((r = s = void 0), a);
  23187. }
  23188. function b() {
  23189. o !== void 0 && clearTimeout(o), (h = 0), (r = l = s = o = void 0);
  23190. }
  23191. function x() {
  23192. return o === void 0 ? a : y(Op());
  23193. }
  23194. function w() {
  23195. var A = Op(),
  23196. S = m(A);
  23197. if (((r = arguments), (s = this), (l = A), S)) {
  23198. if (o === void 0) return f(l);
  23199. if (c) return clearTimeout(o), (o = setTimeout(v, t)), p(l);
  23200. }
  23201. return o === void 0 && (o = setTimeout(v, t)), a;
  23202. }
  23203. return (w.cancel = b), (w.flush = x), w;
  23204. }
  23205. var __ = Kz;
  23206. function Jz(e) {
  23207. var t = e == null ? 0 : e.length;
  23208. return t ? e[t - 1] : void 0;
  23209. }
  23210. var $z = Jz;
  23211. function eN(e, t) {
  23212. return t.length < 2 ? e : o_(e, jR(t, 0, -1));
  23213. }
  23214. var tN = eN;
  23215. function iN(e, t) {
  23216. return kz(e, t);
  23217. }
  23218. var jg = iN;
  23219. function rN(e, t) {
  23220. return (t = $o(t, e)), (e = tN(e, t)), e == null || delete e[vu($z(t))];
  23221. }
  23222. var sN = rN;
  23223. function nN(e) {
  23224. return FR(e) ? void 0 : e;
  23225. }
  23226. var aN = nN,
  23227. oN = 1,
  23228. lN = 2,
  23229. hN = 4,
  23230. cN = h_(function (e, t) {
  23231. var i = {};
  23232. if (e == null) return i;
  23233. var r = !1;
  23234. (t = Zw(t, function (n) {
  23235. return (n = $o(n, e)), r || (r = n.length > 1), n;
  23236. })),
  23237. Rh(e, m_(e), i),
  23238. r && (i = x_(i, oN | lN | hN, aN));
  23239. for (var s = t.length; s--; ) sN(i, t[s]);
  23240. return i;
  23241. }),
  23242. tm = cN;
  23243. function dN(e, t, i, r) {
  23244. if (!xs(e)) return e;
  23245. t = $o(t, e);
  23246. for (var s = -1, n = t.length, a = n - 1, o = e; o != null && ++s < n; ) {
  23247. var l = vu(t[s]),
  23248. h = i;
  23249. if (l === '__proto__' || l === 'constructor' || l === 'prototype') return e;
  23250. if (s != a) {
  23251. var u = o[l];
  23252. (h = r ? r(u, l, o) : void 0), h === void 0 && (h = xs(u) ? u : Cg(t[s + 1]) ? [] : {});
  23253. }
  23254. Pg(o, l, h), (o = o[l]);
  23255. }
  23256. return e;
  23257. }
  23258. var uN = dN;
  23259. function pN(e, t, i) {
  23260. for (var r = -1, s = t.length, n = {}; ++r < s; ) {
  23261. var a = t[r],
  23262. o = o_(e, a);
  23263. i(o, a) && uN(n, $o(a, e), o);
  23264. }
  23265. return n;
  23266. }
  23267. var fN = pN;
  23268. function mN(e, t) {
  23269. return fN(e, t, function (i, r) {
  23270. return Xz(e, r);
  23271. });
  23272. }
  23273. var gN = mN,
  23274. vN = h_(function (e, t) {
  23275. return e == null ? {} : gN(e, t);
  23276. }),
  23277. gh = vN,
  23278. A_,
  23279. yN = new Promise((e) => {
  23280. A_ = e;
  23281. }),
  23282. f1 = !1;
  23283. async function xN() {
  23284. if (f1) return;
  23285. let e = await import('./physics.js');
  23286. await e.init(), A_(e), (f1 = !0);
  23287. }
  23288. var Qt = class {
  23289. modifyById(e, t) {
  23290. let i = this;
  23291. if (i[e] === void 0) throw new Error('not expected');
  23292. {
  23293. let r = { ...i, [e]: t };
  23294. return Object.setPrototypeOf(r, Qt.prototype), r;
  23295. }
  23296. }
  23297. add(e, t) {
  23298. return this.runOp({ type: 1, id: e, data: t })?.data ?? this;
  23299. }
  23300. runOp(e) {
  23301. let t = this;
  23302. if (e.type === 1) {
  23303. let i = t[e.id],
  23304. r;
  23305. i === void 0 ? (r = { type: 2, id: e.id }) : (r = { type: 1, id: e.id, data: i });
  23306. let { id: s, data: n } = e,
  23307. a = { ...t, [s]: n };
  23308. return Object.setPrototypeOf(a, Qt.prototype), { data: a, actual: e, reverse: r };
  23309. } else if (e.type === 2) {
  23310. let { id: i } = e,
  23311. r = t[i];
  23312. if (r === void 0) return null;
  23313. {
  23314. let s = { ...t };
  23315. return Object.setPrototypeOf(s, Qt.prototype), delete s[i], { data: s, actual: e, reverse: { type: 1, id: i, data: r } };
  23316. }
  23317. }
  23318. return null;
  23319. }
  23320. };
  23321. function Gg(e) {
  23322. if (e.deepFreeze !== void 0) {
  23323. e.deepFreeze(e);
  23324. return;
  23325. }
  23326. let t = Object.getOwnPropertyNames(e);
  23327. for (let i of t) {
  23328. let r = e[i];
  23329. r && typeof r == 'object' && Gg(r);
  23330. }
  23331. return Object.freeze(e);
  23332. }
  23333. function bN(e, t) {
  23334. let i = 0;
  23335. for (; i < e.length && i < t.length; ) {
  23336. if (e[i] < t[i]) return -1;
  23337. if (e[i] > t[i]) return 1;
  23338. i += 1;
  23339. }
  23340. return i !== t.length ? -1 : i !== e.length ? 1 : 0;
  23341. }
  23342. var S_ = class extends Error {};
  23343. function Ip(e) {
  23344. let t = { ...e };
  23345. return Object.setPrototypeOf(t, Object.getPrototypeOf(e)), t;
  23346. }
  23347. function yn(e, t, i) {
  23348. if ((e === void 0 ? (t === void 0 ? ((e = 0), (t = 10)) : (e = t - 10)) : t === void 0 && (t = e + 10), e > t)) {
  23349. let n = e;
  23350. (e = t), (t = n);
  23351. }
  23352. let r = [],
  23353. s = 1 / (i + 1);
  23354. for (let n = 0; n < i; n++) {
  23355. let a = e + (t - e) * (n + 0.75 + Math.random() * 0.5) * s;
  23356. r.push(a);
  23357. }
  23358. return r;
  23359. }
  23360. function Vg(e) {
  23361. return (
  23362. e instanceof Uint8Array ||
  23363. e instanceof Uint16Array ||
  23364. e instanceof Uint32Array ||
  23365. e instanceof Int8Array ||
  23366. e instanceof Int16Array ||
  23367. e instanceof Int32Array ||
  23368. e instanceof Float32Array ||
  23369. e instanceof Float64Array
  23370. );
  23371. }
  23372. function wN() {
  23373. return typeof process < 'u';
  23374. }
  23375. function M_(e, t) {
  23376. for (let i of e) t(i.id, i.data) !== !0 && M_(i.children, t);
  23377. }
  23378. function E_(e, t) {
  23379. if (t(e.id, e.data) !== !0) for (let i of e.children) E_(i, t);
  23380. }
  23381. var ki = class extends Array {
  23382. constructor(...e) {
  23383. super(...e), Object.setPrototypeOf(this, ki.prototype);
  23384. }
  23385. deepFreeze() {
  23386. let e = 0;
  23387. for (; e < this.length; ) Gg(this[e]), e++;
  23388. }
  23389. fillCaches0(e, t) {
  23390. this.objCaches.set(e.id, e), this.parentCaches.set(e.id, t);
  23391. for (let i of e.children) this.fillCaches0(i, e.id);
  23392. }
  23393. fillCaches() {
  23394. if (this.objCaches === void 0) {
  23395. (this.objCaches = new Map()), (this.parentCaches = new Map());
  23396. for (let e of this) this.fillCaches0(e, null);
  23397. }
  23398. }
  23399. randomId() {
  23400. this.fillCaches();
  23401. let e = Array.from(this.objCaches.keys());
  23402. if (e.length !== 0) return e[Math.max(0, Math.floor(Math.random() * e.length) - 1)];
  23403. }
  23404. nonExistOrDescendantOf(e, t) {
  23405. if (!this.has(e)) return !0;
  23406. for (; e; ) {
  23407. let i = this.parent(e);
  23408. if (i === t) return !0;
  23409. e = i;
  23410. }
  23411. return !1;
  23412. }
  23413. isDescendantOf(e, t) {
  23414. for (; e; ) {
  23415. let i = this.parent(e);
  23416. if (i === t) return !0;
  23417. e = i;
  23418. }
  23419. return !1;
  23420. }
  23421. data(e) {
  23422. return this.get(e)?.data;
  23423. }
  23424. has(e) {
  23425. return this.childrenOf(e) !== void 0;
  23426. }
  23427. get(e) {
  23428. return this.fillCaches(), this.objCaches.get(e);
  23429. }
  23430. childrenOf(e) {
  23431. return e === null ? this : this.get(e)?.children;
  23432. }
  23433. traverseFrom(e, t) {
  23434. if (e === null) this.traverse(t);
  23435. else {
  23436. let i = this.get(e);
  23437. i && E_(i, t);
  23438. }
  23439. }
  23440. traverse(e) {
  23441. M_(this, e);
  23442. }
  23443. totalSize() {
  23444. return this.fillCaches(), this.objCaches.size;
  23445. }
  23446. parent(e) {
  23447. return this.fillCaches(), this.parentCaches.get(e);
  23448. }
  23449. childrenArray(e) {
  23450. return e === null ? this : this.get(e).children;
  23451. }
  23452. modifyById(e, t) {
  23453. if (this.get(e) === void 0) throw new Error('not expected');
  23454. {
  23455. let i = this.parent(e),
  23456. r = this.childrenArray(i),
  23457. s = r.findIndex((a) => a.id === e);
  23458. if (s < 0) throw new Error('not expected');
  23459. let n = r[s];
  23460. return (r = [...r]), (r[s] = { ...n, data: t }), this.modifyArrayBy(i, r);
  23461. }
  23462. }
  23463. modifyArrayBy(e, t) {
  23464. let i = e,
  23465. r = t;
  23466. for (; i !== null; ) {
  23467. let n = r,
  23468. a = i;
  23469. if (((i = this.parent(i)), i === void 0)) throw new Error();
  23470. r = this.childrenArray(i);
  23471. let o = r.findIndex((l) => l.id === a);
  23472. if (o < 0) throw new Error();
  23473. (r = [...r]), (r[o] = { ...r[o], children: n });
  23474. }
  23475. Object.setPrototypeOf(r, ki.prototype);
  23476. let s = r;
  23477. return s.fillCaches(), s;
  23478. }
  23479. runOp(e) {
  23480. switch (e.type) {
  23481. case 7:
  23482. return this.addOp(e);
  23483. case 8:
  23484. return this.deleteOp(e);
  23485. case 9:
  23486. return this.moveOp(e);
  23487. }
  23488. return null;
  23489. }
  23490. checkDuplicatedIdRec({ id: e, children: t }) {
  23491. if (this.get(e) !== void 0) return !0;
  23492. for (let i of t) if (this.checkDuplicatedIdRec(i)) return !0;
  23493. return !1;
  23494. }
  23495. addOp(e) {
  23496. let { parent: t, fi: i, id: r, data: s, children: n } = e;
  23497. if ((t !== null && this.get(t) === void 0) || this.checkDuplicatedIdRec(e)) return null;
  23498. {
  23499. let a = t,
  23500. o = this.childrenArray(a),
  23501. l = { fi: i, id: r, data: s, children: n };
  23502. return (
  23503. (o = [...o, l]),
  23504. o.sort((h, u) => h.fi - u.fi),
  23505. (e.localIndex = o.indexOf(l)),
  23506. { data: this.modifyArrayBy(a, o), actual: e, reverse: { type: 8, id: r } }
  23507. );
  23508. }
  23509. }
  23510. deleteOp(e) {
  23511. let { id: t } = e;
  23512. if (this.get(t) === null) return null;
  23513. {
  23514. let i = this.parent(t);
  23515. if (i === void 0) return null;
  23516. let r = this.childrenArray(i),
  23517. s = r.findIndex((a) => a.id === t);
  23518. (e.localIndex = s), (r = [...r]);
  23519. let n = r.splice(s, 1)[0];
  23520. return { data: this.modifyArrayBy(i, r), actual: e, reverse: { type: 7, ...n, parent: i } };
  23521. }
  23522. }
  23523. moveOp(e) {
  23524. let { parent: t, fi: i, id: r } = e;
  23525. if (t !== null && this.get(t) === void 0) return this.deleteOp({ type: 8, id: r });
  23526. if (t !== null) {
  23527. let c = t;
  23528. for (; c !== null; ) {
  23529. if (c === void 0) throw new Error();
  23530. if (c === r) throw new S_('cyclic tree');
  23531. c = this.parent(c);
  23532. }
  23533. }
  23534. let s = this.parent(r);
  23535. if (s === void 0) return null;
  23536. let n = s,
  23537. a = this.childrenArray(s),
  23538. o = a.findIndex((c) => c.id === r);
  23539. a = [...a];
  23540. let l = a.splice(o, 1)[0],
  23541. h = this.modifyArrayBy(s, a);
  23542. (s = t), (a = h.childrenArray(s));
  23543. let u = l.fi;
  23544. return (
  23545. (l = { ...l, fi: i }),
  23546. (a = [...a, l]),
  23547. a.sort((c, d) => c.fi - d.fi),
  23548. (e.localIndex = a.indexOf(l)),
  23549. (h = h.modifyArrayBy(s, a)),
  23550. { data: h, actual: e, reverse: { type: 9, parent: n, fi: u, id: r } }
  23551. );
  23552. }
  23553. previous(e, t) {
  23554. if (t === null) {
  23555. let r = this.childrenArray(e);
  23556. return r.length === 0 ? null : r[r.length - 1].id;
  23557. }
  23558. let i = null;
  23559. for (let r of this.childrenArray(e)) {
  23560. if (r.id === t) return i;
  23561. i = r.id;
  23562. }
  23563. return null;
  23564. }
  23565. traverseSortNext(e) {
  23566. let t = this.parent(e);
  23567. if (t !== void 0) {
  23568. let i = this.childrenArray(t),
  23569. r = i.findIndex((s) => s.id === e) + 1;
  23570. if (r < i.length) return i[r].id;
  23571. if (t) return this.traverseSortNext(t);
  23572. }
  23573. }
  23574. sortNext(e) {
  23575. let t = this.childrenArray(e);
  23576. return t.length > 0 ? t[0].id : this.traverseSortNext(e);
  23577. }
  23578. traverseSortPrevious(e) {
  23579. let t = this.childrenArray(e);
  23580. return t.length > 0 ? this.traverseSortPrevious(t[t.length - 1].id) : e;
  23581. }
  23582. sortPrevious(e) {
  23583. let t = this.parent(e);
  23584. if (t !== void 0) {
  23585. let i = this.childrenArray(t),
  23586. r = i.findIndex((s) => s.id === e) - 1;
  23587. return r >= 0 ? this.traverseSortPrevious(i[r].id) : t;
  23588. }
  23589. }
  23590. getAllSorted(e) {
  23591. let t = [];
  23592. for (let i of e) {
  23593. let r = this.getWithSortKey(i.id);
  23594. r !== void 0 && t.push({ ...i, ...r });
  23595. }
  23596. t.sort((i, r) => bN(i.sortKey, r.sortKey));
  23597. for (let i of t) delete i.sortKey;
  23598. return t;
  23599. }
  23600. getWithSortKey(e) {
  23601. var t = e;
  23602. let i = [],
  23603. r = this.get(t),
  23604. s = r;
  23605. if (r !== void 0) {
  23606. for (; t; ) i.splice(0, 0, r.fi), (t = this.parent(t)), t !== null && (r = this.get(t));
  23607. return { ...s, sortKey: i };
  23608. }
  23609. }
  23610. insertBeforeHelper(e, t, i) {
  23611. return this.insertAfterHelper(e, this.previous(e, t), i);
  23612. }
  23613. insertAfterHelper(e, t, i) {
  23614. let r = this.childrenArray(e);
  23615. if (t === null) {
  23616. if (r.length === 0) return yn(0, i, i);
  23617. {
  23618. let s = r[0].fi;
  23619. return yn(s - i, s, i);
  23620. }
  23621. } else {
  23622. let s = this.get(t);
  23623. if (s === void 0 || this.parent(t) !== e) throw new Error('illegal args');
  23624. let n = r.find((a) => a.fi > s.fi);
  23625. if (n === void 0) {
  23626. let a = r[r.length - 1].fi;
  23627. return yn(a, a + i, i);
  23628. } else return yn(s.fi, n.fi, i);
  23629. }
  23630. }
  23631. },
  23632. Ed;
  23633. ((e) => {
  23634. function t(i, r) {
  23635. if (r.type !== 0) return null;
  23636. if (Array.isArray(i)) {
  23637. let s = r.props,
  23638. n = {},
  23639. a = [...i],
  23640. o = !1;
  23641. if (s)
  23642. for (let l of Object.keys(s)) {
  23643. let h = parseInt(l);
  23644. if (isNaN(h)) throw new Error('wrong index');
  23645. (n[l] = a[h]), (a[h] = s[l]), (o = !0);
  23646. }
  23647. return o ? { data: a, actual: r, reverse: { type: 0, props: n } } : null;
  23648. } else {
  23649. let s = r.props,
  23650. n = {},
  23651. a = { ...i },
  23652. o = !1;
  23653. if (s)
  23654. for (let l of Object.keys(s)) {
  23655. n[l] = a[l];
  23656. let h = s[l];
  23657. h === void 0 ? delete a[l] : (a[l] = h), (o = !0);
  23658. }
  23659. return o ? { data: a, actual: r, reverse: { type: 0, props: n } } : null;
  23660. }
  23661. }
  23662. e.runOp = t;
  23663. })(Ed || (Ed = {}));
  23664. var rt = class extends Array {
  23665. constructor(...e) {
  23666. super(...e), Object.setPrototypeOf(this, rt.prototype);
  23667. }
  23668. deepFreeze() {
  23669. let e = 0;
  23670. for (; e < this.length; ) Gg(this[e]), e++;
  23671. }
  23672. fillCaches0(e) {
  23673. this.objCaches.set(e.id, e);
  23674. }
  23675. fillCaches() {
  23676. if (this.objCaches === void 0) {
  23677. (this.objCaches = new Map()), (Object.getOwnPropertyDescriptor(this, 'objCaches').enumerable = !1);
  23678. for (let e of this) this.fillCaches0(e);
  23679. }
  23680. }
  23681. randomId() {
  23682. this.fillCaches();
  23683. let e = Array.from(this.objCaches.keys());
  23684. if (e.length !== 0) return e[Math.max(0, Math.floor(Math.random() * e.length) - 1)];
  23685. }
  23686. data(e) {
  23687. return this.get(e)?.data;
  23688. }
  23689. get(e) {
  23690. return this.fillCaches(), this.objCaches.get(e);
  23691. }
  23692. modifyById(e, t) {
  23693. if (this.get(e) === void 0) throw new Error('not expected');
  23694. {
  23695. let i = this,
  23696. r = i.findIndex((n) => n.id === e);
  23697. if (r < 0) throw new Error('not expected');
  23698. let s = i[r];
  23699. return (i = [...i]), (i[r] = { ...s, data: t }), this.modifyArrayBy(i);
  23700. }
  23701. }
  23702. modifyArrayBy(e) {
  23703. Object.setPrototypeOf(e, rt.prototype);
  23704. let t = e;
  23705. return wN() || t.fillCaches(), t;
  23706. }
  23707. runOp(e) {
  23708. switch (e.type) {
  23709. case 4:
  23710. return this.addOp(e);
  23711. case 5:
  23712. return this.deleteOp(e);
  23713. case 6:
  23714. return this.moveOp(e);
  23715. }
  23716. return null;
  23717. }
  23718. addOp(e) {
  23719. let { fi: t, id: i, data: r } = e,
  23720. s = this,
  23721. n = { fi: t, id: i, data: r };
  23722. return (
  23723. (s = [...s, n]),
  23724. s.sort((a, o) => a.fi - o.fi),
  23725. (e.localIndex = s.indexOf(n)),
  23726. { data: this.modifyArrayBy(s), actual: e, reverse: { type: 5, id: i } }
  23727. );
  23728. }
  23729. deleteOp(e) {
  23730. let { id: t } = e,
  23731. i = this,
  23732. r = i.findIndex((n) => n.id === t);
  23733. if (r === -1) return null;
  23734. (e.localIndex = r), (i = [...i]);
  23735. let s = i.splice(r, 1)[0];
  23736. return { data: this.modifyArrayBy(i), actual: e, reverse: { type: 4, ...s } };
  23737. }
  23738. moveOp(e) {
  23739. let { fi: t, id: i } = e,
  23740. r = this;
  23741. r = [...r];
  23742. let s = r.findIndex((o) => o.id === i);
  23743. if (s === -1) return null;
  23744. let n = r[s].fi,
  23745. a = { ...r[s], fi: t };
  23746. return (
  23747. (r[s] = a),
  23748. r.sort((o, l) => o.fi - l.fi),
  23749. (e.localIndex = r.indexOf(a)),
  23750. { data: this.modifyArrayBy(r), actual: e, reverse: { type: 6, fi: n, id: i } }
  23751. );
  23752. }
  23753. previous(e) {
  23754. if (e === null) return this.length === 0 ? null : this[this.length - 1].id;
  23755. let t = null;
  23756. for (let i of this) {
  23757. if (i.id === e) return t;
  23758. t = i.id;
  23759. }
  23760. return null;
  23761. }
  23762. insertBeforeHelper(e, t) {
  23763. return this.insertAfterHelper(this.previous(e), t);
  23764. }
  23765. insertAfterHelper(e, t) {
  23766. let i = this;
  23767. if (e === null) {
  23768. if (i.length === 0) return yn(0, t, t);
  23769. {
  23770. let r = i[0].fi;
  23771. return yn(r - t, r, t);
  23772. }
  23773. } else {
  23774. let r = this.get(e);
  23775. if (r === void 0) throw new Error('illegal args');
  23776. let s = i.find((n) => n.fi > r.fi);
  23777. if (s === void 0) {
  23778. let n = i[i.length - 1].fi;
  23779. return yn(n, n + t, t);
  23780. } else return yn(r.fi, s.fi, t);
  23781. }
  23782. }
  23783. };
  23784. function Uo(e) {
  23785. return e && typeof e == 'object' && e instanceof mi;
  23786. }
  23787. var mi = class {
  23788. unusedFunOverridesTable(e) {}
  23789. runOp(e) {
  23790. let t = [],
  23791. i = this,
  23792. r = 0,
  23793. s = {};
  23794. for (; r < e.path.length; ) {
  23795. if ((t.push(i), (i = i === void 0 ? void 0 : i[e.path[r]]), i !== void 0 && !Uo(i))) return null;
  23796. r += 1;
  23797. }
  23798. i = i ? Ip(i) : new mi();
  23799. for (let [o, l] of Object.entries(e.props)) {
  23800. let h = i[o];
  23801. (s[o] = h), l === void 0 ? delete i[o] : (i[o] = l);
  23802. }
  23803. for (; r > 0; ) {
  23804. if (Object.keys(i).length === 0) {
  23805. let o = t[r - 1];
  23806. o && ((i = Ip(o)), delete i[e.path[r - 1]]);
  23807. } else {
  23808. let o = t[r - 1];
  23809. if (o) {
  23810. let l = Ip(o);
  23811. (l[e.path[r - 1]] = i), (i = l);
  23812. } else {
  23813. let l = new mi();
  23814. (l[e.path[r - 1]] = i), (i = l);
  23815. }
  23816. }
  23817. r -= 1;
  23818. }
  23819. let n = Object.setPrototypeOf(i, mi.prototype),
  23820. a = { ...e, props: s };
  23821. return { data: n, actual: e, reverse: a };
  23822. }
  23823. },
  23824. fa;
  23825. ((e) => {
  23826. function t(s, n) {
  23827. return vh(s, n) ?? s;
  23828. }
  23829. e.apply = t;
  23830. function i(s, n) {
  23831. return Wg(s, n);
  23832. }
  23833. e.merge = i;
  23834. function r(s, n) {
  23835. let a = 0,
  23836. o = n.path,
  23837. l = s;
  23838. for (; a < o.length && l !== void 0; ) {
  23839. if (((l = fs.zoomOnce(l, o[a])), l === void 0)) return n;
  23840. if (!Uo(l)) return;
  23841. a += 1;
  23842. }
  23843. if (l === void 0) return n;
  23844. if (Uo(l))
  23845. if (n.type === 0) {
  23846. let h = { ...n.props };
  23847. for (let u of Object.keys(l)) delete h[u];
  23848. return { ...n, props: h };
  23849. } else if (n.type === 1 || n.type === 4 || n.type === 7) {
  23850. let h = Hg([n], l);
  23851. return h ? (console.log(h), h) : n;
  23852. } else return n;
  23853. }
  23854. e.filterOp = r;
  23855. })(fa || (fa = {}));
  23856. function Hg(e, t) {
  23857. if (t === void 0) return;
  23858. let i = !1,
  23859. r = e.map((s) => {
  23860. let n = s.id,
  23861. a = vh(s.data, t[n]);
  23862. if (((i = i || a !== void 0), a === void 0 && (a = s.data), s.children)) {
  23863. let o = Hg(s.children, t);
  23864. return o !== void 0 ? (i = !0) : (o = s.children), { ...s, id: n, data: a, children: o };
  23865. } else return { ...s, id: n, data: a };
  23866. });
  23867. if (i) return r;
  23868. }
  23869. function _N(e, t) {
  23870. if (t === void 0) return;
  23871. let i = !1,
  23872. r = e.map((s) => {
  23873. let n = s.id,
  23874. a = vh(s.data, t[n]);
  23875. return (i = i || a !== void 0), a === void 0 && (a = s.data), { ...s, id: n, data: a };
  23876. });
  23877. if (i) return Object.setPrototypeOf(r, Object.getPrototypeOf(e)), r;
  23878. }
  23879. function vh(e, t) {
  23880. if (!Uo(t)) return t;
  23881. if (e instanceof ki) {
  23882. let i = Hg(e, t);
  23883. return i !== void 0 && Object.setPrototypeOf(i, Object.getPrototypeOf(e)), i;
  23884. } else {
  23885. if (e instanceof rt) return _N(e, t);
  23886. if (Array.isArray(e)) {
  23887. let i = !1,
  23888. r = e.map((s, n) => {
  23889. let a = vh(s, t[n]);
  23890. return (i = i || a !== void 0), a === void 0 && (a = s), a;
  23891. });
  23892. return i ? (Object.setPrototypeOf(r, Object.getPrototypeOf(e)), r) : void 0;
  23893. } else {
  23894. if (e instanceof mi) return Wg(e, t);
  23895. if (e && typeof e == 'object') {
  23896. let i = {},
  23897. r = !1;
  23898. for (let [s, n] of Object.entries(e)) {
  23899. let a = vh(n, t[s]);
  23900. (r = r || a !== void 0), a === void 0 && (a = n), (i[s] = a);
  23901. }
  23902. return r ? (Object.setPrototypeOf(i, Object.getPrototypeOf(e)), i) : void 0;
  23903. }
  23904. }
  23905. }
  23906. }
  23907. function Wg(e, t) {
  23908. if (e === void 0) return t;
  23909. if (t === void 0) return e;
  23910. if (!Uo(t)) return t;
  23911. if (!Uo(e)) return fa.apply(e, t);
  23912. let i = new Set();
  23913. for (let s of Object.keys(e)) i.add(s);
  23914. for (let s of Object.keys(t)) i.add(s);
  23915. let r = new mi();
  23916. for (let s of i) {
  23917. let n = Wg(e === void 0 ? void 0 : e[s], t === void 0 ? void 0 : t[s]);
  23918. r[s] = n;
  23919. }
  23920. return r;
  23921. }
  23922. function AN(e, t) {
  23923. let i = { cur: [], result: [], len: 0 };
  23924. return (e = yh(e, t, i) ?? e), [e, i.result];
  23925. }
  23926. function Cd(e, t) {
  23927. return e === null ? null : ((e.cur[e.len] = t), (e.len += 1), e);
  23928. }
  23929. function Td(e) {
  23930. e && (e.len -= 1);
  23931. }
  23932. function SN(e) {
  23933. if (e === null) return null;
  23934. e.result.push(e.cur.slice(0, e.len));
  23935. }
  23936. function C_(e, t, i) {
  23937. let r = !1,
  23938. s = e.map((n) => {
  23939. let a = n.id,
  23940. o = t[a];
  23941. if (o !== void 0 && typeof o == 'string' && ((r = !0), (a = o), i !== null)) throw new Error('not supported');
  23942. let l = yh(n.data, t, Cd(i, a));
  23943. Td(i), (r = r || l !== void 0), l === void 0 && (l = n.data);
  23944. let h = C_(n.children, t, i);
  23945. return h !== void 0 ? (r = !0) : (h = n.children), { ...n, id: a, data: l, children: h };
  23946. });
  23947. if (r) return s;
  23948. }
  23949. function MN(e, t, i) {
  23950. let r = !1,
  23951. s = e.map((n) => {
  23952. let a = n.id,
  23953. o = t[a];
  23954. if (o !== void 0 && typeof o == 'string' && ((r = !0), (a = o), i !== null)) throw new Error('not supported');
  23955. let l = yh(n.data, t, Cd(i, a));
  23956. return Td(i), (r = r || l !== void 0), l === void 0 && (l = n.data), { ...n, id: a, data: l };
  23957. });
  23958. if (r) return Object.setPrototypeOf(s, Object.getPrototypeOf(e)), s;
  23959. }
  23960. function yh(e, t, i) {
  23961. if (e instanceof ki) {
  23962. let r = C_(e, t, i);
  23963. return r !== void 0 && Object.setPrototypeOf(r, Object.getPrototypeOf(e)), r;
  23964. } else {
  23965. if (e instanceof rt) return MN(e, t, i);
  23966. if (Array.isArray(e)) {
  23967. let r = !1,
  23968. s = e.map((n, a) => {
  23969. let o = yh(n, t, Cd(i, a));
  23970. return Td(i), (r = r || o !== void 0), o === void 0 && (o = n), o;
  23971. });
  23972. return r ? (Object.setPrototypeOf(s, Object.getPrototypeOf(e)), s) : void 0;
  23973. } else if (e && typeof e == 'object' && !Vg(e)) {
  23974. let r = {},
  23975. s = !1;
  23976. for (let [n, a] of Object.entries(e))
  23977. if (n !== 'name' && n !== 'text') {
  23978. let o = t[n];
  23979. if (typeof o == 'string') {
  23980. if (i !== null) throw new Error('not supported');
  23981. (s = !0), (n = o);
  23982. }
  23983. let l = yh(a, t, Cd(i, n));
  23984. Td(i), (s = s || l !== void 0), l === void 0 && (l = a), (r[n] = l);
  23985. } else r[n] = a;
  23986. return s ? (Object.setPrototypeOf(r, Object.getPrototypeOf(e)), r) : void 0;
  23987. } else if (typeof e == 'string') {
  23988. let r = t[e];
  23989. if (r !== void 0) {
  23990. if (e.length !== 36) throw new Error('for now you should only call this method when the key is a uuid');
  23991. SN(i);
  23992. }
  23993. return r;
  23994. } else return;
  23995. }
  23996. }
  23997. var im;
  23998. ((e) => {
  23999. function t(i, r) {
  24000. let s = fs.zoom(r, i.path);
  24001. if (typeof s == 'object') {
  24002. let n = {};
  24003. for (let a of Object.keys(i.props)) n[a] = s[a];
  24004. return { ...i, props: n };
  24005. } else return { ...i, props: {} };
  24006. }
  24007. e.replaceProps = t;
  24008. })(im || (im = {}));
  24009. var ir;
  24010. ((e) => {
  24011. function t(l, h) {
  24012. return { ...l, path: l.path.slice(h) };
  24013. }
  24014. e.drop = t;
  24015. function i(l, h) {
  24016. return r(l, h)?.data ?? l;
  24017. }
  24018. e.applySimple = i;
  24019. function r(l, h) {
  24020. let u = h.path;
  24021. for (var c = []; ; ) {
  24022. let d;
  24023. if (
  24024. (l instanceof mi && h.type === 0 && ((d = l.runOp({ ...h, path: u.slice(c.length) })), d === null && (d = void 0)),
  24025. c.length === u.length && (l instanceof ki || l instanceof rt || l instanceof Qt ? (d = l.runOp(h)) : (d = Ed.runOp(l, h))),
  24026. d !== void 0)
  24027. )
  24028. if (d !== null) {
  24029. let g = d.data;
  24030. for (let m = c.length - 1; m >= 0; m--) {
  24031. let v = u[m],
  24032. y = c[m];
  24033. if (y instanceof ki) {
  24034. if (typeof v == 'number') throw new Error('illegal arg');
  24035. g = y.modifyById(v, g);
  24036. } else if (y instanceof rt) {
  24037. if (typeof v == 'number') throw new Error('illegal arg');
  24038. g = y.modifyById(v, g);
  24039. } else if (y instanceof Qt) {
  24040. if (typeof v == 'number') throw new Error('illegal arg');
  24041. g = y.modifyById(v, g);
  24042. } else if (y instanceof mi) {
  24043. let b = { ...y, [v]: g };
  24044. g = Object.setPrototypeOf(b, mi.prototype);
  24045. } else if (typeof y == 'object')
  24046. if (Array.isArray(y)) {
  24047. if (typeof v == 'string' && ((v = parseInt(v)), isNaN(v))) throw new Error('Invalid path');
  24048. let b = g;
  24049. (g = [...y]), (g[v] = b);
  24050. } else g = { ...y, [v]: g };
  24051. else return null;
  24052. }
  24053. return { data: g, actual: { ...d.actual, path: u }, reverse: { ...d.reverse, path: u } };
  24054. } else return null;
  24055. let p = u[c.length],
  24056. f;
  24057. if (l instanceof ki) {
  24058. if (typeof p == 'number') throw new Error('');
  24059. f = l.get(p)?.data;
  24060. } else if (l instanceof rt) {
  24061. if (typeof p == 'number') throw new Error('');
  24062. f = l.get(p)?.data;
  24063. } else l !== null && (f = l[p]);
  24064. if (f !== void 0) c.push(l), (l = f);
  24065. else return null;
  24066. }
  24067. }
  24068. e.apply = r;
  24069. function s(l, h) {
  24070. for (let u = 0; u < l.length && u < h.length; u++) if (l[u] !== h[u]) return !0;
  24071. return !1;
  24072. }
  24073. e.pathDisjoint = s;
  24074. function n(l, h) {
  24075. if (l.length !== h.length) return !1;
  24076. for (let u = 0; u < l.length; u++) if (l[u] !== h[u]) return !1;
  24077. return !0;
  24078. }
  24079. e.pathEq = n;
  24080. function a(l, h) {
  24081. return s(l.path, h.path);
  24082. }
  24083. e.commutative = a;
  24084. function o(l, h) {
  24085. return l.type === 0 && h.type === 0 && n(l.path, h.path) ? Object.keys(l.props).every((u) => h.props[u] !== void 0) : !1;
  24086. }
  24087. e.subsumed = o;
  24088. })(ir || (ir = {}));
  24089. var m1;
  24090. ((e) => {
  24091. function t() {
  24092. return [];
  24093. }
  24094. e.empty = t;
  24095. function i(h, u) {
  24096. let c = [];
  24097. for (let d of h) {
  24098. let [p, ...f] = d.path;
  24099. p === u && c.push({ ...d, path: f });
  24100. }
  24101. return c;
  24102. }
  24103. e.removePrefix = i;
  24104. function r(h, u) {
  24105. return h.map((c) => ({ ...c, path: [u, ...c.path] }));
  24106. }
  24107. e.addPrefix = r;
  24108. function s(h, u) {
  24109. return [...h, ...u];
  24110. }
  24111. e.concat = s;
  24112. function n(h, u) {
  24113. return [...h.filter((c) => !u.some((d) => ir.subsumed(c, d))), ...u];
  24114. }
  24115. e.compress = n;
  24116. function a(h, u) {
  24117. return h.every((c) => u.every((d) => ir.commutative(c, d)));
  24118. }
  24119. e.commutative = a;
  24120. function o(h, u) {
  24121. for (let c of u) {
  24122. let d = l(h, c);
  24123. d !== null && (h = d.data);
  24124. }
  24125. return h;
  24126. }
  24127. e.applyAll = o;
  24128. function l(h, u) {
  24129. var c = h;
  24130. let d = [],
  24131. p = [];
  24132. for (let f of u)
  24133. try {
  24134. if (f.type === 3) {
  24135. let g = fs.zoom(c, [...f.path, f.id]),
  24136. m = ir.apply(c, { ...f, type: 2 });
  24137. if (m !== null) {
  24138. c = m.data;
  24139. let [v, y] = AN(c, { [f.id]: g });
  24140. c = v;
  24141. for (let b of y) {
  24142. let x = b[b.length - 1];
  24143. b.splice(b.length - 1, 1),
  24144. d.push({ type: 0, path: b, props: { [x]: g } }),
  24145. p.push({ type: 0, path: b, props: { [x]: f.id } });
  24146. }
  24147. p.push(m.reverse), d.push(m.actual);
  24148. }
  24149. } else {
  24150. let g = ir.apply(c, f);
  24151. g !== null && (d.push(g.actual), (c = g.data), p.push(g.reverse));
  24152. }
  24153. } catch (g) {
  24154. if (g instanceof S_) return null;
  24155. throw g;
  24156. }
  24157. return { data: c, actual: d, reverse: p.reverse() };
  24158. }
  24159. e.apply = l;
  24160. })(m1 || (m1 = {}));
  24161. var T_ = Symbol(),
  24162. EN = Symbol(),
  24163. xu = Symbol(),
  24164. Bh = class {
  24165. reportOp(e, t, i = []) {
  24166. let r = this;
  24167. if (t === null) return;
  24168. r._current = t.data;
  24169. let s = i;
  24170. for (; !(r instanceof D_); ) {
  24171. let n = r._path,
  24172. a = r._current;
  24173. if ((n !== '' && s.splice(0, 0, n), (r = r._parent), r === null)) return;
  24174. r.update(n, a);
  24175. }
  24176. r.push(s, e, t.actual, t.reverse);
  24177. }
  24178. deleteChildren(e) {
  24179. if (this._children) {
  24180. let t = this._children[e];
  24181. if (t) {
  24182. let i = t[xu];
  24183. i && i(), delete this._children[e];
  24184. }
  24185. }
  24186. }
  24187. },
  24188. CN = class extends Bh {
  24189. constructor(e, t, i) {
  24190. super(), (this._parent = e), (this._path = t), (this._current = i);
  24191. }
  24192. update(e, t) {
  24193. if (Array.isArray(this._current)) {
  24194. if (typeof e == 'string' && ((e = parseInt(e)), isNaN(e))) throw new Error('Invalid path');
  24195. (this._current = [...this._current]), (this._current[e] = t);
  24196. } else this._current = { ...this._current, [e]: t };
  24197. }
  24198. runOp(e) {
  24199. this.reportOp(e, Ed.runOp(this._current, e), e.path);
  24200. }
  24201. },
  24202. TN = class extends Bh {
  24203. constructor(e, t, i) {
  24204. super(), (this._parent = e), (this._path = t), (this._current = i);
  24205. }
  24206. update(e, t) {
  24207. (this._current = { ...this._current, [e]: t }), Object.setPrototypeOf(this._current, Qt.prototype);
  24208. }
  24209. runOp(e) {
  24210. this.reportOp(e, this._current.runOp(e));
  24211. }
  24212. },
  24213. P_ = {
  24214. get(e, t) {
  24215. if (t === xu)
  24216. return () => {
  24217. e._parent = null;
  24218. };
  24219. if (t === T_) return e._current;
  24220. if (t === EN) return e;
  24221. let { _current: i, _children: r } = e;
  24222. if (t === 'push' && Array.isArray(i)) throw new Error('not supported to expand array');
  24223. let s = r === void 0 ? void 0 : r[t];
  24224. if (s !== void 0) return s;
  24225. let n = i[t],
  24226. a = bu(e, t, n);
  24227. return a !== n ? (r === void 0 && ((r = {}), (e._children = r)), (r[t] = a), a) : n;
  24228. },
  24229. has(e, t) {
  24230. return t in e._current;
  24231. },
  24232. ownKeys(e) {
  24233. return Reflect.ownKeys(e._current);
  24234. },
  24235. defineProperty() {
  24236. throw Error('not supported');
  24237. },
  24238. getPrototypeOf(e) {
  24239. return Object.getPrototypeOf(e._current);
  24240. },
  24241. setPrototypeOf() {
  24242. throw Error('not supported');
  24243. },
  24244. getOwnPropertyDescriptor(e, t) {
  24245. let i = e._current,
  24246. r = Reflect.getOwnPropertyDescriptor(i, t);
  24247. return r && { writable: !0, configurable: !0, enumerable: r.enumerable, value: i[t] };
  24248. }
  24249. },
  24250. PN = {
  24251. ...P_,
  24252. set(e, t, i) {
  24253. let r = { type: 0, props: { [t]: Si(i) ?? i } };
  24254. return e.deleteChildren(t), e.runOp(r), !0;
  24255. },
  24256. deleteProperty(e, t) {
  24257. let i = { type: 0, props: { [t]: void 0 } };
  24258. return e.deleteChildren(t), e.runOp(i), !0;
  24259. }
  24260. },
  24261. DN = {
  24262. ...P_,
  24263. set(e, t, i) {
  24264. return i === void 0 ? this.deleteProperty(e, t) : (e.deleteChildren(t), e.runOp({ type: 1, id: t, data: i })), !0;
  24265. },
  24266. deleteProperty(e, t) {
  24267. return e.runOp({ type: 2, id: t }), !0;
  24268. }
  24269. },
  24270. Xg = class extends Bh {
  24271. constructor(e, t, i) {
  24272. super(),
  24273. (this._children = {}),
  24274. (this._parent = e),
  24275. (this._path = t),
  24276. (this._current = i),
  24277. (this[xu] = () => {
  24278. this._parent = null;
  24279. });
  24280. }
  24281. unproxy() {
  24282. return this._current;
  24283. }
  24284. update(e, t) {
  24285. this._current = this._current.modifyById(e, t);
  24286. }
  24287. runOp(e) {
  24288. this.reportOp(e, this._current.runOp(e));
  24289. }
  24290. randomId() {
  24291. return this._current.randomId();
  24292. }
  24293. isDescendantOf(e, t) {
  24294. return this._current.isDescendantOf(e, t);
  24295. }
  24296. childrenOf(e) {
  24297. return this._current.childrenOf(e);
  24298. }
  24299. traverse(e) {
  24300. return this._current.traverse(e);
  24301. }
  24302. get(e) {
  24303. return this._current.get(e);
  24304. }
  24305. parent(e) {
  24306. return this._current.parent(e);
  24307. }
  24308. traverse(e) {
  24309. this._current.traverse((t, i) => {
  24310. e(t, this.data(t));
  24311. });
  24312. }
  24313. data(e) {
  24314. let { _current: t, _children: i } = this,
  24315. r = i === void 0 ? void 0 : i[e];
  24316. if (r !== void 0) return r;
  24317. let s = t.get(e)?.data,
  24318. n = bu(this, e, s);
  24319. return n !== s ? (i === void 0 && ((i = {}), (this._children = i)), (i[e] = n), n) : s;
  24320. }
  24321. add(e, t, i, r, s) {
  24322. this.runOp({ type: 7, parent: e, fi: t, id: i, data: r, children: s });
  24323. }
  24324. move(e, t, i) {
  24325. this.runOp({ type: 9, parent: e, fi: t, id: i });
  24326. }
  24327. insertAfter(e, t, i) {
  24328. let r = this._current.insertAfterHelper(e, t, i.length);
  24329. for (let s = 0; s < i.length; s++) {
  24330. let n = i[s];
  24331. this.add(e, r[s], n.id, n.data, n.children);
  24332. }
  24333. }
  24334. insertBefore(e, t, i) {
  24335. let r = this._current.insertBeforeHelper(e, t, i.length);
  24336. for (let s = 0; s < i.length; s++) {
  24337. let n = i[s];
  24338. this.add(e, r[s], n.id, n.data, n.children);
  24339. }
  24340. }
  24341. moveAfter(e, t, i) {
  24342. let r = this._current.insertAfterHelper(e, t, i.length);
  24343. for (let s = 0; s < i.length; s++) {
  24344. let n = i[s];
  24345. this.move(e, r[s], n);
  24346. }
  24347. }
  24348. moveBefore(e, t, i) {
  24349. let r = this._current.insertBeforeHelper(e, t, i.length);
  24350. for (let s = 0; s < i.length; s++) {
  24351. let n = i[s];
  24352. this.move(e, r[s], n);
  24353. }
  24354. }
  24355. delete(e) {
  24356. this.deleteChildren(e), this.runOp({ type: 8, id: e });
  24357. }
  24358. sortNext(e) {
  24359. return this._current.sortNext(e);
  24360. }
  24361. sortPrevious(e) {
  24362. return this._current.sortPrevious(e);
  24363. }
  24364. getAllSorted(e) {
  24365. return this._current.getAllSorted(e);
  24366. }
  24367. },
  24368. qg = class extends Bh {
  24369. constructor(e, t, i) {
  24370. super(),
  24371. (this._children = {}),
  24372. (this._parent = e),
  24373. (this._path = t),
  24374. (this._current = i),
  24375. (this[xu] = () => {
  24376. this._parent = null;
  24377. });
  24378. }
  24379. unproxy() {
  24380. return this._current;
  24381. }
  24382. get length() {
  24383. return this._current.length;
  24384. }
  24385. forEach(e) {
  24386. let t = this.length;
  24387. for (let i = 0; i < t; i++) {
  24388. let r = this._current[i].id,
  24389. s = this._current[i].fi;
  24390. e(this.data(this._current[i].id), r, s);
  24391. }
  24392. }
  24393. find(e) {
  24394. let t = this.length;
  24395. for (let i = 0; i < t; i++) {
  24396. let r = this._current[i].id;
  24397. if (e(this.data(r), r)) return this.get(r);
  24398. }
  24399. }
  24400. update(e, t) {
  24401. this._current = this._current.modifyById(e, t);
  24402. }
  24403. randomId() {
  24404. return this._current.randomId();
  24405. }
  24406. get(e) {
  24407. return { ...this._current.get(e), data: this.data(e) };
  24408. }
  24409. data(e) {
  24410. let { _current: t, _children: i } = this,
  24411. r = i === void 0 ? void 0 : i[e];
  24412. if (r !== void 0) return r;
  24413. let s = t.get(e)?.data,
  24414. n = bu(this, e, s);
  24415. return n !== s ? (i === void 0 && ((i = {}), (this._children = i)), (i[e] = n), n) : s;
  24416. }
  24417. runOp(e) {
  24418. this.reportOp(e, this._current.runOp(e));
  24419. }
  24420. add(e, t, i) {
  24421. this.runOp({ type: 4, fi: e, id: t, data: i });
  24422. }
  24423. move(e, t) {
  24424. this.runOp({ type: 6, fi: e, id: t });
  24425. }
  24426. insertAfter(e, t) {
  24427. let i = this._current.insertAfterHelper(e, t.length);
  24428. for (let r = 0; r < t.length; r++) {
  24429. let s = t[r];
  24430. this.add(i[r], s.id, s.data);
  24431. }
  24432. }
  24433. insertBefore(e, t) {
  24434. let i = this._current.insertBeforeHelper(e, t.length);
  24435. for (let r = 0; r < t.length; r++) {
  24436. let s = t[r];
  24437. this.add(i[r], s.id, s.data);
  24438. }
  24439. }
  24440. moveAfter(e, t) {
  24441. let i = this._current.insertAfterHelper(e, t.length);
  24442. for (let r = 0; r < t.length; r++) {
  24443. let s = t[r];
  24444. this.move(i[r], s);
  24445. }
  24446. }
  24447. moveBefore(e, t) {
  24448. let i = this._current.insertBeforeHelper(e, t.length);
  24449. for (let r = 0; r < t.length; r++) {
  24450. let s = t[r];
  24451. this.move(i[r], s);
  24452. }
  24453. }
  24454. delete(e) {
  24455. this.deleteChildren(e), this.runOp({ type: 5, id: e });
  24456. }
  24457. };
  24458. function Rp(e, t, i) {
  24459. if (e.length > 0) {
  24460. let r = e[e.length - 1];
  24461. if (r.type === 0 && t.type === 0 && fs.equal(r.path, i)) {
  24462. Object.assign(r.props, t.props);
  24463. return;
  24464. }
  24465. }
  24466. e.push({ ...t, path: i });
  24467. }
  24468. var D_ = class extends Bh {
  24469. constructor(e) {
  24470. super(), (this.ts = []), (this.actual = []), (this.reverse = []), (this._current = e);
  24471. }
  24472. update(e, t) {
  24473. if (e !== '') throw new Error('');
  24474. this._current = t;
  24475. }
  24476. push(e, t, i, r) {
  24477. Rp(this.ts, t, e), Rp(this.actual, i, e), Rp(this.reverse, r, e);
  24478. }
  24479. result() {
  24480. return { data: this._current, ts: this.ts, actual: this.actual, reverse: this.reverse.reverse() };
  24481. }
  24482. };
  24483. function bu(e, t, i) {
  24484. return i instanceof ki
  24485. ? new Xg(e, t, i)
  24486. : i instanceof rt
  24487. ? new qg(e, t, i)
  24488. : i instanceof Qt
  24489. ? new Proxy(new TN(e, t, i), DN)
  24490. : i !== null && typeof i == 'object'
  24491. ? Vg(i)
  24492. ? i
  24493. : new Proxy(new CN(e, t, i), PN)
  24494. : i;
  24495. }
  24496. function L_(e) {
  24497. let t = new D_(e);
  24498. return [bu(t, '', e), t];
  24499. }
  24500. function Pd(e, t) {
  24501. let [i, r] = L_(e);
  24502. return t(i), r.result();
  24503. }
  24504. function Si(e) {
  24505. return e instanceof Xg || e instanceof qg ? e._current : e !== null && typeof e == 'object' ? e[T_] : e;
  24506. }
  24507. var fs;
  24508. ((e) => {
  24509. function t(n, a) {
  24510. if (a.length === n.length)
  24511. for (var o = 0; o < n.length; ) {
  24512. if (n[o] !== a[o]) return !1;
  24513. o += 1;
  24514. }
  24515. else return !1;
  24516. return !0;
  24517. }
  24518. e.equal = t;
  24519. function i(n, a, o) {
  24520. let l = s(o, n);
  24521. if (l !== void 0 && typeof l == 'object' && l !== null) {
  24522. let h = { ...a };
  24523. return (
  24524. Object.keys(l).forEach((u) => {
  24525. delete h[u];
  24526. }),
  24527. h
  24528. );
  24529. } else return a;
  24530. }
  24531. e.removeOverridden = i;
  24532. function r(n, a) {
  24533. if (((n instanceof ki || n instanceof Xg) && typeof a == 'string') || ((n instanceof rt || n instanceof qg) && typeof a == 'string'))
  24534. return n.data(a);
  24535. if ((typeof a == 'number' && Array.isArray(n)) || (typeof a == 'string' && typeof n == 'object' && n !== null)) return n[a];
  24536. }
  24537. e.zoomOnce = r;
  24538. function s(n, a, o = 0) {
  24539. for (; o < a.length && n !== void 0; ) (n = r(n, a[o])), (o += 1);
  24540. return n;
  24541. }
  24542. e.zoom = s;
  24543. })(fs || (fs = {}));
  24544. function LN(e, t) {
  24545. let i = [];
  24546. if (t.length === e.length)
  24547. for (var r = 0; r < e.length; ) {
  24548. if (t[r] === '*') i.push(e[r]);
  24549. else if (e[r] !== t[r]) return null;
  24550. r += 1;
  24551. }
  24552. else return null;
  24553. return i;
  24554. }
  24555. function pn(e, t) {
  24556. let i = [];
  24557. if (t.length <= e.length)
  24558. for (var r = 0; r < t.length; ) {
  24559. if (t[r] === '*') i.push(e[r]);
  24560. else if (e[r] !== t[r]) return null;
  24561. r += 1;
  24562. }
  24563. else return null;
  24564. return i;
  24565. }
  24566. var O_ = class {},
  24567. g1 = class extends O_ {
  24568. constructor(e) {
  24569. super(), (this.id = e);
  24570. }
  24571. },
  24572. v1 = class extends O_ {
  24573. constructor(e) {
  24574. super(), (this.data = e);
  24575. }
  24576. },
  24577. rm;
  24578. try {
  24579. rm = new TextDecoder();
  24580. } catch {}
  24581. var Se,
  24582. En,
  24583. Z = 0,
  24584. I_ = [],
  24585. sm = I_,
  24586. nm = 0,
  24587. zi = {},
  24588. pt,
  24589. xn,
  24590. gr = 0,
  24591. os = 0,
  24592. Zi,
  24593. Vs,
  24594. Ii = [],
  24595. ft,
  24596. y1 = { useRecords: !1, mapsAsObjects: !0 },
  24597. R_ = class {},
  24598. B_ = new R_();
  24599. B_.name = 'MessagePack 0xC1';
  24600. var Fo = !1,
  24601. Dd = class {
  24602. constructor(e) {
  24603. e &&
  24604. (e.useRecords === !1 && e.mapsAsObjects === void 0 && (e.mapsAsObjects = !0),
  24605. e.structures
  24606. ? (e.structures.sharedLength = e.structures.length)
  24607. : e.getStructures && (((e.structures = []).uninitialized = !0), (e.structures.sharedLength = 0))),
  24608. Object.assign(this, e);
  24609. }
  24610. unpack(e, t) {
  24611. if (Se) return j_(() => (om(), this ? this.unpack(e, t) : Dd.prototype.unpack.call(y1, e, t)));
  24612. (En = t > -1 ? t : e.length), (Z = 0), (nm = 0), (os = 0), (xn = null), (sm = I_), (Zi = null), (Se = e);
  24613. try {
  24614. ft = e.dataView || (e.dataView = new DataView(e.buffer, e.byteOffset, e.byteLength));
  24615. } catch (i) {
  24616. throw (
  24617. ((Se = null),
  24618. e instanceof Uint8Array
  24619. ? i
  24620. : new Error('Source must be a Uint8Array or Buffer but was a ' + (e && typeof e == 'object' ? e.constructor.name : typeof e)))
  24621. );
  24622. }
  24623. if (this instanceof Dd) {
  24624. if (((zi = this), this.structures)) return (pt = this.structures), _c();
  24625. (!pt || pt.length > 0) && (pt = []);
  24626. } else (zi = y1), (!pt || pt.length > 0) && (pt = []);
  24627. return _c();
  24628. }
  24629. unpackMultiple(e, t) {
  24630. let i,
  24631. r = 0;
  24632. try {
  24633. Fo = !0;
  24634. let s = e.length,
  24635. n = this ? this.unpack(e, s) : _u.unpack(e, s);
  24636. if (t) {
  24637. for (t(n); Z < s; ) if (((r = Z), t(_c()) === !1)) return;
  24638. } else {
  24639. for (i = [n]; Z < s; ) (r = Z), i.push(_c());
  24640. return i;
  24641. }
  24642. } catch (s) {
  24643. throw ((s.lastPosition = r), (s.values = i), s);
  24644. } finally {
  24645. (Fo = !1), om();
  24646. }
  24647. }
  24648. _mergeStructures(e, t) {
  24649. e = e || [];
  24650. for (let i = 0, r = e.length; i < r; i++) {
  24651. let s = e[i];
  24652. s && ((s.isShared = !0), i >= 32 && (s.highByte = (i - 32) >> 5));
  24653. }
  24654. e.sharedLength = e.length;
  24655. for (let i in t || [])
  24656. if (i >= 0) {
  24657. let r = e[i],
  24658. s = t[i];
  24659. s && (r && ((e.restoreStructures || (e.restoreStructures = []))[i] = r), (e[i] = s));
  24660. }
  24661. return (this.structures = e);
  24662. }
  24663. decode(e, t) {
  24664. return this.unpack(e, t);
  24665. }
  24666. };
  24667. function _c() {
  24668. try {
  24669. if (!zi.trusted && !Fo) {
  24670. let t = pt.sharedLength || 0;
  24671. t < pt.length && (pt.length = t);
  24672. }
  24673. let e = zt();
  24674. if (Z == En) pt.restoreStructures && x1(), (pt = null), (Se = null), Vs && (Vs = null);
  24675. else if (Z > En) {
  24676. let t = new Error('Unexpected end of MessagePack data');
  24677. throw ((t.incomplete = !0), t);
  24678. } else if (!Fo) throw new Error('Data read, but end of buffer not reached');
  24679. return e;
  24680. } catch (e) {
  24681. throw (
  24682. (pt.restoreStructures && x1(),
  24683. om(),
  24684. (e instanceof RangeError || e.message.startsWith('Unexpected end of buffer')) && (e.incomplete = !0),
  24685. e)
  24686. );
  24687. }
  24688. }
  24689. function x1() {
  24690. for (let e in pt.restoreStructures) pt[e] = pt.restoreStructures[e];
  24691. pt.restoreStructures = null;
  24692. }
  24693. function zt() {
  24694. let e = Se[Z++];
  24695. if (e < 160)
  24696. if (e < 128) {
  24697. if (e < 64) return e;
  24698. {
  24699. let t = pt[e & 63] || (zi.getStructures && z_()[e & 63]);
  24700. return t ? (t.read || (t.read = Yg(t, e & 63)), t.read()) : e;
  24701. }
  24702. } else if (e < 144)
  24703. if (((e -= 128), zi.mapsAsObjects)) {
  24704. let t = {};
  24705. for (let i = 0; i < e; i++) t[U_()] = zt();
  24706. return t;
  24707. } else {
  24708. let t = new Map();
  24709. for (let i = 0; i < e; i++) t.set(zt(), zt());
  24710. return t;
  24711. }
  24712. else {
  24713. e -= 144;
  24714. let t = new Array(e);
  24715. for (let i = 0; i < e; i++) t[i] = zt();
  24716. return t;
  24717. }
  24718. else if (e < 192) {
  24719. let t = e - 160;
  24720. if (os >= Z) return xn.slice(Z - gr, (Z += t) - gr);
  24721. if (os == 0 && En < 140) {
  24722. let i = t < 16 ? Qg(t) : N_(t);
  24723. if (i != null) return i;
  24724. }
  24725. return am(t);
  24726. } else {
  24727. let t;
  24728. switch (e) {
  24729. case 192:
  24730. return null;
  24731. case 193:
  24732. return Zi
  24733. ? ((t = zt()), t > 0 ? Zi[1].slice(Zi.position1, (Zi.position1 += t)) : Zi[0].slice(Zi.position0, (Zi.position0 -= t)))
  24734. : B_;
  24735. case 194:
  24736. return !1;
  24737. case 195:
  24738. return !0;
  24739. case 196:
  24740. return Bp(Se[Z++]);
  24741. case 197:
  24742. return (t = ft.getUint16(Z)), (Z += 2), Bp(t);
  24743. case 198:
  24744. return (t = ft.getUint32(Z)), (Z += 4), Bp(t);
  24745. case 199:
  24746. return qn(Se[Z++]);
  24747. case 200:
  24748. return (t = ft.getUint16(Z)), (Z += 2), qn(t);
  24749. case 201:
  24750. return (t = ft.getUint32(Z)), (Z += 4), qn(t);
  24751. case 202:
  24752. if (((t = ft.getFloat32(Z)), zi.useFloat32 > 2)) {
  24753. let i = Zg[((Se[Z] & 127) << 1) | (Se[Z + 1] >> 7)];
  24754. return (Z += 4), ((i * t + (t > 0 ? 0.5 : -0.5)) >> 0) / i;
  24755. }
  24756. return (Z += 4), t;
  24757. case 203:
  24758. return (t = ft.getFloat64(Z)), (Z += 8), t;
  24759. case 204:
  24760. return Se[Z++];
  24761. case 205:
  24762. return (t = ft.getUint16(Z)), (Z += 2), t;
  24763. case 206:
  24764. return (t = ft.getUint32(Z)), (Z += 4), t;
  24765. case 207:
  24766. return zi.int64AsNumber ? ((t = ft.getUint32(Z) * 4294967296), (t += ft.getUint32(Z + 4))) : (t = ft.getBigUint64(Z)), (Z += 8), t;
  24767. case 208:
  24768. return ft.getInt8(Z++);
  24769. case 209:
  24770. return (t = ft.getInt16(Z)), (Z += 2), t;
  24771. case 210:
  24772. return (t = ft.getInt32(Z)), (Z += 4), t;
  24773. case 211:
  24774. return zi.int64AsNumber ? ((t = ft.getInt32(Z) * 4294967296), (t += ft.getUint32(Z + 4))) : (t = ft.getBigInt64(Z)), (Z += 8), t;
  24775. case 212:
  24776. if (((t = Se[Z++]), t == 114)) return S1(Se[Z++] & 63);
  24777. {
  24778. let i = Ii[t];
  24779. if (i) return i.read ? (Z++, i.read(zt())) : i.noBuffer ? (Z++, i()) : i(Se.subarray(Z, ++Z));
  24780. throw new Error('Unknown extension ' + t);
  24781. }
  24782. case 213:
  24783. return (t = Se[Z]), t == 114 ? (Z++, S1(Se[Z++] & 63, Se[Z++])) : qn(2);
  24784. case 214:
  24785. return qn(4);
  24786. case 215:
  24787. return qn(8);
  24788. case 216:
  24789. return qn(16);
  24790. case 217:
  24791. return (t = Se[Z++]), os >= Z ? xn.slice(Z - gr, (Z += t) - gr) : IN(t);
  24792. case 218:
  24793. return (t = ft.getUint16(Z)), (Z += 2), os >= Z ? xn.slice(Z - gr, (Z += t) - gr) : RN(t);
  24794. case 219:
  24795. return (t = ft.getUint32(Z)), (Z += 4), os >= Z ? xn.slice(Z - gr, (Z += t) - gr) : BN(t);
  24796. case 220:
  24797. return (t = ft.getUint16(Z)), (Z += 2), w1(t);
  24798. case 221:
  24799. return (t = ft.getUint32(Z)), (Z += 4), w1(t);
  24800. case 222:
  24801. return (t = ft.getUint16(Z)), (Z += 2), _1(t);
  24802. case 223:
  24803. return (t = ft.getUint32(Z)), (Z += 4), _1(t);
  24804. default:
  24805. if (e >= 224) return e - 256;
  24806. if (e === void 0) {
  24807. let i = new Error('Unexpected end of MessagePack data');
  24808. throw ((i.incomplete = !0), i);
  24809. }
  24810. throw new Error('Unknown MessagePack token ' + e);
  24811. }
  24812. }
  24813. }
  24814. var ON = /^[a-zA-Z_$][a-zA-Z\d_$]*$/;
  24815. function Yg(e, t) {
  24816. function i() {
  24817. if (i.count++ > 2) {
  24818. let s = (e.read = new Function(
  24819. 'r',
  24820. 'return function(){return {' + e.map((n) => (ON.test(n) ? n + ':r()' : '[' + JSON.stringify(n) + ']:r()')).join(',') + '}}'
  24821. )(zt));
  24822. return e.highByte === 0 && (e.read = b1(t, e.read)), s();
  24823. }
  24824. let r = {};
  24825. for (let s = 0, n = e.length; s < n; s++) {
  24826. let a = e[s];
  24827. r[a] = zt();
  24828. }
  24829. return r;
  24830. }
  24831. return (i.count = 0), e.highByte === 0 ? b1(t, i) : i;
  24832. }
  24833. var b1 = (e, t) =>
  24834. function () {
  24835. let i = Se[Z++];
  24836. if (i === 0) return t();
  24837. let r = e < 32 ? -(e + (i << 5)) : e + (i << 5),
  24838. s = pt[r] || z_()[r];
  24839. if (!s) throw new Error('Record id is not defined for ' + r);
  24840. return s.read || (s.read = Yg(s, e)), s.read();
  24841. };
  24842. function z_() {
  24843. let e = j_(() => ((Se = null), zi.getStructures()));
  24844. return (pt = zi._mergeStructures(e, pt));
  24845. }
  24846. var am = wu,
  24847. IN = wu,
  24848. RN = wu,
  24849. BN = wu;
  24850. function wu(e) {
  24851. let t;
  24852. if (e < 16 && (t = Qg(e))) return t;
  24853. if (e > 64 && rm) return rm.decode(Se.subarray(Z, (Z += e)));
  24854. let i = Z + e,
  24855. r = [];
  24856. for (t = ''; Z < i; ) {
  24857. let s = Se[Z++];
  24858. if ((s & 128) === 0) r.push(s);
  24859. else if ((s & 224) === 192) {
  24860. let n = Se[Z++] & 63;
  24861. r.push(((s & 31) << 6) | n);
  24862. } else if ((s & 240) === 224) {
  24863. let n = Se[Z++] & 63,
  24864. a = Se[Z++] & 63;
  24865. r.push(((s & 31) << 12) | (n << 6) | a);
  24866. } else if ((s & 248) === 240) {
  24867. let n = Se[Z++] & 63,
  24868. a = Se[Z++] & 63,
  24869. o = Se[Z++] & 63,
  24870. l = ((s & 7) << 18) | (n << 12) | (a << 6) | o;
  24871. l > 65535 && ((l -= 65536), r.push(((l >>> 10) & 1023) | 55296), (l = 56320 | (l & 1023))), r.push(l);
  24872. } else r.push(s);
  24873. r.length >= 4096 && ((t += li.apply(String, r)), (r.length = 0));
  24874. }
  24875. return r.length > 0 && (t += li.apply(String, r)), t;
  24876. }
  24877. function w1(e) {
  24878. let t = new Array(e);
  24879. for (let i = 0; i < e; i++) t[i] = zt();
  24880. return t;
  24881. }
  24882. function _1(e) {
  24883. if (zi.mapsAsObjects) {
  24884. let t = {};
  24885. for (let i = 0; i < e; i++) t[U_()] = zt();
  24886. return t;
  24887. } else {
  24888. let t = new Map();
  24889. for (let i = 0; i < e; i++) t.set(zt(), zt());
  24890. return t;
  24891. }
  24892. }
  24893. var li = String.fromCharCode;
  24894. function N_(e) {
  24895. let t = Z,
  24896. i = new Array(e);
  24897. for (let r = 0; r < e; r++) {
  24898. let s = Se[Z++];
  24899. if ((s & 128) > 0) {
  24900. Z = t;
  24901. return;
  24902. }
  24903. i[r] = s;
  24904. }
  24905. return li.apply(String, i);
  24906. }
  24907. function Qg(e) {
  24908. if (e < 4)
  24909. if (e < 2) {
  24910. if (e === 0) return '';
  24911. {
  24912. let t = Se[Z++];
  24913. if ((t & 128) > 1) {
  24914. Z -= 1;
  24915. return;
  24916. }
  24917. return li(t);
  24918. }
  24919. } else {
  24920. let t = Se[Z++],
  24921. i = Se[Z++];
  24922. if ((t & 128) > 0 || (i & 128) > 0) {
  24923. Z -= 2;
  24924. return;
  24925. }
  24926. if (e < 3) return li(t, i);
  24927. let r = Se[Z++];
  24928. if ((r & 128) > 0) {
  24929. Z -= 3;
  24930. return;
  24931. }
  24932. return li(t, i, r);
  24933. }
  24934. else {
  24935. let t = Se[Z++],
  24936. i = Se[Z++],
  24937. r = Se[Z++],
  24938. s = Se[Z++];
  24939. if ((t & 128) > 0 || (i & 128) > 0 || (r & 128) > 0 || (s & 128) > 0) {
  24940. Z -= 4;
  24941. return;
  24942. }
  24943. if (e < 6) {
  24944. if (e === 4) return li(t, i, r, s);
  24945. {
  24946. let n = Se[Z++];
  24947. if ((n & 128) > 0) {
  24948. Z -= 5;
  24949. return;
  24950. }
  24951. return li(t, i, r, s, n);
  24952. }
  24953. } else if (e < 8) {
  24954. let n = Se[Z++],
  24955. a = Se[Z++];
  24956. if ((n & 128) > 0 || (a & 128) > 0) {
  24957. Z -= 6;
  24958. return;
  24959. }
  24960. if (e < 7) return li(t, i, r, s, n, a);
  24961. let o = Se[Z++];
  24962. if ((o & 128) > 0) {
  24963. Z -= 7;
  24964. return;
  24965. }
  24966. return li(t, i, r, s, n, a, o);
  24967. } else {
  24968. let n = Se[Z++],
  24969. a = Se[Z++],
  24970. o = Se[Z++],
  24971. l = Se[Z++];
  24972. if ((n & 128) > 0 || (a & 128) > 0 || (o & 128) > 0 || (l & 128) > 0) {
  24973. Z -= 8;
  24974. return;
  24975. }
  24976. if (e < 10) {
  24977. if (e === 8) return li(t, i, r, s, n, a, o, l);
  24978. {
  24979. let h = Se[Z++];
  24980. if ((h & 128) > 0) {
  24981. Z -= 9;
  24982. return;
  24983. }
  24984. return li(t, i, r, s, n, a, o, l, h);
  24985. }
  24986. } else if (e < 12) {
  24987. let h = Se[Z++],
  24988. u = Se[Z++];
  24989. if ((h & 128) > 0 || (u & 128) > 0) {
  24990. Z -= 10;
  24991. return;
  24992. }
  24993. if (e < 11) return li(t, i, r, s, n, a, o, l, h, u);
  24994. let c = Se[Z++];
  24995. if ((c & 128) > 0) {
  24996. Z -= 11;
  24997. return;
  24998. }
  24999. return li(t, i, r, s, n, a, o, l, h, u, c);
  25000. } else {
  25001. let h = Se[Z++],
  25002. u = Se[Z++],
  25003. c = Se[Z++],
  25004. d = Se[Z++];
  25005. if ((h & 128) > 0 || (u & 128) > 0 || (c & 128) > 0 || (d & 128) > 0) {
  25006. Z -= 12;
  25007. return;
  25008. }
  25009. if (e < 14) {
  25010. if (e === 12) return li(t, i, r, s, n, a, o, l, h, u, c, d);
  25011. {
  25012. let p = Se[Z++];
  25013. if ((p & 128) > 0) {
  25014. Z -= 13;
  25015. return;
  25016. }
  25017. return li(t, i, r, s, n, a, o, l, h, u, c, d, p);
  25018. }
  25019. } else {
  25020. let p = Se[Z++],
  25021. f = Se[Z++];
  25022. if ((p & 128) > 0 || (f & 128) > 0) {
  25023. Z -= 14;
  25024. return;
  25025. }
  25026. if (e < 15) return li(t, i, r, s, n, a, o, l, h, u, c, d, p, f);
  25027. let g = Se[Z++];
  25028. if ((g & 128) > 0) {
  25029. Z -= 15;
  25030. return;
  25031. }
  25032. return li(t, i, r, s, n, a, o, l, h, u, c, d, p, f, g);
  25033. }
  25034. }
  25035. }
  25036. }
  25037. }
  25038. function Bp(e) {
  25039. return zi.copyBuffers ? Uint8Array.prototype.slice.call(Se, Z, (Z += e)) : Se.subarray(Z, (Z += e));
  25040. }
  25041. function qn(e) {
  25042. let t = Se[Z++];
  25043. if (Ii[t]) return Ii[t](Se.subarray(Z, (Z += e)));
  25044. throw new Error('Unknown extension type ' + t);
  25045. }
  25046. var A1 = new Array(4096);
  25047. function U_() {
  25048. let e = Se[Z++];
  25049. if (e >= 160 && e < 192) {
  25050. if (((e = e - 160), os >= Z)) return xn.slice(Z - gr, (Z += e) - gr);
  25051. if (!(os == 0 && En < 180)) return am(e);
  25052. } else return Z--, zt();
  25053. let t = ((e << 5) ^ (e > 1 ? ft.getUint16(Z) : e > 0 ? Se[Z] : 0)) & 4095,
  25054. i = A1[t],
  25055. r = Z,
  25056. s = Z + e - 3,
  25057. n,
  25058. a = 0;
  25059. if (i && i.bytes == e) {
  25060. for (; r < s; ) {
  25061. if (((n = ft.getUint32(r)), n != i[a++])) {
  25062. r = 1879048192;
  25063. break;
  25064. }
  25065. r += 4;
  25066. }
  25067. for (s += 3; r < s; )
  25068. if (((n = Se[r++]), n != i[a++])) {
  25069. r = 1879048192;
  25070. break;
  25071. }
  25072. if (r === s) return (Z = r), i.string;
  25073. (s -= 3), (r = Z);
  25074. }
  25075. for (i = [], A1[t] = i, i.bytes = e; r < s; ) (n = ft.getUint32(r)), i.push(n), (r += 4);
  25076. for (s += 3; r < s; ) (n = Se[r++]), i.push(n);
  25077. let o = e < 16 ? Qg(e) : N_(e);
  25078. return o != null ? (i.string = o) : (i.string = am(e));
  25079. }
  25080. var S1 = (e, t) => {
  25081. var i = zt();
  25082. let r = e;
  25083. t !== void 0 && ((e = e < 32 ? -((t << 5) + e) : (t << 5) + e), (i.highByte = t));
  25084. let s = pt[e];
  25085. return s && s.isShared && ((pt.restoreStructures || (pt.restoreStructures = []))[e] = s), (pt[e] = i), (i.read = Yg(i, r)), i.read();
  25086. },
  25087. F_ = typeof self == 'object' ? self : global;
  25088. Ii[0] = () => {};
  25089. Ii[0].noBuffer = !0;
  25090. Ii[101] = () => {
  25091. let e = zt();
  25092. return (F_[e[0]] || Error)(e[1]);
  25093. };
  25094. Ii[105] = (e) => {
  25095. let t = ft.getUint32(Z - 4);
  25096. Vs || (Vs = new Map());
  25097. let i = Se[Z],
  25098. r;
  25099. (i >= 144 && i < 160) || i == 220 || i == 221 ? (r = []) : (r = {});
  25100. let s = { target: r };
  25101. Vs.set(t, s);
  25102. let n = zt();
  25103. return s.used ? Object.assign(r, n) : ((s.target = n), n);
  25104. };
  25105. Ii[112] = (e) => {
  25106. let t = ft.getUint32(Z - 4),
  25107. i = Vs.get(t);
  25108. return (i.used = !0), i.target;
  25109. };
  25110. Ii[115] = () => new Set(zt());
  25111. var k_ = ['Int8', 'Uint8', 'Uint8Clamped', 'Int16', 'Uint16', 'Int32', 'Uint32', 'Float32', 'Float64', 'BigInt64', 'BigUint64'].map(
  25112. (e) => e + 'Array'
  25113. );
  25114. Ii[116] = (e) => {
  25115. let t = e[0],
  25116. i = k_[t];
  25117. if (!i) throw new Error('Could not find typed array for code ' + t);
  25118. return new F_[i](Uint8Array.prototype.slice.call(e, 1).buffer);
  25119. };
  25120. Ii[120] = () => {
  25121. let e = zt();
  25122. return new RegExp(e[0], e[1]);
  25123. };
  25124. Ii[98] = (e) => {
  25125. let t = (e[0] << 24) + (e[1] << 16) + (e[2] << 8) + e[3],
  25126. i = Z;
  25127. (Z += t - 4), (Zi = [zt(), zt()]), (Zi.position0 = 0), (Zi.position1 = 0);
  25128. let r = Z;
  25129. Z = i;
  25130. try {
  25131. return zt();
  25132. } finally {
  25133. Z = r;
  25134. }
  25135. };
  25136. Ii[255] = (e) =>
  25137. e.length == 4
  25138. ? new Date((e[0] * 16777216 + (e[1] << 16) + (e[2] << 8) + e[3]) * 1e3)
  25139. : e.length == 8
  25140. ? new Date(
  25141. ((e[0] << 22) + (e[1] << 14) + (e[2] << 6) + (e[3] >> 2)) / 1e6 +
  25142. ((e[3] & 3) * 4294967296 + e[4] * 16777216 + (e[5] << 16) + (e[6] << 8) + e[7]) * 1e3
  25143. )
  25144. : e.length == 12
  25145. ? new Date(
  25146. ((e[0] << 24) + (e[1] << 16) + (e[2] << 8) + e[3]) / 1e6 +
  25147. ((e[4] & 128 ? -281474976710656 : 0) +
  25148. e[6] * 1099511627776 +
  25149. e[7] * 4294967296 +
  25150. e[8] * 16777216 +
  25151. (e[9] << 16) +
  25152. (e[10] << 8) +
  25153. e[11]) *
  25154. 1e3
  25155. )
  25156. : new Date('invalid');
  25157. function j_(e) {
  25158. let t = En,
  25159. i = Z,
  25160. r = nm,
  25161. s = gr,
  25162. n = os,
  25163. a = xn,
  25164. o = sm,
  25165. l = Vs,
  25166. h = Zi,
  25167. u = new Uint8Array(Se.slice(0, En)),
  25168. c = pt,
  25169. d = pt.slice(0, pt.length),
  25170. p = zi,
  25171. f = Fo,
  25172. g = e();
  25173. return (
  25174. (En = t),
  25175. (Z = i),
  25176. (nm = r),
  25177. (gr = s),
  25178. (os = n),
  25179. (xn = a),
  25180. (sm = o),
  25181. (Vs = l),
  25182. (Zi = h),
  25183. (Se = u),
  25184. (Fo = f),
  25185. (pt = c),
  25186. pt.splice(0, pt.length, ...d),
  25187. (zi = p),
  25188. (ft = new DataView(Se.buffer, Se.byteOffset, Se.byteLength)),
  25189. g
  25190. );
  25191. }
  25192. function om() {
  25193. (Se = null), (Vs = null), (pt = null);
  25194. }
  25195. function zN(e) {
  25196. e.unpack ? (Ii[e.type] = e.unpack) : (Ii[e.type] = e);
  25197. }
  25198. var Zg = new Array(147);
  25199. for (let e = 0; e < 256; e++) Zg[e] = +('1e' + Math.floor(45.15 - e * 0.30103));
  25200. var _u = new Dd({ useRecords: !1 }),
  25201. f9 = _u.unpack,
  25202. m9 = _u.unpackMultiple,
  25203. g9 = _u.unpack,
  25204. NN = { NEVER: 0, ALWAYS: 1, DECIMAL_ROUND: 3, DECIMAL_FIT: 4 },
  25205. UN = new Float32Array(1),
  25206. v9 = new Uint8Array(UN.buffer, 0, 4),
  25207. id;
  25208. try {
  25209. id = new TextEncoder();
  25210. } catch {}
  25211. var Ld,
  25212. Kg,
  25213. Au = typeof Buffer < 'u',
  25214. zp = Au ? Buffer.allocUnsafeSlow : Uint8Array,
  25215. G_ = Au ? Buffer : Uint8Array,
  25216. M1 = Au ? 4294967296 : 2144337920,
  25217. le,
  25218. jt,
  25219. te = 0,
  25220. Xr,
  25221. qr = null,
  25222. FN = /[\u0080-\uFFFF]/,
  25223. wl = Symbol('record-id'),
  25224. V_ = class extends Dd {
  25225. constructor(e) {
  25226. super(e), (this.offset = 0);
  25227. let t,
  25228. i,
  25229. r,
  25230. s,
  25231. n,
  25232. a,
  25233. o = 0,
  25234. l = G_.prototype.utf8Write
  25235. ? function (S, _, M) {
  25236. return le.utf8Write(S, _, M);
  25237. }
  25238. : id && id.encodeInto
  25239. ? function (S, _) {
  25240. return id.encodeInto(S, le.subarray(_)).written;
  25241. }
  25242. : !1,
  25243. h = this;
  25244. e || (e = {});
  25245. let u = e && e.sequential,
  25246. c = e.structures || e.saveStructures,
  25247. d = e.maxSharedStructures;
  25248. if ((d == null && (d = c ? 32 : 0), d > 8160)) throw new Error('Maximum maxSharedStructure is 8160');
  25249. let p = e.maxOwnStructures;
  25250. p == null && (p = c ? 32 : 64), u && !e.saveStructures && (this.structures = []);
  25251. let f = d > 32 || p + d > 64,
  25252. g = d + 64,
  25253. m = d + p + 64;
  25254. if (m > 8256) throw new Error('Maximum maxSharedStructure + maxOwnStructure is 8192');
  25255. let v = [],
  25256. y = 0,
  25257. b = 0;
  25258. this.pack = this.encode = function (S, _) {
  25259. if (
  25260. (le || ((le = new zp(8192)), (jt = new DataView(le.buffer, 0, 8192)), (te = 0)),
  25261. (Xr = le.length - 10),
  25262. Xr - te < 2048
  25263. ? ((le = new zp(le.length)), (jt = new DataView(le.buffer, 0, le.length)), (Xr = le.length - 10), (te = 0))
  25264. : (te = (te + 7) & 2147483640),
  25265. (i = te),
  25266. (a = h.structuredClone ? new Map() : null),
  25267. h.bundleStrings ? ((qr = ['', '']), (le[te++] = 214), (le[te++] = 98), (qr.position = te - i), (te += 4)) : (qr = null),
  25268. (r = h.structures),
  25269. r)
  25270. ) {
  25271. r.uninitialized && (r = h._mergeStructures(h.getStructures()));
  25272. let M = r.sharedLength || 0;
  25273. if (M > d)
  25274. throw new Error(
  25275. 'Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to ' + r.sharedLength
  25276. );
  25277. if (!r.transitions) {
  25278. r.transitions = Object.create(null);
  25279. for (let C = 0; C < M; C++) {
  25280. let T = r[C];
  25281. if (!T) continue;
  25282. let P,
  25283. L = r.transitions;
  25284. for (let D = 0, k = T.length; D < k; D++) {
  25285. let W = T[D];
  25286. (P = L[W]), P || (P = L[W] = Object.create(null)), (L = P);
  25287. }
  25288. L[wl] = C + 64;
  25289. }
  25290. o = M;
  25291. }
  25292. u || (r.nextId = M + 64);
  25293. }
  25294. s && (s = !1), (n = r || []);
  25295. try {
  25296. if ((x(S), qr)) {
  25297. jt.setUint32(qr.position + i, te - qr.position - i);
  25298. let M = qr;
  25299. (qr = null), x(M[0]), x(M[1]);
  25300. }
  25301. if (((h.offset = te), a && a.idsToInsert)) {
  25302. (te += a.idsToInsert.length * 6), te > Xr && A(te), (h.offset = te);
  25303. let M = jN(le.subarray(i, te), a.idsToInsert);
  25304. return (a = null), M;
  25305. }
  25306. return _ & GN ? ((le.start = i), (le.end = te), le) : le.subarray(i, te);
  25307. } finally {
  25308. if (r) {
  25309. if ((b < 10 && b++, y > 1e4)) (r.transitions = null), (b = 0), (y = 0), v.length > 0 && (v = []);
  25310. else if (v.length > 0 && !u) {
  25311. for (let M = 0, C = v.length; M < C; M++) v[M][wl] = 0;
  25312. v = [];
  25313. }
  25314. if (s && h.saveStructures) {
  25315. let M = r.sharedLength || d;
  25316. r.length > M && (r = r.slice(0, M));
  25317. let C = le.subarray(i, te);
  25318. return h.saveStructures(r, o) === !1 ? (h._mergeStructures(h.getStructures()), h.pack(S)) : ((o = M), C);
  25319. }
  25320. }
  25321. _ & VN && (te = i);
  25322. }
  25323. };
  25324. let x = (S) => {
  25325. te > Xr && (le = A(te));
  25326. var _ = typeof S,
  25327. M;
  25328. if (_ === 'string') {
  25329. let C = S.length;
  25330. if (qr && C >= 8 && C < 4096) {
  25331. let L = FN.test(S);
  25332. (qr[L ? 0 : 1] += S), (le[te++] = 193), x(L ? -C : C);
  25333. return;
  25334. }
  25335. let T;
  25336. C < 32 ? (T = 1) : C < 256 ? (T = 2) : C < 65536 ? (T = 3) : (T = 5);
  25337. let P = C * 3;
  25338. if ((te + P > Xr && (le = A(te + P)), C < 64 || !l)) {
  25339. let L,
  25340. D,
  25341. k,
  25342. W = te + T;
  25343. for (L = 0; L < C; L++)
  25344. (D = S.charCodeAt(L)),
  25345. D < 128
  25346. ? (le[W++] = D)
  25347. : D < 2048
  25348. ? ((le[W++] = (D >> 6) | 192), (le[W++] = (D & 63) | 128))
  25349. : (D & 64512) === 55296 && ((k = S.charCodeAt(L + 1)) & 64512) === 56320
  25350. ? ((D = 65536 + ((D & 1023) << 10) + (k & 1023)),
  25351. L++,
  25352. (le[W++] = (D >> 18) | 240),
  25353. (le[W++] = ((D >> 12) & 63) | 128),
  25354. (le[W++] = ((D >> 6) & 63) | 128),
  25355. (le[W++] = (D & 63) | 128))
  25356. : ((le[W++] = (D >> 12) | 224), (le[W++] = ((D >> 6) & 63) | 128), (le[W++] = (D & 63) | 128));
  25357. M = W - te - T;
  25358. } else M = l(S, te + T, P);
  25359. M < 32
  25360. ? (le[te++] = 160 | M)
  25361. : M < 256
  25362. ? (T < 2 && le.copyWithin(te + 2, te + 1, te + 1 + M), (le[te++] = 217), (le[te++] = M))
  25363. : M < 65536
  25364. ? (T < 3 && le.copyWithin(te + 3, te + 2, te + 2 + M), (le[te++] = 218), (le[te++] = M >> 8), (le[te++] = M & 255))
  25365. : (T < 5 && le.copyWithin(te + 5, te + 3, te + 3 + M), (le[te++] = 219), jt.setUint32(te, M), (te += 4)),
  25366. (te += M);
  25367. } else if (_ === 'number')
  25368. if (S >>> 0 === S)
  25369. S < 64
  25370. ? (le[te++] = S)
  25371. : S < 256
  25372. ? ((le[te++] = 204), (le[te++] = S))
  25373. : S < 65536
  25374. ? ((le[te++] = 205), (le[te++] = S >> 8), (le[te++] = S & 255))
  25375. : ((le[te++] = 206), jt.setUint32(te, S), (te += 4));
  25376. else if (S >> 0 === S)
  25377. S >= -32
  25378. ? (le[te++] = 256 + S)
  25379. : S >= -128
  25380. ? ((le[te++] = 208), (le[te++] = S + 256))
  25381. : S >= -32768
  25382. ? ((le[te++] = 209), jt.setInt16(te, S), (te += 2))
  25383. : ((le[te++] = 210), jt.setInt32(te, S), (te += 4));
  25384. else {
  25385. let C;
  25386. if ((C = this.useFloat32) > 0 && S < 4294967296 && S >= -2147483648) {
  25387. (le[te++] = 202), jt.setFloat32(te, S);
  25388. let T;
  25389. if (C < 4 || (T = S * Zg[((le[te] & 127) << 1) | (le[te + 1] >> 7)]) >> 0 === T) {
  25390. te += 4;
  25391. return;
  25392. } else te--;
  25393. }
  25394. (le[te++] = 203), jt.setFloat64(te, S), (te += 8);
  25395. }
  25396. else if (_ === 'object')
  25397. if (!S) le[te++] = 192;
  25398. else {
  25399. if (a) {
  25400. let T = a.get(S);
  25401. if (T) {
  25402. if (!T.id) {
  25403. let P = a.idsToInsert || (a.idsToInsert = []);
  25404. T.id = P.push(T);
  25405. }
  25406. (le[te++] = 214), (le[te++] = 112), jt.setUint32(te, T.id), (te += 4);
  25407. return;
  25408. } else a.set(S, { offset: te - i });
  25409. }
  25410. let C = S.constructor;
  25411. if (C === Object) w(S, !0);
  25412. else if (C === Array) {
  25413. (M = S.length),
  25414. M < 16
  25415. ? (le[te++] = 144 | M)
  25416. : M < 65536
  25417. ? ((le[te++] = 220), (le[te++] = M >> 8), (le[te++] = M & 255))
  25418. : ((le[te++] = 221), jt.setUint32(te, M), (te += 4));
  25419. for (let T = 0; T < M; T++) x(S[T]);
  25420. } else if (C === Map) {
  25421. (M = S.size),
  25422. M < 16
  25423. ? (le[te++] = 128 | M)
  25424. : M < 65536
  25425. ? ((le[te++] = 222), (le[te++] = M >> 8), (le[te++] = M & 255))
  25426. : ((le[te++] = 223), jt.setUint32(te, M), (te += 4));
  25427. for (let [T, P] of S) x(T), x(P);
  25428. } else {
  25429. for (let T = 0, P = Ld.length; T < P; T++) {
  25430. let L = Kg[T];
  25431. if (S instanceof L) {
  25432. let D = Ld[T];
  25433. if (D.write) {
  25434. D.type && ((le[te++] = 212), (le[te++] = D.type), (le[te++] = 0)), x(D.write.call(this, S));
  25435. return;
  25436. }
  25437. let k = le,
  25438. W = jt,
  25439. X = te;
  25440. le = null;
  25441. let z;
  25442. try {
  25443. z = D.pack.call(
  25444. this,
  25445. S,
  25446. (j) => ((le = k), (k = null), (te += j), te > Xr && A(te), { target: le, targetView: jt, position: te - j }),
  25447. x
  25448. );
  25449. } finally {
  25450. k && ((le = k), (jt = W), (te = X), (Xr = le.length - 10));
  25451. }
  25452. z && (z.length + te > Xr && A(z.length + te), (te = kN(z, le, te, D.type)));
  25453. return;
  25454. }
  25455. }
  25456. w(S, !S.hasOwnProperty);
  25457. }
  25458. }
  25459. else if (_ === 'boolean') le[te++] = S ? 195 : 194;
  25460. else if (_ === 'bigint') {
  25461. if (S < BigInt(1) << BigInt(63) && S >= -(BigInt(1) << BigInt(63))) (le[te++] = 211), jt.setBigInt64(te, S);
  25462. else if (S < BigInt(1) << BigInt(64) && S > 0) (le[te++] = 207), jt.setBigUint64(te, S);
  25463. else if (this.largeBigIntToFloat) (le[te++] = 203), jt.setFloat64(te, Number(S));
  25464. else
  25465. throw new RangeError(
  25466. S + ' was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64'
  25467. );
  25468. te += 8;
  25469. } else if (_ === 'undefined') this.encodeUndefinedAsNil ? (le[te++] = 192) : ((le[te++] = 212), (le[te++] = 0), (le[te++] = 0));
  25470. else if (_ === 'function') x(this.writeFunction && this.writeFunction());
  25471. else throw new Error('Unknown type: ' + _);
  25472. },
  25473. w =
  25474. this.useRecords === !1
  25475. ? this.variableMapSize
  25476. ? (S) => {
  25477. let _ = Object.keys(S),
  25478. M = _.length;
  25479. M < 16
  25480. ? (le[te++] = 128 | M)
  25481. : M < 65536
  25482. ? ((le[te++] = 222), (le[te++] = M >> 8), (le[te++] = M & 255))
  25483. : ((le[te++] = 223), jt.setUint32(te, M), (te += 4));
  25484. let C;
  25485. for (let T = 0; T < M; T++) x((C = _[T])), x(S[C]);
  25486. }
  25487. : (S, _) => {
  25488. le[te++] = 222;
  25489. let M = te - i;
  25490. te += 2;
  25491. let C = 0;
  25492. for (let T in S) (_ || S.hasOwnProperty(T)) && (x(T), x(S[T]), C++);
  25493. (le[M++ + i] = C >> 8), (le[M + i] = C & 255);
  25494. }
  25495. : (S) => {
  25496. let _ = Object.keys(S),
  25497. M,
  25498. C = n.transitions || (n.transitions = Object.create(null)),
  25499. T = 0;
  25500. for (let L = 0, D = _.length; L < D; L++) {
  25501. let k = _[L];
  25502. (M = C[k]), M || ((M = C[k] = Object.create(null)), T++), (C = M);
  25503. }
  25504. let P = C[wl];
  25505. if (P) P >= 96 && f ? ((le[te++] = ((P -= 96) & 31) + 96), (le[te++] = P >> 5)) : (le[te++] = P);
  25506. else {
  25507. (P = n.nextId),
  25508. P || (P = 64),
  25509. P < g && this.shouldShareStructure && !this.shouldShareStructure(_)
  25510. ? ((P = n.nextOwnId), P < m || (P = g), (n.nextOwnId = P + 1))
  25511. : (P >= m && (P = g), (n.nextId = P + 1));
  25512. let L = (_.highByte = P >= 96 && f ? (P - 96) >> 5 : -1);
  25513. (C[wl] = P),
  25514. (n[P - 64] = _),
  25515. P < g
  25516. ? ((_.isShared = !0),
  25517. (n.sharedLength = P - 63),
  25518. (s = !0),
  25519. L >= 0 ? ((le[te++] = (P & 31) + 96), (le[te++] = L)) : (le[te++] = P))
  25520. : (L >= 0
  25521. ? ((le[te++] = 213), (le[te++] = 114), (le[te++] = (P & 31) + 96), (le[te++] = L))
  25522. : ((le[te++] = 212), (le[te++] = 114), (le[te++] = P)),
  25523. T && (y += b * T),
  25524. v.length >= p && (v.shift()[wl] = 0),
  25525. v.push(C),
  25526. x(_));
  25527. }
  25528. for (let L = 0, D = _.length; L < D; L++) x(S[_[L]]);
  25529. },
  25530. A = (S) => {
  25531. let _;
  25532. if (S > 16777216) {
  25533. if (S - i > M1) throw new Error('Packed buffer would be larger than maximum buffer size');
  25534. _ = Math.min(M1, Math.round(Math.max((S - i) * (S > 67108864 ? 1.25 : 2), 4194304) / 4096) * 4096);
  25535. } else _ = ((Math.max((S - i) << 2, le.length - 1) >> 12) + 1) << 12;
  25536. let M = new zp(_);
  25537. return (
  25538. (jt = new DataView(M.buffer, 0, _)),
  25539. le.copy ? le.copy(M, 0, i, S) : M.set(le.slice(i, S)),
  25540. (te -= i),
  25541. (i = 0),
  25542. (Xr = M.length - 10),
  25543. (le = M)
  25544. );
  25545. };
  25546. }
  25547. useBuffer(e) {
  25548. (le = e), (jt = new DataView(le.buffer, le.byteOffset, le.byteLength)), (te = 0);
  25549. }
  25550. };
  25551. Kg = [Date, Set, Error, RegExp, ArrayBuffer, Object.getPrototypeOf(Uint8Array.prototype).constructor, R_];
  25552. Ld = [
  25553. {
  25554. pack(e, t, i) {
  25555. let r = e.getTime() / 1e3;
  25556. if ((this.useTimestamp32 || e.getMilliseconds() === 0) && r >= 0 && r < 4294967296) {
  25557. let { target: s, targetView: n, position: a } = t(6);
  25558. (s[a++] = 214), (s[a++] = 255), n.setUint32(a, r);
  25559. } else if (r > 0 && r < 17179869184) {
  25560. let { target: s, targetView: n, position: a } = t(10);
  25561. (s[a++] = 215), (s[a++] = 255), n.setUint32(a, e.getMilliseconds() * 4e6 + ((r / 1e3 / 4294967296) >> 0)), n.setUint32(a + 4, r);
  25562. } else if (isNaN(r)) {
  25563. if (this.onInvalidDate) return t(0), i(this.onInvalidDate());
  25564. let { target: s, targetView: n, position: a } = t(3);
  25565. (s[a++] = 212), (s[a++] = 255), (s[a++] = 255);
  25566. } else {
  25567. let { target: s, targetView: n, position: a } = t(15);
  25568. (s[a++] = 199),
  25569. (s[a++] = 12),
  25570. (s[a++] = 255),
  25571. n.setUint32(a, e.getMilliseconds() * 1e6),
  25572. n.setBigInt64(a + 4, BigInt(Math.floor(r)));
  25573. }
  25574. }
  25575. },
  25576. {
  25577. pack(e, t, i) {
  25578. let r = Array.from(e),
  25579. { target: s, position: n } = t(this.structuredClone ? 3 : 0);
  25580. this.structuredClone && ((s[n++] = 212), (s[n++] = 115), (s[n++] = 0)), i(r);
  25581. }
  25582. },
  25583. {
  25584. pack(e, t, i) {
  25585. let { target: r, position: s } = t(this.structuredClone ? 3 : 0);
  25586. this.structuredClone && ((r[s++] = 212), (r[s++] = 101), (r[s++] = 0)), i([e.name, e.message]);
  25587. }
  25588. },
  25589. {
  25590. pack(e, t, i) {
  25591. let { target: r, position: s } = t(this.structuredClone ? 3 : 0);
  25592. this.structuredClone && ((r[s++] = 212), (r[s++] = 120), (r[s++] = 0)), i([e.source, e.flags]);
  25593. }
  25594. },
  25595. {
  25596. pack(e, t) {
  25597. this.structuredClone ? E1(e, 16, t) : C1(Au ? Buffer.from(e) : new Uint8Array(e), t);
  25598. }
  25599. },
  25600. {
  25601. pack(e, t) {
  25602. let i = e.constructor;
  25603. i !== G_ && this.structuredClone ? E1(e, k_.indexOf(i.name), t) : C1(e, t);
  25604. }
  25605. },
  25606. {
  25607. pack(e, t) {
  25608. let { target: i, position: r } = t(1);
  25609. i[r] = 193;
  25610. }
  25611. }
  25612. ];
  25613. function E1(e, t, i, r) {
  25614. let s = e.byteLength;
  25615. if (s + 1 < 256) {
  25616. var { target: n, position: a } = i(4 + s);
  25617. (n[a++] = 199), (n[a++] = s + 1);
  25618. } else if (s + 1 < 65536) {
  25619. var { target: n, position: a } = i(5 + s);
  25620. (n[a++] = 200), (n[a++] = (s + 1) >> 8), (n[a++] = (s + 1) & 255);
  25621. } else {
  25622. var { target: n, position: a, targetView: o } = i(7 + s);
  25623. (n[a++] = 201), o.setUint32(a, s + 1), (a += 4);
  25624. }
  25625. (n[a++] = 116), (n[a++] = t), n.set(new Uint8Array(e.buffer, e.byteOffset, e.byteLength), a);
  25626. }
  25627. function C1(e, t) {
  25628. let i = e.byteLength;
  25629. var r, s;
  25630. if (i < 256) {
  25631. var { target: r, position: s } = t(i + 2);
  25632. (r[s++] = 196), (r[s++] = i);
  25633. } else if (i < 65536) {
  25634. var { target: r, position: s } = t(i + 3);
  25635. (r[s++] = 197), (r[s++] = i >> 8), (r[s++] = i & 255);
  25636. } else {
  25637. var { target: r, position: s, targetView: n } = t(i + 5);
  25638. (r[s++] = 198), n.setUint32(s, i), (s += 4);
  25639. }
  25640. r.set(e, s);
  25641. }
  25642. function kN(e, t, i, r) {
  25643. let s = e.length;
  25644. switch (s) {
  25645. case 1:
  25646. t[i++] = 212;
  25647. break;
  25648. case 2:
  25649. t[i++] = 213;
  25650. break;
  25651. case 4:
  25652. t[i++] = 214;
  25653. break;
  25654. case 8:
  25655. t[i++] = 215;
  25656. break;
  25657. case 16:
  25658. t[i++] = 216;
  25659. break;
  25660. default:
  25661. s < 256
  25662. ? ((t[i++] = 199), (t[i++] = s))
  25663. : s < 65536
  25664. ? ((t[i++] = 200), (t[i++] = s >> 8), (t[i++] = s & 255))
  25665. : ((t[i++] = 201), (t[i++] = s >> 24), (t[i++] = (s >> 16) & 255), (t[i++] = (s >> 8) & 255), (t[i++] = s & 255));
  25666. }
  25667. return (t[i++] = r), t.set(e, i), (i += s), i;
  25668. }
  25669. function jN(e, t) {
  25670. let i,
  25671. r = t.length * 6,
  25672. s = e.length - r;
  25673. for (t.sort((n, a) => (n.offset > a.offset ? 1 : -1)); (i = t.pop()); ) {
  25674. let n = i.offset,
  25675. a = i.id;
  25676. e.copyWithin(n + r, n, s), (r -= 6);
  25677. let o = n + r;
  25678. (e[o++] = 214), (e[o++] = 105), (e[o++] = a >> 24), (e[o++] = (a >> 16) & 255), (e[o++] = (a >> 8) & 255), (e[o++] = a & 255), (s = n);
  25679. }
  25680. return e;
  25681. }
  25682. function tl(e) {
  25683. if (e.Class) {
  25684. if (!e.pack && !e.write) throw new Error('Extension has no pack or write function');
  25685. if (e.pack && !e.type) throw new Error('Extension has no type (numeric code to identify the extension)');
  25686. Kg.unshift(e.Class), Ld.unshift(e);
  25687. }
  25688. zN(e);
  25689. }
  25690. var H_ = new V_({ useRecords: !1 }),
  25691. y9 = H_.pack,
  25692. x9 = H_.pack,
  25693. { NEVER: b9, ALWAYS: w9, DECIMAL_ROUND: _9, DECIMAL_FIT: A9 } = NN,
  25694. GN = 512,
  25695. VN = 1024,
  25696. T1 = new V_({ structuredClone: !0 });
  25697. tl({
  25698. Class: Qt.prototype.constructor,
  25699. type: 1,
  25700. write(e) {
  25701. return { ...e };
  25702. },
  25703. read(e) {
  25704. return Object.setPrototypeOf(e, Qt.prototype), e;
  25705. }
  25706. });
  25707. tl({
  25708. Class: rt.prototype.constructor,
  25709. type: 2,
  25710. write(e) {
  25711. return [...e];
  25712. },
  25713. read(e) {
  25714. return Object.setPrototypeOf(e, rt.prototype), e;
  25715. }
  25716. });
  25717. tl({
  25718. Class: ki.prototype.constructor,
  25719. type: 3,
  25720. write(e) {
  25721. return [...e];
  25722. },
  25723. read(e) {
  25724. return Object.setPrototypeOf(e, ki.prototype), e;
  25725. }
  25726. });
  25727. tl({
  25728. Class: g1.prototype.constructor,
  25729. type: 4,
  25730. write(e) {
  25731. return e.id;
  25732. },
  25733. read(e) {
  25734. return new g1(e);
  25735. }
  25736. });
  25737. tl({
  25738. Class: v1.prototype.constructor,
  25739. type: 5,
  25740. write(e) {
  25741. return e.data;
  25742. },
  25743. read(e) {
  25744. return new v1(e);
  25745. }
  25746. });
  25747. tl({
  25748. Class: mi.prototype.constructor,
  25749. type: 6,
  25750. write(e) {
  25751. return { ...e };
  25752. },
  25753. read(e) {
  25754. return Object.setPrototypeOf(e, mi.prototype), e;
  25755. }
  25756. });
  25757. function HN(e) {
  25758. var t = 0;
  25759. if (e.length === 0) return t;
  25760. for (let i = 0; i < e.length; i++) {
  25761. let r = e[i];
  25762. (t = (t << 5) - t + r), (t = t & t);
  25763. }
  25764. return t;
  25765. }
  25766. function lm(e) {
  25767. if (Vg(e)) return e;
  25768. if (Array.isArray(e)) return e.map(lm);
  25769. if (typeof e == 'object' && e !== null) {
  25770. let t = {};
  25771. for (let i of Object.keys(e).sort()) t[i] = lm(e[i]);
  25772. return Object.setPrototypeOf(t, Object.getPrototypeOf(e)), t;
  25773. } else return e;
  25774. }
  25775. var hm;
  25776. ((e) => {
  25777. function t(s) {
  25778. return T1.pack(s);
  25779. }
  25780. e.serialize = t;
  25781. function i(s) {
  25782. return T1.unpack(s);
  25783. }
  25784. e.deserialize = i;
  25785. function r(s) {
  25786. return HN(t(lm(s))).toString();
  25787. }
  25788. e.checksum = r;
  25789. })(hm || (hm = {}));
  25790. var _l = {
  25791. LookAt: [],
  25792. Follow: [],
  25793. MouseHover: ['Transition'],
  25794. Scroll: ['Transition'],
  25795. Start: ['Transition', 'Audio', 'Video'],
  25796. Conditional: ['Transition', 'Audio', 'Video'],
  25797. MouseDown: ['Transition', 'Audio', 'Video', 'Link', 'Reset'],
  25798. MouseUp: ['Transition', 'Audio', 'Video', 'Link', 'Reset'],
  25799. MousePress: ['Transition', 'Audio', 'Video', 'Link', 'Reset'],
  25800. KeyDown: ['Transition', 'Audio', 'Video', 'Link', 'Reset'],
  25801. KeyUp: ['Transition', 'Audio', 'Video', 'Link', 'Reset'],
  25802. KeyPress: ['Transition', 'Audio', 'Video', 'Link', 'Reset'],
  25803. GameControl: ['Transition', 'Audio'],
  25804. Collision: ['Transition', 'Audio']
  25805. },
  25806. P1;
  25807. ((e) => {
  25808. function t(r) {
  25809. return (
  25810. r.type === 'MouseDown' ||
  25811. r.type === 'MouseUp' ||
  25812. r.type === 'MousePress' ||
  25813. r.type === 'KeyDown' ||
  25814. r.type === 'KeyUp' ||
  25815. r.type === 'KeyPress'
  25816. );
  25817. }
  25818. e.is = t;
  25819. function i(r) {
  25820. return r === 'MouseDown' || r === 'MouseUp' || r === 'MousePress'
  25821. ? { type: r, disabled: !1, toggle: !1, actions: new rt() }
  25822. : { type: r, disabled: !1, key: void 0, toggle: !1, actions: new rt() };
  25823. }
  25824. e.defaultData = i;
  25825. })(P1 || (P1 = {}));
  25826. var Od;
  25827. ((e) => {
  25828. function t(i) {
  25829. return { type: 'Property', value: [i ?? null, 'position', 'x'] };
  25830. }
  25831. (e.propertyDefaultData = t), (e.valueDefaultData = { type: 'Literal', value: 0 });
  25832. })(Od || (Od = {}));
  25833. var cm;
  25834. ((e) => {
  25835. function t(s) {
  25836. return { type: 'Comparison', operator: '==', lOperand: Od.propertyDefaultData(s), rOperand: { ...Od.valueDefaultData } };
  25837. }
  25838. e.comparisonDefaultData = t;
  25839. function i(s) {
  25840. return { type: 'Distance', toObject: s ?? null, fromObject: s ?? null, distance: 200 };
  25841. }
  25842. e.distanceDefaultData = i;
  25843. function r(s, n) {
  25844. return { type: 'State', object: s ?? null, state: n ?? null };
  25845. }
  25846. e.stateDefaultData = r;
  25847. })(cm || (cm = {}));
  25848. var D1;
  25849. ((e) => {
  25850. function t(r) {
  25851. return r.type === 'Conditional';
  25852. }
  25853. e.is = t;
  25854. function i(r) {
  25855. return { type: 'Conditional', disabled: !1, inActions: new rt(), outActions: new rt(), condition: cm.distanceDefaultData(r) };
  25856. }
  25857. e.defaultData = i;
  25858. })(D1 || (D1 = {}));
  25859. var dm;
  25860. ((e) =>
  25861. (e.defaultData = {
  25862. type: 'Follow',
  25863. disabled: !1,
  25864. maxDelta: 0,
  25865. dampingFactor: 1,
  25866. target: 'cursor',
  25867. plane: 'custom',
  25868. resetOnPointerLeave: !0,
  25869. resetAfterDistanceLimit: !0,
  25870. enabledTranslation: [!0, !0, !0],
  25871. limitDistanceEnabled: !1,
  25872. limitDistance: 1e3,
  25873. snapDelay: 0,
  25874. resetSpeed: 5
  25875. }))(dm || (dm = {}));
  25876. var um;
  25877. ((e) =>
  25878. (e.defaultData = {
  25879. type: 'LookAt',
  25880. disabled: !1,
  25881. distance: 1e3,
  25882. dampingFactor: 1,
  25883. target: 'cursor',
  25884. tilt: 'up',
  25885. axis: 'z',
  25886. plane: 'custom',
  25887. resetOnPointerLeave: !0,
  25888. resetAfterDistanceLimit: !0,
  25889. enabledRotation: [!0, !0, !0],
  25890. limitDistanceEnabled: !1,
  25891. limitDistance: 1e3,
  25892. snapDelay: 0,
  25893. resetSpeed: 5
  25894. }))(um || (um = {}));
  25895. var L1;
  25896. ((e) => {
  25897. function t(r) {
  25898. return r.type === 'MouseHover';
  25899. }
  25900. e.is = t;
  25901. function i() {
  25902. return { type: 'MouseHover', disabled: !1, actions: new rt() };
  25903. }
  25904. e.defaultData = i;
  25905. })(L1 || (L1 = {}));
  25906. var O1;
  25907. ((e) => {
  25908. function t(r) {
  25909. return r.type === 'Scroll';
  25910. }
  25911. e.is = t;
  25912. function i() {
  25913. return {
  25914. type: 'Scroll',
  25915. disabled: !1,
  25916. steps: 100,
  25917. trigger: 'load',
  25918. startFrom: 'enter',
  25919. enterAnchor: 'top',
  25920. startOffset: 0,
  25921. endAfter: 400,
  25922. actions: new rt()
  25923. };
  25924. }
  25925. e.defaultData = i;
  25926. })(O1 || (O1 = {}));
  25927. var I1;
  25928. ((e) => {
  25929. function t(r) {
  25930. return r.type === 'Start';
  25931. }
  25932. e.is = t;
  25933. function i() {
  25934. return { type: 'Start', disabled: !1, actions: new rt() };
  25935. }
  25936. e.defaultData = i;
  25937. })(I1 || (I1 = {}));
  25938. var R1;
  25939. ((e) => {
  25940. function t(r) {
  25941. return r.type === 'Collision';
  25942. }
  25943. e.is = t;
  25944. function i() {
  25945. return { type: 'Collision', disabled: !1, toggle: !1, target: 'character', actions: new rt() };
  25946. }
  25947. e.defaultData = i;
  25948. })(R1 || (R1 = {}));
  25949. var mo;
  25950. ((e) => {
  25951. function t(r, s) {
  25952. return r[0] === s[0] && r[1] === s[1];
  25953. }
  25954. e.isEqual = t;
  25955. function i(r, s, n) {
  25956. return [r[0] + (s[0] - r[0]) * n, r[1] + (s[1] - r[1]) * n];
  25957. }
  25958. e.lerp = i;
  25959. })(mo || (mo = {}));
  25960. var ma;
  25961. ((e) => {
  25962. function t(l, h) {
  25963. return l[0] === h[0] && l[1] === h[1] && l[2] === h[2];
  25964. }
  25965. e.isEqual = t;
  25966. function i(l, h) {
  25967. return [l[0] + h[0], l[1] + h[1], l[2] + h[2]];
  25968. }
  25969. e.add = i;
  25970. function r(l, h) {
  25971. return [l[0] - h[0], l[1] - h[1], l[2] - h[2]];
  25972. }
  25973. e.sub = r;
  25974. function s(l, h) {
  25975. return [l[0] / h[0], l[1] / h[1], l[2] / h[2]];
  25976. }
  25977. e.div = s;
  25978. function n(l, h) {
  25979. return [l[0] * h[0], l[1] * h[1], l[2] * h[2]];
  25980. }
  25981. e.mul = n;
  25982. function a(l, h) {
  25983. return Math.hypot(l[0] - h[0], l[1] - h[1], l[2] - h[2]);
  25984. }
  25985. e.dist = a;
  25986. function o(l, h, u) {
  25987. return [l[0] + (h[0] - l[0]) * u, l[1] + (h[1] - l[1]) * u, l[2] + (h[2] - l[2]) * u];
  25988. }
  25989. e.lerp = o;
  25990. })(ma || (ma = {}));
  25991. var Id;
  25992. ((e) => {
  25993. function t(r, s) {
  25994. return r[0] === s[0] && r[1] === s[1] && r[2] === s[2] && r[3] === s[3];
  25995. }
  25996. e.isEqual = t;
  25997. function i(r, s, n) {
  25998. return [r[0] + (s[0] - r[0]) * n, r[1] + (s[1] - r[1]) * n, r[2] + (s[2] - r[2]) * n, r[3] + (s[3] - r[3]) * n];
  25999. }
  26000. e.lerp = i;
  26001. })(Id || (Id = {}));
  26002. var ko;
  26003. ((e) => {
  26004. e.identity = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
  26005. function t(s, n) {
  26006. for (let a = 0; a < 16; a++) if (s[a] !== n[a]) return !1;
  26007. return !0;
  26008. }
  26009. e.isEqual = t;
  26010. function i(s) {
  26011. return s ?? e.identity;
  26012. }
  26013. e.simplify = i;
  26014. function r(s, n) {
  26015. let a = n.slice(0);
  26016. for (var o = 0, l = n.length; o < l; o += 3) {
  26017. let h = s[3] * n[o] + s[7] * n[o + 1] + s[11] * n[o + 2] + s[15];
  26018. (a[o] = (s[0] * n[o] + s[4] * n[o + 1] + s[8] * n[o + 2] + s[12]) / h),
  26019. (a[o + 1] = (s[1] * n[o] + s[5] * n[o + 1] + s[9] * n[o + 2] + s[13]) / h),
  26020. (a[o + 2] = (s[2] * n[o] + s[6] * n[o + 1] + s[10] * n[o + 2] + s[14]) / h);
  26021. }
  26022. return a;
  26023. }
  26024. e.applyMatrix4 = r;
  26025. })(ko || (ko = {}));
  26026. var $i;
  26027. ((e) => {
  26028. function t(o) {
  26029. return typeof o == 'object' && typeof o.r == 'number' && typeof o.g == 'number' && typeof o.b == 'number';
  26030. }
  26031. (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 });
  26032. function i(o) {
  26033. return { r: Math.round(o.r * 255), g: Math.round(o.g * 255), b: Math.round(o.b * 255), a: 1 };
  26034. }
  26035. e.toRgb255a1 = i;
  26036. function r(o) {
  26037. return { r: o.r, g: o.g, b: o.b };
  26038. }
  26039. e.clone = r;
  26040. function s(o) {
  26041. return (o = Math.floor(o)), { r: ((o >> 16) & 255) / 255, g: ((o >> 8) & 255) / 255, b: (o & 255) / 255 };
  26042. }
  26043. e.fromHex = s;
  26044. function n(o, l) {
  26045. return o.r === l.r && o.g === l.g && o.b === l.b;
  26046. }
  26047. e.equals = n;
  26048. function a(o, l, h) {
  26049. return { r: o.r + (l.r - o.r) * h, g: o.g + (l.g - o.g) * h, b: o.b + (l.b - o.b) * h };
  26050. }
  26051. e.lerp = a;
  26052. })($i || ($i = {}));
  26053. var kr;
  26054. ((e) => {
  26055. (e.white = { ...$i.white, a: 1 }), (e.transparent = { ...$i.white, a: 0 });
  26056. function t(a) {
  26057. return { r: a[0], g: a[1], b: a[2], a: a[3] };
  26058. }
  26059. e.from0to1 = t;
  26060. function i(a, o) {
  26061. return { ...$i.fromHex(a), a: o };
  26062. }
  26063. e.fromHexAndA = i;
  26064. function r(a) {
  26065. return { r: Math.round(a.r * 255), g: Math.round(a.g * 255), b: Math.round(a.b * 255), a: a.a };
  26066. }
  26067. e.toRgb255a1 = r;
  26068. function s(a, o) {
  26069. return $i.equals(a, o) && a.a === o.a;
  26070. }
  26071. e.equals = s;
  26072. function n(a, o, l) {
  26073. return { r: a.r + (o.r - a.r) * l, g: a.g + (o.g - a.g) * l, b: a.b + (o.b - a.b) * l, a: a.a + (o.a - a.a) * l };
  26074. }
  26075. e.lerp = n;
  26076. })(kr || (kr = {}));
  26077. var pm;
  26078. ((e) => (e.identity = { position: [0, 0, 0], rotation: [0, 0, 0], scale: [1, 1, 1] }))(pm || (pm = {}));
  26079. var B1;
  26080. ((e) => (e.defaultData = { mass: 1, stiffness: 80, damping: 10, velocity: 0 }))(B1 || (B1 = {}));
  26081. var z1;
  26082. ((e) => (e.defaultData = { control1: [0.5, 0.05], control2: [0.1, 0.3] }))(z1 || (z1 = {}));
  26083. var _a;
  26084. ((e) => {
  26085. e.all = ['PerspectiveCamera', 'OrthographicCamera'];
  26086. function t(i) {
  26087. return e.all.includes(i);
  26088. }
  26089. e.is = t;
  26090. })(_a || (_a = {}));
  26091. var xh;
  26092. ((e) => {
  26093. (e.DefaultUp = [0, 1, 0]),
  26094. (e.DefaultTargetOffset = 1e3),
  26095. (e.defaultData = {
  26096. far: 1e5,
  26097. type: 'OrthographicCamera',
  26098. perspective: { near: 70, fov: 45, zoom: 1 },
  26099. orthographic: { near: -1e5, zoom: 1, autoZoom: !1, autoZoomFrustumSize: 790 },
  26100. up: e.DefaultUp,
  26101. isUpVectorFlipped: !1,
  26102. targetOffset: e.DefaultTargetOffset
  26103. });
  26104. function t(i) {
  26105. return i.type === 'PerspectiveCamera' ? i.perspective.zoom : i.orthographic.zoom;
  26106. }
  26107. e.getZoom = t;
  26108. })(xh || (xh = {}));
  26109. var bn;
  26110. ((e) => {
  26111. function t(r, s = 0.1) {
  26112. return {
  26113. disabled: !1,
  26114. type: 'linear',
  26115. hideBase: !1,
  26116. count: 3,
  26117. radial: {
  26118. radius: Math.max(r[0], r[1]) * 2,
  26119. start: 0,
  26120. end: 360,
  26121. alignment: !1,
  26122. axis: 'y',
  26123. scale: [1, 1, 1],
  26124. rotation: [0, 0, 0],
  26125. position: [0, 0, 0]
  26126. },
  26127. toObject: {
  26128. object: '',
  26129. spreadType: 'random',
  26130. scale: [0, 0, 0],
  26131. rotation: [0, 0, 0],
  26132. position: [0, 0, 0],
  26133. axis: 'x',
  26134. seed: 0,
  26135. count: 99,
  26136. align: 'normal'
  26137. },
  26138. linear: { scale: [1, 1, 1], rotation: [0, 0, 0], position: [r[0] + r[0] * s, 0, 0] },
  26139. grid: { count: [2, 2, 2], size: r.map((n) => n * (1 + s)), useCenter: !0 },
  26140. randomness: !1,
  26141. randomnessObject: {
  26142. strength: 100,
  26143. scale: [0, 0, 0],
  26144. rotation: [0, 0, 0],
  26145. position: [0, 0, 0],
  26146. movement: 1,
  26147. seed: 0,
  26148. freqScale: 10,
  26149. noiseType: 'perlin'
  26150. }
  26151. };
  26152. }
  26153. e.defaultData = t;
  26154. function i(r, s) {
  26155. let n = { ...r };
  26156. if (
  26157. (W_.forEach((a) => {
  26158. Object.assign(n, { [a]: s[a] ?? r[a] });
  26159. }),
  26160. (n.radial = { ...r.radial }),
  26161. s.radial)
  26162. ) {
  26163. let a = r.radial,
  26164. o = s.radial;
  26165. X_.forEach((l) => {
  26166. Object.assign(n.radial, { [l]: o[l] ?? a[l] });
  26167. });
  26168. }
  26169. if (((n.linear = { ...r.linear }), s.linear)) {
  26170. let a = r.linear,
  26171. o = s.linear;
  26172. q_.forEach((l) => {
  26173. Object.assign(n.linear, { [l]: o[l] ?? a[l] });
  26174. });
  26175. }
  26176. if (((n.grid = { ...r.grid }), s.grid)) {
  26177. let a = r.grid,
  26178. o = s.grid;
  26179. Y_.forEach((l) => {
  26180. Object.assign(n.grid, { [l]: o[l] ?? a[l] });
  26181. });
  26182. }
  26183. if (((n.toObject = { ...r.toObject }), s.toObject)) {
  26184. let a = r.toObject,
  26185. o = s.toObject;
  26186. Q_.forEach((l) => {
  26187. Object.assign(n.toObject, { [l]: o[l] ?? a[l] });
  26188. });
  26189. }
  26190. if (((n.randomnessObject = { ...r.randomnessObject }), s.randomnessObject)) {
  26191. let a = r.randomnessObject,
  26192. o = s.randomnessObject;
  26193. Z_.forEach((l) => {
  26194. Object.assign(n.randomnessObject, { [l]: o[l] ?? a[l] });
  26195. });
  26196. }
  26197. return n;
  26198. }
  26199. e.merge = i;
  26200. })(bn || (bn = {}));
  26201. var fm;
  26202. ((e) => {
  26203. e.defaultData = { radial: {}, linear: {}, grid: {}, toObject: {}, randomnessObject: {} };
  26204. let t = ['radial', 'linear', 'grid', 'toObject', 'randomnessObject'];
  26205. function i(r, s) {
  26206. let n = [];
  26207. r.count !== void 0 && n.push({ type: 0, path: s, props: { count: r.count } });
  26208. for (let a of t) {
  26209. let o = r[a];
  26210. o && Object.keys(o).length > 0 && n.push({ type: 0, path: [...s, a], props: o });
  26211. }
  26212. return n;
  26213. }
  26214. e.toOps = i;
  26215. })(fm || (fm = {}));
  26216. var W_ = ['count'],
  26217. X_ = ['radius', 'start', 'end', 'position', 'scale', 'rotation'],
  26218. q_ = ['position', 'scale', 'rotation'],
  26219. Y_ = ['count', 'size'],
  26220. Q_ = ['count', 'position', 'scale', 'rotation'],
  26221. Z_ = ['strength', 'scale', 'rotation', 'position', 'movement', 'seed', 'freqScale'],
  26222. bh;
  26223. ((e) => {
  26224. let t = { opacity: 1, blendFunction: 13, enabled: !1 };
  26225. e.defaultData = {
  26226. enabled: !1,
  26227. pixelation: { ...t, blendFunction: 16, granularity: 15 },
  26228. bloom: { ...t, blendFunction: 16, intensity: 1, blurScale: 1, luminanceThreshold: 0.25, luminanceSmoothing: 0.025, kernelSize: 3 },
  26229. chromaticAberration: { ...t, offset: [2, 2] },
  26230. vignette: { ...t, darkness: 1, offset: 0 },
  26231. hueSaturation: { ...t, hue: 3, saturation: 0 },
  26232. brightnessContrast: { ...t, brightness: 0.25, contrast: 0 },
  26233. depthOfField: { ...t, focalLength: 2, focusDistance: 2, bokehScale: 2 },
  26234. noise: { ...t, blendFunction: 16 }
  26235. };
  26236. })(bh || (bh = {}));
  26237. var mm;
  26238. ((e) => {
  26239. e.all = ['PointLight', 'SpotLight', 'DirectionalLight', 'HemisphereLight'];
  26240. function t(i) {
  26241. return e.all.includes(i);
  26242. }
  26243. e.is = t;
  26244. })(mm || (mm = {}));
  26245. var gm;
  26246. ((e) => {
  26247. function t(r) {
  26248. return i(r);
  26249. }
  26250. e.defaultData = t;
  26251. function i(r) {
  26252. if (r === 'PointLight')
  26253. return {
  26254. type: r,
  26255. color: kr.white,
  26256. intensity: 1,
  26257. distance: 2e3,
  26258. decay: 1,
  26259. shadows: !0,
  26260. shadowResolution: 1024,
  26261. shadowRadius: 1,
  26262. depth: 1e5
  26263. };
  26264. if (r === 'SpotLight')
  26265. return {
  26266. type: r,
  26267. color: kr.white,
  26268. intensity: 1,
  26269. distance: 2e3,
  26270. decay: 1,
  26271. shadows: !0,
  26272. penumbra: 0,
  26273. angle: (30 / 180) * Math.PI,
  26274. depth: 1e5,
  26275. shadowResolution: 1024,
  26276. shadowRadius: 1
  26277. };
  26278. if (r === 'DirectionalLight')
  26279. return { type: r, color: kr.white, intensity: 1, shadows: !0, size: 2e3, depth: 1e5, shadowResolution: 1024, shadowRadius: 1 };
  26280. throw new Error('not implemented');
  26281. }
  26282. })(gm || (gm = {}));
  26283. var vm;
  26284. ((e) => {
  26285. e.defaultData = { castShadow: !0, receiveShadow: !0 };
  26286. function t(i, r) {
  26287. return i.castShadow === r.castShadow && i.receiveShadow === r.receiveShadow;
  26288. }
  26289. e.equals = t;
  26290. })(vm || (vm = {}));
  26291. var ym;
  26292. ((e) => {
  26293. e.defaultData = { flatShading: !1, wireframe: !1, side: 0 };
  26294. function t(i, r) {
  26295. return i.flatShading === r.flatShading && i.side === r.side && i.wireframe === r.wireframe;
  26296. }
  26297. e.equals = t;
  26298. })(ym || (ym = {}));
  26299. var xm;
  26300. ((e) => (e.defaultData = { ...ym.defaultData, ...vm.defaultData }))(xm || (xm = {}));
  26301. var Rd;
  26302. ((e) => ((e.defaultVideo = { data: '', thumb: '/_assets/_videos/catThumb.png', type: 'video', name: 'Cat video' }), (e.maxSize = 3e7)))(
  26303. Rd || (Rd = {})
  26304. );
  26305. var N1;
  26306. ((e) => {
  26307. function t(i) {
  26308. return (
  26309. i === 'texture' ||
  26310. i === 'video' ||
  26311. i === 'color' ||
  26312. i === 'depth' ||
  26313. i === 'normal' ||
  26314. i === 'gradient' ||
  26315. i === 'noise' ||
  26316. i === 'fresnel' ||
  26317. i === 'rainbow' ||
  26318. i === 'toon' ||
  26319. i === 'outline' ||
  26320. i === 'transmission' ||
  26321. i === 'matcap' ||
  26322. i === 'displace' ||
  26323. i === 'light'
  26324. );
  26325. }
  26326. e.is = t;
  26327. })(N1 || (N1 = {}));
  26328. var U1;
  26329. ((e) => {
  26330. function t(i) {
  26331. return i === 'phong' || i === 'toon' || i === 'lambert' || i === 'physical';
  26332. }
  26333. e.is = t;
  26334. })(U1 || (U1 = {}));
  26335. var K_ = ['mode', 'gradientType', 'noiseType', 'displacementType', 'projection', 'cnormal', 'crop', 'axis', 'side'],
  26336. WN = ['wrapping', 'image', 'video'],
  26337. xr;
  26338. ((e) => {
  26339. function t(n, a) {
  26340. let { texture: o, ...l } = a;
  26341. if ((Object.assign(n, l), o)) {
  26342. let h = n.texture;
  26343. h && Object.assign(h, o);
  26344. }
  26345. }
  26346. e.patch = t;
  26347. function i(n, a) {
  26348. return n === 'light' && a ? r(a) : s(n);
  26349. }
  26350. e.defaultData = i;
  26351. function r(n) {
  26352. switch (n) {
  26353. case 'phong':
  26354. return { category: 'phong', specular: { r: 0.2, g: 0.2, b: 0.2 }, shininess: 5, type: 'light', alpha: 0.6, visible: !0, mode: 0 };
  26355. case 'toon':
  26356. return { category: 'toon', specular: { r: 0.2, g: 0.2, b: 0.2 }, shininess: 10, type: 'light', alpha: 1, visible: !0, mode: 0 };
  26357. case 'lambert':
  26358. return { category: 'lambert', emissive: { r: 0, g: 0, b: 0 }, type: 'light', alpha: 1, visible: !0, mode: 0 };
  26359. case 'physical':
  26360. return { category: 'physical', roughness: 0.2, metalness: 0.2, reflectivity: 0.2, type: 'light', alpha: 1, visible: !0, mode: 0 };
  26361. }
  26362. }
  26363. function s(n) {
  26364. switch (n) {
  26365. case 'texture':
  26366. return {
  26367. alpha: 1,
  26368. visible: !0,
  26369. size: [128, 128],
  26370. mode: 0,
  26371. axis: 'x',
  26372. side: 2,
  26373. type: 'texture',
  26374. projection: 0,
  26375. texture: { image: 'image_0', wrapping: 1e3, repeat: [1, 1], offset: [0, 0] },
  26376. crop: !1
  26377. };
  26378. case 'video':
  26379. return {
  26380. alpha: 1,
  26381. visible: !0,
  26382. size: [128, 128],
  26383. mode: 0,
  26384. axis: 'x',
  26385. side: 2,
  26386. type: 'video',
  26387. projection: 0,
  26388. texture: { video: Rd.defaultVideo, wrapping: 1001, repeat: [1, 1], offset: [0, 0] },
  26389. crop: !0
  26390. };
  26391. case 'color':
  26392. return { type: 'color', alpha: 1, visible: !0, mode: 0, color: $i.fromHex(5526619) };
  26393. case 'depth':
  26394. return {
  26395. type: 'depth',
  26396. alpha: 1,
  26397. visible: !0,
  26398. mode: 0,
  26399. gradientType: 1,
  26400. smooth: !1,
  26401. isVector: !0,
  26402. isWorldSpace: !1,
  26403. origin: [0, 0, 0],
  26404. direction: [1, 0, 0],
  26405. colors: [
  26406. [1, 1, 1, 1],
  26407. [0, 0, 0, 1]
  26408. ],
  26409. steps: [0, 1],
  26410. near: 50,
  26411. far: 200
  26412. };
  26413. case 'normal':
  26414. return { type: 'normal', alpha: 1, visible: !0, mode: 0, cnormal: [1, 1, 1] };
  26415. case 'gradient':
  26416. return {
  26417. type: 'gradient',
  26418. alpha: 1,
  26419. visible: !0,
  26420. mode: 0,
  26421. gradientType: 0,
  26422. smooth: !1,
  26423. colors: [
  26424. [0, 0, 0, 1],
  26425. [1, 1, 1, 1],
  26426. [1, 1, 1, 1],
  26427. [1, 1, 1, 1],
  26428. [1, 1, 1, 1],
  26429. [1, 1, 1, 1],
  26430. [1, 1, 1, 1],
  26431. [1, 1, 1, 1],
  26432. [1, 1, 1, 1],
  26433. [1, 1, 1, 1]
  26434. ],
  26435. steps: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
  26436. num: 2,
  26437. angle: 0,
  26438. offset: [0, 0],
  26439. morph: [0, 0]
  26440. };
  26441. case 'noise':
  26442. return {
  26443. type: 'noise',
  26444. alpha: 1,
  26445. visible: !0,
  26446. mode: 0,
  26447. size: [100, 100, 100],
  26448. noiseType: 0,
  26449. scale: 1,
  26450. move: 1,
  26451. colorA: { ...$i.fromHex(6710886), a: 1 },
  26452. colorB: { ...$i.fromHex(6710886), a: 1 },
  26453. colorC: { ...$i.fromHex(16777215), a: 1 },
  26454. colorD: { ...$i.fromHex(16777215), a: 1 },
  26455. distortion: [1, 1],
  26456. fA: [1.7, 9.2],
  26457. fB: [8.3, 2.8]
  26458. };
  26459. case 'fresnel':
  26460. return {
  26461. type: 'fresnel',
  26462. alpha: 1,
  26463. visible: !0,
  26464. mode: 0,
  26465. color: kr.fromHexAndA(16777215, 1),
  26466. bias: 0.1,
  26467. scale: 1,
  26468. intensity: 2,
  26469. factor: 1
  26470. };
  26471. case 'rainbow':
  26472. return {
  26473. type: 'rainbow',
  26474. alpha: 1,
  26475. visible: !0,
  26476. mode: 0,
  26477. filmThickness: 30,
  26478. movement: 0,
  26479. wavelengths: [0, 0, 0],
  26480. noiseStrength: 0,
  26481. noiseScale: 1,
  26482. offset: [0, 0, 0]
  26483. };
  26484. case 'toon':
  26485. return {
  26486. type: 'toon',
  26487. alpha: 1,
  26488. visible: !0,
  26489. mode: 0,
  26490. positioning: 2,
  26491. colors: [
  26492. [0, 0, 0, 1],
  26493. [0.5, 0.5, 0.5, 1],
  26494. [0.5, 0.5, 0.5, 1],
  26495. [1, 1, 1, 1],
  26496. [1, 1, 1, 1],
  26497. [1, 1, 1, 1],
  26498. [1, 1, 1, 1],
  26499. [1, 1, 1, 1],
  26500. [1, 1, 1, 1],
  26501. [1, 1, 1, 1]
  26502. ],
  26503. steps: [0, 0.475, 0.525, 1, 1, 1, 1, 1, 1, 1],
  26504. num: 4,
  26505. source: [0, 1e3, 0],
  26506. isWorldSpace: !0,
  26507. noiseStrength: 0,
  26508. noiseScale: 1,
  26509. shadowColor: kr.fromHexAndA(0, 0),
  26510. offset: [0, 0, 0]
  26511. };
  26512. case 'outline':
  26513. return {
  26514. type: 'outline',
  26515. alpha: 1,
  26516. visible: !0,
  26517. mode: 0,
  26518. outlineColor: kr.fromHexAndA(0, 1),
  26519. contourColor: kr.fromHexAndA(0, 1),
  26520. outlineWidth: 2,
  26521. contourWidth: 5,
  26522. outlineThreshold: 0.4,
  26523. contourThreshold: 0,
  26524. outlineSmoothing: 0,
  26525. contourFrequency: 10,
  26526. contourDirection: [0, 1, 0],
  26527. positionalLines: !1,
  26528. compensation: !0
  26529. };
  26530. case 'matcap':
  26531. return {
  26532. type: 'matcap',
  26533. alpha: 1,
  26534. visible: !0,
  26535. mode: 0,
  26536. texture: { image: 'matcap_0', wrapping: 1001, repeat: [1, 1], offset: [0, 0] }
  26537. };
  26538. case 'transmission':
  26539. return { type: 'transmission', alpha: 1, visible: !0, mode: 0, thickness: 10, ior: 1.5, roughness: 1 };
  26540. case 'displace':
  26541. return {
  26542. type: 'displace',
  26543. displacementType: 'noise',
  26544. noiseType: 0,
  26545. scale: 10,
  26546. movement: 1,
  26547. offset: [0, 0, 0],
  26548. intensity: 8,
  26549. visible: !0
  26550. };
  26551. }
  26552. }
  26553. })(xr || (xr = {}));
  26554. var nr;
  26555. ((e) => {
  26556. function t(h) {
  26557. return !h.layers.some(
  26558. (u) =>
  26559. (u.data.type === 'texture' && u.data.projection !== 0) ||
  26560. (u.data.type === 'depth' && !u.data.isWorldSpace) ||
  26561. u.data.type === 'noise' ||
  26562. u.data.type === 'displace'
  26563. );
  26564. }
  26565. e.isMergable = t;
  26566. function i(h) {
  26567. let u = '';
  26568. return (
  26569. h.layers.forEach((c) => {
  26570. Object.entries(c.data).forEach(([d, p]) => {
  26571. (u += `${d}${p}`),
  26572. Array.isArray(p)
  26573. ? p.forEach((f) => (u += `${f}`))
  26574. : typeof p == 'object'
  26575. ? Object.values(p).forEach((f) => {
  26576. typeof f == 'number' ? (u += `${f.toFixed(4)}`) : (u += `${f}`);
  26577. })
  26578. : (u += `${p}`);
  26579. });
  26580. }),
  26581. u
  26582. );
  26583. }
  26584. e.getHash = i;
  26585. function r() {
  26586. return { layers: new rt() };
  26587. }
  26588. e.defaultEmptyData = r;
  26589. function s(h = 'layer1', u = 'layer2') {
  26590. return a('phong', h, u);
  26591. }
  26592. e.defaultData = s;
  26593. function n(h, u) {
  26594. return { ...h, name: u };
  26595. }
  26596. e.withName = n;
  26597. function a(h, u = 'layer1', c = 'layer2') {
  26598. let d = new rt();
  26599. return (
  26600. d.push({ fi: 0, data: xr.defaultData('light', h), id: u }), d.push({ fi: 1, data: xr.defaultData('color'), id: c }), { layers: d }
  26601. );
  26602. }
  26603. e.defaultTwoLayerData = a;
  26604. function o(h, u = 'phong', c = 'layer1', d = 'layer2') {
  26605. let p = xr.defaultData('texture');
  26606. Object.assign(p.texture, { image: h });
  26607. let f = new rt();
  26608. return f.push({ fi: 0, data: p, id: c }), f.push({ fi: 1, data: xr.defaultData('light', u), id: d }), { layers: f };
  26609. }
  26610. e.defaultTwoLayerTextureData = o;
  26611. function l(h, u = 'phong', c = 'layer1', d = 'layer2') {
  26612. let p = xr.defaultData('video');
  26613. Object.assign(p.texture, { video: h });
  26614. let f = new rt();
  26615. return f.push({ fi: 0, data: p, id: c }), f.push({ fi: 1, data: xr.defaultData('light', u), id: d }), { layers: f };
  26616. }
  26617. e.defaultTwoLayerVideoTextureData = l;
  26618. })(nr || (nr = {}));
  26619. var Bd;
  26620. ((e) => {
  26621. function t() {
  26622. return { points: new rt(), roundness: 0, shapeHoles: [], isClosed: !1 };
  26623. }
  26624. e.defaultData = t;
  26625. })(Bd || (Bd = {}));
  26626. var zd;
  26627. ((e) => {
  26628. function t() {
  26629. return { points: new rt(), lastInsertionPlane: null, subdivisions: 12, isClosed: !1 };
  26630. }
  26631. e.defaultData = t;
  26632. })(zd || (zd = {}));
  26633. var J_ = { type: 'Ellipse', width: 100, height: 100, spikes: 64, angle: 360, innerRadius: 0 },
  26634. bm;
  26635. ((e) => {
  26636. function t(i, r) {
  26637. let s = { ...i };
  26638. return (
  26639. eA.forEach((n) => {
  26640. Object.assign(s, { [n]: r[n] ?? i[n] });
  26641. }),
  26642. s
  26643. );
  26644. }
  26645. e.merge = t;
  26646. })(bm || (bm = {}));
  26647. var $_ = { shape: J_, depth: 1, offset: 0, bevel: 0, bevelSides: 1, angle: 0, twist: 0, startScale: 1, endScale: 1 },
  26648. eA = ['depth', 'offset', 'angle', 'twist', 'startScale', 'endScale'],
  26649. Nd;
  26650. ((e) => {
  26651. function t(r) {
  26652. return (
  26653. r === 'PolygonGeometry' || r === 'RectangleGeometry' || r === 'StarGeometry' || r === 'TriangleGeometry' || r === 'EllipseGeometry'
  26654. );
  26655. }
  26656. e.is2DParametricMesh = t;
  26657. function i(r) {
  26658. return (
  26659. r === 'PolygonGeometry' ||
  26660. r === 'PolygonGeometry' ||
  26661. r === 'RectangleGeometry' ||
  26662. r === 'StarGeometry' ||
  26663. r === 'TriangleGeometry' ||
  26664. r === 'EllipseGeometry' ||
  26665. r === 'PathGeometry' ||
  26666. r === 'VectorGeometry' ||
  26667. r === 'ConeGeometry' ||
  26668. r === 'CubeGeometry' ||
  26669. r === 'CylinderGeometry' ||
  26670. r === 'DodecahedronGeometry' ||
  26671. r === 'HelixGeometry' ||
  26672. r === 'IcosahedronGeometry' ||
  26673. r === 'LatheGeometry' ||
  26674. r === 'PyramidGeometry' ||
  26675. r === 'SphereGeometry' ||
  26676. r === 'PlaneGeometry' ||
  26677. r === 'BackdropGeometry' ||
  26678. r === 'TorusGeometry' ||
  26679. r === 'TorusKnotGeometry' ||
  26680. r === 'BooleanGeometry' ||
  26681. r === 'TextGeometry'
  26682. );
  26683. }
  26684. e.isParametricMesh = i;
  26685. })(Nd || (Nd = {}));
  26686. var wm;
  26687. ((e) => {
  26688. function t(i, r) {
  26689. let s = { ...i };
  26690. return (
  26691. Object.assign(s, r),
  26692. s.type === 'PathGeometry' &&
  26693. 'extrusion' in r &&
  26694. r.extrusion &&
  26695. ((s.extrusion = { ...i.extrusion }), Object.assign(s.extrusion, bm.merge(s.extrusion, r.extrusion))),
  26696. s
  26697. );
  26698. }
  26699. e.merge = t;
  26700. })(wm || (wm = {}));
  26701. var So;
  26702. ((e) => {
  26703. function t(i) {
  26704. if (i === 'RectangleGeometry')
  26705. return {
  26706. width: 320,
  26707. height: 320,
  26708. type: i,
  26709. cornerRadius: [0, 0, 0, 0],
  26710. cornerType: 0,
  26711. depth: 0,
  26712. extrudeBevelSize: 0,
  26713. extrudeBevelSegments: 1
  26714. };
  26715. if (i === 'PathGeometry') return { type: i, width: 1, height: 1, depth: 1, path: zd.defaultData(), extrusion: $_ };
  26716. if (i === 'VectorGeometry')
  26717. return {
  26718. width: 1,
  26719. height: 1,
  26720. type: i,
  26721. subdivisions: 12,
  26722. shape: Bd.defaultData(),
  26723. depth: 0,
  26724. extrudeBevelSize: 0,
  26725. extrudeBevelSegments: 1
  26726. };
  26727. if (i === 'BooleanGeometry') return { type: i, operation: 2, width: 0, height: 0, depth: 0, phongAngle: 35 };
  26728. if (i === 'TextGeometry')
  26729. return {
  26730. type: i,
  26731. width: 100,
  26732. height: 100,
  26733. depth: 0,
  26734. horizontalAlign: 1,
  26735. verticalAlign: 1,
  26736. fontSize: 16,
  26737. lineHeight: 1.2,
  26738. letterSpacing: 0,
  26739. text: '',
  26740. textTransform: 1,
  26741. font: 'Roboto_regular',
  26742. extrudeBevelSize: 0,
  26743. extrudeBevelSegments: 1
  26744. };
  26745. throw new Error('not implemented');
  26746. }
  26747. e.defaultData = t;
  26748. })(So || (So = {}));
  26749. var F1 = ['width', 'height', 'depth'],
  26750. k1;
  26751. ((e) => {
  26752. function t(r) {
  26753. return r === 'Component' || r === 'Instance';
  26754. }
  26755. e.isComponentRelated = t;
  26756. function i(r) {
  26757. return r === 'Empty' || r === 'Instance';
  26758. }
  26759. e.isEmptyOrComponent = i;
  26760. })(k1 || (k1 = {}));
  26761. var jo;
  26762. ((e) => {
  26763. e.identity = { ...pm.identity, hiddenMatrix: ko.identity };
  26764. function t(s) {
  26765. return { position: s.position, rotation: s.rotation, scale: s.scale, hiddenMatrix: s.hiddenMatrix };
  26766. }
  26767. e.fromObject = t;
  26768. function i(s, n) {
  26769. return {
  26770. position: n?.position || s.position,
  26771. rotation: n?.rotation || s.rotation,
  26772. scale: n?.scale || s.scale,
  26773. hiddenMatrix: n?.hiddenMatrix || s.hiddenMatrix
  26774. };
  26775. }
  26776. e.merge = i;
  26777. function r(s, n) {
  26778. return {
  26779. position: ma.isEqual(s.position, n.position) ? null : n.position,
  26780. rotation: ma.isEqual(s.rotation, n.rotation) ? null : n.rotation,
  26781. scale: ma.isEqual(s.scale, n.scale) ? null : n.scale,
  26782. hiddenMatrix: ko.isEqual(s.hiddenMatrix, n.hiddenMatrix) ? null : n.hiddenMatrix
  26783. };
  26784. }
  26785. e.diff = r;
  26786. })(jo || (jo = {}));
  26787. var _m;
  26788. ((e) =>
  26789. (e.defaultData = {
  26790. fusedBody: !0,
  26791. rigidBody: 'positioned',
  26792. density: 1,
  26793. pointMass: 0,
  26794. gravityScale: 1,
  26795. friction: 0.5,
  26796. damping: 0,
  26797. restitution: 0.2,
  26798. colliderType: 'convex',
  26799. enabledRotation: [!0, !0, !0],
  26800. enabledTranslation: [!0, !0, !0]
  26801. }))(_m || (_m = {}));
  26802. var Ar;
  26803. ((e) =>
  26804. (e.defaultData = {
  26805. states: new rt(),
  26806. events: new rt(),
  26807. visible: !0,
  26808. raycastLock: !1,
  26809. physics: null,
  26810. pathSnapping: { pathId: null, slide: 0, offset: 0, orientation: 'tangential' },
  26811. ...jo.identity,
  26812. cloner: null
  26813. }))(Ar || (Ar = {}));
  26814. var j1;
  26815. ((e) => (e.defaultData = { type: 'Empty', ...Ar.defaultData }))(j1 || (j1 = {}));
  26816. var G1;
  26817. ((e) => (e.defaultData = { type: 'Component', ...Ar.defaultData }))(G1 || (G1 = {}));
  26818. var Mo;
  26819. ((e) => (e.defaultData = { type: 'Mesh', ...Ar.defaultData, ...xm.defaultData }))(Mo || (Mo = {}));
  26820. var Ud;
  26821. ((e) => (e.defaultData = { ...Ar.defaultData, ...jo.identity, ...xh.defaultData }))(Ud || (Ud = {}));
  26822. var Am;
  26823. ((e) => {
  26824. function t(i) {
  26825. return { ...Ar.defaultData, ...gm.defaultData(i) };
  26826. }
  26827. e.defaultData = t;
  26828. })(Am || (Am = {}));
  26829. var Fd;
  26830. ((e) => {
  26831. function t(r, s, n = 0) {
  26832. for (; n < s.length; ) {
  26833. let a = r ? r[s[n]] : void 0;
  26834. if (s.length === n + 1) return a;
  26835. if (a) (r = a.descendants), (n += 1);
  26836. else return;
  26837. }
  26838. }
  26839. e.resolveWithDes = t;
  26840. function i(r, s, n = 0) {
  26841. let a = t(r, s, n);
  26842. if (a) {
  26843. let o = Object.keys(a);
  26844. if (o.length === 1 && o[0] === 'descendants') return;
  26845. }
  26846. return a;
  26847. }
  26848. e.resolve = i;
  26849. })(Fd || (Fd = {}));
  26850. var Go;
  26851. ((e) => {
  26852. (e.rootOverrideProps = ['physics']),
  26853. (e.compositeNonOptionalOverrideProps = ['geometry']),
  26854. (e.compositeEntireOverrideOverrideProps = ['material']);
  26855. function t(r, s) {
  26856. return { ...Ar.defaultData, ...s, component: r, overrides: new mi(), physics: void 0, type: 'Instance' };
  26857. }
  26858. e.ofComponent = t;
  26859. function i(r) {
  26860. let s = jo.fromObject(r.data);
  26861. return t(r.id, s);
  26862. }
  26863. e.fromComponentData = i;
  26864. })(Go || (Go = {}));
  26865. var Sm;
  26866. ((e) => (
  26867. (e.defaultCamera = {
  26868. position: [0, 0, 1e3],
  26869. scale: [1, 1, 1],
  26870. rotation: [0, 0, 0],
  26871. hiddenMatrix: ko.identity,
  26872. name: 'Play Camera',
  26873. visible: !0,
  26874. raycastLock: !1,
  26875. physics: _m.defaultData,
  26876. states: new rt(),
  26877. events: new rt(),
  26878. cloner: null,
  26879. pathSnapping: { pathId: null, orientation: 'tangential', slide: 0, offset: 0 },
  26880. ...xh.defaultData
  26881. }),
  26882. (e.KeysByResetCategory = {
  26883. States: ['states'],
  26884. Events: ['events'],
  26885. Material: ['material', 'materials'],
  26886. Geometry: ['geometry'],
  26887. Position: ['position'],
  26888. Rotation: ['rotation'],
  26889. Scale: ['scale'],
  26890. Transform: ['position', 'scale', 'rotation', 'hiddenMatrix'],
  26891. Name: ['name'],
  26892. Visibility: ['visible', 'raycastLock', 'flatShading', 'wireframe', 'side'],
  26893. Shadows: ['castShadow', 'receiveShadow'],
  26894. Cloner: ['cloner'],
  26895. Physics: ['physics']
  26896. }),
  26897. (e.defaultMeshObject = {
  26898. name: 'Rectangle',
  26899. ...Ar.defaultData,
  26900. ...Mo.defaultData,
  26901. geometry: So.defaultData('RectangleGeometry'),
  26902. material: nr.defaultTwoLayerData('phong', 'layer1', 'layer2')
  26903. }),
  26904. (e.defaultBooleanObject = {
  26905. name: 'Boolean',
  26906. ...Ar.defaultData,
  26907. ...Mo.defaultData,
  26908. geometry: So.defaultData('BooleanGeometry'),
  26909. material: nr.defaultTwoLayerData('phong', 'layer1', 'layer2')
  26910. }),
  26911. (e.defaultTextObject = {
  26912. name: 'Text',
  26913. ...Ar.defaultData,
  26914. ...Mo.defaultData,
  26915. geometry: So.defaultData('TextGeometry'),
  26916. material: nr.defaultTwoLayerData('phong', 'layer1', 'layer2')
  26917. })
  26918. ))(Sm || (Sm = {}));
  26919. var oa;
  26920. ((e) => {
  26921. function t(n, a) {
  26922. let o = { name: a };
  26923. return (
  26924. n.type === 'Mesh'
  26925. ? ((o.geometry = {}),
  26926. 'material' in n && (o.material = { layers: new mi() }),
  26927. 'materials' in n && (o.materials = n.materials.map((l) => ({ layers: new mi() }))))
  26928. : _a.is(n.type) && ((o.perspective = {}), (o.orthographic = {})),
  26929. o
  26930. );
  26931. }
  26932. e.newEmpty = t;
  26933. function i(n, a) {
  26934. if (a === void 0) return n;
  26935. let o = { ...n };
  26936. return (
  26937. 'material' in o &&
  26938. 'material' in a &&
  26939. a.material &&
  26940. (o.material = Pd(o.material, (l) => {
  26941. if (typeof l != 'string')
  26942. for (let [h, u] of Object.entries(a.material.layers)) {
  26943. let c = l.layers.data(h);
  26944. c && xr.patch(c, u);
  26945. }
  26946. }).data),
  26947. o.materials &&
  26948. a.materials &&
  26949. (o.materials = Pd(o.materials, (l) => {
  26950. for (let h = 0; h < o.materials.length; h++) {
  26951. let u = a.materials[h];
  26952. if (typeof u != 'string')
  26953. for (let [c, d] of Object.entries(u.layers)) {
  26954. let p = l[h]?.layers?.data(c);
  26955. p && xr.patch(p, d);
  26956. }
  26957. }
  26958. }).data),
  26959. o
  26960. );
  26961. }
  26962. function r(n, a) {
  26963. let o,
  26964. l = [],
  26965. h = { orthographic: 0, perspective: 0, geometry: 0 };
  26966. function u(c, d) {
  26967. for (let [p, f] of Object.entries(d.layers)) {
  26968. let { texture: g, ...m } = f;
  26969. if (g !== void 0 && Object.keys(g).length > 0) {
  26970. let v = { path: [...c, 'layers', p, 'texture'], props: g, type: 0 };
  26971. l.push(v);
  26972. }
  26973. if (Object.keys(m).length > 0) {
  26974. let v = { path: [...c, 'layers', p], props: m, type: 0 };
  26975. l.push(v);
  26976. }
  26977. }
  26978. }
  26979. for (let [c, d] of Object.entries(a))
  26980. if (c !== 'name')
  26981. if (c === 'cloner') l.push(...fm.toOps(d, ['cloner']));
  26982. else if (c === 'pathSnapping') l.push({ path: [c], props: { slide: d.slide, offset: d.offset }, type: 0 });
  26983. else if (c === 'material') u(['material'], d);
  26984. else if (c === 'materials') for (let [p, f] of Object.entries(d)) u(['materials', p], f);
  26985. else if (h[c] === 0) {
  26986. if (c === 'geometry' && d.extrusion !== void 0) {
  26987. let p = { path: [c, 'extrusion'], props: d.extrusion, type: 0 };
  26988. l.push(p), (d = { ...d }), delete d.extrusion;
  26989. }
  26990. if (Object.keys(d).length > 0) {
  26991. let p = { path: [c], props: d, type: 0 };
  26992. l.push(p);
  26993. }
  26994. } else o === void 0 && ((o = { path: [], props: {}, type: 0 }), l.push(o)), (o.props[c] = d);
  26995. return l;
  26996. }
  26997. e.toOps = r;
  26998. function s(n, a) {
  26999. if (a === void 0) return n;
  27000. let o = { ...n };
  27001. if (
  27002. (Object.assign(o, jo.merge(o, a)),
  27003. Object.assign(o, {
  27004. pathSnapping: Object.assign({}, o.pathSnapping, {
  27005. slide: a.pathSnapping?.slide ?? o.pathSnapping?.slide ?? 0,
  27006. offset: a.pathSnapping?.offset ?? o.pathSnapping?.offset ?? 0
  27007. })
  27008. }),
  27009. _a.is(n.type))
  27010. ) {
  27011. (o.orthographic = { ...o.orthographic }), (o.perspective = { ...o.perspective });
  27012. let l = a;
  27013. l.orthographic?.zoom !== void 0 && (o.orthographic.zoom = l.orthographic.zoom),
  27014. l.perspective?.zoom !== void 0 && (o.perspective.zoom = l.perspective.zoom),
  27015. l.isUpVectorFlipped !== void 0 && (o.isUpVectorFlipped = l.isUpVectorFlipped),
  27016. l.targetOffset !== void 0 && (o.targetOffset = l.targetOffset);
  27017. } else if (n.type === 'Mesh')
  27018. 'geometry' in a && Object.assign(o, { geometry: wm.merge(o.geometry, a.geometry) }),
  27019. (a.material || a.materials) && (o = i(o, a)),
  27020. o.cloner && 'cloner' in a && Object.assign(o, { cloner: bn.merge(o.cloner, a.cloner) });
  27021. else if (n.type === 'Empty') o.cloner && 'cloner' in a && Object.assign(o, { cloner: bn.merge(o.cloner, a.cloner) });
  27022. else if (mm.is(n.type)) {
  27023. let l = a;
  27024. l.intensity !== void 0 && (o.intensity = l.intensity),
  27025. l.color !== void 0 && (typeof l.color == 'string' ? (o.color = l.color) : (o.color = $i.clone(l.color)));
  27026. }
  27027. return o;
  27028. }
  27029. e.patch = s;
  27030. })(oa || (oa = {}));
  27031. var kd;
  27032. ((e) => (e.defaultData = { enabled: !1, useBackgroundColor: !1, color: $i.white, near: 0.1, far: 2e3 }))(kd || (kd = {}));
  27033. var jd;
  27034. ((e) =>
  27035. (e.defaultData = {
  27036. enablePan: !0,
  27037. enableZoom: !0,
  27038. enableRotate: !0,
  27039. enableDamping: !0,
  27040. rotationLimitsMode: 0,
  27041. rotationVerticalOffset: { min: Math.PI / 4, max: Math.PI / 4 },
  27042. rotationHorizontalOffset: { min: Math.PI / 4, max: Math.PI / 4 },
  27043. rotationSoftLimit: 2,
  27044. panLimitsMode: 0,
  27045. panVerticalOffset: { min: 250, max: 250 },
  27046. panHorizontalOffset: { min: 250, max: 250 },
  27047. panSoftLimit: 2,
  27048. zoomLimitsEnabled: !1,
  27049. zoomLimits: { min: 0.1, max: 2 },
  27050. autoRotate: !1,
  27051. autoRotateSpeed: 2,
  27052. autoRotateClockwise: !0,
  27053. hoverRotatePanMode: 0,
  27054. hoverRotatePanStrength: 20,
  27055. isTouchZoom: !0,
  27056. orbitTouches: 2,
  27057. panTouches: 3,
  27058. resetHoverEffectOnPointerLeave: !0,
  27059. autoZoom: !1
  27060. }))(jd || (jd = {}));
  27061. var Vo;
  27062. ((e) =>
  27063. (e.defaultData = {
  27064. orbitControls: jd.defaultData,
  27065. playCamera: null,
  27066. withBackground: !0,
  27067. preventScroll: !1,
  27068. preventTouchScroll: !1,
  27069. hideCursor: !1,
  27070. mouseEventTarget: 'canvas',
  27071. settings: {
  27072. image: { format: 'jpg', ratio: 1 },
  27073. video: {
  27074. format: 'mp4',
  27075. imageFormat: 'jpg',
  27076. fps: 30,
  27077. mbps: 80,
  27078. ratio: typeof window < 'u' ? Math.floor(window.devicePixelRatio) : 1,
  27079. stopMode: 'manual',
  27080. duration: 5e3
  27081. },
  27082. web: { logo: !0, compress: !0, preset: 1, preload: !0, hint: !1 }
  27083. },
  27084. stopRaycast: !0,
  27085. joystickSizeAndXYOffset: Array(12)
  27086. .fill(0)
  27087. .map((t, i) => {
  27088. let r = 0,
  27089. s = 0;
  27090. return (
  27091. i < 5 ? (s = -30) : i < 10 && (s = 30),
  27092. i === 0 || i === 10 || i === 5 ? (r = 30) : (i === 4 || i === 11 || i === 9) && (r = -30),
  27093. [120, [r, s], 'show']
  27094. );
  27095. }),
  27096. gameControlObject: null
  27097. }))(Vo || (Vo = {}));
  27098. function Aa(e, t) {
  27099. return Object.setPrototypeOf(e, t), e;
  27100. }
  27101. var XN = () => (typeof window > 'u' ? !1 : window.navigator.userAgent.toLowerCase().includes(' electron/')),
  27102. qN = () => (typeof window > 'u' ? !1 : window.navigator.platform.toUpperCase().includes('MAC')),
  27103. YN = () => (typeof window > 'u' ? !1 : /iPad|iPhone|iPod/.test(window.navigator.userAgent) || (Su && 'ontouchend' in document)),
  27104. QN = () => (typeof window > 'u' ? !1 : window.navigator.userAgent.toLowerCase().indexOf('firefox') > -1),
  27105. ZN = () => (typeof window > 'u' ? !1 : 'ontouchstart' in window || navigator.maxTouchPoints > 0),
  27106. KN = () => {
  27107. if (typeof window > 'u') return !1;
  27108. let e = navigator.userAgent,
  27109. t = navigator.vendor;
  27110. return /Safari/i.test(e) && /Apple Computer/.test(t);
  27111. },
  27112. JN = () => {
  27113. if (typeof window > 'u') return null;
  27114. let e = navigator.userAgent.match(/Version\/(\d+\.\d)/);
  27115. return e && e[1];
  27116. },
  27117. S9 = XN(),
  27118. Su = qN(),
  27119. Mm = YN(),
  27120. $N = QN(),
  27121. rr = ZN(),
  27122. V1 = KN(),
  27123. H1 = Number(JN());
  27124. function tA(e) {
  27125. return Array.isArray(e) ? e : [e];
  27126. }
  27127. function eU(e, t) {
  27128. let i = 0;
  27129. for (; i < e.length && i < t.length; ) {
  27130. if (e[i] < t[i]) return -1;
  27131. if (e[i] > t[i]) return 1;
  27132. i += 1;
  27133. }
  27134. return i !== t.length ? -1 : i !== e.length ? 1 : 0;
  27135. }
  27136. function Ac(e) {
  27137. return Su ? e.metaKey : e.ctrlKey;
  27138. }
  27139. var Qe = [],
  27140. Gd = {},
  27141. Vl = {},
  27142. rd = {};
  27143. function iA(e) {
  27144. Qe.includes(e) || Qe.push(e);
  27145. }
  27146. function Eo(e) {
  27147. delete Gd[e.pointerId];
  27148. for (let t = 0; t < Qe.length; t++)
  27149. if (Qe[t].pointerId === e.pointerId) {
  27150. Qe.splice(t, 1);
  27151. break;
  27152. }
  27153. }
  27154. function tU() {
  27155. Qe.splice(0, Qe.length);
  27156. }
  27157. function Vd(e) {
  27158. if (e.pointerType !== 'touch') return;
  27159. let t = Gd[e.pointerId];
  27160. t === void 0 && ((t = { x: 0, y: 0 }), (Gd[e.pointerId] = t)), (t.x = e.pageX), (t.y = e.pageY);
  27161. }
  27162. function Np(e) {
  27163. let t = e.pointerId === Qe[0].pointerId ? Qe[1] : Qe[0];
  27164. return Gd[t.pointerId];
  27165. }
  27166. function rA(e) {
  27167. (Vl[e.key] = !0), (rd[e.key] = rd[e.key] === void 0 ? 1 : rd[e.key] + 1);
  27168. }
  27169. function sA(e) {
  27170. if (Su && Vl.Meta) for (let t in Vl) Vl[t] = !1;
  27171. else Vl[e.key] = !1;
  27172. rd = {};
  27173. }
  27174. function iU(e) {
  27175. e.addEventListener('pointerdown', iA, !0),
  27176. e.addEventListener('pointerdown', Vd, !0),
  27177. e.addEventListener('pointermove', Vd, !0),
  27178. e.addEventListener('pointerup', Eo, !0),
  27179. e.addEventListener('pointercancel', Eo, !0),
  27180. e.addEventListener('pointerleave', Eo, !0),
  27181. window.addEventListener('keydown', rA, !0),
  27182. window.addEventListener('keyup', sA, !0);
  27183. }
  27184. function rU(e) {
  27185. e.removeEventListener('pointerdown', iA, !0),
  27186. e.removeEventListener('pointerdown', Vd, !0),
  27187. e.removeEventListener('pointermove', Vd, !0),
  27188. e.removeEventListener('pointerup', Eo, !0),
  27189. e.removeEventListener('pointercancel', Eo, !0),
  27190. e.removeEventListener('pointerleave', Eo, !0),
  27191. window.removeEventListener('keydown', rA, !0),
  27192. window.removeEventListener('keyup', sA, !0);
  27193. }
  27194. var Ki;
  27195. ((e) =>
  27196. (e.defaultData = {
  27197. ambientLight: {
  27198. enabled: !0,
  27199. color: { r: 0.8274509803921568, g: 0.8274509803921568, b: 0.8274509803921568 },
  27200. intensity: 0.75,
  27201. depth: 100,
  27202. groundColor: { r: 0.5098039215686274, g: 0.5098039215686274, b: 0.5098039215686274 },
  27203. softShadows: !0,
  27204. softShadowQuality: 'low'
  27205. },
  27206. usePhysics: !1,
  27207. gravity: -10,
  27208. pixelsPerMeter: 200,
  27209. skinWidthRelative: 0.02,
  27210. stepThreshRelative: 0.3,
  27211. slopeThresh: 65
  27212. }))(Ki || (Ki = {}));
  27213. var Em;
  27214. ((e) => {
  27215. e.TRASH_CAN_ID = '830a2708-8ed9-49cf-a68e-085299892222';
  27216. function t(s = { withLight: !0, withSquare: !0 }) {
  27217. let n = new ki(),
  27218. a = Sm.defaultMeshObject;
  27219. return (
  27220. s.withLight === !0 &&
  27221. n.push({
  27222. fi: -1,
  27223. data: { ...Am.defaultData('DirectionalLight'), position: [200, 300, 300], name: 'Directional Light', intensity: 0.7 },
  27224. id: '830a2708-8ed9-49cf-a68e-085299899103',
  27225. children: []
  27226. }),
  27227. s.withSquare === !0 && n.push({ fi: 1, id: '7ba78968-2a55-48f2-b14c-5191da3e075e', data: a, children: [] }),
  27228. n
  27229. );
  27230. }
  27231. (e.defaultData = {
  27232. backgroundColor: kr.fromHexAndA(2960946, 1),
  27233. postprocessing: bh.defaultData,
  27234. fog: kd.defaultData,
  27235. objects: t(),
  27236. environment: Ki.defaultData,
  27237. publish: Vo.defaultData
  27238. }),
  27239. (e.emptyData = function (s) {
  27240. return {
  27241. backgroundColor: kr.fromHexAndA(2960946, 1),
  27242. postprocessing: bh.defaultData,
  27243. fog: kd.defaultData,
  27244. objects: s ? t(s) : new ki(),
  27245. environment: Ki.defaultData,
  27246. publish: Vo.defaultData
  27247. };
  27248. });
  27249. function i(s) {
  27250. return { ...e.defaultData, objects: Aa(s, ki.prototype) };
  27251. }
  27252. e.withObjs = i;
  27253. function r(s, n) {
  27254. return i([{ id: s, data: n, children: [], fi: 0 }]);
  27255. }
  27256. e.withObj = r;
  27257. })(Em || (Em = {}));
  27258. var Hd;
  27259. ((e) =>
  27260. (e.emptyImage = {
  27261. data: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII='
  27262. }))(Hd || (Hd = {}));
  27263. var Wd;
  27264. ((e) => {
  27265. function t() {
  27266. let s = {};
  27267. return (s['89b10010-844c-11ec-a8a3-0242ac120002'] = { r: 0.5, g: 0.5, b: 0.5, a: 1, name: 'Default Color' }), Aa(s, Qt.prototype);
  27268. }
  27269. e.defaultColors = t;
  27270. function i(s) {
  27271. let n = {};
  27272. return (
  27273. s?.withAITexture && (n['a1b10010-844c-a8a3-11ec-0242ac2011ec'] = { ...Hd.emptyImage, name: 'AI generated image' }),
  27274. Aa(n, Qt.prototype)
  27275. );
  27276. }
  27277. e.defaultImages = i;
  27278. function r() {
  27279. return {
  27280. materials: new Qt(),
  27281. images: new Qt(),
  27282. videos: new Qt(),
  27283. colors: new Qt(),
  27284. audios: new Qt(),
  27285. fonts: new Qt(),
  27286. penumbraSize: [2, 2, 2]
  27287. };
  27288. }
  27289. e.emptyData = r;
  27290. })(Wd || (Wd = {}));
  27291. function W1(e) {
  27292. e.layers.forEach((t) => {
  27293. if (t.type === 'depth' && t.colorA !== void 0) {
  27294. let i = t.colorA,
  27295. r = t.colorB,
  27296. s = [
  27297. [i.r, i.g, i.b, i.a],
  27298. [r.r, r.g, r.b, r.a]
  27299. ],
  27300. n = [0, 1];
  27301. for (let o = 2; o < 10; o++) s.push(s[1]), n.push(1);
  27302. let a = {
  27303. ...gh(Si(t), 'type', 'visible', 'isVector', 'isWorldSpace', 'origin', 'alpha', 'mode'),
  27304. near: Math.max(0, t.near),
  27305. far: Math.max(0, t.far),
  27306. colors: s,
  27307. steps: n,
  27308. num: 2,
  27309. direction: [1, 0, 0],
  27310. smooth: !1,
  27311. gradientType: 1
  27312. };
  27313. Object.assign(t, a);
  27314. } else if (t.type === 'depth' && t.gradientType === 1 && (t.near < 0 || t.far < 0)) {
  27315. let i = { ...Si(t), near: Math.max(t.near, 0), far: Math.max(t.far, 0) };
  27316. Object.assign(t, i);
  27317. }
  27318. });
  27319. }
  27320. function sd(e, t) {
  27321. Object.values(e.shared.materials).forEach((i) => t(i));
  27322. }
  27323. function nd(e, t) {
  27324. e.scene.objects.traverse((i, r) => {
  27325. 'materials' in r
  27326. ? r.materials.forEach((s) => {
  27327. typeof s != 'string' && t(s);
  27328. })
  27329. : 'material' in r && typeof r.material != 'string' && t(r.material);
  27330. });
  27331. }
  27332. function sU(e) {
  27333. Object.assign(e.scene.publish, { orbitControls: { ...jd.defaultData, ...Si(e.scene.publish.orbitControls) } });
  27334. }
  27335. function nU(e) {
  27336. Object.assign(e.scene.publish.settings, { video: { ...Vo.defaultData.settings.video, ...Si(e.scene.publish.settings.video) } });
  27337. }
  27338. function aU(e) {
  27339. function t(i) {
  27340. if (i.layers) {
  27341. for (let r of Object.values(i.layers))
  27342. if (r) {
  27343. for (let [s, n] of Object.entries(r))
  27344. if (((K_.includes(s) || typeof n == 'boolean') && delete r[s], s === 'texture'))
  27345. for (let [a, o] of Object.entries(n)) (WN.includes(a) || typeof o == 'boolean') && delete n[a];
  27346. }
  27347. }
  27348. }
  27349. e.scene.objects.traverse((i, r) => {
  27350. r.states.forEach((s) => {
  27351. let n = s;
  27352. n.material
  27353. ? t(n.material)
  27354. : n.materials &&
  27355. n.materials.forEach((a) => {
  27356. t(a);
  27357. });
  27358. });
  27359. });
  27360. }
  27361. function oU(e) {
  27362. e.scene.publish.withBackground = !0;
  27363. }
  27364. function lU(e) {
  27365. e.scene.publish.settings.web = { compress: !0, preload: !0, preset: 1, logo: !0, hint: !1 };
  27366. }
  27367. function hU(e) {
  27368. e.scene.objects.traverse((t, i) => {
  27369. let r = i.cloner;
  27370. r && ((r.radial.scale = r.radial.scale.map((s) => s + 1)), (r.linear.scale = r.linear.scale.map((s) => s + 1)));
  27371. });
  27372. }
  27373. function cU(e) {
  27374. e.scene.objects.traverse((t, i) => {
  27375. let r = i.geometry;
  27376. r && (r.type === 'DodecahedronGeometry' || r.type === 'IcosahedronGeometry') && (r.detail = Math.round(r.detail));
  27377. });
  27378. }
  27379. function dU(e) {
  27380. e.scene.objects.traverse((t, i) => {
  27381. let r = e.scene.objects.unproxy().parent(t);
  27382. if (r) {
  27383. let s = Si(e.scene.objects.data(r));
  27384. s && s.type === 'Mesh' && s.geometry.type === 'BooleanGeometry' && i.type === 'Mesh' && (i.visible = Si(i).booleanExclude !== !0);
  27385. }
  27386. });
  27387. }
  27388. function uU(e) {
  27389. e.scene.objects.traverse((t, i) => {
  27390. if (i.type === 'Mesh') {
  27391. let r = i;
  27392. i.geometry.type === 'NonParametricGeometry'
  27393. ? r.material !== void 0 && delete r.material
  27394. : r.materials !== void 0 && delete r.materials;
  27395. }
  27396. });
  27397. }
  27398. function pU(e) {
  27399. function t(r) {
  27400. Object.setPrototypeOf(r, mi.prototype), r.texture && Object.setPrototypeOf(r.texture, mi.prototype);
  27401. }
  27402. function i(r) {
  27403. Object.setPrototypeOf(r, mi.prototype);
  27404. for (let s in r) t(r[s]);
  27405. }
  27406. e.scene.objects.traverse((r, s) => {
  27407. s.states.forEach((n) => {
  27408. let a = n;
  27409. if (a.material) {
  27410. let o = Si(a.material).layers;
  27411. i(o), (a.material.layers = o);
  27412. }
  27413. if (a.materials)
  27414. for (let o = 0; o < a.materials.length; o++) {
  27415. let l = a.materials[o],
  27416. h = Si(l).layers;
  27417. i(h), (l.layers = h);
  27418. }
  27419. });
  27420. });
  27421. }
  27422. function X1(e) {
  27423. e.layers === void 0 && Object.assign(e, nr.defaultTwoLayerData('lambert'));
  27424. }
  27425. function Up(e) {
  27426. !e.layers ||
  27427. e.layers.forEach((t) => {
  27428. if (t.type === 'depth' && t.colors.length === 10) {
  27429. let i = [...t.colors];
  27430. i.push(t.colors[9]);
  27431. let r = [...t.steps];
  27432. r.push(t.steps[9]);
  27433. let s = { ...Si(t), colors: i, steps: r };
  27434. Object.assign(t, s);
  27435. }
  27436. });
  27437. }
  27438. function fU(e) {
  27439. e.scene.objects.traverse((t, i) => {
  27440. i.type === 'Mesh' && (i.geometry.type === 'BooleanGeometry' || i.geometry.type === 'SubdivGeometry') && (i.geometry.phongAngle = 35);
  27441. });
  27442. }
  27443. function q1(e) {
  27444. e.scene.objects.traverse((t, i) => {
  27445. 'materials' in i
  27446. ? i.materials.forEach((r) => {
  27447. typeof r != 'string' && Up(r);
  27448. })
  27449. : 'material' in i && typeof i.material != 'string' && Up(i.material);
  27450. }),
  27451. Object.values(e.shared.materials).forEach((t) => Up(t));
  27452. }
  27453. function mU(e) {
  27454. (e.scene.environment.ambientLight.softShadows = !1),
  27455. (e.scene.environment.ambientLight.softShadowQuality = 'low'),
  27456. e.scene.objects.traverse((t, i) => {
  27457. (i.type === 'DirectionalLight' || i.type === 'SpotLight') && ((i.shadowResolution = 1024), (i.shadowRadius = 1), (i.depth = 1e5));
  27458. }),
  27459. (e.shared.penumbraSize = new Array(5).fill(0.5));
  27460. }
  27461. function gU(e) {
  27462. e.shared.audios = Aa({}, Qt.prototype);
  27463. }
  27464. function vU(e) {
  27465. e.shared.videos = Aa({}, Qt.prototype);
  27466. }
  27467. function yU(e) {
  27468. let t = e.shared.materials;
  27469. Object.entries(t).forEach(([i, r]) => {
  27470. if (!r.layers) {
  27471. let s = {
  27472. name: 'Untitled Material',
  27473. layers: [
  27474. {
  27475. fi: 0,
  27476. data: {
  27477. type: 'light',
  27478. category: 'phong',
  27479. alpha: 0.6,
  27480. visible: !0,
  27481. mode: 0,
  27482. specular: { r: 0.2, g: 0.2, b: 0.2 },
  27483. shininess: 5
  27484. },
  27485. id: 'layer1'
  27486. },
  27487. {
  27488. fi: 1,
  27489. data: {
  27490. type: 'color',
  27491. alpha: 1,
  27492. visible: !0,
  27493. mode: 0,
  27494. color: { r: 0.2823529411764706, g: 0.2823529411764706, b: 0.30196078431372547 }
  27495. },
  27496. id: 'layer2'
  27497. }
  27498. ]
  27499. };
  27500. Object.assign(t, { [i]: s });
  27501. }
  27502. });
  27503. }
  27504. function xU(e) {
  27505. Object.entries(Si(e.shared.images))
  27506. .filter((t) => t[1].asset === !1)
  27507. .map((t) => t[0])
  27508. .forEach((t) => {
  27509. delete e.shared.images[t];
  27510. }),
  27511. Object.entries(Si(e.shared.audios))
  27512. .filter((t) => t[1].asset === !1)
  27513. .map((t) => t[0])
  27514. .forEach((t) => {
  27515. delete e.shared.audios[t];
  27516. });
  27517. }
  27518. function bU(e) {
  27519. e.scene.publish.settings.web.preload = !1;
  27520. }
  27521. function Y1(e) {
  27522. e.layers &&
  27523. e.layers.forEach((t) => {
  27524. 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);
  27525. });
  27526. }
  27527. function wU(e) {
  27528. e.shared.fonts = Aa({}, Qt.prototype);
  27529. }
  27530. function _U(e) {
  27531. return e
  27532. .replace('.typeface', '')
  27533. .replace(/optimer/gi, 'open sans')
  27534. .replace('space_mono', 'space mono')
  27535. .replace(/alma_mono/gi, 'varela round')
  27536. .replace(/droid_sans_mono/gi, 'noto sans mono')
  27537. .replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi, 'roboto')
  27538. .replace(/droid_serif/gi, 'roboto slab')
  27539. .replace('_sans', ' sans')
  27540. .replace('crimson_text', 'crimson text')
  27541. .replace('medium_medium', 'medium')
  27542. .replace('fatface_fatface', 'fatface')
  27543. .replace('100hairline', 'thin')
  27544. .replace('200thin', 'extralight')
  27545. .replace('300light', 'light')
  27546. .replace('500medium', 'medium')
  27547. .replace('600semi', 'semibold')
  27548. .replace('800heavy', 'extrabold')
  27549. .replace('900black', 'black')
  27550. .replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi, 'bodoni_$1_$2')
  27551. .replace(/bodoni_(11|16|24|36|48|72|96)/gi, 'bodoni moda')
  27552. .replace(/(thin|hairline)(_regular)?/gi, '100')
  27553. .replace(/(extra|ultra)light(_regular)?/gi, '200')
  27554. .replace(/light(_regular)?/gi, '300')
  27555. .replace(/_book|_normal|_roman/gi, '_regular')
  27556. .replace(/medium(_regular)?/gi, '500')
  27557. .replace(/(semi|demi)bold(_regular)?/gi, '600')
  27558. .replace(/(extra|ultra)bold(_regular)?/gi, '800')
  27559. .replace(/bold(_regular)?/gi, '700')
  27560. .replace(/(black|heavy|fatface)(_regular)?/gi, '900')
  27561. .replace(/([1-9]00)_italic/gi, '$1italic')
  27562. .replace(/regularitalic/gi, 'italic')
  27563. .replace(/regularitalic/gi, 'italic')
  27564. .split(' ')
  27565. .map((t) => t.charAt(0).toUpperCase() + t.slice(1))
  27566. .join(' ');
  27567. }
  27568. function AU(e) {
  27569. let t = [];
  27570. e.scene.objects.traverse((i, r) => {
  27571. let s = r;
  27572. if (s.type === 'TextFrame') {
  27573. let n = nr.defaultTwoLayerData('phong'),
  27574. a = typeof s.color == 'string' ? e.shared.colors[s.color] : s.color;
  27575. (n.layers[1].data.color = { r: a.r, g: a.g, b: a.b }), (n.layers[1].data.alpha = s.alpha);
  27576. let o = _U(s.font);
  27577. e.shared.fonts[o] === void 0 && (e.shared.fonts[o] = { name: o });
  27578. let l = {
  27579. name: s.name,
  27580. ...Ar.defaultData,
  27581. ...Mo.defaultData,
  27582. flatShading: !1,
  27583. wireframe: !1,
  27584. geometry: {
  27585. ...So.defaultData('TextGeometry'),
  27586. width: s.width,
  27587. height: s.height,
  27588. font: o,
  27589. depth: 0,
  27590. horizontalAlign: s.horizontalAlign,
  27591. verticalAlign: s.verticalAlign,
  27592. fontSize: s.fontSize * 1.40625,
  27593. lineHeight: s.lineHeight / 1.40625,
  27594. letterSpacing: s.letterSpacing - 1,
  27595. text: s.text,
  27596. textTransform: s.textTransform,
  27597. extrudeBevelSize: 0,
  27598. extrudeBevelSegments: 1
  27599. },
  27600. material: n,
  27601. states: Si(s.states),
  27602. events: Si(s.events),
  27603. visible: s.visible,
  27604. raycastLock: s.raycastLock,
  27605. position: s.position,
  27606. rotation: s.rotation,
  27607. scale: s.scale,
  27608. hiddenMatrix: s.hiddenMatrix
  27609. },
  27610. h = Si(e.scene.objects).parent(i);
  27611. e.scene.objects.insertAfter(h ?? null, i, [{ id: i + 'new', data: l, children: [] }]), t.push(i);
  27612. }
  27613. }),
  27614. t.forEach((i) => {
  27615. e.scene.objects.delete(i);
  27616. });
  27617. }
  27618. function SU(e) {
  27619. let t = {
  27620. 0: 'MouseDown',
  27621. 1: 'MouseUp',
  27622. 2: 'MouseHover',
  27623. 5: 'KeyDown',
  27624. 6: 'KeyUp',
  27625. 7: 'Start',
  27626. 9: 'LookAt',
  27627. 10: 'Follow',
  27628. 11: 'Scroll',
  27629. 12: 'Audio',
  27630. 13: 'GameControl'
  27631. };
  27632. e.scene.objects.traverse((i, r) => {
  27633. r.events.forEach((s) => {
  27634. if (t[Number(s.type)])
  27635. if (
  27636. (Object.assign(s, { type: t[Number(s.type)] }),
  27637. s.type === 'Audio' && 'audioEvent' in s && (Object.assign(s, { playAudio: s.audioEvent }), delete s.audioEvent),
  27638. s.type === 'GameControl')
  27639. )
  27640. Object.assign(s, { gameActions: { idle: new rt(), move: new rt(), jump: new rt() } });
  27641. else {
  27642. let n = new rt();
  27643. Object.assign(s, { actions: n }),
  27644. (s.type === 'MouseDown' || s.type === 'MouseUp' || s.type === 'KeyDown' || s.type === 'KeyUp') &&
  27645. 'url' in s &&
  27646. n.push({ fi: 0, id: it.generateUUID(), data: { type: 'Link', url: s.url, delay: 0 } }),
  27647. 'targets' in s &&
  27648. (s.targets.forEach((a, o, l) => {
  27649. let h = { state: void 0, repeat: 0, delay: 0, delayDirection: void 0, direction: 'normal', duration: 0, easing: 4 },
  27650. u = { easing: a.easing, duration: a.duration };
  27651. a.easing === 6
  27652. ? Object.assign(u, gh(a, 'mass', 'stiffness', 'damping', 'velocity'))
  27653. : a.easing === 5 && Object.assign(u, { control1: { ...a.control1 }, control2: { ...a.control2 } });
  27654. let c = {
  27655. repeat: a.repeat ? -1 : 0,
  27656. delay: a.delay,
  27657. delayDirection: a.delayDirection,
  27658. direction: a.cycle && a.rewind ? 'pingpong-rewind' : a.cycle ? 'pingpong' : 'normal'
  27659. },
  27660. d = { state: a.state, ...c, ...u },
  27661. p = {
  27662. allowSlerp: !0,
  27663. type: 'Transition',
  27664. object: a.object,
  27665. repeat: 0,
  27666. delay: 0,
  27667. delayDirection: void 0,
  27668. direction: 'normal',
  27669. tweens: new rt({ fi: 0, id: it.generateUUID(), data: h }, { fi: 1, id: it.generateUUID(), data: d })
  27670. };
  27671. n.push({ fi: l, id: o, data: p });
  27672. }),
  27673. delete s.targets);
  27674. }
  27675. });
  27676. });
  27677. }
  27678. function MU(e) {
  27679. e.scene.objects.traverse((t, i) => {
  27680. function r(s, n) {
  27681. let a = new rt(),
  27682. o = [];
  27683. if (
  27684. (i.events.forEach((l, h, u) => {
  27685. if (l.type === 'Audio' && l.trigger === n) {
  27686. let c;
  27687. o.push(h),
  27688. l.interaction === 'play'
  27689. ? (c = {
  27690. ...gh(l, 'interaction', 'audio', 'delay', 'volume', 'loop'),
  27691. triggerAfter: 'after' in l ? l.after : void 0,
  27692. toggle: 'after' in l ? l.toggle : void 0,
  27693. type: 'Audio'
  27694. })
  27695. : (l.interaction === 'pause' || l.interaction === 'stop') &&
  27696. (c = { ...gh(l, 'interaction', 'delay', 'object', 'playAudio'), type: 'Audio' }),
  27697. c && a.push({ fi: u, id: h, data: c });
  27698. }
  27699. }),
  27700. o.forEach((l) => i.events.delete(l)),
  27701. a.length)
  27702. ) {
  27703. let l = i.events.find((h) => h.type === s)?.data;
  27704. l
  27705. ? 'actions' in l && l.actions.insertBefore(null, a)
  27706. : i.events.insertBefore(null, [{ id: it.generateUUID(), data: { type: s, actions: a } }]);
  27707. }
  27708. }
  27709. r('Start', 'start'), r('MouseDown', 'mouseDown'), r('MouseUp', 'mouseUp'), r('KeyDown', 'keyDown'), r('KeyUp', 'keyUp');
  27710. });
  27711. }
  27712. function Q1(e) {
  27713. let t = e.layers.find((i) => i.type === 'light')?.data;
  27714. if (t?.category === 'basic') {
  27715. let i = xr.defaultData('light', 'phong'),
  27716. r = t;
  27717. Object.assign(r, i), (r.visible = !1);
  27718. }
  27719. }
  27720. function Z1(e) {
  27721. sd(e, Q1), nd(e, Q1);
  27722. }
  27723. function EU(e) {
  27724. e.scene.objects.traverse((t, i) => {
  27725. i.type === 'Mesh' && i.geometry.type === 'SubdivGeometry' && (i.geometry.scaleBaked || (i.geometry.scaleBaked = [1, 1, 1]));
  27726. });
  27727. }
  27728. function CU(e) {
  27729. e.scene.objects.traverse((t, i) => {
  27730. (i.type === 'Empty' || i.type === 'Mesh') &&
  27731. i.cloner &&
  27732. !i.cloner.randomnessObject &&
  27733. !i.cloner.toObject &&
  27734. !i.cloner.randomness &&
  27735. (i.cloner = {
  27736. ...i.cloner,
  27737. toObject: {
  27738. object: '',
  27739. spreadType: 'random',
  27740. scale: [0, 0, 0],
  27741. rotation: [0, 0, 0],
  27742. position: [0, 0, 0],
  27743. axis: 'x',
  27744. seed: 0,
  27745. count: 99,
  27746. align: 'normal'
  27747. },
  27748. randomness: !1,
  27749. randomnessObject: {
  27750. strength: 100,
  27751. scale: [0, 0, 0],
  27752. rotation: [0, 0, 0],
  27753. position: [0, 0, 0],
  27754. movement: 1,
  27755. seed: 0,
  27756. freqScale: 10,
  27757. noiseType: 'perlin'
  27758. }
  27759. });
  27760. });
  27761. }
  27762. function TU(e) {
  27763. e.scene.objects.traverse((t, i) => {
  27764. i.type === 'Mesh' &&
  27765. i.geometry.type === 'NonParametricGeometry' &&
  27766. !('material' in i) &&
  27767. !('materials' in i) &&
  27768. (i.material = nr.defaultTwoLayerData('phong'));
  27769. });
  27770. }
  27771. function PU(e) {
  27772. e.scene.publish.orbitControls.autoZoom === void 0 && (e.scene.publish.orbitControls.autoZoom = !1),
  27773. e.scene.objects.traverse((t, i) => {
  27774. (i.type === 'OrthographicCamera' || i.type === 'PerspectiveCamera') &&
  27775. (i.orthographic.autoZoom === void 0 && (i.orthographic.autoZoom = !1),
  27776. i.orthographic.autoZoomFrustumSize === void 0 && (i.orthographic.autoZoomFrustumSize = 790));
  27777. });
  27778. }
  27779. function DU(e) {
  27780. e.scene.objects.traverse((t, i) => {
  27781. i.pathSnapping === void 0 && (i.pathSnapping = { pathId: null, slide: 0, offset: 0, orientation: 'tangential' }),
  27782. i.pathSnapping.offset === void 0 && (i.pathSnapping.offset = 0);
  27783. });
  27784. }
  27785. function LU(e) {
  27786. e.scene.publish.mouseEventTarget === void 0 && (e.scene.publish.mouseEventTarget = 'canvas'),
  27787. e.scene.publish.settings.web.hint === void 0 && (e.scene.publish.settings.web.hint = !1);
  27788. }
  27789. function OU(e) {
  27790. let { video: t } = e.scene.publish.settings;
  27791. t.format === 'gif' && t.fps > 48 && (t.fps = 15);
  27792. }
  27793. function IU(e) {
  27794. e.scene.objects.traverse((t, i) => {
  27795. i.events.forEach((r) => {
  27796. r.type === 'GameControl' && (r.resetYPosition = Math.abs(r.resetYPosition - i.position[1]));
  27797. });
  27798. });
  27799. }
  27800. var K1 = 36;
  27801. function RU(e) {
  27802. let t = e.schema ?? 0;
  27803. t !== K1 &&
  27804. (console.warn('updating from ', t, 'to ', K1),
  27805. t < 1 && (nd(e, W1), sd(e, W1), (e.schema = 1)),
  27806. t < 2 && (sU(e), (e.schema = 2)),
  27807. t < 3 && (aU(e), (e.schema = 3)),
  27808. t < 4 && (oU(e), (e.schema = 4)),
  27809. t < 5 && (lU(e), (e.schema = 5)),
  27810. t < 6 && (hU(e), (e.schema = 6)),
  27811. t < 7 && (cU(e), (e.schema = 7)),
  27812. t < 8 && (e.schema = 8),
  27813. t < 9 && (q1(e), (e.schema = 9)),
  27814. t < 10 && (fU(e), (e.schema = 10)),
  27815. t < 11 && (mU(e), (e.schema = 11)),
  27816. t < 12 && (q1(e), (e.schema = 12)),
  27817. t < 13 && (gU(e), (e.schema = 13)),
  27818. t < 14 && (yU(e), (e.schema = 14)),
  27819. t < 15 && (xU(e), (e.schema = 15)),
  27820. t < 16 && (bU(e), (e.schema = 16)),
  27821. t < 17 && (nd(e, Y1), sd(e, Y1), (e.schema = 17)),
  27822. t < 18 && (nd(e, X1), sd(e, X1), (e.schema = 18)),
  27823. t < 19 && (nU(e), (e.schema = 19)),
  27824. t < 20 && (wU(e), AU(e), (e.schema = 20)),
  27825. t < 21 && (SU(e), MU(e), (e.schema = 21)),
  27826. t < 22 && (Z1(e), (e.schema = 22)),
  27827. t < 23 && (EU(e), (e.schema = 23)),
  27828. t < 24 && (CU(e), (e.schema = 24)),
  27829. (t < 25 || e.shared.videos === void 0) && (vU(e), t < 25 && (e.schema = 25)),
  27830. t < 26 && (dU(e), (e.schema = 26)),
  27831. t < 27 && (uU(e), (e.schema = 27)),
  27832. t < 28 && (Z1(e), (e.schema = 28)),
  27833. t < 29 && (pU(e), (e.schema = 29)),
  27834. t < 30 && (TU(e), (e.schema = 30)),
  27835. t < 31 && (PU(e), (e.schema = 31)),
  27836. t < 33 && (DU(e), (e.schema = 33)),
  27837. t < 34 && (LU(e), (e.schema = 34)),
  27838. t < 35 && (OU(e), (e.schema = 35)),
  27839. t < 36 && (IU(e), (e.schema = 36)));
  27840. }
  27841. function go(e, t = !1) {
  27842. let i = e[0].index !== null,
  27843. r = new Set(Object.keys(e[0].attributes)),
  27844. s = new Set(Object.keys(e[0].morphAttributes)),
  27845. n = {},
  27846. a = {},
  27847. o = e[0].morphTargetsRelative,
  27848. l = new Ve(),
  27849. h = 0;
  27850. for (let u = 0; u < e.length; ++u) {
  27851. let c = e[u],
  27852. d = 0;
  27853. if (i !== (c.index !== null))
  27854. return (
  27855. console.error(
  27856. 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' +
  27857. u +
  27858. '. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.'
  27859. ),
  27860. null
  27861. );
  27862. for (let p in c.attributes) {
  27863. if (!r.has(p))
  27864. return (
  27865. console.error(
  27866. 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' +
  27867. u +
  27868. '. All geometries must have compatible attributes; make sure "' +
  27869. p +
  27870. '" attribute exists among all geometries, or in none of them.'
  27871. ),
  27872. null
  27873. );
  27874. n[p] === void 0 && (n[p] = []), n[p].push(c.attributes[p]), d++;
  27875. }
  27876. if (d !== r.size)
  27877. return (
  27878. console.error(
  27879. 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' +
  27880. u +
  27881. '. Make sure all geometries have the same number of attributes.'
  27882. ),
  27883. null
  27884. );
  27885. if (o !== c.morphTargetsRelative)
  27886. return (
  27887. console.error(
  27888. 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' +
  27889. u +
  27890. '. .morphTargetsRelative must be consistent throughout all geometries.'
  27891. ),
  27892. null
  27893. );
  27894. for (let p in c.morphAttributes) {
  27895. if (!s.has(p))
  27896. return (
  27897. console.error(
  27898. 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' +
  27899. u +
  27900. '. .morphAttributes must be consistent throughout all geometries.'
  27901. ),
  27902. null
  27903. );
  27904. a[p] === void 0 && (a[p] = []), a[p].push(c.morphAttributes[p]);
  27905. }
  27906. if (t) {
  27907. let p;
  27908. if (i) p = c.index.count;
  27909. else if (c.attributes.position !== void 0) p = c.attributes.position.count;
  27910. else
  27911. return (
  27912. console.error(
  27913. 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' +
  27914. u +
  27915. '. The geometry must have either an index or a position attribute'
  27916. ),
  27917. null
  27918. );
  27919. l.addGroup(h, p, u), (h += p);
  27920. }
  27921. }
  27922. if (i) {
  27923. let u = 0,
  27924. c = [];
  27925. for (let d = 0; d < e.length; ++d) {
  27926. let p = e[d].index;
  27927. for (let f = 0; f < p.count; ++f) c.push(p.getX(f) + u);
  27928. u += e[d].attributes.position.count;
  27929. }
  27930. l.setIndex(c);
  27931. }
  27932. for (let u in n) {
  27933. let c = J1(n[u]);
  27934. if (!c)
  27935. return (
  27936. console.error('THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + u + ' attribute.'), null
  27937. );
  27938. l.setAttribute(u, c);
  27939. }
  27940. for (let u in a) {
  27941. let c = a[u][0].length;
  27942. if (c === 0) break;
  27943. (l.morphAttributes = l.morphAttributes || {}), (l.morphAttributes[u] = []);
  27944. for (let d = 0; d < c; ++d) {
  27945. let p = [];
  27946. for (let g = 0; g < a[u].length; ++g) p.push(a[u][g][d]);
  27947. let f = J1(p);
  27948. if (!f)
  27949. return (
  27950. console.error('THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + u + ' morphAttribute.'),
  27951. null
  27952. );
  27953. l.morphAttributes[u].push(f);
  27954. }
  27955. }
  27956. return l;
  27957. }
  27958. function J1(e) {
  27959. let t,
  27960. i,
  27961. r,
  27962. s = 0;
  27963. for (let o = 0; o < e.length; ++o) {
  27964. let l = e[o];
  27965. if (l.isInterleavedBufferAttribute)
  27966. return (
  27967. console.error('THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported.'), null
  27968. );
  27969. if ((t === void 0 && (t = l.array.constructor), t !== l.array.constructor))
  27970. return (
  27971. console.error(
  27972. 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.'
  27973. ),
  27974. null
  27975. );
  27976. if ((i === void 0 && (i = l.itemSize), i !== l.itemSize))
  27977. return (
  27978. console.error(
  27979. 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.'
  27980. ),
  27981. null
  27982. );
  27983. if ((r === void 0 && (r = l.normalized), r !== l.normalized))
  27984. return (
  27985. console.error(
  27986. 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.'
  27987. ),
  27988. null
  27989. );
  27990. s += l.array.length;
  27991. }
  27992. let n = new t(s),
  27993. a = 0;
  27994. for (let o = 0; o < e.length; ++o) n.set(e[o].array, a), (a += e[o].array.length);
  27995. return new Xe(n, i, r);
  27996. }
  27997. var Cm;
  27998. ((e) => (
  27999. (e.defaultColliderData = { type: 'capsule', height: 200, radius: 50, position: [0, 0, 0], rotation: [0, 0, 0] }),
  28000. (e.defaultDataThirdPerson = {
  28001. moveMode: 'walk',
  28002. speedTranslate: 1e3,
  28003. speedRotate: 100,
  28004. rotationMode: 'normal',
  28005. rotBy: 'keys',
  28006. rotByTouch: 'drag',
  28007. delayPos: [0.3, 0.3],
  28008. delayRot: [0.3, 0.3],
  28009. keyAssignments: [
  28010. ['moveNegZ', 'W'],
  28011. ['moveNegX', 'A'],
  28012. ['movePosZ', 'S'],
  28013. ['movePosX', 'D'],
  28014. ['rotPosX', '▲'],
  28015. ['rotPosY', '◀'],
  28016. ['rotNegX', '▼'],
  28017. ['rotNegY', '▶'],
  28018. ['jump', 'Space']
  28019. ],
  28020. touchControl: !0,
  28021. joystickPosLoc: 5,
  28022. joystickRotLoc: 11,
  28023. jumpTouchButtonLoc: 9,
  28024. collider: e.defaultColliderData,
  28025. colliderHelperVisible: !0,
  28026. collisionEnabled: !0,
  28027. jumpPower: 100,
  28028. resetYPosition: 3e3,
  28029. alignToGround: !1,
  28030. autoOrientMove: !0,
  28031. orientWith: 'camera',
  28032. orientMode: 'radial',
  28033. delayPosCamera: 0.3,
  28034. delayRotCamera: 0.3,
  28035. camera: '',
  28036. cameraXAxis: 'Limit',
  28037. cameraYAxis: 'Free',
  28038. cameraRotXLimits: [0, Math.PI / 2],
  28039. cameraRotYLimits: [-Math.PI / 2, Math.PI / 2],
  28040. gameActions: { idle: new rt(), move: new rt(), jump: new rt() }
  28041. })
  28042. ))(Cm || (Cm = {}));
  28043. var BU = Math.pow(2, -24),
  28044. Sc = class {
  28045. constructor() {}
  28046. };
  28047. function ls(e, t, i) {
  28048. 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;
  28049. }
  28050. function $1(e) {
  28051. let t = -1,
  28052. i = -1 / 0;
  28053. for (let r = 0; r < 3; r++) {
  28054. let s = e[r + 3] - e[r];
  28055. s > i && ((i = s), (t = r));
  28056. }
  28057. return t;
  28058. }
  28059. function ex(e, t) {
  28060. t.set(e);
  28061. }
  28062. function tx(e, t, i) {
  28063. let r, s;
  28064. for (let n = 0; n < 3; n++) {
  28065. let a = n + 3;
  28066. (r = e[n]), (s = t[n]), (i[n] = r < s ? r : s), (r = e[a]), (s = t[a]), (i[a] = r > s ? r : s);
  28067. }
  28068. }
  28069. function Mc(e, t, i) {
  28070. for (let r = 0; r < 3; r++) {
  28071. let s = t[e + 2 * r],
  28072. n = t[e + 2 * r + 1],
  28073. a = s - n,
  28074. o = s + n;
  28075. a < i[r] && (i[r] = a), o > i[r + 3] && (i[r + 3] = o);
  28076. }
  28077. }
  28078. function Al(e) {
  28079. let t = e[3] - e[0],
  28080. i = e[4] - e[1],
  28081. r = e[5] - e[2];
  28082. return 2 * (t * i + i * r + r * t);
  28083. }
  28084. function zU(e, t) {
  28085. if (!e.index) {
  28086. let i = e.attributes.position.count,
  28087. r = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer,
  28088. s;
  28089. i > 65535 ? (s = new Uint32Array(new r(4 * i))) : (s = new Uint16Array(new r(2 * i))), e.setIndex(new Xe(s, 1));
  28090. for (let n = 0; n < i; n++) s[n] = n;
  28091. }
  28092. }
  28093. function NU(e) {
  28094. if (!e.groups || !e.groups.length) return [{ offset: 0, count: e.index.count / 3 }];
  28095. let t = [],
  28096. i = new Set();
  28097. for (let s of e.groups) i.add(s.start), i.add(s.start + s.count);
  28098. let r = Array.from(i.values()).sort((s, n) => s - n);
  28099. for (let s = 0; s < r.length - 1; s++) {
  28100. let n = r[s],
  28101. a = r[s + 1];
  28102. t.push({ offset: n / 3, count: (a - n) / 3 });
  28103. }
  28104. return t;
  28105. }
  28106. function Fp(e, t, i, r, s = null) {
  28107. let n = 1 / 0,
  28108. a = 1 / 0,
  28109. o = 1 / 0,
  28110. l = -1 / 0,
  28111. h = -1 / 0,
  28112. u = -1 / 0,
  28113. c = 1 / 0,
  28114. d = 1 / 0,
  28115. p = 1 / 0,
  28116. f = -1 / 0,
  28117. g = -1 / 0,
  28118. m = -1 / 0,
  28119. v = s !== null;
  28120. for (let y = t * 6, b = (t + i) * 6; y < b; y += 6) {
  28121. let x = e[y + 0],
  28122. w = e[y + 1],
  28123. A = x - w,
  28124. S = x + w;
  28125. A < n && (n = A), S > l && (l = S), v && x < c && (c = x), v && x > f && (f = x);
  28126. let _ = e[y + 2],
  28127. M = e[y + 3],
  28128. C = _ - M,
  28129. T = _ + M;
  28130. C < a && (a = C), T > h && (h = T), v && _ < d && (d = _), v && _ > g && (g = _);
  28131. let P = e[y + 4],
  28132. L = e[y + 5],
  28133. D = P - L,
  28134. k = P + L;
  28135. D < o && (o = D), k > u && (u = k), v && P < p && (p = P), v && P > m && (m = P);
  28136. }
  28137. (r[0] = n),
  28138. (r[1] = a),
  28139. (r[2] = o),
  28140. (r[3] = l),
  28141. (r[4] = h),
  28142. (r[5] = u),
  28143. v && ((s[0] = c), (s[1] = d), (s[2] = p), (s[3] = f), (s[4] = g), (s[5] = m));
  28144. }
  28145. function UU(e, t, i, r) {
  28146. let s = 1 / 0,
  28147. n = 1 / 0,
  28148. a = 1 / 0,
  28149. o = -1 / 0,
  28150. l = -1 / 0,
  28151. h = -1 / 0;
  28152. for (let u = t * 6, c = (t + i) * 6; u < c; u += 6) {
  28153. let d = e[u + 0];
  28154. d < s && (s = d), d > o && (o = d);
  28155. let p = e[u + 2];
  28156. p < n && (n = p), p > l && (l = p);
  28157. let f = e[u + 4];
  28158. f < a && (a = f), f > h && (h = f);
  28159. }
  28160. (r[0] = s), (r[1] = n), (r[2] = a), (r[3] = o), (r[4] = l), (r[5] = h);
  28161. }
  28162. function FU(e, t, i, r, s) {
  28163. let n = i,
  28164. a = i + r - 1,
  28165. o = s.pos,
  28166. l = s.axis * 2;
  28167. for (;;) {
  28168. for (; n <= a && t[n * 6 + l] < o; ) n++;
  28169. for (; n <= a && t[a * 6 + l] >= o; ) a--;
  28170. if (n < a) {
  28171. for (let h = 0; h < 3; h++) {
  28172. let u = e[n * 3 + h];
  28173. (e[n * 3 + h] = e[a * 3 + h]), (e[a * 3 + h] = u);
  28174. let c = t[n * 6 + h * 2 + 0];
  28175. (t[n * 6 + h * 2 + 0] = t[a * 6 + h * 2 + 0]), (t[a * 6 + h * 2 + 0] = c);
  28176. let d = t[n * 6 + h * 2 + 1];
  28177. (t[n * 6 + h * 2 + 1] = t[a * 6 + h * 2 + 1]), (t[a * 6 + h * 2 + 1] = d);
  28178. }
  28179. n++, a--;
  28180. } else return n;
  28181. }
  28182. }
  28183. var Us = 32,
  28184. kU = (e, t) => e.candidate - t.candidate,
  28185. rn = new Array(Us)
  28186. .fill()
  28187. .map(() => ({
  28188. count: 0,
  28189. bounds: new Float32Array(6),
  28190. rightCacheBounds: new Float32Array(6),
  28191. leftCacheBounds: new Float32Array(6),
  28192. candidate: 0
  28193. })),
  28194. Ec = new Float32Array(6);
  28195. function jU(e, t, i, r, s, n) {
  28196. let a = -1,
  28197. o = 0;
  28198. if (n === 0) (a = $1(t)), a !== -1 && (o = (t[a] + t[a + 3]) / 2);
  28199. else if (n === 1) (a = $1(e)), a !== -1 && (o = GU(i, r, s, a));
  28200. else if (n === 2) {
  28201. let l = Al(e),
  28202. h = 1.25 * s,
  28203. u = r * 6,
  28204. c = (r + s) * 6;
  28205. for (let d = 0; d < 3; d++) {
  28206. let p = t[d],
  28207. f = (t[d + 3] - p) / Us;
  28208. if (s < Us / 4) {
  28209. let g = [...rn];
  28210. g.length = s;
  28211. let m = 0;
  28212. for (let y = u; y < c; y += 6, m++) {
  28213. let b = g[m];
  28214. (b.candidate = i[y + 2 * d]), (b.count = 0);
  28215. let { bounds: x, leftCacheBounds: w, rightCacheBounds: A } = b;
  28216. for (let S = 0; S < 3; S++)
  28217. (A[S] = 1 / 0), (A[S + 3] = -1 / 0), (w[S] = 1 / 0), (w[S + 3] = -1 / 0), (x[S] = 1 / 0), (x[S + 3] = -1 / 0);
  28218. Mc(y, i, x);
  28219. }
  28220. g.sort(kU);
  28221. let v = s;
  28222. for (let y = 0; y < v; y++) {
  28223. let b = g[y];
  28224. for (; y + 1 < v && g[y + 1].candidate === b.candidate; ) g.splice(y + 1, 1), v--;
  28225. }
  28226. for (let y = u; y < c; y += 6) {
  28227. let b = i[y + 2 * d];
  28228. for (let x = 0; x < v; x++) {
  28229. let w = g[x];
  28230. b >= w.candidate ? Mc(y, i, w.rightCacheBounds) : (Mc(y, i, w.leftCacheBounds), w.count++);
  28231. }
  28232. }
  28233. for (let y = 0; y < v; y++) {
  28234. let b = g[y],
  28235. x = b.count,
  28236. w = s - b.count,
  28237. A = b.leftCacheBounds,
  28238. S = b.rightCacheBounds,
  28239. _ = 0;
  28240. x !== 0 && (_ = Al(A) / l);
  28241. let M = 0;
  28242. w !== 0 && (M = Al(S) / l);
  28243. let C = 1 + 1.25 * (_ * x + M * w);
  28244. C < h && ((a = d), (h = C), (o = b.candidate));
  28245. }
  28246. } else {
  28247. for (let v = 0; v < Us; v++) {
  28248. let y = rn[v];
  28249. (y.count = 0), (y.candidate = p + f + v * f);
  28250. let b = y.bounds;
  28251. for (let x = 0; x < 3; x++) (b[x] = 1 / 0), (b[x + 3] = -1 / 0);
  28252. }
  28253. for (let v = u; v < c; v += 6) {
  28254. let y = ~~((i[v + 2 * d] - p) / f);
  28255. y >= Us && (y = Us - 1);
  28256. let b = rn[y];
  28257. b.count++, Mc(v, i, b.bounds);
  28258. }
  28259. let g = rn[Us - 1];
  28260. ex(g.bounds, g.rightCacheBounds);
  28261. for (let v = Us - 2; v >= 0; v--) {
  28262. let y = rn[v],
  28263. b = rn[v + 1];
  28264. tx(y.bounds, b.rightCacheBounds, y.rightCacheBounds);
  28265. }
  28266. let m = 0;
  28267. for (let v = 0; v < Us - 1; v++) {
  28268. let y = rn[v],
  28269. b = y.count,
  28270. x = y.bounds,
  28271. w = rn[v + 1].rightCacheBounds;
  28272. b !== 0 && (m === 0 ? ex(x, Ec) : tx(x, Ec, Ec)), (m += b);
  28273. let A = 0,
  28274. S = 0;
  28275. m !== 0 && (A = Al(Ec) / l);
  28276. let _ = s - m;
  28277. _ !== 0 && (S = Al(w) / l);
  28278. let M = 1 + 1.25 * (A * m + S * _);
  28279. M < h && ((a = d), (h = M), (o = y.candidate));
  28280. }
  28281. }
  28282. }
  28283. } else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);
  28284. return { axis: a, pos: o };
  28285. }
  28286. function GU(e, t, i, r) {
  28287. let s = 0;
  28288. for (let n = t, a = t + i; n < a; n++) s += e[n * 6 + r * 2];
  28289. return s / i;
  28290. }
  28291. function VU(e, t) {
  28292. let i = e.attributes.position,
  28293. r = i.array,
  28294. s = e.index.array,
  28295. n = s.length / 3,
  28296. a = new Float32Array(n * 6),
  28297. o = i.offset || 0,
  28298. l = 3;
  28299. i.isInterleavedBufferAttribute && (l = i.data.stride);
  28300. for (let h = 0; h < n; h++) {
  28301. let u = h * 3,
  28302. c = h * 6,
  28303. d = s[u + 0] * l + o,
  28304. p = s[u + 1] * l + o,
  28305. f = s[u + 2] * l + o;
  28306. for (let g = 0; g < 3; g++) {
  28307. let m = r[d + g],
  28308. v = r[p + g],
  28309. y = r[f + g],
  28310. b = m;
  28311. v < b && (b = v), y < b && (b = y);
  28312. let x = m;
  28313. v > x && (x = v), y > x && (x = y);
  28314. let w = (x - b) / 2,
  28315. A = g * 2;
  28316. (a[c + A + 0] = b + w), (a[c + A + 1] = w + (Math.abs(b) + w) * BU), b < t[g] && (t[g] = b), x > t[g + 3] && (t[g + 3] = x);
  28317. }
  28318. }
  28319. return a;
  28320. }
  28321. function HU(e, t) {
  28322. function i(v) {
  28323. d && d(v / p);
  28324. }
  28325. function r(v, y, b, x = null, w = 0) {
  28326. if (
  28327. (!f &&
  28328. w >= l &&
  28329. ((f = !0),
  28330. h && (console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`), console.warn(e))),
  28331. b <= u || w >= l)
  28332. )
  28333. return i(y + b), (v.offset = y), (v.count = b), v;
  28334. let A = jU(v.boundingData, x, a, y, b, c);
  28335. if (A.axis === -1) return i(y + b), (v.offset = y), (v.count = b), v;
  28336. let S = FU(o, a, y, b, A);
  28337. if (S === y || S === y + b) i(y + b), (v.offset = y), (v.count = b);
  28338. else {
  28339. v.splitAxis = A.axis;
  28340. let _ = new Sc(),
  28341. M = y,
  28342. C = S - y;
  28343. (v.left = _), (_.boundingData = new Float32Array(6)), Fp(a, M, C, _.boundingData, n), r(_, M, C, n, w + 1);
  28344. let T = new Sc(),
  28345. P = S,
  28346. L = b - C;
  28347. (v.right = T), (T.boundingData = new Float32Array(6)), Fp(a, P, L, T.boundingData, n), r(T, P, L, n, w + 1);
  28348. }
  28349. return v;
  28350. }
  28351. zU(e, t);
  28352. let s = new Float32Array(6),
  28353. n = new Float32Array(6),
  28354. a = VU(e, s),
  28355. o = e.index.array,
  28356. l = t.maxDepth,
  28357. h = t.verbose,
  28358. u = t.maxLeafTris,
  28359. c = t.strategy,
  28360. d = t.onProgress,
  28361. p = e.index.count / 3,
  28362. f = !1,
  28363. g = [],
  28364. m = NU(e);
  28365. if (m.length === 1) {
  28366. let v = m[0],
  28367. y = new Sc();
  28368. (y.boundingData = s), UU(a, v.offset, v.count, n), r(y, v.offset, v.count, n), g.push(y);
  28369. } else
  28370. for (let v of m) {
  28371. let y = new Sc();
  28372. (y.boundingData = new Float32Array(6)), Fp(a, v.offset, v.count, y.boundingData, n), r(y, v.offset, v.count, n), g.push(y);
  28373. }
  28374. return g;
  28375. }
  28376. function WU(e, t) {
  28377. let i = HU(e, t),
  28378. r,
  28379. s,
  28380. n,
  28381. a = [],
  28382. o = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer;
  28383. for (let u = 0; u < i.length; u++) {
  28384. let c = i[u],
  28385. d = l(c),
  28386. p = new o(32 * d);
  28387. (r = new Float32Array(p)), (s = new Uint32Array(p)), (n = new Uint16Array(p)), h(0, c), a.push(p);
  28388. }
  28389. return a;
  28390. function l(u) {
  28391. return u.count ? 1 : 1 + l(u.left) + l(u.right);
  28392. }
  28393. function h(u, c) {
  28394. let d = u / 4,
  28395. p = u / 2,
  28396. f = !!c.count,
  28397. g = c.boundingData;
  28398. for (let m = 0; m < 6; m++) r[d + m] = g[m];
  28399. if (f) {
  28400. let m = c.offset,
  28401. v = c.count;
  28402. return (s[d + 6] = m), (n[p + 14] = v), (n[p + 15] = 65535), u + 32;
  28403. } else {
  28404. let m = c.left,
  28405. v = c.right,
  28406. y = c.splitAxis,
  28407. b;
  28408. if (((b = h(u + 32, m)), b / 4 > Math.pow(2, 32))) throw new Error('MeshBVH: Cannot store child pointer greater than 32 bits.');
  28409. return (s[d + 6] = b / 4), (b = h(b, v)), (s[d + 7] = y), b;
  28410. }
  28411. }
  28412. }
  28413. var bs = class {
  28414. constructor() {
  28415. (this.min = 1 / 0), (this.max = -1 / 0);
  28416. }
  28417. setFromPointsField(e, t) {
  28418. let i = 1 / 0,
  28419. r = -1 / 0;
  28420. for (let s = 0, n = e.length; s < n; s++) {
  28421. let a = e[s][t];
  28422. (i = a < i ? a : i), (r = a > r ? a : r);
  28423. }
  28424. (this.min = i), (this.max = r);
  28425. }
  28426. setFromPoints(e, t) {
  28427. let i = 1 / 0,
  28428. r = -1 / 0;
  28429. for (let s = 0, n = t.length; s < n; s++) {
  28430. let a = t[s],
  28431. o = e.dot(a);
  28432. (i = o < i ? o : i), (r = o > r ? o : r);
  28433. }
  28434. (this.min = i), (this.max = r);
  28435. }
  28436. isSeparated(e) {
  28437. return this.min > e.max || e.min > this.max;
  28438. }
  28439. };
  28440. bs.prototype.setFromBox = (function () {
  28441. let e = new E();
  28442. return function (t, i) {
  28443. let r = i.min,
  28444. s = i.max,
  28445. n = 1 / 0,
  28446. a = -1 / 0;
  28447. for (let o = 0; o <= 1; o++)
  28448. for (let l = 0; l <= 1; l++)
  28449. for (let h = 0; h <= 1; h++) {
  28450. (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));
  28451. let u = t.dot(e);
  28452. (n = Math.min(u, n)), (a = Math.max(u, a));
  28453. }
  28454. (this.min = n), (this.max = a);
  28455. };
  28456. })();
  28457. var M9 = (function () {
  28458. let e = new bs();
  28459. return function (t, i) {
  28460. let r = t.points,
  28461. s = t.satAxes,
  28462. n = t.satBounds,
  28463. a = i.points,
  28464. o = i.satAxes,
  28465. l = i.satBounds;
  28466. for (let h = 0; h < 3; h++) {
  28467. let u = n[h],
  28468. c = s[h];
  28469. if ((e.setFromPoints(c, a), u.isSeparated(e))) return !1;
  28470. }
  28471. for (let h = 0; h < 3; h++) {
  28472. let u = l[h],
  28473. c = o[h];
  28474. if ((e.setFromPoints(c, r), u.isSeparated(e))) return !1;
  28475. }
  28476. };
  28477. })(),
  28478. XU = (function () {
  28479. let e = new E(),
  28480. t = new E(),
  28481. i = new E();
  28482. return function (r, s, n) {
  28483. let a = r.start,
  28484. o = e,
  28485. l = s.start,
  28486. h = t;
  28487. i.subVectors(a, l), e.subVectors(r.end, s.start), t.subVectors(s.end, s.start);
  28488. let u = i.dot(h),
  28489. c = h.dot(o),
  28490. d = h.dot(h),
  28491. p = i.dot(o),
  28492. f = o.dot(o) * d - c * c,
  28493. g,
  28494. m;
  28495. f !== 0 ? (g = (u * c - p * d) / f) : (g = 0), (m = (u + g * c) / d), (n.x = g), (n.y = m);
  28496. };
  28497. })(),
  28498. Jg = (function () {
  28499. let e = new G(),
  28500. t = new E(),
  28501. i = new E();
  28502. return function (r, s, n, a) {
  28503. XU(r, s, e);
  28504. let o = e.x,
  28505. l = e.y;
  28506. if (o >= 0 && o <= 1 && l >= 0 && l <= 1) {
  28507. r.at(o, n), s.at(l, a);
  28508. return;
  28509. } else if (o >= 0 && o <= 1) {
  28510. l < 0 ? s.at(0, a) : s.at(1, a), r.closestPointToPoint(a, !0, n);
  28511. return;
  28512. } else if (l >= 0 && l <= 1) {
  28513. o < 0 ? r.at(0, n) : r.at(1, n), s.closestPointToPoint(n, !0, a);
  28514. return;
  28515. } else {
  28516. let h;
  28517. o < 0 ? (h = r.start) : (h = r.end);
  28518. let u;
  28519. l < 0 ? (u = s.start) : (u = s.end);
  28520. let c = t,
  28521. d = i;
  28522. if ((r.closestPointToPoint(u, !0, t), s.closestPointToPoint(h, !0, i), c.distanceToSquared(u) <= d.distanceToSquared(h))) {
  28523. n.copy(c), a.copy(u);
  28524. return;
  28525. } else {
  28526. n.copy(h), a.copy(d);
  28527. return;
  28528. }
  28529. }
  28530. };
  28531. })(),
  28532. qU = (function () {
  28533. let e = new E(),
  28534. t = new E(),
  28535. i = new yr(),
  28536. r = new _r();
  28537. return function (s, n) {
  28538. let { radius: a, center: o } = s,
  28539. { a: l, b: h, c: u } = n;
  28540. if (
  28541. ((r.start = l),
  28542. (r.end = h),
  28543. r.closestPointToPoint(o, !0, e).distanceTo(o) <= a ||
  28544. ((r.start = l), (r.end = u), r.closestPointToPoint(o, !0, e).distanceTo(o) <= a) ||
  28545. ((r.start = h), (r.end = u), r.closestPointToPoint(o, !0, e).distanceTo(o) <= a))
  28546. )
  28547. return !0;
  28548. let c = n.getPlane(i);
  28549. if (Math.abs(c.distanceToPoint(o)) <= a) {
  28550. let d = c.projectPoint(o, t);
  28551. if (n.containsPoint(d)) return !0;
  28552. }
  28553. return !1;
  28554. };
  28555. })(),
  28556. YU = 1e-15;
  28557. function Qa(e) {
  28558. return Math.abs(e) < YU;
  28559. }
  28560. var Xs = class extends Bi {
  28561. constructor(...e) {
  28562. super(...e),
  28563. (this.isExtendedTriangle = !0),
  28564. (this.satAxes = new Array(4).fill().map(() => new E())),
  28565. (this.satBounds = new Array(4).fill().map(() => new bs())),
  28566. (this.points = [this.a, this.b, this.c]),
  28567. (this.sphere = new Mr()),
  28568. (this.plane = new yr()),
  28569. (this.needsUpdate = !0);
  28570. }
  28571. intersectsSphere(e) {
  28572. return qU(e, this);
  28573. }
  28574. update() {
  28575. let e = this.a,
  28576. t = this.b,
  28577. i = this.c,
  28578. r = this.points,
  28579. s = this.satAxes,
  28580. n = this.satBounds,
  28581. a = s[0],
  28582. o = n[0];
  28583. this.getNormal(a), o.setFromPoints(a, r);
  28584. let l = s[1],
  28585. h = n[1];
  28586. l.subVectors(e, t), h.setFromPoints(l, r);
  28587. let u = s[2],
  28588. c = n[2];
  28589. u.subVectors(t, i), c.setFromPoints(u, r);
  28590. let d = s[3],
  28591. p = n[3];
  28592. d.subVectors(i, e),
  28593. p.setFromPoints(d, r),
  28594. this.sphere.setFromPoints(this.points),
  28595. this.plane.setFromNormalAndCoplanarPoint(a, e),
  28596. (this.needsUpdate = !1);
  28597. }
  28598. };
  28599. Xs.prototype.closestPointToSegment = (function () {
  28600. let e = new E(),
  28601. t = new E(),
  28602. i = new _r();
  28603. return function (r, s = null, n = null) {
  28604. let { start: a, end: o } = r,
  28605. l = this.points,
  28606. h,
  28607. u = 1 / 0;
  28608. for (let c = 0; c < 3; c++) {
  28609. let d = (c + 1) % 3;
  28610. i.start.copy(l[c]),
  28611. i.end.copy(l[d]),
  28612. Jg(i, r, e, t),
  28613. (h = e.distanceToSquared(t)),
  28614. h < u && ((u = h), s && s.copy(e), n && n.copy(t));
  28615. }
  28616. return (
  28617. this.closestPointToPoint(a, e),
  28618. (h = a.distanceToSquared(e)),
  28619. h < u && ((u = h), s && s.copy(e), n && n.copy(a)),
  28620. this.closestPointToPoint(o, e),
  28621. (h = o.distanceToSquared(e)),
  28622. h < u && ((u = h), s && s.copy(e), n && n.copy(o)),
  28623. Math.sqrt(u)
  28624. );
  28625. };
  28626. })();
  28627. Xs.prototype.intersectsTriangle = (function () {
  28628. let e = new Xs(),
  28629. t = new Array(3),
  28630. i = new Array(3),
  28631. r = new bs(),
  28632. s = new bs(),
  28633. n = new E(),
  28634. a = new E(),
  28635. o = new E(),
  28636. l = new E(),
  28637. h = new _r(),
  28638. u = new _r(),
  28639. c = new _r();
  28640. return function (d, p = null) {
  28641. this.needsUpdate && this.update(), d.isExtendedTriangle ? d.needsUpdate && d.update() : (e.copy(d), e.update(), (d = e));
  28642. let f = this.plane,
  28643. g = d.plane;
  28644. if (Math.abs(f.normal.dot(g.normal)) > 1 - 1e-10) {
  28645. let m = this.satBounds,
  28646. v = this.satAxes;
  28647. (i[0] = d.a), (i[1] = d.b), (i[2] = d.c);
  28648. for (let x = 0; x < 4; x++) {
  28649. let w = m[x],
  28650. A = v[x];
  28651. if ((r.setFromPoints(A, i), w.isSeparated(r))) return !1;
  28652. }
  28653. let y = d.satBounds,
  28654. b = d.satAxes;
  28655. (t[0] = this.a), (t[1] = this.b), (t[2] = this.c);
  28656. for (let x = 0; x < 4; x++) {
  28657. let w = y[x],
  28658. A = b[x];
  28659. if ((r.setFromPoints(A, t), w.isSeparated(r))) return !1;
  28660. }
  28661. for (let x = 0; x < 4; x++) {
  28662. let w = v[x];
  28663. for (let A = 0; A < 4; A++) {
  28664. let S = b[A];
  28665. if ((n.crossVectors(w, S), r.setFromPoints(n, t), s.setFromPoints(n, i), r.isSeparated(s))) return !1;
  28666. }
  28667. }
  28668. return (
  28669. p &&
  28670. (console.warn(
  28671. 'ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0.'
  28672. ),
  28673. p.start.set(0, 0, 0),
  28674. p.end.set(0, 0, 0)),
  28675. !0
  28676. );
  28677. } else {
  28678. let m = this.points,
  28679. v = !1,
  28680. y = 0;
  28681. for (let P = 0; P < 3; P++) {
  28682. let L = m[P],
  28683. D = m[(P + 1) % 3];
  28684. h.start.copy(L), h.end.copy(D), h.delta(a);
  28685. let k = v ? u.start : u.end,
  28686. W = Qa(g.distanceToPoint(L));
  28687. if (Qa(g.normal.dot(a)) && W) {
  28688. u.copy(h), (y = 2);
  28689. break;
  28690. }
  28691. if ((g.intersectLine(h, k) || W) && !Qa(k.distanceTo(D))) {
  28692. if ((y++, v)) break;
  28693. v = !0;
  28694. }
  28695. }
  28696. if (y === 1 && this.containsPoint(u.start)) return p && (p.start.copy(u.start), p.end.copy(u.start)), !0;
  28697. if (y !== 2) return !1;
  28698. let b = d.points,
  28699. x = !1,
  28700. w = 0;
  28701. for (let P = 0; P < 3; P++) {
  28702. let L = b[P],
  28703. D = b[(P + 1) % 3];
  28704. h.start.copy(L), h.end.copy(D), h.delta(o);
  28705. let k = x ? c.start : c.end,
  28706. W = Qa(f.distanceToPoint(L));
  28707. if (Qa(f.normal.dot(o)) && W) {
  28708. c.copy(h), (w = 2);
  28709. break;
  28710. }
  28711. if ((f.intersectLine(h, k) || W) && !Qa(k.distanceTo(D))) {
  28712. if ((w++, x)) break;
  28713. x = !0;
  28714. }
  28715. }
  28716. if (w === 1 && this.containsPoint(c.start)) return p && (p.start.copy(c.start), p.end.copy(c.start)), !0;
  28717. if (w !== 2) return !1;
  28718. if ((u.delta(a), c.delta(o), a.dot(o) < 0)) {
  28719. let P = c.start;
  28720. (c.start = c.end), (c.end = P);
  28721. }
  28722. let A = u.start.dot(a),
  28723. S = u.end.dot(a),
  28724. _ = c.start.dot(a),
  28725. M = c.end.dot(a),
  28726. C = S < _,
  28727. T = A < M;
  28728. return A !== M && _ !== S && C === T
  28729. ? !1
  28730. : (p &&
  28731. (l.subVectors(u.start, c.start),
  28732. l.dot(a) > 0 ? p.start.copy(u.start) : p.start.copy(c.start),
  28733. l.subVectors(u.end, c.end),
  28734. l.dot(a) < 0 ? p.end.copy(u.end) : p.end.copy(c.end)),
  28735. !0);
  28736. }
  28737. };
  28738. })();
  28739. Xs.prototype.distanceToPoint = (function () {
  28740. let e = new E();
  28741. return function (t) {
  28742. return this.closestPointToPoint(t, e), t.distanceTo(e);
  28743. };
  28744. })();
  28745. Xs.prototype.distanceToTriangle = (function () {
  28746. let e = new E(),
  28747. t = new E(),
  28748. i = ['a', 'b', 'c'],
  28749. r = new _r(),
  28750. s = new _r();
  28751. return function (n, a = null, o = null) {
  28752. let l = a || o ? r : null;
  28753. if (this.intersectsTriangle(n, l)) return (a || o) && (a && l.getCenter(a), o && l.getCenter(o)), 0;
  28754. let h = 1 / 0;
  28755. for (let u = 0; u < 3; u++) {
  28756. let c,
  28757. d = i[u],
  28758. p = n[d];
  28759. this.closestPointToPoint(p, e), (c = p.distanceToSquared(e)), c < h && ((h = c), a && a.copy(e), o && o.copy(p));
  28760. let f = this[d];
  28761. n.closestPointToPoint(f, e), (c = f.distanceToSquared(e)), c < h && ((h = c), a && a.copy(f), o && o.copy(e));
  28762. }
  28763. for (let u = 0; u < 3; u++) {
  28764. let c = i[u],
  28765. d = i[(u + 1) % 3];
  28766. r.set(this[c], this[d]);
  28767. for (let p = 0; p < 3; p++) {
  28768. let f = i[p],
  28769. g = i[(p + 1) % 3];
  28770. s.set(n[f], n[g]), Jg(r, s, e, t);
  28771. let m = e.distanceToSquared(t);
  28772. m < h && ((h = m), a && a.copy(e), o && o.copy(t));
  28773. }
  28774. }
  28775. return Math.sqrt(h);
  28776. };
  28777. })();
  28778. var ws = class extends Kt {
  28779. constructor(...e) {
  28780. super(...e),
  28781. (this.isOrientedBox = !0),
  28782. (this.matrix = new ve()),
  28783. (this.invMatrix = new ve()),
  28784. (this.points = new Array(8).fill().map(() => new E())),
  28785. (this.satAxes = new Array(3).fill().map(() => new E())),
  28786. (this.satBounds = new Array(3).fill().map(() => new bs())),
  28787. (this.alignedSatBounds = new Array(3).fill().map(() => new bs())),
  28788. (this.needsUpdate = !1);
  28789. }
  28790. set(e, t, i) {
  28791. super.set(e, t), this.matrix.copy(i), (this.needsUpdate = !0);
  28792. }
  28793. copy(e) {
  28794. super.copy(e), this.matrix.copy(e.matrix), (this.needsUpdate = !0);
  28795. }
  28796. };
  28797. ws.prototype.update = (function () {
  28798. return function () {
  28799. let e = this.matrix,
  28800. t = this.min,
  28801. i = this.max,
  28802. r = this.points;
  28803. for (let l = 0; l <= 1; l++)
  28804. for (let h = 0; h <= 1; h++)
  28805. for (let u = 0; u <= 1; u++) {
  28806. let c = (1 * l) | (2 * h) | (4 * u),
  28807. d = r[c];
  28808. (d.x = l ? i.x : t.x), (d.y = h ? i.y : t.y), (d.z = u ? i.z : t.z), d.applyMatrix4(e);
  28809. }
  28810. let s = this.satBounds,
  28811. n = this.satAxes,
  28812. a = r[0];
  28813. for (let l = 0; l < 3; l++) {
  28814. let h = n[l],
  28815. u = s[l],
  28816. c = 1 << l,
  28817. d = r[c];
  28818. h.subVectors(a, d), u.setFromPoints(h, r);
  28819. }
  28820. let o = this.alignedSatBounds;
  28821. o[0].setFromPointsField(r, 'x'),
  28822. o[1].setFromPointsField(r, 'y'),
  28823. o[2].setFromPointsField(r, 'z'),
  28824. this.invMatrix.copy(this.matrix).invert(),
  28825. (this.needsUpdate = !1);
  28826. };
  28827. })();
  28828. ws.prototype.intersectsBox = (function () {
  28829. let e = new bs();
  28830. return function (t) {
  28831. this.needsUpdate && this.update();
  28832. let i = t.min,
  28833. r = t.max,
  28834. s = this.satBounds,
  28835. n = this.satAxes,
  28836. a = this.alignedSatBounds;
  28837. if (
  28838. ((e.min = i.x),
  28839. (e.max = r.x),
  28840. a[0].isSeparated(e) || ((e.min = i.y), (e.max = r.y), a[1].isSeparated(e)) || ((e.min = i.z), (e.max = r.z), a[2].isSeparated(e)))
  28841. )
  28842. return !1;
  28843. for (let o = 0; o < 3; o++) {
  28844. let l = n[o],
  28845. h = s[o];
  28846. if ((e.setFromBox(l, t), h.isSeparated(e))) return !1;
  28847. }
  28848. return !0;
  28849. };
  28850. })();
  28851. ws.prototype.intersectsTriangle = (function () {
  28852. let e = new Xs(),
  28853. t = new Array(3),
  28854. i = new bs(),
  28855. r = new bs(),
  28856. s = new E();
  28857. return function (n) {
  28858. this.needsUpdate && this.update(), n.isExtendedTriangle ? n.needsUpdate && n.update() : (e.copy(n), e.update(), (n = e));
  28859. let a = this.satBounds,
  28860. o = this.satAxes;
  28861. (t[0] = n.a), (t[1] = n.b), (t[2] = n.c);
  28862. for (let c = 0; c < 3; c++) {
  28863. let d = a[c],
  28864. p = o[c];
  28865. if ((i.setFromPoints(p, t), d.isSeparated(i))) return !1;
  28866. }
  28867. let l = n.satBounds,
  28868. h = n.satAxes,
  28869. u = this.points;
  28870. for (let c = 0; c < 3; c++) {
  28871. let d = l[c],
  28872. p = h[c];
  28873. if ((i.setFromPoints(p, u), d.isSeparated(i))) return !1;
  28874. }
  28875. for (let c = 0; c < 3; c++) {
  28876. let d = o[c];
  28877. for (let p = 0; p < 4; p++) {
  28878. let f = h[p];
  28879. if ((s.crossVectors(d, f), i.setFromPoints(s, t), r.setFromPoints(s, u), i.isSeparated(r))) return !1;
  28880. }
  28881. }
  28882. return !0;
  28883. };
  28884. })();
  28885. ws.prototype.closestPointToPoint = (function () {
  28886. return function (e, t) {
  28887. return this.needsUpdate && this.update(), t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min, this.max).applyMatrix4(this.matrix), t;
  28888. };
  28889. })();
  28890. ws.prototype.distanceToPoint = (function () {
  28891. let e = new E();
  28892. return function (t) {
  28893. return this.closestPointToPoint(t, e), t.distanceTo(e);
  28894. };
  28895. })();
  28896. ws.prototype.distanceToBox = (function () {
  28897. let e = ['x', 'y', 'z'],
  28898. t = new Array(12).fill().map(() => new _r()),
  28899. i = new Array(12).fill().map(() => new _r()),
  28900. r = new E(),
  28901. s = new E();
  28902. return function (n, a = 0, o = null, l = null) {
  28903. if ((this.needsUpdate && this.update(), this.intersectsBox(n)))
  28904. return (o || l) && (n.getCenter(s), this.closestPointToPoint(s, r), n.closestPointToPoint(r, s), o && o.copy(r), l && l.copy(s)), 0;
  28905. let h = a * a,
  28906. u = n.min,
  28907. c = n.max,
  28908. d = this.points,
  28909. p = 1 / 0;
  28910. for (let g = 0; g < 8; g++) {
  28911. let m = d[g];
  28912. s.copy(m).clamp(u, c);
  28913. let v = m.distanceToSquared(s);
  28914. if (v < p && ((p = v), o && o.copy(m), l && l.copy(s), v < h)) return Math.sqrt(v);
  28915. }
  28916. let f = 0;
  28917. for (let g = 0; g < 3; g++)
  28918. for (let m = 0; m <= 1; m++)
  28919. for (let v = 0; v <= 1; v++) {
  28920. let y = (g + 1) % 3,
  28921. b = (g + 2) % 3,
  28922. x = (m << y) | (v << b),
  28923. w = (1 << g) | (m << y) | (v << b),
  28924. A = d[x],
  28925. S = d[w];
  28926. t[f].set(A, S);
  28927. let _ = e[g],
  28928. M = e[y],
  28929. C = e[b],
  28930. T = i[f],
  28931. P = T.start,
  28932. L = T.end;
  28933. (P[_] = u[_]),
  28934. (P[M] = m ? u[M] : c[M]),
  28935. (P[C] = v ? u[C] : c[M]),
  28936. (L[_] = c[_]),
  28937. (L[M] = m ? u[M] : c[M]),
  28938. (L[C] = v ? u[C] : c[M]),
  28939. f++;
  28940. }
  28941. for (let g = 0; g <= 1; g++)
  28942. for (let m = 0; m <= 1; m++)
  28943. for (let v = 0; v <= 1; v++) {
  28944. (s.x = g ? c.x : u.x), (s.y = m ? c.y : u.y), (s.z = v ? c.z : u.z), this.closestPointToPoint(s, r);
  28945. let y = s.distanceToSquared(r);
  28946. if (y < p && ((p = y), o && o.copy(r), l && l.copy(s), y < h)) return Math.sqrt(y);
  28947. }
  28948. for (let g = 0; g < 12; g++) {
  28949. let m = t[g];
  28950. for (let v = 0; v < 12; v++) {
  28951. let y = i[v];
  28952. Jg(m, y, r, s);
  28953. let b = r.distanceToSquared(s);
  28954. if (b < p && ((p = b), o && o.copy(r), l && l.copy(s), b < h)) return Math.sqrt(b);
  28955. }
  28956. }
  28957. return Math.sqrt(p);
  28958. };
  28959. })();
  28960. var Cc = new E(),
  28961. Tc = new E(),
  28962. Pc = new E(),
  28963. ix = new G(),
  28964. rx = new G(),
  28965. sx = new G(),
  28966. nx = new E();
  28967. function QU(e, t, i, r, s, n) {
  28968. let a;
  28969. return (
  28970. n === hi ? (a = e.intersectTriangle(r, i, t, !0, s)) : (a = e.intersectTriangle(t, i, r, n !== er, s)),
  28971. a === null ? null : { distance: e.origin.distanceTo(s), point: s.clone() }
  28972. );
  28973. }
  28974. function ZU(e, t, i, r, s, n, a) {
  28975. Cc.fromBufferAttribute(t, r), Tc.fromBufferAttribute(t, s), Pc.fromBufferAttribute(t, n);
  28976. let o = QU(e, Cc, Tc, Pc, nx, a);
  28977. if (o) {
  28978. i &&
  28979. (ix.fromBufferAttribute(i, r),
  28980. rx.fromBufferAttribute(i, s),
  28981. sx.fromBufferAttribute(i, n),
  28982. (o.uv = Bi.getUV(nx, Cc, Tc, Pc, ix, rx, sx, new G())));
  28983. let l = { a: r, b: s, c: n, normal: new E(), materialIndex: 0 };
  28984. Bi.getNormal(Cc, Tc, Pc, l.normal), (o.face = l), (o.faceIndex = r);
  28985. }
  28986. return o;
  28987. }
  28988. function nA(e, t, i, r, s) {
  28989. let n = r * 3,
  28990. a = e.index.getX(n),
  28991. o = e.index.getX(n + 1),
  28992. l = e.index.getX(n + 2),
  28993. h = ZU(i, e.attributes.position, e.attributes.uv, a, o, l, t);
  28994. return h ? ((h.faceIndex = r), s && s.push(h), h) : null;
  28995. }
  28996. function KU(e, t, i, r, s, n) {
  28997. for (let a = r, o = r + s; a < o; a++) nA(e, t, i, a, n);
  28998. }
  28999. function JU(e, t, i, r, s) {
  29000. let n = 1 / 0,
  29001. a = null;
  29002. for (let o = r, l = r + s; o < l; o++) {
  29003. let h = nA(e, t, i, o);
  29004. h && h.distance < n && ((a = h), (n = h.distance));
  29005. }
  29006. return a;
  29007. }
  29008. function aA(e, t, i) {
  29009. return e === null ||
  29010. (e.point.applyMatrix4(t.matrixWorld),
  29011. (e.distance = e.point.distanceTo(i.ray.origin)),
  29012. (e.object = t),
  29013. e.distance < i.near || e.distance > i.far)
  29014. ? null
  29015. : e;
  29016. }
  29017. function ns(e, t, i, r) {
  29018. let s = e.a,
  29019. n = e.b,
  29020. a = e.c,
  29021. o = t,
  29022. l = t + 1,
  29023. h = t + 2;
  29024. i && ((o = i.getX(t)), (l = i.getX(t + 1)), (h = i.getX(t + 2))),
  29025. (s.x = r.getX(o)),
  29026. (s.y = r.getY(o)),
  29027. (s.z = r.getZ(o)),
  29028. (n.x = r.getX(l)),
  29029. (n.y = r.getY(l)),
  29030. (n.z = r.getZ(l)),
  29031. (a.x = r.getX(h)),
  29032. (a.y = r.getY(h)),
  29033. (a.z = r.getZ(h));
  29034. }
  29035. function ax(e, t, i, r, s, n, a) {
  29036. let o = i.index,
  29037. l = i.attributes.position;
  29038. for (let h = e, u = t + e; h < u; h++) if ((ns(a, h * 3, o, l), (a.needsUpdate = !0), r(a, h, s, n))) return !0;
  29039. return !1;
  29040. }
  29041. var oA = class {
  29042. constructor(e) {
  29043. (this._getNewPrimitive = e), (this._primitives = []);
  29044. }
  29045. getPrimitive() {
  29046. let e = this._primitives;
  29047. return e.length === 0 ? this._getNewPrimitive() : e.pop();
  29048. }
  29049. releasePrimitive(e) {
  29050. this._primitives.push(e);
  29051. }
  29052. };
  29053. function fn(e, t) {
  29054. return t[e + 15] === 65535;
  29055. }
  29056. function Co(e, t) {
  29057. return t[e + 6];
  29058. }
  29059. function wh(e, t) {
  29060. return t[e + 14];
  29061. }
  29062. function _h(e) {
  29063. return e + 8;
  29064. }
  29065. function Ah(e, t) {
  29066. return t[e + 6];
  29067. }
  29068. function $U(e, t) {
  29069. return t[e + 7];
  29070. }
  29071. var vo = new Kt(),
  29072. Xd = new E(),
  29073. eF = ['x', 'y', 'z'];
  29074. function Tm(e, t, i, r, s) {
  29075. let n = e * 2,
  29076. a = il,
  29077. o = Cn,
  29078. l = Tn;
  29079. if (fn(n, o)) {
  29080. let h = Co(e, l),
  29081. u = wh(n, o);
  29082. KU(t, i, r, h, u, s);
  29083. } else {
  29084. let h = _h(e);
  29085. qd(h, a, r, Xd) && Tm(h, t, i, r, s);
  29086. let u = Ah(e, l);
  29087. qd(u, a, r, Xd) && Tm(u, t, i, r, s);
  29088. }
  29089. }
  29090. function Pm(e, t, i, r) {
  29091. let s = e * 2,
  29092. n = il,
  29093. a = Cn,
  29094. o = Tn;
  29095. if (fn(s, a)) {
  29096. let l = Co(e, o),
  29097. h = wh(s, a);
  29098. return JU(t, i, r, l, h);
  29099. } else {
  29100. let l = $U(e, o),
  29101. h = eF[l],
  29102. u = r.direction[h] >= 0,
  29103. c,
  29104. d;
  29105. u ? ((c = _h(e)), (d = Ah(e, o))) : ((c = Ah(e, o)), (d = _h(e)));
  29106. let p = qd(c, n, r, Xd) ? Pm(c, t, i, r) : null;
  29107. if (p) {
  29108. let g = p.point[h];
  29109. if (u ? g <= n[d + l] : g >= n[d + l + 3]) return p;
  29110. }
  29111. let f = qd(d, n, r, Xd) ? Pm(d, t, i, r) : null;
  29112. return p && f ? (p.distance <= f.distance ? p : f) : p || f || null;
  29113. }
  29114. }
  29115. var tF = (function () {
  29116. let e,
  29117. t,
  29118. i = [],
  29119. r = new oA(() => new Kt());
  29120. return function (...n) {
  29121. (e = r.getPrimitive()), (t = r.getPrimitive()), i.push(e, t);
  29122. let a = s(...n);
  29123. r.releasePrimitive(e), r.releasePrimitive(t), i.pop(), i.pop();
  29124. let o = i.length;
  29125. return o > 0 && ((t = i[o - 1]), (e = i[o - 2])), a;
  29126. };
  29127. function s(n, a, o, l, h = null, u = 0, c = 0) {
  29128. function d(y) {
  29129. let b = y * 2,
  29130. x = Cn,
  29131. w = Tn;
  29132. for (; !fn(b, x); ) (y = _h(y)), (b = y * 2);
  29133. return Co(y, w);
  29134. }
  29135. function p(y) {
  29136. let b = y * 2,
  29137. x = Cn,
  29138. w = Tn;
  29139. for (; !fn(b, x); ) (y = Ah(y, w)), (b = y * 2);
  29140. return Co(y, w) + wh(b, x);
  29141. }
  29142. let f = n * 2,
  29143. g = il,
  29144. m = Cn,
  29145. v = Tn;
  29146. if (fn(f, m)) {
  29147. let y = Co(n, v),
  29148. b = wh(f, m);
  29149. return ls(n, g, e), l(y, b, !1, c, u + n, e);
  29150. } else {
  29151. let y = _h(n),
  29152. b = Ah(n, v),
  29153. x = y,
  29154. w = b,
  29155. A,
  29156. S,
  29157. _,
  29158. M;
  29159. if (h && ((_ = e), (M = t), ls(x, g, _), ls(w, g, M), (A = h(_)), (S = h(M)), S < A)) {
  29160. (x = b), (w = y);
  29161. let W = A;
  29162. (A = S), (S = W), (_ = M);
  29163. }
  29164. _ || ((_ = e), ls(x, g, _));
  29165. let C = fn(x * 2, m),
  29166. T = o(_, C, A, c + 1, u + x),
  29167. P;
  29168. if (T === 2) {
  29169. let W = d(x),
  29170. X = p(x) - W;
  29171. P = l(W, X, !0, c + 1, u + x, _);
  29172. } else P = T && s(x, a, o, l, h, u, c + 1);
  29173. if (P) return !0;
  29174. (M = t), ls(w, g, M);
  29175. let L = fn(w * 2, m),
  29176. D = o(M, L, S, c + 1, u + w),
  29177. k;
  29178. if (D === 2) {
  29179. let W = d(w),
  29180. X = p(w) - W;
  29181. k = l(W, X, !0, c + 1, u + w, M);
  29182. } else k = D && s(w, a, o, l, h, u, c + 1);
  29183. return !!k;
  29184. }
  29185. }
  29186. })(),
  29187. iF = (function () {
  29188. let e = new Xs(),
  29189. t = new Xs(),
  29190. i = new ve(),
  29191. r = new ws(),
  29192. s = new ws();
  29193. return function n(a, o, l, h, u = null) {
  29194. let c = a * 2,
  29195. d = il,
  29196. p = Cn,
  29197. f = Tn;
  29198. if ((u === null && (l.boundingBox || l.computeBoundingBox(), r.set(l.boundingBox.min, l.boundingBox.max, h), (u = r)), fn(c, p))) {
  29199. let g = o,
  29200. m = g.index,
  29201. v = g.attributes.position,
  29202. y = l.index,
  29203. b = l.attributes.position,
  29204. x = Co(a, f),
  29205. w = wh(c, p);
  29206. if ((i.copy(h).invert(), l.boundsTree))
  29207. return (
  29208. ls(a, d, s),
  29209. s.matrix.copy(i),
  29210. (s.needsUpdate = !0),
  29211. l.boundsTree.shapecast({
  29212. intersectsBounds: (A) => s.intersectsBox(A),
  29213. intersectsTriangle: (A) => {
  29214. A.a.applyMatrix4(h), A.b.applyMatrix4(h), A.c.applyMatrix4(h), (A.needsUpdate = !0);
  29215. for (let S = x * 3, _ = (w + x) * 3; S < _; S += 3)
  29216. if ((ns(t, S, m, v), (t.needsUpdate = !0), A.intersectsTriangle(t))) return !0;
  29217. return !1;
  29218. }
  29219. })
  29220. );
  29221. for (let A = x * 3, S = w + x * 3; A < S; A += 3) {
  29222. ns(e, A, m, v), e.a.applyMatrix4(i), e.b.applyMatrix4(i), e.c.applyMatrix4(i), (e.needsUpdate = !0);
  29223. for (let _ = 0, M = y.count; _ < M; _ += 3) if ((ns(t, _, y, b), (t.needsUpdate = !0), e.intersectsTriangle(t))) return !0;
  29224. }
  29225. } else {
  29226. let g = a + 8,
  29227. m = f[a + 6];
  29228. return ls(g, d, vo), !!((u.intersectsBox(vo) && n(g, o, l, h, u)) || (ls(m, d, vo), u.intersectsBox(vo) && n(m, o, l, h, u)));
  29229. }
  29230. };
  29231. })();
  29232. function qd(e, t, i, r) {
  29233. return ls(e, t, vo), i.intersectBox(vo, r);
  29234. }
  29235. var Dm = [],
  29236. ad,
  29237. il,
  29238. Cn,
  29239. Tn;
  29240. function Hl(e) {
  29241. ad && Dm.push(ad), (ad = e), (il = new Float32Array(e)), (Cn = new Uint16Array(e)), (Tn = new Uint32Array(e));
  29242. }
  29243. function Dc() {
  29244. (ad = null), (il = null), (Cn = null), (Tn = null), Dm.length && Hl(Dm.pop());
  29245. }
  29246. var kp = Symbol('skip tree generation'),
  29247. jp = new Kt(),
  29248. Gp = new Kt(),
  29249. Za = new ve(),
  29250. Yn = new ws(),
  29251. Sl = new ws(),
  29252. Ml = new E(),
  29253. Lc = new E(),
  29254. rF = new E(),
  29255. sF = new E(),
  29256. nF = new E(),
  29257. ox = new Kt(),
  29258. Yr = new oA(() => new Xs()),
  29259. gi = class {
  29260. static serialize(e, t = {}) {
  29261. if (t.isBufferGeometry)
  29262. return (
  29263. console.warn('MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature.'),
  29264. gi.serialize(arguments[0], { cloneBuffers: arguments[2] === void 0 ? !0 : arguments[2] })
  29265. );
  29266. t = { cloneBuffers: !0, ...t };
  29267. let i = e.geometry,
  29268. r = e._roots,
  29269. s = i.getIndex(),
  29270. n;
  29271. return t.cloneBuffers ? (n = { roots: r.map((a) => a.slice()), index: s.array.slice() }) : (n = { roots: r, index: s.array }), n;
  29272. }
  29273. static deserialize(e, t, i = {}) {
  29274. if (typeof i == 'boolean')
  29275. return (
  29276. console.warn('MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature.'),
  29277. gi.deserialize(arguments[0], arguments[1], { setIndex: arguments[2] === void 0 ? !0 : arguments[2] })
  29278. );
  29279. i = { setIndex: !0, ...i };
  29280. let { index: r, roots: s } = e,
  29281. n = new gi(t, { ...i, [kp]: !0 });
  29282. if (((n._roots = s), i.setIndex)) {
  29283. let a = t.getIndex();
  29284. if (a === null) {
  29285. let o = new Xe(e.index, 1, !1);
  29286. t.setIndex(o);
  29287. } else a.array !== r && (a.array.set(r), (a.needsUpdate = !0));
  29288. }
  29289. return n;
  29290. }
  29291. constructor(e, t = {}) {
  29292. if (e.isBufferGeometry) {
  29293. if (e.index && e.index.isInterleavedBufferAttribute)
  29294. throw new Error('MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.');
  29295. } else throw new Error('MeshBVH: Only BufferGeometries are supported.');
  29296. if (
  29297. ((t = Object.assign(
  29298. {
  29299. strategy: 0,
  29300. maxDepth: 40,
  29301. maxLeafTris: 10,
  29302. verbose: !0,
  29303. useSharedArrayBuffer: !1,
  29304. setBoundingBox: !0,
  29305. onProgress: null,
  29306. [kp]: !1
  29307. },
  29308. t
  29309. )),
  29310. t.useSharedArrayBuffer && typeof SharedArrayBuffer > 'u')
  29311. )
  29312. throw new Error('MeshBVH: SharedArrayBuffer is not available.');
  29313. (this._roots = null),
  29314. t[kp] || ((this._roots = WU(e, t)), !e.boundingBox && t.setBoundingBox && (e.boundingBox = this.getBoundingBox(new Kt()))),
  29315. (this.geometry = e);
  29316. }
  29317. refit(e = null) {
  29318. e && Array.isArray(e) && (e = new Set(e));
  29319. let t = this.geometry,
  29320. i = t.index.array,
  29321. r = t.attributes.position,
  29322. s = r.array,
  29323. n = r.offset || 0,
  29324. a = 3;
  29325. r.isInterleavedBufferAttribute && (a = r.data.stride);
  29326. let o,
  29327. l,
  29328. h,
  29329. u,
  29330. c = 0,
  29331. d = this._roots;
  29332. for (let f = 0, g = d.length; f < g; f++)
  29333. (o = d[f]), (l = new Uint32Array(o)), (h = new Uint16Array(o)), (u = new Float32Array(o)), p(0, c), (c += o.byteLength);
  29334. function p(f, g, m = !1) {
  29335. let v = f * 2;
  29336. if (h[v + 15] === 65535) {
  29337. let y = l[f + 6],
  29338. b = h[v + 14],
  29339. x = 1 / 0,
  29340. w = 1 / 0,
  29341. A = 1 / 0,
  29342. S = -1 / 0,
  29343. _ = -1 / 0,
  29344. M = -1 / 0;
  29345. for (let C = 3 * y, T = 3 * (y + b); C < T; C++) {
  29346. let P = i[C] * a + n,
  29347. L = s[P + 0],
  29348. D = s[P + 1],
  29349. k = s[P + 2];
  29350. L < x && (x = L), L > S && (S = L), D < w && (w = D), D > _ && (_ = D), k < A && (A = k), k > M && (M = k);
  29351. }
  29352. return u[f + 0] !== x || u[f + 1] !== w || u[f + 2] !== A || u[f + 3] !== S || u[f + 4] !== _ || u[f + 5] !== M
  29353. ? ((u[f + 0] = x), (u[f + 1] = w), (u[f + 2] = A), (u[f + 3] = S), (u[f + 4] = _), (u[f + 5] = M), !0)
  29354. : !1;
  29355. } else {
  29356. let y = f + 8,
  29357. b = l[f + 6],
  29358. x = y + g,
  29359. w = b + g,
  29360. A = m,
  29361. S = !1,
  29362. _ = !1;
  29363. e ? A || ((S = e.has(x)), (_ = e.has(w)), (A = !S && !_)) : ((S = !0), (_ = !0));
  29364. let M = A || S,
  29365. C = A || _,
  29366. T = !1;
  29367. M && (T = p(y, g, A));
  29368. let P = !1;
  29369. C && (P = p(b, g, A));
  29370. let L = T || P;
  29371. if (L)
  29372. for (let D = 0; D < 3; D++) {
  29373. let k = y + D,
  29374. W = b + D,
  29375. X = u[k],
  29376. z = u[k + 3],
  29377. j = u[W],
  29378. U = u[W + 3];
  29379. (u[f + D] = X < j ? X : j), (u[f + D + 3] = z > U ? z : U);
  29380. }
  29381. return L;
  29382. }
  29383. }
  29384. }
  29385. traverse(e, t = 0) {
  29386. let i = this._roots[t],
  29387. r = new Uint32Array(i),
  29388. s = new Uint16Array(i);
  29389. n(0);
  29390. function n(a, o = 0) {
  29391. let l = a * 2,
  29392. h = s[l + 15] === 65535;
  29393. if (h) {
  29394. let u = r[a + 6],
  29395. c = s[l + 14];
  29396. e(o, h, new Float32Array(i, a * 4, 6), u, c);
  29397. } else {
  29398. let u = a + 8,
  29399. c = r[a + 6],
  29400. d = r[a + 7];
  29401. e(o, h, new Float32Array(i, a * 4, 6), d) || (n(u, o + 1), n(c, o + 1));
  29402. }
  29403. }
  29404. }
  29405. raycast(e, t = Vr) {
  29406. let i = this._roots,
  29407. r = this.geometry,
  29408. s = [],
  29409. n = t.isMaterial,
  29410. a = Array.isArray(t),
  29411. o = r.groups,
  29412. l = n ? t.side : t;
  29413. for (let h = 0, u = i.length; h < u; h++) {
  29414. let c = a ? t[o[h].materialIndex].side : l,
  29415. d = s.length;
  29416. if ((Hl(i[h]), Tm(0, r, c, e, s), Dc(), a)) {
  29417. let p = o[h].materialIndex;
  29418. for (let f = d, g = s.length; f < g; f++) s[f].face.materialIndex = p;
  29419. }
  29420. }
  29421. return s;
  29422. }
  29423. raycastFirst(e, t = Vr) {
  29424. let i = this._roots,
  29425. r = this.geometry,
  29426. s = t.isMaterial,
  29427. n = Array.isArray(t),
  29428. a = null,
  29429. o = r.groups,
  29430. l = s ? t.side : t;
  29431. for (let h = 0, u = i.length; h < u; h++) {
  29432. let c = n ? t[o[h].materialIndex].side : l;
  29433. Hl(i[h]);
  29434. let d = Pm(0, r, c, e);
  29435. Dc(), d != null && (a == null || d.distance < a.distance) && ((a = d), n && (d.face.materialIndex = o[h].materialIndex));
  29436. }
  29437. return a;
  29438. }
  29439. intersectsGeometry(e, t) {
  29440. let i = this.geometry,
  29441. r = !1;
  29442. for (let s of this._roots) if ((Hl(s), (r = iF(0, i, e, t)), Dc(), r)) break;
  29443. return r;
  29444. }
  29445. shapecast(e, t, i) {
  29446. let r = this.geometry;
  29447. if (e instanceof Function) {
  29448. if (t) {
  29449. let c = t;
  29450. t = (d, p, f, g) => {
  29451. let m = p * 3;
  29452. return c(d, m, m + 1, m + 2, f, g);
  29453. };
  29454. }
  29455. (e = { boundsTraverseOrder: i, intersectsBounds: e, intersectsTriangle: t, intersectsRange: null }),
  29456. console.warn(
  29457. 'MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.'
  29458. );
  29459. }
  29460. let s = Yr.getPrimitive(),
  29461. { boundsTraverseOrder: n, intersectsBounds: a, intersectsRange: o, intersectsTriangle: l } = e;
  29462. if (o && l) {
  29463. let c = o;
  29464. o = (d, p, f, g, m) => (c(d, p, f, g, m) ? !0 : ax(d, p, r, l, f, g, s));
  29465. } else o || (l ? (o = (c, d, p, f) => ax(c, d, r, l, p, f, s)) : (o = (c, d, p) => p));
  29466. let h = !1,
  29467. u = 0;
  29468. for (let c of this._roots) {
  29469. if ((Hl(c), (h = tF(0, r, a, o, n, u)), Dc(), h)) break;
  29470. u += c.byteLength;
  29471. }
  29472. return Yr.releasePrimitive(s), h;
  29473. }
  29474. bvhcast(e, t, i) {
  29475. let { intersectsRanges: r, intersectsTriangles: s } = i,
  29476. n = this.geometry.index,
  29477. a = this.geometry.attributes.position,
  29478. o = e.geometry.index,
  29479. l = e.geometry.attributes.position;
  29480. Za.copy(t).invert();
  29481. let h = Yr.getPrimitive(),
  29482. u = Yr.getPrimitive();
  29483. if (s) {
  29484. let d = function (p, f, g, m, v, y, b, x) {
  29485. for (let w = g, A = g + m; w < A; w++) {
  29486. ns(u, w * 3, o, l), u.a.applyMatrix4(t), u.b.applyMatrix4(t), u.c.applyMatrix4(t), (u.needsUpdate = !0);
  29487. for (let S = p, _ = p + f; S < _; S++) if ((ns(h, S * 3, n, a), (h.needsUpdate = !0), s(h, u, S, w, v, y, b, x))) return !0;
  29488. }
  29489. return !1;
  29490. };
  29491. if (r) {
  29492. let p = r;
  29493. r = function (f, g, m, v, y, b, x, w) {
  29494. return p(f, g, m, v, y, b, x, w) ? !0 : d(f, g, m, v, y, b, x, w);
  29495. };
  29496. } else r = d;
  29497. }
  29498. e.getBoundingBox(Gp), Gp.applyMatrix4(t);
  29499. let c = this.shapecast({
  29500. intersectsBounds: (d) => Gp.intersectsBox(d),
  29501. intersectsRange: (d, p, f, g, m, v) => (
  29502. jp.copy(v),
  29503. jp.applyMatrix4(Za),
  29504. e.shapecast({ intersectsBounds: (y) => jp.intersectsBox(y), intersectsRange: (y, b, x, w, A) => r(d, p, y, b, g, m, w, A) })
  29505. )
  29506. });
  29507. return Yr.releasePrimitive(h), Yr.releasePrimitive(u), c;
  29508. }
  29509. intersectsBox(e, t) {
  29510. return (
  29511. Yn.set(e.min, e.max, t),
  29512. (Yn.needsUpdate = !0),
  29513. this.shapecast({ intersectsBounds: (i) => Yn.intersectsBox(i), intersectsTriangle: (i) => Yn.intersectsTriangle(i) })
  29514. );
  29515. }
  29516. intersectsSphere(e) {
  29517. return this.shapecast({ intersectsBounds: (t) => e.intersectsBox(t), intersectsTriangle: (t) => t.intersectsSphere(e) });
  29518. }
  29519. closestPointToGeometry(e, t, i = {}, r = {}, s = 0, n = 1 / 0) {
  29520. e.boundingBox || e.computeBoundingBox(), Yn.set(e.boundingBox.min, e.boundingBox.max, t), (Yn.needsUpdate = !0);
  29521. let a = this.geometry,
  29522. o = a.attributes.position,
  29523. l = a.index,
  29524. h = e.attributes.position,
  29525. u = e.index,
  29526. c = Yr.getPrimitive(),
  29527. d = Yr.getPrimitive(),
  29528. p = Lc,
  29529. f = rF,
  29530. g = null,
  29531. m = null;
  29532. r && ((g = sF), (m = nF));
  29533. let v = 1 / 0,
  29534. y = null,
  29535. b = null;
  29536. return (
  29537. Za.copy(t).invert(),
  29538. Sl.matrix.copy(Za),
  29539. this.shapecast({
  29540. boundsTraverseOrder: (x) => Yn.distanceToBox(x),
  29541. intersectsBounds: (x, w, A) => (A < v && A < n ? (w && (Sl.min.copy(x.min), Sl.max.copy(x.max), (Sl.needsUpdate = !0)), !0) : !1),
  29542. intersectsRange: (x, w) => {
  29543. if (e.boundsTree)
  29544. return e.boundsTree.shapecast({
  29545. boundsTraverseOrder: (A) => Sl.distanceToBox(A),
  29546. intersectsBounds: (A, S, _) => _ < v && _ < n,
  29547. intersectsRange: (A, S) => {
  29548. for (let _ = A * 3, M = (A + S) * 3; _ < M; _ += 3) {
  29549. ns(d, _, u, h), d.a.applyMatrix4(t), d.b.applyMatrix4(t), d.c.applyMatrix4(t), (d.needsUpdate = !0);
  29550. for (let C = x * 3, T = (x + w) * 3; C < T; C += 3) {
  29551. ns(c, C, l, o), (c.needsUpdate = !0);
  29552. let P = c.distanceToTriangle(d, p, g);
  29553. if ((P < v && (f.copy(p), m && m.copy(g), (v = P), (y = C / 3), (b = _ / 3)), P < s)) return !0;
  29554. }
  29555. }
  29556. }
  29557. });
  29558. {
  29559. let A = u ? u.count : h.count;
  29560. for (let S = 0, _ = A; S < _; S += 3) {
  29561. ns(d, S, u, h), d.a.applyMatrix4(t), d.b.applyMatrix4(t), d.c.applyMatrix4(t), (d.needsUpdate = !0);
  29562. for (let M = x * 3, C = (x + w) * 3; M < C; M += 3) {
  29563. ns(c, M, l, o), (c.needsUpdate = !0);
  29564. let T = c.distanceToTriangle(d, p, g);
  29565. if ((T < v && (f.copy(p), m && m.copy(g), (v = T), (y = M / 3), (b = S / 3)), T < s)) return !0;
  29566. }
  29567. }
  29568. }
  29569. }
  29570. }),
  29571. Yr.releasePrimitive(c),
  29572. Yr.releasePrimitive(d),
  29573. v === 1 / 0
  29574. ? null
  29575. : (i.point ? i.point.copy(f) : (i.point = f.clone()),
  29576. (i.distance = v),
  29577. (i.faceIndex = y),
  29578. r &&
  29579. (r.point ? r.point.copy(m) : (r.point = m.clone()),
  29580. r.point.applyMatrix4(Za),
  29581. f.applyMatrix4(Za),
  29582. (r.distance = f.sub(r.point).length()),
  29583. (r.faceIndex = b)),
  29584. i)
  29585. );
  29586. }
  29587. closestPointToPoint(e, t = {}, i = 0, r = 1 / 0) {
  29588. let s = i * i,
  29589. n = r * r,
  29590. a = 1 / 0,
  29591. o = null;
  29592. if (
  29593. (this.shapecast({
  29594. boundsTraverseOrder: (h) => (Ml.copy(e).clamp(h.min, h.max), Ml.distanceToSquared(e)),
  29595. intersectsBounds: (h, u, c) => c < a && c < n,
  29596. intersectsTriangle: (h, u) => {
  29597. h.closestPointToPoint(e, Ml);
  29598. let c = e.distanceToSquared(Ml);
  29599. return c < a && (Lc.copy(Ml), (a = c), (o = u)), c < s;
  29600. }
  29601. }),
  29602. a === 1 / 0)
  29603. )
  29604. return null;
  29605. let l = Math.sqrt(a);
  29606. return t.point ? t.point.copy(Lc) : (t.point = Lc.clone()), (t.distance = l), (t.faceIndex = o), t;
  29607. }
  29608. getBoundingBox(e) {
  29609. return (
  29610. e.makeEmpty(),
  29611. this._roots.forEach((t) => {
  29612. ls(0, new Float32Array(t), ox), e.union(ox);
  29613. }),
  29614. e
  29615. );
  29616. }
  29617. },
  29618. lx = gi.prototype.raycast;
  29619. gi.prototype.raycast = function (...e) {
  29620. if (e[0].isMesh) {
  29621. console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');
  29622. let [t, i, r, s] = e;
  29623. return (
  29624. lx.call(this, r, t.material).forEach((n) => {
  29625. (n = aA(n, t, i)), n && s.push(n);
  29626. }),
  29627. s
  29628. );
  29629. } else return lx.apply(this, e);
  29630. };
  29631. var hx = gi.prototype.raycastFirst;
  29632. gi.prototype.raycastFirst = function (...e) {
  29633. if (e[0].isMesh) {
  29634. console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');
  29635. let [t, i, r] = e;
  29636. return aA(hx.call(this, r, t.material), t, i);
  29637. } else return hx.apply(this, e);
  29638. };
  29639. var cx = gi.prototype.closestPointToPoint;
  29640. gi.prototype.closestPointToPoint = function (...e) {
  29641. if (e[0].isMesh) {
  29642. console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),
  29643. e.unshift();
  29644. let t = e[1],
  29645. i = {};
  29646. return (e[1] = i), cx.apply(this, e), t && t.copy(i.point), i.distance;
  29647. } else return cx.apply(this, e);
  29648. };
  29649. var dx = gi.prototype.closestPointToGeometry;
  29650. gi.prototype.closestPointToGeometry = function (...e) {
  29651. let t = e[2],
  29652. i = e[3];
  29653. if ((t && t.isVector3) || (i && i.isVector3)) {
  29654. console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');
  29655. let r = {},
  29656. s = {},
  29657. n = e[1];
  29658. return (e[2] = r), (e[3] = s), dx.apply(this, e), t && t.copy(r.point), i && i.copy(s.point).applyMatrix4(n), r.distance;
  29659. } else return dx.apply(this, e);
  29660. };
  29661. var ux = gi.prototype.refit;
  29662. gi.prototype.refit = function (...e) {
  29663. let t = e[0],
  29664. i = e[1];
  29665. if (i && (i instanceof Set || Array.isArray(i))) {
  29666. console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');
  29667. let r = new Set();
  29668. i.forEach((s) => r.add(s)), t && t.forEach((s) => r.add(s)), ux.call(this, r);
  29669. } else ux.apply(this, e);
  29670. };
  29671. ['intersectsGeometry', 'shapecast', 'intersectsBox', 'intersectsSphere'].forEach((e) => {
  29672. let t = gi.prototype[e];
  29673. gi.prototype[e] = function (...i) {
  29674. return (
  29675. (i[0] === null || i[0].isMesh) &&
  29676. (i.shift(),
  29677. console.warn(`MeshBVH: The function signature for "${e}" has changed and no longer takes Mesh. See docs for new signature.`)),
  29678. t.apply(this, i)
  29679. );
  29680. };
  29681. });
  29682. var El = Eh(W2()),
  29683. aF = 0.5 * (Math.sqrt(3) - 1),
  29684. Cl = (3 - Math.sqrt(3)) / 6,
  29685. oF = 1 / 3,
  29686. Qr = 1 / 6,
  29687. E9 = (Math.sqrt(5) - 1) / 4,
  29688. C9 = (5 - Math.sqrt(5)) / 20,
  29689. th = (e) => Math.floor(e) | 0,
  29690. px = 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]),
  29691. Vp = new Float64Array([
  29692. 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
  29693. ]);
  29694. function Hp(e = Math.random) {
  29695. let t = lA(e),
  29696. i = new Float64Array(t).map((s) => px[(s % 12) * 2]),
  29697. r = new Float64Array(t).map((s) => px[(s % 12) * 2 + 1]);
  29698. return function (s, n) {
  29699. let a = 0,
  29700. o = 0,
  29701. l = 0,
  29702. h = (s + n) * aF,
  29703. u = th(s + h),
  29704. c = th(n + h),
  29705. d = (u + c) * Cl,
  29706. p = u - d,
  29707. f = c - d,
  29708. g = s - p,
  29709. m = n - f,
  29710. v,
  29711. y;
  29712. g > m ? ((v = 1), (y = 0)) : ((v = 0), (y = 1));
  29713. let b = g - v + Cl,
  29714. x = m - y + Cl,
  29715. w = g - 1 + 2 * Cl,
  29716. A = m - 1 + 2 * Cl,
  29717. S = u & 255,
  29718. _ = c & 255,
  29719. M = 0.5 - g * g - m * m;
  29720. if (M >= 0) {
  29721. let P = S + t[_],
  29722. L = i[P],
  29723. D = r[P];
  29724. (M *= M), (a = M * M * (L * g + D * m));
  29725. }
  29726. let C = 0.5 - b * b - x * x;
  29727. if (C >= 0) {
  29728. let P = S + v + t[_ + y],
  29729. L = i[P],
  29730. D = r[P];
  29731. (C *= C), (o = C * C * (L * b + D * x));
  29732. }
  29733. let T = 0.5 - w * w - A * A;
  29734. if (T >= 0) {
  29735. let P = S + 1 + t[_ + 1],
  29736. L = i[P],
  29737. D = r[P];
  29738. (T *= T), (l = T * T * (L * w + D * A));
  29739. }
  29740. return 70 * (a + o + l);
  29741. };
  29742. }
  29743. function lF(e = Math.random) {
  29744. let t = lA(e),
  29745. i = new Float64Array(t).map((n) => Vp[(n % 12) * 3]),
  29746. r = new Float64Array(t).map((n) => Vp[(n % 12) * 3 + 1]),
  29747. s = new Float64Array(t).map((n) => Vp[(n % 12) * 3 + 2]);
  29748. return function (n, a, o) {
  29749. let l,
  29750. h,
  29751. u,
  29752. c,
  29753. d = (n + a + o) * oF,
  29754. p = th(n + d),
  29755. f = th(a + d),
  29756. g = th(o + d),
  29757. m = (p + f + g) * Qr,
  29758. v = p - m,
  29759. y = f - m,
  29760. b = g - m,
  29761. x = n - v,
  29762. w = a - y,
  29763. A = o - b,
  29764. S,
  29765. _,
  29766. M,
  29767. C,
  29768. T,
  29769. P;
  29770. x >= w
  29771. ? w >= A
  29772. ? ((S = 1), (_ = 0), (M = 0), (C = 1), (T = 1), (P = 0))
  29773. : x >= A
  29774. ? ((S = 1), (_ = 0), (M = 0), (C = 1), (T = 0), (P = 1))
  29775. : ((S = 0), (_ = 0), (M = 1), (C = 1), (T = 0), (P = 1))
  29776. : w < A
  29777. ? ((S = 0), (_ = 0), (M = 1), (C = 0), (T = 1), (P = 1))
  29778. : x < A
  29779. ? ((S = 0), (_ = 1), (M = 0), (C = 0), (T = 1), (P = 1))
  29780. : ((S = 0), (_ = 1), (M = 0), (C = 1), (T = 1), (P = 0));
  29781. let L = x - S + Qr,
  29782. D = w - _ + Qr,
  29783. k = A - M + Qr,
  29784. W = x - C + 2 * Qr,
  29785. X = w - T + 2 * Qr,
  29786. z = A - P + 2 * Qr,
  29787. j = x - 1 + 3 * Qr,
  29788. U = w - 1 + 3 * Qr,
  29789. N = A - 1 + 3 * Qr,
  29790. B = p & 255,
  29791. H = f & 255,
  29792. Q = g & 255,
  29793. Y = 0.6 - x * x - w * w - A * A;
  29794. if (Y < 0) l = 0;
  29795. else {
  29796. let ee = B + t[H + t[Q]];
  29797. (Y *= Y), (l = Y * Y * (i[ee] * x + r[ee] * w + s[ee] * A));
  29798. }
  29799. let F = 0.6 - L * L - D * D - k * k;
  29800. if (F < 0) h = 0;
  29801. else {
  29802. let ee = B + S + t[H + _ + t[Q + M]];
  29803. (F *= F), (h = F * F * (i[ee] * L + r[ee] * D + s[ee] * k));
  29804. }
  29805. let se = 0.6 - W * W - X * X - z * z;
  29806. if (se < 0) u = 0;
  29807. else {
  29808. let ee = B + C + t[H + T + t[Q + P]];
  29809. (se *= se), (u = se * se * (i[ee] * W + r[ee] * X + s[ee] * z));
  29810. }
  29811. let V = 0.6 - j * j - U * U - N * N;
  29812. if (V < 0) c = 0;
  29813. else {
  29814. let ee = B + 1 + t[H + 1 + t[Q + 1]];
  29815. (V *= V), (c = V * V * (i[ee] * j + r[ee] * U + s[ee] * N));
  29816. }
  29817. return 32 * (l + h + u + c);
  29818. };
  29819. }
  29820. function lA(e) {
  29821. let t = new Uint8Array(512);
  29822. for (let i = 0; i < 512 / 2; i++) t[i] = i;
  29823. for (let i = 0; i < 512 / 2 - 1; i++) {
  29824. let r = i + ~~(e() * (256 - i)),
  29825. s = t[i];
  29826. (t[i] = t[r]), (t[r] = s);
  29827. }
  29828. for (let i = 256; i < 512; i++) t[i] = t[i - 256];
  29829. return t;
  29830. }
  29831. var Ir = new Bi(),
  29832. hF = class {
  29833. constructor(e) {
  29834. this.weightAttribute = null;
  29835. let t = e.geometry;
  29836. if (!t.isBufferGeometry || t.attributes.position.itemSize !== 3)
  29837. throw new Error('THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.');
  29838. t.index && (t = t.toNonIndexed()),
  29839. (this.geometry = t),
  29840. (this.randomFunction = Math.random),
  29841. (this.positionAttribute = this.geometry.getAttribute('position')),
  29842. (this.distribution = null);
  29843. }
  29844. build() {
  29845. let e = this.positionAttribute,
  29846. t = new Float32Array(e.count / 3);
  29847. for (let r = 0; r < e.count; r += 3) {
  29848. let s = 1;
  29849. Ir.a.fromBufferAttribute(e, r),
  29850. Ir.b.fromBufferAttribute(e, r + 1),
  29851. Ir.c.fromBufferAttribute(e, r + 2),
  29852. (s *= Ir.getArea()),
  29853. (t[r / 3] = s);
  29854. }
  29855. this.distribution = new Float32Array(e.count / 3);
  29856. let i = 0;
  29857. for (let r = 0; r < t.length; r++) (i += t[r]), (this.distribution[r] = i);
  29858. return this;
  29859. }
  29860. setRandomGenerator(e) {
  29861. return (this.randomFunction = e), this;
  29862. }
  29863. sample(e, t) {
  29864. if (this.distribution) {
  29865. let i = this.distribution[this.distribution.length - 1],
  29866. r = this.binarySearch(this.randomFunction() * i);
  29867. return this.sampleFace(r, e, t);
  29868. }
  29869. }
  29870. binarySearch(e) {
  29871. if (!this.distribution) return 0;
  29872. let t = this.distribution,
  29873. i = 0,
  29874. r = t.length - 1,
  29875. s = -1;
  29876. for (; i <= r; ) {
  29877. let n = Math.ceil((i + r) / 2);
  29878. if (n === 0 || (t[n - 1] <= e && t[n] > e)) {
  29879. s = n;
  29880. break;
  29881. } else e < t[n] ? (r = n - 1) : (i = n + 1);
  29882. }
  29883. return s;
  29884. }
  29885. sampleFace(e, t, i) {
  29886. let r = this.randomFunction(),
  29887. s = this.randomFunction();
  29888. return (
  29889. r + s > 1 && ((r = 1 - r), (s = 1 - s)),
  29890. Ir.a.fromBufferAttribute(this.positionAttribute, e * 3),
  29891. Ir.b.fromBufferAttribute(this.positionAttribute, e * 3 + 1),
  29892. Ir.c.fromBufferAttribute(this.positionAttribute, e * 3 + 2),
  29893. t
  29894. .set(0, 0, 0)
  29895. .addScaledVector(Ir.a, r)
  29896. .addScaledVector(Ir.b, s)
  29897. .addScaledVector(Ir.c, 1 - (r + s)),
  29898. Ir.getNormal(i),
  29899. this
  29900. );
  29901. }
  29902. },
  29903. cF = Eh(rw()),
  29904. dF = new ve(),
  29905. uF = new ve(),
  29906. pF = new ve(),
  29907. Yd;
  29908. ((e) => {
  29909. function t(i) {
  29910. return i && i.__isSPEObject;
  29911. }
  29912. e.is = t;
  29913. })(Yd || (Yd = {}));
  29914. var $g = (e) =>
  29915. class extends e {
  29916. constructor() {
  29917. super(...arguments),
  29918. (this.hiddenMatrix = new ve()),
  29919. (this.matrixWorldRigid = new ve()),
  29920. (this.shearScale = new ve()),
  29921. (this.shearScaleInv = new ve());
  29922. }
  29923. get __isSPEObject() {
  29924. return !0;
  29925. }
  29926. isDescendantOf(t) {
  29927. t instanceof bt && (t = t.uuid);
  29928. let i = this;
  29929. for (; i.parent; ) {
  29930. if (i.parent.uuid === t) return !0;
  29931. i = i.parent;
  29932. }
  29933. return !1;
  29934. }
  29935. updateMatrixWorld(t) {
  29936. this.matrixAutoUpdate && this.updateMatrix(),
  29937. (this.matrixWorldNeedsUpdate || t) &&
  29938. (this.parent === null
  29939. ? this.matrixWorld.multiplyMatrices(this.hiddenMatrix, this.matrix)
  29940. : (this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.hiddenMatrix),
  29941. this.matrixWorld.multiplyMatrices(this.matrixWorld, this.matrix)),
  29942. (this.matrixWorldNeedsUpdate = !1),
  29943. (t = !0));
  29944. for (let i of this.children) i.updateMatrixWorld(t);
  29945. }
  29946. updateWorldMatrix(t, i) {
  29947. let r = this.parent;
  29948. if (
  29949. (t && r !== null && r.updateWorldMatrix(!0, !1),
  29950. this.matrixAutoUpdate && this.updateMatrix(),
  29951. this.parent === null
  29952. ? this.matrixWorld.multiplyMatrices(this.hiddenMatrix, this.matrix)
  29953. : (this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.hiddenMatrix),
  29954. this.matrixWorld.multiplyMatrices(this.matrixWorld, this.matrix)),
  29955. i)
  29956. )
  29957. for (let s of this.children) s.updateWorldMatrix(!1, !0);
  29958. }
  29959. traverseObject(t, i = 0) {
  29960. if (t(this, i) !== !0) for (let r of this.children) Yd.is(r) && r.traverseObject(t, i + 1);
  29961. }
  29962. updateMatrixWorldSVD() {
  29963. let t = this.matrixWorld.elements,
  29964. i = [
  29965. [t[0], t[4], t[8]],
  29966. [t[1], t[5], t[9]],
  29967. [t[2], t[6], t[10]]
  29968. ],
  29969. { u: r, v: s, q: n } = (0, cF.SVD)(i),
  29970. a = dF.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),
  29971. o = uF.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),
  29972. l = pF.copy(o).transpose();
  29973. this.shearScale.makeScale(n[0], n[1], n[2]).multiply(l).premultiply(o),
  29974. this.shearScaleInv.copy(this.shearScale).invert(),
  29975. this.matrixWorldRigid.multiplyMatrices(a, l).copyPosition(this.matrixWorld),
  29976. n.every((h) => Math.abs(n[0] - h) < 0.01) ? (this.hasNonUniformScale = !1) : (this.hasNonUniformScale = !0);
  29977. }
  29978. attach(t, i) {
  29979. this.updateWorldMatrix(!0, !1);
  29980. let r = new ve().copy(this.matrixWorld).invert();
  29981. return (
  29982. t.parent !== null && (t.parent.updateWorldMatrix(!0, !1), r.multiply(t.parent.matrixWorld)),
  29983. 'hiddenMatrix' in t && t.hiddenMatrix instanceof ve ? t.hiddenMatrix.premultiply(r) : t.applyMatrix4(r),
  29984. t.updateWorldMatrix(!1, !1),
  29985. this.add(t),
  29986. i !== void 0 && (this.children.pop(), this.children.splice(i, 0, t)),
  29987. this
  29988. );
  29989. }
  29990. },
  29991. fF = class extends $g(bt) {},
  29992. mF = (e) => e.type === 'Mesh',
  29993. la = class extends fF {
  29994. constructor(e) {
  29995. super(), (this.object = e), (this.matrixAutoUpdate = !1);
  29996. }
  29997. expand() {
  29998. let e = 0,
  29999. t = this.object.entityChildren(e);
  30000. for (; t; ) {
  30001. let i = this.children[e];
  30002. i?.object !== t &&
  30003. (i && this.remove(i),
  30004. (i = new la(t)),
  30005. this.add(i),
  30006. this.children.splice(e, 0, this.children.pop()),
  30007. (i.matrixWorldNeedsUpdate = !0),
  30008. (i.matrixAutoUpdate = !1),
  30009. (i.matrix = t.matrix),
  30010. (i.hiddenMatrix = t.hiddenMatrix)),
  30011. i.expand(),
  30012. (e += 1),
  30013. (t = this.object.entityChildren(e));
  30014. }
  30015. for (; this.children.length > e; ) this.remove(this.children[e]);
  30016. }
  30017. get visible() {
  30018. return this.object.visible || (this.object.dataPatched.visible && this.object.dataPatched.cloner?.hideBase === !0);
  30019. }
  30020. set visible(e) {}
  30021. get castShadow() {
  30022. return this.object.castShadow;
  30023. }
  30024. set castShadow(e) {}
  30025. get receiveShadow() {
  30026. return this.object.receiveShadow;
  30027. }
  30028. set receiveShadow(e) {}
  30029. get isMesh() {
  30030. return mF(this.object);
  30031. }
  30032. get isLight() {
  30033. return this.object.isLight;
  30034. }
  30035. get layers() {
  30036. return this.object.layers;
  30037. }
  30038. set layers(e) {}
  30039. get isCamera() {
  30040. return !1;
  30041. }
  30042. get geometry() {
  30043. if (this.object.geometry) return this.object.geometry;
  30044. }
  30045. get material() {
  30046. if (this.object.material) return this.object.material;
  30047. }
  30048. },
  30049. ra = new E(),
  30050. sa = new E(),
  30051. To = new ve(),
  30052. hA = [
  30053. new E(-1, 1, 1),
  30054. new E(-1, -1, 1),
  30055. new E(1, -1, 1),
  30056. new E(1, 1, 1),
  30057. new E(-1, 1, -1),
  30058. new E(-1, -1, -1),
  30059. new E(1, -1, -1),
  30060. new E(1, 1, -1)
  30061. ],
  30062. gF = [
  30063. [0, 3],
  30064. [1, 2],
  30065. [5, 6],
  30066. [4, 7],
  30067. [0, 1],
  30068. [3, 2],
  30069. [7, 6],
  30070. [4, 5],
  30071. [0, 4],
  30072. [1, 5],
  30073. [2, 6],
  30074. [3, 7]
  30075. ],
  30076. vF = [
  30077. [0, 2],
  30078. [7, 5],
  30079. [4, 1],
  30080. [3, 6],
  30081. [4, 3],
  30082. [1, 6]
  30083. ],
  30084. fx = (e, t, i) => {
  30085. e.updateEntityBoxSize(ra, sa),
  30086. To.copy(t).multiply(e.matrixWorld),
  30087. sa.x === 0 && sa.y === 0 && sa.z === 0
  30088. ? i.push(new E(ra.x, ra.y, ra.z).applyMatrix4(To))
  30089. : hA.forEach((r) => {
  30090. i.push(r.clone().multiply(sa).add(ra).applyMatrix4(To));
  30091. });
  30092. },
  30093. mx = class extends Kt {
  30094. constructor() {
  30095. super(...arguments), (this.matrix = new ve()), (this.vertices = []), (this.faces = []), (this.edges = []), (this.centerEdges = []);
  30096. }
  30097. copy(e) {
  30098. return (
  30099. super.copy(e),
  30100. this.matrix.copy(e.matrix),
  30101. (this.vertices = e.vertices.map((t) => t.clone())),
  30102. (this.faces = e.faces.map((t) => t.clone())),
  30103. (this.edges = e.edges.map((t) => t.clone())),
  30104. (this.centerEdges = e.centerEdges.map((t) => t.clone())),
  30105. this
  30106. );
  30107. }
  30108. setFromObjectSize(e, t = !1) {
  30109. e.updateWorldMatrix(!1, t), this.makeEmpty(), this.matrix.copy(e.matrixWorld);
  30110. let i = new ve().copy(e.matrixWorld).invert();
  30111. return this.expandByObjectSize(e, i, t);
  30112. }
  30113. expandByObjectSize(e, t, i = !1) {
  30114. let r = [];
  30115. return (
  30116. i === !0
  30117. ? e.traverseEntity((s) => {
  30118. (s.visible || (s.cloner && s.data.visible)) && fx(s, t, r);
  30119. })
  30120. : fx(e, t, r),
  30121. this.setFromPoints(r)
  30122. );
  30123. }
  30124. getCenter(e) {
  30125. return (e = super.getCenter(e)), e.applyMatrix4(this.matrix), e;
  30126. }
  30127. getPositionToCenter(e) {
  30128. return (e = super.getCenter(e)), e.applyMatrix4(To.copy(this.matrix).setPosition(0, 0, 0)), e;
  30129. }
  30130. computeVertices() {
  30131. this.getSize(sa).multiplyScalar(0.5),
  30132. this.getCenter(ra),
  30133. To.copy(this.matrix).setPosition(ra),
  30134. (this.vertices = hA.map((e) => e.clone().multiply(sa).applyMatrix4(To)));
  30135. }
  30136. computeEdges() {
  30137. this.vertices.length > 0 && this.computeVertices(),
  30138. (this.edges = gF.map(([e, t]) => new _r(this.vertices[e], this.vertices[t]))),
  30139. (this.centerEdges = this.edges.map((e) => e.getCenter(new E())));
  30140. }
  30141. computeFaces() {
  30142. this.vertices.length > 0 && this.computeVertices(),
  30143. (this.faces = vF.map(([e, t]) => this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(0.5)));
  30144. }
  30145. },
  30146. wn = { Cloner: () => {}, changeEntityProptotype: () => {}, createEntity: () => {} },
  30147. yF = class extends Cw {
  30148. constructor() {
  30149. super();
  30150. }
  30151. getPoints(e = 12) {
  30152. let t = [],
  30153. i,
  30154. r = this.getCurveLengths(),
  30155. s = r[r.length - 1] / r.length;
  30156. for (let n = 0, a = this.curves; n < a.length; n++) {
  30157. let o = a[n],
  30158. l = n === 0 ? r[n] : r[n] - r[n - 1],
  30159. h = Math.ceil((e * l) / s),
  30160. u = o.getPoints(h);
  30161. for (let c = 0; c < u.length; c++) {
  30162. let d = u[c];
  30163. (i && i.equals(d)) || (t.push(d), (i = d));
  30164. }
  30165. }
  30166. return this.autoClose && t.length > 1 && !t[t.length - 1].equals(t[0]) && t.push(t[0]), t;
  30167. }
  30168. },
  30169. Lm = 0.001;
  30170. function Om(e, t, i) {
  30171. return t.clone().sub(e).cross(t.clone().sub(i)).length() <= Lm;
  30172. }
  30173. function Wp(e, t) {
  30174. let i = new E(...e.position),
  30175. r = new E(...e.controlNext.position),
  30176. s = new E(...t.controlPrevious.position),
  30177. n = new E(...t.position);
  30178. return Om(i, r, n) && Om(i, s, n);
  30179. }
  30180. function cA(e) {
  30181. let t = e.points.map((u) => new E(...u.data.position)),
  30182. i = [e.points[0]],
  30183. r = new E(...i[0].data.position);
  30184. for (let u = 0; u < e.points.length - 1; u++) Om(r, t[u], t[u + 1]) || (i.push(e.points[u]), (r = t[u]));
  30185. i.push(e.points[e.points.length - 1]);
  30186. let s = e.isClosed,
  30187. n = i.length - (s ? 0 : 1),
  30188. a = i.length,
  30189. o = [];
  30190. for (let u = 0; u < a; u++) {
  30191. let c = i[u].data,
  30192. d = new E(...c.position),
  30193. p = new E(...c.controlPrevious.position),
  30194. f = new E(...c.controlNext.position),
  30195. g = { position: d, baseRoundness: c.roundness, controlPrevious: p, controlNext: f };
  30196. if (c.roundness === 0 || (!e.isClosed && (u === 0 || u === a - 1))) {
  30197. o[u] = { ...g, removedLength: 0 };
  30198. continue;
  30199. }
  30200. let m = s && u == 0 ? a - 1 : u - 1,
  30201. v = s && u == a - 1 ? 0 : u + 1,
  30202. y = i[m].data,
  30203. b = i[v].data,
  30204. x = new E(...y.position),
  30205. w = new E(...b.position),
  30206. A = x.clone().sub(d).normalize(),
  30207. S = w.clone().sub(d).normalize();
  30208. Object.assign(g, { prevDir: A, nextDir: S });
  30209. let _ = Wp(y, c),
  30210. M = Wp(c, b);
  30211. if (!_ || !M) o[u] = { ...g, removedLength: 0 };
  30212. else {
  30213. let C = A.clone().add(S).normalize(),
  30214. T = C.clone().cross(A).length() / A.dot(C);
  30215. o[u] = { ...g, tan: T, removedLength: c.roundness / T };
  30216. }
  30217. }
  30218. for (let u = 0; u < n; u++) {
  30219. let c = u,
  30220. d = s && u === a - 1 ? 0 : u + 1,
  30221. p = o[c],
  30222. f = o[d];
  30223. if (p.removedLength !== 0 || f.removedLength !== 0) {
  30224. let g = p.position.distanceTo(f.position);
  30225. (p.removedLength = Math.min(p.removedLength, g / 2)), (f.removedLength = Math.min(f.removedLength, g / 2));
  30226. }
  30227. }
  30228. let l = [];
  30229. for (let u = 0; u < n; u++) {
  30230. let c = u,
  30231. d = s && u === a - 1 ? 0 : u + 1,
  30232. p = o[c],
  30233. f = o[d],
  30234. g = null;
  30235. if (!Wp(i[c].data, i[d].data))
  30236. p.position.distanceTo(f.position) > Lm && (g = new $c(p.position, p.controlNext, f.controlPrevious, f.position));
  30237. else {
  30238. let m = p.position.clone(),
  30239. v = f.position.clone();
  30240. (p.removedLength !== 0 || f.removedLength !== 0) &&
  30241. (p.nextDir && m.add(p.nextDir.clone().setLength(p.removedLength)),
  30242. f.prevDir && v.add(f.prevDir.clone().setLength(f.removedLength))),
  30243. m.distanceTo(v) > Lm && (g = new $c(m, m.clone().lerp(v, 0.3), v.clone().lerp(m, 0.3), v));
  30244. }
  30245. l[2 * u + 1] = g;
  30246. }
  30247. for (let u = 0; u < a; u++) {
  30248. let c = o[u];
  30249. if (c.removedLength === 0) {
  30250. l[2 * u] = null;
  30251. continue;
  30252. }
  30253. let d = c.position,
  30254. p = c.prevDir.clone().multiplyScalar(c.removedLength).add(d),
  30255. f = c.nextDir.clone().multiplyScalar(c.removedLength).add(d),
  30256. g = c.tan * c.removedLength,
  30257. m = c.prevDir.clone().add(c.nextDir).normalize(),
  30258. v = p.clone().lerp(f, 0.5),
  30259. y = p.distanceTo(f) / 2,
  30260. b = m
  30261. .clone()
  30262. .multiplyScalar(Math.sqrt(Math.pow(g, 2) - Math.pow(y, 2)))
  30263. .add(v),
  30264. x = m.clone().multiplyScalar(-g).add(b),
  30265. w = d.distanceTo(x) / d.distanceTo(v),
  30266. A = c.prevDir
  30267. .clone()
  30268. .multiplyScalar(w * d.distanceTo(p))
  30269. .add(d),
  30270. S = A.clone().lerp(x, 2),
  30271. _ = p.clone().lerp(A, 4 / 3),
  30272. M = f.clone().lerp(S, 4 / 3);
  30273. l[2 * u] = new $c(p, _, M, f);
  30274. }
  30275. let h = new yF();
  30276. return (
  30277. l.forEach((u) => {
  30278. u && h.add(u);
  30279. }),
  30280. h
  30281. );
  30282. }
  30283. var Ct;
  30284. ((e) => {
  30285. function t(i) {
  30286. return i && i.__isEntity;
  30287. }
  30288. e.is = t;
  30289. })(Ct || (Ct = {}));
  30290. var mn = (e) => Ct.is(e),
  30291. xF = { type: 'completeState', isfromEntity: !0 },
  30292. dA = (e) =>
  30293. class extends $g(e) {
  30294. constructor() {
  30295. super(...arguments),
  30296. (this.raycastLock = !1),
  30297. (this.scaleLock = !1),
  30298. (this.disposed = !1),
  30299. (this.stateSelection = null),
  30300. (this.instances = []),
  30301. (this.prevState = null),
  30302. (this.currentState = null),
  30303. (this.reversibleToState = null),
  30304. (this.currentTransitionEvent = null),
  30305. (this.previousAction = null),
  30306. (this._singleBBox = new mx()),
  30307. (this._recursiveBBox = new mx()),
  30308. (this.singleBBoxNeedsUpdate = !0),
  30309. (this.recursiveBBoxNeedsUpdate = !0),
  30310. (this._needApplyPathSnapping = !0),
  30311. (this.attachedPaths = new Set());
  30312. }
  30313. get __isEntity() {
  30314. return !0;
  30315. }
  30316. entityChildren(t) {
  30317. let i = this.children[t];
  30318. if (Ct.is(i)) return i;
  30319. }
  30320. get isConcreteEntity() {
  30321. return typeof this.identity == 'string';
  30322. }
  30323. get isVirtualEntity() {
  30324. return typeof this.identity != 'string';
  30325. }
  30326. get isInstanceRoot() {
  30327. return this.isConcreteEntity && this.data.type === 'Instance';
  30328. }
  30329. nearestInstanceSelfOrParent() {
  30330. let t = this;
  30331. for (; t.data.type !== 'Instance'; ) {
  30332. let i = t.parent;
  30333. if (Ct.is(i)) t = i;
  30334. else return;
  30335. }
  30336. return t;
  30337. }
  30338. forInstancesRec(t) {
  30339. this.instances.forEach((i) => {
  30340. i.disposed || t(i), i.forInstancesRec(t);
  30341. });
  30342. }
  30343. super_Entity(t, i) {
  30344. typeof t == 'string' && (this.uuid = t),
  30345. (this.identity = t),
  30346. (this.data = i),
  30347. (this.matrixAutoUpdate = !1),
  30348. (this.dataPatched = this.data);
  30349. }
  30350. changeSelectedState(t, i, r = !1) {
  30351. if (!(this.data.states.length === 0 && !r)) {
  30352. for (let s of this.data.states)
  30353. oa.toOps(this.data, s.data).forEach((n) => {
  30354. let a = im.replaceProps(n, this.data);
  30355. (this.dataPatched = this.data), this.updateByPatchedOp(a, this.data, i);
  30356. });
  30357. if (t !== null) {
  30358. let s = this.data.states.data(t);
  30359. s &&
  30360. ((this.dataPatched = oa.patch(this.data, s)),
  30361. oa.toOps(this.data, s).forEach((n) => {
  30362. this.updateByPatchedOp(n, this.dataPatched, i);
  30363. }));
  30364. }
  30365. r && this.updateTransformState(this.dataPatched),
  30366. (this.stateSelection = t),
  30367. this.updatePathSnapping(this.dataPatched.pathSnapping);
  30368. }
  30369. }
  30370. get singleBBox() {
  30371. return (
  30372. this.singleBBoxNeedsUpdate &&
  30373. ((this.singleBBoxNeedsUpdate = !1),
  30374. this._singleBBox.setFromObjectSize(this, !1),
  30375. this._singleBBox.computeVertices(),
  30376. this._singleBBox.computeEdges(),
  30377. this._singleBBox.computeFaces()),
  30378. this._singleBBox
  30379. );
  30380. }
  30381. get recursiveBBox() {
  30382. return (
  30383. this.recursiveBBoxNeedsUpdate &&
  30384. ((this.recursiveBBoxNeedsUpdate = !1),
  30385. this._recursiveBBox.setFromObjectSize(this, !0),
  30386. this._recursiveBBox.computeVertices(),
  30387. this._recursiveBBox.computeEdges(),
  30388. this._recursiveBBox.computeFaces()),
  30389. this._recursiveBBox
  30390. );
  30391. }
  30392. updateEntityBoxSize(t, i) {
  30393. t.setScalar(0), i.setScalar(0);
  30394. }
  30395. resetBBoxNeedsUpdateSelf() {
  30396. (this.singleBBoxNeedsUpdate = !0), (this.recursiveBBoxNeedsUpdate = !0);
  30397. }
  30398. resetBBoxNeedsUpdate() {
  30399. this.resetBBoxNeedsUpdateSelf(),
  30400. this.traverseAncestors((t) => {
  30401. mn(t) && t.resetBBoxNeedsUpdateSelf();
  30402. }),
  30403. this.traverseEntity((t) => {
  30404. t.resetBBoxNeedsUpdateSelf();
  30405. });
  30406. }
  30407. find(t) {
  30408. let i;
  30409. return (
  30410. this.traverseEntity((r) => {
  30411. r.uuid === t && (i = r);
  30412. }),
  30413. i
  30414. );
  30415. }
  30416. traverseSortNextHelper() {
  30417. let t = this.parent;
  30418. if (t) {
  30419. let i = t.children,
  30420. r = i.indexOf(this) + 1;
  30421. if (Ct.is(i[r])) return i[r];
  30422. if (Ct.is(t)) return t.traverseSortNextHelper();
  30423. }
  30424. }
  30425. sortNext() {
  30426. let t = this.children;
  30427. return this.children.length > 0 && Ct.is(this.children[0]) ? t[0] : this.traverseSortNextHelper();
  30428. }
  30429. goUp(t) {
  30430. let i = this;
  30431. for (; t > 0 && i !== null; ) (i = i.parent), (t -= 1);
  30432. return i;
  30433. }
  30434. hasAnccestorOrSelf(t) {
  30435. return this === t || this.hasAnccestor(t);
  30436. }
  30437. hasAnccestor(t) {
  30438. let i = this.parent;
  30439. for (; i; ) {
  30440. if (t === i) return !0;
  30441. i = i.parent;
  30442. }
  30443. return !1;
  30444. }
  30445. countToAccestor(t) {
  30446. let i = 0,
  30447. r = this;
  30448. for (; r !== t; ) {
  30449. if (r === null) return -1;
  30450. (r = r.parent), (i += 1);
  30451. }
  30452. return i;
  30453. }
  30454. forEachEntity(t) {
  30455. for (let i of this.children) mn(i) && t(i);
  30456. }
  30457. traverseEntityAncestors(t) {
  30458. this.traverseAncestors((i) => {
  30459. Ct.is(i) && t(i);
  30460. });
  30461. }
  30462. traverseEntity(t, i = 0) {
  30463. if (t(this, i) !== !0) for (let r of this.children) mn(r) && r.traverseEntity(t, i + 1);
  30464. }
  30465. traverseVisibleEntity(t) {
  30466. t(this);
  30467. for (let i of this.children) mn(i) && i.visible && i.traverseVisibleEntity(t);
  30468. }
  30469. updateMatrix() {
  30470. super.updateMatrix(), this.cloner && this.cloner.onObjUpdateMatrix(), this.dispatchEvent({ type: 'updateMatrix' });
  30471. }
  30472. copy(t, i = !0) {
  30473. return (
  30474. super.copy(t, !1),
  30475. (this.raycastLock = t.raycastLock),
  30476. (this.scaleLock = t.scaleLock),
  30477. this.hiddenMatrix.copy(t.hiddenMatrix),
  30478. this
  30479. );
  30480. }
  30481. hasEntityChild() {
  30482. return this.children.some((t) => mn(t));
  30483. }
  30484. isAncestorOf(t) {
  30485. if (this.uuid === t) return !1;
  30486. let i = !1;
  30487. return (
  30488. this.traverseEntity((r) => {
  30489. r.uuid === t && (i = !0);
  30490. }),
  30491. i
  30492. );
  30493. }
  30494. toObjectTransformState(t = []) {
  30495. this.updateWorldMatrix(!0, !1);
  30496. let i = {
  30497. position: this.position.toArray(),
  30498. rotation: [this.rotation.x, this.rotation.y, this.rotation.z],
  30499. scale: this.scale.toArray(),
  30500. hiddenMatrix: this.hiddenMatrix.toArray()
  30501. };
  30502. return tm(i, t);
  30503. }
  30504. updateTransformState(t) {
  30505. let i = !1;
  30506. return (
  30507. t.position && (this.position.fromArray(t.position), (i = !0)),
  30508. t.rotation && (this.rotation.fromArray(t.rotation), (i = !0)),
  30509. t.scale && ((i = !0), this.scale.fromArray(t.scale)),
  30510. t.hiddenMatrix !== void 0 && ((i = !0), this.hiddenMatrix.fromArray(t.hiddenMatrix ?? ko.identity)),
  30511. i &&
  30512. (this.updateMatrix(),
  30513. this.resetBBoxNeedsUpdate(),
  30514. this.invalidateClonerTransform(this),
  30515. this.traverseEntityAncestors((r) => {
  30516. r.invalidateClonerTransform(this);
  30517. })),
  30518. t.position && t.rotation && t.scale && t.hiddenMatrix !== void 0 && this.updateWorldMatrix(!1, !0),
  30519. i
  30520. );
  30521. }
  30522. dispose() {
  30523. (this.disposed = !0), this.cloner && (this.cloner.removeFromParent(), (this.cloner = void 0));
  30524. }
  30525. disposeChildrenRecursively() {
  30526. for (let t of this.children) Ct.is(t) && t.disposeRecursively();
  30527. }
  30528. disposeRecursively() {
  30529. this.dispose(),
  30530. this.children.forEach((t) => {
  30531. Ct.is(t) && t.disposeRecursively();
  30532. });
  30533. }
  30534. toState(t = []) {
  30535. let i = { name: this.name, visible: this.visible, raycastLock: this.raycastLock, ...this.toObjectTransformState(t) };
  30536. return tm(i, t);
  30537. }
  30538. updateByOp(t, i, r, s) {
  30539. let n = this.data;
  30540. this.data = i;
  30541. let a = t,
  30542. o = pn(t.path, ['states', '*']);
  30543. if (o !== null) {
  30544. if (t.type === 0) {
  30545. let [l] = o;
  30546. if (this?.stateSelection === l) {
  30547. let h = { ...t.props };
  30548. if (Object.values(t.props).some((u) => u === void 0)) {
  30549. let u = this.data;
  30550. if (u !== void 0) {
  30551. let c = fs.zoom(u, t.path.slice(2));
  30552. if (c) for (let d in t.props) t.props[d] === void 0 && d in c && (h[d] = c[d]);
  30553. }
  30554. }
  30555. a = { ...t, props: h, path: t.path.slice(2) };
  30556. }
  30557. }
  30558. } else if (t.type === 0) {
  30559. let l = this.stateSelection ? this.data.states.data(this.stateSelection) : void 0;
  30560. if (l !== void 0) {
  30561. if (t.props.name !== void 0 && l.name) {
  30562. let { name: u, ...c } = l;
  30563. l = c;
  30564. }
  30565. if (t.props.material !== void 0 && 'material' in l) {
  30566. let { material: u, ...c } = l;
  30567. l = c;
  30568. }
  30569. let h = fs.removeOverridden(t.path, t.props, l);
  30570. a = { ...t, props: h };
  30571. }
  30572. }
  30573. if (
  30574. (this.updateByPatchedOpBase(a, oa.patch(this.data, this.stateSelection ? this.data.states.data(this.stateSelection) : void 0), r),
  30575. pn(t.path, ['overrides']))
  30576. ) {
  30577. let l = [],
  30578. h = [...t.path];
  30579. for (l.push(h[1]), h.splice(0, 2); h.length > 0 && h[0] === 'descendants'; ) l.push(h[1]), h.splice(0, 2);
  30580. if (l[l.length - 1] === void 0) {
  30581. if (t.type === 0)
  30582. for (let u of Object.keys(t.props)) {
  30583. l[l.length - 1] = u;
  30584. let c = r.scene.findInstance([this.uuid, ...l]);
  30585. c && ((c.overrideData = t.props[u]), c.updateState(fa.apply(c.component.data, c.overrideData), r));
  30586. }
  30587. } else {
  30588. let u = r.scene.findInstance([this.uuid, ...l]);
  30589. if (u) {
  30590. let c = fs.zoom(u.component.data, h);
  30591. if (((t = { ...t, path: h }), t.type === 0)) {
  30592. let d = t.props;
  30593. if (c) for (let [p, f] of Object.entries(t.props)) f === void 0 && (d === t.props && (d = { ...t.props }), (d[p] = c[p]));
  30594. t = { ...t, props: d };
  30595. }
  30596. (u.overrideData = Fd.resolve(i.overrides, l)), u.updateByOp(t, ir.applySimple(u.data, t), r, !1);
  30597. }
  30598. }
  30599. } else if (this.instances.length > 0) {
  30600. let l;
  30601. if (t.path.length === 0 && t.type === 0) {
  30602. let h;
  30603. for (let u of Go.rootOverrideProps) u in t.props && (h === void 0 && (h = {}), (h[u] = t.props[u]));
  30604. h && (l = { ...t, props: h });
  30605. } else
  30606. for (let h of Go.rootOverrideProps)
  30607. if (pn(t.path, [h])) {
  30608. l = t;
  30609. break;
  30610. }
  30611. l !== void 0 &&
  30612. this.instances.forEach((h) => {
  30613. if (h.isInstanceRoot) {
  30614. let u = fa.filterOp(h.overrideData, l);
  30615. u && h.updateByOp(u, ir.applySimple(h.data, u), r, !0);
  30616. }
  30617. }),
  30618. this.instances.forEach((h) => {
  30619. if (!h.isInstanceRoot) {
  30620. let u = fa.filterOp(h.overrideData, t);
  30621. if (u) {
  30622. let c;
  30623. n === h.data && t === u ? (c = i) : (c = ir.applySimple(h.data, u)), h.updateByOp(u, c, r, !0);
  30624. }
  30625. }
  30626. });
  30627. }
  30628. }
  30629. updateByPatchedOpBase(t, i, r) {
  30630. if (((this.dataPatched = i), t.path.length === 0 && t.type === 0))
  30631. t.props.type !== void 0 && !_a.is(t.props.type) && wn.changeEntityProptotype(this, i, r);
  30632. else if (t.path.length === 1 && t.path[0] === 'geometry' && t.type === 0 && 'type' in t.props) {
  30633. wn.changeEntityProptotype(this, i, r);
  30634. for (let s of this.children) Ct.is(s) && s.updateVisible();
  30635. }
  30636. this.updateByPatchedOp(t, i, r);
  30637. }
  30638. updateByPatchedOp(t, i, r) {
  30639. if (
  30640. (t.path.length === 0 && t.type === 0 && this.updateState(t.props, r),
  30641. pn(t.path, ['pathSnapping']) !== null && this.updatePathSnapping(i.pathSnapping),
  30642. pn(t.path, ['cloner']) !== null)
  30643. ) {
  30644. let s = ir.drop(t, 1);
  30645. s.path.length === 0 && s.type === 0 && s.props.disabled === !0
  30646. ? this.setFromClonerState(null, r)
  30647. : this.cloner
  30648. ? this.cloner.updateState(i.cloner, r.scene)
  30649. : (this.setFromClonerState(i.cloner, r), this.expandCloner(r.scene)),
  30650. this.updateVisible();
  30651. }
  30652. }
  30653. updatePathSnapping(t) {
  30654. (this._updatedPathSnapping = t), (this._needApplyPathSnapping = !0);
  30655. }
  30656. applyPathSnapping(t) {
  30657. let i = this._updatedPathSnapping?.pathId ?? this.dataPatched.pathSnapping.pathId,
  30658. r = this._updatedPathSnapping?.slide ?? this.dataPatched.pathSnapping.slide,
  30659. s = this._updatedPathSnapping?.offset ?? this.dataPatched.pathSnapping.offset,
  30660. n = this._updatedPathSnapping?.orientation ?? this.dataPatched.pathSnapping.orientation;
  30661. if (i === null) return;
  30662. let a = t.find(i);
  30663. if (!a || this._needApplyPathSnapping === !1) return;
  30664. this._needApplyPathSnapping = !1;
  30665. let o = a.data,
  30666. l = cA(o.geometry.path),
  30667. h = (r + s) % 1,
  30668. u = l.getPointAt(h),
  30669. c = this.parent ? this.parent?.matrixWorld : new ve();
  30670. a.updateMatrixWorld();
  30671. let d = new ve().multiplyMatrices(c.clone().invert(), a.matrixWorld);
  30672. u.applyMatrix4(d);
  30673. let p = { position: u.toArray(), rotation: o.rotation };
  30674. if (n === 'tangential') {
  30675. let f = new ve().extractRotation(a.matrixWorld),
  30676. g = l.getTangentAt(h).applyMatrix4(f).add(u),
  30677. m = new ve().lookAt(u, g, new E(0, 1, 0)),
  30678. v = new _i().setFromRotationMatrix(m);
  30679. p = { ...p, rotation: [v.x, v.y, v.z] };
  30680. }
  30681. this.updateTransformState(p),
  30682. this.traverseEntity((f) => {
  30683. f._cameraType && f.dispatchEvent(xF);
  30684. });
  30685. }
  30686. updateVisible() {
  30687. this.visible =
  30688. this.dataPatched.visible &&
  30689. (!this.dataPatched.cloner || (this.dataPatched.cloner.disabled ?? !1) || this.dataPatched.cloner?.hideBase !== !0);
  30690. }
  30691. updateState_Entity(t, i) {
  30692. t.name !== void 0 && (this.name = t.name),
  30693. t.raycastLock !== void 0 && (this.raycastLock = t.raycastLock),
  30694. t.visible !== void 0 && (this.updateVisible(), this.resetBBoxNeedsUpdate()),
  30695. 'cloner' in t && t.cloner !== void 0 && (this.setFromClonerState(t.cloner, i), this.updateVisible()),
  30696. this.updateTransformState(t);
  30697. }
  30698. get attachedSurfaceCloners() {
  30699. return this.children.filter((t) => t instanceof wn.Cloner && t.parameters.type === 'toObject');
  30700. }
  30701. setFromClonerState(t, i) {
  30702. this.disposed ||
  30703. (t === null || t.disabled
  30704. ? (this.cloner && this.cloner.removeFromParent(), (this.cloner = void 0))
  30705. : this.cloner === void 0
  30706. ? ((this.cloner = new wn.Cloner(this, t)), i.scene.addPendingExpandCloner(this))
  30707. : this.cloner.updateState(t, i.scene));
  30708. }
  30709. expandCloner(t) {
  30710. !this.disposed && this.cloner && this.cloner.expandClones(t);
  30711. }
  30712. invalidateClonerTransform(t) {
  30713. this.cloner && this.cloner.invalidateTransform(t);
  30714. }
  30715. },
  30716. bF = class {
  30717. static create(e) {
  30718. return this.build(this.normalizeInputs(e));
  30719. }
  30720. static normalizeInputs(e, t) {
  30721. let i = Object.assign(
  30722. {},
  30723. t?.parameters ?? {
  30724. width: 100,
  30725. radialSegments: 64,
  30726. heightSegments: 1,
  30727. openEnded: !1,
  30728. thetaStart: 0,
  30729. thetaLength: 360,
  30730. cornerRadius: 8,
  30731. cornerSegments: 8,
  30732. hollow: 0
  30733. },
  30734. e.parameters
  30735. ),
  30736. r = i.width / 2,
  30737. s = i.radiusTop ?? r,
  30738. n = i.radiusBottom ?? r;
  30739. return (
  30740. s === n ? ((s = r), (n = r)) : s > n ? ((s = r), (n = (n * r) / s)) : ((s = (s * r) / n), (n = r)),
  30741. {
  30742. parameters: Object.assign(i, {
  30743. width: Math.abs(i.width),
  30744. height: Math.abs(i.height ?? i.width),
  30745. depth: Math.abs(i.depth ?? i.width),
  30746. radiusTop: s,
  30747. radiusBottom: n
  30748. })
  30749. }
  30750. );
  30751. }
  30752. static build(e) {
  30753. let {
  30754. width: t,
  30755. depth: i,
  30756. height: r,
  30757. radialSegments: s,
  30758. heightSegments: n,
  30759. openEnded: a,
  30760. thetaStart: o,
  30761. thetaLength: l,
  30762. radiusTop: h,
  30763. radiusBottom: u,
  30764. cornerRadius: c,
  30765. cornerSegments: d,
  30766. hollow: p
  30767. } = e.parameters,
  30768. f;
  30769. return (
  30770. c || p
  30771. ? (f = new uA(h, u, r, s, n, a, o, (l * Math.PI) / 180, c, c, d, p))
  30772. : (f = new gg(h, u, r, s, n, a, o, (l * Math.PI) / 180)),
  30773. f.scale(1, 1, i / t),
  30774. Object.assign(f, { userData: { ...e, type: 'CylinderGeometry' } })
  30775. );
  30776. }
  30777. };
  30778. function sn(e, t, i) {
  30779. (i.x = e.x * t.x), (i.y = e.y), (i.z = e.x * t.y);
  30780. }
  30781. function gx(e) {
  30782. return new G(e.y, -e.x);
  30783. }
  30784. var uA = class extends Ve {
  30785. constructor(e, t, i, r, s, n, a, o, l, h, u, c, d = !1) {
  30786. super(),
  30787. (this.type = 'RoundedCylinderBufferGeometry'),
  30788. (e = e !== void 0 ? e : 1),
  30789. (t = t !== void 0 ? t : 1),
  30790. (i = i || 1),
  30791. (r = Math.floor(r) || 8),
  30792. (s = Math.floor(s) || 1),
  30793. (n = n !== void 0 ? n : !1),
  30794. (a = a !== void 0 ? a : 0),
  30795. (o = o !== void 0 ? o : Math.PI * 2),
  30796. n && ((l = 0), (h = 0));
  30797. let p = [],
  30798. f = [],
  30799. g = [],
  30800. m = [],
  30801. v = 0,
  30802. y = i / 2,
  30803. b = new E(),
  30804. x = new E();
  30805. d && e == 0 && (e = l), d && t == 0 && (t = h);
  30806. let w = new G(e, y),
  30807. A = new G(t, -y),
  30808. S = null,
  30809. _ = null,
  30810. M = null,
  30811. C = null,
  30812. T = w.clone().sub(A),
  30813. P = 0,
  30814. L = 0,
  30815. D = 0;
  30816. c > 0 && ((P = Math.min(e, t) * (1 - c)), (L = e - P), (D = t - P));
  30817. let k = w.clone();
  30818. k.x -= P;
  30819. let W = Math.PI - T.angle(),
  30820. X = T.angle(),
  30821. z = Math.tan(X / 2),
  30822. j = Math.tan(W / 2),
  30823. U = z + j,
  30824. N = c ? U : j,
  30825. B = c ? U : z;
  30826. if (((l = Math.min(l, (e - L) / N, T.length() / U)), (h = Math.min(h, (t - D) / B, T.length() / U)), l > 0)) {
  30827. let V = l / z;
  30828. (S = w.clone().sub(new G(V, l))), c && ((M = S.clone()), (M.x -= P - U * l)), w.sub(T.clone().setLength(V));
  30829. }
  30830. if (h > 0) {
  30831. let V = h / j;
  30832. (_ = A.clone().sub(new G(V, -h))),
  30833. A.add(T.clone().setLength(V)),
  30834. c && ((C = _.clone()), (C.x -= P - U * h), k.sub(T.clone().setLength(V)));
  30835. }
  30836. T = w.clone().sub(A);
  30837. let H = T.length() < 0.5,
  30838. Q = [];
  30839. for (let V = 0; V <= r; V++) {
  30840. let ee = [],
  30841. J = V / r,
  30842. fe = J * o + a,
  30843. re = new G(Math.sin(fe), Math.cos(fe));
  30844. C && _
  30845. ? (Y(ee, J, re, W, h, C, -1, !0), Y(ee, J, re, X, h, _, -1, !1))
  30846. : _
  30847. ? (F(ee, re, _.x, 0, -1), Y(ee, J, re, X, h, _, -1, !1))
  30848. : n || F(ee, re, t, D, -1);
  30849. let oe = gx(T).normalize();
  30850. if ((sn(oe, re, b), !H))
  30851. for (let ue = 0; ue <= s; ue++) {
  30852. let ye = ue / s,
  30853. Te = T.clone().multiplyScalar(ye).add(A);
  30854. sn(Te, re, x), f.push(x.x, x.y, x.z), g.push(b.x, b.y, b.z), m.push(J, 0.5 + x.y / i), ee.push(v++);
  30855. }
  30856. if (
  30857. (M && S
  30858. ? (Y(ee, J, re, W, l, S, 1, !1), Y(ee, J, re, X, l, M, 1, !0))
  30859. : S
  30860. ? (Y(ee, J, re, W, l, S, 1, !1), F(ee, re, S.x, 0, 1))
  30861. : n || F(ee, re, e, L, 1),
  30862. c && !H)
  30863. ) {
  30864. let ue = gx(T).multiplyScalar(-1).normalize();
  30865. sn(ue, re, b);
  30866. for (let ye = 0; ye <= s; ye++) {
  30867. let Te = ye / s,
  30868. xe = T.clone().multiplyScalar(-Te).add(k);
  30869. sn(xe, re, x), f.push(x.x, x.y, x.z), g.push(b.x, b.y, b.z), m.push(J, 0.5 + x.y / i), ee.push(v++);
  30870. }
  30871. }
  30872. c && !n && ee.push(ee[0]), Q.push(ee);
  30873. }
  30874. for (let V = 0; V < Q.length - 1; V++)
  30875. for (let ee = 0; ee < Q[0].length - 1; ee++) {
  30876. if (n && c && ee == s) continue;
  30877. let J = Q[V][ee],
  30878. fe = Q[V + 1][ee],
  30879. re = Q[V + 1][ee + 1],
  30880. oe = Q[V][ee + 1],
  30881. ue = f[re * 3 + 0],
  30882. ye = f[re * 3 + 2];
  30883. p.push(J, fe, oe), (ue != 0 || ye != 0) && p.push(fe, re, oe);
  30884. }
  30885. o < Math.PI * 2 && (se(-1, Q[0], a), se(1, Q[Q.length - 1], a + o)),
  30886. this.setIndex(p),
  30887. this.setAttribute('position', new Ce(f, 3)),
  30888. this.setAttribute('normal', new Ce(g, 3)),
  30889. this.setAttribute('uv', new Ce(m, 2));
  30890. function Y(V, ee, J, fe, re, oe, ue, ye) {
  30891. for (let Te = 0; Te < u + 1; Te++) {
  30892. let xe = Te / u,
  30893. we = ue < 0 ? xe : 1 - xe;
  30894. ye && (we -= 1), (we *= fe);
  30895. let Ie = new G(Math.sin(we), Math.cos(we) * ue),
  30896. He = Ie.clone().multiplyScalar(re).add(oe);
  30897. sn(He, J, x), f.push(x.x, x.y, x.z), sn(Ie, J, b), g.push(b.x, b.y, b.z), m.push(ee, 0.5 + x.y / i), V.push(v++);
  30898. }
  30899. }
  30900. function F(V, ee, J, fe, re) {
  30901. let oe = new E(),
  30902. ue = new G(),
  30903. ye = [J, fe];
  30904. re < 0 && ye.reverse();
  30905. for (let Te of ye) ue.set(Te, y * re), sn(ue, ee, oe), f.push(oe.x, oe.y, oe.z), g.push(0, re, 0), m.push(0.5, 0.5), V.push(v++);
  30906. }
  30907. function se(V, ee, J) {
  30908. let fe = new G(Math.sin(J), Math.cos(J)),
  30909. re = new G(-Math.cos(J), Math.sin(J)),
  30910. oe = new E(),
  30911. ue = V < 0 ? (xe, we, Ie) => p.push(xe, we, Ie) : (xe, we, Ie) => p.push(xe, Ie, we),
  30912. ye = new G((e + t + L + D) / 4, 0);
  30913. sn(ye, fe, oe), f.push(oe.x, oe.y, oe.z), g.push(re.x, 0, re.y), m.push(0.5, 0.5);
  30914. let Te = v++;
  30915. for (let xe of ee) {
  30916. let we = f.slice(xe * 3, xe * 3 + 3);
  30917. f.push(...we), g.push(re.x, 0, re.y);
  30918. let Ie = m.slice(xe * 2, xe * 2 + 2);
  30919. m.push(...Ie), v++;
  30920. }
  30921. for (let xe = Te + 1; xe < v - 1; xe++) ue(Te, xe, xe + 1);
  30922. ue(Te, v - 1, Te + 1);
  30923. }
  30924. }
  30925. },
  30926. wF = class {
  30927. static create(e) {
  30928. return this.build(this.normalizeInputs(e));
  30929. }
  30930. static normalizeInputs(e, t) {
  30931. let i = Object.assign(
  30932. {},
  30933. t?.parameters ?? {
  30934. width: 100,
  30935. radialSegments: 32,
  30936. heightSegments: 8,
  30937. openEnded: !1,
  30938. thetaStart: 0,
  30939. thetaLength: 360,
  30940. cornerRadiusTop: 8,
  30941. cornerRadiusBottom: 8,
  30942. cornerSegments: 8
  30943. },
  30944. e.parameters
  30945. );
  30946. return {
  30947. parameters: Object.assign(i, {
  30948. width: Math.abs(i.width),
  30949. height: Math.abs(i.height ?? i.width),
  30950. depth: Math.abs(i.depth ?? i.width)
  30951. })
  30952. };
  30953. }
  30954. static build(e) {
  30955. let {
  30956. width: t,
  30957. depth: i,
  30958. height: r,
  30959. radialSegments: s,
  30960. heightSegments: n,
  30961. openEnded: a,
  30962. thetaStart: o,
  30963. thetaLength: l,
  30964. cornerRadiusTop: h,
  30965. cornerRadiusBottom: u,
  30966. cornerSegments: c
  30967. } = e.parameters,
  30968. d;
  30969. return (
  30970. h > 0 || u > 0 || l < 360
  30971. ? (d = new uA(0, t / 2, r, s, n, a, o, (l * Math.PI) / 180, h, u, c, 0, !0))
  30972. : (d = new Pw(t / 2, r, s, n, a)),
  30973. d.scale(1, 1, i / t),
  30974. Object.assign(d, { userData: { ...e, type: 'ConeGeometry' } })
  30975. );
  30976. }
  30977. },
  30978. _F = class {
  30979. static create(e) {
  30980. return this.build(this.normalizeInputs(e));
  30981. }
  30982. static normalizeInputs(e, t) {
  30983. let i = Object.assign(
  30984. {},
  30985. t?.parameters ?? { width: 100, widthSegments: 1, heightSegments: 1, depthSegments: 1, cornerRadius: 8, cornerSegments: 8 },
  30986. e.parameters
  30987. );
  30988. return {
  30989. parameters: Object.assign(i, {
  30990. width: Math.abs(i.width),
  30991. height: Math.abs(i.height ?? i.width),
  30992. depth: Math.abs(i.depth ?? i.width)
  30993. })
  30994. };
  30995. }
  30996. static build(e) {
  30997. let {
  30998. width: t,
  30999. height: i,
  31000. depth: r,
  31001. widthSegments: s,
  31002. heightSegments: n,
  31003. depthSegments: a,
  31004. cornerRadius: o,
  31005. cornerSegments: l
  31006. } = e.parameters,
  31007. h;
  31008. return (
  31009. o == 0 ? (h = new vs(t, i, r, s, n, a)) : (h = new AF(t, i, r, s, n, a, o, l)),
  31010. Object.assign(h, { userData: { ...e, type: 'CubeGeometry' } })
  31011. );
  31012. }
  31013. },
  31014. Xp = Math.PI / 2,
  31015. AF = class extends Ve {
  31016. constructor(e = 1, t = 1, i = 1, r = 1, s = 1, n = 1, a = 0, o = 4) {
  31017. super(), (this.type = 'BoxGeometry');
  31018. let l = this;
  31019. (r = Math.floor(r)), (s = Math.floor(s)), (n = Math.floor(n)), (o = Math.floor(o)), (a = Math.min(a, e / 2, t / 2, i / 2));
  31020. let h = [],
  31021. u = [],
  31022. c = [],
  31023. d = [],
  31024. p = 0,
  31025. f = 0;
  31026. g('z', 'y', 'x', -1, -1, i, t, e, n, s, 0),
  31027. g('z', 'y', 'x', 1, -1, i, t, -e, n, s, 1),
  31028. g('x', 'z', 'y', 1, 1, e, i, t, r, n, 2),
  31029. g('x', 'z', 'y', 1, -1, e, i, -t, r, n, 3),
  31030. g('x', 'y', 'z', 1, -1, e, t, i, r, s, 4),
  31031. g('x', 'y', 'z', -1, -1, e, t, -i, r, s, 5),
  31032. a > 0 &&
  31033. (m('z', 'y', 'x', -1, -1, 1, i, t, e, n, 0),
  31034. m('z', 'y', 'x', 1, -1, -1, i, t, e, n, 1),
  31035. m('z', 'y', 'x', -1, 1, -1, i, t, e, n, 1),
  31036. m('z', 'y', 'x', 1, 1, 1, i, t, e, n, 0),
  31037. m('x', 'y', 'z', -1, -1, -1, e, t, i, r, 0),
  31038. m('x', 'y', 'z', 1, -1, 1, e, t, i, r, 1),
  31039. m('x', 'y', 'z', -1, 1, 1, e, t, i, r, 0),
  31040. m('x', 'y', 'z', 1, 1, -1, e, t, i, r, 1),
  31041. m('y', 'x', 'z', -1, -1, 1, t, e, i, s, 0),
  31042. m('y', 'x', 'z', 1, -1, -1, t, e, i, s, 1),
  31043. m('y', 'x', 'z', 1, 1, 1, t, e, i, s, 1),
  31044. m('y', 'x', 'z', -1, 1, -1, t, e, i, s, 0),
  31045. v(1, 1, 1),
  31046. v(-1, 1, 1),
  31047. v(1, -1, 1),
  31048. v(-1, -1, 1),
  31049. v(1, 1, -1),
  31050. v(-1, 1, -1),
  31051. v(1, -1, -1),
  31052. v(-1, -1, -1)),
  31053. this.setIndex(h),
  31054. this.setAttribute('position', new Ce(u, 3)),
  31055. this.setAttribute('normal', new Ce(c, 3)),
  31056. this.setAttribute('uv', new Ce(d, 2));
  31057. function g(y, b, x, w, A, S, _, M, C, T, P) {
  31058. let L = (S - 2 * a) / C,
  31059. D = (_ - 2 * a) / T,
  31060. k = S / 2 - a,
  31061. W = _ / 2 - a,
  31062. X = M / 2,
  31063. z = C + 1,
  31064. j = T + 1,
  31065. U = 0,
  31066. N = 0,
  31067. B = new E();
  31068. for (let H = 0; H < j; H++) {
  31069. let Q = H * D - W;
  31070. for (let Y = 0; Y < z; Y++) {
  31071. let F = Y * L - k;
  31072. (B[y] = F * w),
  31073. (B[b] = Q * A),
  31074. (B[x] = X),
  31075. u.push(B.x, B.y, B.z),
  31076. (B[y] = 0),
  31077. (B[b] = 0),
  31078. (B[x] = M > 0 ? 1 : -1),
  31079. c.push(B.x, B.y, B.z),
  31080. d.push(Y / C),
  31081. d.push(1 - H / T),
  31082. (U += 1);
  31083. }
  31084. }
  31085. for (let H = 0; H < T; H++)
  31086. for (let Q = 0; Q < C; Q++) {
  31087. let Y = p + Q + z * H,
  31088. F = p + Q + z * (H + 1),
  31089. se = p + (Q + 1) + z * (H + 1),
  31090. V = p + (Q + 1) + z * H;
  31091. h.push(Y, F, V), h.push(F, se, V), (N += 6);
  31092. }
  31093. l.addGroup(f, N, P), (f += N), (p += U);
  31094. }
  31095. function m(y, b, x, w, A, S, _, M, C, T, P) {
  31096. let L = (_ - 2 * a) / T,
  31097. D = _ / 2 - a,
  31098. k = M / 2 - a,
  31099. W = C / 2,
  31100. X = T + 1,
  31101. z = 0,
  31102. j = 0,
  31103. U = new E(),
  31104. N = new E();
  31105. for (let B = 0; B < o + 1; B++) {
  31106. let H = (B / o) * Xp,
  31107. Q = Math.sin(H) * a,
  31108. Y = (1 - Math.cos(H)) * a,
  31109. F = Math.sin(H),
  31110. se = Math.cos(H);
  31111. (U[b] = (k + Q) * A), (U[x] = (W - Y) * S), (N[y] = 0), (N[b] = F * Math.sign(U[b])), (N[x] = se * Math.sign(U[x]));
  31112. for (let V = 0; V < X; V++) {
  31113. let ee = V * L - D;
  31114. (U[y] = ee * w), u.push(U.x, U.y, U.z), c.push(N.x, N.y, N.z), d.push(V / T), d.push(0), (z += 1);
  31115. }
  31116. }
  31117. for (let B = 0; B < o; B++)
  31118. for (let H = 0; H < T; H++) {
  31119. let Q = p + H + X * B,
  31120. Y = p + H + X * (B + 1),
  31121. F = p + (H + 1) + X * (B + 1),
  31122. se = p + (H + 1) + X * B;
  31123. h.push(Q, Y, se), h.push(Y, F, se), (j += 6);
  31124. }
  31125. l.addGroup(f, j, P), (f += j), (p += z);
  31126. }
  31127. function v(y, b, x) {
  31128. let w = new E(),
  31129. A = new E(e / 2, t / 2, i / 2);
  31130. A.subScalar(a);
  31131. let S = [],
  31132. _ = y * b * x > 0 ? (C, T, P) => h.push(C, T, P) : (C, T, P) => h.push(C, P, T);
  31133. for (let C = 0; C <= o; C++) {
  31134. let T = [],
  31135. P = Xp * (1 - C / o),
  31136. L = Math.cos(P),
  31137. D = Math.sin(P),
  31138. k = 0;
  31139. for (let W = 0; W <= C; W++) {
  31140. let X = Math.cos(k),
  31141. z = Math.sin(k);
  31142. (w.x = L * X), (w.y = D), (w.z = L * z);
  31143. let j = A.clone().addScaledVector(w, a);
  31144. u.push(y * j.x, b * j.y, x * j.z), c.push(y * w.x, b * w.y, x * w.z), d.push(0, 0), T.push(p++), (k += Xp / C);
  31145. }
  31146. S.push(T);
  31147. }
  31148. let M = S.length - 1;
  31149. for (let C = 0; C < M; C++) {
  31150. let T = S[C],
  31151. P = S[C + 1],
  31152. L = T.length - 1;
  31153. _(T[0], P[1], P[0]);
  31154. for (let D = 1; D <= L; D++) _(T[D - 1], T[D], P[D]), _(T[D], P[D + 1], P[D]);
  31155. }
  31156. }
  31157. }
  31158. },
  31159. ev = class extends Ve {
  31160. constructor(e = [], t = [], i = '', r = 1, s = 0.2, n = 4) {
  31161. super(), (this.type = 'PolyhedronGeometryRound');
  31162. let a = [],
  31163. o = [],
  31164. l = [];
  31165. h(),
  31166. u(),
  31167. this.setAttribute('position', new Ce(a, 3)),
  31168. this.setAttribute('normal', new Ce(l, 3)),
  31169. this.setAttribute('uv', new Ce(o, 2));
  31170. return;
  31171. function h() {
  31172. (s = Math.min(1 - 1e-5, s)), s == 0 && (n = 0);
  31173. let c = { IcosahedronGeometry: 5, DodecahedronGeometry: 3, HexahedronGeometry: 3, OctahedronGeometry: 4, TetrahedronGeometry: 3 }[
  31174. i
  31175. ],
  31176. d = new E(),
  31177. p = d.clone(),
  31178. f = new Bi(),
  31179. g = s * r,
  31180. m = r - g,
  31181. v = n + 1,
  31182. y = new E(),
  31183. b = (X, z) => y.subVectors(X, z).normalize(),
  31184. x = (X, z) =>
  31185. Array(X)
  31186. .fill(void 0)
  31187. .map(z),
  31188. w = x(e.length / 3, (X, z) => new E().fromArray(e, z * 3).setLength(r)),
  31189. A = [],
  31190. S = 1e6;
  31191. for (let X = 0; X < w.length; X++) {
  31192. let z = w[X],
  31193. j = [],
  31194. U,
  31195. N,
  31196. B,
  31197. H = 1e10,
  31198. Q = -1;
  31199. for (; (Q = t.indexOf(X, Q + 1)) != -1; ) {
  31200. let V = Q - (Q % 3);
  31201. (U = t[V + ((Q + 1) % 3)]),
  31202. (N = t[V + ((Q + 2) % 3)]),
  31203. (B = z.distanceToSquared(w[U])),
  31204. (H = Math.min(H, B)),
  31205. j.push([U, N, B]);
  31206. }
  31207. H += 1e-6;
  31208. let Y = [],
  31209. F = 0,
  31210. se = j.length;
  31211. for (let V = 0; V < se; V++) {
  31212. [U, N, B] = j[F];
  31213. let ee = A[U]?.includes(X) == !0;
  31214. B <= H && Y.push(U + +ee * S), (F = j.findIndex((J) => J[0] == N));
  31215. }
  31216. A.push(Y);
  31217. }
  31218. let _ = [];
  31219. {
  31220. let X = 0,
  31221. z = 0,
  31222. j,
  31223. U,
  31224. N = c == 3;
  31225. for (let B = 0; B <= n; B++) {
  31226. (j = (B * (B + 1)) / 2), (U = ((B + 1) * (B + 2)) / 2);
  31227. for (let H = 0; H < n - B; H++)
  31228. ([X, z] = [j + H + B + 2, U + H + B + 3]), _.push(j, U, ...(N ? [z, j] : [X, U]), z, X), ([j, U] = [X, z]);
  31229. _.push(j, U, j + n + 2);
  31230. }
  31231. }
  31232. let M = d.clone(),
  31233. C = d.clone(),
  31234. T = d.clone(),
  31235. P = d.clone(),
  31236. L = d.clone(),
  31237. D = [],
  31238. k = x(w.length, () => x(c, () => d.clone()));
  31239. for (let X = 0; X < w.length; X++) {
  31240. d.copy(w[X]).normalize(), M.copy(d).multiplyScalar(m);
  31241. let z = A[X];
  31242. for (let Y = 0; Y < z.length; Y++) {
  31243. let F = z[Y],
  31244. se = z[(Y + 1) % c];
  31245. f.setFromPointsAndIndices(w, X, F % S, se % S),
  31246. f.b.sub(f.a).setLength(1e10).add(f.a),
  31247. f.c.sub(f.a).setLength(1e10).add(f.a),
  31248. f.closestPointToPoint(M, k[X][Y]);
  31249. }
  31250. let j = [],
  31251. U = [],
  31252. N = [],
  31253. B = new E();
  31254. n == 0 && [...k[X]].reduce((Y, F) => Y.add(F), B).multiplyScalar(1 / c);
  31255. for (let Y = 0; Y < c; Y++) {
  31256. let F = [],
  31257. se = (Y - 1 + c) % c,
  31258. V = k[X][se],
  31259. ee = k[X][Y];
  31260. d.copy(V).sub(M), p.copy(ee).sub(M);
  31261. let J = M.angleTo(d),
  31262. fe = d.angleTo(p),
  31263. re = Math.cos(J) * g;
  31264. n == 0 ? C.copy(B) : C.copy(M).setLength(m + re), U.push(re);
  31265. let oe = [C, V, ee];
  31266. for (let ue = 0; ue < 2; ue++) {
  31267. let ye = oe[ue],
  31268. Te = oe[ue + 1];
  31269. P.subVectors(ye, M), L.subVectors(Te, M), T.crossVectors(P, L).normalize();
  31270. for (let xe = 0; xe < v; xe++) {
  31271. let we = ([J, fe][ue] * xe) / v;
  31272. d.copy(P).applyAxisAngle(T, we).add(M), j.push(d.clone()), ue && (b(d, M), F.push([xe == 0 ? ye : d.clone(), y.clone()]));
  31273. }
  31274. ue && (b(Te, M), F.push([Te, y.clone()]));
  31275. }
  31276. N.push(F);
  31277. }
  31278. D.push(N);
  31279. let H = 2 * v,
  31280. Q = 2;
  31281. for (let Y = 0; Y < c; Y++) {
  31282. let F = H * Y,
  31283. se = H * ((Y + 1) % c),
  31284. V = [j[F]];
  31285. for (let J = 1; J < v; J++) {
  31286. (P = j[F + J]), (L = j[se + J]), V.push(P);
  31287. for (let fe = 1, re = J - Q + 1; fe <= re; fe++)
  31288. d.lerpVectors(P, L, fe / (re + 1)), d.sub(M).setLength(U[Y]).add(M), V.push(d.clone());
  31289. V.push(L);
  31290. }
  31291. for (let J = 0; J < v; J++) V.push(j[J + v + F]);
  31292. V.push(j[se + v]);
  31293. let ee = _.map((J) => V[J]);
  31294. a.push(...ee.map((J) => [J.x, J.y, J.z]).flat()), l.push(...ee.map((J) => (b(J, M), [y.x, y.y, y.z])).flat());
  31295. }
  31296. }
  31297. let W = [];
  31298. for (let X = 0; X < A.length; X++)
  31299. for (let z = 0; z < c; z++) {
  31300. let j = A[X][z];
  31301. if (j < S) {
  31302. let U = A[j].findIndex((H) => H % S == X),
  31303. N = D[X][z],
  31304. B = D[j][U];
  31305. for (let H = 0; H < v; H++) {
  31306. let Q = N[H],
  31307. Y = B[v - H],
  31308. F = N[H + 1],
  31309. se = B[v - (H + 1)];
  31310. [Q, Y, F, F, Y, se].forEach((V) => {
  31311. a.push(V[0].x, V[0].y, V[0].z), l.push(V[1].x, V[1].y, V[1].z);
  31312. });
  31313. }
  31314. W.push(N[0][0], B[v][0], N[v][0], B[0][0]);
  31315. }
  31316. }
  31317. for (; W.length; ) {
  31318. let X, z, j, U;
  31319. [X, z] = W.splice(0, 2);
  31320. let N = [X];
  31321. for (; X != z; ) N.push(z), (j = W.indexOf(z)), (U = j % 2), (z = W.splice(j - U, 2)[1 - U]);
  31322. y.subVectors(N[0], N[1]).cross(d.subVectors(N[0], N[2])).normalize();
  31323. let B = y.dot(N[0]) < 0;
  31324. B && y.negate();
  31325. for (let H = 1; H <= N.length - 2; H++)
  31326. [N[H + +B], N[H + 1 - +B], N[0]].forEach((Q) => {
  31327. a.push(Q.x, Q.y, Q.z), l.push(y.x, y.y, y.z);
  31328. });
  31329. }
  31330. }
  31331. function u() {
  31332. let c = new E();
  31333. for (let A = 0; A < a.length; A += 3) {
  31334. (c.x = a[A + 0]), (c.y = a[A + 1]), (c.z = a[A + 2]);
  31335. let S = x(c) / 2 / Math.PI + 0.5,
  31336. _ = w(c) / Math.PI + 0.5;
  31337. o.push(S, 1 - _);
  31338. }
  31339. let d = new E(),
  31340. p = new E(),
  31341. f = new E(),
  31342. g = new E(),
  31343. m = new G(),
  31344. v = new G(),
  31345. y = new G(),
  31346. b = (A, S, _, M) => {
  31347. M < 0 && A.x === 1 && (o[S] = A.x - 1), _.x === 0 && _.z === 0 && (o[S] = M / 2 / Math.PI + 0.5);
  31348. };
  31349. for (let A = 0, S = 0; A < a.length; A += 9, S += 6) {
  31350. d.set(a[A + 0], a[A + 1], a[A + 2]),
  31351. p.set(a[A + 3], a[A + 4], a[A + 5]),
  31352. f.set(a[A + 6], a[A + 7], a[A + 8]),
  31353. m.set(o[S + 0], o[S + 1]),
  31354. v.set(o[S + 2], o[S + 3]),
  31355. y.set(o[S + 4], o[S + 5]),
  31356. g.copy(d).add(p).add(f).divideScalar(3);
  31357. let _ = x(g);
  31358. b(m, S + 0, d, _), b(v, S + 2, p, _), b(y, S + 4, f, _);
  31359. }
  31360. for (let A = 0; A < o.length; A += 6) {
  31361. let S = o[A + 0],
  31362. _ = o[A + 2],
  31363. M = o[A + 4],
  31364. C = Math.max(S, _, M),
  31365. T = Math.min(S, _, M);
  31366. C > 0.9 && T < 0.1 && (S < 0.2 && (o[A + 0] += 1), _ < 0.2 && (o[A + 2] += 1), M < 0.2 && (o[A + 4] += 1));
  31367. }
  31368. function x(A) {
  31369. return Math.atan2(A.z, -A.x);
  31370. }
  31371. function w(A) {
  31372. return Math.atan2(-A.y, Math.sqrt(A.x * A.x + A.z * A.z));
  31373. }
  31374. }
  31375. }
  31376. static fromJSON(e) {
  31377. return new ev(e.vertices, e.indices, e.radius, e.corner, e.cornerSides);
  31378. }
  31379. },
  31380. SF = class {
  31381. static create(e) {
  31382. return this.build(this.normalizeInputs(e));
  31383. }
  31384. static normalizeInputs(e, t) {
  31385. let i = Object.assign({}, t?.parameters ?? { width: 100, detail: 0, corner: 0, cornerSides: 4 }, e.parameters);
  31386. return {
  31387. parameters: Object.assign(i, {
  31388. width: Math.abs(i.width),
  31389. height: Math.abs(i.height ?? i.width),
  31390. depth: Math.abs(i.depth ?? i.width)
  31391. })
  31392. };
  31393. }
  31394. static build(e) {
  31395. let { width: t, height: i, depth: r, detail: s, corner: n, cornerSides: a } = e.parameters,
  31396. o = s === 0 && n !== 0 ? new pA(t * 0.5, n, a) : new Dw(t * 0.5, s);
  31397. return o.scale(1, i / t, r / t), Object.assign(o, { userData: { ...e, type: 'DodecahedronGeometry' } });
  31398. }
  31399. },
  31400. pA = class extends ev {
  31401. constructor(e = 1, t = 0.2, i = 4) {
  31402. let r = (1 + Math.sqrt(5)) / 2,
  31403. s = 1 / r,
  31404. n = [
  31405. -1,
  31406. -1,
  31407. -1,
  31408. -1,
  31409. -1,
  31410. 1,
  31411. -1,
  31412. 1,
  31413. -1,
  31414. -1,
  31415. 1,
  31416. 1,
  31417. 1,
  31418. -1,
  31419. -1,
  31420. 1,
  31421. -1,
  31422. 1,
  31423. 1,
  31424. 1,
  31425. -1,
  31426. 1,
  31427. 1,
  31428. 1,
  31429. 0,
  31430. -s,
  31431. -r,
  31432. 0,
  31433. -s,
  31434. r,
  31435. 0,
  31436. s,
  31437. -r,
  31438. 0,
  31439. s,
  31440. r,
  31441. -s,
  31442. -r,
  31443. 0,
  31444. -s,
  31445. r,
  31446. 0,
  31447. s,
  31448. -r,
  31449. 0,
  31450. s,
  31451. r,
  31452. 0,
  31453. -r,
  31454. 0,
  31455. -s,
  31456. r,
  31457. 0,
  31458. -s,
  31459. -r,
  31460. 0,
  31461. s,
  31462. r,
  31463. 0,
  31464. s
  31465. ],
  31466. a = [
  31467. 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,
  31468. 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,
  31469. 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
  31470. ],
  31471. o = 'DodecahedronGeometry';
  31472. super(n, a, o, e, t, i), (this.type = o);
  31473. }
  31474. static fromJSON(e) {
  31475. return new pA(e.radius, e.corner, e.cornerSides);
  31476. }
  31477. },
  31478. Tl = 1e-12,
  31479. tv = class {
  31480. constructor(e) {
  31481. (this.position = new G()), (this.startPosition = new G()), (this.uuid = it.generateUUID()), (this.position = e.clone());
  31482. }
  31483. start() {
  31484. this.reset();
  31485. }
  31486. reset() {
  31487. this.startPosition.copy(this.position);
  31488. }
  31489. applyOffset(e) {
  31490. this.position.copy(this.startPosition).add(e);
  31491. }
  31492. copy(e) {
  31493. return this.position.copy(e.position), this.startPosition.copy(e.startPosition), this;
  31494. }
  31495. clone() {
  31496. return new tv(this.position).copy(this);
  31497. }
  31498. toJSON() {
  31499. return [this.position.x, this.position.y];
  31500. }
  31501. },
  31502. Im = class extends tv {
  31503. constructor(e) {
  31504. super(e.position), (this.parent = e);
  31505. }
  31506. copy(e) {
  31507. return super.copy(e), this;
  31508. }
  31509. clone() {
  31510. return new Im(this.parent).copy(this);
  31511. }
  31512. },
  31513. Po = class extends tv {
  31514. constructor(e, t) {
  31515. super(t),
  31516. (this.controls = []),
  31517. (this.roundness = 0),
  31518. (this.areControlsDirectionsMirrored = !0),
  31519. (this.uuid = e),
  31520. this.controls.push(new Im(this), new Im(this));
  31521. }
  31522. static create(e, t) {
  31523. let i = new Po(e, new G(...t.position));
  31524. return (
  31525. i.controls[0].position.set(...t.controlPrevious.position),
  31526. i.controls[1].position.set(...t.controlNext.position),
  31527. (i.roundness = t.roundness),
  31528. (i.areControlsDirectionsMirrored = t.areControlsDirectionsMirrored),
  31529. i
  31530. );
  31531. }
  31532. getOppositeControl(e) {
  31533. let t = this.controls.indexOf(e);
  31534. return t === 0 ? this.controls[1] : t === 1 ? this.controls[0] : null;
  31535. }
  31536. applyOffsetToControls(e, t = 1) {
  31537. for (let i = 0, r = this.controls.length; i < r; i++) {
  31538. let s = this.controls[i];
  31539. this.position.distanceTo(s.position) <= t ? s.position.copy(this.position) : s.applyOffset(e);
  31540. }
  31541. }
  31542. controlsMoved() {
  31543. return !(this.position.equals(this.controls[0].position) && this.position.equals(this.controls[1].position));
  31544. }
  31545. copy(e) {
  31546. return (
  31547. super.copy(e),
  31548. this.controls[0].copy(e.controls[0]),
  31549. this.controls[1].copy(e.controls[1]),
  31550. (this.roundness = e.roundness),
  31551. (this.uuid = e.uuid),
  31552. this
  31553. );
  31554. }
  31555. clone() {
  31556. return new Po(this.uuid, this.position).copy(this);
  31557. }
  31558. toJSON() {
  31559. return super.toJSON().concat(this.controls[0].toJSON(), this.controls[1].toJSON(), [this.roundness]);
  31560. }
  31561. computeTangents() {
  31562. let e = this.curveBefore?.getTangentAt(1),
  31563. t = this.curveAfter?.getTangentAt(0);
  31564. return [e, t];
  31565. }
  31566. computeNormals(e = new G(), t = new G()) {
  31567. let [i, r] = this.computeTangents();
  31568. return i && r && (vx(i, e), vx(r, t)), [e, t];
  31569. }
  31570. computeTangent(e = new G()) {
  31571. let [t, i] = this.computeTangents();
  31572. return t && i && e.copy(t).add(i).normalize(), e;
  31573. }
  31574. computeNormal(e = new G()) {
  31575. let [t, i] = this.computeNormals();
  31576. return e.copy(t).add(i).normalize(), e;
  31577. }
  31578. };
  31579. function vx(e, t = new G()) {
  31580. let i = e.length();
  31581. return t.set(-e.y / i, e.x / i);
  31582. }
  31583. var iv = (e) => e,
  31584. rl = new G(),
  31585. Mu = new G(),
  31586. MF = new G(),
  31587. EF = new G(),
  31588. CF = new G(),
  31589. TF = new G(),
  31590. fA = new E(),
  31591. mA = new E();
  31592. function PF(e) {
  31593. let t = new G();
  31594. t.addVectors(e.v0, rl.subVectors(e.v1, e.v0).multiplyScalar(2 / 3));
  31595. let i = new G();
  31596. return i.addVectors(e.v2, Mu.subVectors(e.v1, e.v2).multiplyScalar(2 / 3)), new Fr(e.v0, t, i, e.v2);
  31597. }
  31598. function Wl(e, t, i = Number.EPSILON) {
  31599. return Math.abs(e - t) < i;
  31600. }
  31601. function DF(e, t, i = Number.EPSILON) {
  31602. return e.distanceTo(t) < i;
  31603. }
  31604. function LF(e, t, i = Number.EPSILON) {
  31605. return e.distanceTo(t) < i;
  31606. }
  31607. function gA(e, t, i) {
  31608. let r = Math.sqrt(Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2)),
  31609. s = Math.sqrt(Math.pow(t.x - i.x, 2) + Math.pow(t.y - i.y, 2)),
  31610. n = Math.sqrt(Math.pow(i.x - e.x, 2) + Math.pow(i.y - e.y, 2));
  31611. return Math.acos((s * s + r * r - n * n) / (2 * s * r));
  31612. }
  31613. function OF(e, t, i) {
  31614. return xx(e, t) && xx(t, i) && Rm(e.position, t.position, i.position);
  31615. }
  31616. function Rm(e, t, i) {
  31617. return rl.copy(t).sub(e).cross(Mu.copy(i).sub(e)) === 0;
  31618. }
  31619. function IF(e, t, i, r, s) {
  31620. let n = Math.sqrt(Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2)),
  31621. a = (e.y + t.y) / 2,
  31622. o = (e.x + t.x) / 2,
  31623. l = (Math.sqrt(Math.pow(i, 2) - Math.pow(n / 2, 2)) * (e.y - t.y)) / n,
  31624. h = (Math.sqrt(Math.pow(i, 2) - Math.pow(n / 2, 2)) * (t.x - e.x)) / n;
  31625. return r.set(o + l, a + h), s.set(o - l, a - h), [r, s];
  31626. }
  31627. function RF(e, t, i) {
  31628. let r = e.distanceTo(i),
  31629. s = t.distanceTo(i);
  31630. return r < s ? t : e;
  31631. }
  31632. function BF(e, t, i, r, s, n) {
  31633. let a = t.x - e.x,
  31634. o = t.y - e.y,
  31635. l = i.x - e.x,
  31636. h = i.y - e.y,
  31637. u = Math.sqrt((a + l) * (a + l) + (o + h) * (o + h)),
  31638. c;
  31639. return (
  31640. gA(t, e, i) > Math.PI && (u *= -1),
  31641. Wl(h, o) ? (c = ((o + h) * (r / u - 0.5) * 8) / 3 / (a - l)) : (c = ((a + l) * (r / u - 0.5) * 8) / 3 / (h - o)),
  31642. s.set(t.x - c * o, t.y + c * a),
  31643. n.set(i.x + c * h, i.y - c * l),
  31644. [s, n]
  31645. );
  31646. }
  31647. function yx(e, t) {
  31648. return e.position.equals(e.controls[1].position) && t.position.equals(t.controls[0].position);
  31649. }
  31650. function xx(e, t) {
  31651. return Rm(e.position, e.controls[1].position, t.position) && Rm(e.position, t.controls[0].position, t.position);
  31652. }
  31653. function zF(e, t, i, r, s = 0.5) {
  31654. let n = rl.subVectors(t, e).multiplyScalar(s).add(e),
  31655. a = Mu.subVectors(i, t).multiplyScalar(s).add(t),
  31656. o = MF.subVectors(r, i).multiplyScalar(s).add(i),
  31657. l = n,
  31658. h = EF.subVectors(a, n).multiplyScalar(s).add(n),
  31659. u = CF.subVectors(o, a).multiplyScalar(s).add(a),
  31660. c = o,
  31661. d = TF.subVectors(u, h).multiplyScalar(s).add(h);
  31662. return [e.x, e.y, l.x, l.y, h.x, h.y, d.x, d.y, u.x, u.y, c.x, c.y, r.x, r.y];
  31663. }
  31664. function NF(e, t, i = 12, r = !0) {
  31665. let s = mA.set(0, 0, 0),
  31666. n,
  31667. a = 0,
  31668. o = [];
  31669. for (let l = 0; l < t.length; l++) {
  31670. let h = iv(t[l]),
  31671. u = rl,
  31672. c = ga(h, i);
  31673. o.push(c);
  31674. for (let d = 0; d <= c; d++)
  31675. if (h instanceof Fr || h instanceof Pn || h instanceof Gr) {
  31676. if ((h.getPoint(d / c, u), s.set(u.x, u.y, 0), n !== void 0 && LF(n, s))) continue;
  31677. n === void 0 && (n = fA), n.copy(s), e.setXYZ(a, s.x, s.y, s.z), a++;
  31678. }
  31679. }
  31680. return (
  31681. r &&
  31682. a > 1 &&
  31683. !(e.getX(a - 1) === e.getX(0) && e.getY(a - 1) === e.getY(0) && e.getZ(a - 1) === e.getZ(0)) &&
  31684. (e.setXYZ(a, e.getX(0), e.getY(0), e.getZ(0)), a++),
  31685. e
  31686. );
  31687. }
  31688. function UF(e, t, i, r = 12, s = !0) {
  31689. let n = mA.set(0, 0, 0),
  31690. a = 0,
  31691. o = [];
  31692. for (let l = 0; l < t.length; l++) {
  31693. if (i[l] === !1) continue;
  31694. let h,
  31695. u = iv(t[l]),
  31696. c = rl,
  31697. d = ga(u, r);
  31698. o.push(d);
  31699. for (let p = 0; p <= d; p++)
  31700. if (u instanceof Fr || u instanceof Pn || u instanceof Gr) {
  31701. if ((u.getPoint(p / d, c), n.set(c.x, c.y, 0), h?.equals(n))) continue;
  31702. h === void 0 ? (h = fA) : (e.setXYZ(a, h.x, h.y, h.z), a++, e.setXYZ(a, n.x, n.y, n.z), a++), h.copy(n);
  31703. }
  31704. }
  31705. return (
  31706. s &&
  31707. a > 1 &&
  31708. !(e.getX(a - 1) === e.getX(0) && e.getY(a - 1) === e.getY(0) && e.getZ(a - 1) === e.getZ(0)) &&
  31709. (e.setXYZ(a, e.getX(0), e.getY(0), e.getZ(0)), a++),
  31710. o
  31711. );
  31712. }
  31713. function bx(e, t = 12, i = !1) {
  31714. let r = [];
  31715. for (let s = 0, n = e.length; s < n; s++) {
  31716. let a = e[s],
  31717. o = 0;
  31718. if (i && a.roundedCurveCorner !== void 0) {
  31719. let l = ga(a.roundedCurveCorner, t) * 0.5;
  31720. s > 0 && (r[s - 1] += l), (o += l);
  31721. }
  31722. a.curveAfter !== void 0 && (o += ga(a.curveAfter, t)), r.push(o);
  31723. }
  31724. return e.length > 0 && i && e[0].roundedCurveCorner !== void 0 && (r[e.length - 1] += ga(e[0].roundedCurveCorner, t) * 0.5), r;
  31725. }
  31726. function ga(e, t = 12) {
  31727. return e && e instanceof hu ? t * 2 : e && (e instanceof Gr || e instanceof Ew) ? 1 : e && e instanceof mg ? t * e.points.length : t;
  31728. }
  31729. function FF(e, t, i = 12, r = !0) {
  31730. let s,
  31731. n = 0;
  31732. for (let a = 0; a < t.length; a++) {
  31733. let o = iv(t[a]),
  31734. l = ga(o, i),
  31735. h = rl;
  31736. for (let u = 0; u <= l; u++)
  31737. if (o instanceof Fr || o instanceof Pn || o instanceof Gr) {
  31738. if ((o.getPoint(u / l, h), s !== void 0 && DF(s, h, Tl))) continue;
  31739. s === void 0 && (s = Mu), s.copy(h), e.push(h.x, h.y), n++;
  31740. }
  31741. }
  31742. return (
  31743. Wl(e[0], e[e.length - 2], Tl) && Wl(e[1], e[e.length - 1], Tl) && (e.pop(), e.pop()),
  31744. r && n > 1 && !(Wl(e[n - 1], e[1], Tl) && Wl(e[n - 2], e[0], Tl)) && (e.push(e[0], e[1]), n++),
  31745. e
  31746. );
  31747. }
  31748. var qp = new G(),
  31749. kF = new G(),
  31750. jF = new G(),
  31751. GF = new G(),
  31752. VF = new G(),
  31753. HF = new G(),
  31754. Nt = class extends xd {
  31755. constructor(e = 100, t = 100) {
  31756. super(),
  31757. (this.points = []),
  31758. (this.shapeHoles = []),
  31759. (this.plane = new yr(new E(0, 0, -1))),
  31760. (this.subdivision = 0),
  31761. (this.controlSnapDistance = 4),
  31762. (this.pointIDs = 0),
  31763. (this.isMesh2D = !1),
  31764. (this._roundness = 0),
  31765. (this.isClosed = !1),
  31766. (this.useCubicForRoundedCorners = !0),
  31767. (this.uuid = it.generateUUID()),
  31768. (this.needsUpdate = !1),
  31769. (this.roundedCurves = []),
  31770. (this._width = e),
  31771. (this._height = t);
  31772. }
  31773. static createFromState(e, t, i) {
  31774. let r = new Nt();
  31775. return (
  31776. (r.isClosed = e.isClosed),
  31777. (r.points = e.points.map((s) => Po.create(s.id, s.data))),
  31778. typeof e.roundness == 'number' && (r.roundness = e.roundness),
  31779. (r.shapeHoles = e.shapeHoles.map((s) => Nt.createFromState(s))),
  31780. t !== void 0 && i !== void 0 && r.applySize(t, i),
  31781. r.update(),
  31782. r
  31783. );
  31784. }
  31785. get width() {
  31786. return this._width;
  31787. }
  31788. get height() {
  31789. return this._height;
  31790. }
  31791. get roundness() {
  31792. return this._roundness;
  31793. }
  31794. set roundness(e) {
  31795. if (this._roundness !== e) {
  31796. this._roundness = e;
  31797. for (let t = 0, i = this.points.length; t < i; t++) this.points[t].roundness = e;
  31798. this.needsUpdate = !0;
  31799. }
  31800. }
  31801. getPointsIndexesByIds(e) {
  31802. return e.map((t) => this.getPointIndexById(t)).filter((t) => t >= 0);
  31803. }
  31804. getPointIndexById(e) {
  31805. let t = this.points.length,
  31806. i = this.points.findIndex((r) => r.uuid === e);
  31807. if (i < 0) {
  31808. let r = t;
  31809. for (let s = 0, n = this.shapeHoles.length; s < n; s++) {
  31810. let a = this.shapeHoles[s],
  31811. o = a.points.length,
  31812. l = a.getPointIndexById(e);
  31813. if (l < 0) r += o;
  31814. else return l + r;
  31815. }
  31816. }
  31817. return i;
  31818. }
  31819. getLineIndexById(e) {
  31820. return this.getPointIndexById(e);
  31821. }
  31822. getBezierPoint(e) {
  31823. if (e <= this.points.length - 1) return this.points[e];
  31824. if (this.shapeHoles.length > 0) {
  31825. let t = this.points.length;
  31826. for (let i = 0, r = this.shapeHoles.length; i < r; i++) {
  31827. let s = this.shapeHoles[i],
  31828. n = e - t;
  31829. if (n <= s.points.length - 1) return s.points[n];
  31830. t += s.points.length;
  31831. }
  31832. }
  31833. throw new Error('This shape does not have a point for this index: ' + e);
  31834. }
  31835. getBezierPointIndex(e) {
  31836. let t = this.points.indexOf(e);
  31837. if (t >= 0) return t;
  31838. if (((t = this.points.length), this.shapeHoles.length > 0))
  31839. for (let i = 0, r = this.shapeHoles.length; i < r; i++) {
  31840. let s = this.shapeHoles[i],
  31841. n = s.points.indexOf(e);
  31842. if (n >= 0) return t + n;
  31843. t += s.points.length;
  31844. }
  31845. return -1;
  31846. }
  31847. getAllPoints() {
  31848. let e = [].concat(...this.shapeHoles.map((t) => t.points));
  31849. return [...this.points, ...e];
  31850. }
  31851. applySize(e, t) {
  31852. e === 0 && (e = 0.001), t === 0 && (t = 0.001), (this._width = e), (this._height = t);
  31853. }
  31854. applyScale(e, t) {
  31855. let i = qp.set(e, t);
  31856. for (let r = 0, s = this.points.length; r < s; r++) {
  31857. let n = this.points[r];
  31858. n.position.multiply(i), n.controls[0].position.multiply(i), n.controls[1].position.multiply(i);
  31859. }
  31860. for (let r = 0, s = this.shapeHoles.length; r < s; r++) this.shapeHoles[r].applyScale(e, t);
  31861. this._update();
  31862. }
  31863. createPoint(e, t = 0, i = it.generateUUID()) {
  31864. let r;
  31865. e instanceof G ? (r = e) : (r = new G(e, t));
  31866. let s = new Po(i, r);
  31867. return (s.roundness = this.roundness), s;
  31868. }
  31869. addPoint(e) {
  31870. this.points.push(e), (this.needsUpdate = !0);
  31871. }
  31872. addPointAt(e, t) {
  31873. this.points.splice(t, 0, e), (this.needsUpdate = !0);
  31874. }
  31875. getPointByUuid(e) {
  31876. for (let t = 0, i = this.points.length; t < i; t++) {
  31877. let r = this.points[t];
  31878. if (r.uuid === e) return r;
  31879. }
  31880. for (let t = 0, i = this.shapeHoles.length; t < i; t++) {
  31881. let r = this.shapeHoles[t].getPointByUuid(e);
  31882. if (r) return r;
  31883. }
  31884. }
  31885. getFirstPoint() {
  31886. return this.points[0];
  31887. }
  31888. getLastPoint() {
  31889. return this.points[this.points.length - 1];
  31890. }
  31891. removePoint(e) {
  31892. let t = this.points.indexOf(e);
  31893. t >= 0 && this.points.splice(t, 1), (this.needsUpdate = !0);
  31894. }
  31895. removePointById(e) {
  31896. let t = this.points.find((i) => i.uuid === e);
  31897. t && this.removePoint(t);
  31898. }
  31899. update() {
  31900. for (let e = 0, t = this.shapeHoles.length; e < t; e++) this.shapeHoles[e].update();
  31901. this._update();
  31902. }
  31903. extractShapePointsToBuffer(e, t = 12, i = !1) {
  31904. (this.subdivision = t), this.curveDivisions === void 0 && this.computeCurveDivisions(t);
  31905. let r = i ? this.roundedCurveDivisions : this.curveDivisions;
  31906. return NF(e, i ? this.roundedCurves : this.curves, t, this.autoClose), r.reduce((s, n) => s + n, 0) + 1;
  31907. }
  31908. computeCurveDivisions(e = 12) {
  31909. return (this.curveDivisions = bx(this.points, e, !1)), (this.roundedCurveDivisions = bx(this.points, e, !0)), this.curveDivisions;
  31910. }
  31911. extractFilteredShapePointsToBuffer(e, t, i = 12) {
  31912. return UF(e, this.curves, t, i, this.autoClose).reduce((r, s) => r + s, 0) * 2;
  31913. }
  31914. extractShapePointsToFlatArray(e, t = 12) {
  31915. return (
  31916. (this.subdivision = t),
  31917. this.curveDivisions === void 0 && this.computeCurveDivisions(t),
  31918. FF(e, this.roundedCurves, t, this.autoClose)
  31919. );
  31920. }
  31921. getCurveIndexFromVertexId(e, t = !1) {
  31922. let i = 0;
  31923. this.curveDivisions === void 0 && this.computeCurveDivisions(this.subdivision);
  31924. let r = t ? this.roundedCurveDivisions : this.curveDivisions,
  31925. s = 0;
  31926. t && this.points[0].roundedCurveCorner !== void 0 && (s = ga(this.points[0].roundedCurveCorner, this.subdivision) * 0.5);
  31927. let n = e - s;
  31928. n < 0 && (n += r.reduce((a, o) => a + o, 0));
  31929. for (let a = 0, o = r.length; a < o; a++) {
  31930. let l = r[a];
  31931. if (n < i + l) return [a, (n - i + 1) / l];
  31932. i += l;
  31933. }
  31934. return [0, 1];
  31935. }
  31936. getCurveT(e, t, i) {
  31937. let r = this.points[e],
  31938. s = this.points[e >= this.points.length - 1 ? 0 : e + 1],
  31939. n = this.curveDivisions,
  31940. a = n[e];
  31941. if (yx(r, s)) {
  31942. let l = r.position.distanceTo(s.position);
  31943. return r.position.distanceTo(qp.set(i.x, i.y)) / l;
  31944. }
  31945. let o = 0;
  31946. for (let l = 0; l < e; l++) o += n[l];
  31947. return (t - o) / a;
  31948. }
  31949. dispose() {}
  31950. _applyCurveForPoint(e, t) {
  31951. yx(t, e)
  31952. ? this.lineTo(e.position.x, e.position.y)
  31953. : this.bezierCurveTo(
  31954. t.controls[1].position.x,
  31955. t.controls[1].position.y,
  31956. e.controls[0].position.x,
  31957. e.controls[0].position.y,
  31958. e.position.x,
  31959. e.position.y
  31960. );
  31961. let i = this.curves[this.curves.length - 1];
  31962. (e.curveBefore = i), (t.curveAfter = i);
  31963. let r = i.clone();
  31964. (e.roundedCurveBefore = r), (t.roundedCurveAfter = r), (e.roundedCurveCorner = void 0), this.roundedCurves.push(r);
  31965. }
  31966. _update() {
  31967. if (((this.curves = []), (this.roundedCurves = []), !this.points.length)) return;
  31968. for (let t = 0, i = this.points.length; t < i; t++) {
  31969. let r = this.points[t];
  31970. if (t === 0) this.moveTo(r.position.x, r.position.y);
  31971. else {
  31972. let s = this.points[t - 1];
  31973. this._applyCurveForPoint(r, s);
  31974. }
  31975. }
  31976. let e = this.getLastPoint();
  31977. if ((e?.curveAfter && (e.curveAfter = void 0), this.isClosed)) {
  31978. let t = this.points[0],
  31979. i = this.points[this.points.length - 1];
  31980. this._applyCurveForPoint(t, i);
  31981. }
  31982. if (this.points.length > 2) {
  31983. let t = 0;
  31984. for (let i = 0, r = this.points.length; i < r; i++) {
  31985. let s = this.points[i],
  31986. n = this.points[i - 1] ?? this.points[this.points.length - 1],
  31987. a = this.points[i + 1] ?? this.points[0],
  31988. o = s.roundness,
  31989. l = n && a && OF(n, s, a);
  31990. if (!s.controlsMoved() && o > 0 && !l) {
  31991. let h = s.curveBefore,
  31992. u = s.curveAfter;
  31993. if (h === void 0 || u === void 0) continue;
  31994. let c = s.roundedCurveBefore,
  31995. d = s.roundedCurveAfter,
  31996. p = h.getLength(),
  31997. f = u.getLength(),
  31998. g = Math.min(o, p * 0.499),
  31999. m = Math.min(o, f * 0.499),
  32000. v = Math.min(g, m),
  32001. y = 1 - v / p,
  32002. b = v / f,
  32003. x = h.getPointAt(y, qp),
  32004. w = u.getPointAt(b, kF);
  32005. this._subSplitCurve(h, c, y, x, void 0), this._subSplitCurve(u, d, b, void 0, w);
  32006. let A;
  32007. if (this.useCubicForRoundedCorners) {
  32008. let S = gA(x, s.position, w) / 2,
  32009. _ = Math.tan(S) * x.distanceTo(s.position),
  32010. [M, C] = IF(x, w, _, jF, GF),
  32011. T = RF(M, C, s.position),
  32012. [P, L] = BF(T, x, w, _, VF, HF);
  32013. A = new Fr(x.clone(), P.clone(), L.clone(), w.clone());
  32014. } else A = new Pn(x.clone(), s.position.clone(), w.clone());
  32015. (s.roundedCurveCorner = A), this.roundedCurves.splice(i + t, 0, A), t++;
  32016. }
  32017. }
  32018. }
  32019. }
  32020. _subSplitCurve(e, t, i, r, s) {
  32021. if (e instanceof Gr) r !== void 0 && t.v2.copy(r), s !== void 0 && t.v1.copy(s);
  32022. else {
  32023. let n = e,
  32024. a = t,
  32025. o = n.getUtoTmapping(i, 0),
  32026. l = zF(n.v0, n.v1, n.v2, n.v3, o);
  32027. return (
  32028. r !== void 0 && (a.v0.set(l[0], l[1]), a.v1.set(l[2], l[3]), a.v2.set(l[4], l[5]), a.v3.set(l[6], l[7])),
  32029. s !== void 0 && (a.v0.set(l[6], l[7]), a.v1.set(l[8], l[9]), a.v2.set(l[10], l[11]), a.v3.set(l[12], l[13])),
  32030. a
  32031. );
  32032. }
  32033. return t;
  32034. }
  32035. clone() {
  32036. let e = new Nt(this._width, this._height);
  32037. return (
  32038. (e.points = this.points.map((t) => t.clone())),
  32039. (e.isClosed = this.isClosed),
  32040. (e.roundness = this.roundness),
  32041. (e.isMesh2D = this.isMesh2D),
  32042. (e.shapeHoles = this.shapeHoles.map((t) => t.clone())),
  32043. e
  32044. );
  32045. }
  32046. toJSON() {
  32047. return {
  32048. points: this.points.reduce((e, t) => e.concat(t.toJSON()), []),
  32049. shapeHoles: this.shapeHoles.map((e) => e.toJSON()),
  32050. isClosed: this.isClosed,
  32051. roundness: this.roundness
  32052. };
  32053. }
  32054. fromJSON(e) {
  32055. (this.points = []), (this.pointIDs = 0);
  32056. let t = e.points.length / 7;
  32057. for (let i = 0; i < t; i++) {
  32058. let r = i * 7,
  32059. s = e.points[r + 0],
  32060. n = e.points[r + 1],
  32061. a = e.points[r + 2],
  32062. o = e.points[r + 3],
  32063. l = e.points[r + 4],
  32064. h = e.points[r + 5],
  32065. u = e.points[r + 6],
  32066. c = new Po(it.generateUUID(), new G(s, n));
  32067. c.controls[0].position.set(a, o), c.controls[1].position.set(l, h), (c.roundness = u), this.points.push(c);
  32068. }
  32069. return (
  32070. (this.shapeHoles = e.shapeHoles?.length
  32071. ? e.shapeHoles.map((i) => {
  32072. let r = new Nt();
  32073. return r.fromJSON(i), r;
  32074. })
  32075. : []),
  32076. (this.isClosed = e.isClosed),
  32077. (this._roundness = e.roundness),
  32078. this._update(),
  32079. this
  32080. );
  32081. }
  32082. fromShape(e) {
  32083. let t = (r, s) => {
  32084. s instanceof Fr && s.v3.equals(r.position) && r.controls[0].position.copy(s.v2);
  32085. },
  32086. i = (r) => {
  32087. let s = [],
  32088. n,
  32089. a;
  32090. for (n = 0, a = r.length; n < a; n++) r[n] instanceof Pn && (r[n] = PF(r[n]));
  32091. for (n = 0, a = r.length; n < a; n++) {
  32092. let h = r[n],
  32093. u = n > 0 ? r[n - 1] : null,
  32094. c;
  32095. h instanceof Fr
  32096. ? ((c = this.createPoint(h.v0)), c.controls[1].position.copy(h.v1))
  32097. : h instanceof Gr && (c = this.createPoint(h.v1)),
  32098. c !== void 0 && (u !== null && t(c, u), s.push(c));
  32099. }
  32100. let o = r[r.length - 1],
  32101. l = !1;
  32102. return (
  32103. o instanceof Fr
  32104. ? o.v3.equals(s[0].position) && (s[0].controls[0].position.copy(o.v2), (l = !0))
  32105. : o instanceof Gr && o.v2.equals(s[0].position) && (l = !0),
  32106. (this.isClosed = l),
  32107. s
  32108. );
  32109. };
  32110. return (
  32111. (this.points = i(e.curves)),
  32112. e instanceof xd &&
  32113. (this.shapeHoles = e.holes.map((r) => {
  32114. let s = new Nt();
  32115. return s.fromShape(r), s;
  32116. })),
  32117. this.update(),
  32118. this
  32119. );
  32120. }
  32121. updatePoint(e, t) {
  32122. let i = this.getPointByUuid(e);
  32123. i &&
  32124. (t.position !== void 0 && i.position.fromArray(t.position),
  32125. t.roundness !== void 0 && (i.roundness = t.roundness),
  32126. t.areControlsDirectionsMirrored !== void 0 && (i.areControlsDirectionsMirrored = t.areControlsDirectionsMirrored),
  32127. (this.needsUpdate = !0));
  32128. }
  32129. updatePreviousControl(e, t) {
  32130. let i = this.getPointByUuid(e)?.controls[0];
  32131. i && (t.position && i.position.fromArray(t.position), (this.needsUpdate = !0));
  32132. }
  32133. updateNextControl(e, t) {
  32134. let i = this.getPointByUuid(e)?.controls[1];
  32135. i && (t.position && i.position.fromArray(t.position), (this.needsUpdate = !0));
  32136. }
  32137. },
  32138. Bm = Math.PI * 2;
  32139. function Yp({ x: e, y: t }, i, r, s, n) {
  32140. return { x: e * i + s, y: t * r + n };
  32141. }
  32142. function WF(e, t) {
  32143. let i = t === 1.5707963267948966 ? 0.551915024494 : t === -1.5707963267948966 ? -0.551915024494 : 1.3333333333333333 * Math.tan(t / 4),
  32144. r = Math.cos(e),
  32145. s = Math.sin(e),
  32146. n = Math.cos(e + t),
  32147. a = Math.sin(e + t);
  32148. return [
  32149. { x: r - s * i, y: s + r * i },
  32150. { x: n + a * i, y: a - n * i },
  32151. { x: n, y: a }
  32152. ];
  32153. }
  32154. function wx(e, t, i, r) {
  32155. let s = e * r - t * i < 0 ? -1 : 1,
  32156. n = Math.min(1, Math.max(-1, e * i + t * r));
  32157. return s * Math.acos(n);
  32158. }
  32159. function XF(e, t, i, r, s, n, a, o, l, h) {
  32160. let u = Math.pow(s, 2),
  32161. c = Math.pow(n, 2),
  32162. d = Math.pow(a, 2),
  32163. p = Math.pow(o, 2),
  32164. f = u * c - u * p - c * d;
  32165. f < 0 && (f = 0), (f /= u * p + c * d), (f = Math.sqrt(f) * (l === h ? -1 : 1));
  32166. let g = ((f * s) / n) * o,
  32167. m = ((f * -n) / s) * a,
  32168. v = g + (e + i) / 2,
  32169. y = m + (t + r) / 2,
  32170. b = (a - g) / s,
  32171. x = (o - m) / n,
  32172. w = (-a - g) / s,
  32173. A = (-o - m) / n,
  32174. S = wx(1, 0, b, x),
  32175. _ = wx(b, x, w, A);
  32176. return !h && _ > 0 && (_ -= Bm), h && _ < 0 && (_ += Bm), { centerx: v, centery: y, ang1: S, ang2: _ };
  32177. }
  32178. function qF({ px: e, py: t, cx: i, cy: r, rx: s, ry: n, largeArcFlag: a, sweepFlag: o }) {
  32179. let l = [];
  32180. if (s === 0 || n === 0) return [];
  32181. let h = (e - i) / 2,
  32182. u = (t - r) / 2;
  32183. if (h === 0 && u === 0) return [];
  32184. (s = Math.abs(s)), (n = Math.abs(n));
  32185. let c = Math.pow(h, 2) / Math.pow(s, 2) + Math.pow(u, 2) / Math.pow(n, 2);
  32186. c > 1 && ((s *= Math.sqrt(c)), (n *= Math.sqrt(c)));
  32187. let d = XF(e, t, i, r, s, n, h, u, a, o),
  32188. { ang1: p, ang2: f } = d,
  32189. { centerx: g, centery: m } = d,
  32190. v = Math.abs(f) / (Bm / 4);
  32191. Math.abs(1 - v) < 1e-7 && (v = 1);
  32192. let y = Math.max(Math.ceil(v), 1);
  32193. f /= y;
  32194. for (let b = 0; b < y; b++) l.push(WF(p, f)), (p += f);
  32195. return l.map((b) => {
  32196. let { x, y: w } = Yp(b[0], s, n, g, m),
  32197. { x: A, y: S } = Yp(b[1], s, n, g, m),
  32198. { x: _, y: M } = Yp(b[2], s, n, g, m);
  32199. return { x1: x, y1: w, x2: A, y2: S, x: _, y: M };
  32200. });
  32201. }
  32202. var yt;
  32203. (function (e) {
  32204. (e[(e.ODD = 0)] = 'ODD'),
  32205. (e[(e.NONZERO = 1)] = 'NONZERO'),
  32206. (e[(e.POSITIVE = 2)] = 'POSITIVE'),
  32207. (e[(e.NEGATIVE = 3)] = 'NEGATIVE'),
  32208. (e[(e.ABS_GEQ_TWO = 4)] = 'ABS_GEQ_TWO');
  32209. })(yt || (yt = {}));
  32210. var Zt;
  32211. (function (e) {
  32212. (e[(e.POLYGONS = 0)] = 'POLYGONS'),
  32213. (e[(e.CONNECTED_POLYGONS = 1)] = 'CONNECTED_POLYGONS'),
  32214. (e[(e.BOUNDARY_CONTOURS = 2)] = 'BOUNDARY_CONTOURS');
  32215. })(Zt || (Zt = {}));
  32216. function ke(e, t) {
  32217. if (!e) throw t || 'Assertion Failed!';
  32218. }
  32219. var ze = (function () {
  32220. function e() {}
  32221. return (
  32222. (e.vertEq = function (t, i) {
  32223. return t.s === i.s && t.t === i.t;
  32224. }),
  32225. (e.vertLeq = function (t, i) {
  32226. return t.s < i.s || (t.s === i.s && t.t <= i.t);
  32227. }),
  32228. (e.transLeq = function (t, i) {
  32229. return t.t < i.t || (t.t === i.t && t.s <= i.s);
  32230. }),
  32231. (e.edgeGoesLeft = function (t) {
  32232. return e.vertLeq(t.Dst, t.Org);
  32233. }),
  32234. (e.edgeGoesRight = function (t) {
  32235. return e.vertLeq(t.Org, t.Dst);
  32236. }),
  32237. (e.vertL1dist = function (t, i) {
  32238. return Math.abs(t.s - i.s) + Math.abs(t.t - i.t);
  32239. }),
  32240. (e.edgeEval = function (t, i, r) {
  32241. ke(e.vertLeq(t, i) && e.vertLeq(i, r));
  32242. var s = i.s - t.s,
  32243. n = r.s - i.s;
  32244. return s + n > 0 ? (s < n ? i.t - t.t + (t.t - r.t) * (s / (s + n)) : i.t - r.t + (r.t - t.t) * (n / (s + n))) : 0;
  32245. }),
  32246. (e.edgeSign = function (t, i, r) {
  32247. ke(e.vertLeq(t, i) && e.vertLeq(i, r));
  32248. var s = i.s - t.s,
  32249. n = r.s - i.s;
  32250. return s + n > 0 ? (i.t - r.t) * s + (i.t - t.t) * n : 0;
  32251. }),
  32252. (e.transEval = function (t, i, r) {
  32253. ke(e.transLeq(t, i) && e.transLeq(i, r));
  32254. var s = i.t - t.t,
  32255. n = r.t - i.t;
  32256. return s + n > 0 ? (s < n ? i.s - t.s + (t.s - r.s) * (s / (s + n)) : i.s - r.s + (r.s - t.s) * (n / (s + n))) : 0;
  32257. }),
  32258. (e.transSign = function (t, i, r) {
  32259. ke(e.transLeq(t, i) && e.transLeq(i, r));
  32260. var s = i.t - t.t,
  32261. n = r.t - i.t;
  32262. return s + n > 0 ? (i.s - r.s) * s + (i.s - t.s) * n : 0;
  32263. }),
  32264. (e.vertCCW = function (t, i, r) {
  32265. return t.s * (i.t - r.t) + i.s * (r.t - t.t) + r.s * (t.t - i.t) >= 0;
  32266. }),
  32267. (e.interpolate = function (t, i, r, s) {
  32268. return (
  32269. (t = t < 0 ? 0 : t),
  32270. (r = r < 0 ? 0 : r),
  32271. t <= r ? (r === 0 ? (i + s) / 2 : i + (s - i) * (t / (t + r))) : s + (i - s) * (r / (t + r))
  32272. );
  32273. }),
  32274. (e.intersect = function (t, i, r, s, n) {
  32275. var a, o, l;
  32276. e.vertLeq(t, i) || ((l = t), (t = i), (i = l)),
  32277. e.vertLeq(r, s) || ((l = r), (r = s), (s = l)),
  32278. e.vertLeq(t, r) || ((l = t), (t = r), (r = l), (l = i), (i = s), (s = l)),
  32279. e.vertLeq(r, i)
  32280. ? e.vertLeq(i, s)
  32281. ? ((a = e.edgeEval(t, r, i)),
  32282. (o = e.edgeEval(r, i, s)),
  32283. a + o < 0 && ((a = -a), (o = -o)),
  32284. (n.s = e.interpolate(a, r.s, o, i.s)))
  32285. : ((a = e.edgeSign(t, r, i)),
  32286. (o = -e.edgeSign(t, s, i)),
  32287. a + o < 0 && ((a = -a), (o = -o)),
  32288. (n.s = e.interpolate(a, r.s, o, s.s)))
  32289. : (n.s = (r.s + i.s) / 2),
  32290. e.transLeq(t, i) || ((l = t), (t = i), (i = l)),
  32291. e.transLeq(r, s) || ((l = r), (r = s), (s = l)),
  32292. e.transLeq(t, r) || ((l = t), (t = r), (r = l), (l = i), (i = s), (s = l)),
  32293. e.transLeq(r, i)
  32294. ? e.transLeq(i, s)
  32295. ? ((a = e.transEval(t, r, i)),
  32296. (o = e.transEval(r, i, s)),
  32297. a + o < 0 && ((a = -a), (o = -o)),
  32298. (n.t = e.interpolate(a, r.t, o, i.t)))
  32299. : ((a = e.transSign(t, r, i)),
  32300. (o = -e.transSign(t, s, i)),
  32301. a + o < 0 && ((a = -a), (o = -o)),
  32302. (n.t = e.interpolate(a, r.t, o, s.t)))
  32303. : (n.t = (r.t + i.t) / 2);
  32304. }),
  32305. e
  32306. );
  32307. })(),
  32308. Pl = (function () {
  32309. function e() {
  32310. (this.next = null),
  32311. (this.prev = null),
  32312. (this.anEdge = null),
  32313. (this.trail = null),
  32314. (this.n = 0),
  32315. (this.marked = !1),
  32316. (this.inside = !1);
  32317. }
  32318. return e;
  32319. })(),
  32320. Oc = (function () {
  32321. function e(t) {
  32322. (this.side = t),
  32323. (this.next = null),
  32324. (this.Org = null),
  32325. (this.Sym = null),
  32326. (this.Onext = null),
  32327. (this.Lnext = null),
  32328. (this.Lface = null),
  32329. (this.activeRegion = null),
  32330. (this.winding = 0);
  32331. }
  32332. return (
  32333. Object.defineProperty(e.prototype, 'Rface', {
  32334. get: function () {
  32335. return this.Sym.Lface;
  32336. },
  32337. set: function (t) {
  32338. this.Sym.Lface = t;
  32339. },
  32340. enumerable: !0,
  32341. configurable: !0
  32342. }),
  32343. Object.defineProperty(e.prototype, 'Dst', {
  32344. get: function () {
  32345. return this.Sym.Org;
  32346. },
  32347. set: function (t) {
  32348. this.Sym.Org = t;
  32349. },
  32350. enumerable: !0,
  32351. configurable: !0
  32352. }),
  32353. Object.defineProperty(e.prototype, 'Oprev', {
  32354. get: function () {
  32355. return this.Sym.Lnext;
  32356. },
  32357. set: function (t) {
  32358. this.Sym.Lnext = t;
  32359. },
  32360. enumerable: !0,
  32361. configurable: !0
  32362. }),
  32363. Object.defineProperty(e.prototype, 'Lprev', {
  32364. get: function () {
  32365. return this.Onext.Sym;
  32366. },
  32367. set: function (t) {
  32368. this.Onext.Sym = t;
  32369. },
  32370. enumerable: !0,
  32371. configurable: !0
  32372. }),
  32373. Object.defineProperty(e.prototype, 'Dprev', {
  32374. get: function () {
  32375. return this.Lnext.Sym;
  32376. },
  32377. set: function (t) {
  32378. this.Lnext.Sym = t;
  32379. },
  32380. enumerable: !0,
  32381. configurable: !0
  32382. }),
  32383. Object.defineProperty(e.prototype, 'Rprev', {
  32384. get: function () {
  32385. return this.Sym.Onext;
  32386. },
  32387. set: function (t) {
  32388. this.Sym.Onext = t;
  32389. },
  32390. enumerable: !0,
  32391. configurable: !0
  32392. }),
  32393. Object.defineProperty(e.prototype, 'Dnext', {
  32394. get: function () {
  32395. return this.Sym.Onext.Sym;
  32396. },
  32397. set: function (t) {
  32398. this.Sym.Onext.Sym = t;
  32399. },
  32400. enumerable: !0,
  32401. configurable: !0
  32402. }),
  32403. Object.defineProperty(e.prototype, 'Rnext', {
  32404. get: function () {
  32405. return this.Sym.Lnext.Sym;
  32406. },
  32407. set: function (t) {
  32408. this.Sym.Lnext.Sym = t;
  32409. },
  32410. enumerable: !0,
  32411. configurable: !0
  32412. }),
  32413. e
  32414. );
  32415. })(),
  32416. oo = (function () {
  32417. function e() {
  32418. (this.next = null),
  32419. (this.prev = null),
  32420. (this.anEdge = null),
  32421. (this.coords = [0, 0, 0]),
  32422. (this.s = 0),
  32423. (this.t = 0),
  32424. (this.pqHandle = 0),
  32425. (this.n = 0),
  32426. (this.idx = 0);
  32427. }
  32428. return e;
  32429. })(),
  32430. _x = (function () {
  32431. function e() {
  32432. var t = new oo(),
  32433. i = new Pl(),
  32434. r = new Oc(0),
  32435. s = new Oc(1);
  32436. (t.next = t.prev = t),
  32437. (t.anEdge = null),
  32438. (i.next = i.prev = i),
  32439. (r.next = r),
  32440. (r.Sym = s),
  32441. (s.next = s),
  32442. (s.Sym = r),
  32443. (this.vHead = t),
  32444. (this.fHead = i),
  32445. (this.eHead = r),
  32446. (this.eHeadSym = s);
  32447. }
  32448. return (
  32449. (e.prototype.makeEdge_ = function (t) {
  32450. var i = new Oc(0),
  32451. r = new Oc(1);
  32452. t.Sym.side < t.side && (t = t.Sym);
  32453. var s = t.Sym.next;
  32454. return (
  32455. (r.next = s),
  32456. (s.Sym.next = i),
  32457. (i.next = t),
  32458. (t.Sym.next = r),
  32459. (i.Sym = r),
  32460. (i.Onext = i),
  32461. (i.Lnext = r),
  32462. (i.Org = null),
  32463. (i.Lface = null),
  32464. (i.winding = 0),
  32465. (i.activeRegion = null),
  32466. (r.Sym = i),
  32467. (r.Onext = r),
  32468. (r.Lnext = i),
  32469. (r.Org = null),
  32470. (r.Lface = null),
  32471. (r.winding = 0),
  32472. (r.activeRegion = null),
  32473. i
  32474. );
  32475. }),
  32476. (e.prototype.splice_ = function (t, i) {
  32477. var r = t.Onext,
  32478. s = i.Onext;
  32479. (r.Sym.Lnext = i), (s.Sym.Lnext = t), (t.Onext = s), (i.Onext = r);
  32480. }),
  32481. (e.prototype.makeVertex_ = function (t, i, r) {
  32482. var s = t;
  32483. ke(s, "Vertex can't be null!");
  32484. var n = r.prev;
  32485. (s.prev = n), (n.next = s), (s.next = r), (r.prev = s), (s.anEdge = i);
  32486. var a = i;
  32487. do {
  32488. (a.Org = s), (a = a.Onext);
  32489. } while (a !== i);
  32490. }),
  32491. (e.prototype.makeFace_ = function (t, i, r) {
  32492. var s = t;
  32493. ke(s, "Face can't be null");
  32494. var n = r.prev;
  32495. (s.prev = n), (n.next = s), (s.next = r), (r.prev = s), (s.anEdge = i), (s.trail = null), (s.marked = !1), (s.inside = r.inside);
  32496. var a = i;
  32497. do {
  32498. (a.Lface = s), (a = a.Lnext);
  32499. } while (a !== i);
  32500. }),
  32501. (e.prototype.killEdge_ = function (t) {
  32502. t.Sym.side < t.side && (t = t.Sym);
  32503. var i = t.next,
  32504. r = t.Sym.next;
  32505. (i.Sym.next = r), (r.Sym.next = i);
  32506. }),
  32507. (e.prototype.killVertex_ = function (t, i) {
  32508. var r = t.anEdge,
  32509. s = r;
  32510. do {
  32511. (s.Org = i), (s = s.Onext);
  32512. } while (s !== r);
  32513. var n = t.prev,
  32514. a = t.next;
  32515. (a.prev = n), (n.next = a);
  32516. }),
  32517. (e.prototype.killFace_ = function (t, i) {
  32518. var r = t.anEdge,
  32519. s = r;
  32520. do {
  32521. (s.Lface = i), (s = s.Lnext);
  32522. } while (s !== r);
  32523. var n = t.prev,
  32524. a = t.next;
  32525. (a.prev = n), (n.next = a);
  32526. }),
  32527. (e.prototype.makeEdge = function () {
  32528. var t = new oo(),
  32529. i = new oo(),
  32530. r = new Pl(),
  32531. s = this.makeEdge_(this.eHead);
  32532. return this.makeVertex_(t, s, this.vHead), this.makeVertex_(i, s.Sym, this.vHead), this.makeFace_(r, s, this.fHead), s;
  32533. }),
  32534. (e.prototype.splice = function (t, i) {
  32535. var r = !1,
  32536. s = !1;
  32537. if (t !== i) {
  32538. if (
  32539. (i.Org !== t.Org && ((s = !0), this.killVertex_(i.Org, t.Org)),
  32540. i.Lface !== t.Lface && ((r = !0), this.killFace_(i.Lface, t.Lface)),
  32541. this.splice_(i, t),
  32542. !s)
  32543. ) {
  32544. var n = new oo();
  32545. this.makeVertex_(n, i, t.Org), (t.Org.anEdge = t);
  32546. }
  32547. if (!r) {
  32548. var a = new Pl();
  32549. this.makeFace_(a, i, t.Lface), (t.Lface.anEdge = t);
  32550. }
  32551. }
  32552. }),
  32553. (e.prototype.delete = function (t) {
  32554. var i = t.Sym,
  32555. r = !1;
  32556. if ((t.Lface !== t.Rface && ((r = !0), this.killFace_(t.Lface, t.Rface)), t.Onext === t)) this.killVertex_(t.Org, null);
  32557. else if (((t.Rface.anEdge = t.Oprev), (t.Org.anEdge = t.Onext), this.splice_(t, t.Oprev), !r)) {
  32558. var s = new Pl();
  32559. this.makeFace_(s, t, t.Lface);
  32560. }
  32561. i.Onext === i
  32562. ? (this.killVertex_(i.Org, null), this.killFace_(i.Lface, null))
  32563. : ((t.Lface.anEdge = i.Oprev), (i.Org.anEdge = i.Onext), this.splice_(i, i.Oprev)),
  32564. this.killEdge_(t);
  32565. }),
  32566. (e.prototype.addEdgeVertex = function (t) {
  32567. var i = this.makeEdge_(t),
  32568. r = i.Sym;
  32569. this.splice_(i, t.Lnext), (i.Org = t.Dst);
  32570. var s = new oo();
  32571. return this.makeVertex_(s, r, i.Org), (i.Lface = r.Lface = t.Lface), i;
  32572. }),
  32573. (e.prototype.splitEdge = function (t) {
  32574. var i = this.addEdgeVertex(t),
  32575. r = i.Sym;
  32576. return (
  32577. this.splice_(t.Sym, t.Sym.Oprev),
  32578. this.splice_(t.Sym, r),
  32579. (t.Dst = r.Org),
  32580. (r.Dst.anEdge = r.Sym),
  32581. (r.Rface = t.Rface),
  32582. (r.winding = t.winding),
  32583. (r.Sym.winding = t.Sym.winding),
  32584. (r.idx = t.idx),
  32585. (r.Sym.idx = t.Sym.idx),
  32586. r
  32587. );
  32588. }),
  32589. (e.prototype.connect = function (t, i) {
  32590. var r = !1,
  32591. s = this.makeEdge_(t),
  32592. n = s.Sym;
  32593. if (
  32594. (i.Lface !== t.Lface && ((r = !0), this.killFace_(i.Lface, t.Lface)),
  32595. this.splice_(s, t.Lnext),
  32596. this.splice_(n, i),
  32597. (s.Org = t.Dst),
  32598. (n.Org = i.Org),
  32599. (s.Lface = n.Lface = t.Lface),
  32600. (t.Lface.anEdge = n),
  32601. !r)
  32602. ) {
  32603. var a = new Pl();
  32604. this.makeFace_(a, s, t.Lface);
  32605. }
  32606. return s;
  32607. }),
  32608. (e.prototype.zapFace = function (t) {
  32609. var i = t.anEdge,
  32610. r,
  32611. s,
  32612. n,
  32613. a,
  32614. o;
  32615. s = i.Lnext;
  32616. do {
  32617. (r = s),
  32618. (s = r.Lnext),
  32619. (r.Lface = null),
  32620. r.Rface === null &&
  32621. (r.Onext === r ? this.killVertex_(r.Org, null) : ((r.Org.anEdge = r.Onext), this.splice_(r, r.Oprev)),
  32622. (n = r.Sym),
  32623. n.Onext === n ? this.killVertex_(n.Org, null) : ((n.Org.anEdge = n.Onext), this.splice_(n, n.Oprev)),
  32624. this.killEdge_(r));
  32625. } while (r != i);
  32626. (a = t.prev), (o = t.next), (o.prev = a), (a.next = o);
  32627. }),
  32628. (e.prototype.countFaceVerts_ = function (t) {
  32629. var i = t.anEdge,
  32630. r = 0;
  32631. do {
  32632. r++, (i = i.Lnext);
  32633. } while (i !== t.anEdge);
  32634. return r;
  32635. }),
  32636. (e.prototype.mergeConvexFaces = function (t) {
  32637. var i, r, s, n, a, o, l;
  32638. for (i = this.fHead.next; i !== this.fHead; i = i.next)
  32639. if (i.inside)
  32640. for (
  32641. r = i.anEdge, a = r.Org;
  32642. (s = r.Lnext),
  32643. (n = r.Sym),
  32644. n &&
  32645. n.Lface &&
  32646. n.Lface.inside &&
  32647. ((o = this.countFaceVerts_(i)),
  32648. (l = this.countFaceVerts_(n.Lface)),
  32649. o + l - 2 <= t &&
  32650. ze.vertCCW(r.Lprev.Org, r.Org, n.Lnext.Lnext.Org) &&
  32651. ze.vertCCW(n.Lprev.Org, n.Org, r.Lnext.Lnext.Org) &&
  32652. ((s = n.Lnext), this.delete(n), (r = null), (n = null))),
  32653. !(r && r.Lnext.Org === a);
  32654. )
  32655. r = s;
  32656. return !0;
  32657. }),
  32658. (e.prototype.check = function () {
  32659. var t = this.fHead,
  32660. i = this.vHead,
  32661. r = this.eHead,
  32662. s,
  32663. n,
  32664. a,
  32665. o,
  32666. l,
  32667. h;
  32668. for (n = t, n = t; (s = n.next) !== t; n = s) {
  32669. ke(s.prev === n), (l = s.anEdge);
  32670. do {
  32671. ke(l.Sym !== l),
  32672. ke(l.Sym.Sym === l),
  32673. ke(l.Lnext.Onext.Sym === l),
  32674. ke(l.Onext.Sym.Lnext === l),
  32675. ke(l.Lface === s),
  32676. (l = l.Lnext);
  32677. } while (l !== s.anEdge);
  32678. }
  32679. for (ke(s.prev === n && s.anEdge === null), o = i, o = i; (a = o.next) !== i; o = a) {
  32680. ke(a.prev === o), (l = a.anEdge);
  32681. do {
  32682. ke(l.Sym !== l), ke(l.Sym.Sym === l), ke(l.Lnext.Onext.Sym === l), ke(l.Onext.Sym.Lnext === l), ke(l.Org === a), (l = l.Onext);
  32683. } while (l !== a.anEdge);
  32684. }
  32685. for (ke(a.prev === o && a.anEdge === null), h = r, h = r; (l = h.next) !== r; h = l)
  32686. ke(l.Sym.next === h.Sym),
  32687. ke(l.Sym !== l),
  32688. ke(l.Sym.Sym === l),
  32689. ke(l.Org !== null),
  32690. ke(l.Dst !== null),
  32691. ke(l.Lnext.Onext.Sym === l),
  32692. ke(l.Onext.Sym.Lnext === l);
  32693. ke(
  32694. l.Sym.next === h.Sym &&
  32695. l.Sym === this.eHeadSym &&
  32696. l.Sym.Sym === l &&
  32697. l.Org === null &&
  32698. l.Dst === null &&
  32699. l.Lface === null &&
  32700. l.Rface === null
  32701. );
  32702. }),
  32703. e
  32704. );
  32705. })(),
  32706. Ax = (function () {
  32707. function e() {
  32708. this.handle = null;
  32709. }
  32710. return e;
  32711. })(),
  32712. Sx = (function () {
  32713. function e() {
  32714. (this.key = null), (this.node = 0);
  32715. }
  32716. return e;
  32717. })(),
  32718. YF = (function () {
  32719. function e(t, i) {
  32720. (this.leq = i),
  32721. (this.max = 0),
  32722. (this.nodes = []),
  32723. (this.handles = []),
  32724. (this.initialized = !1),
  32725. (this.freeList = 0),
  32726. (this.size = 0),
  32727. (this.max = t),
  32728. (this.nodes = []),
  32729. (this.handles = []);
  32730. for (var r = 0; r < t + 1; r++) (this.nodes[r] = new Ax()), (this.handles[r] = new Sx());
  32731. (this.initialized = !1), (this.nodes[1].handle = 1), (this.handles[1].key = null);
  32732. }
  32733. return (
  32734. (e.prototype.floatDown_ = function (t) {
  32735. var i = this.nodes,
  32736. r = this.handles,
  32737. s,
  32738. n,
  32739. a;
  32740. for (s = i[t].handle; ; ) {
  32741. if (
  32742. ((a = t << 1),
  32743. a < this.size && this.leq(r[i[a + 1].handle].key, r[i[a].handle].key) && ++a,
  32744. ke(a <= this.max),
  32745. (n = i[a].handle),
  32746. a > this.size || this.leq(r[s].key, r[n].key))
  32747. ) {
  32748. (i[t].handle = s), (r[s].node = t);
  32749. break;
  32750. }
  32751. (i[t].handle = n), (r[n].node = t), (t = a);
  32752. }
  32753. }),
  32754. (e.prototype.floatUp_ = function (t) {
  32755. var i = this.nodes,
  32756. r = this.handles,
  32757. s,
  32758. n,
  32759. a;
  32760. for (s = i[t].handle; ; ) {
  32761. if (((a = t >> 1), (n = i[a].handle), a === 0 || this.leq(r[n].key, r[s].key))) {
  32762. (i[t].handle = s), (r[s].node = t);
  32763. break;
  32764. }
  32765. (i[t].handle = n), (r[n].node = t), (t = a);
  32766. }
  32767. }),
  32768. (e.prototype.init = function () {
  32769. for (var t = this.size; t >= 1; --t) this.floatDown_(t);
  32770. this.initialized = !0;
  32771. }),
  32772. (e.prototype.min = function () {
  32773. return this.handles[this.nodes[1].handle].key;
  32774. }),
  32775. (e.prototype.insert = function (t) {
  32776. var i, r;
  32777. if (((i = ++this.size), i * 2 > this.max)) {
  32778. this.max *= 2;
  32779. var s, n;
  32780. for (n = this.nodes.length, this.nodes.length = this.max + 1, s = n; s < this.nodes.length; s++) this.nodes[s] = new Ax();
  32781. for (n = this.handles.length, this.handles.length = this.max + 1, s = n; s < this.handles.length; s++) this.handles[s] = new Sx();
  32782. }
  32783. return (
  32784. this.freeList === 0 ? (r = i) : ((r = this.freeList), (this.freeList = this.handles[r].node)),
  32785. (this.nodes[i].handle = r),
  32786. (this.handles[r].node = i),
  32787. (this.handles[r].key = t),
  32788. this.initialized && this.floatUp_(i),
  32789. r
  32790. );
  32791. }),
  32792. (e.prototype.extractMin = function () {
  32793. var t = this.nodes,
  32794. i = this.handles,
  32795. r = t[1].handle,
  32796. s = i[r].key;
  32797. return (
  32798. this.size > 0 &&
  32799. ((t[1].handle = t[this.size].handle),
  32800. (i[t[1].handle].node = 1),
  32801. (i[r].key = null),
  32802. (i[r].node = this.freeList),
  32803. (this.freeList = r),
  32804. --this.size,
  32805. this.size > 0 && this.floatDown_(1)),
  32806. s
  32807. );
  32808. }),
  32809. (e.prototype.delete = function (t) {
  32810. var i = this.nodes,
  32811. r = this.handles,
  32812. s;
  32813. ke(t >= 1 && t <= this.max && r[t].key !== null),
  32814. (s = r[t].node),
  32815. (i[s].handle = i[this.size].handle),
  32816. (r[i[s].handle].node = s),
  32817. --this.size,
  32818. s <= this.size && (s <= 1 || this.leq(r[i[s >> 1].handle].key, r[i[s].handle].key) ? this.floatDown_(s) : this.floatUp_(s)),
  32819. (r[t].key = null),
  32820. (r[t].node = this.freeList),
  32821. (this.freeList = t);
  32822. }),
  32823. e
  32824. );
  32825. })(),
  32826. Qp = (function () {
  32827. function e() {
  32828. (this.eUp = null),
  32829. (this.nodeUp = null),
  32830. (this.windingNumber = 0),
  32831. (this.inside = !1),
  32832. (this.sentinel = !1),
  32833. (this.dirty = !1),
  32834. (this.fixUpperEdge = !1);
  32835. }
  32836. return e;
  32837. })(),
  32838. Mx = (function () {
  32839. function e() {
  32840. (this.key = null), (this.next = null), (this.prev = null);
  32841. }
  32842. return e;
  32843. })(),
  32844. QF = (function () {
  32845. function e(t, i) {
  32846. (this.frame = t), (this.leq = i), (this.head = new Mx()), (this.head.next = this.head), (this.head.prev = this.head);
  32847. }
  32848. return (
  32849. (e.prototype.min = function () {
  32850. return this.head.next;
  32851. }),
  32852. (e.prototype.max = function () {
  32853. return this.head.prev;
  32854. }),
  32855. (e.prototype.insert = function (t) {
  32856. return this.insertBefore(this.head, t);
  32857. }),
  32858. (e.prototype.search = function (t) {
  32859. var i = this.head;
  32860. do {
  32861. i = i.next;
  32862. } while (i.key !== null && !this.leq(this.frame, t, i.key));
  32863. return i;
  32864. }),
  32865. (e.prototype.insertBefore = function (t, i) {
  32866. do {
  32867. t = t.prev;
  32868. } while (t.key !== null && !this.leq(this.frame, t.key, i));
  32869. var r = new Mx();
  32870. return (r.key = i), (r.next = t.next), (t.next.prev = r), (r.prev = t), (t.next = r), r;
  32871. }),
  32872. (e.prototype.delete = function (t) {
  32873. (t.next.prev = t.prev), (t.prev.next = t.next);
  32874. }),
  32875. e
  32876. );
  32877. })(),
  32878. ZF = (function () {
  32879. function e() {}
  32880. return (
  32881. (e.regionBelow = function (t) {
  32882. return t.nodeUp.prev.key;
  32883. }),
  32884. (e.regionAbove = function (t) {
  32885. return t.nodeUp.next.key;
  32886. }),
  32887. (e.debugEvent = function (t) {}),
  32888. (e.addWinding = function (t, i) {
  32889. (t.winding += i.winding), (t.Sym.winding += i.Sym.winding);
  32890. }),
  32891. (e.edgeLeq = function (t, i, r) {
  32892. var s = t.event,
  32893. n = i.eUp,
  32894. a = r.eUp;
  32895. if (n.Dst === s)
  32896. return a.Dst === s
  32897. ? ze.vertLeq(n.Org, a.Org)
  32898. ? ze.edgeSign(a.Dst, n.Org, a.Org) <= 0
  32899. : ze.edgeSign(n.Dst, a.Org, n.Org) >= 0
  32900. : ze.edgeSign(a.Dst, s, a.Org) <= 0;
  32901. if (a.Dst === s) return ze.edgeSign(n.Dst, s, n.Org) >= 0;
  32902. var o = ze.edgeEval(n.Dst, s, n.Org),
  32903. l = ze.edgeEval(a.Dst, s, a.Org);
  32904. return o >= l;
  32905. }),
  32906. (e.deleteRegion = function (t, i) {
  32907. i.fixUpperEdge && ke(i.eUp.winding === 0), (i.eUp.activeRegion = null), t.dict.delete(i.nodeUp);
  32908. }),
  32909. (e.fixUpperEdge = function (t, i, r) {
  32910. ke(i.fixUpperEdge), t.mesh.delete(i.eUp), (i.fixUpperEdge = !1), (i.eUp = r), (r.activeRegion = i);
  32911. }),
  32912. (e.topLeftRegion = function (t, i) {
  32913. var r = i.eUp.Org,
  32914. s;
  32915. do {
  32916. i = e.regionAbove(i);
  32917. } while (i.eUp.Org === r);
  32918. if (i.fixUpperEdge) {
  32919. if (((s = t.mesh.connect(e.regionBelow(i).eUp.Sym, i.eUp.Lnext)), s === null)) return null;
  32920. e.fixUpperEdge(t, i, s), (i = e.regionAbove(i));
  32921. }
  32922. return i;
  32923. }),
  32924. (e.topRightRegion = function (t) {
  32925. var i = t.eUp.Dst;
  32926. do {
  32927. t = e.regionAbove(t);
  32928. } while (t.eUp.Dst === i);
  32929. return t;
  32930. }),
  32931. (e.addRegionBelow = function (t, i, r) {
  32932. var s = new Qp();
  32933. return (
  32934. (s.eUp = r),
  32935. (s.nodeUp = t.dict.insertBefore(i.nodeUp, s)),
  32936. (s.fixUpperEdge = !1),
  32937. (s.sentinel = !1),
  32938. (s.dirty = !1),
  32939. (r.activeRegion = s),
  32940. s
  32941. );
  32942. }),
  32943. (e.isWindingInside = function (t, i) {
  32944. switch (t.windingRule) {
  32945. case yt.ODD:
  32946. return (i & 1) !== 0;
  32947. case yt.NONZERO:
  32948. return i !== 0;
  32949. case yt.POSITIVE:
  32950. return i > 0;
  32951. case yt.NEGATIVE:
  32952. return i < 0;
  32953. case yt.ABS_GEQ_TWO:
  32954. return i >= 2 || i <= -2;
  32955. }
  32956. throw new Error('Invalid winding rulle');
  32957. }),
  32958. (e.computeWinding = function (t, i) {
  32959. (i.windingNumber = e.regionAbove(i).windingNumber + i.eUp.winding), (i.inside = e.isWindingInside(t, i.windingNumber));
  32960. }),
  32961. (e.finishRegion = function (t, i) {
  32962. var r = i.eUp,
  32963. s = r.Lface;
  32964. (s.inside = i.inside), (s.anEdge = r), e.deleteRegion(t, i);
  32965. }),
  32966. (e.finishLeftRegions = function (t, i, r) {
  32967. for (var s, n = null, a = i, o = i.eUp; a !== r; ) {
  32968. if (((a.fixUpperEdge = !1), (n = e.regionBelow(a)), (s = n.eUp), s.Org != o.Org)) {
  32969. if (!n.fixUpperEdge) {
  32970. e.finishRegion(t, a);
  32971. break;
  32972. }
  32973. (s = t.mesh.connect(o.Lprev, s.Sym)), e.fixUpperEdge(t, n, s);
  32974. }
  32975. o.Onext !== s && (t.mesh.splice(s.Oprev, s), t.mesh.splice(o, s)), e.finishRegion(t, a), (o = n.eUp), (a = n);
  32976. }
  32977. return o;
  32978. }),
  32979. (e.addRightEdges = function (t, i, r, s, n, a) {
  32980. var o,
  32981. l,
  32982. h,
  32983. u,
  32984. c = !0;
  32985. h = r;
  32986. do {
  32987. ke(ze.vertLeq(h.Org, h.Dst)), e.addRegionBelow(t, i, h.Sym), (h = h.Onext);
  32988. } while (h !== s);
  32989. for (n === null && (n = e.regionBelow(i).eUp.Rprev), l = i, u = n; (o = e.regionBelow(l)), (h = o.eUp.Sym), h.Org === u.Org; )
  32990. h.Onext !== u && (t.mesh.splice(h.Oprev, h), t.mesh.splice(u.Oprev, h)),
  32991. (o.windingNumber = l.windingNumber - h.winding),
  32992. (o.inside = e.isWindingInside(t, o.windingNumber)),
  32993. (l.dirty = !0),
  32994. !c && e.checkForRightSplice(t, l) && (e.addWinding(h, u), e.deleteRegion(t, l), t.mesh.delete(u)),
  32995. (c = !1),
  32996. (l = o),
  32997. (u = h);
  32998. (l.dirty = !0), ke(l.windingNumber - h.winding === o.windingNumber), a && e.walkDirtyRegions(t, l);
  32999. }),
  33000. (e.spliceMergeVertices = function (t, i, r) {
  33001. t.mesh.splice(i, r);
  33002. }),
  33003. (e.vertexWeights = function (t, i, r) {
  33004. var s = ze.vertL1dist(i, t),
  33005. n = ze.vertL1dist(r, t),
  33006. a = (0.5 * n) / (s + n),
  33007. o = (0.5 * s) / (s + n);
  33008. (t.coords[0] += a * i.coords[0] + o * r.coords[0]),
  33009. (t.coords[1] += a * i.coords[1] + o * r.coords[1]),
  33010. (t.coords[2] += a * i.coords[2] + o * r.coords[2]);
  33011. }),
  33012. (e.getIntersectData = function (t, i, r, s, n, a) {
  33013. (i.coords[0] = i.coords[1] = i.coords[2] = 0), (i.idx = -1), e.vertexWeights(i, r, s), e.vertexWeights(i, n, a);
  33014. }),
  33015. (e.checkForRightSplice = function (t, i) {
  33016. var r = e.regionBelow(i),
  33017. s = i.eUp,
  33018. n = r.eUp;
  33019. if (ze.vertLeq(s.Org, n.Org)) {
  33020. if (ze.edgeSign(n.Dst, s.Org, n.Org) > 0) return !1;
  33021. ze.vertEq(s.Org, n.Org)
  33022. ? s.Org !== n.Org && (t.pq.delete(s.Org.pqHandle), e.spliceMergeVertices(t, n.Oprev, s))
  33023. : (t.mesh.splitEdge(n.Sym), t.mesh.splice(s, n.Oprev), (i.dirty = r.dirty = !0));
  33024. } else {
  33025. if (ze.edgeSign(s.Dst, n.Org, s.Org) < 0) return !1;
  33026. (e.regionAbove(i).dirty = i.dirty = !0), t.mesh.splitEdge(s.Sym), t.mesh.splice(n.Oprev, s);
  33027. }
  33028. return !0;
  33029. }),
  33030. (e.checkForLeftSplice = function (t, i) {
  33031. var r = e.regionBelow(i),
  33032. s = i.eUp,
  33033. n = r.eUp,
  33034. a;
  33035. if ((ke(!ze.vertEq(s.Dst, n.Dst)), ze.vertLeq(s.Dst, n.Dst))) {
  33036. if (ze.edgeSign(s.Dst, n.Dst, s.Org) < 0) return !1;
  33037. (e.regionAbove(i).dirty = i.dirty = !0), (a = t.mesh.splitEdge(s)), t.mesh.splice(n.Sym, a), (a.Lface.inside = i.inside);
  33038. } else {
  33039. if (ze.edgeSign(n.Dst, s.Dst, n.Org) > 0) return !1;
  33040. (i.dirty = r.dirty = !0), (a = t.mesh.splitEdge(n)), t.mesh.splice(s.Lnext, n.Sym), (a.Rface.inside = i.inside);
  33041. }
  33042. return !0;
  33043. }),
  33044. (e.checkForIntersect = function (t, i) {
  33045. var r = e.regionBelow(i),
  33046. s = i.eUp,
  33047. n = r.eUp,
  33048. a = s.Org,
  33049. o = n.Org,
  33050. l = s.Dst,
  33051. h = n.Dst,
  33052. u,
  33053. c,
  33054. d = new oo(),
  33055. p,
  33056. f;
  33057. if (
  33058. (ke(!ze.vertEq(h, l)),
  33059. ke(ze.edgeSign(l, t.event, a) <= 0),
  33060. ke(ze.edgeSign(h, t.event, o) >= 0),
  33061. ke(a !== t.event && o !== t.event),
  33062. ke(!i.fixUpperEdge && !r.fixUpperEdge),
  33063. a === o || ((u = Math.min(a.t, l.t)), (c = Math.max(o.t, h.t)), u > c))
  33064. )
  33065. return !1;
  33066. if (ze.vertLeq(a, o)) {
  33067. if (ze.edgeSign(h, a, o) > 0) return !1;
  33068. } else if (ze.edgeSign(l, o, a) < 0) return !1;
  33069. return (
  33070. e.debugEvent(t),
  33071. ze.intersect(l, a, h, o, d),
  33072. ke(Math.min(a.t, l.t) <= d.t),
  33073. ke(d.t <= Math.max(o.t, h.t)),
  33074. ke(Math.min(h.s, l.s) <= d.s),
  33075. ke(d.s <= Math.max(o.s, a.s)),
  33076. ze.vertLeq(d, t.event) && ((d.s = t.event.s), (d.t = t.event.t)),
  33077. (p = ze.vertLeq(a, o) ? a : o),
  33078. ze.vertLeq(p, d) && ((d.s = p.s), (d.t = p.t)),
  33079. ze.vertEq(d, a) || ze.vertEq(d, o)
  33080. ? (e.checkForRightSplice(t, i), !1)
  33081. : (!ze.vertEq(l, t.event) && ze.edgeSign(l, t.event, d) >= 0) || (!ze.vertEq(h, t.event) && ze.edgeSign(h, t.event, d) <= 0)
  33082. ? h === t.event
  33083. ? (t.mesh.splitEdge(s.Sym),
  33084. t.mesh.splice(n.Sym, s),
  33085. (i = e.topLeftRegion(t, i)),
  33086. (s = e.regionBelow(i).eUp),
  33087. e.finishLeftRegions(t, e.regionBelow(i), r),
  33088. e.addRightEdges(t, i, s.Oprev, s, s, !0),
  33089. !0)
  33090. : l === t.event
  33091. ? (t.mesh.splitEdge(n.Sym),
  33092. t.mesh.splice(s.Lnext, n.Oprev),
  33093. (r = i),
  33094. (i = e.topRightRegion(i)),
  33095. (f = e.regionBelow(i).eUp.Rprev),
  33096. (r.eUp = n.Oprev),
  33097. (n = e.finishLeftRegions(t, r, null)),
  33098. e.addRightEdges(t, i, n.Onext, s.Rprev, f, !0),
  33099. !0)
  33100. : (ze.edgeSign(l, t.event, d) >= 0 &&
  33101. ((e.regionAbove(i).dirty = i.dirty = !0), t.mesh.splitEdge(s.Sym), (s.Org.s = t.event.s), (s.Org.t = t.event.t)),
  33102. ze.edgeSign(h, t.event, d) <= 0 &&
  33103. ((i.dirty = r.dirty = !0), t.mesh.splitEdge(n.Sym), (n.Org.s = t.event.s), (n.Org.t = t.event.t)),
  33104. !1)
  33105. : (t.mesh.splitEdge(s.Sym),
  33106. t.mesh.splitEdge(n.Sym),
  33107. t.mesh.splice(n.Oprev, s),
  33108. (s.Org.s = d.s),
  33109. (s.Org.t = d.t),
  33110. (s.Org.pqHandle = t.pq.insert(s.Org)),
  33111. e.getIntersectData(t, s.Org, a, l, o, h),
  33112. (e.regionAbove(i).dirty = i.dirty = r.dirty = !0),
  33113. !1)
  33114. );
  33115. }),
  33116. (e.walkDirtyRegions = function (t, i) {
  33117. for (var r = e.regionBelow(i), s, n; ; ) {
  33118. for (; r.dirty; ) (i = r), (r = e.regionBelow(r));
  33119. if (!i.dirty && ((r = i), (i = e.regionAbove(i)), i === null || !i.dirty)) return;
  33120. if (
  33121. ((i.dirty = !1),
  33122. (s = i.eUp),
  33123. (n = r.eUp),
  33124. s.Dst !== n.Dst &&
  33125. e.checkForLeftSplice(t, i) &&
  33126. (r.fixUpperEdge
  33127. ? (e.deleteRegion(t, r), t.mesh.delete(n), (r = e.regionBelow(i)), (n = r.eUp))
  33128. : i.fixUpperEdge && (e.deleteRegion(t, i), t.mesh.delete(s), (i = e.regionAbove(r)), (s = i.eUp))),
  33129. s.Org !== n.Org)
  33130. )
  33131. if (s.Dst !== n.Dst && !i.fixUpperEdge && !r.fixUpperEdge && (s.Dst === t.event || n.Dst === t.event)) {
  33132. if (e.checkForIntersect(t, i)) return;
  33133. } else e.checkForRightSplice(t, i);
  33134. s.Org === n.Org && s.Dst === n.Dst && (e.addWinding(n, s), e.deleteRegion(t, i), t.mesh.delete(s), (i = e.regionAbove(r)));
  33135. }
  33136. }),
  33137. (e.connectRightVertex = function (t, i, r) {
  33138. var s,
  33139. n = r.Onext,
  33140. a = e.regionBelow(i),
  33141. o = i.eUp,
  33142. l = a.eUp,
  33143. h = !1;
  33144. if (
  33145. (o.Dst !== l.Dst && e.checkForIntersect(t, i),
  33146. ze.vertEq(o.Org, t.event) &&
  33147. (t.mesh.splice(n.Oprev, o),
  33148. (i = e.topLeftRegion(t, i)),
  33149. (n = e.regionBelow(i).eUp),
  33150. e.finishLeftRegions(t, e.regionBelow(i), a),
  33151. (h = !0)),
  33152. ze.vertEq(l.Org, t.event) && (t.mesh.splice(r, l.Oprev), (r = e.finishLeftRegions(t, a, null)), (h = !0)),
  33153. h)
  33154. ) {
  33155. e.addRightEdges(t, i, r.Onext, n, n, !0);
  33156. return;
  33157. }
  33158. ze.vertLeq(l.Org, o.Org) ? (s = l.Oprev) : (s = o),
  33159. (s = t.mesh.connect(r.Lprev, s)),
  33160. e.addRightEdges(t, i, s, s.Onext, s.Onext, !1),
  33161. (s.Sym.activeRegion.fixUpperEdge = !0),
  33162. e.walkDirtyRegions(t, i);
  33163. }),
  33164. (e.connectLeftDegenerate = function (t, i, r) {
  33165. var s, n, a, o, l;
  33166. if (((s = i.eUp), ze.vertEq(s.Org, r))) {
  33167. ke(!1), e.spliceMergeVertices(t, s, r.anEdge);
  33168. return;
  33169. }
  33170. if (!ze.vertEq(s.Dst, r)) {
  33171. t.mesh.splitEdge(s.Sym),
  33172. i.fixUpperEdge && (t.mesh.delete(s.Onext), (i.fixUpperEdge = !1)),
  33173. t.mesh.splice(r.anEdge, s),
  33174. e.sweepEvent(t, r);
  33175. return;
  33176. }
  33177. ke(!1),
  33178. (i = e.topRightRegion(i)),
  33179. (l = e.regionBelow(i)),
  33180. (a = l.eUp.Sym),
  33181. (n = o = a.Onext),
  33182. l.fixUpperEdge && (ke(n !== a), e.deleteRegion(t, l), t.mesh.delete(a), (a = n.Oprev)),
  33183. t.mesh.splice(r.anEdge, a),
  33184. ze.edgeGoesLeft(n) || (n = null),
  33185. e.addRightEdges(t, i, a.Onext, o, n, !0);
  33186. }),
  33187. (e.connectLeftVertex = function (t, i) {
  33188. var r,
  33189. s,
  33190. n,
  33191. a,
  33192. o,
  33193. l,
  33194. h = new Qp();
  33195. if (((h.eUp = i.anEdge.Sym), (r = t.dict.search(h).key), (s = e.regionBelow(r)), !!s)) {
  33196. if (((a = r.eUp), (o = s.eUp), ze.edgeSign(a.Dst, i, a.Org) === 0)) {
  33197. e.connectLeftDegenerate(t, r, i);
  33198. return;
  33199. }
  33200. if (((n = ze.vertLeq(o.Dst, a.Dst) ? r : s), r.inside || n.fixUpperEdge)) {
  33201. if (n === r) l = t.mesh.connect(i.anEdge.Sym, a.Lnext);
  33202. else {
  33203. var u = t.mesh.connect(o.Dnext, i.anEdge);
  33204. l = u.Sym;
  33205. }
  33206. n.fixUpperEdge ? e.fixUpperEdge(t, n, l) : e.computeWinding(t, e.addRegionBelow(t, r, l)), e.sweepEvent(t, i);
  33207. } else e.addRightEdges(t, r, i.anEdge, i.anEdge, null, !0);
  33208. }
  33209. }),
  33210. (e.sweepEvent = function (t, i) {
  33211. (t.event = i), e.debugEvent(t);
  33212. for (var r = i.anEdge; r.activeRegion === null; )
  33213. if (((r = r.Onext), r === i.anEdge)) {
  33214. e.connectLeftVertex(t, i);
  33215. return;
  33216. }
  33217. var s = e.topLeftRegion(t, r.activeRegion);
  33218. ke(s !== null);
  33219. var n = e.regionBelow(s),
  33220. a = n.eUp,
  33221. o = e.finishLeftRegions(t, n, null);
  33222. o.Onext === a ? e.connectRightVertex(t, s, o) : e.addRightEdges(t, s, o.Onext, a, a, !0);
  33223. }),
  33224. (e.addSentinel = function (t, i, r, s) {
  33225. var n = new Qp(),
  33226. a = t.mesh.makeEdge();
  33227. (a.Org.s = r),
  33228. (a.Org.t = s),
  33229. (a.Dst.s = i),
  33230. (a.Dst.t = s),
  33231. (t.event = a.Dst),
  33232. (n.eUp = a),
  33233. (n.windingNumber = 0),
  33234. (n.inside = !1),
  33235. (n.fixUpperEdge = !1),
  33236. (n.sentinel = !0),
  33237. (n.dirty = !1),
  33238. (n.nodeUp = t.dict.insert(n));
  33239. }),
  33240. (e.initEdgeDict = function (t) {
  33241. t.dict = new QF(t, e.edgeLeq);
  33242. var i = t.bmax[0] - t.bmin[0],
  33243. r = t.bmax[1] - t.bmin[1],
  33244. s = t.bmin[0] - i,
  33245. n = t.bmax[0] + i,
  33246. a = t.bmin[1] - r,
  33247. o = t.bmax[1] + r;
  33248. e.addSentinel(t, s, n, a), e.addSentinel(t, s, n, o);
  33249. }),
  33250. (e.doneEdgeDict = function (t) {
  33251. for (var i, r = 0; (i = t.dict.min().key) !== null; )
  33252. i.sentinel || (ke(i.fixUpperEdge), ke(++r === 1)), ke(i.windingNumber === 0), e.deleteRegion(t, i);
  33253. }),
  33254. (e.removeDegenerateEdges = function (t) {
  33255. var i,
  33256. r,
  33257. s,
  33258. n = t.mesh.eHead;
  33259. for (i = n.next; i !== n; i = r)
  33260. (r = i.next),
  33261. (s = i.Lnext),
  33262. ze.vertEq(i.Org, i.Dst) && i.Lnext.Lnext !== i && (e.spliceMergeVertices(t, s, i), t.mesh.delete(i), (i = s), (s = i.Lnext)),
  33263. s.Lnext === i &&
  33264. (s !== i && ((s === r || s === r.Sym) && (r = r.next), t.mesh.delete(s)),
  33265. (i === r || i === r.Sym) && (r = r.next),
  33266. t.mesh.delete(i));
  33267. }),
  33268. (e.initPriorityQ = function (t) {
  33269. var i,
  33270. r,
  33271. s,
  33272. n = 0;
  33273. for (s = t.mesh.vHead, r = s.next; r !== s; r = r.next) n++;
  33274. for (n += 8, i = t.pq = new YF(n, ze.vertLeq), s = t.mesh.vHead, r = s.next; r !== s; r = r.next) r.pqHandle = i.insert(r);
  33275. return r !== s ? !1 : (i.init(), !0);
  33276. }),
  33277. (e.donePriorityQ = function (t) {
  33278. t.pq = null;
  33279. }),
  33280. (e.removeDegenerateFaces = function (t, i) {
  33281. var r, s, n;
  33282. for (r = i.fHead.next; r !== i.fHead; r = s)
  33283. (s = r.next), (n = r.anEdge), ke(n.Lnext !== n), n.Lnext.Lnext === n && (e.addWinding(n.Onext, n), t.mesh.delete(n));
  33284. return !0;
  33285. }),
  33286. (e.computeInterior = function (t, i) {
  33287. i === void 0 && (i = !0);
  33288. var r, s;
  33289. if ((e.removeDegenerateEdges(t), !e.initPriorityQ(t))) return !1;
  33290. for (e.initEdgeDict(t); (r = t.pq.extractMin()) !== null; ) {
  33291. for (; (s = t.pq.min()), !(s === null || !ze.vertEq(s, r)); )
  33292. (s = t.pq.extractMin()), e.spliceMergeVertices(t, r.anEdge, s.anEdge);
  33293. e.sweepEvent(t, r);
  33294. }
  33295. return (
  33296. (t.event = t.dict.min().key.eUp.Org),
  33297. e.debugEvent(t),
  33298. e.doneEdgeDict(t),
  33299. e.donePriorityQ(t),
  33300. e.removeDegenerateFaces(t, t.mesh) ? (i && t.mesh.check(), !0) : !1
  33301. );
  33302. }),
  33303. e
  33304. );
  33305. })(),
  33306. KF = (function () {
  33307. function e() {
  33308. (this.mesh = new _x()),
  33309. (this.normal = [0, 0, 0]),
  33310. (this.sUnit = [0, 0, 0]),
  33311. (this.tUnit = [0, 0, 0]),
  33312. (this.bmin = [0, 0]),
  33313. (this.bmax = [0, 0]),
  33314. (this.windingRule = yt.ODD),
  33315. (this.dict = null),
  33316. (this.pq = null),
  33317. (this.event = null),
  33318. (this.vertexIndexCounter = 0),
  33319. (this.vertices = []),
  33320. (this.vertexIndices = []),
  33321. (this.vertexCount = 0),
  33322. (this.elements = []),
  33323. (this.elementCount = 0);
  33324. }
  33325. return (
  33326. (e.prototype.dot_ = function (t, i) {
  33327. return t[0] * i[0] + t[1] * i[1] + t[2] * i[2];
  33328. }),
  33329. (e.prototype.normalize_ = function (t) {
  33330. var i = t[0] * t[0] + t[1] * t[1] + t[2] * t[2];
  33331. if (!i) throw 'Zero-size vector!';
  33332. (i = Math.sqrt(i)), (t[0] /= i), (t[1] /= i), (t[2] /= i);
  33333. }),
  33334. (e.prototype.longAxis_ = function (t) {
  33335. var i = 0;
  33336. return Math.abs(t[1]) > Math.abs(t[0]) && (i = 1), Math.abs(t[2]) > Math.abs(t[i]) && (i = 2), i;
  33337. }),
  33338. (e.prototype.computeNormal_ = function (t) {
  33339. var i,
  33340. r,
  33341. s,
  33342. n,
  33343. a,
  33344. o,
  33345. l = [0, 0, 0],
  33346. h = [0, 0, 0],
  33347. u = [0, 0, 0],
  33348. c = [0, 0, 0],
  33349. d = [0, 0, 0],
  33350. p = [null, null, null],
  33351. f = [null, null, null],
  33352. g = this.mesh.vHead;
  33353. i = g.next;
  33354. for (var m = 0; m < 3; ++m) (n = i.coords[m]), (h[m] = n), (f[m] = i), (l[m] = n), (p[m] = i);
  33355. for (i = g.next; i !== g; i = i.next)
  33356. for (var v = 0; v < 3; ++v) (n = i.coords[v]), n < h[v] && ((h[v] = n), (f[v] = i)), n > l[v] && ((l[v] = n), (p[v] = i));
  33357. var y = 0;
  33358. 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])) {
  33359. (t[0] = 0), (t[1] = 0), (t[2] = 1);
  33360. return;
  33361. }
  33362. for (
  33363. o = 0,
  33364. r = f[y],
  33365. s = p[y],
  33366. u[0] = r.coords[0] - s.coords[0],
  33367. u[1] = r.coords[1] - s.coords[1],
  33368. u[2] = r.coords[2] - s.coords[2],
  33369. i = g.next;
  33370. i !== g;
  33371. i = i.next
  33372. )
  33373. (c[0] = i.coords[0] - s.coords[0]),
  33374. (c[1] = i.coords[1] - s.coords[1]),
  33375. (c[2] = i.coords[2] - s.coords[2]),
  33376. (d[0] = u[1] * c[2] - u[2] * c[1]),
  33377. (d[1] = u[2] * c[0] - u[0] * c[2]),
  33378. (d[2] = u[0] * c[1] - u[1] * c[0]),
  33379. (a = d[0] * d[0] + d[1] * d[1] + d[2] * d[2]),
  33380. a > o && ((o = a), (t[0] = d[0]), (t[1] = d[1]), (t[2] = d[2]));
  33381. o <= 0 && ((t[0] = t[1] = t[2] = 0), (t[this.longAxis_(u)] = 1));
  33382. }),
  33383. (e.prototype.checkOrientation_ = function () {
  33384. for (var t = this.mesh.fHead, i, r = this.mesh.vHead, s, n = 0, a = t.next; a !== t; a = a.next)
  33385. if (((s = a.anEdge), !(s.winding <= 0)))
  33386. do {
  33387. (n += (s.Org.s - s.Dst.s) * (s.Org.t + s.Dst.t)), (s = s.Lnext);
  33388. } while (s !== a.anEdge);
  33389. if (n < 0) {
  33390. for (i = r.next; i !== r; i = i.next) i.t = -i.t;
  33391. (this.tUnit[0] = -this.tUnit[0]), (this.tUnit[1] = -this.tUnit[1]), (this.tUnit[2] = -this.tUnit[2]);
  33392. }
  33393. }),
  33394. (e.prototype.projectPolygon_ = function () {
  33395. var t = this.mesh.vHead,
  33396. i = [0, 0, 0],
  33397. r,
  33398. s,
  33399. n = !1;
  33400. (i[0] = this.normal[0]),
  33401. (i[1] = this.normal[1]),
  33402. (i[2] = this.normal[2]),
  33403. !i[0] && !i[1] && !i[2] && (this.computeNormal_(i), (n = !0)),
  33404. (r = this.sUnit),
  33405. (s = this.tUnit);
  33406. var a = this.longAxis_(i);
  33407. (r[a] = 0), (r[(a + 1) % 3] = 1), (r[(a + 2) % 3] = 0), (s[a] = 0), (s[(a + 1) % 3] = 0), (s[(a + 2) % 3] = i[a] > 0 ? 1 : -1);
  33408. for (var o = t.next; o !== t; o = o.next) (o.s = this.dot_(o.coords, r)), (o.t = this.dot_(o.coords, s));
  33409. n && this.checkOrientation_();
  33410. for (var l = !0, h = t.next; h !== t; h = h.next)
  33411. l
  33412. ? ((this.bmin[0] = this.bmax[0] = h.s), (this.bmin[1] = this.bmax[1] = h.t), (l = !1))
  33413. : (h.s < this.bmin[0] && (this.bmin[0] = h.s),
  33414. h.s > this.bmax[0] && (this.bmax[0] = h.s),
  33415. h.t < this.bmin[1] && (this.bmin[1] = h.t),
  33416. h.t > this.bmax[1] && (this.bmax[1] = h.t));
  33417. }),
  33418. (e.prototype.addWinding_ = function (t, i) {
  33419. (t.winding += i.winding), (t.Sym.winding += i.Sym.winding);
  33420. }),
  33421. (e.prototype.tessellateMonoRegion_ = function (t, i) {
  33422. var r, s;
  33423. if (((r = i.anEdge), !(r.Lnext !== r && r.Lnext.Lnext !== r))) throw 'Mono region invalid';
  33424. for (; ze.vertLeq(r.Dst, r.Org); r = r.Lprev);
  33425. for (; ze.vertLeq(r.Org, r.Dst); r = r.Lnext);
  33426. s = r.Lprev;
  33427. for (var n = void 0; r.Lnext !== s; )
  33428. if (ze.vertLeq(r.Dst, s.Org)) {
  33429. for (; s.Lnext !== r && (ze.edgeGoesLeft(s.Lnext) || ze.edgeSign(s.Org, s.Dst, s.Lnext.Dst) <= 0); )
  33430. (n = t.connect(s.Lnext, s)), (s = n.Sym);
  33431. s = s.Lprev;
  33432. } else {
  33433. for (; s.Lnext !== r && (ze.edgeGoesRight(r.Lprev) || ze.edgeSign(r.Dst, r.Org, r.Lprev.Org) >= 0); )
  33434. (n = t.connect(r, r.Lprev)), (r = n.Sym);
  33435. r = r.Lnext;
  33436. }
  33437. if (s.Lnext === r) throw 'Mono region invalid';
  33438. for (; s.Lnext.Lnext !== r; ) (n = t.connect(s.Lnext, s)), (s = n.Sym);
  33439. return !0;
  33440. }),
  33441. (e.prototype.tessellateInterior_ = function (t) {
  33442. for (var i, r = t.fHead.next; r !== t.fHead; r = i) if (((i = r.next), r.inside && !this.tessellateMonoRegion_(t, r))) return !1;
  33443. return !0;
  33444. }),
  33445. (e.prototype.discardExterior_ = function (t) {
  33446. for (var i, r = t.fHead.next; r !== t.fHead; r = i) (i = r.next), r.inside || t.zapFace(r);
  33447. }),
  33448. (e.prototype.setWindingNumber_ = function (t, i, r) {
  33449. for (var s, n = t.eHead.next; n !== t.eHead; n = s)
  33450. (s = n.next), n.Rface.inside !== n.Lface.inside ? (n.winding = n.Lface.inside ? i : -i) : r ? t.delete(n) : (n.winding = 0);
  33451. }),
  33452. (e.prototype.getNeighbourFace_ = function (t) {
  33453. return !t.Rface || !t.Rface.inside ? -1 : t.Rface.n;
  33454. }),
  33455. (e.prototype.outputPolymesh_ = function (t, i, r, s) {
  33456. var n,
  33457. a = 0,
  33458. o = 0,
  33459. l;
  33460. r > 3 && t.mergeConvexFaces(r);
  33461. for (var h = t.vHead.next; h !== t.vHead; h = h.next) h.n = -1;
  33462. for (var u = t.fHead.next; u !== t.fHead; u = u.next)
  33463. if (((u.n = -1), !!u.inside)) {
  33464. (n = u.anEdge), (l = 0);
  33465. do {
  33466. var h = n.Org;
  33467. h.n === -1 && ((h.n = o), o++), l++, (n = n.Lnext);
  33468. } while (n !== u.anEdge);
  33469. if (l > r) throw 'Face vertex greater that support polygon';
  33470. (u.n = a), ++a;
  33471. }
  33472. (this.elementCount = a),
  33473. i === Zt.CONNECTED_POLYGONS && (a *= 2),
  33474. (this.elements = []),
  33475. (this.elements.length = a * r),
  33476. (this.vertexCount = o),
  33477. (this.vertices = []),
  33478. (this.vertices.length = o * s),
  33479. (this.vertexIndices = []),
  33480. (this.vertexIndices.length = o);
  33481. for (var h = t.vHead.next; h !== t.vHead; h = h.next)
  33482. if (h.n !== -1) {
  33483. var c = h.n * s;
  33484. (this.vertices[c + 0] = h.coords[0]),
  33485. (this.vertices[c + 1] = h.coords[1]),
  33486. s > 2 && (this.vertices[c + 2] = h.coords[2]),
  33487. (this.vertexIndices[h.n] = h.idx);
  33488. }
  33489. for (var d = 0, u = t.fHead.next; u !== t.fHead; u = u.next)
  33490. if (u.inside) {
  33491. (n = u.anEdge), (l = 0);
  33492. do {
  33493. var h = n.Org;
  33494. (this.elements[d++] = h.n), l++, (n = n.Lnext);
  33495. } while (n !== u.anEdge);
  33496. for (var p = l; p < r; ++p) this.elements[d++] = -1;
  33497. if (i === Zt.CONNECTED_POLYGONS) {
  33498. n = u.anEdge;
  33499. do {
  33500. (this.elements[d++] = this.getNeighbourFace_(n)), (n = n.Lnext);
  33501. } while (n !== u.anEdge);
  33502. for (var f = l; f < r; ++f) this.elements[d++] = -1;
  33503. }
  33504. }
  33505. }),
  33506. (e.prototype.outputContours_ = function (t, i) {
  33507. var r,
  33508. s,
  33509. n = 0,
  33510. a = 0;
  33511. (this.vertexCount = 0), (this.elementCount = 0);
  33512. for (var o = t.fHead.next; o !== t.fHead; o = o.next)
  33513. if (o.inside) {
  33514. s = r = o.anEdge;
  33515. do {
  33516. this.vertexCount++, (r = r.Lnext);
  33517. } while (r !== s);
  33518. this.elementCount++;
  33519. }
  33520. (this.elements = []),
  33521. (this.elements.length = this.elementCount * 2),
  33522. (this.vertices = []),
  33523. (this.vertices.length = this.vertexCount * i),
  33524. (this.vertexIndices = []),
  33525. (this.vertexIndices.length = this.vertexCount);
  33526. var l = 0,
  33527. h = 0,
  33528. u = 0;
  33529. n = 0;
  33530. for (var o = t.fHead.next; o !== t.fHead; o = o.next)
  33531. if (o.inside) {
  33532. (a = 0), (s = r = o.anEdge);
  33533. do {
  33534. (this.vertices[l++] = r.Org.coords[0]),
  33535. (this.vertices[l++] = r.Org.coords[1]),
  33536. i > 2 && (this.vertices[l++] = r.Org.coords[2]),
  33537. (this.vertexIndices[h++] = this.vertexIdCallback ? this.vertexIdCallback(r) : r.Org.idx),
  33538. a++,
  33539. (r = r.Lnext);
  33540. } while (r !== s);
  33541. (this.elements[u++] = n), (this.elements[u++] = a), (n += a);
  33542. }
  33543. }),
  33544. (e.prototype.addContour = function (t, i) {
  33545. this.mesh === null && (this.mesh = new _x()), t < 2 && (t = 2), t > 3 && (t = 3);
  33546. for (var r = null, s = 0; s < i.length; s += t)
  33547. r === null ? ((r = this.mesh.makeEdge()), this.mesh.splice(r, r.Sym)) : (this.mesh.splitEdge(r), (r = r.Lnext)),
  33548. (r.Org.coords[0] = i[s + 0]),
  33549. (r.Org.coords[1] = i[s + 1]),
  33550. t > 2 ? (r.Org.coords[2] = i[s + 2]) : (r.Org.coords[2] = 0),
  33551. (r.Org.idx = this.vertexIndexCounter++),
  33552. this.edgeCreateCallback && this.edgeCreateCallback(r),
  33553. (r.winding = 1),
  33554. (r.Sym.winding = -1);
  33555. }),
  33556. (e.prototype.tesselate = function (t, i, r, s, n, a) {
  33557. if (
  33558. (t === void 0 && (t = yt.ODD),
  33559. i === void 0 && (i = Zt.POLYGONS),
  33560. a === void 0 && (a = !0),
  33561. (this.vertices = []),
  33562. (this.elements = []),
  33563. (this.vertexIndices = []),
  33564. (this.vertexIndexCounter = 0),
  33565. n && ((this.normal[0] = n[0]), (this.normal[1] = n[1]), (this.normal[2] = n[2])),
  33566. (this.windingRule = t),
  33567. s < 2 && (s = 2),
  33568. s > 3 && (s = 3),
  33569. !this.mesh)
  33570. )
  33571. return !1;
  33572. this.projectPolygon_(), ZF.computeInterior(this, a);
  33573. var o = this.mesh;
  33574. return (
  33575. i === Zt.BOUNDARY_CONTOURS ? this.setWindingNumber_(o, 1, !0) : this.tessellateInterior_(o),
  33576. a && o.check(),
  33577. i === Zt.BOUNDARY_CONTOURS ? this.outputContours_(o, s) : this.outputPolymesh_(o, i, r, s),
  33578. !0
  33579. );
  33580. }),
  33581. e
  33582. );
  33583. })();
  33584. function _n(e) {
  33585. var t = e.windingRule,
  33586. i = t === void 0 ? yt.ODD : t,
  33587. r = e.elementType,
  33588. s = r === void 0 ? Zt.POLYGONS : r,
  33589. n = e.polySize,
  33590. a = n === void 0 ? 3 : n,
  33591. o = e.vertexSize,
  33592. l = o === void 0 ? 2 : o,
  33593. h = e.normal,
  33594. u = h === void 0 ? [0, 0, 1] : h,
  33595. c = e.contours,
  33596. d = c === void 0 ? [] : c,
  33597. p = e.strict,
  33598. f = p === void 0 ? !0 : p,
  33599. g = e.debug,
  33600. m = g === void 0 ? !1 : g;
  33601. if (!d && f) throw new Error("Contours can't be empty");
  33602. if (d) {
  33603. var v = new KF();
  33604. e.edgeCreateCallback && (v.edgeCreateCallback = e.edgeCreateCallback), e.vertexIdCallback && (v.vertexIdCallback = e.vertexIdCallback);
  33605. for (var y = 0; y < d.length; y++) v.addContour(l || 2, d[y]);
  33606. return (
  33607. v.tesselate(i, s, a, l, u, f),
  33608. {
  33609. vertices: v.vertices,
  33610. vertexIndices: v.vertexIndices,
  33611. vertexCount: v.vertexCount,
  33612. elements: v.elements,
  33613. elementCount: v.elementCount,
  33614. mesh: m ? v.mesh : void 0
  33615. }
  33616. );
  33617. }
  33618. }
  33619. var T9 = yt.ODD,
  33620. P9 = yt.NONZERO,
  33621. D9 = yt.POSITIVE,
  33622. L9 = yt.NEGATIVE,
  33623. O9 = yt.ABS_GEQ_TWO,
  33624. I9 = Zt.POLYGONS,
  33625. R9 = Zt.CONNECTED_POLYGONS,
  33626. B9 = Zt.BOUNDARY_CONTOURS,
  33627. zm = class {
  33628. constructor(e = 256, t = !1) {
  33629. (this.capacity = e), (this.size = 0), (this.debug = t), this.debug && console.log(`allocating with cap ${e}`);
  33630. let i = e * zm.eSize;
  33631. this.buffer = new ArrayBuffer(i);
  33632. let r = Float32Array.BYTES_PER_ELEMENT,
  33633. s = 0;
  33634. (this.positions = new Float32Array(this.buffer, s * r, 3 * e)),
  33635. (s += 3 * e),
  33636. (this.normals = new Float32Array(this.buffer, s * r, 3 * e)),
  33637. (s += 3 * e),
  33638. (this.uvs = new Float32Array(this.buffer, s * r, 2 * e));
  33639. }
  33640. realloc(e, t = !1) {
  33641. if (e < this.size) throw Error('cannot shrink buffer');
  33642. if (e <= this.capacity && !t) return;
  33643. this.debug && console.log(`resizing from ${this.capacity} \u2192 ${e}`);
  33644. let i = e * zm.eSize,
  33645. r = new ArrayBuffer(i),
  33646. s = Float32Array.BYTES_PER_ELEMENT,
  33647. n = 0,
  33648. a = new Float32Array(r, n * s, 3 * e);
  33649. n += 3 * e;
  33650. let o = new Float32Array(r, n * s, 3 * e);
  33651. n += 3 * e;
  33652. let l = new Float32Array(r, n * s, 2 * e);
  33653. a.set(this.positions.slice(0, this.size * 3)),
  33654. o.set(this.normals.slice(0, this.size * 3)),
  33655. l.set(this.uvs.slice(0, this.size * 2)),
  33656. (this.buffer = r),
  33657. (this.positions = a),
  33658. (this.normals = o),
  33659. (this.uvs = l),
  33660. (this.capacity = e);
  33661. }
  33662. get(e = 1) {
  33663. let t = this.size + e;
  33664. if (t > this.capacity) {
  33665. let r = this.capacity;
  33666. for (; t > r; ) r *= 2;
  33667. this.realloc(r);
  33668. }
  33669. let i = this.size;
  33670. return (this.size = t), i;
  33671. }
  33672. reserve(e) {
  33673. let t = this.size + e;
  33674. t > this.capacity && this.realloc(t);
  33675. }
  33676. shrink() {
  33677. this.debug && console.log(`shrinking ${this.capacity} \u2192 ${this.size}`), this.realloc(this.size, !0);
  33678. }
  33679. },
  33680. vA = zm;
  33681. vA.eSize = (3 + 3 + 2) * Float32Array.BYTES_PER_ELEMENT;
  33682. var rv = {
  33683. vertices: [160, 160, -160, 160, -160, -160, 160, -160],
  33684. vertexIndices: [1, 0, 3, 2],
  33685. vertexCount: 4,
  33686. elements: [0, 4],
  33687. elementCount: 1,
  33688. mesh: void 0
  33689. },
  33690. yA = { vertices: [], vertexIndices: [], vertexCount: 0, elements: [], elementCount: 0, mesh: void 0 },
  33691. xA = {
  33692. vertices: [-160, 160, 160, -160, 160, 160, -160, -160],
  33693. vertexIndices: [1, 3, 0, 2],
  33694. vertexCount: 4,
  33695. elements: [0, 1, 2, 1, 0, 3],
  33696. elementCount: 2,
  33697. mesh: void 0
  33698. },
  33699. Zp =
  33700. (e, t) =>
  33701. ([i, r]) => (r < i && (r += t), (e >= i ? e : e + t) <= r),
  33702. bA = class extends Ve {
  33703. constructor(e, t, i = 0, r = 12, s = 3, n = yt.ODD) {
  33704. super(),
  33705. (this.type = 'ShapeGeometry'),
  33706. (this.vertexCache = {}),
  33707. (this._shape = e),
  33708. (this._depth = t),
  33709. (this._bevel = i),
  33710. (this._curveSegments = r),
  33711. (this._bevelSegmentsInput = s),
  33712. i <= 0
  33713. ? ((this._bevelSize = 0), (this._bevelSegments = 0))
  33714. : ((this._bevelSize = Math.min(i, t / 2 - 1e-12)), (this._bevelSegments = Math.floor(s)));
  33715. let a = this._shape.extractShapePointsToFlatArray([], r),
  33716. o = this._shape.shapeHoles.map((w) => {
  33717. let A = w.extractShapePointsToFlatArray([], r),
  33718. S = [];
  33719. for (let _ = A.length - 1; _ >= 1; _ -= 2) {
  33720. let M = A[_ - 1],
  33721. C = A[_ - 0];
  33722. S.push(M, C);
  33723. }
  33724. return S;
  33725. }),
  33726. l;
  33727. try {
  33728. l = _n({ windingRule: n, elementType: Zt.BOUNDARY_CONTOURS, vertexSize: 2, strict: !0, contours: [a] });
  33729. } catch {
  33730. l = rv;
  33731. }
  33732. let h;
  33733. try {
  33734. h = _n({ windingRule: yt.ODD, elementType: Zt.BOUNDARY_CONTOURS, vertexSize: 2, strict: !0, contours: [...o] });
  33735. } catch {
  33736. h = yA;
  33737. }
  33738. if (!l) throw new Error('error generating geometry');
  33739. let u = l.elementCount;
  33740. if (h) {
  33741. l.elementCount += h.elementCount;
  33742. for (let w = 0; w < h.elements.length; w++) {
  33743. let A = h.elements[w],
  33744. S = w % 2 === 0 ? l.vertexCount : 0;
  33745. l.elements.push(A + S);
  33746. }
  33747. for (let w = 0; w < h.vertexIndices.length; w++) {
  33748. let A = h.vertexIndices[w],
  33749. S = l.vertexCount;
  33750. l.vertexIndices.push(A + S);
  33751. }
  33752. for (let w = 0; w < h.vertices.length; w++) {
  33753. let A = h.vertices[w];
  33754. l.vertices.push(A);
  33755. }
  33756. }
  33757. let c = 1 / 0,
  33758. d = -1 / 0,
  33759. p = 1 / 0,
  33760. f = -1 / 0;
  33761. for (let w = 0, A = l.vertexCount; w < A; w++) {
  33762. let S = w * 2,
  33763. _ = l.vertices[S + 0],
  33764. M = l.vertices[S + 1];
  33765. _ < c && (c = _), _ > d && (d = _), M < p && (p = M), M > f && (f = M);
  33766. }
  33767. (this._minX = c),
  33768. (this._minY = p),
  33769. (this._width = d - c),
  33770. (this._height = f - p),
  33771. (this._buffer = new vA(this._computeBufferEstimatedSize(l)));
  33772. let g = [],
  33773. m = [];
  33774. for (let w = l.elementCount - 1; w >= 0; w--) {
  33775. let A = w >= u,
  33776. S = w * 2,
  33777. _ = l.elements[S + 0],
  33778. M = l.elements[S + 1],
  33779. C = _ + M,
  33780. T = { start: _, count: M, normals: [], continuous: [], concave: [] },
  33781. P = _,
  33782. L = C - 1,
  33783. D = _ + 1,
  33784. k = this._shape.roundedCurves.length;
  33785. do {
  33786. let j = P - _,
  33787. U = l.vertices[L * 2 + 0],
  33788. N = l.vertices[L * 2 + 1],
  33789. B = l.vertices[P * 2 + 0],
  33790. H = l.vertices[P * 2 + 1],
  33791. Q = l.vertices[D * 2 + 0],
  33792. Y = l.vertices[D * 2 + 1],
  33793. F = B - U,
  33794. se = H - N,
  33795. V = Math.sqrt(F * F + se * se);
  33796. (F /= V), (se /= V);
  33797. let ee = B - Q,
  33798. J = H - Y,
  33799. fe = Math.sqrt(ee * ee + J * J);
  33800. (ee /= fe), (J /= fe), (T.normals[j * 2 + 0] = -J), (T.normals[j * 2 + 1] = ee), (T.concave[j] = F * J - se * ee > 0);
  33801. let re = l.vertexIndices[P];
  33802. if (Array.isArray(re)) T.continuous[j] = !1;
  33803. else {
  33804. let [oe, ue] = this._shape.getCurveIndexFromVertexId(re - 1, !0);
  33805. if (ue > 0 && ue < 1) T.continuous[j] = !0;
  33806. else {
  33807. let ye = ue === 1 ? oe + 1 : oe - 1;
  33808. ye = (ye + k) % k;
  33809. let Te = ue === 1 ? 0 : 1,
  33810. xe = this._shape.roundedCurves[oe].getTangent(ue),
  33811. we = this._shape.roundedCurves[ye].getTangent(Te);
  33812. T.continuous[j] = xe.dot(we) > 0.95;
  33813. }
  33814. }
  33815. A && ((T.normals[j * 2 + 0] *= -1), (T.normals[j * 2 + 1] *= -1)), ([L, P, D] = [P, D, D + 1]), D >= C && (D -= M);
  33816. } while (D !== _ + 1);
  33817. let W = [];
  33818. W.push({
  33819. bevelI: 0,
  33820. angle: 0,
  33821. size: 0,
  33822. boundary: {
  33823. vertices: l.vertices.slice(_ * 2, C * 2),
  33824. vertexCount: M,
  33825. vertexIndices: new Array(M).fill(!0).map((j, U) => [U, U]),
  33826. elements: [0, M],
  33827. elementCount: 1,
  33828. mesh: null
  33829. },
  33830. reverseMap: [],
  33831. insetPoints: l.vertices.slice(_ * 2, C * 2)
  33832. });
  33833. for (let j = 1; j <= this._bevelSegments; j++) {
  33834. let U = ((j / this._bevelSegments) * Math.PI) / 2,
  33835. N = (1 - Math.cos(U)) * this._bevelSize,
  33836. B = [],
  33837. H = [],
  33838. Q = [],
  33839. Y = [],
  33840. F = 0;
  33841. for (let V = 0; V < M; V++) {
  33842. let ee = V * 2,
  33843. J = ((V - 1 + M) % M) * 2,
  33844. fe = l.vertices[T.start * 2 + ee + 0],
  33845. re = l.vertices[T.start * 2 + ee + 1],
  33846. oe = -T.normals[J + 0] * N,
  33847. ue = -T.normals[J + 1] * N,
  33848. ye = -T.normals[ee + 0] * N,
  33849. Te = -T.normals[ee + 1] * N;
  33850. if (T.concave[V] || (!T.concave[V] && A)) {
  33851. let xe = Math.atan2(ue, oe),
  33852. we = Math.atan2(Te, ye);
  33853. we > xe && (we -= Math.PI * 2);
  33854. let Ie = we - xe;
  33855. if (T.continuous[V] || A) {
  33856. let He = xe + Ie / 2,
  33857. dt = Math.cos(He) * N,
  33858. I = Math.sin(He) * N;
  33859. (B[2 * F + 0] = fe + dt * (A ? -1 : 1)), (B[2 * F + 1] = re + I * (A ? -1 : 1)), (Y[F] = V), F++;
  33860. } else {
  33861. let He = Math.max(1, Math.floor(((r / 4) * Math.abs(Ie)) / Math.PI));
  33862. for (let dt = 0; dt <= He; dt++) {
  33863. let I = xe + Ie * (dt / He),
  33864. O = Math.cos(I) * N,
  33865. ie = Math.sin(I) * N;
  33866. (B[2 * F + 0] = fe + O), (B[2 * F + 1] = re + ie), (Y[F] = V), F++;
  33867. }
  33868. }
  33869. } else
  33870. (B[2 * F + 0] = fe + oe),
  33871. (B[2 * F + 1] = re + ue),
  33872. (Y[F] = V),
  33873. (H[V] = F),
  33874. F++,
  33875. (B[2 * F + 0] = fe),
  33876. (B[2 * F + 1] = re),
  33877. (Y[F] = V),
  33878. F++,
  33879. (B[2 * F + 0] = fe + ye),
  33880. (B[2 * F + 1] = re + Te),
  33881. (Y[F] = V),
  33882. (Q[V] = F),
  33883. F++;
  33884. }
  33885. let se = _n({
  33886. windingRule: yt.POSITIVE,
  33887. elementType: Zt.BOUNDARY_CONTOURS,
  33888. vertexSize: 2,
  33889. strict: !0,
  33890. contours: [B],
  33891. edgeCreateCallback: (V) => {
  33892. let ee = V.Org.idx,
  33893. J = Y[ee],
  33894. fe = Y[(ee + 1) % Y.length];
  33895. (V.idx = [J, fe]), (V.Sym.idx = [fe, J]);
  33896. },
  33897. vertexIdCallback: (V) => {
  33898. let ee = V.Lprev.idx;
  33899. return [ee ? ee[1] : 0, V.idx ? V.idx[0] : 0];
  33900. }
  33901. });
  33902. if (!se) throw (console.log('Error'), new Error(`error generating bevel geometry for ${j}'th loop`));
  33903. if (!se.vertexCount) break;
  33904. for (let V = 0; V < se.vertexIndices.length; V++) {
  33905. let [ee, J] = se.vertexIndices[V];
  33906. if (ee === J) continue;
  33907. let fe = J;
  33908. J < ee && (fe += M);
  33909. for (let re = ee; re < fe; re++) {
  33910. let oe = re % M,
  33911. ue = (re + 1) % M;
  33912. if (!T.continuous[oe] || !T.continuous[ue]) {
  33913. (se.vertexIndices[V] = [ee, oe]),
  33914. se.vertexIndices.splice(V + 1, 0, [ue, J]),
  33915. se.vertices.splice((V + 1) * 2, 0, se.vertices[V * 2], se.vertices[V * 2 + 1]);
  33916. break;
  33917. }
  33918. }
  33919. }
  33920. W.push({ bevelI: j, angle: U, size: N, boundary: se, reverseMap: Y, insetPoints: B });
  33921. }
  33922. let X = (j, U, N) => {
  33923. let B = 0,
  33924. H = j.boundary.vertexIndices.length;
  33925. for (; B < H && N(j.boundary.vertexIndices[U]); ) (U = (U + 1) % H), B++;
  33926. return B;
  33927. },
  33928. z = g.length;
  33929. for (let j = 1; j < W.length; j++) {
  33930. let U = W[j - 1],
  33931. N = W[j],
  33932. B = U.boundary.vertexIndices.length,
  33933. H = N.boundary.vertexIndices.length;
  33934. if (!B || !H) break;
  33935. let Q = T.concave.length,
  33936. Y = 0,
  33937. F = Zp(Y, M);
  33938. for (; !U.boundary.vertexIndices.filter(F).length || !N.boundary.vertexIndices.filter(F).length; ) Y++, (F = Zp(Y, M));
  33939. let se = U.boundary.vertexIndices.findIndex(F),
  33940. V = N.boundary.vertexIndices.findIndex(F);
  33941. do {
  33942. se = (se + 1) % B;
  33943. } while (F(U.boundary.vertexIndices[se]));
  33944. do {
  33945. V = (V + 1) % H;
  33946. } while (F(N.boundary.vertexIndices[V]));
  33947. Y = (Y + 1) % M;
  33948. let ee = Y,
  33949. J = this._buildBevelVert(T, U, (se - 1 + B) % B),
  33950. fe = this._buildBevelVert(T, N, (V - 1 + H) % H),
  33951. re = J,
  33952. oe = fe,
  33953. ue,
  33954. ye,
  33955. Te = !1;
  33956. do {
  33957. F = Zp(Y, M);
  33958. let xe = X(U, se, F),
  33959. we = X(N, V, F),
  33960. Ie = Te;
  33961. if (((Te = !1), xe && !we)) {
  33962. for (let He = 0; He < xe; He++)
  33963. (ue = this._buildBevelVert(T, U, (se + He) % B, He / (xe - 1))),
  33964. g.push(re.topN, ue.topP, oe.topN),
  33965. g.push(ue.bottomP, re.bottomN, oe.bottomN),
  33966. (re = ue);
  33967. Te = !0;
  33968. } else if (!xe && we)
  33969. for (let He = 0; He < we; He++)
  33970. (ye = this._buildBevelVert(T, N, (V + He) % H, He / (we - 1))),
  33971. g.push(oe.topN, re.topP, ye.topP),
  33972. g.push(re.bottomP, oe.bottomN, ye.bottomP),
  33973. (oe = ye);
  33974. else if (xe && we)
  33975. if (
  33976. ((ue = this._buildBevelVert(T, U, se, 0)),
  33977. (ye = this._buildBevelVert(T, N, V, 0)),
  33978. Ie
  33979. ? (g.push(re.topN, ye.topP, oe.topN),
  33980. g.push(re.topN, ue.topP, ye.topP),
  33981. g.push(ye.bottomP, re.bottomN, oe.bottomN),
  33982. g.push(ye.bottomP, ue.bottomP, re.bottomN))
  33983. : (g.push(oe.topN, re.topN, ue.topP),
  33984. g.push(oe.topN, ue.topP, ye.topP),
  33985. g.push(ue.bottomP, re.bottomN, oe.bottomN),
  33986. g.push(ue.bottomP, oe.bottomN, ye.bottomP)),
  33987. (re = ue),
  33988. (oe = ye),
  33989. xe === we)
  33990. )
  33991. for (let He = 1; He < xe; He++)
  33992. (ue = this._buildBevelVert(T, U, (se + He) % B, He / (xe - 1))),
  33993. (ye = this._buildBevelVert(T, N, (V + He) % H, He / (we - 1))),
  33994. g.push(re.topN, ue.topP, oe.topN),
  33995. g.push(oe.topN, ue.topP, ye.topP),
  33996. g.push(ue.bottomP, re.bottomN, oe.bottomN),
  33997. g.push(ue.bottomP, oe.bottomN, ye.bottomP),
  33998. (re = ue),
  33999. (oe = ye);
  34000. else if (xe > we) {
  34001. let He = xe / we,
  34002. dt = 0;
  34003. for (let I = 1; I < xe; I++)
  34004. (ue = this._buildBevelVert(T, U, (se + I) % B, I / (xe - 1))),
  34005. g.push(re.topN, ue.topP, oe.topN),
  34006. g.push(ue.bottomP, re.bottomN, oe.bottomN),
  34007. (re = ue),
  34008. I > (dt + 1) * He &&
  34009. (dt++,
  34010. (ye = this._buildBevelVert(T, N, (V + dt) % H, dt / (we - 1))),
  34011. g.push(oe.topN, ue.topP, ye.topP),
  34012. g.push(ue.bottomP, oe.bottomN, ye.bottomP),
  34013. (oe = ye));
  34014. } else {
  34015. let He = we / xe,
  34016. dt = 0;
  34017. for (let I = 1; I < we; I++)
  34018. (ye = this._buildBevelVert(T, N, (V + I) % H, I / (we - 1))),
  34019. g.push(oe.topN, ue.topP, ye.topP),
  34020. g.push(ue.bottomP, oe.bottomN, ye.bottomP),
  34021. (oe = ye),
  34022. I > (dt + 1) * He &&
  34023. (dt++,
  34024. (ue = this._buildBevelVert(T, U, (se + dt) % B, dt / (xe - 1))),
  34025. g.push(re.topN, ue.topP, oe.topN),
  34026. g.push(ue.bottomP, re.bottomN, oe.bottomN),
  34027. (re = ue));
  34028. }
  34029. (se = (se + xe) % B), (V = (V + we) % H), (Y = (Y + 1) % Q);
  34030. } while (Y !== ee);
  34031. }
  34032. if ((this._buildWall(W, T, g), A)) {
  34033. let j = [];
  34034. for (let U = g.length - 1; U >= z + 2; U -= 3) {
  34035. let N = g[U - 2],
  34036. B = g[U - 1],
  34037. H = g[U - 0];
  34038. j.push(H, B, N);
  34039. }
  34040. g.splice(z, g.length - z, ...j);
  34041. }
  34042. if (A) {
  34043. let j = [];
  34044. for (let U = W[W.length - 1].boundary.vertices.length - 1; U >= 1; U -= 2) {
  34045. let N = W[W.length - 1].boundary.vertices[U - 1],
  34046. B = W[W.length - 1].boundary.vertices[U - 0];
  34047. j.push(N, B);
  34048. }
  34049. m.push(j);
  34050. }
  34051. if (!A) {
  34052. let j = W[W.length - 1],
  34053. U;
  34054. try {
  34055. U = _n({
  34056. windingRule: W.length > 1 ? yt.POSITIVE : yt.ODD,
  34057. elementType: Zt.POLYGONS,
  34058. vertexSize: 2,
  34059. strict: !0,
  34060. contours: [j.insetPoints, ...m]
  34061. });
  34062. } catch {
  34063. U = xA;
  34064. }
  34065. if (!U) throw new Error('Error generating geometry for surface');
  34066. o.length === 0 && Object.assign(this, { capStartIndex: g.length });
  34067. for (let N = 0; N < U.elementCount * 3; N += 3) {
  34068. let B = this._buildSurfaceVert(U, U.elements[N + 0]),
  34069. H = this._buildSurfaceVert(U, U.elements[N + 1]),
  34070. Q = this._buildSurfaceVert(U, U.elements[N + 2]);
  34071. g.push(B.top, H.top, Q.top), g.push(Q.bottom, H.bottom, B.bottom);
  34072. }
  34073. }
  34074. this.vertexCache = {};
  34075. }
  34076. this._buffer.shrink();
  34077. let v = new Xe(Uint32Array.from(g), 1),
  34078. y = new Xe(this._buffer.positions, 3),
  34079. b = new Xe(this._buffer.normals, 3),
  34080. x = new Xe(this._buffer.uvs, 2);
  34081. (y.needsUpdate = !0),
  34082. (b.needsUpdate = !0),
  34083. (x.needsUpdate = !0),
  34084. (v.needsUpdate = !0),
  34085. this.setAttribute('position', y),
  34086. this.setAttribute('normal', b),
  34087. this.setAttribute('uv', x),
  34088. this.setIndex(v);
  34089. }
  34090. _computeBufferEstimatedSize(e) {
  34091. return e.vertexCount * 2 * (2 + this._bevelSegments);
  34092. }
  34093. _buildWall(e, t, i) {
  34094. let r = e[0];
  34095. for (let s = 0, n = r.boundary.vertexCount; s < n; s++) {
  34096. let a = this._buildBevelVert(t, r, s),
  34097. o = this._buildBevelVert(t, r, (s + 1) % n);
  34098. i.push(o.topP, a.topN, a.bottomN), i.push(o.topP, a.bottomN, o.bottomP);
  34099. }
  34100. }
  34101. _buildSurfaceVert(e, t) {
  34102. let i = t.toString();
  34103. if (i in this.vertexCache) return this.vertexCache[i];
  34104. let r = e.vertices[t * 2 + 0],
  34105. s = e.vertices[t * 2 + 1],
  34106. n = (r - this._minX) / this._width,
  34107. a = (s - this._minY) / this._height,
  34108. o = this._buffer.get(2),
  34109. l = o * 3,
  34110. h = o * 2,
  34111. u = { top: o + 0, bottom: o + 1 };
  34112. return (
  34113. (this._buffer.positions[l + 0] = r),
  34114. (this._buffer.positions[l + 1] = s),
  34115. (this._buffer.positions[l + 2] = this._depth),
  34116. (this._buffer.normals[l + 0] = 0),
  34117. (this._buffer.normals[l + 1] = 0),
  34118. (this._buffer.normals[l + 2] = 1),
  34119. (this._buffer.uvs[h + 0] = n),
  34120. (this._buffer.uvs[h + 1] = a),
  34121. (this._buffer.positions[l + 3] = r),
  34122. (this._buffer.positions[l + 4] = s),
  34123. (this._buffer.positions[l + 5] = 0),
  34124. (this._buffer.normals[l + 3] = 0),
  34125. (this._buffer.normals[l + 4] = 0),
  34126. (this._buffer.normals[l + 5] = -1),
  34127. (this._buffer.uvs[h + 2] = n),
  34128. (this._buffer.uvs[h + 3] = a),
  34129. (this.vertexCache[i] = u),
  34130. u
  34131. );
  34132. }
  34133. _buildBevelVert(e, t, i, r = 1) {
  34134. let s = `${t.bevelI}:${i}`;
  34135. if (s in this.vertexCache) return this.vertexCache[s];
  34136. let [n, a] = t.boundary.vertexIndices[i],
  34137. o,
  34138. l,
  34139. h,
  34140. u;
  34141. n !== a
  34142. ? ((l = n), (o = a), (u = !1), (h = e.continuous[l] && e.continuous[o]))
  34143. : ((o = n), (l = (o - 1 + e.count) % e.count), (u = e.concave[o] && t.bevelI > 0), (h = e.continuous[o] || u));
  34144. let c = Math.cos(t.angle),
  34145. d = Math.sin(t.angle),
  34146. p = i * 2,
  34147. f = o * 2,
  34148. g = l * 2,
  34149. m = t.boundary.vertices[p + 0],
  34150. v = t.boundary.vertices[p + 1],
  34151. y = (1 - d) * this._bevelSize,
  34152. b = (m - this._minX) / this._width,
  34153. x = (v - this._minY) / this._height,
  34154. w = e.normals[f + 0],
  34155. A = e.normals[f + 1],
  34156. S = e.normals[g + 0],
  34157. _ = e.normals[g + 1];
  34158. if (u) {
  34159. let L = S - w,
  34160. D = _ - A;
  34161. (w = w + L * (1 - r)), (A = A + D * (1 - r));
  34162. let k = Math.sqrt(w * w + A * A);
  34163. (w /= k), (A /= k);
  34164. }
  34165. let M = this._buffer.get(h ? 2 : 4),
  34166. C = M * 3,
  34167. T = M * 2,
  34168. P = { i: i, fi: o, topP: M + 0, topN: M + 0, bottomP: M + 1, bottomN: M + 1 };
  34169. return (
  34170. (this._buffer.positions[C + 0] = m),
  34171. (this._buffer.positions[C + 1] = v),
  34172. (this._buffer.positions[C + 2] = this._depth - y),
  34173. (this._buffer.normals[C + 0] = w * c),
  34174. (this._buffer.normals[C + 1] = A * c),
  34175. (this._buffer.normals[C + 2] = d),
  34176. (this._buffer.uvs[T + 0] = b),
  34177. (this._buffer.uvs[T + 1] = x),
  34178. (this._buffer.positions[C + 3] = m),
  34179. (this._buffer.positions[C + 4] = v),
  34180. (this._buffer.positions[C + 5] = y),
  34181. (this._buffer.normals[C + 3] = w * c),
  34182. (this._buffer.normals[C + 4] = A * c),
  34183. (this._buffer.normals[C + 5] = -d),
  34184. (this._buffer.uvs[T + 2] = x),
  34185. (this._buffer.uvs[T + 3] = b),
  34186. h ||
  34187. ((M += 2),
  34188. (C += 6),
  34189. (T += 4),
  34190. (P.topP = M + 0),
  34191. (P.bottomP = M + 1),
  34192. (this._buffer.positions[C + 0] = m),
  34193. (this._buffer.positions[C + 1] = v),
  34194. (this._buffer.positions[C + 2] = this._depth - y),
  34195. (this._buffer.normals[C + 0] = S * c),
  34196. (this._buffer.normals[C + 1] = _ * c),
  34197. (this._buffer.normals[C + 2] = d),
  34198. (this._buffer.uvs[T + 0] = b),
  34199. (this._buffer.uvs[T + 1] = x),
  34200. (this._buffer.positions[C + 3] = m),
  34201. (this._buffer.positions[C + 4] = v),
  34202. (this._buffer.positions[C + 5] = y),
  34203. (this._buffer.normals[C + 3] = S * c),
  34204. (this._buffer.normals[C + 4] = _ * c),
  34205. (this._buffer.normals[C + 5] = -d),
  34206. (this._buffer.uvs[T + 2] = x),
  34207. (this._buffer.uvs[T + 3] = b)),
  34208. (this.vertexCache[s] = P),
  34209. P
  34210. );
  34211. }
  34212. clone() {
  34213. let e = new bA(this._shape, this._depth, this._bevel, this._curveSegments, this._bevelSegmentsInput);
  34214. return (e.userData = yu(this.userData)), e;
  34215. }
  34216. },
  34217. wA = class extends Ve {
  34218. constructor(e, t = 12, i = {}) {
  34219. super(),
  34220. (this.type = 'ShapeGeometry'),
  34221. (this.windingRule = yt.ODD),
  34222. (this.elementType = Zt.POLYGONS),
  34223. (this.polySize = 3),
  34224. (this.vertexSize = 2),
  34225. (this.strict = !0),
  34226. (this._shape = e),
  34227. (this._curveSegments = t),
  34228. (this._triangulationOptions = Object.assign(
  34229. { windingRule: yt.ODD, elementType: Zt.POLYGONS, polySize: 3, vertexSize: 2, strict: !0 },
  34230. i
  34231. ));
  34232. let r = this._shape.extractShapePointsToFlatArray([], this._curveSegments),
  34233. s = this._shape.shapeHoles.map((d) => d.extractShapePointsToFlatArray([], this._curveSegments)),
  34234. n,
  34235. a = !0,
  34236. o = !0,
  34237. l,
  34238. h;
  34239. for (let d = 0, p = r.length / 2; d < p; d++) {
  34240. let f = d * 2,
  34241. g = r[f + 0],
  34242. m = r[f + 1];
  34243. if ((l !== void 0 && g !== l && (a = !1), h !== void 0 && m !== h && (o = !1), (l = g), (h = m), !a && !o)) break;
  34244. }
  34245. if (!a && !o)
  34246. try {
  34247. n = _n({
  34248. contours: [r, ...s],
  34249. windingRule: this._triangulationOptions.windingRule,
  34250. elementType: this._triangulationOptions.elementType,
  34251. polySize: this._triangulationOptions.polySize,
  34252. vertexSize: this._triangulationOptions.vertexSize,
  34253. strict: this._triangulationOptions.strict
  34254. });
  34255. } catch {
  34256. n = rv;
  34257. }
  34258. let u = n?.vertexCount ?? 1,
  34259. c = n?.elementCount ?? 1;
  34260. if (
  34261. ((this._positionAttribute = new Xe(new Float32Array(u * 3), 3)),
  34262. (this._normalAttribute = new Xe(new Float32Array(u * 3), 3)),
  34263. (this._uvAttribute = new Xe(new Float32Array(u * 2), 2)),
  34264. (this._indexAttribute = new Xe(new Uint32Array(c * 3), 1)),
  34265. n)
  34266. ) {
  34267. let d = 1 / 0,
  34268. p = -1 / 0,
  34269. f = 1 / 0,
  34270. g = -1 / 0;
  34271. for (let y = 0, b = u; y < b; y++) {
  34272. let x = y * 2,
  34273. w = n.vertices[x + 0],
  34274. A = n.vertices[x + 1];
  34275. w < d && (d = w), w > p && (p = w), A < f && (f = A), A > g && (g = A);
  34276. }
  34277. let m = p - d,
  34278. v = g - f;
  34279. for (let y = 0, b = u; y < b; y++) {
  34280. let x = y * 2,
  34281. w = n.vertices[x + 0],
  34282. A = n.vertices[x + 1],
  34283. S = (w - d) / m,
  34284. _ = (A - f) / v;
  34285. this._positionAttribute.setXYZ(y, w, A, 0), this._normalAttribute.setXYZ(y, 0, 0, 1), this._uvAttribute.setXY(y, S, _);
  34286. }
  34287. for (let y = 0, b = c; y < b; y++) {
  34288. let x = y * 3,
  34289. w = n.elements[x + 0],
  34290. A = n.elements[x + 1],
  34291. S = n.elements[x + 2];
  34292. this._indexAttribute.setX(x + 0, w), this._indexAttribute.setX(x + 1, A), this._indexAttribute.setX(x + 2, S);
  34293. }
  34294. }
  34295. this.setAttribute('position', this._positionAttribute),
  34296. this.setAttribute('normal', this._normalAttribute),
  34297. this.setAttribute('uv', this._uvAttribute),
  34298. this.setIndex(this._indexAttribute),
  34299. this.setDrawRange(0, (n?.elementCount ?? 1) * 3);
  34300. }
  34301. clone() {
  34302. let e = new wA(this._shape, this._curveSegments);
  34303. return (e.userData = yu(this.userData)), e;
  34304. }
  34305. },
  34306. _A = class extends bA {
  34307. constructor(e, t, i = 0, r = 12, s = 3, n = yt.ODD) {
  34308. super(e, t, i, r, s, n), (this.type = 'ShapeGeometry');
  34309. }
  34310. _computeBufferEstimatedSize(e) {
  34311. return e.vertexCount * 2 * (2 + this._bevelSegments);
  34312. }
  34313. _buildWall(e, t, i) {
  34314. let r = e[0];
  34315. for (let s = 0, n = r.boundary.vertexCount; s < n; s++) {
  34316. let a = this._buildBevelVert(t, r, s),
  34317. o = this._buildBevelVert(t, r, (s + 1) % n);
  34318. i.push(o.topP, a.topN, a.bottomN), i.push(o.topP, a.bottomN, o.bottomP);
  34319. }
  34320. }
  34321. clone() {
  34322. let e = new _A(this._shape, this._depth, this._bevel, this._curveSegments, this._bevelSegmentsInput);
  34323. return (e.userData = yu(this.userData)), e;
  34324. }
  34325. },
  34326. Ta = class {
  34327. static create(e) {
  34328. return this.build(this.normalizeInputs(e));
  34329. }
  34330. static normalizeInputs(e, t) {
  34331. let i = Object.assign(
  34332. {},
  34333. t?.parameters ?? {
  34334. width: 100,
  34335. subdivisions: 40,
  34336. roundness: 0,
  34337. extrudeBevelSize: 0,
  34338. extrudeBevelSegments: 3,
  34339. windingRule: yt.ODD
  34340. },
  34341. e.parameters
  34342. ),
  34343. r = Math.abs(i.width),
  34344. s = Math.abs(i.height ?? i.width),
  34345. n = Math.abs(i.depth ?? 0),
  34346. a = e.shape ?? t?.shape,
  34347. o = a?.roundness ?? i.roundness;
  34348. a !== void 0 &&
  34349. (a instanceof Nt ? (a.width !== r || a.height !== s) && a.applySize(r, s) : (a = new Nt(r, s).fromJSON(a)),
  34350. e.parameters?.roundness !== void 0 && e.parameters?.roundness > 0 && a.update());
  34351. let l = a ?? new Nt(r, s);
  34352. return { parameters: Object.assign(i, { width: r, height: s, depth: n, roundness: o }), shape: l };
  34353. }
  34354. static build(e) {
  34355. let { depth: t, extrudeBevelSize: i, extrudeBevelSegments: r, subdivisions: s, roundness: n, windingRule: a } = e.parameters;
  34356. e.shape.roundness = n;
  34357. let o;
  34358. return (
  34359. t <= 0 ? (o = new wA(e.shape, s, { windingRule: a })) : (o = new _A(e.shape, t, i, s, r, a)),
  34360. Object.assign(o, { userData: { ...e, type: 'VectorGeometry' } })
  34361. );
  34362. }
  34363. },
  34364. AA = Math.PI * 2,
  34365. sv = class {
  34366. static create(e) {
  34367. return this.build(this.normalizeInputs(e));
  34368. }
  34369. static normalizeInputs(e, t) {
  34370. let i = Object.assign(
  34371. {},
  34372. t?.parameters ?? { width: 100, depth: 0, spikes: 64, angle: 360, innerRadius: 0, extrudeBevelSize: 0, extrudeBevelSegments: 1 },
  34373. e.parameters
  34374. );
  34375. return {
  34376. shape: e.shape && e.shape instanceof Nt ? e.shape : new Nt(),
  34377. parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? 0) })
  34378. };
  34379. }
  34380. static build(e) {
  34381. let {
  34382. width: t,
  34383. height: i,
  34384. spikes: r,
  34385. angle: s,
  34386. innerRadius: n,
  34387. depth: a,
  34388. extrudeBevelSize: o,
  34389. extrudeBevelSegments: l
  34390. } = e.parameters,
  34391. h = e.shape,
  34392. u = t * 0.5,
  34393. c = i * 0.5,
  34394. d = JF(h, u, c, (s * Math.PI) / 180, r, n);
  34395. (h.isClosed = !0), h.update();
  34396. let p = Ta.create({ shape: h, parameters: { subdivisions: d, depth: a, extrudeBevelSize: o, extrudeBevelSegments: l } });
  34397. return Object.assign(p, { userData: { ...e, type: 'EllipseGeometry' } });
  34398. }
  34399. };
  34400. function JF(e, t, i, r, s, n) {
  34401. if (r >= AA) return s > 30 || s % 4 === 0 ? (e6(e, t, i, n), Math.round(s / 4)) : Ex(e, r, s, t, i, n);
  34402. r = Math.max(r, 0.001);
  34403. let a = { x: 0, y: i },
  34404. o = r + Math.PI * 0.5,
  34405. l = { x: Math.cos(o) * t, y: Math.sin(o) * i },
  34406. h = qF({ px: a.x, py: a.y, cx: l.x, cy: l.y, rx: t, ry: i, largeArcFlag: r > Math.PI, sweepFlag: !0 });
  34407. return s > 30 || s % h.length === 0 ? $F(e, a.x, a.y, h, s, t, i, n) : Ex(e, r, s, t, i, n);
  34408. }
  34409. function $F(e, t, i, r, s, n, a, o) {
  34410. let l = Math.round(s / r.length);
  34411. e.addPoint(Do(t, i));
  34412. for (let h = 0, u = r.length; h < u; h++) {
  34413. let c = r[h],
  34414. d = e.points[h],
  34415. p = Do(c.x, c.y);
  34416. d.controls[1].position.set(c.x1, c.y1), p.controls[0].position.set(c.x2, c.y2), e.addPoint(p);
  34417. }
  34418. return o > 0 ? SA(e, n, a, o) : e.addPoint(Do(0, 0)), l;
  34419. }
  34420. function Ex(e, t, i, r, s, n) {
  34421. let a = -t / i;
  34422. for (let o = 0; o <= i; o++) {
  34423. let l = a * o,
  34424. h = Math.sin(l) * r,
  34425. u = Math.cos(l) * s;
  34426. e.addPoint(Do(h, u));
  34427. }
  34428. return (
  34429. t < AA ? (n > 0 ? SA(e, r, s, n) : e.addPoint(Do(0, 0))) : (e.removePoint(e.points[e.points.length - 1]), n > 0 && MA(e, r, s, n)), 1
  34430. );
  34431. }
  34432. function e6(e, t, i, r = 0, s = 0, n = 0) {
  34433. let a = 0.5522847498,
  34434. o = t * a,
  34435. l = i * a;
  34436. e.addPoint(Ic(s - t, n, s - t, n - l, s - t, n + l)),
  34437. e.addPoint(Ic(s, n + i, s - o, n + i, s + o, n + i)),
  34438. e.addPoint(Ic(s + t, n, s + t, n + l, s + t, n - l)),
  34439. e.addPoint(Ic(s, n - i, s + o, n - i, s - o, n - i)),
  34440. r > 0 && MA(e, t, i, r);
  34441. }
  34442. function Do(e, t) {
  34443. return new Po(it.generateUUID(), new G(e, t));
  34444. }
  34445. function Ic(e, t, i, r, s, n) {
  34446. let a = Do(e, t);
  34447. return a.controls[0].position.set(i, r), a.controls[1].position.set(s, n), a;
  34448. }
  34449. function SA(e, t, i, r) {
  34450. EA(e, t, i, r).forEach((s) => e.addPoint(s));
  34451. }
  34452. function MA(e, t, i, r) {
  34453. let s = EA(e, t, i, r),
  34454. n = new Nt();
  34455. s.forEach((a) => n.addPoint(a)), (n.isClosed = !0), e.shapeHoles.push(n);
  34456. }
  34457. function EA(e, t, i, r) {
  34458. let s = (r * t) / 100,
  34459. n = s * (Math.abs(i) / Math.abs(t)),
  34460. a = new G(s / t, n / i),
  34461. o = e.points
  34462. .map((l) => {
  34463. let h = l.clone();
  34464. return (h.uuid = it.generateUUID()), h;
  34465. })
  34466. .reverse();
  34467. return (
  34468. o.forEach((l) => {
  34469. l.position.multiply(a);
  34470. let h = l.controls[0].position.clone().multiply(a),
  34471. u = l.controls[1].position.clone().multiply(a);
  34472. l.controls[0].position.copy(u), l.controls[1].position.copy(h);
  34473. }),
  34474. o
  34475. );
  34476. }
  34477. var t6 = class {
  34478. static create(e) {
  34479. return this.build(this.normalizeInputs(e));
  34480. }
  34481. static normalizeInputs(e, t) {
  34482. let i = Object.assign(
  34483. {},
  34484. t?.parameters ?? {
  34485. width: 100,
  34486. revolutions: 2,
  34487. segments: 40,
  34488. pathRadius: 10,
  34489. pathType: 0,
  34490. pathSegments: 30,
  34491. cornerRadius: 30,
  34492. cornerSegments: 4
  34493. },
  34494. e.parameters
  34495. ),
  34496. r = Math.abs(i.width),
  34497. s = Math.abs(i.height ?? r),
  34498. n = Math.abs(i.depth ?? r),
  34499. a = Math.abs(Math.min(r, n)) / 2;
  34500. return {
  34501. parameters: Object.assign(i, {
  34502. width: r,
  34503. height: s,
  34504. depth: n,
  34505. radius: a,
  34506. segments: Math.round(i.segments),
  34507. pathSegments: Math.round(i.pathSegments),
  34508. cornerSegments: Math.round(i.cornerSegments)
  34509. })
  34510. };
  34511. }
  34512. static build(e) {
  34513. let {
  34514. width: t,
  34515. height: i,
  34516. depth: r,
  34517. radius: s,
  34518. revolutions: n,
  34519. segments: a,
  34520. pathRadius: o,
  34521. pathType: l,
  34522. pathSegments: h,
  34523. cornerRadius: u,
  34524. cornerSegments: c
  34525. } = e.parameters,
  34526. d = new nv(!1, t, i, r, s, n, a, o, l, h, u, c);
  34527. return Object.assign(d, { userData: { ...e, type: 'HelixGeometry' } });
  34528. }
  34529. },
  34530. nv = class extends Ve {
  34531. constructor(e = !0, t = 1, i = 1, r = 1, s = 1, n = 1, a = 1, o = 1, l = 1, h = 1, u = 1, c = 1, d = !1) {
  34532. super();
  34533. let p = e && n === 1;
  34534. p && (c = 0), u > 100 && (u = 100);
  34535. let f = () => new E(),
  34536. g = new E(),
  34537. m = f(),
  34538. v = f(),
  34539. y = f(),
  34540. b,
  34541. x,
  34542. w,
  34543. A,
  34544. S,
  34545. _,
  34546. M,
  34547. C,
  34548. T = f(),
  34549. P = f(),
  34550. L = f(),
  34551. D = f(),
  34552. k = f(),
  34553. W = f(),
  34554. X = f(),
  34555. z = f(),
  34556. j = i - 2 * o + 0.001,
  34557. U = j / n,
  34558. N = Math.ceil(a * n),
  34559. B = N + 1,
  34560. H = j / N,
  34561. Q = -j / 2,
  34562. Y = h + 1,
  34563. F = (2 * Math.PI) / h,
  34564. se = Math.PI / 2 / c,
  34565. V = 0.01,
  34566. ee = Math.min((1 - u / 100) * o, o - V),
  34567. J = o - ee,
  34568. fe = 0,
  34569. re = 2,
  34570. oe = c * re + re,
  34571. ue = (Y * oe) / re,
  34572. ye = ue + Y * B,
  34573. Te = Y * (B + oe),
  34574. [xe, we, Ie] = [3, 3, 2].map((Ee) => Array(Te * Ee).fill(0)),
  34575. He = [],
  34576. dt = s - o;
  34577. function I(Ee, _e) {
  34578. let Le = Math.PI / 2;
  34579. (_ = _e * H),
  34580. (C = (2 * Math.PI * (_ % U)) / U + Le),
  34581. (_ += Q),
  34582. (M = Math.sin(C) * dt),
  34583. (S = Math.cos(C) * dt),
  34584. e ? Ee.set(S, M, _) : Ee.set(S, _, M);
  34585. }
  34586. I(g, -1e-10), I(m, 0), T.copy(g), I(g, 1);
  34587. let O = g.distanceTo(m),
  34588. ie = p ? 0 : J + ee,
  34589. pe = O * N + 2 * ie,
  34590. me = ee,
  34591. be = pe - ie;
  34592. for (let Ee = 0; Ee <= N; Ee++) {
  34593. I(v, Ee),
  34594. z.subVectors(v, T).normalize(),
  34595. T.copy(v),
  34596. W.copy(v)
  34597. .setComponent(+e + 1, 0)
  34598. .normalize(),
  34599. X.crossVectors(z, W).normalize();
  34600. let _e = Ee === 0,
  34601. Le = Ee === N,
  34602. Ne = _e ? (3 * Math.PI) / 2 : se,
  34603. at = _e ? me : be,
  34604. Mt = _e ? Y : ye,
  34605. Wt = _e ? 0 : Te - Y,
  34606. q = z
  34607. .clone()
  34608. .multiplyScalar(_e ? -J : J)
  34609. .add(v),
  34610. ne = z
  34611. .clone()
  34612. .multiplyScalar(_e ? -1 : 1)
  34613. .normalize();
  34614. for (let de = 0; de < Y; de++) {
  34615. let Ae = de * F;
  34616. if (
  34617. (P.addVectors(g.copy(W).multiplyScalar(o * Math.cos(Ae)), m.copy(X).multiplyScalar(o * Math.sin(Ae))),
  34618. L.copy(P).normalize(),
  34619. _e || Le)
  34620. ) {
  34621. p ||
  34622. ((fe = Wt + de),
  34623. [0, 1, 2].forEach((De) => {
  34624. (xe[fe * 3 + De] = q.getComponent(De)), (we[fe * 3 + De] = ne.getComponent(De));
  34625. }),
  34626. (Ie[fe * 2] = +Le),
  34627. (Ie[fe * 2 + 1] = de / h)),
  34628. m.copy(L).multiplyScalar(ee),
  34629. y.addVectors(v, m);
  34630. for (let De = 0; De < c; De++) {
  34631. let ot = De * se + Ne;
  34632. D.addVectors(g.copy(z).multiplyScalar(J * Math.sin(ot)), m.copy(L).multiplyScalar(J * Math.cos(ot))),
  34633. k.copy(D).normalize(),
  34634. m.addVectors(y, D),
  34635. D.normalize(),
  34636. (fe = Mt + De * Y + de),
  34637. [0, 1, 2].forEach((Ft) => {
  34638. (xe[fe * 3 + Ft] = m.getComponent(Ft)), (we[fe * 3 + Ft] = k.getComponent(Ft));
  34639. });
  34640. let Xt = +_e + Math.sin(ot);
  34641. (Ie[fe * 2] = (at + J * Xt) / pe), (Ie[fe * 2 + 1] = de / h);
  34642. }
  34643. }
  34644. m.addVectors(v, P),
  34645. (fe = ue + Ee * Y + de),
  34646. [0, 1, 2].forEach((De) => {
  34647. (xe[fe * 3 + De] = m.getComponent(De)), (we[fe * 3 + De] = L.getComponent(De));
  34648. }),
  34649. (Ie[fe * 2] = (ie + Ee * O) / pe),
  34650. (Ie[fe * 2 + 1] = de / h);
  34651. }
  34652. }
  34653. let We = B + 2 * c + re,
  34654. Me = 1,
  34655. [ce, Fe] = [+p, We - 1];
  34656. d && (Fe -= 1);
  34657. for (let Ee = ce; Ee <= Fe - 1; Ee++) {
  34658. let _e = p && Ee === Fe - 1;
  34659. for (let Le = 0; Le < Y - 1; Le++)
  34660. (b = Ee * Y + Le),
  34661. (x = b + 1),
  34662. (w = (_e ? Le : b) + Y),
  34663. (A = (_e ? Le + 1 : x) + Y),
  34664. Ee === 0 ? He.push(x, A, w) : Ee === We - 2 ? He.push(b, x, w) : He.push(b, x, w, x, A, w);
  34665. }
  34666. this.setIndex(He),
  34667. this.setAttribute('position', new Ce(xe, 3)),
  34668. this.setAttribute('normal', new Ce(we, 3)),
  34669. this.setAttribute('uv', new Ce(Ie, 2));
  34670. }
  34671. },
  34672. i6 = class {
  34673. static create(e) {
  34674. return this.build(this.normalizeInputs(e));
  34675. }
  34676. static normalizeInputs(e, t) {
  34677. let i = Object.assign({}, t?.parameters ?? { width: 100, detail: 0, corner: 0, cornerSides: 4 }, e.parameters);
  34678. return {
  34679. parameters: Object.assign(i, {
  34680. width: Math.abs(i.width),
  34681. height: Math.abs(i.height ?? i.width),
  34682. depth: Math.abs(i.depth ?? i.width)
  34683. })
  34684. };
  34685. }
  34686. static build(e) {
  34687. let { width: t, height: i, depth: r, detail: s, corner: n, cornerSides: a } = e.parameters,
  34688. o = s === 0 && n !== 0 ? new CA(t * 0.5, n, a) : new Bw(t * 0.5, s);
  34689. return o.scale(1, i / t, r / t), Object.assign(o, { userData: { ...e, type: 'IcosahedronGeometry' } });
  34690. }
  34691. },
  34692. CA = class extends ev {
  34693. constructor(e = 1, t = 0.2, i = 4) {
  34694. let r = (1 + Math.sqrt(5)) / 2,
  34695. 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],
  34696. n = [
  34697. 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,
  34698. 8, 3, 8, 9, 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1
  34699. ],
  34700. a = 'IcosahedronGeometry';
  34701. super(s, n, a, e, t, i), (this.type = a);
  34702. }
  34703. static fromJSON(e) {
  34704. return new CA(e.radius, e.corner, e.cornerSides);
  34705. }
  34706. },
  34707. r6 = class {
  34708. static create(e) {
  34709. return this.build(this.normalizeInputs(e));
  34710. }
  34711. static normalizeInputs(e, t) {
  34712. (e.parameters?.points ?? []).forEach((r) => {
  34713. Array.isArray(r) && ((r.x = r[0]), (r.y = r[1]));
  34714. });
  34715. let i = Object.assign(
  34716. {},
  34717. t?.parameters ?? {
  34718. width: 100,
  34719. segments: 64,
  34720. verticalSegments: 64,
  34721. points: [
  34722. { x: 0, y: -50, id: 0 },
  34723. { x: 50, y: -50, id: 1 },
  34724. { x: 50, y: 50, id: 2 },
  34725. { x: 0, y: 50, id: 3 }
  34726. ]
  34727. },
  34728. e.parameters
  34729. );
  34730. return {
  34731. parameters: Object.assign(i, {
  34732. width: Math.abs(i.width),
  34733. height: Math.abs(i.height ?? i.width),
  34734. depth: Math.abs(i.depth ?? i.width)
  34735. })
  34736. };
  34737. }
  34738. static build(e) {
  34739. let { points: t, segments: i, verticalSegments: r } = e.parameters,
  34740. s = new xd();
  34741. 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);
  34742. let n = new Tw(s.extractPoints(r).shape, i);
  34743. return n.rotateZ(Math.PI), Object.assign(n, { userData: { ...e, type: 'LatheGeometry' } });
  34744. }
  34745. },
  34746. Zr = new ve(),
  34747. Kp = new bt(),
  34748. Rc = new E(),
  34749. Qd = class extends Vi {
  34750. constructor() {
  34751. super(),
  34752. (this.uuid = it.generateUUID()),
  34753. (this.name = ''),
  34754. (this.type = 'Geometry'),
  34755. (this.vertices = []),
  34756. (this.colors = []),
  34757. (this.faces = []),
  34758. (this.faceVertexUvs = [[]]),
  34759. (this.morphTargets = []),
  34760. (this.morphNormals = []),
  34761. (this.skinWeights = []),
  34762. (this.skinIndices = []),
  34763. (this.lineDistances = []),
  34764. (this.boundingBox = null),
  34765. (this.boundingSphere = null),
  34766. (this.elementsNeedUpdate = !1),
  34767. (this.verticesNeedUpdate = !1),
  34768. (this.uvsNeedUpdate = !1),
  34769. (this.normalsNeedUpdate = !1),
  34770. (this.colorsNeedUpdate = !1),
  34771. (this.lineDistancesNeedUpdate = !1),
  34772. (this.groupsNeedUpdate = !1);
  34773. }
  34774. applyMatrix4(e) {
  34775. let t = new Ai().getNormalMatrix(e);
  34776. for (let i = 0, r = this.vertices.length; i < r; i++) this.vertices[i].applyMatrix4(e);
  34777. for (let i = 0, r = this.faces.length; i < r; i++) {
  34778. let s = this.faces[i];
  34779. s.normal.applyMatrix3(t).normalize();
  34780. for (let n = 0, a = s.vertexNormals.length; n < a; n++) s.vertexNormals[n].applyMatrix3(t).normalize();
  34781. }
  34782. return (
  34783. this.boundingBox !== null && this.computeBoundingBox(),
  34784. this.boundingSphere !== null && this.computeBoundingSphere(),
  34785. (this.verticesNeedUpdate = !0),
  34786. (this.normalsNeedUpdate = !0),
  34787. this
  34788. );
  34789. }
  34790. rotateX(e) {
  34791. return Zr.makeRotationX(e), this.applyMatrix4(Zr), this;
  34792. }
  34793. rotateY(e) {
  34794. return Zr.makeRotationY(e), this.applyMatrix4(Zr), this;
  34795. }
  34796. rotateZ(e) {
  34797. return Zr.makeRotationZ(e), this.applyMatrix4(Zr), this;
  34798. }
  34799. translate(e, t, i) {
  34800. return Zr.makeTranslation(e, t, i), this.applyMatrix4(Zr), this;
  34801. }
  34802. scale(e, t, i) {
  34803. return Zr.makeScale(e, t, i), this.applyMatrix4(Zr), this;
  34804. }
  34805. lookAt(e) {
  34806. return Kp.lookAt(e), Kp.updateMatrix(), this.applyMatrix4(Kp.matrix), this;
  34807. }
  34808. fromBufferGeometry(e) {
  34809. let t = this,
  34810. i = e.index !== null ? e.index : void 0,
  34811. r = e.attributes;
  34812. if (r.position === void 0)
  34813. return console.error('THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.'), this;
  34814. let s = r.position,
  34815. n = r.normal,
  34816. a = r.color,
  34817. o = r.uv,
  34818. l = r.uv2;
  34819. l !== void 0 && (this.faceVertexUvs[1] = []);
  34820. for (let c = 0; c < s.count; c++)
  34821. t.vertices.push(new E().fromBufferAttribute(s, c)), a !== void 0 && t.colors.push(new Ge().fromBufferAttribute(a, c));
  34822. function h(c, d, p, f) {
  34823. let g = a === void 0 ? [] : [t.colors[c].clone(), t.colors[d].clone(), t.colors[p].clone()],
  34824. m = n === void 0 ? [] : [new E().fromBufferAttribute(n, c), new E().fromBufferAttribute(n, d), new E().fromBufferAttribute(n, p)],
  34825. v = new Nm(c, d, p, m, g, f);
  34826. t.faces.push(v),
  34827. o !== void 0 &&
  34828. t.faceVertexUvs[0].push([
  34829. new G().fromBufferAttribute(o, c),
  34830. new G().fromBufferAttribute(o, d),
  34831. new G().fromBufferAttribute(o, p)
  34832. ]),
  34833. l !== void 0 &&
  34834. t.faceVertexUvs[1].push([
  34835. new G().fromBufferAttribute(l, c),
  34836. new G().fromBufferAttribute(l, d),
  34837. new G().fromBufferAttribute(l, p)
  34838. ]);
  34839. }
  34840. let u = e.groups;
  34841. if (u.length > 0)
  34842. for (let c = 0; c < u.length; c++) {
  34843. let d = u[c],
  34844. p = d.start,
  34845. f = d.count;
  34846. for (let g = p, m = p + f; g < m; g += 3)
  34847. i !== void 0 ? h(i.getX(g), i.getX(g + 1), i.getX(g + 2), d.materialIndex) : h(g, g + 1, g + 2, d.materialIndex);
  34848. }
  34849. else if (i !== void 0) for (let c = 0; c < i.count; c += 3) h(i.getX(c), i.getX(c + 1), i.getX(c + 2));
  34850. else for (let c = 0; c < s.count; c += 3) h(c, c + 1, c + 2);
  34851. return (
  34852. this.computeFaceNormals(),
  34853. e.boundingBox !== null && (this.boundingBox = e.boundingBox.clone()),
  34854. e.boundingSphere !== null && (this.boundingSphere = e.boundingSphere.clone()),
  34855. this
  34856. );
  34857. }
  34858. center() {
  34859. return this.computeBoundingBox(), this.boundingBox.getCenter(Rc).negate(), this.translate(Rc.x, Rc.y, Rc.z), this;
  34860. }
  34861. normalize() {
  34862. this.computeBoundingSphere();
  34863. let e = this.boundingSphere.center,
  34864. t = this.boundingSphere.radius,
  34865. i = t === 0 ? 1 : 1 / t,
  34866. r = new ve();
  34867. 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;
  34868. }
  34869. computeFaceNormals() {
  34870. let e = new E(),
  34871. t = new E();
  34872. for (let i = 0, r = this.faces.length; i < r; i++) {
  34873. let s = this.faces[i],
  34874. n = this.vertices[s.a],
  34875. a = this.vertices[s.b],
  34876. o = this.vertices[s.c];
  34877. e.subVectors(o, a), t.subVectors(n, a), e.cross(t), e.normalize(), s.normal.copy(e);
  34878. }
  34879. }
  34880. computeVertexNormals(e = !0) {
  34881. let t = new Array(this.vertices.length);
  34882. for (let i = 0, r = this.vertices.length; i < r; i++) t[i] = new E();
  34883. if (e) {
  34884. let i = new E(),
  34885. r = new E();
  34886. for (let s = 0, n = this.faces.length; s < n; s++) {
  34887. let a = this.faces[s],
  34888. o = this.vertices[a.a],
  34889. l = this.vertices[a.b],
  34890. h = this.vertices[a.c];
  34891. i.subVectors(h, l), r.subVectors(o, l), i.cross(r), t[a.a].add(i), t[a.b].add(i), t[a.c].add(i);
  34892. }
  34893. } else {
  34894. this.computeFaceNormals();
  34895. for (let i = 0, r = this.faces.length; i < r; i++) {
  34896. let s = this.faces[i];
  34897. t[s.a].add(s.normal), t[s.b].add(s.normal), t[s.c].add(s.normal);
  34898. }
  34899. }
  34900. for (let i = 0, r = this.vertices.length; i < r; i++) t[i].normalize();
  34901. for (let i = 0, r = this.faces.length; i < r; i++) {
  34902. let s = this.faces[i],
  34903. n = s.vertexNormals;
  34904. n.length === 3
  34905. ? (n[0].copy(t[s.a]), n[1].copy(t[s.b]), n[2].copy(t[s.c]))
  34906. : ((n[0] = t[s.a].clone()), (n[1] = t[s.b].clone()), (n[2] = t[s.c].clone()));
  34907. }
  34908. this.faces.length > 0 && (this.normalsNeedUpdate = !0);
  34909. }
  34910. computeFlatVertexNormals() {
  34911. this.computeFaceNormals();
  34912. for (let e = 0, t = this.faces.length; e < t; e++) {
  34913. let i = this.faces[e],
  34914. r = i.vertexNormals;
  34915. r.length === 3
  34916. ? (r[0].copy(i.normal), r[1].copy(i.normal), r[2].copy(i.normal))
  34917. : ((r[0] = i.normal.clone()), (r[1] = i.normal.clone()), (r[2] = i.normal.clone()));
  34918. }
  34919. this.faces.length > 0 && (this.normalsNeedUpdate = !0);
  34920. }
  34921. computeMorphNormals() {
  34922. for (let t = 0, i = this.faces.length; t < i; t++) {
  34923. let r = this.faces[t];
  34924. r.__originalFaceNormal ? r.__originalFaceNormal.copy(r.normal) : (r.__originalFaceNormal = r.normal.clone()),
  34925. r.__originalVertexNormals || (r.__originalVertexNormals = []);
  34926. for (let s = 0, n = r.vertexNormals.length; s < n; s++)
  34927. r.__originalVertexNormals[s]
  34928. ? r.__originalVertexNormals[s].copy(r.vertexNormals[s])
  34929. : (r.__originalVertexNormals[s] = r.vertexNormals[s].clone());
  34930. }
  34931. let e = new Qd();
  34932. e.faces = this.faces;
  34933. for (let t = 0, i = this.morphTargets.length; t < i; t++) {
  34934. if (!this.morphNormals[t]) {
  34935. (this.morphNormals[t] = {}), (this.morphNormals[t].faceNormals = []), (this.morphNormals[t].vertexNormals = []);
  34936. let s = this.morphNormals[t].faceNormals,
  34937. n = this.morphNormals[t].vertexNormals;
  34938. for (let a = 0, o = this.faces.length; a < o; a++) {
  34939. let l = new E(),
  34940. h = { a: new E(), b: new E(), c: new E() };
  34941. s.push(l), n.push(h);
  34942. }
  34943. }
  34944. let r = this.morphNormals[t];
  34945. (e.vertices = this.morphTargets[t].vertices), e.computeFaceNormals(), e.computeVertexNormals();
  34946. for (let s = 0, n = this.faces.length; s < n; s++) {
  34947. let a = this.faces[s],
  34948. o = r.faceNormals[s],
  34949. l = r.vertexNormals[s];
  34950. o.copy(a.normal), l.a.copy(a.vertexNormals[0]), l.b.copy(a.vertexNormals[1]), l.c.copy(a.vertexNormals[2]);
  34951. }
  34952. }
  34953. for (let t = 0, i = this.faces.length; t < i; t++) {
  34954. let r = this.faces[t];
  34955. (r.normal = r.__originalFaceNormal), (r.vertexNormals = r.__originalVertexNormals);
  34956. }
  34957. }
  34958. computeBoundingBox() {
  34959. this.boundingBox === null && (this.boundingBox = new Kt()), this.boundingBox.setFromPoints(this.vertices);
  34960. }
  34961. computeBoundingSphere() {
  34962. this.boundingSphere === null && (this.boundingSphere = new Mr()), this.boundingSphere.setFromPoints(this.vertices);
  34963. }
  34964. merge(e, t, i = 0) {
  34965. if (!(e && e.isGeometry)) {
  34966. console.error('THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.', e);
  34967. return;
  34968. }
  34969. let r,
  34970. s = this.vertices.length,
  34971. n = this.vertices,
  34972. a = e.vertices,
  34973. o = this.faces,
  34974. l = e.faces,
  34975. h = this.colors,
  34976. u = e.colors;
  34977. t !== void 0 && (r = new Ai().getNormalMatrix(t));
  34978. for (let c = 0, d = a.length; c < d; c++) {
  34979. let p = a[c].clone();
  34980. t !== void 0 && p.applyMatrix4(t), n.push(p);
  34981. }
  34982. for (let c = 0, d = u.length; c < d; c++) h.push(u[c].clone());
  34983. for (let c = 0, d = l.length; c < d; c++) {
  34984. let p = l[c],
  34985. f,
  34986. g,
  34987. m = p.vertexNormals,
  34988. v = p.vertexColors,
  34989. y = new Nm(p.a + s, p.b + s, p.c + s);
  34990. y.normal.copy(p.normal), r !== void 0 && y.normal.applyMatrix3(r).normalize();
  34991. for (let b = 0, x = m.length; b < x; b++)
  34992. (f = m[b].clone()), r !== void 0 && f.applyMatrix3(r).normalize(), y.vertexNormals.push(f);
  34993. y.color.copy(p.color);
  34994. for (let b = 0, x = v.length; b < x; b++) (g = v[b]), y.vertexColors.push(g.clone());
  34995. (y.materialIndex = p.materialIndex + i), o.push(y);
  34996. }
  34997. for (let c = 0, d = e.faceVertexUvs.length; c < d; c++) {
  34998. let p = e.faceVertexUvs[c];
  34999. this.faceVertexUvs[c] === void 0 && (this.faceVertexUvs[c] = []);
  35000. for (let f = 0, g = p.length; f < g; f++) {
  35001. let m = p[f],
  35002. v = [];
  35003. for (let y = 0, b = m.length; y < b; y++) v.push(m[y].clone());
  35004. this.faceVertexUvs[c].push(v);
  35005. }
  35006. }
  35007. }
  35008. mergeMesh(e) {
  35009. if (!(e && e.isMesh)) {
  35010. console.error('THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.', e);
  35011. return;
  35012. }
  35013. e.matrixAutoUpdate && e.updateMatrix(), this.merge(e.geometry, e.matrix);
  35014. }
  35015. mergeVertices(e = 4) {
  35016. let t = {},
  35017. i = [],
  35018. r = [],
  35019. s = Math.pow(10, e);
  35020. for (let o = 0, l = this.vertices.length; o < l; o++) {
  35021. let h = this.vertices[o],
  35022. u = Math.round(h.x * s) + '_' + Math.round(h.y * s) + '_' + Math.round(h.z * s);
  35023. t[u] === void 0 ? ((t[u] = o), i.push(this.vertices[o]), (r[o] = i.length - 1)) : (r[o] = r[t[u]]);
  35024. }
  35025. let n = [];
  35026. for (let o = 0, l = this.faces.length; o < l; o++) {
  35027. let h = this.faces[o];
  35028. (h.a = r[h.a]), (h.b = r[h.b]), (h.c = r[h.c]);
  35029. let u = [h.a, h.b, h.c];
  35030. for (let c = 0; c < 3; c++)
  35031. if (u[c] === u[(c + 1) % 3]) {
  35032. n.push(o);
  35033. break;
  35034. }
  35035. }
  35036. for (let o = n.length - 1; o >= 0; o--) {
  35037. let l = n[o];
  35038. this.faces.splice(l, 1);
  35039. for (let h = 0, u = this.faceVertexUvs.length; h < u; h++) this.faceVertexUvs[h].splice(l, 1);
  35040. }
  35041. let a = this.vertices.length - i.length;
  35042. return (this.vertices = i), a;
  35043. }
  35044. setFromPoints(e) {
  35045. this.vertices = [];
  35046. for (let t = 0, i = e.length; t < i; t++) {
  35047. let r = e[t];
  35048. this.vertices.push(new E(r.x, r.y, r.z || 0));
  35049. }
  35050. return this;
  35051. }
  35052. sortFacesByMaterialIndex() {
  35053. let e = this.faces,
  35054. t = e.length;
  35055. for (let o = 0; o < t; o++) e[o]._id = o;
  35056. function i(o, l) {
  35057. return o.materialIndex - l.materialIndex;
  35058. }
  35059. e.sort(i);
  35060. let r = this.faceVertexUvs[0],
  35061. s = this.faceVertexUvs[1],
  35062. n,
  35063. a;
  35064. r && r.length === t && (n = []), s && s.length === t && (a = []);
  35065. for (let o = 0; o < t; o++) {
  35066. let l = e[o]._id;
  35067. n && n.push(r[l]), a && a.push(s[l]);
  35068. }
  35069. n && (this.faceVertexUvs[0] = n), a && (this.faceVertexUvs[1] = a);
  35070. }
  35071. toJSON() {
  35072. let e = { metadata: { version: 4.5, type: 'Geometry', generator: 'Geometry.toJSON' } };
  35073. if (((e.uuid = this.uuid), (e.type = this.type), this.name !== '' && (e.name = this.name), this.parameters !== void 0)) {
  35074. let p = this.parameters;
  35075. for (let f in p) p[f] !== void 0 && (e[f] = p[f]);
  35076. return e;
  35077. }
  35078. let t = [];
  35079. for (let p = 0; p < this.vertices.length; p++) {
  35080. let f = this.vertices[p];
  35081. t.push(f.x, f.y, f.z);
  35082. }
  35083. let i = [],
  35084. r = [],
  35085. s = {},
  35086. n = [],
  35087. a = {},
  35088. o = [],
  35089. l = {};
  35090. for (let p = 0; p < this.faces.length; p++) {
  35091. let f = this.faces[p],
  35092. g = !0,
  35093. m = !1,
  35094. v = this.faceVertexUvs[0][p] !== void 0,
  35095. y = f.normal.length() > 0,
  35096. b = f.vertexNormals.length > 0,
  35097. x = f.color.r !== 1 || f.color.g !== 1 || f.color.b !== 1,
  35098. w = f.vertexColors.length > 0,
  35099. A = 0;
  35100. if (
  35101. ((A = h(A, 0, 0)),
  35102. (A = h(A, 1, g)),
  35103. (A = h(A, 2, m)),
  35104. (A = h(A, 3, v)),
  35105. (A = h(A, 4, y)),
  35106. (A = h(A, 5, b)),
  35107. (A = h(A, 6, x)),
  35108. (A = h(A, 7, w)),
  35109. i.push(A),
  35110. i.push(f.a, f.b, f.c),
  35111. i.push(f.materialIndex),
  35112. v)
  35113. ) {
  35114. let S = this.faceVertexUvs[0][p];
  35115. i.push(d(S[0]), d(S[1]), d(S[2]));
  35116. }
  35117. if ((y && i.push(u(f.normal)), b)) {
  35118. let S = f.vertexNormals;
  35119. i.push(u(S[0]), u(S[1]), u(S[2]));
  35120. }
  35121. if ((x && i.push(c(f.color)), w)) {
  35122. let S = f.vertexColors;
  35123. i.push(c(S[0]), c(S[1]), c(S[2]));
  35124. }
  35125. }
  35126. function h(p, f, g) {
  35127. return g ? p | (1 << f) : p & ~(1 << f);
  35128. }
  35129. function u(p) {
  35130. let f = p.x.toString() + p.y.toString() + p.z.toString();
  35131. return s[f] !== void 0 || ((s[f] = r.length / 3), r.push(p.x, p.y, p.z)), s[f];
  35132. }
  35133. function c(p) {
  35134. let f = p.r.toString() + p.g.toString() + p.b.toString();
  35135. return a[f] !== void 0 || ((a[f] = n.length), n.push(p.getHex())), a[f];
  35136. }
  35137. function d(p) {
  35138. let f = p.x.toString() + p.y.toString();
  35139. return l[f] !== void 0 || ((l[f] = o.length / 2), o.push(p.x, p.y)), l[f];
  35140. }
  35141. return (
  35142. (e.data = {}),
  35143. (e.data.vertices = t),
  35144. (e.data.normals = r),
  35145. n.length > 0 && (e.data.colors = n),
  35146. o.length > 0 && (e.data.uvs = [o]),
  35147. (e.data.faces = i),
  35148. e
  35149. );
  35150. }
  35151. clone() {
  35152. return new Qd().copy(this);
  35153. }
  35154. copy(e) {
  35155. (this.vertices = []),
  35156. (this.colors = []),
  35157. (this.faces = []),
  35158. (this.faceVertexUvs = [[]]),
  35159. (this.morphTargets = []),
  35160. (this.morphNormals = []),
  35161. (this.skinWeights = []),
  35162. (this.skinIndices = []),
  35163. (this.lineDistances = []),
  35164. (this.boundingBox = null),
  35165. (this.boundingSphere = null),
  35166. (this.name = e.name);
  35167. let t = e.vertices;
  35168. for (let c = 0, d = t.length; c < d; c++) this.vertices.push(t[c].clone());
  35169. let i = e.colors;
  35170. for (let c = 0, d = i.length; c < d; c++) this.colors.push(i[c].clone());
  35171. let r = e.faces;
  35172. for (let c = 0, d = r.length; c < d; c++) this.faces.push(r[c].clone());
  35173. for (let c = 0, d = e.faceVertexUvs.length; c < d; c++) {
  35174. let p = e.faceVertexUvs[c];
  35175. this.faceVertexUvs[c] === void 0 && (this.faceVertexUvs[c] = []);
  35176. for (let f = 0, g = p.length; f < g; f++) {
  35177. let m = p[f],
  35178. v = [];
  35179. for (let y = 0, b = m.length; y < b; y++) {
  35180. let x = m[y];
  35181. v.push(x.clone());
  35182. }
  35183. this.faceVertexUvs[c].push(v);
  35184. }
  35185. }
  35186. let s = e.morphTargets;
  35187. for (let c = 0, d = s.length; c < d; c++) {
  35188. let p = {};
  35189. if (((p.name = s[c].name), s[c].vertices !== void 0)) {
  35190. p.vertices = [];
  35191. for (let f = 0, g = s[c].vertices.length; f < g; f++) p.vertices.push(s[c].vertices[f].clone());
  35192. }
  35193. if (s[c].normals !== void 0) {
  35194. p.normals = [];
  35195. for (let f = 0, g = s[c].normals.length; f < g; f++) p.normals.push(s[c].normals[f].clone());
  35196. }
  35197. this.morphTargets.push(p);
  35198. }
  35199. let n = e.morphNormals;
  35200. for (let c = 0, d = n.length; c < d; c++) {
  35201. let p = {};
  35202. if (n[c].vertexNormals !== void 0) {
  35203. p.vertexNormals = [];
  35204. for (let f = 0, g = n[c].vertexNormals.length; f < g; f++) {
  35205. let m = n[c].vertexNormals[f],
  35206. v = {};
  35207. (v.a = m.a.clone()), (v.b = m.b.clone()), (v.c = m.c.clone()), p.vertexNormals.push(v);
  35208. }
  35209. }
  35210. if (n[c].faceNormals !== void 0) {
  35211. p.faceNormals = [];
  35212. for (let f = 0, g = n[c].faceNormals.length; f < g; f++) p.faceNormals.push(n[c].faceNormals[f].clone());
  35213. }
  35214. this.morphNormals.push(p);
  35215. }
  35216. let a = e.skinWeights;
  35217. for (let c = 0, d = a.length; c < d; c++) this.skinWeights.push(a[c].clone());
  35218. let o = e.skinIndices;
  35219. for (let c = 0, d = o.length; c < d; c++) this.skinIndices.push(o[c].clone());
  35220. let l = e.lineDistances;
  35221. for (let c = 0, d = l.length; c < d; c++) this.lineDistances.push(l[c]);
  35222. let h = e.boundingBox;
  35223. h !== null && (this.boundingBox = h.clone());
  35224. let u = e.boundingSphere;
  35225. return (
  35226. u !== null && (this.boundingSphere = u.clone()),
  35227. (this.elementsNeedUpdate = e.elementsNeedUpdate),
  35228. (this.verticesNeedUpdate = e.verticesNeedUpdate),
  35229. (this.uvsNeedUpdate = e.uvsNeedUpdate),
  35230. (this.normalsNeedUpdate = e.normalsNeedUpdate),
  35231. (this.colorsNeedUpdate = e.colorsNeedUpdate),
  35232. (this.lineDistancesNeedUpdate = e.lineDistancesNeedUpdate),
  35233. (this.groupsNeedUpdate = e.groupsNeedUpdate),
  35234. this
  35235. );
  35236. }
  35237. toBufferGeometry() {
  35238. let e = new s6().fromGeometry(this),
  35239. t = new Ve(),
  35240. i = new Float32Array(e.vertices.length * 3);
  35241. if ((t.setAttribute('position', Bc.call(new Xe(i, 3), e.vertices)), e.normals.length > 0)) {
  35242. let r = new Float32Array(e.normals.length * 3);
  35243. t.setAttribute('normal', Bc.call(new Xe(r, 3), e.normals));
  35244. }
  35245. if (e.colors.length > 0) {
  35246. let r = new Float32Array(e.colors.length * 3);
  35247. t.setAttribute('color', Cx.call(new Xe(r, 3), e.colors));
  35248. }
  35249. if (e.uvs.length > 0) {
  35250. let r = new Float32Array(e.uvs.length * 2);
  35251. t.setAttribute('uv', Tx.call(new Xe(r, 2), e.uvs));
  35252. }
  35253. if (e.uvs2.length > 0) {
  35254. let r = new Float32Array(e.uvs2.length * 2);
  35255. t.setAttribute('uv2', Tx.call(new Xe(r, 2), e.uvs2));
  35256. }
  35257. t.groups = e.groups;
  35258. for (let r in e.morphTargets) {
  35259. let s = [],
  35260. n = e.morphTargets[r];
  35261. for (let a = 0, o = n.length; a < o; a++) {
  35262. let l = n[a],
  35263. h = new Ce(l.data.length * 3, 3);
  35264. (h.name = l.name), s.push(Bc.call(h, l.data));
  35265. }
  35266. t.morphAttributes[r] = s;
  35267. }
  35268. if (e.skinIndices.length > 0) {
  35269. let r = new Ce(e.skinIndices.length * 4, 4);
  35270. t.setAttribute('skinIndex', Px.call(r, e.skinIndices));
  35271. }
  35272. if (e.skinWeights.length > 0) {
  35273. let r = new Ce(e.skinWeights.length * 4, 4);
  35274. t.setAttribute('skinWeight', Px.call(r, e.skinWeights));
  35275. }
  35276. return (
  35277. e.boundingSphere !== null && (t.boundingSphere = e.boundingSphere.clone()),
  35278. e.boundingBox !== null && (t.boundingBox = e.boundingBox.clone()),
  35279. t
  35280. );
  35281. }
  35282. computeTangents() {
  35283. console.error('THREE.Geometry: .computeTangents() has been removed.');
  35284. }
  35285. computeLineDistances() {
  35286. console.error('THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.');
  35287. }
  35288. applyMatrix(e) {
  35289. return console.warn('THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().'), this.applyMatrix4(e);
  35290. }
  35291. dispose() {
  35292. this.dispatchEvent({ type: 'dispose' });
  35293. }
  35294. static createBufferGeometryFromObject(e) {
  35295. let t = new Ve(),
  35296. i = e.geometry;
  35297. if (e.isPoints || e.isLine) {
  35298. let r = new Ce(i.vertices.length * 3, 3),
  35299. s = new Ce(i.colors.length * 3, 3);
  35300. if (
  35301. (t.setAttribute('position', Bc.call(r, i.vertices)),
  35302. t.setAttribute('color', Cx.call(s, i.colors)),
  35303. i.lineDistances && i.lineDistances.length === i.vertices.length)
  35304. ) {
  35305. let n = new Ce(i.lineDistances.length, 1);
  35306. t.setAttribute('lineDistance', n6.call(n, i.lineDistances));
  35307. }
  35308. i.boundingSphere !== null && (t.boundingSphere = i.boundingSphere.clone()),
  35309. i.boundingBox !== null && (t.boundingBox = i.boundingBox.clone());
  35310. } else e.isMesh && (t = i.toBufferGeometry());
  35311. return t;
  35312. }
  35313. };
  35314. Qd.prototype.isGeometry = !0;
  35315. var s6 = class {
  35316. constructor() {
  35317. (this.vertices = []),
  35318. (this.normals = []),
  35319. (this.colors = []),
  35320. (this.uvs = []),
  35321. (this.uvs2 = []),
  35322. (this.groups = []),
  35323. (this.morphTargets = {}),
  35324. (this.skinWeights = []),
  35325. (this.skinIndices = []),
  35326. (this.boundingBox = null),
  35327. (this.boundingSphere = null),
  35328. (this.verticesNeedUpdate = !1),
  35329. (this.normalsNeedUpdate = !1),
  35330. (this.colorsNeedUpdate = !1),
  35331. (this.uvsNeedUpdate = !1),
  35332. (this.groupsNeedUpdate = !1);
  35333. }
  35334. computeGroups(e) {
  35335. let t = [],
  35336. i,
  35337. r,
  35338. s,
  35339. n = e.faces;
  35340. for (r = 0; r < n.length; r++) {
  35341. let a = n[r];
  35342. a.materialIndex !== s &&
  35343. ((s = a.materialIndex), i !== void 0 && ((i.count = r * 3 - i.start), t.push(i)), (i = { start: r * 3, materialIndex: s }));
  35344. }
  35345. i !== void 0 && ((i.count = r * 3 - i.start), t.push(i)), (this.groups = t);
  35346. }
  35347. fromGeometry(e) {
  35348. let t = e.faces,
  35349. i = e.vertices,
  35350. r = e.faceVertexUvs,
  35351. s = r[0] && r[0].length > 0,
  35352. n = r[1] && r[1].length > 0,
  35353. a = e.morphTargets,
  35354. o = a.length,
  35355. l;
  35356. if (o > 0) {
  35357. l = [];
  35358. for (let m = 0; m < o; m++) l[m] = { name: a[m].name, data: [] };
  35359. this.morphTargets.position = l;
  35360. }
  35361. let h = e.morphNormals,
  35362. u = h.length,
  35363. c;
  35364. if (u > 0) {
  35365. c = [];
  35366. for (let m = 0; m < u; m++) c[m] = { name: h[m].name, data: [] };
  35367. this.morphTargets.normal = c;
  35368. }
  35369. let d = e.skinIndices,
  35370. p = e.skinWeights,
  35371. f = d.length === i.length,
  35372. g = p.length === i.length;
  35373. i.length > 0 && t.length === 0 && console.error('THREE.DirectGeometry: Faceless geometries are not supported.');
  35374. for (let m = 0; m < t.length; m++) {
  35375. let v = t[m];
  35376. this.vertices.push(i[v.a], i[v.b], i[v.c]);
  35377. let y = v.vertexNormals;
  35378. if (y.length === 3) this.normals.push(y[0], y[1], y[2]);
  35379. else {
  35380. let x = v.normal;
  35381. this.normals.push(x, x, x);
  35382. }
  35383. let b = v.vertexColors;
  35384. if (b.length === 3) this.colors.push(b[0], b[1], b[2]);
  35385. else {
  35386. let x = v.color;
  35387. this.colors.push(x, x, x);
  35388. }
  35389. if (s === !0) {
  35390. let x = r[0][m];
  35391. x !== void 0
  35392. ? this.uvs.push(x[0], x[1], x[2])
  35393. : (console.warn('THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', m), this.uvs.push(new G(), new G(), new G()));
  35394. }
  35395. if (n === !0) {
  35396. let x = r[1][m];
  35397. x !== void 0
  35398. ? this.uvs2.push(x[0], x[1], x[2])
  35399. : (console.warn('THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', m), this.uvs2.push(new G(), new G(), new G()));
  35400. }
  35401. for (let x = 0; x < o; x++) {
  35402. let w = a[x].vertices;
  35403. l[x].data.push(w[v.a], w[v.b], w[v.c]);
  35404. }
  35405. for (let x = 0; x < u; x++) {
  35406. let w = h[x].vertexNormals[m];
  35407. c[x].data.push(w.a, w.b, w.c);
  35408. }
  35409. f && this.skinIndices.push(d[v.a], d[v.b], d[v.c]), g && this.skinWeights.push(p[v.a], p[v.b], p[v.c]);
  35410. }
  35411. return (
  35412. this.computeGroups(e),
  35413. (this.verticesNeedUpdate = e.verticesNeedUpdate),
  35414. (this.normalsNeedUpdate = e.normalsNeedUpdate),
  35415. (this.colorsNeedUpdate = e.colorsNeedUpdate),
  35416. (this.uvsNeedUpdate = e.uvsNeedUpdate),
  35417. (this.groupsNeedUpdate = e.groupsNeedUpdate),
  35418. e.boundingSphere !== null && (this.boundingSphere = e.boundingSphere.clone()),
  35419. e.boundingBox !== null && (this.boundingBox = e.boundingBox.clone()),
  35420. this
  35421. );
  35422. }
  35423. },
  35424. Nm = class {
  35425. constructor(e, t, i, r, s, n = 0) {
  35426. (this.a = e),
  35427. (this.b = t),
  35428. (this.c = i),
  35429. (this.normal = r && r.isVector3 ? r : new E()),
  35430. (this.vertexNormals = Array.isArray(r) ? r : []),
  35431. (this.color = s && s.isColor ? s : new Ge()),
  35432. (this.vertexColors = Array.isArray(s) ? s : []),
  35433. (this.materialIndex = n);
  35434. }
  35435. clone() {
  35436. return new this.constructor().copy(this);
  35437. }
  35438. copy(e) {
  35439. (this.a = e.a),
  35440. (this.b = e.b),
  35441. (this.c = e.c),
  35442. this.normal.copy(e.normal),
  35443. this.color.copy(e.color),
  35444. (this.materialIndex = e.materialIndex);
  35445. for (let t = 0, i = e.vertexNormals.length; t < i; t++) this.vertexNormals[t] = e.vertexNormals[t].clone();
  35446. for (let t = 0, i = e.vertexColors.length; t < i; t++) this.vertexColors[t] = e.vertexColors[t].clone();
  35447. return this;
  35448. }
  35449. };
  35450. function n6(e) {
  35451. return this.array.set(e), this;
  35452. }
  35453. function Cx(e) {
  35454. let t = this.array,
  35455. i = 0;
  35456. for (let r = 0, s = e.length; r < s; r++) {
  35457. let n = e[r];
  35458. n === void 0 && (console.warn('THREE.BufferAttribute.copyColorsArray(): color is undefined', r), (n = new Ge())),
  35459. (t[i++] = n.r),
  35460. (t[i++] = n.g),
  35461. (t[i++] = n.b);
  35462. }
  35463. return this;
  35464. }
  35465. function Tx(e) {
  35466. let t = this.array,
  35467. i = 0;
  35468. for (let r = 0, s = e.length; r < s; r++) {
  35469. let n = e[r];
  35470. n === void 0 && (console.warn('THREE.BufferAttribute.copyVector2sArray(): vector is undefined', r), (n = new G())),
  35471. (t[i++] = n.x),
  35472. (t[i++] = n.y);
  35473. }
  35474. return this;
  35475. }
  35476. function Bc(e) {
  35477. let t = this.array,
  35478. i = 0;
  35479. for (let r = 0, s = e.length; r < s; r++) {
  35480. let n = e[r];
  35481. n === void 0 && (console.warn('THREE.BufferAttribute.copyVector3sArray(): vector is undefined', r), (n = new E())),
  35482. (t[i++] = n.x),
  35483. (t[i++] = n.y),
  35484. (t[i++] = n.z);
  35485. }
  35486. return this;
  35487. }
  35488. function Px(e) {
  35489. let t = this.array,
  35490. i = 0;
  35491. for (let r = 0, s = e.length; r < s; r++) {
  35492. let n = e[r];
  35493. n === void 0 && (console.warn('THREE.BufferAttribute.copyVector4sArray(): vector is undefined', r), (n = new $e())),
  35494. (t[i++] = n.x),
  35495. (t[i++] = n.y),
  35496. (t[i++] = n.z),
  35497. (t[i++] = n.w);
  35498. }
  35499. return this;
  35500. }
  35501. var a6 = ['a', 'b', 'c'];
  35502. function o6(e, t) {
  35503. switch (t) {
  35504. case 'c':
  35505. return e.c;
  35506. case 'b':
  35507. return e.b;
  35508. case 'a':
  35509. default:
  35510. return e.a;
  35511. }
  35512. }
  35513. function Jp(e, t, i) {
  35514. let r = Math.min(e, t),
  35515. s = Math.max(e, t),
  35516. n = r + '_' + s;
  35517. return i.get(n);
  35518. }
  35519. function $p(e, t, i, r, s, n) {
  35520. let a = Math.min(e, t),
  35521. o = Math.max(e, t),
  35522. l = a + '_' + o,
  35523. h;
  35524. if (r.has(l)) h = r.get(l);
  35525. else {
  35526. let u = i[a],
  35527. c = i[o];
  35528. (h = { a: u, b: c, newEdge: null, faces: [] }), r.set(l, h);
  35529. }
  35530. h.faces.push(s), n[e].edges.push(h), n[t].edges.push(h);
  35531. }
  35532. function l6(e, t, i, r) {
  35533. let s, n, a;
  35534. for (s = 0, n = e.length; s < n; s++) i[s] = { edges: [] };
  35535. for (s = 0, n = t.length; s < n; s++) (a = t[s]), $p(a.a, a.b, e, r, a, i), $p(a.b, a.c, e, r, a, i), $p(a.c, a.a, e, r, a, i);
  35536. }
  35537. function zc(e, t, i, r, s) {
  35538. e.push(new Nm(t, i, r, void 0, void 0, s));
  35539. }
  35540. function Ka(e, t) {
  35541. return Math.abs(t - e) / 2 + Math.min(e, t);
  35542. }
  35543. function Nc(e, t, i, r) {
  35544. e.push([t.clone(), i.clone(), r.clone()]);
  35545. }
  35546. var h6 = class {
  35547. constructor(e = 1) {
  35548. this.subdivisions = e;
  35549. }
  35550. modify(e) {
  35551. e instanceof Ve ? (e = new Qd().fromBufferGeometry(e)) : (e = e.clone()), e.mergeVertices();
  35552. let t = this.subdivisions;
  35553. for (; t-- > 0; ) this._smooth(e);
  35554. return e.computeFaceNormals(), e.computeVertexNormals(), e;
  35555. }
  35556. _smooth(e) {
  35557. let t = new E(),
  35558. i,
  35559. r,
  35560. s,
  35561. n,
  35562. a,
  35563. o = e.vertices,
  35564. l = e.faces,
  35565. h = e.faceVertexUvs[0],
  35566. u = h !== void 0 && h.length > 0,
  35567. c = [],
  35568. d = new Map();
  35569. l6(o, l, c, d);
  35570. let p = [],
  35571. f,
  35572. g,
  35573. m,
  35574. v,
  35575. y,
  35576. b,
  35577. x;
  35578. for (let se of Array.from(d.keys())) {
  35579. for (
  35580. g = d.get(se),
  35581. m = new E(),
  35582. y = 3 / 8,
  35583. b = 1 / 8,
  35584. x = g.faces.length,
  35585. x != 2 && ((y = 0.5), (b = 0), x != 1),
  35586. m.addVectors(g.a, g.b).multiplyScalar(y),
  35587. t.set(0, 0, 0),
  35588. n = 0;
  35589. n < x;
  35590. n++
  35591. ) {
  35592. for (v = g.faces[n], a = 0; a < 3 && ((f = o[o6(v, a6[a])]), !(f !== g.a && f !== g.b)); a++);
  35593. f && t.add(f);
  35594. }
  35595. t.multiplyScalar(b), m.add(t), (g.newEdge = p.length), p.push(m);
  35596. }
  35597. let w,
  35598. A,
  35599. S,
  35600. _,
  35601. M,
  35602. C,
  35603. T,
  35604. P = [];
  35605. for (r = 0, s = o.length; r < s; r++) {
  35606. for (
  35607. C = o[r],
  35608. M = c[r].edges,
  35609. i = M.length,
  35610. i == 3 ? (w = 3 / 16) : i > 3 && (w = 3 / (8 * i)),
  35611. A = 1 - i * Number(w),
  35612. S = w,
  35613. i <= 2 && (i == 2 ? ((A = 3 / 4), (S = 1 / 8)) : i == 1 || i == 0),
  35614. T = C.clone().multiplyScalar(A),
  35615. t.set(0, 0, 0),
  35616. n = 0;
  35617. n < i;
  35618. n++
  35619. )
  35620. (_ = M[n]), (f = _.a !== C ? _.a : _.b), t.add(f);
  35621. t.multiplyScalar(Number(S)), T.add(t), P.push(T);
  35622. }
  35623. let L = P.concat(p),
  35624. D = P.length,
  35625. k,
  35626. W,
  35627. X,
  35628. z = [],
  35629. j = [],
  35630. U,
  35631. N,
  35632. B,
  35633. H,
  35634. Q = new G(),
  35635. Y = new G(),
  35636. F = new G();
  35637. for (r = 0, s = l.length; r < s; r++)
  35638. (v = l[r]),
  35639. (k = Number(Jp(v.a, v.b, d).newEdge) + D),
  35640. (W = Number(Jp(v.b, v.c, d).newEdge) + D),
  35641. (X = Number(Jp(v.c, v.a, d).newEdge) + D),
  35642. zc(z, k, W, X, v.materialIndex),
  35643. zc(z, v.a, k, X, v.materialIndex),
  35644. zc(z, v.b, W, k, v.materialIndex),
  35645. zc(z, v.c, X, W, v.materialIndex),
  35646. u &&
  35647. ((U = h[r]),
  35648. (N = U[0]),
  35649. (B = U[1]),
  35650. (H = U[2]),
  35651. Q.set(Ka(N.x, B.x), Ka(N.y, B.y)),
  35652. Y.set(Ka(B.x, H.x), Ka(B.y, H.y)),
  35653. F.set(Ka(N.x, H.x), Ka(N.y, H.y)),
  35654. Nc(j, Q, Y, F),
  35655. Nc(j, N, Q, F),
  35656. Nc(j, B, Y, Q),
  35657. Nc(j, H, F, Y));
  35658. (e.vertices = L), (e.faces = z), u && (e.faceVertexUvs[0] = j);
  35659. }
  35660. },
  35661. $t = new E(),
  35662. c6 = class {
  35663. static create(e) {
  35664. return this.build(this.normalizeInputs(e));
  35665. }
  35666. static normalizeInputs(e, t) {
  35667. let i = e.geometry ?? t?.geometry ?? new Ve().copy(new vs(100, 100, 100)),
  35668. r;
  35669. t === void 0
  35670. ? (i.computeBoundingBox(), i.boundingBox.getSize($t), (r = { width: $t.x, height: $t.y, depth: $t.z, subdivisions: 0 }))
  35671. : (r = t.parameters);
  35672. let s = { ...r, ...e.parameters };
  35673. return {
  35674. parameters: {
  35675. width: Math.abs(s.width),
  35676. height: Math.abs(s.height),
  35677. depth: Math.abs(s.depth),
  35678. subdivisions: Math.abs(s.subdivisions)
  35679. },
  35680. geometry: i
  35681. };
  35682. }
  35683. static build(e) {
  35684. let { width: t, height: i, depth: r, subdivisions: s } = e.parameters,
  35685. n = e.geometry ?? new Ve().copy(new vs(100, 100, 100)),
  35686. a = n.userData.parameters;
  35687. a === void 0 ? (n.computeBoundingBox(), n.boundingBox.getSize($t)) : $t.set(a.width, a.height, a.depth),
  35688. (t !== $t.x || i !== $t.y || r !== $t.z) &&
  35689. n.scale($t.x === 0 ? 1 : t / $t.x, $t.y === 0 ? 1 : i / $t.y, $t.z === 0 ? 1 : r / $t.z);
  35690. let o = n.originalGeometry;
  35691. return (
  35692. s > 0
  35693. ? (o === void 0 || a?.subdivisions !== s) && (o === void 0 && (o = n), (n = new h6(s).modify(o).toBufferGeometry()))
  35694. : (o !== void 0 && (n = o), (o = void 0), n.getAttribute('normal') === void 0 && n.computeVertexNormals()),
  35695. o !== void 0 && Object.assign(n, { originalGeometry: o }),
  35696. delete e.geometry,
  35697. Object.assign(n, { userData: { ...e, type: 'NonParametricGeometry' } })
  35698. );
  35699. }
  35700. static loadFromUrl(e, t, i) {
  35701. new Fw(i).load(e, (r) => {
  35702. let s = this.normalizeInputs({ geometry: r });
  35703. r.boundingBox.getSize($t);
  35704. let n = 100 / $t.x;
  35705. Object.assign(s.parameters, { width: 100, height: $t.y * n, depth: $t.z * n }), t(this.build(s));
  35706. });
  35707. }
  35708. },
  35709. TA = class {
  35710. static create(e) {
  35711. return this.build(this.normalizeInputs(e));
  35712. }
  35713. static normalizeInputs(e, t) {
  35714. let i = Object.assign(
  35715. {},
  35716. t?.parameters ?? { width: 100, depth: 0, spikes: 5, cornerRadius: 0, extrudeBevelSize: 0, extrudeBevelSegments: 3 },
  35717. e.parameters
  35718. );
  35719. return {
  35720. shape: e.shape && e.shape instanceof Nt ? e.shape : new Nt(),
  35721. parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? 0) })
  35722. };
  35723. }
  35724. static build(e) {
  35725. let { width: t, height: i, spikes: r, cornerRadius: s, depth: n, extrudeBevelSize: a, extrudeBevelSegments: o } = e.parameters,
  35726. l = e.shape,
  35727. h = t * 0.5,
  35728. u = i * 0.5,
  35729. c = 0,
  35730. d = 0,
  35731. p = (2 * Math.PI) / r;
  35732. for (let g = 0; g < r; g++) {
  35733. let m = p * g,
  35734. v = c + Math.sin(m) * h,
  35735. y = d + Math.cos(m) * u;
  35736. l.addPoint(l.createPoint(v, y));
  35737. }
  35738. l.isClosed = !0;
  35739. for (let g = 0, m = l.points.length; g < m; g++) l.points[g].roundness = s;
  35740. (l.roundness = s), l.update();
  35741. let f = Ta.create({ shape: l, parameters: { roundness: s, depth: n, extrudeBevelSize: a, extrudeBevelSegments: o } });
  35742. return Object.assign(f, { userData: { ...e, type: 'PolygonGeometry' } });
  35743. }
  35744. },
  35745. d6 = class {
  35746. static create(e) {
  35747. return this.build(this.normalizeInputs(e));
  35748. }
  35749. static normalizeInputs(e, t) {
  35750. let i = Object.assign(
  35751. {},
  35752. t?.parameters ?? { width: 100, radialSegments: 4, heightSegments: 1, cornerRadius: 0, cornerSegments: 8, openEnded: !1 },
  35753. e.parameters
  35754. );
  35755. return {
  35756. parameters: Object.assign(i, {
  35757. width: Math.abs(i.width),
  35758. height: Math.abs(i.height ?? i.width),
  35759. depth: Math.abs(i.depth ?? i.width)
  35760. })
  35761. };
  35762. }
  35763. static build(e) {
  35764. let {
  35765. width: t,
  35766. height: i,
  35767. depth: r,
  35768. radialSegments: s,
  35769. heightSegments: n,
  35770. openEnded: a,
  35771. cornerRadius: o,
  35772. cornerSegments: l
  35773. } = e.parameters,
  35774. h = new p6(t * 0.5, i, s, n, a, o, l);
  35775. return h.scale(1, 1, r / t), Object.assign(h, { userData: { ...e, type: 'PyramidGeometry' } });
  35776. }
  35777. };
  35778. function Dl(e, t, i) {
  35779. (i.x = e.x * t.x), (i.y = e.y), (i.z = e.x * t.y);
  35780. }
  35781. function ef(e, t, i, r, s, n) {
  35782. let a = t.clone().sub(e),
  35783. o = i.clone().sub(e),
  35784. l = a.angleTo(o);
  35785. if ((a.normalize(), o.normalize(), r === s)) {
  35786. let h = a.add(o).normalize();
  35787. n.copy(e).addScaledVector(h, r / Math.sin(l / 2));
  35788. } else {
  35789. let h = a.angleTo(o);
  35790. n.copy(e), n.addScaledVector(a, s / Math.sin(h)), n.addScaledVector(o, r / Math.sin(h));
  35791. }
  35792. }
  35793. function u6(e, t, i) {
  35794. let r = e.clone().sub(t),
  35795. s = i.clone().sub(t);
  35796. return r.projectOnVector(s), r.add(t);
  35797. }
  35798. var p6 = class extends Ve {
  35799. constructor(e = 0.5, t = 1, i = 4, r = 1, s = !1, n = 0, a = 4) {
  35800. super(), (i = Math.floor(Math.max(3, i))), (r = Math.floor(r)), (a = Math.floor(a));
  35801. let o = [],
  35802. l = [],
  35803. h = [],
  35804. u = [],
  35805. c = 0,
  35806. d = t / 2,
  35807. p = Math.PI / i,
  35808. f = e * Math.cos(Math.PI / i),
  35809. g = (2 * Math.PI) / i,
  35810. m = ((i - 2) * Math.PI) / i,
  35811. v = Math.PI - m,
  35812. y = new E(0, -d, 0),
  35813. b = new E(0, d, 0),
  35814. x = new G(e, -d),
  35815. w = new G(f, -d),
  35816. A = new G(0, b.y).sub(w),
  35817. S = new G(0, b.y).sub(x),
  35818. _ = new G(A.y, -A.x).normalize(),
  35819. M = new G(S.y, -S.x).normalize(),
  35820. C = e * Math.cos(Math.PI / i) * Math.tan((Math.PI - A.angle()) / 2) - 1e-8;
  35821. n = Math.min(n, C);
  35822. let T;
  35823. {
  35824. let z = new E(_.x, _.y, 0),
  35825. j = new E(Math.cos(g) * z.x, z.y, Math.sin(g) * z.x);
  35826. T = z.angleTo(j);
  35827. }
  35828. let P = n / Math.tan((Math.PI - A.angle()) / 2),
  35829. L = n / Math.tan((Math.PI - T) / 2),
  35830. D = new E();
  35831. if (!s) {
  35832. l.push(y.x, y.y, y.z), h.push(0, -1, 0), u.push(0, 0);
  35833. let z = c++,
  35834. j = [],
  35835. U = x.clone(),
  35836. N = P / Math.cos(Math.PI / i);
  35837. U.x -= N;
  35838. for (let B = 0; B < i; B++) {
  35839. let H = (B / i) * Math.PI * 2 + p,
  35840. Q = new G(Math.sin(H), Math.cos(H));
  35841. Dl(U, Q, D), l.push(D.x, D.y, D.z), h.push(0, -1, 0), u.push(0, 0), j.push(c++);
  35842. }
  35843. for (let B = 0; B < j.length; B++) o.push(j[B], z, j[(B + 1) % j.length]);
  35844. }
  35845. let k = [];
  35846. {
  35847. let z = new E(),
  35848. j = new E(),
  35849. U = new E(),
  35850. N = new E(),
  35851. B = new E(),
  35852. H = new E();
  35853. for (let Q = 0; Q < i; Q++) {
  35854. let Y = (Q / i) * Math.PI * 2 + p,
  35855. F = ((Q + 0.5) / i) * Math.PI * 2 + p,
  35856. se = ((Q + 1) / i) * Math.PI * 2 + p,
  35857. V = new G(Math.sin(Y), Math.cos(Y)),
  35858. ee = new G(Math.sin(F), Math.cos(F)),
  35859. J = new G(Math.sin(se), Math.cos(se));
  35860. Dl(x, V, j),
  35861. Dl(x, J, U),
  35862. Dl(_, ee, z),
  35863. ef(b, j, U, L, L, N),
  35864. l.push(N.x, N.y, N.z),
  35865. ef(j, b, U, L, P, B),
  35866. l.push(B.x, B.y, B.z),
  35867. ef(U, j, b, P, L, H),
  35868. l.push(H.x, H.y, H.z),
  35869. h.push(z.x, z.y, z.z),
  35870. h.push(z.x, z.y, z.z),
  35871. h.push(z.x, z.y, z.z),
  35872. u.push(0, 0),
  35873. u.push(0, 0),
  35874. u.push(0, 0);
  35875. let fe = c++,
  35876. re = c++,
  35877. oe = c++;
  35878. if ((o.push(fe, re, oe), n > 0)) {
  35879. {
  35880. let Te = j.clone().add(U).multiplyScalar(0.5),
  35881. xe = b.clone().sub(Te).normalize(),
  35882. we = y.clone().sub(Te).normalize().add(xe).normalize().multiplyScalar(-1),
  35883. Ie = H.clone().sub(B);
  35884. W(Te, Ie, we, A.angle());
  35885. }
  35886. let ue, ye;
  35887. {
  35888. let Te = new E();
  35889. Dl(M, J, Te);
  35890. let xe = H.clone().add(N).multiplyScalar(0.5);
  35891. xe = u6(xe, U, b);
  35892. let we = H.clone().sub(N);
  35893. [ue, ye] = W(xe, we, Te, T, N.y);
  35894. }
  35895. {
  35896. let Te = ue,
  35897. xe = Te.clone().setY(0).normalize(),
  35898. we = new E(0, -1, 0),
  35899. Ie = xe.clone().cross(we);
  35900. X(Te, xe, we, Ie);
  35901. }
  35902. k.concat(ye);
  35903. {
  35904. let Te = A.angle(),
  35905. xe = Math.PI - Te,
  35906. we = b.clone();
  35907. we.y -= n / Math.sin(Te - Math.PI / 2);
  35908. let Ie = new E(),
  35909. He = [];
  35910. for (let I = 0; I < a; I++) {
  35911. let O = [],
  35912. ie = Math.PI / 2 - (xe * I) / a,
  35913. pe = Math.cos(ie),
  35914. me = Math.sin(ie),
  35915. be = F;
  35916. for (let We = 0; We <= I; We++) {
  35917. let Me = Math.cos(be),
  35918. ce = Math.sin(be);
  35919. (z.x = pe * ce),
  35920. (z.y = me),
  35921. (z.z = pe * Me),
  35922. Ie.copy(we).addScaledVector(z, n),
  35923. l.push(Ie.x, Ie.y, Ie.z),
  35924. h.push(z.x, z.y, z.z),
  35925. u.push(0, 0),
  35926. O.push(c++),
  35927. (be += (Math.PI * 2) / I / i);
  35928. }
  35929. He.push(O);
  35930. }
  35931. ye.reverse(), He.push(ye);
  35932. let dt = He.length - 1;
  35933. for (let I = 0; I < dt; I++) {
  35934. let O = He[I],
  35935. ie = He[I + 1],
  35936. pe = O.length - 1;
  35937. o.push(ie[1], O[0], ie[0]);
  35938. for (let me = 1; me <= pe; me++) o.push(O[me], O[me - 1], ie[me]), o.push(ie[me + 1], O[me], ie[me]);
  35939. }
  35940. }
  35941. }
  35942. }
  35943. }
  35944. this.setIndex(o),
  35945. this.setAttribute('position', new Ce(l, 3)),
  35946. this.setAttribute('normal', new Ce(h, 3)),
  35947. this.setAttribute('uv', new Ce(u, 2));
  35948. function W(z, j, U, N, B) {
  35949. let H = -N / 2,
  35950. Q = (Math.PI - N) / 2,
  35951. Y = j.clone().normalize().cross(U);
  35952. z.addScaledVector(U, -n / Math.sin(Q));
  35953. let F = new E(),
  35954. se = new E(),
  35955. V = 1,
  35956. ee = c,
  35957. J = [];
  35958. for (let fe = 0; fe <= a; fe++) {
  35959. let re = H + (fe / a) * N;
  35960. se.set(0, 0, 0), se.addScaledVector(Y, Math.sin(re)), se.addScaledVector(U, Math.cos(re));
  35961. for (let oe = 0; oe <= V; oe++) {
  35962. let ue = oe / V - 0.5;
  35963. if ((F.copy(z), F.addScaledVector(j, ue), F.addScaledVector(se, n), B != null)) {
  35964. let ye = Math.max(0, F.y - B);
  35965. F.addScaledVector(j, -ye / j.y);
  35966. }
  35967. l.push(F.x, F.y, F.z), h.push(se.x, se.y, se.z), u.push(0, 0), oe === 0 && J.push(c), c++;
  35968. }
  35969. }
  35970. for (let fe = 0; fe < a; fe++)
  35971. for (let re = 0; re < V; re++) {
  35972. let oe = ee + re + (V + 1) * fe,
  35973. ue = oe + (V + 1),
  35974. ye = ue + 1,
  35975. Te = oe + 1;
  35976. o.push(oe, ue, Te), o.push(ue, ye, Te);
  35977. }
  35978. return [z.clone().addScaledVector(j, 0.5), J];
  35979. }
  35980. function X(z, j, U, N) {
  35981. let B = Math.PI / 2,
  35982. H = S.angle() - B,
  35983. Q = [],
  35984. Y = new E(),
  35985. F = new E();
  35986. for (let V = 0; V <= a; V++) {
  35987. let ee = [],
  35988. J = V / a;
  35989. for (let fe = 0; fe <= V; fe++) {
  35990. let re = ((V ? fe / V : 0) - 0.5) * v,
  35991. oe = Math.cos(re),
  35992. ue = Math.sin(re),
  35993. ye = Math.atan(Math.tan(H) * oe),
  35994. Te = (B + ye) * J,
  35995. xe = Math.cos(Te),
  35996. we = Math.sin(Te);
  35997. Y.set(0, 0, 0),
  35998. Y.addScaledVector(j, we * oe),
  35999. Y.addScaledVector(U, xe),
  36000. Y.addScaledVector(N, we * ue),
  36001. F.copy(z).addScaledVector(Y, n),
  36002. l.push(F.x, F.y, F.z),
  36003. h.push(Y.x, Y.y, Y.z),
  36004. u.push(0, 0),
  36005. ee.push(c++);
  36006. }
  36007. Q.push(ee);
  36008. }
  36009. let se = Q.length - 1;
  36010. for (let V = 0; V < se; V++) {
  36011. let ee = Q[V],
  36012. J = Q[V + 1],
  36013. fe = ee.length - 1;
  36014. o.push(ee[0], J[1], J[0]);
  36015. for (let re = 1; re <= fe; re++) o.push(ee[re - 1], ee[re], J[re]), o.push(ee[re], J[re + 1], J[re]);
  36016. }
  36017. }
  36018. }
  36019. },
  36020. PA = class {
  36021. static create(e) {
  36022. return this.build(this.normalizeInputs(e));
  36023. }
  36024. static normalizeInputs(e, t) {
  36025. let i = Object.assign(
  36026. {},
  36027. t?.parameters ?? {
  36028. width: 100,
  36029. depth: 0,
  36030. cornerRadius: [0, 0, 0, 0],
  36031. cornerType: 1,
  36032. extrudeBevelSize: 0,
  36033. extrudeBevelSegments: 1
  36034. },
  36035. e.parameters
  36036. ),
  36037. r = Object.assign(t?.ui ?? { enabledIndieCorners: !1 }, e.ui);
  36038. return {
  36039. shape: e.shape && e.shape instanceof Nt ? e.shape : new Nt(),
  36040. parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? 0) }),
  36041. ui: r
  36042. };
  36043. }
  36044. static build(e) {
  36045. let t = e.shape,
  36046. { width: i, height: r, cornerRadius: s, cornerType: n, depth: a, extrudeBevelSize: o, extrudeBevelSegments: l } = e.parameters,
  36047. h = { x: i * 0.5, y: r * 0.5 },
  36048. u = { x: -h.x, y: -h.y },
  36049. c = { x: h.x, y: h.y };
  36050. function d(x, w, A) {
  36051. return w > i && A > r ? Math.min((x * i) / w, (x * r) / A) : w > i ? (x * i) / w : A > r ? (x * r) / A : x;
  36052. }
  36053. let p = [];
  36054. (p[0] = s[0] === 0 ? 0 : d(s[0], s[0] + s[3], s[0] + s[1])),
  36055. (p[1] = s[1] === 0 ? 0 : d(s[1], s[1] + s[2], s[1] + s[0])),
  36056. (p[2] = s[2] === 0 ? 0 : d(s[2], s[2] + s[1], s[2] + s[3])),
  36057. (p[3] = s[3] === 0 ? 0 : d(s[3], s[3] + s[0], s[3] + s[2]));
  36058. let f = u.x,
  36059. g = c.x,
  36060. m = c.y,
  36061. v = u.y;
  36062. t.addPoint(t.createPoint(f, m)),
  36063. t.addPoint(t.createPoint(g, m)),
  36064. t.addPoint(t.createPoint(g, v)),
  36065. t.addPoint(t.createPoint(f, v)),
  36066. (t.isClosed = !0);
  36067. let y = !0;
  36068. for (let x = 0, w = t.points.length; x < w; x++) (t.points[x].roundness = p[x]), x > 0 && p[x] !== p[x - 1] && (y = !1);
  36069. y && (t.roundness = p[0]), (t.useCubicForRoundedCorners = n !== 1), t.update();
  36070. let b = Ta.create({ shape: t, parameters: { depth: a, extrudeBevelSize: o, extrudeBevelSegments: l } });
  36071. return Object.assign(b, { userData: { ...e, type: 'RectangleGeometry' } });
  36072. }
  36073. },
  36074. f6 = class {
  36075. static create(e) {
  36076. return this.build(this.normalizeInputs(e));
  36077. }
  36078. static normalizeInputs(e, t) {
  36079. let i = Object.assign(
  36080. {},
  36081. t?.parameters ?? {
  36082. width: 100,
  36083. widthSegments: 64,
  36084. heightSegments: 64,
  36085. phiStart: 0,
  36086. phiLength: 2 * Math.PI,
  36087. thetaStart: 0,
  36088. thetaLength: Math.PI
  36089. },
  36090. e.parameters
  36091. );
  36092. return {
  36093. parameters: Object.assign(i, {
  36094. width: Math.abs(i.width),
  36095. height: Math.abs(i.height ?? i.width),
  36096. depth: Math.abs(i.depth ?? i.width)
  36097. })
  36098. };
  36099. }
  36100. static build(e) {
  36101. let {
  36102. width: t = 100,
  36103. height: i = t,
  36104. depth: r = t,
  36105. widthSegments: s = 64,
  36106. heightSegments: n = 64,
  36107. phiStart: a,
  36108. phiLength: o,
  36109. thetaStart: l,
  36110. thetaLength: h
  36111. } = e.parameters,
  36112. u = new yg(0.5 * t, s, n, a, o, l, h);
  36113. return u.scale(1, i / t, r / t), Object.assign(u, { userData: { ...e, type: 'SphereGeometry' } });
  36114. }
  36115. },
  36116. m6 = class {
  36117. static create(e) {
  36118. return this.build(this.normalizeInputs(e));
  36119. }
  36120. static normalizeInputs(e, t) {
  36121. let i = Object.assign({}, t?.parameters ?? { width: 100, depth: 0, widthSegments: 8, heightSegments: 8 }, e.parameters);
  36122. return { parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: 0 }) };
  36123. }
  36124. static build(e) {
  36125. let { width: t = 100, height: i = t, widthSegments: r = 8, heightSegments: s = 8 } = e.parameters,
  36126. n = new ou(t, i, r, s);
  36127. return n.scale(1, 1, 1), Object.assign(n, { userData: { ...e, type: 'PlaneGeometry' } });
  36128. }
  36129. },
  36130. g6 = class {
  36131. static create(e) {
  36132. return this.build(this.normalizeInputs(e));
  36133. }
  36134. static normalizeInputs(e, t) {
  36135. let i = Object.assign({}, t?.parameters ?? { width: 100, angle: 90, cornerRadius: 24, cornerSegments: 8 }, e.parameters);
  36136. return {
  36137. parameters: Object.assign(i, {
  36138. width: Math.abs(i.width),
  36139. height: Math.abs(i.height ?? i.width),
  36140. depth: Math.abs(i.depth ?? i.width)
  36141. })
  36142. };
  36143. }
  36144. static build(e) {
  36145. let { width: t, height: i, depth: r, angle: s, cornerRadius: n, cornerSegments: a } = e.parameters,
  36146. o = new v6(t, i, r, s, n, a);
  36147. return Object.assign(o, { userData: { ...e, type: 'BackdropGeometry' } });
  36148. }
  36149. },
  36150. v6 = class extends Ve {
  36151. constructor(e = 1, t = 1, i = 1, r = 90, s = 10, n = 24) {
  36152. super(), (this.type = 'BackdropGeometry');
  36153. let a = [],
  36154. o = [],
  36155. l = [],
  36156. h = 0.001;
  36157. s == 0 && (n = 1), (n = Math.max(1, Math.floor(n))), (s = Math.min(s, 100)), (r = Math.min(180 - h, r)), (r *= Math.PI / 180);
  36158. let u = [],
  36159. c = Math.PI / 2,
  36160. d = (se = 0, V = 0, ee = 0) => new E(se, V, ee),
  36161. p = d(),
  36162. f = d(),
  36163. [g, m, v] = [t / 2, e / 2, i / 2],
  36164. y = -m,
  36165. b = +m,
  36166. [x, w, A] = [d(y, -g, +v), d(y, -g, -v), d(y, +g, -v)],
  36167. S = (se, V = !1) => Math.sin(se - Math.PI / (1 + +V)),
  36168. _ = (se, V = !1) => Math.cos(se - Math.PI / (1 + +V));
  36169. A.y = Math.sin(r) * t - g;
  36170. let M = Math.cos(r) * t - v,
  36171. C = x.z - h;
  36172. r <= c ? ((A.z = Math.min(M, C)), A.z == C && (A.y -= (M - C) / Math.tan(c - r))) : (w.z = Math.min(w.z - M - v, x.z - h)),
  36173. p.subVectors(x, w),
  36174. f.subVectors(A, w);
  36175. let T = (Math.min(p.length(), f.length()) * s) / 100,
  36176. P = T * Math.tan(r / 2),
  36177. L = T / Math.cos(r / 2),
  36178. D = p.clone().normalize().add(f.normalize()).setLength(L).add(w);
  36179. p.set(0, S(r, !0), _(r, !0)), u.push([A, p.clone()]);
  36180. let k = (Math.PI - r) / n;
  36181. for (let se = 0; se <= n; se++) {
  36182. let V = c + r + se * k;
  36183. p.set(0, Math.sin(V) * P, Math.cos(V) * P), p.add(D), f.set(0, S(V), _(V)), u.push([p.clone(), f.clone()]);
  36184. }
  36185. u.push([x, d(0, 1, 0)]);
  36186. let W = Math.sin(k / 2) * P * 2,
  36187. X = u.length - 1,
  36188. z = u[0][0].distanceTo(u[1][0]),
  36189. j = u[X - 1][0].distanceTo(u[X][0]),
  36190. U = z + W * n + j;
  36191. u[0].push(1);
  36192. for (let se = 0; se <= n; se++) u[se + 1].push(1 - (z + se * W) / U);
  36193. u[X].push(0);
  36194. let [N, B, H] = u[0],
  36195. Q,
  36196. Y,
  36197. F;
  36198. for (let se = 1; se < u.length; se++)
  36199. ([Q, Y, F] = u[se]),
  36200. a.push(y, N.y, N.z, y, Q.y, Q.z, b, N.y, N.z, b, N.y, N.z, y, Q.y, Q.z, b, Q.y, Q.z),
  36201. o.push(0, B.y, B.z, 0, Y.y, Y.z, 0, B.y, B.z, 0, B.y, B.z, 0, Y.y, Y.z, 0, Y.y, Y.z),
  36202. l.push(0, H, 0, F, 1, H, 1, H, 0, F, 1, F),
  36203. ([N, B, H] = [Q, Y, F]);
  36204. this.setAttribute('position', new Ce(a, 3)), this.setAttribute('normal', new Ce(o, 3)), this.setAttribute('uv', new Ce(l, 2));
  36205. }
  36206. },
  36207. DA = class {
  36208. static create(e) {
  36209. return this.build(this.normalizeInputs(e));
  36210. }
  36211. static normalizeInputs(e, t) {
  36212. let i = Object.assign(
  36213. {},
  36214. t?.parameters ?? {
  36215. width: 100,
  36216. depth: 0,
  36217. innerRadiusPercent: 38.19,
  36218. spikes: 5,
  36219. cornerRadius: 0,
  36220. angle: 360,
  36221. extrudeBevelSize: 0,
  36222. extrudeBevelSegments: 1
  36223. },
  36224. e.parameters
  36225. );
  36226. return {
  36227. shape: e.shape && e.shape instanceof Nt ? e.shape : new Nt(),
  36228. parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? 0) })
  36229. };
  36230. }
  36231. static build(e) {
  36232. let {
  36233. width: t,
  36234. height: i,
  36235. innerRadiusPercent: r,
  36236. spikes: s,
  36237. cornerRadius: n,
  36238. angle: a,
  36239. depth: o,
  36240. extrudeBevelSize: l,
  36241. extrudeBevelSegments: h
  36242. } = e.parameters,
  36243. u = e.shape,
  36244. c = t * 0.5,
  36245. d = i * 0.5,
  36246. p = 0,
  36247. f = 0,
  36248. g = (a * Math.PI) / 360 / s,
  36249. m = (Math.PI / 2) * 3 * -1,
  36250. v = (c * r) / 100,
  36251. y = (d * r) / 100;
  36252. if (s === 3 && r === 50) {
  36253. g = (2 * Math.PI) / s;
  36254. for (let x = 0; x < s; x++) {
  36255. let w = g * x,
  36256. A = p + Math.sin(w) * c,
  36257. S = f + Math.cos(w) * d;
  36258. u.addPoint(u.createPoint(A, S));
  36259. }
  36260. } else
  36261. for (let x = 0; x < s; x++) {
  36262. let w = p + Math.cos(m) * c,
  36263. A = f + Math.sin(m) * d;
  36264. u.addPoint(u.createPoint(w, A)),
  36265. (m += g),
  36266. (w = p + Math.cos(m) * v),
  36267. (A = f + Math.sin(m) * y),
  36268. x <= s,
  36269. u.addPoint(u.createPoint(w, A)),
  36270. (m += g);
  36271. }
  36272. u.isClosed = !0;
  36273. for (let x = 0, w = u.points.length; x < w; x++) u.points[x].roundness = n;
  36274. (u.roundness = n), u.update();
  36275. let b = Ta.create({ shape: u, parameters: { roundness: n, depth: o, extrudeBevelSize: l, extrudeBevelSegments: h } });
  36276. return Object.assign(b, { userData: { ...e, type: 'StarGeometry' } });
  36277. }
  36278. },
  36279. y6 = class {
  36280. static create(e) {
  36281. return this.build(this.normalizeInputs(e));
  36282. }
  36283. static normalizeInputs(e, t) {
  36284. let i = Object.assign({}, t?.parameters ?? { width: 100, depth: 0 }, e.parameters);
  36285. return {
  36286. parameters: Object.assign(i, { width: Math.abs(i.width), height: Math.abs(i.height ?? i.width), depth: Math.abs(i.depth ?? 0) })
  36287. };
  36288. }
  36289. static build(e) {
  36290. let { width: t, height: i } = e.parameters,
  36291. r = new ou(t, i);
  36292. return Object.assign(r, { userData: { ...e, type: 'TextFrameGeometry' } });
  36293. }
  36294. },
  36295. x6 = class {
  36296. static create(e) {
  36297. return this.build(this.normalizeInputs(e));
  36298. }
  36299. static normalizeInputs(e, t) {
  36300. let i = Object.assign(
  36301. {},
  36302. t?.parameters ?? { width: 100, radialSegments: 32, tubularSegments: 64, arc: Math.PI * 2, cornerRadius: 30, cornerSegments: 8 },
  36303. e.parameters
  36304. ),
  36305. r = Math.abs(i.width),
  36306. s = Math.abs(i.height ?? i.width),
  36307. n = Math.round(Math.abs(i.depth ?? i.width * 0.25));
  36308. return { parameters: Object.assign(i, { width: r, height: s, depth: n }) };
  36309. }
  36310. static build(e) {
  36311. let {
  36312. width: t,
  36313. height: i,
  36314. depth: r,
  36315. radialSegments: s,
  36316. tubularSegments: n,
  36317. arc: a,
  36318. cornerRadius: o,
  36319. cornerSegments: l
  36320. } = e.parameters,
  36321. h = b6(t, i, r, t * 0.5, a, n, 0, 0, s, o, l);
  36322. return h.scale(1, i / t, 1), Object.assign(h, { userData: { ...e, type: 'TorusGeometry' } });
  36323. }
  36324. };
  36325. function b6(e, t, i, r, s, n, a, o, l, h, u) {
  36326. return ([t, i] = [i, t]), (a = t / 2), (s /= 2 * Math.PI), s == 1 && (h = 0), new nv(!0, e, t, i, r, s, n, a, o, l, h, u);
  36327. }
  36328. var w6 = class {
  36329. static create(e) {
  36330. return this.build(this.normalizeInputs(e));
  36331. }
  36332. static normalizeInputs(e, t) {
  36333. let i = Object.assign({}, t?.parameters ?? { width: 100, tubularSegments: 64, radialSegments: 32, p: 2, q: 3 }, e.parameters);
  36334. return {
  36335. parameters: Object.assign(i, {
  36336. width: Math.abs(i.width),
  36337. height: Math.abs(i.height ?? i.width),
  36338. depth: Math.abs(i.depth ?? i.width),
  36339. tube: i.tube ?? i.width * 0.125
  36340. })
  36341. };
  36342. }
  36343. static build(e) {
  36344. let { width: t, tube: i, tubularSegments: r, radialSegments: s, p: n, q: a } = e.parameters,
  36345. o = t * 0.5;
  36346. o !== i && (o -= i);
  36347. let l = new zw(o, i, r, s, n, a);
  36348. return Object.assign(l, { userData: { ...e, type: 'TorusKnotGeometry' } });
  36349. }
  36350. },
  36351. _6 = class {
  36352. static create(e) {
  36353. return this.build(this.normalizeInputs(e));
  36354. }
  36355. static normalizeInputs(e, t) {
  36356. let i = Object.assign(
  36357. {},
  36358. t?.parameters ?? { width: 100, depth: 0, spikes: 5, cornerRadius: 0, extrudeBevelSize: 0, extrudeBevelSegments: 1, isRect: !1 },
  36359. e.parameters
  36360. );
  36361. return {
  36362. shape: e.shape && e.shape instanceof Nt ? e.shape : new Nt(),
  36363. parameters: Object.assign(i, {
  36364. width: Math.abs(i.width),
  36365. height: Math.abs(i.height ?? i.width * (i.isRect ? 1 : Math.sqrt(3) / 2)),
  36366. depth: Math.abs(i.depth ?? 0)
  36367. })
  36368. };
  36369. }
  36370. static build(e) {
  36371. let { width: t = 100, height: i, cornerRadius: r, depth: s, extrudeBevelSize: n, extrudeBevelSegments: a, isRect: o } = e.parameters,
  36372. l = e.shape,
  36373. h = t * 0.5,
  36374. u = i * 0.5;
  36375. o
  36376. ? (l.addPoint(l.createPoint(-h, u)), l.addPoint(l.createPoint(h, -u)), l.addPoint(l.createPoint(-h, -u)))
  36377. : (l.addPoint(l.createPoint(0, u)), l.addPoint(l.createPoint(h, -u)), l.addPoint(l.createPoint(-h, -u))),
  36378. (l.isClosed = !0);
  36379. for (let d = 0, p = l.points.length; d < p; d++) l.points[d].roundness = r;
  36380. (l.roundness = r), l.update();
  36381. let c = Ta.create({ shape: l, parameters: { roundness: r, depth: s, extrudeBevelSize: n, extrudeBevelSegments: a } });
  36382. return Object.assign(c, { userData: { ...e, type: 'TriangleGeometry' } });
  36383. }
  36384. };
  36385. function A6(e, t) {
  36386. let i = 2 * Math.PI;
  36387. return ((e % i) + i) % i === ((t % i) + i) % i;
  36388. }
  36389. function S6(e, t, i) {
  36390. let r = [new E(), new E(), new E()],
  36391. s = [new E(), new E(), new E()];
  36392. return (
  36393. e.extractBasis(r[0], r[1], r[2]),
  36394. t.extractBasis(s[0], s[1], s[2]),
  36395. r.forEach((n, a) => {
  36396. let o = s[a],
  36397. l = it.lerp(n.length(), o.length(), i);
  36398. n.lerp(o, i).setLength(l);
  36399. }),
  36400. new ve().makeBasis(r[0], r[1], r[2])
  36401. );
  36402. }
  36403. var M6 = class {
  36404. static create(e) {
  36405. return this.build(this.normalizeInputs(e));
  36406. }
  36407. static normalizeInputs(e, t) {
  36408. let i = Object.assign(
  36409. {},
  36410. t?.parameters ?? {
  36411. width: 100,
  36412. height: 100,
  36413. depth: 1,
  36414. subdivisions: 12,
  36415. roundness: 0,
  36416. extrudeBevelSize: 0,
  36417. extrudeBevelSegments: 3
  36418. },
  36419. e.parameters
  36420. ),
  36421. r = Math.abs(i.width),
  36422. s = Math.abs(i.height ?? i.width),
  36423. n = Math.abs(i.depth ?? 0),
  36424. a = t?.shapeData ?? sv.create({ parameters: J_ }).userData.shape;
  36425. return {
  36426. path: e.path ?? zd.defaultData(),
  36427. parameters: Object.assign(i, { width: r, height: s, depth: n, extrusion: { ...$_, ...i.extrusion } }),
  36428. shapeData: a
  36429. };
  36430. }
  36431. static build(e) {
  36432. if (e.path.points.length >= 2) {
  36433. let t = new E6(e);
  36434. return Object.assign(t, { userData: { ...e, type: 'PathGeometry' } });
  36435. } else return Object.assign(new Ve(), { userData: { ...e, type: 'PathGeometry' } });
  36436. }
  36437. },
  36438. E6 = class extends Ve {
  36439. constructor(e) {
  36440. super(), (this.type = 'PathExtrusionGeometry'), (this.inputs = e), this.build();
  36441. }
  36442. _isGeometryClosed() {
  36443. return this.inputs.path.isClosed && this.inputs.parameters.extrusion.depth === 1;
  36444. }
  36445. _isOpenEnded() {
  36446. let e = this.inputs.parameters.extrusion;
  36447. return !(this.inputs.path.isClosed && e.depth === 1) || !A6(e.twist, 0) || e.startScale !== e.endScale;
  36448. }
  36449. build() {
  36450. let e = this._extractPathPoints();
  36451. if (e.length < 2) return;
  36452. let t = this._computeBasisMatrices(e),
  36453. { depth: i, offset: r } = this.inputs.parameters.extrusion,
  36454. s = this.inputs.path.isClosed ? e.length : e.length - 1,
  36455. n = Math.floor(r * s),
  36456. a = this.inputs.path.isClosed ? Math.ceil((i + r) * s) : Math.ceil(Math.min(1, i + r) * s),
  36457. o = Math.min(Math.max(2, a - n + 1), s + 2),
  36458. l = [],
  36459. h = [];
  36460. for (let C = 0; C < o; C++) {
  36461. let T = this.inputs.path.isClosed ? (C + n) % e.length : Math.min(C + n, e.length - 1);
  36462. l.push(e[T].clone()), h.push(t[T].clone());
  36463. }
  36464. let u = (C, T, P) => {
  36465. (l[C] = l[C].clone().lerp(l[T], P)), (h[C] = S6(h[C], h[T], P));
  36466. },
  36467. c = 0,
  36468. d = (r * s) % 1;
  36469. (!this.inputs.path.isClosed || i <= 1) && (d || r === 0) && ((c = d), u(0, 1, c));
  36470. let p = 0,
  36471. f = ((r + i) * s) % 1;
  36472. if (
  36473. (((this.inputs.path.isClosed && i <= 1) || (!this.inputs.path.isClosed && r + i < 1)) &&
  36474. f &&
  36475. ((p = f), u(l.length - 1, l.length - 2, 1 - p)),
  36476. i === 0)
  36477. ) {
  36478. let C = l.length - 1;
  36479. l[C].copy(l[0]), h[C].copy(h[0]);
  36480. }
  36481. this._applyPathModifiers(h, c, p);
  36482. let { regions: g, infos: m, vertices: v } = this._computeShapePoints(5),
  36483. y = 0,
  36484. b = 0;
  36485. m.sort((C, T) => C.start - T.start),
  36486. m.forEach((C) => {
  36487. (C.verticesStart = y),
  36488. (C.verticesCount = C.continuous.reduce((T, P, L) => T + (L === 0 || !P ? 2 : 1), 0)),
  36489. (b += C.verticesCount),
  36490. (y = b);
  36491. });
  36492. let x = b * o,
  36493. w,
  36494. A = 0;
  36495. if (this._isOpenEnded()) {
  36496. try {
  36497. w = _n({ windingRule: yt.ODD, elementType: Zt.POLYGONS, polySize: 3, vertexSize: 2, strict: !0, contours: g });
  36498. } catch {
  36499. w = xA;
  36500. }
  36501. A = w.vertexCount;
  36502. }
  36503. let S = x + 2 * A,
  36504. _ = { positions: new Float32Array(S * 3), normals: new Float32Array(S * 3), uvs: new Float32Array(S * 2) },
  36505. M = [];
  36506. m.forEach((C) => {
  36507. this._extrudeRegion(C, v, h, l, _, M, this._isGeometryClosed() && !this._isOpenEnded());
  36508. }),
  36509. w && (this._closeEnd(w, x, M, _, h[0], l[0], !1), this._closeEnd(w, x + A, M, _, h[h.length - 1], l[l.length - 1], !0)),
  36510. this.setAttribute('position', new Xe(_.positions, 3)),
  36511. this.setAttribute('normal', new Xe(_.normals, 3)),
  36512. this.setAttribute('uv', new Xe(_.uvs, 2)),
  36513. this.setIndex(M);
  36514. }
  36515. _extractPathPoints() {
  36516. let e = cA(this.inputs.path).getPoints(this.inputs.path.subdivisions);
  36517. if (e.length < 2) return [];
  36518. let t = [e[0]];
  36519. return (
  36520. e.forEach((i) => {
  36521. t[t.length - 1].distanceToSquared(i) > 0.001 && t.push(i);
  36522. }),
  36523. this.inputs.path.isClosed && t[t.length - 1].distanceTo(t[0]) < 0.001 && t.pop(),
  36524. t
  36525. );
  36526. }
  36527. _computeBasisMatrices(e) {
  36528. let t = [],
  36529. i = e.length,
  36530. r = this.inputs.path.isClosed,
  36531. s = new E(),
  36532. n = new E(),
  36533. a = new E(),
  36534. o = new E(),
  36535. l = new E(0, 1, 0);
  36536. for (let f = 0; f < i; f++) {
  36537. let g = e[f],
  36538. m;
  36539. f === 0 ? (m = r ? e[e.length - 2] : g.clone().multiplyScalar(2).sub(e[1])) : (m = e[f - 1]);
  36540. let v;
  36541. f === i - 1
  36542. ? (v = r
  36543. ? e[1]
  36544. : g
  36545. .clone()
  36546. .multiplyScalar(2)
  36547. .sub(e[f - 1]))
  36548. : (v = e[f + 1]);
  36549. let y = g.clone().sub(m).normalize(),
  36550. b = v.clone().sub(g).normalize(),
  36551. x = y.clone().add(b).normalize();
  36552. a.copy(x), f === 0 && (x.equals(l) || x.clone().negate().equals(l)) && l.set(0, 0, 1);
  36553. let w = l.clone().cross(x).normalize(),
  36554. A = x.clone().cross(w).normalize();
  36555. l.copy(A), o.copy(w), f === 0 && (s.copy(A), n.copy(x));
  36556. let S = new ve().makeBasis(w, A, x);
  36557. t.push(S);
  36558. }
  36559. let h = r ? n : a,
  36560. u = r ? s : new E(0, 1, 0),
  36561. c = h.clone().cross(o).normalize(),
  36562. d = Math.acos(u.dot(c));
  36563. if (isNaN(d)) return t;
  36564. let p = u.clone().cross(c);
  36565. h.dot(p) > 0 && (d *= -1);
  36566. for (let f = 1; f < t.length; f++) {
  36567. let g = new ve().makeRotationZ((d * f) / t.length);
  36568. t[f].multiply(g);
  36569. }
  36570. return t;
  36571. }
  36572. _applyPathModifiers(e, t, i) {
  36573. let r = e.length,
  36574. { angle: s, twist: n, startScale: a, endScale: o } = this.inputs.parameters.extrusion,
  36575. l = new ve(),
  36576. h = new ve();
  36577. return (
  36578. e.forEach((u, c) => {
  36579. let d = c === 0 ? 0 : c === r - 1 ? 1 : (c - t) / (r - (i === 0 ? 0 : 1) - (t + (1 - i)));
  36580. l.makeRotationZ(it.lerp(s, s + n, d));
  36581. let p = it.lerp(a, o, d);
  36582. h.makeScale(p, p, p), u.multiply(l).multiply(h);
  36583. }),
  36584. e
  36585. );
  36586. }
  36587. _computeShapePoints(e = 12, t = yt.ODD) {
  36588. let i = this.inputs.shapeData,
  36589. r = i.extractShapePointsToFlatArray([], e),
  36590. s = i.shapeHoles.map((p) => {
  36591. let f = p.extractShapePointsToFlatArray([], e),
  36592. g = [];
  36593. for (let m = f.length - 1; m >= 1; m -= 2) {
  36594. let v = f[m - 1],
  36595. y = f[m - 0];
  36596. g.push(v, y);
  36597. }
  36598. return g;
  36599. }),
  36600. n;
  36601. try {
  36602. n = _n({ windingRule: t, elementType: Zt.BOUNDARY_CONTOURS, vertexSize: 2, strict: !0, contours: [r] });
  36603. } catch {
  36604. n = rv;
  36605. }
  36606. let a;
  36607. try {
  36608. a = _n({ windingRule: yt.ODD, elementType: Zt.BOUNDARY_CONTOURS, vertexSize: 2, strict: !0, contours: [...s] });
  36609. } catch {
  36610. a = yA;
  36611. }
  36612. if (!n) throw new Error('error generating geometry');
  36613. let o = n.elementCount;
  36614. if (a) {
  36615. n.elementCount += a.elementCount;
  36616. for (let p = 0; p < a.elements.length; p++) {
  36617. let f = a.elements[p],
  36618. g = p % 2 === 0 ? n.vertexCount : 0;
  36619. n.elements.push(f + g);
  36620. }
  36621. for (let p = 0; p < a.vertexIndices.length; p++) {
  36622. let f = a.vertexIndices[p],
  36623. g = n.vertexCount;
  36624. n.vertexIndices.push(f + g);
  36625. }
  36626. for (let p = 0; p < a.vertices.length; p++) {
  36627. let f = a.vertices[p];
  36628. n.vertices.push(f);
  36629. }
  36630. }
  36631. let l = 1 / 0,
  36632. h = -1 / 0,
  36633. u = 1 / 0,
  36634. c = -1 / 0;
  36635. for (let p = 0, f = n.vertexCount; p < f; p++) {
  36636. let g = p * 2,
  36637. m = n.vertices[g + 0],
  36638. v = n.vertices[g + 1];
  36639. m < l && (l = m), m > h && (h = m), v < u && (u = v), v > c && (c = v);
  36640. }
  36641. let d = [];
  36642. for (let p = n.elementCount - 1; p >= 0; p--) {
  36643. let f = p >= o,
  36644. g = p * 2,
  36645. m = n.elements[g + 0],
  36646. v = n.elements[g + 1],
  36647. y = m + v,
  36648. b = { start: m, count: v, normals: [], isHole: f, continuous: [], verticesStart: 0, verticesCount: 0 };
  36649. d.push(b);
  36650. let x = m,
  36651. w = y - 1,
  36652. A = m + 1,
  36653. S = i.roundedCurves.length;
  36654. do {
  36655. let _ = x - m,
  36656. M = n.vertices[w * 2 + 0],
  36657. C = n.vertices[w * 2 + 1],
  36658. T = n.vertices[x * 2 + 0],
  36659. P = n.vertices[x * 2 + 1],
  36660. L = n.vertices[A * 2 + 0],
  36661. D = n.vertices[A * 2 + 1],
  36662. k = T - M,
  36663. W = P - C,
  36664. X = Math.sqrt(k * k + W * W);
  36665. (k /= X), (W /= X);
  36666. let z = T - L,
  36667. j = P - D,
  36668. U = Math.sqrt(z * z + j * j);
  36669. (z /= U), (j /= U), (b.normals[_ * 2 + 0] = -j), (b.normals[_ * 2 + 1] = z);
  36670. let N = n.vertexIndices[x];
  36671. if (Array.isArray(N)) b.continuous[_] = !1;
  36672. else {
  36673. let [B, H] = i.getCurveIndexFromVertexId(N - 1, !0);
  36674. if (H > 0 && H < 1) b.continuous[_] = !0;
  36675. else {
  36676. let Q = H === 1 ? B + 1 : B - 1;
  36677. Q = (Q + S) % S;
  36678. let Y = H === 1 ? 0 : 1,
  36679. F = i.roundedCurves[B].getTangent(H),
  36680. se = i.roundedCurves[Q].getTangent(Y);
  36681. b.continuous[_] = F.dot(se) > 0.95;
  36682. }
  36683. }
  36684. f && ((b.normals[_ * 2 + 0] *= -1), (b.normals[_ * 2 + 1] *= -1)), ([w, x, A] = [x, A, A + 1]), A >= y && (A -= v);
  36685. } while (A !== m + 1);
  36686. }
  36687. return { regions: [r, ...s], infos: d, vertices: n.vertices };
  36688. }
  36689. _insertVertex(e, t, i, r, s) {
  36690. let n = t * 2,
  36691. a = t * 3;
  36692. (e.positions[a + 0] = i.x),
  36693. (e.positions[a + 1] = i.y),
  36694. (e.positions[a + 2] = i.z),
  36695. (e.normals[a + 0] = r.x),
  36696. (e.normals[a + 1] = r.y),
  36697. (e.normals[a + 2] = r.z),
  36698. (e.uvs[n + 0] = s.x),
  36699. (e.uvs[n + 1] = s.y);
  36700. }
  36701. _extrudeRegion(e, t, i, r, s, n, a) {
  36702. let o = new E(),
  36703. l = new E(),
  36704. h = new E(),
  36705. u = new E(),
  36706. c = new G();
  36707. i.forEach((p, f) => {
  36708. let g = r[f],
  36709. m = e.verticesStart * i.length + e.verticesCount * f;
  36710. for (let v = 0; v < e.count; v++) {
  36711. let y = (e.start + v) * 2;
  36712. if ((o.set(t[y + 0], t[y + 1], 0), h.copy(o).applyMatrix4(p).add(g), e.continuous[v]))
  36713. u.set(e.normals[v * 2 + 0], e.normals[v * 2 + 1], 0);
  36714. else {
  36715. let b = v == 0 ? (e.start + e.count - 1) * 2 : y - 2;
  36716. l.set(t[b + 0], t[b + 1], 0), u.copy(o).sub(l), u.set(-u.y, u.x, 0), e.isHole || u.negate();
  36717. }
  36718. if (
  36719. (u.applyMatrix4(p).normalize(),
  36720. c.set(v === 0 ? 1 : v / e.count, f / (i.length - 1)),
  36721. this._insertVertex(s, m, h, u, c),
  36722. m++,
  36723. !e.continuous[v] || v === 0)
  36724. ) {
  36725. if (v === 0) u.set(e.normals[v * 2 + 0], e.normals[v * 2 + 1], 0), c.set(0, f / (i.length - 1));
  36726. else {
  36727. let b = v === e.count - 1 ? e.start * 2 : y + 2;
  36728. l.set(t[b + 0], t[b + 1], 0), u.copy(l).sub(o), u.set(-u.y, u.x, 0), e.isHole || u.negate();
  36729. }
  36730. u.applyMatrix4(p).normalize(), this._insertVertex(s, m, h, u, c), m++;
  36731. }
  36732. }
  36733. });
  36734. let d = i.length - 1;
  36735. for (let p = 0; p < d; p++) {
  36736. let f = e.verticesStart * i.length + e.verticesCount * p,
  36737. g = e.verticesStart * i.length + e.verticesCount * (p + 1),
  36738. m = 0;
  36739. for (let v = 0; v < e.count; v++) {
  36740. (!e.continuous[v] || v === 0) && m++;
  36741. let y = v === e.count - 1 ? 0 : m + 1,
  36742. b = f + m,
  36743. x = f + y,
  36744. w = g + y,
  36745. A = g + m;
  36746. e.isHole ? n.push(b, w, x, b, A, w) : n.push(b, x, w, b, w, A), m++;
  36747. }
  36748. }
  36749. }
  36750. _closeEnd(e, t, i, r, s, n, a) {
  36751. let o = e.vertexCount,
  36752. l = new E(0, 0, a ? -1 : 1).applyMatrix4(s),
  36753. h = new E(),
  36754. u = new G();
  36755. for (let d = 0; d < o; d++) {
  36756. let p = 2 * d;
  36757. h
  36758. .set(e.vertices[p + 0], e.vertices[p + 1], 0)
  36759. .applyMatrix4(s)
  36760. .add(n),
  36761. this._insertVertex(r, t + d, h, l, u);
  36762. }
  36763. let c = e.elements;
  36764. for (let d = 0; d < e.elementCount; d++) {
  36765. let p = 3 * d,
  36766. f = c[p + 0] + t,
  36767. g = c[p + (a ? 1 : 2)] + t,
  36768. m = c[p + (a ? 2 : 1)] + t;
  36769. i.push(f, g, m);
  36770. }
  36771. }
  36772. };
  36773. function C6() {
  36774. let e = new Ve();
  36775. return e.setAttribute('position', new Xe(new Float32Array([]), 3)), e.setIndex(new Xe(new Uint16Array([]), 1)), e;
  36776. }
  36777. var T6 = 12,
  36778. P6 = 1,
  36779. LA = class extends Ve {
  36780. constructor(e, t) {
  36781. super(),
  36782. (this.charWidths = []),
  36783. (this.charCoords = []),
  36784. (this.wrappedText = []),
  36785. (this.isLowResolution = !1),
  36786. (this.vectorShapes = []),
  36787. (this.userData = { parameters: e, type: 'TextGeometry' });
  36788. let i = t.getFont(e.font);
  36789. i?.isLoaded
  36790. ? ((this.font = i), this.update(e))
  36791. : this.updateFont(e.font, t).then(() => {
  36792. this.update(e), t?.requestRender();
  36793. });
  36794. }
  36795. async updateFont(e, t) {
  36796. let i = t.getFont(e);
  36797. i && ((this.font = i), await i.loadingPromise);
  36798. }
  36799. update(e) {
  36800. let t = this.font;
  36801. if (((this.userData = { parameters: e, type: 'TextGeometry' }), !t?.isLoaded)) {
  36802. console.warn('Cannot update text because its font is not loaded');
  36803. return;
  36804. }
  36805. let { width: i, height: r, depth: s, extrudeBevelSize: n, extrudeBevelSegments: a, text: o, textTransform: l } = e,
  36806. h = l === 2 ? o.toUpperCase() : l === 3 ? o.toLowerCase() : o,
  36807. u = D6(e, t, h),
  36808. { shapes: c, charWidths: d, charCoords: p } = t.generateShapes(u, e),
  36809. f = i * 0.5,
  36810. g = r * 0.5,
  36811. m = c.map((b) => new Nt().fromShape(b));
  36812. this.vectorShapes = m;
  36813. let v = m.map((b) =>
  36814. Ta.create({
  36815. shape: b,
  36816. parameters: {
  36817. depth: s,
  36818. extrudeBevelSegments: a,
  36819. extrudeBevelSize: n,
  36820. windingRule: s <= 0 ? yt.NONZERO : yt.ODD,
  36821. subdivisions: this.isLowResolution && s > 0 ? P6 : T6
  36822. }
  36823. })
  36824. ),
  36825. y = v.length ? go(v) : C6();
  36826. y.translate(-f, g, 0),
  36827. this.dispose(),
  36828. (this.wrappedText = u),
  36829. (this.charCoords = p),
  36830. (this.charWidths = d),
  36831. this.deleteAttribute('extrudeNormal'),
  36832. Object.entries(y.attributes).forEach(([b, x]) => {
  36833. this.setAttribute(b, x);
  36834. }),
  36835. this.setIndex(y.index),
  36836. this.computeBoundingSphere();
  36837. }
  36838. clone() {
  36839. let e = Aa(new Ve(), LA.prototype);
  36840. return e.copy(this), console.log('CloneGeometry', this, e), e;
  36841. }
  36842. copy(e) {
  36843. return (
  36844. Object.entries(e.attributes).forEach(([t, i]) => {
  36845. this.setAttribute(t, i);
  36846. }),
  36847. this.setIndex(e.index),
  36848. (this.userData = { parameters: { ...e.userData.parameters }, type: 'TextGeometry' }),
  36849. this
  36850. );
  36851. }
  36852. async setText(e) {
  36853. this.font && (await this.font.loadingPromise), await this.update({ ...this.userData.parameters, text: e });
  36854. }
  36855. get text() {
  36856. return this.userData.parameters.text ?? '';
  36857. }
  36858. };
  36859. function D6(e, t, i) {
  36860. i = i ?? e.text;
  36861. let r = [''],
  36862. s = '';
  36863. for (let n of i)
  36864. (s += n),
  36865. n === ' ' ||
  36866. n ===
  36867. `
  36868. `
  36869. ? ((r[r.length - 1] += s),
  36870. (s = ''),
  36871. n ===
  36872. `
  36873. ` && r.push(''))
  36874. : t.getTextWidth(r[r.length - 1] + s, e) > e.width &&
  36875. (r[r.length - 1].length && r.push(''),
  36876. t.getTextWidth(r[r.length - 1] + s, e) > e.width &&
  36877. (s.length === 1
  36878. ? ((r[r.length - 1] += s), (s = ''))
  36879. : ((r[r.length - 1] += s.slice(0, -1)), (s = s[s.length - 1]), r.push(''))));
  36880. return (r[r.length - 1] += s), r;
  36881. }
  36882. var OA,
  36883. av = new Promise((e) => {
  36884. OA = e;
  36885. }),
  36886. Dx = !1;
  36887. async function L6() {
  36888. if (Dx) return;
  36889. let e = './assets/3d',
  36890. [t, i] = await Promise.all([import('./process.js'), fetch(`${e}/process.wasm`).then((n) => n.arrayBuffer())]),
  36891. r = t.default,
  36892. s = await r({ wasmBinary: i });
  36893. OA(s), (Dx = !0);
  36894. }
  36895. function Zd(e, t, i) {
  36896. let r = { parameters: e, type: e.type };
  36897. if (e.type === 'PathGeometry') r.path = e.path;
  36898. else if (e.type === 'VectorGeometry') {
  36899. let n = Nt.createFromState(e.shape, e.width, e.height);
  36900. r.shape = n;
  36901. } else if (e.type === 'NonParametricGeometry')
  36902. e.data.groups && e.data.groups.forEach((n) => (n.materialIndex = Math.max(n.materialIndex ?? 0, 0))), (r.geometry = new Fw().parse(e));
  36903. else {
  36904. if (e.type === 'SubdivGeometry') return new Oi(e, i);
  36905. if (e.type === 'TextGeometry') return new LA(e, t);
  36906. }
  36907. let s;
  36908. try {
  36909. s = zx(r);
  36910. } catch (n) {
  36911. console.error(n);
  36912. }
  36913. if (!s) {
  36914. let n = Nt.createFromState(Bd.defaultData(), 100, 100);
  36915. (r.shape = n), (s = zx(r));
  36916. }
  36917. return s;
  36918. }
  36919. var O6 = new ve();
  36920. function Um(e, t, i, r) {
  36921. let s = e.position.array,
  36922. n = e.normal.array,
  36923. a = O6.makeScale(t, i, r).invert().elements,
  36924. o,
  36925. l,
  36926. h;
  36927. for (var u = 0, c = s.length; u < c; u += 3)
  36928. (s[u] *= t),
  36929. (s[u + 1] *= i),
  36930. (s[u + 2] *= r),
  36931. (o = n[u]),
  36932. (l = n[u + 1]),
  36933. (h = n[u + 2]),
  36934. (n[u] = a[0] * o + a[4] * l + a[8] * h),
  36935. (n[u + 1] = a[1] * o + a[5] * l + a[9] * h),
  36936. (n[u + 2] = a[2] * o + a[6] * l + a[10] * h);
  36937. (e.position.needsUpdate = !0), (e.normal.needsUpdate = !0);
  36938. }
  36939. var Uc = new Kt(),
  36940. Ja = new E(),
  36941. Ue;
  36942. av.then((e) => {
  36943. Ue = e;
  36944. });
  36945. var Lx = new Float32Array([10, 10, 0, -10, 10, 0, -10, -10, 0, 10, -10, 0]),
  36946. Ox = new Uint32Array([0, 1, 2, 3]),
  36947. Ix = new Uint8Array([4]),
  36948. Oi = class extends Ve {
  36949. constructor(e, t) {
  36950. super(), (this.data = e), (this.flatShading = t), (this.subdivPointer = 0), this.rebuild(), this.freeSubdivPointer();
  36951. }
  36952. mutateDirectlyScaleBaked(e, t) {
  36953. this.freeSubdivPointer();
  36954. let i = this.data.scaleBaked,
  36955. r = ma.div(t, i);
  36956. this.subdividedGeometry && Um(this.subdividedGeometry.attributes, ...r),
  36957. this.originalGeometry && Um(this.originalGeometry.attributes, ...r),
  36958. (this.data = e);
  36959. let s = this.userData.parameters;
  36960. (this.userData.parameters = { width: s.width * r[0], height: s.height * r[1], depth: s.depth * r[2] }),
  36961. this.originalGeometry.boundingSphere.center.multiply(Ja.fromArray(r));
  36962. let n = Ja.set(s.width, s.height, s.depth).length();
  36963. this.originalGeometry.boundingSphere.radius = n / 2;
  36964. }
  36965. ensureSubdivPointer() {
  36966. return this.subdivPointer === 0 && this.rebuild(), this.subdivPointer;
  36967. }
  36968. rebuild() {
  36969. let e, t, i;
  36970. try {
  36971. ({ originalGeometry: e, subdividedGeometry: t, subdivPointer: i } = Oi.build(this.data, void 0, !this.flatShading, void 0));
  36972. } catch {
  36973. (e = new vs(100, 100, 100)), (i = 0);
  36974. }
  36975. (this.subdivPointer = i), (this.originalGeometry = e), (this.subdividedGeometry = t ?? void 0);
  36976. let r = this.subdividedGeometry ?? this.originalGeometry;
  36977. Object.assign(this, r), this.calcBoundingBox();
  36978. }
  36979. freeSubdivPointer() {
  36980. this.subdivPointer && (Oi.freeSubdivPointer(this.subdivPointer), (this.subdivPointer = 0));
  36981. }
  36982. dispose() {
  36983. super.dispose(), this.freeSubdivPointer();
  36984. }
  36985. calcBoundingBox() {
  36986. let e = this.originalGeometry;
  36987. e.boundingSphere === null &&
  36988. ((e.boundingSphere = new Mr()), this.subdividedGeometry && (this.subdividedGeometry.boundingSphere = e.boundingSphere));
  36989. let t = e.attributes.position,
  36990. i = e.boundingSphere.center;
  36991. Uc.setFromBufferAttribute(t),
  36992. Uc.getCenter(i),
  36993. (e.boundingSphere.radius = i.distanceTo(Uc.max)),
  36994. isNaN(e.boundingSphere.radius) &&
  36995. console.error(
  36996. 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',
  36997. this
  36998. ),
  36999. Uc.getSize(Ja);
  37000. let r = { width: Ja.x, height: Ja.y, depth: Ja.z };
  37001. return (this.userData.parameters = r), r;
  37002. }
  37003. static build(e, t, i, r) {
  37004. let s,
  37005. n,
  37006. a,
  37007. o = e?.phongAngle ?? 35;
  37008. i === !1 && (o = -1), t && (Ue.free_bvh(t), Ue.free_subdivision_surface(t));
  37009. try {
  37010. s = Oi.allocate(e, r);
  37011. } catch (l) {
  37012. console.error(l, e), (s = Oi.allocate({ positionWASM: Lx, indexWASM: Ox, verticesPerFaceWASM: Ix }, r));
  37013. }
  37014. if ((Ue.set_destination_refinement_level(s, 0), (n = Oi.buildLevel(s, !0, o)), e.subdivisions > 0))
  37015. try {
  37016. Ue.set_destination_refinement_level(s, e.subdivisions), (a = Oi.buildLevel(s, !1, o));
  37017. } catch {
  37018. try {
  37019. Ue.set_destination_refinement_level(s, e.subdivisions - 1), (a = Oi.buildLevel(s, !1, o));
  37020. } catch {
  37021. a = null;
  37022. }
  37023. }
  37024. else a = null;
  37025. return { subdivPointer: s, originalGeometry: n, subdividedGeometry: a };
  37026. }
  37027. static primitiveToQuads(e, t, i) {
  37028. e.widthSegments > 16 && (e.widthSegments = 16),
  37029. e.heightSegments > 16 && (e.heightSegments = 16),
  37030. e.depthSegments > 16 && (e.depthSegments = 16),
  37031. e.radialSegments > 16 && (e.radialSegments = 16),
  37032. e.type === 'DodecahedronGeometry' && (e.detail = 0);
  37033. let r;
  37034. if (e.type === 'TorusGeometry' && e.arc === Math.PI * 2) {
  37035. let { width: h, height: u, depth: c, arc: d, tubularSegments: p, radialSegments: f } = e;
  37036. r = new nv(!0, h, c, u, h * 0.5, d / (2 * Math.PI), p, c / 2, 0, f, 0, 0, !0);
  37037. } else r = e.shape !== void 0 ? t.geometry : Zd(e, i, !1);
  37038. let s, n, a, o;
  37039. ({ positions: s, triIndices: o } = ov(r.getAttribute('position'), r.getIndex()));
  37040. let l;
  37041. if (e.type === 'CylinderGeometry' && e.cornerRadius === 0 && e.hollow === 0 && e.openEnded === !1) {
  37042. let h = e.radialSegments * e.heightSegments * 3 * 2,
  37043. u = h + e.radialSegments * 3;
  37044. l = [h, u];
  37045. }
  37046. return ({ indices: n, verticesPerFace: a } = IA(s, o, r, l)), { positions: s, indices: n, verticesPerFace: a };
  37047. }
  37048. static allocate(e, t) {
  37049. let i,
  37050. r,
  37051. s,
  37052. n = [],
  37053. a = [];
  37054. e.positionWASM && e.positionWASM.length > 0
  37055. ? ((i = e.positionWASM), (r = e.indexWASM), (s = e.verticesPerFaceWASM))
  37056. : ((i = Lx), (r = Ox), (s = Ix));
  37057. let o = i.length,
  37058. l = r.length,
  37059. h = s.length,
  37060. u = i.length + n.length + a.length,
  37061. c = r.length + s.length,
  37062. d = u * Float32Array.BYTES_PER_ELEMENT + c * Uint32Array.BYTES_PER_ELEMENT,
  37063. p = u * Float32Array.BYTES_PER_ELEMENT,
  37064. f = c * Uint32Array.BYTES_PER_ELEMENT,
  37065. g = Ue._malloc(d),
  37066. m = new Float32Array(Ue.HEAPF32.buffer, g, u),
  37067. v = new Uint32Array(Ue.HEAPU32.buffer, g + p, c);
  37068. m.set(i, 0), m.set(n, i.length), m.set(a, i.length + n.length), v.set(r, 0), v.set(s, r.length);
  37069. let y;
  37070. e?.scaleBaked?.some((x) => x !== 1) && (y = new ve().makeScale(...e.scaleBaked)), t && (y ? y.premultiply(t) : (y = t));
  37071. let b = y
  37072. ? Ue.alloc_subdivision_surface2(g, o, g + p, l, g + p + r.length * Uint32Array.BYTES_PER_ELEMENT, h, y.elements)
  37073. : Ue.alloc_subdivision_surface(g, o, g + p, l, g + p + r.length * Uint32Array.BYTES_PER_ELEMENT, h);
  37074. return Ue._free(g), b;
  37075. }
  37076. static buildLevel(e, t, i, r, s) {
  37077. let n = s
  37078. ? Ue.get_mesh_data2(e, t ? Ue.Level.CONTROL : Ue.Level.REFINED, i, s.elements)
  37079. : Ue.get_mesh_data(e, t ? Ue.Level.CONTROL : Ue.Level.REFINED, i),
  37080. a = 8,
  37081. o = Ue.HEAPU32.subarray(n >> 2, (n >> 2) + a),
  37082. l = o.subarray(4, 4 + 4),
  37083. h = 0,
  37084. u = Ue.HEAPU32[o[h] >> 2],
  37085. c = Ue.HEAPF32.subarray(u >> 2, (u >> 2) + l[h]);
  37086. h++;
  37087. let d = Ue.HEAPU32[o[h] >> 2],
  37088. p = Ue.HEAPF32.subarray(d >> 2, (d >> 2) + l[h]);
  37089. h++;
  37090. let f = Ue.HEAPU32[o[h] >> 2],
  37091. g = Ue.HEAPU32.subarray(f >> 2, (f >> 2) + l[h]);
  37092. h++;
  37093. let m = Ue.HEAPU32[o[h] >> 2],
  37094. v = Ue.HEAPU32.subarray(m >> 2, (m >> 2) + l[h]);
  37095. if ((h++, r === void 0)) {
  37096. let y = new Ve();
  37097. if ((y.setIndex(new Kl(v, 1)), y.setAttribute('position', new Ce(c, 3)), y.setAttribute('normal', new Ce(p, 3)), t)) {
  37098. y.setAttribute('faceMap', new Kl(g, 1));
  37099. let b = new Float32Array((p.length / 3) * 4).fill(0);
  37100. y.setAttribute('color', new Xe(b, 4));
  37101. }
  37102. return Ue.free_mesh_data(n), (y.userData.type = 'SubdivGeometry'), y;
  37103. }
  37104. r.getAttribute('position').copyArray(c),
  37105. r.getAttribute('normal').copyArray(p),
  37106. (r.attributes.position.needsUpdate = !0),
  37107. (r.attributes.normal.needsUpdate = !0),
  37108. Ue.free_mesh_data(n);
  37109. }
  37110. static freeSubdivPointer(e) {
  37111. Ue.free_bvh(e), Ue.free_subdivision_surface(e);
  37112. }
  37113. static buildControlCageWireframe(e, t, i) {
  37114. let r = Ue.get_wireframe_data_for_base_level(e),
  37115. s = 4,
  37116. n = Ue.HEAPU32.subarray(r >> 2, (r >> 2) + s),
  37117. a = n.subarray(2, 2 + 2),
  37118. o = 0,
  37119. l = Ue.HEAPU32[n[o] >> 2],
  37120. h = Ue.HEAPF32.subarray(l >> 2, (l >> 2) + a[o]);
  37121. o++;
  37122. let u = Ue.HEAPU32[n[o] >> 2],
  37123. c = Ue.HEAPU32.subarray(u >> 2, (u >> 2) + a[o]);
  37124. if (t === void 0) {
  37125. let d = new Ve();
  37126. d.setAttribute('position', new Ce(h, 3));
  37127. let p = new Float32Array(h.length);
  37128. for (let f = 0, g = h.length; f < g; ) (p[f++] = i.r), (p[f++] = i.g), (p[f++] = i.b);
  37129. return d.setAttribute('color', new Xe(p, 3)), d.setIndex(new Kl(c, 1)), Ue.free_wireframe_data_for_base_level(r), d;
  37130. }
  37131. t.getAttribute('position').copyArray(h), (t.attributes.position.needsUpdate = !0), Ue.free_wireframe_data_for_base_level(r);
  37132. }
  37133. static updateCollabMesh(e, t, i) {
  37134. let r = t === 0;
  37135. r || Ue.set_destination_refinement_level(e, t);
  37136. let s = i
  37137. ? Ue.get_topological_data2(e, r ? Ue.Level.CONTROL : Ue.Level.REFINED, i.elements)
  37138. : Ue.get_topological_data(e, r ? Ue.Level.CONTROL : Ue.Level.REFINED),
  37139. n = 6,
  37140. a = Ue.HEAPU32.subarray(s >> 2, (s >> 2) + n),
  37141. o = a.subarray(3, 3 + 3),
  37142. l = 0,
  37143. h = Ue.HEAPU32[a[l] >> 2],
  37144. u = new Float32Array(Ue.HEAPF32.subarray(h >> 2, (h >> 2) + o[l]));
  37145. l++;
  37146. let c = Ue.HEAPU32[a[l] >> 2],
  37147. d = new Uint32Array(Ue.HEAPU32.subarray(c >> 2, (c >> 2) + o[l]));
  37148. l++;
  37149. let p = Ue.HEAPU32[a[l] >> 2],
  37150. f = new Uint8Array(Ue.HEAPU32.subarray(p >> 2, (p >> 2) + o[l]));
  37151. return Ue.free_topological_data(s), { positions: u, indices: d, verticesPerFace: f };
  37152. }
  37153. },
  37154. Rx = ['getX', 'getY', 'getZ'];
  37155. function ov(e, t) {
  37156. let i = {},
  37157. r = t ? t.count : e.count,
  37158. s = 0,
  37159. n = [],
  37160. a = [],
  37161. o = 1e4;
  37162. for (let h = 0; h < r; h++) {
  37163. let u = t ? t.getX(h) : h,
  37164. c = '';
  37165. for (let d = 0; d < 3; d++) c += `${~~(e[Rx[d]](u) * o)},`;
  37166. if (c in i) n.push(i[c]);
  37167. else {
  37168. for (let d = 0; d < 3; d++) a.push(e[Rx[d]](u));
  37169. (i[c] = s), n.push(s), s++;
  37170. }
  37171. }
  37172. let l = [];
  37173. for (let h = 0; h < n.length; h += 3) n[h] === n[h + 1] || n[h] === n[h + 2] || n[h + 1] === n[h + 2] || l.push(n[h], n[h + 1], n[h + 2]);
  37174. return { positions: a, triIndices: l };
  37175. }
  37176. var Fc = new E(),
  37177. tf = new E(),
  37178. rf = new E(),
  37179. sf = new E();
  37180. function IA(e, t, i, r) {
  37181. let s = [],
  37182. n = [];
  37183. if (i.userData.shape !== void 0 && i.userData.parameters.depth === 0 && i.userData.shape.shapeHoles.length === 0) {
  37184. let a = i.userData.shape.extractShapePointsToFlatArray([]),
  37185. o = i.userData.parameters.spikes;
  37186. if (i.userData.type === 'EllipseGeometry' && o <= 24 && o % 4 === 0 && i.userData.parameters.angle >= 360) {
  37187. let u = a.length / 2 / o;
  37188. a = a.filter((c, d) => Math.floor(d / 2) % u === 0);
  37189. }
  37190. let l = 0;
  37191. for (let u = 0; u < a.length; u += 2) l += (a[u] - a[(u === 0 ? a.length : u) - 2]) * (a[u + 1] + a[(u === 0 ? a.length : u) - 1]);
  37192. e.length = 0;
  37193. let h = 0;
  37194. if (l < 0) for (let u = 0; u < a.length; u += 2) e.push(a[u], a[u + 1], 0), s.push(h++);
  37195. else for (let u = a.length - 2; u >= 0; u -= 2) e.push(a[u], a[u + 1], 0), s.push(h++);
  37196. return n.push(h), { indices: s, verticesPerFace: n };
  37197. }
  37198. for (let a = 0, o = i.capStartIndex ?? t.length; a < o; )
  37199. if ((t[a + 1] === t[a + 3] && t[a + 2] === t[a + 5]) || (t[a + 0] === t[a + 3] && t[a + 2] === t[a + 4])) {
  37200. Fc.set(e[t[a] * 3], e[t[a] * 3 + 1], e[t[a] * 3 + 2]),
  37201. tf.set(e[t[a + 1] * 3], e[t[a + 1] * 3 + 1], e[t[a + 1] * 3 + 2]),
  37202. rf.set(e[t[a + 4] * 3], e[t[a + 4] * 3 + 1], e[t[a + 4] * 3 + 2]),
  37203. sf.set(e[t[a + 5] * 3], e[t[a + 5] * 3 + 1], e[t[a + 5] * 3 + 2]),
  37204. tf.sub(Fc).normalize(),
  37205. rf.sub(Fc).normalize(),
  37206. sf.sub(Fc).normalize();
  37207. let l = tf.cross(rf).dot(sf);
  37208. Math.abs(l) > 0.005 || (r && r.some((h, u) => (u % 2 === 1 ? !1 : a >= r[u] && a < r[u + 1])))
  37209. ? (s.push(t[a], t[a + 1], t[a + 2]), n.push(3), (a += 3))
  37210. : (s.push(t[a], t[a + 1], t[a + 4], t[a + 5]), n.push(4), (a += 6));
  37211. } else s.push(t[a], t[a + 1], t[a + 2]), n.push(3), (a += 3);
  37212. if (i.capStartIndex !== void 0) {
  37213. let a = [],
  37214. o = [],
  37215. l = 0,
  37216. h = new Float32Array([i.userData.parameters.depth])[0];
  37217. for (let u = 0, c = 0; u < e.length; u += 3, c++) e[u + 2] === 0 && (a.push(c), l++), e[u + 2] === h && o.push(c);
  37218. if (i.userData.parameters.extrudeBevelSize === 0) {
  37219. let u = o[0];
  37220. (o[0] = o[1]), (o[1] = u);
  37221. }
  37222. a.reverse(), s.push(...a, ...o), n.push(l, l);
  37223. }
  37224. return { indices: s, verticesPerFace: n };
  37225. }
  37226. var dn = {};
  37227. V2(dn, {
  37228. calcBoolean: () => N6,
  37229. calcBooleanTopological: () => z6,
  37230. freeMeshSet: () => k6,
  37231. getMeshSet: () => U6,
  37232. transformMeshSet: () => F6
  37233. });
  37234. var RA,
  37235. I6 = new Promise((e) => {
  37236. RA = e;
  37237. }),
  37238. Bx = !1;
  37239. async function R6() {
  37240. if (Bx) return;
  37241. let e = './assets/3d',
  37242. [t, i] = await Promise.all([import('./boolean.js'), fetch(`${e}/boolean.wasm`).then((n) => n.arrayBuffer())]),
  37243. r = t.default,
  37244. s = await r({ wasmBinary: i });
  37245. RA(s), (Bx = !0);
  37246. }
  37247. var tt, Lo;
  37248. I6.then((e) => (tt = e));
  37249. function B6(e, t, i) {
  37250. let r,
  37251. { positions: s, triIndices: n } = ov(e.getAttribute('position'), e.getIndex()),
  37252. a;
  37253. if (t && i) {
  37254. let { indices: o, verticesPerFace: l } = IA(s, n, e);
  37255. (a = l.length), (r = []);
  37256. for (let h = 0, u = 0; h < a; h++) {
  37257. r.push(l[h]);
  37258. for (let c = 0; c < l[h]; c++) r.push(o[u++]);
  37259. }
  37260. } else {
  37261. let o = n.length;
  37262. (r = Array(o + o / 3)), (a = 0);
  37263. for (let l = 0, h = 0; h < r.length; ) (r[h++] = 3), a++, (r[h++] = n[l++]), (r[h++] = n[l++]), (r[h++] = n[l++]);
  37264. }
  37265. return { positions: s, faceIndices: r, nFaces: a };
  37266. }
  37267. function BA(e) {
  37268. let t = e.length,
  37269. i = t * Uint32Array.BYTES_PER_ELEMENT,
  37270. r = t * Float32Array.BYTES_PER_ELEMENT,
  37271. s = Number.isInteger(e[0]) ? i : r,
  37272. n = tt._malloc(s);
  37273. return (Number.isInteger(e[0]) ? new Uint32Array(tt.HEAPU32.buffer, n, t) : new Float32Array(tt.HEAPF32.buffer, n, t)).set(e, 0), n;
  37274. }
  37275. function zA(e) {
  37276. switch (e) {
  37277. case 0:
  37278. return tt.OP.UNION;
  37279. case 1:
  37280. return tt.OP.INTERSECTION;
  37281. case 2:
  37282. return tt.OP.A_MINUS_B;
  37283. case 3:
  37284. return tt.OP.B_MINUS_A;
  37285. case 4:
  37286. return tt.OP.SYMMETRIC_DIFFERENCE;
  37287. case 5:
  37288. return tt.OP.ALL;
  37289. default:
  37290. throw new Error('Unknown boolean operation ' + e);
  37291. }
  37292. }
  37293. function z6(e, t) {
  37294. Lo === void 0 && (Lo = tt.init_csg());
  37295. let i = BA(e),
  37296. r = tt.csg_calc_topological(Lo, i, e.length, zA(t));
  37297. tt._free(i);
  37298. let s = 6,
  37299. n = tt.HEAPU32.subarray(r >> 2, (r >> 2) + s),
  37300. a = n.subarray(3, 3 + 3),
  37301. o = 0,
  37302. l = tt.HEAPU32[n[o] >> 2],
  37303. h = new Float32Array(tt.HEAPF32.subarray(l >> 2, (l >> 2) + a[o]));
  37304. o++;
  37305. let u = tt.HEAPU32[n[o] >> 2],
  37306. c = new Uint32Array(tt.HEAPU32.subarray(u >> 2, (u >> 2) + a[o]));
  37307. o++;
  37308. let d = tt.HEAPU32[n[o] >> 2],
  37309. p = new Uint8Array(tt.HEAPU32.subarray(d >> 2, (d >> 2) + a[o]));
  37310. return tt.free_mesh_data(r), { positions: h, indices: c, verticesPerFace: p };
  37311. }
  37312. function N6(e, t, i, r) {
  37313. Lo === void 0 && (Lo = tt.init_csg());
  37314. let s = BA(e),
  37315. n = tt.csg_calc(Lo, s, e.length, r, zA(t));
  37316. tt._free(s);
  37317. let a = 5,
  37318. o = tt.HEAPU32.subarray(n >> 2, (n >> 2) + a),
  37319. l = o.subarray(2, 2 + 3),
  37320. h = 0,
  37321. u = tt.HEAPU32[o[h] >> 2],
  37322. c = tt.HEAPF32.subarray(u >> 2, (u >> 2) + l[h]);
  37323. h++;
  37324. let d = tt.HEAPU32[o[h] >> 2],
  37325. p = tt.HEAPF32.subarray(d >> 2, (d >> 2) + l[h]);
  37326. h++;
  37327. let f = l[h];
  37328. i.setAttribute('position', new Ce(c, 3)), i.setAttribute('normal', new Ce(p, 3));
  37329. let g = tt.HEAPF32.subarray((n >> 2) + 5, (n >> 2) + 5 + 6);
  37330. return (
  37331. i.boundingSphere === null && (i.boundingSphere = new Mr()),
  37332. i.boundingSphere.center.set(g[0], g[1], g[2]),
  37333. (i.boundingSphere.radius = (g[3] ** 2 + g[4] ** 2 + g[5] ** 2) ** 0.5),
  37334. (i.userData.parameters = { width: g[3] * 2, height: g[4] * 2, depth: g[5] * 2 }),
  37335. tt.free_mesh_data(n),
  37336. f
  37337. );
  37338. }
  37339. function U6(e, t, i) {
  37340. if (tt === void 0) return -1;
  37341. let r, s, n;
  37342. if (t && e.userData.positions !== void 0) {
  37343. let m = e.userData;
  37344. (n = m.verticesPerFace.length), (r = m.positions), (s = Array(m.verticesPerFace.reduce((v, y) => v + y, 0) + n));
  37345. for (let v = 0, y = 0, b = 0; v < m.verticesPerFace.length; v++) {
  37346. s[b++] = m.verticesPerFace[v];
  37347. for (let x = 0; x < m.verticesPerFace[v]; x++) s[b++] = m.indices[y++];
  37348. }
  37349. } else ({ positions: r, faceIndices: s, nFaces: n } = B6(e, t, i));
  37350. let a = r.length,
  37351. o = s.length,
  37352. l = r.length,
  37353. h = s.length,
  37354. u = l * Float32Array.BYTES_PER_ELEMENT + h * Uint32Array.BYTES_PER_ELEMENT,
  37355. c = l * Float32Array.BYTES_PER_ELEMENT,
  37356. d = h * Uint32Array.BYTES_PER_ELEMENT,
  37357. p = tt._malloc(u),
  37358. f = new Float32Array(tt.HEAPF32.buffer, p, l),
  37359. g = new Uint32Array(tt.HEAPU32.buffer, p + c, h);
  37360. return f.set(r, 0), g.set(s, 0), tt.get_csg_mesh(p, a, p + c, o, n);
  37361. }
  37362. function F6(e, t) {
  37363. tt.transform_csg_mesh(e, t.elements);
  37364. }
  37365. function k6(e) {
  37366. tt.free_csg_mesh(e);
  37367. }
  37368. var j6 = {
  37369. ConeGeometry: wF,
  37370. CubeGeometry: _F,
  37371. CylinderGeometry: bF,
  37372. DodecahedronGeometry: SF,
  37373. EllipseGeometry: sv,
  37374. HelixGeometry: t6,
  37375. IcosahedronGeometry: i6,
  37376. LatheGeometry: r6,
  37377. NonParametricGeometry: c6,
  37378. PolygonGeometry: TA,
  37379. PyramidGeometry: d6,
  37380. RectangleGeometry: PA,
  37381. SphereGeometry: f6,
  37382. PlaneGeometry: m6,
  37383. BackdropGeometry: g6,
  37384. StarGeometry: DA,
  37385. TextFrameGeometry: y6,
  37386. TorusGeometry: x6,
  37387. TorusKnotGeometry: w6,
  37388. TriangleGeometry: _6,
  37389. PathGeometry: M6,
  37390. VectorGeometry: Ta
  37391. },
  37392. zx = (e) => j6[e.type].create(e);
  37393. function Ll(e) {
  37394. return e !== null && 'booleanOp' in e;
  37395. }
  37396. var NA = class extends dA(tr) {
  37397. constructor() {
  37398. super(...arguments), (this.booleanMeshSetAddress = -1), (this.booleanWasTransformed = !1), (this.booleanMatrixInvOld = new ve());
  37399. }
  37400. updateVisible() {
  37401. super.updateVisible(),
  37402. (this.visible = !Ll(this.parent) && this.visible),
  37403. Ll(this.parent) && this.parent.invalidateDownstreamBooleanData();
  37404. }
  37405. freeBooleanPointer() {
  37406. this.booleanMeshSetAddress !== -1 && (dn.freeMeshSet(this.booleanMeshSetAddress), (this.booleanMeshSetAddress = -1));
  37407. }
  37408. invalidateDownstreamBooleanData(e = !1) {
  37409. return (
  37410. e ? (this.booleanWasTransformed = !0) : this.freeBooleanPointer(),
  37411. Ll(this.parent) ? this.parent.invalidateDownstreamBooleanData() : this
  37412. );
  37413. }
  37414. invalidateUpstreamBooleanData() {
  37415. this.freeBooleanPointer();
  37416. for (let e of this.children) e instanceof NA && (e.freeBooleanPointer(), Ll(e) && e.invalidateUpstreamBooleanData());
  37417. }
  37418. updateTransformState(e) {
  37419. let t = super.updateTransformState(e);
  37420. return t && Ll(this.parent) && this.invalidateDownstreamBooleanData(!0), t;
  37421. }
  37422. },
  37423. kc = new Kt();
  37424. function lv(e, t = 0, i = e.count, r, s) {
  37425. let n = 1 / 0,
  37426. a = 1 / 0,
  37427. o = 1 / 0,
  37428. l = -1 / 0,
  37429. h = -1 / 0,
  37430. u = -1 / 0;
  37431. for (let c = t; c < i; c++) {
  37432. let d = e.getX(c),
  37433. p = e.getY(c),
  37434. f = e.getZ(c);
  37435. d < n && (n = d), p < a && (a = p), f < o && (o = f), d > l && (l = d), p > h && (h = p), f > u && (u = f);
  37436. }
  37437. kc.min.set(n, a, o), kc.max.set(l, h, u), kc.getCenter(r), kc.getSize(s).multiplyScalar(0.5);
  37438. }
  37439. var G6 = new Ve(),
  37440. V6 = new Ph(),
  37441. ar = class extends NA {
  37442. constructor(e, t) {
  37443. super(G6, V6), this.super_Entity(e, t);
  37444. }
  37445. updateState(e, t) {
  37446. this.updateState_Entity(e, t);
  37447. }
  37448. updateEntityBoxSize(e, t) {
  37449. let i = this.geometry.getAttribute('position');
  37450. i !== void 0
  37451. ? lv(i, this.geometry.drawRange.start, this.geometry.drawRange.count < 1 / 0 ? this.geometry.drawRange.count : i.count, e, t)
  37452. : super.updateEntityBoxSize(e, t);
  37453. }
  37454. },
  37455. Nx = class {
  37456. constructor(e) {
  37457. (e = e ?? {}),
  37458. (this.name = e.name),
  37459. (this.type = e.type),
  37460. (this.node = e.node),
  37461. (this.size = e.size),
  37462. (this.needsUpdate = e.needsUpdate);
  37463. }
  37464. get value() {
  37465. return this.node.value;
  37466. }
  37467. set value(e) {
  37468. this.node.value = e;
  37469. }
  37470. },
  37471. Bn = class {
  37472. constructor(e) {
  37473. (this.hashProperties = void 0),
  37474. (this.isNode = !0),
  37475. (this.shortcuts = {}),
  37476. (this.uuid = it.generateUUID()),
  37477. (this.type = e),
  37478. (this.name = '');
  37479. }
  37480. analyze(e, t) {
  37481. (t = t ?? {}),
  37482. (e.analyzing = !0),
  37483. this.build(e.addFlow(t.slot, t.cache, t.context), 'v4'),
  37484. e.clearVertexNodeCode(),
  37485. e.clearFragmentNodeCode(),
  37486. e.removeFlow(),
  37487. (e.analyzing = !1);
  37488. }
  37489. analyzeAndFlow(e, t, i) {
  37490. return (i = i ?? {}), this.analyze(e, i), this.flow(e, t, i);
  37491. }
  37492. flow(e, t, i) {
  37493. (i = i ?? {}), e.addFlow(i.slot, i.cache, i.context);
  37494. let r = { result: this.build(e, t), code: e.clearNodeCode(), extra: e.context.extra };
  37495. return e.removeFlow(), r;
  37496. }
  37497. build(e, t, i) {
  37498. t = t ?? this.getType(e, t);
  37499. let r = e.getNodeData(i ?? this);
  37500. return (
  37501. e.analyzing && this.appendDepsNode(e, r, t),
  37502. e.nodes.indexOf(this) === -1 && e.nodes.push(this),
  37503. this.updateFrame !== void 0 && e.updaters.indexOf(this) === -1 && e.updaters.push(this),
  37504. this.generate(e, t, i)
  37505. );
  37506. }
  37507. updateFrame(e) {}
  37508. generateReadonly(e, t, i, r, s, n) {
  37509. return '';
  37510. }
  37511. generate(e, t, i, r, s) {
  37512. return '';
  37513. }
  37514. parse(e, t, i, r) {}
  37515. appendDepsNode(e, t, i) {
  37516. t.deps = (t.deps || 0) + 1;
  37517. let r = e.getTypeLength(i);
  37518. (r > (t.outputMax || 0) || this.getType(e, i)) && ((t.outputMax = r), (t.output = i));
  37519. }
  37520. setName(e) {
  37521. this.name = e;
  37522. }
  37523. getName() {
  37524. return this.name;
  37525. }
  37526. getType(e, t) {
  37527. return t === 'sampler2D' || t === 'samplerCube' ? t : this.type;
  37528. }
  37529. getHash() {
  37530. let e = '{',
  37531. t,
  37532. i;
  37533. for (t in this) (i = this[t]), i instanceof Bn && (e += '"' + t + '":' + i.getHash() + ',');
  37534. if (this.hashProperties)
  37535. for (let r = 0; r < this.hashProperties.length; r++)
  37536. (t = this.hashProperties[r]), (i = this[t]), (e += '"' + t + '":"' + String(i) + '",');
  37537. return (e += '"id":"' + this.uuid + '"}'), e;
  37538. }
  37539. },
  37540. H6 = class {
  37541. constructor() {
  37542. (this.nodes = {}), (this.keywords = {});
  37543. }
  37544. add(e) {
  37545. this.nodes[e.name] = e;
  37546. }
  37547. addKeyword(e, t, i) {
  37548. (i = i !== void 0 ? i : !0), (this.keywords[e] = { callback: t, cache: i });
  37549. }
  37550. remove(e) {
  37551. delete this.nodes[e.name];
  37552. }
  37553. removeKeyword(e) {
  37554. delete this.keywords[e];
  37555. }
  37556. get(e) {
  37557. return this.nodes[e];
  37558. }
  37559. getKeyword(e, t) {
  37560. return this.keywords[e].callback(t);
  37561. }
  37562. getKeywordData(e) {
  37563. return this.keywords[e];
  37564. }
  37565. contains(e) {
  37566. return this.nodes[e] !== void 0;
  37567. }
  37568. containsKeyword(e) {
  37569. return this.keywords[e] !== void 0;
  37570. }
  37571. },
  37572. Ni = new H6(),
  37573. St = class extends Bn {
  37574. constructor(e, t) {
  37575. super(e),
  37576. (this.scope = ''),
  37577. (t = t ?? {}),
  37578. (this.shared = t.shared !== void 0 ? t.shared : !0),
  37579. (this.unique = t.unique !== void 0 ? t.unique : !1);
  37580. }
  37581. build(e, t, i, r) {
  37582. if (((t = t ?? this.getType(e)), this.getShared(e, t))) {
  37583. let s = this.getUnique(e, t);
  37584. s && this.uuid === void 0 && (this.uuid = it.generateUUID()), (i = e.getUUID(i ?? this.getUUID(), !s));
  37585. let n = e.getNodeData(i),
  37586. a = n.output || this.getType(e);
  37587. if (e.analyzing)
  37588. return (n.deps || 0) > 0 || this.getLabel() ? (this.appendDepsNode(e, n, t), this.generate(e, t, i)) : super.build(e, t, i);
  37589. if (s) return (n.name = n.name || super.build(e, t, i)), n.name;
  37590. if (!this.getLabel() && (!this.getShared(e, a) || e.context.ignoreCache || n.deps === 1)) return super.build(e, t, i);
  37591. i = this.getUUID(!1);
  37592. let o = this.getTemp(e, i);
  37593. if (o) return e.format(o, a, t);
  37594. {
  37595. o = super.generate(e, t, i, n.output, r);
  37596. let l = this.generate(e, a, i);
  37597. return e.addNodeCode(o + ' = ' + l + ';'), e.format(o, a, t);
  37598. }
  37599. }
  37600. return super.build(e, t, i);
  37601. }
  37602. getShared(e, t) {
  37603. return t !== 'sampler2D' && t !== 'samplerCube' && this.shared;
  37604. }
  37605. getUnique(e, t) {
  37606. return this.unique;
  37607. }
  37608. setLabel(e) {
  37609. return (this.label = e), this;
  37610. }
  37611. getLabel() {
  37612. return this.label;
  37613. }
  37614. getUUID(e) {
  37615. let t = this.uuid;
  37616. return typeof this.scope == 'string' && (t = this.scope + '-' + t), t;
  37617. }
  37618. getTemp(e, t) {
  37619. t = t || this.uuid;
  37620. let i = e.getVars()[t];
  37621. return i ? i.name : void 0;
  37622. }
  37623. generate(e, t, i, r, s) {
  37624. return (
  37625. this.getShared(e, t) || console.error('TempNode is not shared'),
  37626. (i = i ?? this.uuid),
  37627. e.getTempVar(i, r ?? this.getType(e), s, this.getLabel()).name
  37628. );
  37629. }
  37630. },
  37631. or = class extends St {
  37632. constructor(e, t) {
  37633. (t = t ?? {}), (t.shared = t.shared !== void 0 ? t.shared : !1), super(e, t), (this.readonly = !1);
  37634. }
  37635. setReadonly(e) {
  37636. return (this.readonly = e), (this.hashProperties = this.readonly ? ['value'] : void 0), this;
  37637. }
  37638. getReadonly() {
  37639. return this.readonly;
  37640. }
  37641. generate(e, t, i, r, s, n) {
  37642. (i = e.getUUID(i ?? this.getUUID())), (r = r ?? this.getType(e));
  37643. let a = e.getNodeData(i);
  37644. return this.getReadonly() && this.generateReadonly !== void 0
  37645. ? this.generateReadonly(e, t, i, r, s, n)
  37646. : e.isShader('vertex')
  37647. ? (a.vertex || (a.vertex = e.createVertexUniform(r, this, s, n, this.getLabel())), e.format(a.vertex.name, r, t))
  37648. : (a.fragment || (a.fragment = e.createFragmentUniform(r, this, s, n, this.getLabel())), e.format(a.fragment.name, r, t));
  37649. }
  37650. },
  37651. vr = class extends or {
  37652. constructor(e = 0, t) {
  37653. super('v2'), (this.nodeType = 'Vector2'), (this.value = e instanceof G ? e : new G(e, t));
  37654. }
  37655. get x() {
  37656. return this.value.x;
  37657. }
  37658. set x(e) {
  37659. this.value.x = e;
  37660. }
  37661. get y() {
  37662. return this.value.y;
  37663. }
  37664. set y(e) {
  37665. this.value.y = e;
  37666. }
  37667. generateReadonly(e, t, i, r, s, n) {
  37668. return e.format('vec2(' + this.value.x + ', ' + this.value.y + ')', r, t);
  37669. }
  37670. },
  37671. fr = class extends or {
  37672. constructor(e = 0, t, i) {
  37673. super('v3'), (this.nodeType = 'Vector3'), (this.value = e instanceof E ? e : new E(e, t, i));
  37674. }
  37675. get x() {
  37676. return this.value.x;
  37677. }
  37678. set x(e) {
  37679. this.value.x = e;
  37680. }
  37681. get y() {
  37682. return this.value.y;
  37683. }
  37684. set y(e) {
  37685. this.value.y = e;
  37686. }
  37687. get z() {
  37688. return this.value.z;
  37689. }
  37690. set z(e) {
  37691. this.value.z = e;
  37692. }
  37693. generateReadonly(e, t, i, r, s, n) {
  37694. return e.format('vec3(' + this.value.x + ', ' + this.value.y + ', ' + this.value.z + ')', r, t);
  37695. }
  37696. },
  37697. ji = class extends Ge {
  37698. constructor(e, t, i, r) {
  37699. super(e, t, i), (this.isColorA = !0), (this.a = r);
  37700. }
  37701. setRGBA(e, t, i, r) {
  37702. super.setRGB(e, t, i), (this.a = r);
  37703. }
  37704. copy(e) {
  37705. return super.copy(e), (this.a = 'a' in e ? e.a : 1), this;
  37706. }
  37707. clone() {
  37708. return new this.constructor(this.r, this.g, this.b, this.a);
  37709. }
  37710. setStyle(e, t = 'srgb') {
  37711. let i;
  37712. if (e === 'transparent') return this.setRGBA(0, 0, 0, 0), this;
  37713. if ((i = /^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e))) {
  37714. let r,
  37715. s = i[1],
  37716. n = i[2];
  37717. switch (s) {
  37718. case 'rgb':
  37719. case 'rgba':
  37720. if ((r = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n)))
  37721. return (this.a = s === 'rgba' ? parseFloat(r[4]) : 1), super.setStyle(e, t);
  37722. break;
  37723. case 'hsl':
  37724. case 'hsla':
  37725. if ((r = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n)))
  37726. return (this.a = s === 'hsla' ? parseFloat(r[4]) : 1), super.setStyle(e, t);
  37727. break;
  37728. }
  37729. }
  37730. return super.setStyle(e, t);
  37731. }
  37732. get x() {
  37733. return this.r;
  37734. }
  37735. get y() {
  37736. return this.g;
  37737. }
  37738. get z() {
  37739. return this.b;
  37740. }
  37741. get w() {
  37742. return this.a;
  37743. }
  37744. set x(e) {
  37745. this.r = e;
  37746. }
  37747. set y(e) {
  37748. this.g = e;
  37749. }
  37750. set z(e) {
  37751. this.b = e;
  37752. }
  37753. set w(e) {
  37754. this.a = e;
  37755. }
  37756. },
  37757. na = class extends or {
  37758. constructor(e) {
  37759. super('v4'), (this.nodeType = 'Vector4'), (this.value = e instanceof ji ? e : new ji(e.r, e.g, e.b, e.a));
  37760. }
  37761. generateReadonly(e, t, i, r, s, n) {
  37762. return e.format('vec4(' + this.value.r + ', ' + this.value.g + ', ' + this.value.b + ', ' + this.value.a + ')', r, t);
  37763. }
  37764. },
  37765. W6 = /^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,
  37766. Ux = /[a-z_0-9]+/gi,
  37767. Re = class extends St {
  37768. constructor(e, t, i, r, s) {
  37769. super(s),
  37770. (this.src = ''),
  37771. (this.nodeType = 'Function'),
  37772. (this.useKeywords = !0),
  37773. (this.includes = []),
  37774. (this.extensions = {}),
  37775. (this.keywords = {}),
  37776. (this.isMethod = s === void 0),
  37777. (this.isInterface = !1),
  37778. this.parse(e, t, i, r);
  37779. }
  37780. getShared(e, t) {
  37781. return !this.isMethod;
  37782. }
  37783. getType(e) {
  37784. return e.getTypeByFormat(this.type);
  37785. }
  37786. getInputByName(e) {
  37787. if (this.inputs) {
  37788. let t = this.inputs.length;
  37789. for (; t--; ) if (this.inputs[t].name === e) return this.inputs[t];
  37790. }
  37791. }
  37792. getIncludeByName(e) {
  37793. if (this.includes) {
  37794. let t = this.includes.length;
  37795. for (; t--; ) if (this.includes[t].name === e) return this.includes[t];
  37796. }
  37797. }
  37798. generate(e, t, i, r, s) {
  37799. let n,
  37800. a = 0,
  37801. o = this.src;
  37802. if (this.includes) for (let h = 0; h < this.includes.length; h++) e.include(this.includes[h], this);
  37803. for (let h in this.extensions) e.extensions[h] = !0;
  37804. let l = [];
  37805. for (; (n = Ux.exec(this.src)); ) l.push(n);
  37806. for (let h = 0; h < l.length; h++) {
  37807. let u = l[h],
  37808. c = u[0],
  37809. d = this.isMethod ? !this.getInputByName(c) : !0,
  37810. p = c;
  37811. if (this.keywords[c] || (this.useKeywords && d && Ni.containsKeyword(c))) {
  37812. let f = this.keywords[c];
  37813. if (!f) {
  37814. let g = Ni.getKeywordData(c);
  37815. g.cache && (f = e.keywords[c]), (f = f || Ni.getKeyword(c, e)), g.cache && (e.keywords[c] = f);
  37816. }
  37817. p = f.build(e);
  37818. }
  37819. c !== p &&
  37820. o[u.index + a - 1] !== '.' &&
  37821. ((o = o.substring(0, u.index + a) + p + o.substring(u.index + c.length + a)), (a += p.length - c.length)),
  37822. this.getIncludeByName(p) === void 0 && Ni.contains(p) && e.include(Ni.get(p));
  37823. }
  37824. return t === 'source'
  37825. ? o
  37826. : this.isMethod
  37827. ? (this.isInterface || e.include(this, void 0, o), this.name)
  37828. : e.format('( ' + o + ' )', this.getType(e), t);
  37829. }
  37830. parse(e, t, i, r) {
  37831. if (((this.src = e || ''), (this.includes = t ?? []), (this.extensions = i ?? {}), (this.keywords = r ?? {}), this.isMethod)) {
  37832. let s = W6.exec(this.src);
  37833. if (((this.inputs = []), s && s.length == 4)) {
  37834. (this.type = s[1]), (this.name = s[2]);
  37835. let n = s[3].match(Ux);
  37836. if (n) {
  37837. let a = 0;
  37838. for (; a < n.length; ) {
  37839. let o = n[a++],
  37840. l;
  37841. o === 'in' || o === 'out' || o === 'inout' ? (l = n[a++]) : ((l = o), (o = ''));
  37842. let h = n[a++];
  37843. this.inputs.push({ name: h, type: l, qualifier: o });
  37844. }
  37845. }
  37846. this.isInterface = this.src.indexOf('{') === -1;
  37847. } else (this.type = ''), (this.name = '');
  37848. }
  37849. }
  37850. },
  37851. X6 = /^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,
  37852. UA = class extends St {
  37853. constructor(e = '', t) {
  37854. super(), (this.src = ''), (this.useDefine = !1), (this.nodeType = 'Const'), this.parse(e || UA.PI, void 0, void 0, void 0, t);
  37855. }
  37856. getType(e) {
  37857. return e.getTypeByFormat(this.type);
  37858. }
  37859. parse(e, t, i, r, s) {
  37860. this.src = e || '';
  37861. let n,
  37862. a,
  37863. o = '',
  37864. l = X6.exec(e);
  37865. (this.useDefine = s ?? this.src.charAt(0) === '#'),
  37866. l && l.length > 1 ? ((a = l[1]), (n = l[2]), (o = l[3])) : ((n = this.src), (a = 'f')),
  37867. (this.name = n),
  37868. (this.type = a),
  37869. (this.value = o);
  37870. }
  37871. build(e, t) {
  37872. if (t === 'source') {
  37873. if (this.value)
  37874. return this.useDefine
  37875. ? '#define ' + this.name + ' ' + this.value
  37876. : 'const ' + this.type + ' ' + this.name + ' = ' + this.value + ';';
  37877. if (this.useDefine) return this.src;
  37878. }
  37879. return e.include(this), e.format(this.name, this.getType(e), t);
  37880. }
  37881. generate(e, t, i, r, s) {
  37882. return e.format(this.name, this.getType(e), t);
  37883. }
  37884. },
  37885. vt = UA;
  37886. (vt.PI = 'PI'),
  37887. (vt.PI2 = 'PI2'),
  37888. (vt.RECIPROCAL_PI = 'RECIPROCAL_PI'),
  37889. (vt.RECIPROCAL_PI2 = 'RECIPROCAL_PI2'),
  37890. (vt.LOG2 = 'LOG2'),
  37891. (vt.EPSILON = 'EPSILON');
  37892. var q6 = new RegExp(
  37893. `^structs*([a-z_0-9]+)s*{s*((.|
  37894. )*?)}`,
  37895. 'gim'
  37896. ),
  37897. Y6 = new RegExp('s*(w*?)s*(w*?)(=|;)', 'gim'),
  37898. FA = class extends St {
  37899. constructor(e = '') {
  37900. super(), (this.inputs = []), (this.src = ''), (this.nodeType = 'Struct'), this.parse(e);
  37901. }
  37902. getType(e) {
  37903. return e.getTypeByFormat(this.name);
  37904. }
  37905. getInputByName(e) {
  37906. let t = this.inputs.length;
  37907. for (; t--; ) if (this.inputs[t].name === e) return this.inputs[t];
  37908. }
  37909. generate(e, t, i, r, s) {
  37910. return t === 'source' ? this.src + ';' : e.format('( ' + this.src + ' )', this.getType(e), t);
  37911. }
  37912. parse(e = '') {
  37913. (this.src = e), (this.inputs = []);
  37914. let t = q6.exec(e);
  37915. if (t) {
  37916. let i = t[2],
  37917. r;
  37918. for (; (r = Y6.exec(i)); ) this.inputs.push({ type: r[1], name: r[2] });
  37919. this.name = t[1];
  37920. } else this.name = '';
  37921. this.type = this.name;
  37922. }
  37923. },
  37924. hv = class extends St {
  37925. constructor(e) {
  37926. super('v2', { shared: !1 }), (this.nodeType = 'UV'), (this.index = e ?? 0);
  37927. }
  37928. generate(e, t) {
  37929. e.requires.uv[this.index] = !0;
  37930. let i = this.index > 0 ? this.index + 1 : '',
  37931. r = e.isShader('vertex') ? 'uv' + i : 'vUv' + i;
  37932. return e.format(r, this.getType(e), t);
  37933. }
  37934. };
  37935. Ni.addKeyword('uv', function () {
  37936. return new hv();
  37937. });
  37938. Ni.addKeyword('uv2', function () {
  37939. return new hv(1);
  37940. });
  37941. var lo = class extends St {
  37942. constructor(e, t) {
  37943. super('v4'),
  37944. (this.nodeType = 'ColorSpace'),
  37945. (this.input = e),
  37946. (this.method = t ?? lo.LINEAR_TO_LINEAR),
  37947. (this.hashProperties = ['method']);
  37948. }
  37949. static getEncodingComponents(e) {
  37950. switch (e) {
  37951. case gs:
  37952. return ['Linear'];
  37953. case Ke:
  37954. return ['sRGB'];
  37955. default:
  37956. return [];
  37957. }
  37958. }
  37959. generate(e, t) {
  37960. let i = this.input.build(e, 'v4'),
  37961. r = this.getType(e),
  37962. s = lo.Nodes[this.method],
  37963. n = e.include(s);
  37964. if (n === lo.LINEAR_TO_LINEAR) return e.format(i, r, t);
  37965. if (s.inputs?.length === 2) {
  37966. let a = this.factor.build(e, 'f');
  37967. return e.format(n + '( ' + i + ', ' + a + ' )', r, t);
  37968. } else return e.format(n + '( ' + i + ' )', r, t);
  37969. }
  37970. fromEncoding(e) {
  37971. let t = lo.getEncodingComponents(e);
  37972. (this.method = 'LinearTo' + t[0]), (this.factor = t[1]);
  37973. }
  37974. fromDecoding(e) {
  37975. let t = lo.getEncodingComponents(e);
  37976. (this.method = t[0] + 'ToLinear'), (this.factor = t[1]);
  37977. }
  37978. },
  37979. hs = lo;
  37980. (hs.Nodes = {
  37981. LinearToLinear: new Re(
  37982. ['vec4 LinearToLinear( in vec4 value ) {', '\treturn value;', '}'].join(`
  37983. `)
  37984. ),
  37985. sRGBToLinear: new Re(
  37986. [
  37987. 'vec4 sRGBToLinear( in vec4 value ) {',
  37988. '\treturn 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 );',
  37989. '}'
  37990. ].join(`
  37991. `)
  37992. ),
  37993. LinearTosRGB: new Re(
  37994. [
  37995. 'vec4 LinearTosRGB( in vec4 value ) {',
  37996. '\treturn 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 );',
  37997. '}'
  37998. ].join(`
  37999. `)
  38000. )
  38001. }),
  38002. (hs.LINEAR_TO_LINEAR = 'LinearToLinear'),
  38003. (hs.SRGB_TO_LINEAR = 'sRGBToLinear'),
  38004. (hs.LINEAR_TO_SRGB = 'LinearTosRGB');
  38005. var Pt = class extends Re {
  38006. constructor(e = '', t, i, r, s) {
  38007. super(e, s, r, i, t), (this.nodeType = 'Expression');
  38008. }
  38009. },
  38010. An = class extends or {
  38011. constructor(e = new ci(), t, i, r) {
  38012. super('v4', { shared: !0 }),
  38013. (this.nodeType = 'Texture'),
  38014. (this.value = e),
  38015. (this.uv = t ?? new hv()),
  38016. (this.bias = i),
  38017. (this.project = r !== void 0 ? r : !1);
  38018. }
  38019. getTexture(e, t) {
  38020. return super.generate(e, t, this.value.uuid, 't');
  38021. }
  38022. generate(e, t) {
  38023. if (t === 'sampler2D') return this.getTexture(e, t);
  38024. let i = this.getTexture(e, t),
  38025. r = this.uv.build(e, this.project ? 'v4' : 'v2'),
  38026. s = this.bias ? this.bias.build(e, 'f') : void 0;
  38027. s === void 0 && e.context.bias && (s = e.context.bias.setTexture(this).build(e, 'f'));
  38028. let n, a;
  38029. this.project ? (n = 'texture2DProj') : (n = s ? 'tex2DBias' : 'tex2D'),
  38030. s ? (a = n + '( ' + i + ', ' + r + ', ' + s + ' )') : (a = n + '( ' + i + ', ' + r + ' )');
  38031. let o = { include: e.isShader('vertex'), ignoreCache: !0 },
  38032. l = this.getType(e);
  38033. return (
  38034. e.addContext(o),
  38035. (this.colorSpace = this.colorSpace ?? new hs(new Pt('', l))),
  38036. this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),
  38037. this.colorSpace.input.parse(a),
  38038. (a = this.colorSpace.build(e, l)),
  38039. e.removeContext(),
  38040. e.format(a, l, t)
  38041. );
  38042. }
  38043. },
  38044. Pe = class extends or {
  38045. constructor(e) {
  38046. super('f'), (this.nodeType = 'Float'), (this.value = e ?? 0);
  38047. }
  38048. generateReadonly(e, t, i, r, s, n) {
  38049. return e.format(this.value + (this.value % 1 ? '' : '.0'), r, t);
  38050. }
  38051. },
  38052. Fx = class extends St {
  38053. constructor(e, t) {
  38054. super(), (this.inputs = []), (this.nodeType = 'FunctionCall'), (this.value = e), (this.inputs = t ?? []);
  38055. }
  38056. getFunction() {
  38057. return this.value;
  38058. }
  38059. getType(e) {
  38060. return this.value.getType(e);
  38061. }
  38062. generate(e, t, i, r, s) {
  38063. r = this.getType(e);
  38064. let n = this.value,
  38065. a = n.build(e, t) + '( ',
  38066. o = [];
  38067. if (n.inputs) {
  38068. for (let l = 0; l < n.inputs.length; l++) {
  38069. let h = n.inputs[l],
  38070. u = this.inputs[l] || this.inputs[h.name];
  38071. o.push(u.build(e, e.getTypeByFormat(h.type)));
  38072. }
  38073. a += o.join(', ') + ' )';
  38074. }
  38075. return e.format(a, r, t);
  38076. }
  38077. },
  38078. kA = class extends St {
  38079. constructor(e, t, i = kA.ADD) {
  38080. super(), (this.nodeType = 'Operator'), (this.type = e.type), (this.a = e), (this.b = t), (this.op = i);
  38081. }
  38082. getType(e) {
  38083. let t = this.a.getType(e),
  38084. i = this.b.getType(e);
  38085. return e.isTypeMatrix(t) ? 'v4' : e.getTypeLength(i) > e.getTypeLength(t) ? i : t;
  38086. }
  38087. generate(e, t) {
  38088. let i = this.getType(e);
  38089. this.type = i;
  38090. let r = this.a.build(e, i),
  38091. s = this.b.build(e, i);
  38092. return e.format('( ' + r + ' ' + this.op + ' ' + s + ' )', i, t);
  38093. }
  38094. },
  38095. cs = kA;
  38096. (cs.ADD = '+'), (cs.SUB = '-'), (cs.MUL = '*'), (cs.DIV = '/');
  38097. var gt = class extends St {
  38098. constructor(e, t = gt.ABS, i, r) {
  38099. super(),
  38100. (this.nodeType = 'Math'),
  38101. (this.a = e),
  38102. typeof t != 'string' ? (this.b = t) : (r = t),
  38103. typeof i != 'string' ? (this.c = i) : (r = i),
  38104. (this.method = r),
  38105. (this.hashProperties = ['method']);
  38106. }
  38107. getNumInputs(e) {
  38108. switch (this.method) {
  38109. case gt.MIX:
  38110. case gt.CLAMP:
  38111. case gt.REFRACT:
  38112. case gt.SMOOTHSTEP:
  38113. case gt.FACEFORWARD:
  38114. return 3;
  38115. case gt.MIN:
  38116. case gt.MAX:
  38117. case gt.MOD:
  38118. case gt.STEP:
  38119. case gt.REFLECT:
  38120. case gt.DISTANCE:
  38121. case gt.DOT:
  38122. case gt.CROSS:
  38123. case gt.POW:
  38124. return 2;
  38125. default:
  38126. return 1;
  38127. }
  38128. }
  38129. getInputType(e) {
  38130. let t = e.getTypeLength(this.a.getType(e)),
  38131. i = this.b ? e.getTypeLength(this.b.getType(e)) : 0,
  38132. r = this.c ? e.getTypeLength(this.c.getType(e)) : 0;
  38133. return t > i && t > r ? this.a.getType(e) : i > r ? this.b.getType(e) : this.c.getType(e);
  38134. }
  38135. getType(e) {
  38136. switch (this.method) {
  38137. case gt.LENGTH:
  38138. case gt.DISTANCE:
  38139. case gt.DOT:
  38140. return 'f';
  38141. case gt.CROSS:
  38142. return 'v3';
  38143. }
  38144. return this.getInputType(e);
  38145. }
  38146. generate(e, t) {
  38147. let i,
  38148. r,
  38149. s,
  38150. n = this.a ? e.getTypeLength(this.a.getType(e)) : 0,
  38151. a = this.b ? e.getTypeLength(this.b.getType(e)) : 0,
  38152. o = this.c ? e.getTypeLength(this.c.getType(e)) : 0,
  38153. l = this.getInputType(e),
  38154. h = this.getType(e);
  38155. switch (((this.type = h), this.method)) {
  38156. case gt.NEGATE:
  38157. return e.format('( -' + this.a.build(e, l) + ' )', l, t);
  38158. case gt.INVERT:
  38159. return e.format('( 1.0 - ' + this.a.build(e, l) + ' )', l, t);
  38160. case gt.CROSS:
  38161. (i = this.a.build(e, 'v3')), (r = this.b.build(e, 'v3'));
  38162. break;
  38163. case gt.STEP:
  38164. (i = this.a.build(e, n === 1 ? 'f' : l)), (r = this.b.build(e, l));
  38165. break;
  38166. case gt.MIN:
  38167. case gt.MAX:
  38168. case gt.MOD:
  38169. (i = this.a.build(e, l)), (r = this.b.build(e, a === 1 ? 'f' : l));
  38170. break;
  38171. case gt.REFRACT:
  38172. (i = this.a.build(e, l)), (r = this.b.build(e, l)), (s = this.c.build(e, 'f'));
  38173. break;
  38174. case gt.MIX:
  38175. (i = this.a.build(e, l)), (r = this.b.build(e, l)), (s = this.c.build(e, o === 1 ? 'f' : l));
  38176. break;
  38177. default:
  38178. (i = this.a.build(e, l)), this.b && (r = this.b.build(e, l)), this.c && (s = this.c.build(e, l));
  38179. break;
  38180. }
  38181. let u = [];
  38182. u.push(i), r && u.push(r), s && u.push(s);
  38183. let c = this.getNumInputs(e);
  38184. if (u.length !== c) throw Error(`Arguments not match used in "${this.method}". Require ${c}, currently ${u.length}.`);
  38185. return e.format(this.method + '( ' + u.join(', ') + ' )', h, t);
  38186. }
  38187. },
  38188. qe = gt;
  38189. (qe.RAD = 'radians'),
  38190. (qe.DEG = 'degrees'),
  38191. (qe.EXP = 'exp'),
  38192. (qe.EXP2 = 'exp2'),
  38193. (qe.LOG = 'log'),
  38194. (qe.LOG2 = 'log2'),
  38195. (qe.SQRT = 'sqrt'),
  38196. (qe.INV_SQRT = 'inversesqrt'),
  38197. (qe.FLOOR = 'floor'),
  38198. (qe.CEIL = 'ceil'),
  38199. (qe.NORMALIZE = 'normalize'),
  38200. (qe.FRACT = 'fract'),
  38201. (qe.SATURATE = 'saturate'),
  38202. (qe.SIN = 'sin'),
  38203. (qe.COS = 'cos'),
  38204. (qe.TAN = 'tan'),
  38205. (qe.ASIN = 'asin'),
  38206. (qe.ACOS = 'acos'),
  38207. (qe.ARCTAN = 'atan'),
  38208. (qe.ABS = 'abs'),
  38209. (qe.SIGN = 'sign'),
  38210. (qe.LENGTH = 'length'),
  38211. (qe.NEGATE = 'negate'),
  38212. (qe.INVERT = 'invert'),
  38213. (qe.MIN = 'min'),
  38214. (qe.MAX = 'max'),
  38215. (qe.MOD = 'mod'),
  38216. (qe.STEP = 'step'),
  38217. (qe.REFLECT = 'reflect'),
  38218. (qe.DISTANCE = 'distance'),
  38219. (qe.DOT = 'dot'),
  38220. (qe.CROSS = 'cross'),
  38221. (qe.POW = 'pow'),
  38222. (qe.MIX = 'mix'),
  38223. (qe.CLAMP = 'clamp'),
  38224. (qe.REFRACT = 'refract'),
  38225. (qe.SMOOTHSTEP = 'smoothstep'),
  38226. (qe.FACEFORWARD = 'faceforward');
  38227. var Xl = class extends St {
  38228. constructor(e, t, i) {
  38229. super('v4'), (this.nodeType = 'TextureCubeUV'), (this.value = e), (this.uv = t), (this.bias = i);
  38230. }
  38231. bilinearCubeUV(e, t, i, r) {
  38232. let s = new Fx(Xl.Nodes.bilinearCubeUV, [t, i, r]);
  38233. (this.colorSpaceTL = this.colorSpaceTL ?? new hs(new Pt('', 'v4'))),
  38234. this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),
  38235. this.colorSpaceTL.input.parse(s.build(e) + '.tl'),
  38236. (this.colorSpaceTR = this.colorSpaceTR ?? new hs(new Pt('', 'v4'))),
  38237. this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),
  38238. this.colorSpaceTR.input.parse(s.build(e) + '.tr'),
  38239. (this.colorSpaceBL = this.colorSpaceBL ?? new hs(new Pt('', 'v4'))),
  38240. this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),
  38241. this.colorSpaceBL.input.parse(s.build(e) + '.bl'),
  38242. (this.colorSpaceBR = this.colorSpaceBR ?? new hs(new Pt('', 'v4'))),
  38243. this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),
  38244. this.colorSpaceBR.input.parse(s.build(e) + '.br');
  38245. let n = { include: e.isShader('vertex'), ignoreCache: !0 };
  38246. e.addContext(n),
  38247. (this.colorSpaceTLExp = new Pt(this.colorSpaceTL.build(e, 'v4'), 'v4')),
  38248. (this.colorSpaceTRExp = new Pt(this.colorSpaceTR.build(e, 'v4'), 'v4')),
  38249. (this.colorSpaceBLExp = new Pt(this.colorSpaceBL.build(e, 'v4'), 'v4')),
  38250. (this.colorSpaceBRExp = new Pt(this.colorSpaceBR.build(e, 'v4'), 'v4')),
  38251. e.removeContext();
  38252. let a = new Pt('mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )', 'v4');
  38253. return (
  38254. (a.keywords.cubeUV_TL = this.colorSpaceTLExp),
  38255. (a.keywords.cubeUV_TR = this.colorSpaceTRExp),
  38256. (a.keywords.cubeUV_BL = this.colorSpaceBLExp),
  38257. (a.keywords.cubeUV_BR = this.colorSpaceBRExp),
  38258. (a.keywords.cubeUV = s),
  38259. a
  38260. );
  38261. }
  38262. generate(e, t) {
  38263. if (e.isShader('fragment')) {
  38264. let i = this.uv,
  38265. r = this.bias || e.context.roughness,
  38266. s = new Fx(Xl.Nodes.roughnessToMip, [r]),
  38267. n = new qe(s, Xl.Nodes.m0, Xl.Nodes.cubeUV_maxMipLevel, qe.CLAMP),
  38268. a = new qe(n, qe.FLOOR),
  38269. o = new qe(n, qe.FRACT),
  38270. l = this.bilinearCubeUV(e, this.value, i, a),
  38271. h = this.bilinearCubeUV(e, this.value, i, new cs(a, new Pe(1).setReadonly(!0), cs.ADD)),
  38272. u = new qe(l, h, o, qe.MIX);
  38273. return e.format(u.build(e), 'v4', t);
  38274. } else
  38275. return (
  38276. console.warn('TextureCubeUVNode is not compatible with ' + e.shader + ' shader.'), e.format('vec4( 0.0 )', this.getType(e), t)
  38277. );
  38278. }
  38279. },
  38280. Fm = Xl;
  38281. Fm.Nodes = (function () {
  38282. let e = new FA(`struct TextureCubeUVData {
  38283. vec4 tl;
  38284. vec4 tr;
  38285. vec4 br;
  38286. vec4 bl;
  38287. vec2 f;
  38288. }`),
  38289. t = new vt('float cubeUV_maxMipLevel 8.0', !0),
  38290. i = new vt('float cubeUV_minMipLevel 4.0', !0),
  38291. r = new vt('float cubeUV_maxTileSize 256.0', !0),
  38292. s = new vt('float cubeUV_minTileSize 16.0', !0),
  38293. n = new Re(`float getFace(vec3 direction) {
  38294. vec3 absDirection = abs(direction);
  38295. float face = -1.0;
  38296. if (absDirection.x > absDirection.z) {
  38297. if (absDirection.x > absDirection.y)
  38298. face = direction.x > 0.0 ? 0.0 : 3.0;
  38299. else
  38300. face = direction.y > 0.0 ? 1.0 : 4.0;
  38301. } else {
  38302. if (absDirection.z > absDirection.y)
  38303. face = direction.z > 0.0 ? 2.0 : 5.0;
  38304. else
  38305. face = direction.y > 0.0 ? 1.0 : 4.0;
  38306. }
  38307. return face;
  38308. }`);
  38309. n.useKeywords = !1;
  38310. let a = new Re(`vec2 getUV(vec3 direction, float face) {
  38311. vec2 uv;
  38312. if (face == 0.0) {
  38313. uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
  38314. } else if (face == 1.0) {
  38315. uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y
  38316. } else if (face == 2.0) {
  38317. uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z
  38318. } else if (face == 3.0) {
  38319. uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x
  38320. } else if (face == 4.0) {
  38321. uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y
  38322. } else {
  38323. uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
  38324. }
  38325. return 0.5 * (uv + 1.0);
  38326. }`);
  38327. a.useKeywords = !1;
  38328. let o = new Re(
  38329. `TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
  38330. float face = getFace(direction);
  38331. float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
  38332. mipInt = max(mipInt, cubeUV_minMipLevel);
  38333. float faceSize = exp2(mipInt);
  38334. float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);
  38335. vec2 uv = getUV(direction, face) * (faceSize - 1.0);
  38336. vec2 f = fract(uv);
  38337. uv += 0.5 - f;
  38338. if (face > 2.0) {
  38339. uv.y += faceSize;
  38340. face -= 3.0;
  38341. }
  38342. uv.x += face * faceSize;
  38343. if(mipInt < cubeUV_maxMipLevel){
  38344. uv.y += 2.0 * cubeUV_maxTileSize;
  38345. }
  38346. uv.y += filterInt * 2.0 * cubeUV_minTileSize;
  38347. uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);
  38348. uv *= texelSize;
  38349. vec4 tl = texture2D(envMap, uv);
  38350. uv.x += texelSize;
  38351. vec4 tr = texture2D(envMap, uv);
  38352. uv.y += texelSize;
  38353. vec4 br = texture2D(envMap, uv);
  38354. uv.x -= texelSize;
  38355. vec4 bl = texture2D(envMap, uv);
  38356. return TextureCubeUVData( tl, tr, br, bl, f );
  38357. }`,
  38358. [e, n, a, t, i, r, s]
  38359. );
  38360. o.useKeywords = !1;
  38361. let l = new vt('float r0 1.0', !0),
  38362. h = new vt('float v0 0.339', !0),
  38363. u = new vt('float m0 -2.0', !0),
  38364. c = new vt('float r1 0.8', !0),
  38365. d = new vt('float v1 0.276', !0),
  38366. p = new vt('float m1 -1.0', !0),
  38367. f = new vt('float r4 0.4', !0),
  38368. g = new vt('float v4 0.046', !0),
  38369. m = new vt('float m4 2.0', !0),
  38370. v = new vt('float r5 0.305', !0),
  38371. y = new vt('float v5 0.016', !0),
  38372. b = new vt('float m5 3.0', !0),
  38373. x = new vt('float r6 0.21', !0),
  38374. w = new vt('float v6 0.0038', !0),
  38375. A = new vt('float m6 4.0', !0),
  38376. S = [l, h, u, c, d, p, f, g, m, v, y, b, x, w, A],
  38377. _ = new Re(
  38378. `float roughnessToMip(float roughness) {
  38379. float mip = 0.0;
  38380. if (roughness >= r1) {
  38381. mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
  38382. } else if (roughness >= r4) {
  38383. mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;
  38384. } else if (roughness >= r5) {
  38385. mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;
  38386. } else if (roughness >= r6) {
  38387. mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;
  38388. } else {
  38389. mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
  38390. }
  38391. return mip;
  38392. }`,
  38393. S
  38394. );
  38395. return { bilinearCubeUV: o, roughnessToMip: _, m0: u, cubeUV_maxMipLevel: t };
  38396. })();
  38397. var ho = class extends St {
  38398. constructor(e) {
  38399. super('v3'), (this.nodeType = 'Normal'), (this.scope = e ?? ho.VIEW);
  38400. }
  38401. getShared() {
  38402. return this.scope === ho.WORLD;
  38403. }
  38404. build(e, t, i, r) {
  38405. let s = e.context[this.scope + 'Normal'];
  38406. return s ? s.build(e, t, i, r) : super.build(e, t, i);
  38407. }
  38408. generate(e, t, i, r, s) {
  38409. let n;
  38410. switch (this.scope) {
  38411. case ho.VIEW:
  38412. e.isShader('vertex') ? (n = 'transformedNormal') : (n = 'geometryNormal');
  38413. break;
  38414. case ho.LOCAL:
  38415. e.isShader('vertex') ? (n = 'objectNormal') : ((e.requires.normal = !0), (n = 'vObjectNormal'));
  38416. break;
  38417. case ho.WORLD:
  38418. e.isShader('vertex')
  38419. ? (n = 'inverseTransformDirection( transformedNormal, viewMatrix ).xyz')
  38420. : ((e.requires.worldNormal = !0), (n = 'vWNormal'));
  38421. break;
  38422. }
  38423. return e.format(n, this.getType(e), t);
  38424. }
  38425. },
  38426. Ui = ho;
  38427. (Ui.LOCAL = 'local'), (Ui.WORLD = 'world'), (Ui.VIEW = 'view'), (Ui.NORMAL = 'normal');
  38428. Ni.addKeyword('viewNormal', function () {
  38429. return new Ui(Ui.VIEW);
  38430. });
  38431. Ni.addKeyword('localNormal', function () {
  38432. return new Ui(Ui.NORMAL);
  38433. });
  38434. Ni.addKeyword('worldNormal', function () {
  38435. return new Ui(Ui.WORLD);
  38436. });
  38437. var Fs = class extends St {
  38438. constructor(e) {
  38439. super('v3'), (this.nodeType = 'Position'), (this.scope = e ?? Fs.LOCAL);
  38440. }
  38441. getType() {
  38442. switch (this.scope) {
  38443. case Fs.PROJECTION:
  38444. return 'v4';
  38445. }
  38446. return this.type;
  38447. }
  38448. getShader() {
  38449. switch (this.scope) {
  38450. case Fs.LOCAL:
  38451. case Fs.WORLD:
  38452. return !1;
  38453. }
  38454. return !0;
  38455. }
  38456. generate(e, t, i, r, s) {
  38457. let n;
  38458. switch (this.scope) {
  38459. case Fs.LOCAL:
  38460. e.isShader('vertex') ? (n = 'transformed') : ((e.requires.position = !0), (n = 'vPosition'));
  38461. break;
  38462. case Fs.WORLD:
  38463. if (e.isShader('vertex')) return '( modelMatrix * vec4( transformed, 1.0 ) ).xyz';
  38464. (e.requires.worldPosition = !0), (n = 'vWPosition');
  38465. break;
  38466. case Fs.VIEW:
  38467. n = e.isShader('vertex') ? '-mvPosition.xyz' : 'vViewPosition';
  38468. break;
  38469. case Fs.PROJECTION:
  38470. n = e.isShader('vertex') ? '( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )' : 'vec4( 0.0 )';
  38471. break;
  38472. }
  38473. return e.format(n, this.getType(), t);
  38474. }
  38475. },
  38476. jr = Fs;
  38477. (jr.LOCAL = 'local'), (jr.WORLD = 'world'), (jr.VIEW = 'view'), (jr.PROJECTION = 'projection');
  38478. Ni.addKeyword('position', function () {
  38479. return new jr();
  38480. });
  38481. Ni.addKeyword('worldPosition', function () {
  38482. return new jr(jr.WORLD);
  38483. });
  38484. Ni.addKeyword('viewPosition', function () {
  38485. return new jr(jr.VIEW);
  38486. });
  38487. var is = class extends St {
  38488. constructor(e) {
  38489. super('v3'), (this.nodeType = 'Reflect'), (this.scope = e ?? is.CUBE);
  38490. }
  38491. getUnique(e) {
  38492. return !e.context.viewNormal;
  38493. }
  38494. getType() {
  38495. switch (this.scope) {
  38496. case is.SPHERE:
  38497. return 'v2';
  38498. }
  38499. return this.type;
  38500. }
  38501. generate(e, t) {
  38502. let i = this.getUnique(e);
  38503. if (e.isShader('fragment')) {
  38504. let r;
  38505. switch (this.scope) {
  38506. case is.VECTOR: {
  38507. let s = new Ui(Ui.VIEW),
  38508. n = e.context.roughness,
  38509. a = s.build(e, 'v3'),
  38510. o = new jr(jr.VIEW).build(e, 'v3'),
  38511. l = n ? n.build(e, 'f') : void 0,
  38512. h = `reflect( -normalize( ${o} ), ${a} )`;
  38513. l && (h = `normalize( mix( ${h}, ${a}, ${l} * ${l} ) )`);
  38514. let u = `inverseTransformDirection( ${h}, viewMatrix )`;
  38515. i ? (e.addNodeCode(`vec3 reflectVec = ${u};`), (r = 'reflectVec')) : (r = u);
  38516. break;
  38517. }
  38518. case is.CUBE: {
  38519. let s = new is(is.VECTOR).build(e, 'v3'),
  38520. n = 'vec3( -' + s + '.x, ' + s + '.yz )';
  38521. i ? (e.addNodeCode(`vec3 reflectCubeVec = ${n};`), (r = 'reflectCubeVec')) : (r = n);
  38522. break;
  38523. }
  38524. case is.SPHERE: {
  38525. let s =
  38526. 'normalize( ( viewMatrix * vec4( ' +
  38527. new is(is.VECTOR).build(e, 'v3') +
  38528. ', 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5';
  38529. i ? (e.addNodeCode(`vec2 reflectSphereVec = ${s};`), (r = 'reflectSphereVec')) : (r = s);
  38530. break;
  38531. }
  38532. }
  38533. return e.format(r, this.getType(), t);
  38534. } else return console.warn('ReflectNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.type, t);
  38535. }
  38536. },
  38537. Oo = is;
  38538. (Oo.CUBE = 'cube'), (Oo.SPHERE = 'sphere'), (Oo.VECTOR = 'vector');
  38539. var Q6 = class extends St {
  38540. constructor(e = new An(), t, i) {
  38541. super('v4'),
  38542. (this.nodeType = 'TextureCube'),
  38543. (this.value = e),
  38544. (this.radianceNode = new Fm(this.value, t ?? new Oo(Oo.VECTOR), i)),
  38545. (this.irradianceNode = new Fm(this.value, new Ui(Ui.WORLD), new Pe(1).setReadonly(!0)));
  38546. }
  38547. generate(e, t) {
  38548. return e.isShader('fragment')
  38549. ? (e.require('irradiance'),
  38550. e.context.bias && e.context.bias.setTexture(this.value),
  38551. (e.slot === 'irradiance' ? this.irradianceNode : this.radianceNode).build(e, t))
  38552. : (console.warn('TextureCubeNode is not compatible with ' + e.shader + ' shader.'), e.format('vec4( 0.0 )', this.getType(e), t));
  38553. }
  38554. },
  38555. Z6 = class extends or {
  38556. constructor(e = new cg(), t, i) {
  38557. super('v4', { shared: !0 }), (this.nodeType = 'CubeTexture'), (this.value = e), (this.uv = t ?? new Oo()), (this.bias = i);
  38558. }
  38559. getTexture(e, t) {
  38560. return super.generate(e, t, this.value.uuid, 'tc');
  38561. }
  38562. generate(e, t) {
  38563. if (t === 'samplerCube') return this.getTexture(e, t);
  38564. let i = this.getTexture(e, t),
  38565. r = this.uv?.build(e, 'v3'),
  38566. s = this.bias ? this.bias.build(e, 'f') : void 0;
  38567. s === void 0 && e.context.bias && (s = e.context.bias.setTexture(this).build(e, 'f'));
  38568. let n;
  38569. s ? (n = 'texCubeBias( ' + i + ', ' + r + ', ' + s + ' )') : (n = 'texCube( ' + i + ', ' + r + ' )');
  38570. let a = { include: e.isShader('vertex'), ignoreCache: !0 },
  38571. o = this.getType(e);
  38572. return (
  38573. e.addContext(a),
  38574. (this.colorSpace = this.colorSpace ?? new hs(new Pt('', o))),
  38575. this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),
  38576. this.colorSpace.input.parse(n),
  38577. (n = this.colorSpace.build(e, o)),
  38578. e.removeContext(),
  38579. e.format(n, o, t)
  38580. );
  38581. }
  38582. },
  38583. kx = ['x', 'y', 'z', 'w'],
  38584. K6 = ['float', 'vec2', 'vec3', 'vec4'],
  38585. J6 = { float: 'f', vec2: 'v2', vec3: 'v3', vec4: 'v4', mat4: 'v4', int: 'i', bool: 'b', 'float[]': 'f[]', 'vec4[]': 'v4[]' },
  38586. $6 = {
  38587. t: 'sampler2D',
  38588. tc: 'samplerCube',
  38589. b: 'bool',
  38590. i: 'int',
  38591. f: 'float',
  38592. c: 'vec3',
  38593. v2: 'vec2',
  38594. v3: 'vec3',
  38595. v4: 'vec4',
  38596. m3: 'mat3',
  38597. m4: 'mat4',
  38598. 'f[]': 'float[]',
  38599. 'v4[]': 'vec4[]'
  38600. },
  38601. ek = class {
  38602. constructor() {
  38603. (this.includes = { consts: {}, functions: {}, structs: {} }),
  38604. (this.cache = ''),
  38605. (this.slot = ''),
  38606. (this.shader = ''),
  38607. (this.context = {}),
  38608. (this.getIncludesCode = (function () {
  38609. function e(t, i) {
  38610. return t.deps.length - i.deps.length;
  38611. }
  38612. return function (t, i) {
  38613. let r = this.getIncludes(t, i);
  38614. if (!r) return '';
  38615. let s = '';
  38616. r = r.sort(e);
  38617. for (let n = 0; n < r.length; n++)
  38618. r[n].src &&
  38619. (s +=
  38620. r[n].src +
  38621. `
  38622. `);
  38623. return s;
  38624. };
  38625. })()),
  38626. (this.slots = []),
  38627. (this.caches = []),
  38628. (this.contexts = []),
  38629. (this.keywords = {}),
  38630. (this.nodeData = {}),
  38631. (this.fragmentVariables = {}),
  38632. (this.fragmentParsVariables = {}),
  38633. (this.vertexParsVariables = {}),
  38634. (this.requires = {
  38635. uv: [],
  38636. color: [],
  38637. transparent: !1,
  38638. irradiance: !1,
  38639. position: !1,
  38640. worldPosition: !1,
  38641. normal: !1,
  38642. worldNormal: !1,
  38643. vWorldViewDir: !1,
  38644. modelMatrix: !1,
  38645. viewMatrix: !1,
  38646. projectionMatrix: !1
  38647. }),
  38648. (this.includes = { consts: [], functions: [], structs: [] }),
  38649. (this.attributes = {}),
  38650. (this.prefixCode = [
  38651. '#ifdef TEXTURE_LOD_EXT',
  38652. '\t#define texCube(a, b) textureCube(a, b)',
  38653. '\t#define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)',
  38654. '\t#define tex2D(a, b) texture2D(a, b)',
  38655. '\t#define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)',
  38656. '#else',
  38657. '\t#define texCube(a, b) textureCube(a, b)',
  38658. '\t#define texCubeBias(a, b, c) textureCube(a, b, c)',
  38659. '\t#define tex2D(a, b) texture2D(a, b)',
  38660. '\t#define tex2DBias(a, b, c) texture2D(a, b, c)',
  38661. '#endif',
  38662. `
  38663. // NOTE: Include Spline's blending modes. This could be part of BlendNode
  38664. #define SPE_BLENDING_NORMAL 0
  38665. #define SPE_BLENDING_MULTIPLY 1
  38666. #define SPE_BLENDING_SCREEN 2
  38667. #define SPE_BLENDING_OVERLAY 3
  38668. vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {
  38669. return mix( a, b, alpha );
  38670. }
  38671. vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {
  38672. return mix( a, a * b, alpha );
  38673. }
  38674. vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {
  38675. vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );
  38676. return mix( a, tmp, alpha );
  38677. }
  38678. vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {
  38679. vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );
  38680. return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );
  38681. }
  38682. vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {
  38683. if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );
  38684. else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );
  38685. else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );
  38686. else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );
  38687. return vec3( 1.0 );
  38688. }
  38689. `,
  38690. '#include <packing>',
  38691. '#include <common>'
  38692. ].join(`
  38693. `)),
  38694. (this.parsCode = {
  38695. vertex: ['float neighbor_offset = 0.0001;', ''].join(`
  38696. `),
  38697. fragment: [
  38698. 'float accumAlpha = 0.0;',
  38699. `void accumulateAlpha(float alpha) {
  38700. accumAlpha += (1.0 - accumAlpha) * alpha;
  38701. }`,
  38702. ''
  38703. ].join(`
  38704. `)
  38705. }),
  38706. (this.code = { vertex: '', fragment: '' }),
  38707. (this.nodeCode = { vertex: '', fragment: '' }),
  38708. (this.resultCode = { vertex: '', fragment: '' }),
  38709. (this.finalCode = { vertex: '', fragment: '' }),
  38710. (this.inputs = {
  38711. uniforms: { list: [], vertex: [], fragment: [] },
  38712. arrayUniforms: { list: [], vertex: [], fragment: [] },
  38713. vars: { varying: [], vertex: [], fragment: [] }
  38714. }),
  38715. (this.defines = {}),
  38716. (this.uniforms = {}),
  38717. (this.extensions = { derivatives: !1, fragDepth: !1, drawBuffers: !1, shaderTextureLOD: !1 }),
  38718. (this.updaters = []),
  38719. (this.nodes = []),
  38720. (this.analyzing = !1);
  38721. }
  38722. build(e, t) {
  38723. this.buildShader('vertex', e), this.buildShader('fragment', t);
  38724. for (let i = 0; i < this.requires.uv.length; i++)
  38725. if (this.requires.uv[i]) {
  38726. let r = i > 0 ? i + 1 : '';
  38727. this.addVaryCode('varying vec2 vUv' + r + ';'),
  38728. i > 0 && this.addVertexParsCode('attribute vec2 uv' + r + ';'),
  38729. this.addVertexFinalCode('vUv' + r + ' = uv' + r + ';');
  38730. }
  38731. return (
  38732. this.requires.color[0] &&
  38733. (this.addVaryCode('varying vec4 vColor;'),
  38734. this.addVertexParsCode('attribute vec4 color;'),
  38735. this.addVertexFinalCode('vColor = color;')),
  38736. this.requires.color[1] &&
  38737. (this.addVaryCode('varying vec4 vColor2;'),
  38738. this.addVertexParsCode('attribute vec4 color2;'),
  38739. this.addVertexFinalCode('vColor2 = color2;')),
  38740. this.requires.position && (this.addVaryCode('varying vec3 vPosition;'), this.addVertexFinalCode('vPosition = transformed;')),
  38741. this.requires.worldPosition,
  38742. this.requires.normal && (this.addVaryCode('varying vec3 vObjectNormal;'), this.addVertexFinalCode('vObjectNormal = normal;')),
  38743. this.requires.modelMatrix && this.addFragmentParsCode('uniform mat4 modelMatrix;'),
  38744. this.requires.viewMatrix && this.addFragmentParsCode('uniform mat4 viewMatrix;'),
  38745. this.requires.projectionMatrix && this.addFragmentParsCode('uniform mat4 projectionMatrix;'),
  38746. this.requires.worldNormal &&
  38747. (this.addVaryCode('varying vec3 vWNormal;'),
  38748. this.addVertexFinalCode('vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;')),
  38749. this.requires.vWorldViewDir &&
  38750. (this.addVaryCode('varying vec3 vWorldViewDir;'),
  38751. this.addVertexFinalCode(
  38752. 'vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );'
  38753. )),
  38754. this
  38755. );
  38756. }
  38757. buildShader(e, t) {
  38758. this.resultCode[e] = t.build(this.setShader(e), 'v4');
  38759. }
  38760. setMaterial(e, t) {
  38761. return (this.defines = {}), this;
  38762. }
  38763. addFlow(e, t, i) {
  38764. return this.addSlot(e).addCache(t).addContext(i);
  38765. }
  38766. removeFlow() {
  38767. return this.removeSlot().removeCache().removeContext();
  38768. }
  38769. addCache(e) {
  38770. return (this.cache = e ?? ''), this.caches.push(this.cache), this;
  38771. }
  38772. removeCache() {
  38773. return this.caches.pop(), (this.cache = this.caches[this.caches.length - 1] || ''), this;
  38774. }
  38775. addContext(e) {
  38776. return (
  38777. (this.context = Object.assign({}, this.context, e)),
  38778. (this.context.extra = this.context.extra || {}),
  38779. this.contexts.push(this.context),
  38780. this
  38781. );
  38782. }
  38783. removeContext() {
  38784. return this.contexts.pop(), (this.context = this.contexts[this.contexts.length - 1] || {}), this;
  38785. }
  38786. addSlot(e) {
  38787. return (this.slot = e || ''), this.slots.push(this.slot), this;
  38788. }
  38789. removeSlot() {
  38790. return this.slots.pop(), (this.slot = this.slots[this.slots.length - 1] || ''), this;
  38791. }
  38792. addFragmentVariable(e, t) {
  38793. this.fragmentVariables[e] === void 0 && (this.addFragmentCode(`${t} ${e};`), (this.fragmentVariables[e] = ''));
  38794. }
  38795. addFragmentParsVariable(e, t) {
  38796. this.fragmentParsVariables[e] === void 0 && (this.addFragmentParsCode(`${t} ${e};`), (this.fragmentParsVariables[e] = ''));
  38797. }
  38798. addVertexParsVariable(e, t) {
  38799. this.vertexParsVariables[e] === void 0 && (this.addVertexParsCode(`${t} ${e};`), (this.vertexParsVariables[e] = ''));
  38800. }
  38801. addVertexCode(e) {
  38802. this.addCode(e, 'vertex');
  38803. }
  38804. addFragmentCode(e) {
  38805. this.addCode(e, 'fragment');
  38806. }
  38807. addCode(e, t) {
  38808. this.code[t ?? this.shader] +=
  38809. e +
  38810. `
  38811. `;
  38812. }
  38813. addVertexNodeCode(e) {
  38814. this.addNodeCode(e, 'vertex');
  38815. }
  38816. addFragmentNodeCode(e) {
  38817. this.addNodeCode(e, 'fragment');
  38818. }
  38819. addNodeCode(e, t) {
  38820. this.nodeCode[t ?? this.shader] +=
  38821. e +
  38822. `
  38823. `;
  38824. }
  38825. clearNodeCode(e) {
  38826. e = e ?? this.shader;
  38827. let t = this.nodeCode[e];
  38828. return (this.nodeCode[e] = ''), t;
  38829. }
  38830. clearVertexNodeCode() {
  38831. return this.clearNodeCode('vertex');
  38832. }
  38833. clearFragmentNodeCode() {
  38834. return this.clearNodeCode('fragment');
  38835. }
  38836. addVertexFinalCode(e) {
  38837. this.addFinalCode(e, 'vertex');
  38838. }
  38839. addFragmentFinalCode(e) {
  38840. this.addFinalCode(e, 'fragment');
  38841. }
  38842. addFinalCode(e, t) {
  38843. this.finalCode[t ?? this.shader] +=
  38844. e +
  38845. `
  38846. `;
  38847. }
  38848. addVertexParsCode(e) {
  38849. this.addParsCode(e, 'vertex');
  38850. }
  38851. addFragmentParsCode(e) {
  38852. this.addParsCode(e, 'fragment');
  38853. }
  38854. addParsCode(e, t) {
  38855. this.parsCode[t ?? this.shader] +=
  38856. e +
  38857. `
  38858. `;
  38859. }
  38860. addVaryCode(e) {
  38861. this.addVertexParsCode(e), this.addFragmentParsCode(e);
  38862. }
  38863. isCache(e) {
  38864. return this.caches.indexOf(e) !== -1;
  38865. }
  38866. isSlot(e) {
  38867. return this.slots.indexOf(e) !== -1;
  38868. }
  38869. define(e, t) {
  38870. this.defines[e] = t === void 0 ? 1 : t;
  38871. }
  38872. require(e) {
  38873. this.requires[e] = !0;
  38874. }
  38875. isDefined(e) {
  38876. return this.defines[e] !== void 0;
  38877. }
  38878. getVar(e, t, i, r = 'varying', s = 'V', n = '') {
  38879. let a = this.getVars(r),
  38880. o = a[e];
  38881. if (!o) {
  38882. let l = a.length;
  38883. (o = { name: i || 'node' + s + l + (n ? '_' + n : ''), type: t }), a.push(o), (a[e] = o);
  38884. }
  38885. return o;
  38886. }
  38887. getTempVar(e, t, i, r) {
  38888. return this.getVar(e, t, i, this.shader, 'T', r);
  38889. }
  38890. getAttribute(e, t) {
  38891. if (!this.attributes[e]) {
  38892. let i = this.getVar(e, t);
  38893. this.addVertexParsCode('attribute ' + t + ' ' + e + ';'),
  38894. this.addVertexFinalCode(i.name + ' = ' + e + ';'),
  38895. (this.attributes[e] = { varying: i, name: e, type: t });
  38896. }
  38897. return this.attributes[e];
  38898. }
  38899. getCode(e) {
  38900. return [
  38901. this.prefixCode,
  38902. this.parsCode[e],
  38903. this.getVarListCode(this.getVars('varying'), 'varying'),
  38904. this.getVarListCode(this.inputs.uniforms[e], 'uniform'),
  38905. this.getVarListCode(this.inputs.arrayUniforms[e], 'uniform'),
  38906. this.getIncludesCode('consts', e),
  38907. this.getIncludesCode('structs', e),
  38908. this.getIncludesCode('functions', e),
  38909. 'void main() {',
  38910. this.getVarListCode(this.getVars(e)),
  38911. this.code[e],
  38912. this.resultCode[e],
  38913. this.finalCode[e],
  38914. '}'
  38915. ].join(`
  38916. `);
  38917. }
  38918. getVarListCode(e, t) {
  38919. t = t ?? '';
  38920. let i = '';
  38921. for (let r = 0, s = e.length; r < s; ++r) {
  38922. let n = e[r],
  38923. a = n.type,
  38924. o = n.name,
  38925. l = n.size,
  38926. h = this.getFormatByType(a);
  38927. if (h === void 0) throw new Error('Node pars ' + h + ' not found.');
  38928. h.includes('[]')
  38929. ? (i +=
  38930. t +
  38931. ' ' +
  38932. h.substring(0, h.length - 2) +
  38933. ' ' +
  38934. o +
  38935. `[${l}];
  38936. `)
  38937. : (i +=
  38938. t +
  38939. ' ' +
  38940. h +
  38941. ' ' +
  38942. o +
  38943. `;
  38944. `);
  38945. }
  38946. return i;
  38947. }
  38948. getVars(e) {
  38949. return this.inputs.vars[e ?? this.shader];
  38950. }
  38951. getNodeData(e) {
  38952. let t = e instanceof Bn ? e.uuid : e;
  38953. return (this.nodeData[t] = this.nodeData[t] || {});
  38954. }
  38955. createUniform(e, t, i, r, s, n) {
  38956. if (t.includes('[]')) {
  38957. let a = this.inputs.arrayUniforms,
  38958. o = a.list.length,
  38959. l = new Nx({ type: t, size: i.size, name: r || 'nodeUA' + o + (n ? '_' + n : ''), node: i, needsUpdate: s });
  38960. return a.list.push(l), a[e].push(l), (a[e][l.name] = l), (this.uniforms[l.name] = l), l;
  38961. } else {
  38962. let a = this.inputs.uniforms,
  38963. o = a.list.length,
  38964. l = new Nx({ type: t, name: r || 'nodeU' + o + (n ? '_' + n : ''), node: i, needsUpdate: s });
  38965. return a.list.push(l), a[e].push(l), (a[e][l.name] = l), (this.uniforms[l.name] = l), l;
  38966. }
  38967. }
  38968. createVertexUniform(e, t, i, r, s) {
  38969. return this.createUniform('vertex', e, t, i, r, s);
  38970. }
  38971. createFragmentUniform(e, t, i, r, s) {
  38972. return this.createUniform('fragment', e, t, i, r, s);
  38973. }
  38974. include(e, t, i) {
  38975. let r;
  38976. if (((e = typeof e == 'string' ? Ni.get(e) : e), this.context.include === !1)) return e.name;
  38977. e instanceof Re
  38978. ? (r = this.includes.functions)
  38979. : e instanceof vt
  38980. ? (r = this.includes.consts)
  38981. : e instanceof FA && (r = this.includes.structs);
  38982. let s = (r[this.shader] = r[this.shader] || []);
  38983. if (e) {
  38984. let n = s[e.name];
  38985. if (
  38986. (n || ((n = s[e.name] = { node: e, deps: [] }), s.push(n), (n.src = e.build(this, 'source'))),
  38987. e instanceof Re && t && s[t.name] && s[t.name].deps.indexOf(e) === -1 && (s[t.name].deps.push(e), e.includes?.length))
  38988. ) {
  38989. let a = 0;
  38990. do {
  38991. this.include(e.includes[a++], t);
  38992. } while (a < e.includes.length);
  38993. }
  38994. return i && (n.src = i), e.name;
  38995. } else throw new Error('Include not found.');
  38996. }
  38997. colorToVectorProperties(e) {
  38998. return e.replace('r', 'x').replace('g', 'y').replace('b', 'z').replace('a', 'w');
  38999. }
  39000. colorToVector(e) {
  39001. return e.replace(/c/g, 'v3');
  39002. }
  39003. getIncludes(e, t) {
  39004. return this.includes[e][t || this.shader];
  39005. }
  39006. getConstructorFromLength(e) {
  39007. return K6[e - 1];
  39008. }
  39009. isTypeMatrix(e) {
  39010. return /^m/.test(e);
  39011. }
  39012. getTypeLength(e) {
  39013. return e === 'f' ? 1 : parseInt(this.colorToVector(e).substr(1));
  39014. }
  39015. getTypeFromLength(e) {
  39016. return e === 1 ? 'f' : 'v' + e;
  39017. }
  39018. findNode(...e) {
  39019. for (let t = 0; t < arguments.length; t++) {
  39020. let i = e[t];
  39021. if (i?.isNode) return i;
  39022. }
  39023. }
  39024. resolve(...e) {
  39025. for (let t = 0; t < arguments.length; t++) {
  39026. let i = e[t];
  39027. if (i !== void 0) {
  39028. if (i.isNode) return i;
  39029. if (i.isTexture)
  39030. switch (i.mapping) {
  39031. case ya:
  39032. case xa:
  39033. return new Z6(i);
  39034. case Ch:
  39035. return new Q6(new An(i));
  39036. default:
  39037. return new An(i);
  39038. }
  39039. else {
  39040. if (i.isVector2) return new vr(i);
  39041. if (i.isVector3) return new fr(i);
  39042. if (i.isVector4) return new na(i);
  39043. }
  39044. }
  39045. }
  39046. }
  39047. format(e, t, i) {
  39048. switch (this.colorToVector(i + ' <- ' + t)) {
  39049. case 'f <- v2':
  39050. return e + '.x';
  39051. case 'f <- v3':
  39052. return e + '.x';
  39053. case 'f <- v4':
  39054. return e + '.x';
  39055. case 'f <- i':
  39056. case 'f <- b':
  39057. return 'float( ' + e + ' )';
  39058. case 'v2 <- f':
  39059. return 'vec2( ' + e + ' )';
  39060. case 'v2 <- v3':
  39061. return e + '.xy';
  39062. case 'v2 <- v4':
  39063. return e + '.xy';
  39064. case 'v2 <- i':
  39065. case 'v2 <- b':
  39066. return 'vec2( float( ' + e + ' ) )';
  39067. case 'v3 <- f':
  39068. return 'vec3( ' + e + ' )';
  39069. case 'v3 <- v2':
  39070. return 'vec3( ' + e + ', 0.0 )';
  39071. case 'v3 <- v4':
  39072. return e + '.xyz';
  39073. case 'v3 <- i':
  39074. case 'v3 <- b':
  39075. return 'vec2( float( ' + e + ' ) )';
  39076. case 'v4 <- f':
  39077. return 'vec4( ' + e + ' )';
  39078. case 'v4 <- v2':
  39079. return 'vec4( ' + e + ', 0.0, 1.0 )';
  39080. case 'v4 <- v3':
  39081. return 'vec4( ' + e + ', 1.0 )';
  39082. case 'v4 <- i':
  39083. case 'v4 <- b':
  39084. return 'vec4( float( ' + e + ' ) )';
  39085. case 'i <- f':
  39086. case 'i <- b':
  39087. return 'int( ' + e + ' )';
  39088. case 'i <- v2':
  39089. return 'int( ' + e + '.x )';
  39090. case 'i <- v3':
  39091. return 'int( ' + e + '.x )';
  39092. case 'i <- v4':
  39093. return 'int( ' + e + '.x )';
  39094. case 'b <- f':
  39095. return '( ' + e + ' != 0.0 )';
  39096. case 'b <- v2':
  39097. return '( ' + e + ' != vec2( 0.0 ) )';
  39098. case 'b <- v3':
  39099. return '( ' + e + ' != vec3( 0.0 ) )';
  39100. case 'b <- v4':
  39101. return '( ' + e + ' != vec4( 0.0 ) )';
  39102. case 'b <- i':
  39103. return '( ' + e + ' != 0 )';
  39104. }
  39105. return e;
  39106. }
  39107. getTypeByFormat(e) {
  39108. return J6[e] || e;
  39109. }
  39110. getFormatByType(e) {
  39111. return $6[e] || e;
  39112. }
  39113. getUUID(e, t) {
  39114. return (t = t !== void 0 ? t : !0), t && this.cache && (e = this.cache + '-' + e), e;
  39115. }
  39116. getElementByIndex(e) {
  39117. return kx[e];
  39118. }
  39119. getIndexByElement(e) {
  39120. return kx.indexOf(e);
  39121. }
  39122. isShader(e) {
  39123. return this.shader === e;
  39124. }
  39125. setShader(e) {
  39126. return (this.shader = e), this;
  39127. }
  39128. mergeDefines(e) {
  39129. for (let t in e) this.defines[t] = e[t];
  39130. return this.defines;
  39131. }
  39132. mergeUniform(e) {
  39133. for (let t in e) this.uniforms[t] = e[t];
  39134. return this.uniforms;
  39135. }
  39136. getTextureEncodingFromMap(e) {
  39137. let t;
  39138. return e ? e.isTexture && (t = e.encoding) : (t = gs), t === gs && this.context.gamma && (t = Ke), t;
  39139. }
  39140. },
  39141. Ut = class extends or {
  39142. constructor(e = 0, t, i, r) {
  39143. super('c'), (this.nodeType = 'Color'), (this.value = e instanceof ji ? e : new ji(e || 0, t, i, r));
  39144. }
  39145. setRGBA(e) {
  39146. this.value.setRGBA(e.r, e.g, e.b, e.a);
  39147. }
  39148. generate(e, t, i, r, s, n) {
  39149. (i = e.getUUID(i ?? this.getUUID())), (r = r ?? this.getType(e));
  39150. let a = e.getNodeData(i),
  39151. o = this.getReadonly() && this.generateReadonly !== void 0;
  39152. if (this.alpha) {
  39153. let l = this.alpha.build(e, 'f');
  39154. e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${l};`);
  39155. }
  39156. return o
  39157. ? this.generateReadonly(e, t, i, r, s, n)
  39158. : e.isShader('vertex')
  39159. ? (a.vertex || (a.vertex = e.createVertexUniform(r, this, s, n, this.getLabel())), e.format(a.vertex.name, r, t))
  39160. : (a.fragment || (a.fragment = e.createFragmentUniform(r, this, s, n, this.getLabel())), e.format(a.fragment.name, r, t));
  39161. }
  39162. generateReadonly(e, t, i, r, s, n) {
  39163. return e.format('vec3(' + this.value.r + ', ' + this.value.g + ', ' + this.value.b + ')', r, t);
  39164. }
  39165. },
  39166. xt = class extends or {
  39167. constructor(e) {
  39168. super('i'), (this.nodeType = 'Int'), (this.value = Math.floor(e ?? 0));
  39169. }
  39170. generateReadonly(e, t, i, r, s, n) {
  39171. return e.format(this.value.toString(), r, t);
  39172. }
  39173. },
  39174. jA = class extends Bn {
  39175. constructor() {
  39176. super('basic'),
  39177. (this.nodeType = 'Basic'),
  39178. (this.color = new Ut(5526619)),
  39179. (this.shadingAlpha = new Pe(1)),
  39180. (this.shadingBlend = new xt(0));
  39181. }
  39182. get category() {
  39183. return 'phong';
  39184. }
  39185. generate(e) {
  39186. let t;
  39187. if (e.isShader('vertex')) {
  39188. let i = this.position ? this.position.analyzeAndFlow(e, 'v3', { cache: 'position' }) : void 0;
  39189. e.mergeUniform(qo.merge([ge.fog])),
  39190. e.addParsCode(
  39191. ['varying vec3 vViewPosition;', 'varying vec3 vWPosition;', '#include <fog_pars_vertex>', '#include <normal_pars_vertex>']
  39192. .join(`
  39193. `)
  39194. );
  39195. let r = [
  39196. '#include <beginnormal_vertex>',
  39197. `
  39198. #if !defined( USE_LAYER_DISPLACE )
  39199. #include <defaultnormal_vertex>
  39200. #endif
  39201. vec3 displaced_position = position;
  39202. vec3 displaced_normal = normal;
  39203. #if defined( USE_LAYER_DISPLACE )
  39204. vec3 transformed;
  39205. vec3 transformedNormal;
  39206. #endif
  39207. `,
  39208. '#include <normal_vertex>',
  39209. `
  39210. #if !defined( USE_LAYER_DISPLACE )
  39211. #include <begin_vertex>
  39212. #endif /* !USE_LAYER_DISPLACE */
  39213. `
  39214. ];
  39215. i && r.push(i.code, i.result ? 'displaced_position = ' + i.result + ';' : ''),
  39216. r.push(
  39217. 'transformed = displaced_position;',
  39218. 'transformedNormal = normalMatrix * displaced_normal;',
  39219. '#ifndef FLAT_SHADED',
  39220. '\tvNormal = transformedNormal;',
  39221. '#endif'
  39222. ),
  39223. r.push(
  39224. '#include <project_vertex>',
  39225. '#include <fog_vertex>',
  39226. '#include <clipping_planes_vertex>',
  39227. '\tvViewPosition = - mvPosition.xyz;',
  39228. '#include <worldpos_vertex>'
  39229. ),
  39230. r.push('vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;'),
  39231. (t = r.join(`
  39232. `));
  39233. } else {
  39234. this.color === void 0 && (this.color = new Ut(5526619)),
  39235. this.color.analyze(e, { slot: 'color' }),
  39236. this.alpha && this.alpha.analyze(e),
  39237. this.afterColor && this.afterColor.analyze(e, { slot: 'afterColor' });
  39238. let i = this.color.flow(e, 'c', { slot: 'color' }),
  39239. r = this.alpha ? this.alpha.flow(e, 'f') : void 0,
  39240. s = this.afterColor ? this.afterColor.flow(e, 'c', { slot: 'afterColor' }) : void 0;
  39241. (e.requires.transparent = r !== void 0),
  39242. e.addParsCode(
  39243. [
  39244. 'varying vec3 vWPosition;',
  39245. '#include <fog_pars_fragment>',
  39246. '#include <dithering_pars_fragment>',
  39247. 'varying vec3 vViewPosition;',
  39248. '#include <normal_pars_fragment>'
  39249. ].join(`
  39250. `)
  39251. );
  39252. let n = ['#include <normal_fragment_begin>', i.code];
  39253. r && n.push(r.code, '#ifdef ALPHATEST', ' if ( ' + r.result + ' <= ALPHATEST ) discard;', '#endif'),
  39254. s
  39255. ? n.push(
  39256. s.code,
  39257. `vec3 outgoingLight = ${i.result};`,
  39258. `vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`
  39259. )
  39260. : n.push(`vec3 finalColor = ${i.result};`),
  39261. r
  39262. ? n.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${r.result} );`)
  39263. : n.push('gl_FragColor = vec4(' + i.result + ', 1.0 );'),
  39264. n.push('#include <fog_fragment>', '#include <dithering_fragment>'),
  39265. (t = n.join(`
  39266. `));
  39267. }
  39268. return t;
  39269. }
  39270. },
  39271. ea = class extends or {
  39272. constructor(e = 1, t) {
  39273. super('f[]'),
  39274. (this.nodeType = 'FloatArray'),
  39275. (this.size = e),
  39276. (this.value = Array.isArray(t) ? t : typeof t == 'number' ? new Array(e).fill(t) : new Array(e).fill(0));
  39277. }
  39278. },
  39279. Lt = {
  39280. normalRenderTarget: new An(),
  39281. normalRenderTargetDepth: new An(),
  39282. transmissionRenderTarget: new An(),
  39283. transmissionSize: new vr(2048, 2048),
  39284. transmissionRenderTargetDepth: new An(),
  39285. pixelRatioNode: new Pe(1),
  39286. resolution: new vr(),
  39287. penumbraSize: new ea(5, 0.5)
  39288. };
  39289. for (let e of Object.values(Lt)) e.isRenderGlobal = !0;
  39290. var tk = class extends Bn {
  39291. constructor() {
  39292. super('lambert'),
  39293. (this.nodeType = 'Lambert'),
  39294. (this.color = new Ut(5526619)),
  39295. (this.emissive = new Ut(0)),
  39296. (this.emissiveIntensity = new Pe(1)),
  39297. (this.shadingAlpha = new Pe(1)),
  39298. (this.shadingBlend = new xt(0));
  39299. }
  39300. get category() {
  39301. return 'lambert';
  39302. }
  39303. build(e) {
  39304. let t;
  39305. if ((e.define('LAMBERT'), (e.requires.lights = !0), (e.extensions.derivatives = !0), e.isShader('vertex'))) {
  39306. let i = this.position ? this.position.analyzeAndFlow(e, 'v3', { cache: 'position' }) : void 0;
  39307. e.mergeUniform(qo.merge([ge.fog, ge.lights])),
  39308. e.addParsCode(
  39309. [
  39310. 'varying vec3 vViewPosition;',
  39311. 'varying vec3 vWPosition;',
  39312. 'varying vec3 vLightFront;',
  39313. 'varying vec3 vIndirectFront;',
  39314. '#ifndef DOUBLE_SIDED',
  39315. ' #define DOUBLE_SIDED',
  39316. '#endif',
  39317. '#ifdef DOUBLE_SIDED',
  39318. '\tvarying vec3 vLightBack;',
  39319. '\tvarying vec3 vIndirectBack;',
  39320. '#endif',
  39321. '#include <bsdfs>',
  39322. '#include <lights_pars_begin>',
  39323. '#include <color_pars_vertex>',
  39324. '#include <fog_pars_vertex>',
  39325. '#include <normal_pars_vertex>',
  39326. '#include <shadowmap_pars_vertex>',
  39327. '#include <clipping_planes_pars_vertex>'
  39328. ].join(`
  39329. `)
  39330. );
  39331. let r = [
  39332. '#include <beginnormal_vertex>',
  39333. `
  39334. #ifndef USE_LAYER_DISPLACE
  39335. #include <defaultnormal_vertex>
  39336. #endif
  39337. vec3 displaced_position = position;
  39338. vec3 displaced_normal = normal;
  39339. #ifdef USE_LAYER_DISPLACE
  39340. vec3 transformed;
  39341. vec3 transformedNormal;
  39342. #endif
  39343. `,
  39344. '#include <normal_vertex>',
  39345. `
  39346. #ifndef USE_LAYER_DISPLACE
  39347. #include <begin_vertex>
  39348. #endif
  39349. `
  39350. ];
  39351. i && r.push(i.code, i.result ? 'displaced_position = ' + i.result + ';' : ''),
  39352. r.push(
  39353. 'transformed = displaced_position;',
  39354. 'transformedNormal = normalMatrix * displaced_normal;',
  39355. '#ifndef FLAT_SHADED',
  39356. ' vNormal = transformedNormal;',
  39357. '#endif'
  39358. ),
  39359. r.push(
  39360. '\t#include <project_vertex>',
  39361. '\t#include <clipping_planes_vertex>',
  39362. '\tvViewPosition = - mvPosition.xyz;',
  39363. '\t#include <worldpos_vertex>',
  39364. `
  39365. vec3 diffuse = vec3( 1.0 );
  39366. GeometricContext geometry;
  39367. geometry.position = mvPosition.xyz;
  39368. geometry.normal = normalize( transformedNormal );
  39369. geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
  39370. GeometricContext backGeometry;
  39371. backGeometry.position = geometry.position;
  39372. backGeometry.normal = -geometry.normal;
  39373. backGeometry.viewDir = geometry.viewDir;
  39374. vLightFront = vec3( 0.0 );
  39375. vIndirectFront = vec3( 0.0 );
  39376. #ifdef DOUBLE_SIDED
  39377. vLightBack = vec3( 0.0 );
  39378. vIndirectBack = vec3( 0.0 );
  39379. #endif
  39380. IncidentLight directLight;
  39381. float dotNL;
  39382. vec3 directLightColor_Diffuse;
  39383. vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
  39384. vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
  39385. #ifdef DOUBLE_SIDED
  39386. vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
  39387. vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
  39388. #endif
  39389. #if NUM_POINT_LIGHTS > 0
  39390. #pragma unroll_loop_start
  39391. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  39392. getPointLightInfo( pointLights[ i ], geometry, directLight );
  39393. dotNL = dot( geometry.normal, directLight.direction );
  39394. directLightColor_Diffuse = directLight.color;
  39395. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  39396. #ifdef DOUBLE_SIDED
  39397. vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
  39398. #endif
  39399. }
  39400. #pragma unroll_loop_end
  39401. #endif
  39402. #if NUM_SPOT_LIGHTS > 0
  39403. #pragma unroll_loop_start
  39404. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  39405. getSpotLightInfo( spotLights[ i ], geometry, directLight );
  39406. dotNL = dot( geometry.normal, directLight.direction );
  39407. directLightColor_Diffuse = directLight.color;
  39408. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  39409. #ifdef DOUBLE_SIDED
  39410. vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
  39411. #endif
  39412. }
  39413. #pragma unroll_loop_end
  39414. #endif
  39415. #if NUM_DIR_LIGHTS > 0
  39416. #pragma unroll_loop_start
  39417. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  39418. getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
  39419. dotNL = dot( geometry.normal, directLight.direction );
  39420. directLightColor_Diffuse = directLight.color;
  39421. vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
  39422. #ifdef DOUBLE_SIDED
  39423. vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
  39424. #endif
  39425. }
  39426. #pragma unroll_loop_end
  39427. #endif
  39428. #if NUM_HEMI_LIGHTS > 0
  39429. #pragma unroll_loop_start
  39430. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  39431. vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
  39432. #ifdef DOUBLE_SIDED
  39433. vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
  39434. #endif
  39435. }
  39436. #pragma unroll_loop_end
  39437. #endif
  39438. `,
  39439. '\t#include <shadowmap_vertex>',
  39440. '\t#include <fog_vertex>'
  39441. ),
  39442. r.push('vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;'),
  39443. (t = r.join(`
  39444. `));
  39445. } else {
  39446. e.mergeUniform({ penumbraSize: Lt.penumbraSize }),
  39447. this.color === void 0 && (this.color = new Ut(5526619)),
  39448. this.color.analyze(e, { slot: 'color' }),
  39449. this.shadingAlpha.analyze(e),
  39450. this.shadingBlend.analyze(e),
  39451. this.afterColor && this.afterColor.analyze(e, { slot: 'afterColor' }),
  39452. this.alpha && this.alpha.analyze(e);
  39453. let i = this.color.flow(e, 'c', { slot: 'color' }),
  39454. r = this.emissive.flow(e, 'c', { slot: 'emissive' }),
  39455. s = this.emissiveIntensity.flow(e, 'f', { slot: 'emissive' }),
  39456. n = this.shadingAlpha.flow(e, 'f'),
  39457. a = this.shadingBlend.flow(e, 'i'),
  39458. o = this.afterColor ? this.afterColor.flow(e, 'c', { slot: 'afterColor' }) : void 0,
  39459. l = this.alpha ? this.alpha.flow(e, 'f') : void 0;
  39460. (e.requires.transparent = l !== void 0),
  39461. e.addParsCode(
  39462. [
  39463. `uniform float penumbraSize[${5}];`,
  39464. 'varying vec3 vViewPosition;',
  39465. 'varying vec3 vWPosition;',
  39466. 'varying vec3 vLightFront;',
  39467. 'varying vec3 vIndirectFront;',
  39468. '#ifndef DOUBLE_SIDED',
  39469. ' #define DOUBLE_SIDED',
  39470. '#endif',
  39471. '#include <normal_pars_fragment>',
  39472. '#ifdef DOUBLE_SIDED',
  39473. '\tvarying vec3 vLightBack;',
  39474. '\tvarying vec3 vIndirectBack;',
  39475. '#endif',
  39476. '#include <bsdfs>',
  39477. '#include <lights_pars_begin>',
  39478. '#include <fog_pars_fragment>',
  39479. '#include <shadowmap_pars_fragment>',
  39480. '#include <shadowmask_pars_fragment>',
  39481. '#include <clipping_planes_pars_fragment>',
  39482. '#include <dithering_pars_fragment>'
  39483. ].join(`
  39484. `)
  39485. );
  39486. let h = [
  39487. '#include <normal_fragment_begin>',
  39488. `
  39489. // NOTE: gl_FrontFacing alternative using face normal estimation.
  39490. vec3 viewdx = dFdx(vViewPosition);
  39491. vec3 viewdy = dFdy(vViewPosition);
  39492. vec3 faceNormal = normalize(cross(viewdx, viewdy));
  39493. bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);
  39494. `,
  39495. '#include <clipping_planes_fragment>'
  39496. ];
  39497. h.push(
  39498. i.code,
  39499. 'vec3 diffuseColor = ' + i.result + ';',
  39500. 'ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );'
  39501. ),
  39502. l && h.push(l.code, '#ifdef ALPHATEST', 'if ( ' + l.result + ' <= ALPHATEST ) discard;', '#endif'),
  39503. h.push(
  39504. '#ifdef DOUBLE_SIDED',
  39505. '\treflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;',
  39506. '#else',
  39507. '\treflectedLight.indirectDiffuse += vIndirectFront;',
  39508. '#endif',
  39509. '#include <lightmap_fragment>',
  39510. 'reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );',
  39511. '#ifdef DOUBLE_SIDED',
  39512. '\treflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;',
  39513. '#else',
  39514. '\treflectedLight.directDiffuse = vLightFront;',
  39515. '#endif',
  39516. 'reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();'
  39517. ),
  39518. r && h.push(r.code, 'reflectedLight.directDiffuse += ' + r.result + ' * ' + s.result + ';'),
  39519. h.push('vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;'),
  39520. h.push(`
  39521. if (outgoingLight != diffuseColor) {
  39522. float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
  39523. accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * lightAccu;
  39524. outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result}, ${a.result} );
  39525. }
  39526. `),
  39527. o && h.push(o.code, `outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`),
  39528. l
  39529. ? h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`)
  39530. : h.push('gl_FragColor = vec4( outgoingLight, 1.0 );'),
  39531. h.push('#include <encodings_fragment>', '#include <fog_fragment>', '#include <dithering_fragment>'),
  39532. (t = h.join(`
  39533. `));
  39534. }
  39535. return t;
  39536. }
  39537. },
  39538. ik = class extends Bn {
  39539. constructor() {
  39540. super('phong'),
  39541. (this.nodeType = 'Phong'),
  39542. (this.color = new Ut(5526619)),
  39543. (this.specular = new Ut(1118481)),
  39544. (this.shininess = new Pe(30)),
  39545. (this.shadingAlpha = new Pe(1)),
  39546. (this.shadingBlend = new xt(0));
  39547. }
  39548. get category() {
  39549. return 'phong';
  39550. }
  39551. build(e) {
  39552. let t;
  39553. if ((e.define('PHONG'), (e.requires.lights = !0), (e.extensions.derivatives = !0), e.isShader('vertex'))) {
  39554. let i = this.position ? this.position.analyzeAndFlow(e, 'v3', { cache: 'position' }) : void 0;
  39555. e.mergeUniform(qo.merge([ge.fog, ge.lights])),
  39556. e.addParsCode(
  39557. [
  39558. 'varying vec3 vViewPosition;',
  39559. 'varying vec3 vWPosition;',
  39560. '#include <fog_pars_vertex>',
  39561. '#include <normal_pars_vertex>',
  39562. '#include <shadowmap_pars_vertex>',
  39563. '#include <clipping_planes_pars_vertex>'
  39564. ].join(`
  39565. `)
  39566. );
  39567. let r = [
  39568. '#include <beginnormal_vertex>',
  39569. `
  39570. #ifndef USE_LAYER_DISPLACE
  39571. #include <defaultnormal_vertex>
  39572. #endif
  39573. vec3 displaced_position = position;
  39574. vec3 displaced_normal = normal;
  39575. #ifdef USE_LAYER_DISPLACE
  39576. vec3 transformed;
  39577. vec3 transformedNormal;
  39578. #endif
  39579. `,
  39580. '#include <normal_vertex>',
  39581. `
  39582. #ifndef USE_LAYER_DISPLACE
  39583. #include <begin_vertex>
  39584. #endif
  39585. `
  39586. ];
  39587. i && r.push(i.code, i.result ? 'displaced_position = ' + i.result + ';' : ''),
  39588. r.push(
  39589. 'transformed = displaced_position;',
  39590. 'transformedNormal = normalMatrix * displaced_normal;',
  39591. '#ifndef FLAT_SHADED',
  39592. ' vNormal = transformedNormal;',
  39593. '#endif'
  39594. ),
  39595. r.push(
  39596. '\t#include <project_vertex>',
  39597. '\t#include <clipping_planes_vertex>',
  39598. '\tvViewPosition = - mvPosition.xyz;',
  39599. '\t#include <worldpos_vertex>',
  39600. '\t#include <shadowmap_vertex>',
  39601. '\t#include <fog_vertex>'
  39602. ),
  39603. r.push('vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;'),
  39604. (t = r.join(`
  39605. `));
  39606. } else {
  39607. e.mergeUniform({ penumbraSize: Lt.penumbraSize }),
  39608. this.color === void 0 && (this.color = new Ut(5526619)),
  39609. this.color.analyze(e, { slot: 'color' }),
  39610. this.specular.analyze(e),
  39611. this.shininess.analyze(e),
  39612. this.shadingAlpha.analyze(e),
  39613. this.shadingBlend.analyze(e),
  39614. this.afterColor && this.afterColor.analyze(e, { slot: 'afterColor' }),
  39615. this.alpha && this.alpha.analyze(e);
  39616. let i = this.color.flow(e, 'c', { slot: 'color' }),
  39617. r = this.specular.flow(e, 'c'),
  39618. s = this.shininess.flow(e, 'f'),
  39619. n = this.shadingAlpha.flow(e, 'f'),
  39620. a = this.shadingBlend.flow(e, 'i'),
  39621. o = this.afterColor ? this.afterColor.flow(e, 'c', { slot: 'afterColor' }) : void 0,
  39622. l = this.alpha ? this.alpha.flow(e, 'f') : void 0;
  39623. (e.requires.transparent = l !== void 0),
  39624. e.addParsCode(
  39625. [
  39626. 'varying vec3 vWPosition;',
  39627. 'uniform vec3 emissive;',
  39628. `uniform float penumbraSize[${5}];`,
  39629. '#include <normal_pars_fragment>',
  39630. '#include <fog_pars_fragment>',
  39631. '#include <bsdfs>',
  39632. '#include <lights_pars_begin>',
  39633. '#include <lights_phong_pars_fragment>',
  39634. '#include <shadowmap_pars_fragment>',
  39635. '#include <dithering_pars_fragment>'
  39636. ].join(`
  39637. `)
  39638. );
  39639. let h = [
  39640. '#include <normal_fragment_begin>',
  39641. `
  39642. // NOTE: gl_FrontFacing alternative using face normal estimation.
  39643. vec3 viewdx = dFdx(vViewPosition);
  39644. vec3 viewdy = dFdy(vViewPosition);
  39645. vec3 faceNormal = normalize(cross(viewdx,viewdy));
  39646. if (dot(normal, faceNormal) < 0.0) {
  39647. normal *= -1.0;
  39648. }
  39649. `,
  39650. '\tBlinnPhongMaterial material;'
  39651. ];
  39652. h.push(
  39653. i.code,
  39654. '\tvec3 diffuseColor = ' + i.result + ';',
  39655. '\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );',
  39656. '\tvec3 totalEmissiveRadiance = emissive;',
  39657. r.code,
  39658. '\tvec3 specular = ' + r.result + ';',
  39659. s.code,
  39660. '\tfloat shininess = max( 0.0001, ' + s.result + ' );',
  39661. '\tfloat specularStrength = 1.0;'
  39662. ),
  39663. l && h.push(l.code, '#ifdef ALPHATEST', 'if ( ' + l.result + ' <= ALPHATEST ) discard;', '#endif'),
  39664. h.push('material.diffuseColor = diffuseColor;'),
  39665. h.push(
  39666. 'material.specularColor = specular;',
  39667. 'material.specularShininess = shininess;',
  39668. 'material.specularStrength = specularStrength;',
  39669. '#include <lights_fragment_begin>',
  39670. '#include <lights_fragment_end>'
  39671. ),
  39672. h.push(
  39673. 'vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;'
  39674. ),
  39675. h.push(`
  39676. if (outgoingLight != diffuseColor) {
  39677. float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
  39678. accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * lightAccu;
  39679. outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result}, ${a.result} );
  39680. }
  39681. `),
  39682. o && h.push(o.code, `outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`),
  39683. l
  39684. ? h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`)
  39685. : h.push('gl_FragColor = vec4( outgoingLight, 1.0 );'),
  39686. h.push('#include <encodings_fragment>', '#include <fog_fragment>', '#include <dithering_fragment>'),
  39687. (t = h.join(`
  39688. `));
  39689. }
  39690. return t;
  39691. }
  39692. },
  39693. rk = class extends Bn {
  39694. constructor() {
  39695. super('standard'),
  39696. (this.nodeType = 'Standard'),
  39697. (this.color = new Ut(5526619)),
  39698. (this.roughness = new Pe(0.3)),
  39699. (this.metalness = new Pe(0)),
  39700. (this.reflectivity = new Pe(0.5)),
  39701. (this.shadingAlpha = new Pe(1)),
  39702. (this.shadingBlend = new xt(0));
  39703. }
  39704. get category() {
  39705. return 'physical';
  39706. }
  39707. build(e) {
  39708. let t;
  39709. if (
  39710. (e.define('STANDARD'),
  39711. (e.requires.lights = !0),
  39712. (e.extensions.derivatives = !0),
  39713. (e.extensions.shaderTextureLOD = !0),
  39714. e.isShader('vertex'))
  39715. ) {
  39716. let i = this.position ? this.position.analyzeAndFlow(e, 'v3', { cache: 'position' }) : void 0;
  39717. e.mergeUniform(qo.merge([ge.fog, ge.lights])),
  39718. ge.LTC_1 && ((e.uniforms.ltc_1 = { value: void 0 }), (e.uniforms.ltc_2 = { value: void 0 })),
  39719. e.addParsCode(
  39720. [
  39721. 'varying vec3 vViewPosition;',
  39722. 'varying vec3 vWPosition;',
  39723. '#include <fog_pars_vertex>',
  39724. '#include <normal_pars_vertex>',
  39725. '#include <shadowmap_pars_vertex>',
  39726. '#include <clipping_planes_pars_vertex>'
  39727. ].join(`
  39728. `)
  39729. );
  39730. let r = [
  39731. '#include <beginnormal_vertex>',
  39732. `
  39733. #if !defined( USE_LAYER_DISPLACE )
  39734. #include <defaultnormal_vertex>
  39735. #endif
  39736. vec3 displaced_position = position;
  39737. vec3 displaced_normal = normal;
  39738. #if defined( USE_LAYER_DISPLACE )
  39739. vec3 transformed;
  39740. vec3 transformedNormal;
  39741. #endif
  39742. `,
  39743. '#include <normal_vertex>',
  39744. `
  39745. #if !defined( USE_LAYER_DISPLACE )
  39746. #include <begin_vertex>
  39747. #endif /* !USE_LAYER_DISPLACE */
  39748. `
  39749. ];
  39750. i && r.push(i.code, i.result ? 'displaced_position = ' + i.result + ';' : ''),
  39751. r.push(
  39752. 'transformed = displaced_position;',
  39753. 'transformedNormal = normalMatrix * displaced_normal;',
  39754. '#ifndef FLAT_SHADED',
  39755. ' vNormal = transformedNormal;',
  39756. '#endif'
  39757. ),
  39758. r.push(
  39759. '#include <project_vertex>',
  39760. '#include <fog_vertex>',
  39761. '#include <clipping_planes_vertex>',
  39762. '\tvViewPosition = - mvPosition.xyz;',
  39763. '#include <worldpos_vertex>',
  39764. '#include <shadowmap_vertex>'
  39765. ),
  39766. r.push('vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;'),
  39767. (t = r.join(`
  39768. `));
  39769. } else {
  39770. e.mergeUniform({ penumbraSize: Lt.penumbraSize });
  39771. let i = { gamma: !0 };
  39772. this.color === void 0 && (this.color = new Ut(5526619)),
  39773. this.color.analyze(e, { slot: 'color', context: i }),
  39774. this.roughness.analyze(e),
  39775. this.metalness.analyze(e),
  39776. this.shadingAlpha.analyze(e),
  39777. this.shadingBlend.analyze(e),
  39778. this.afterColor && this.afterColor.analyze(e, { slot: 'afterColor' }),
  39779. this.alpha && this.alpha.analyze(e),
  39780. this.reflectivity && this.reflectivity.analyze(e);
  39781. let r = this.color.flow(e, 'c', { slot: 'color', context: i }),
  39782. s = this.roughness.flow(e, 'f'),
  39783. n = this.metalness.flow(e, 'f'),
  39784. a = this.shadingAlpha.flow(e, 'f'),
  39785. o = this.shadingBlend.flow(e, 'i'),
  39786. l = this.afterColor ? this.afterColor.flow(e, 'c', { slot: 'afterColor' }) : void 0,
  39787. h = this.alpha ? this.alpha.flow(e, 'f') : void 0,
  39788. u = this.reflectivity ? this.reflectivity.flow(e, 'f') : void 0;
  39789. (e.requires.transparent = h !== void 0),
  39790. e.addParsCode(
  39791. [
  39792. 'varying vec3 vViewPosition;',
  39793. 'varying vec3 vWPosition;',
  39794. `uniform float penumbraSize[${5}];`,
  39795. '#include <normal_pars_fragment>',
  39796. '#include <dithering_pars_fragment>',
  39797. '#include <fog_pars_fragment>',
  39798. '#include <bsdfs>',
  39799. '#include <lights_pars_begin>',
  39800. '#include <lights_physical_pars_fragment>',
  39801. '#include <shadowmap_pars_fragment>'
  39802. ].join(`
  39803. `)
  39804. );
  39805. let c = [
  39806. '#include <clipping_planes_fragment>',
  39807. '\t#include <normal_fragment_begin>',
  39808. `
  39809. // NOTE: gl_FrontFacing alternative using face normal estimation.
  39810. vec3 viewdx = dFdx(vViewPosition);
  39811. vec3 viewdy = dFdy(vViewPosition);
  39812. vec3 faceNormal = normalize(cross(viewdx,viewdy));
  39813. if (dot(normal, faceNormal) < 0.0) {
  39814. normal *= -1.0;
  39815. }
  39816. `,
  39817. '\tPhysicalMaterial material;',
  39818. '\tmaterial.diffuseColor = vec3( 1.0 );'
  39819. ];
  39820. c.push(
  39821. r.code,
  39822. '\tvec3 diffuseColor = ' + r.result + ';',
  39823. '\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );',
  39824. s.code,
  39825. '\tfloat roughnessFactor = ' + s.result + ';',
  39826. n.code,
  39827. '\tfloat metalnessFactor = ' + n.result + ';'
  39828. ),
  39829. h && c.push(h.code, '#ifdef ALPHATEST', '\tif ( ' + h.result + ' <= ALPHATEST ) discard;', '#endif'),
  39830. c.push(
  39831. 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );',
  39832. 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );'
  39833. ),
  39834. c.push(
  39835. 'material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );',
  39836. 'material.roughness = max( roughnessFactor, 0.0525 );',
  39837. 'material.roughness += geometryRoughness;',
  39838. 'material.roughness = min( material.roughness, 1.0 );',
  39839. 'material.roughness = clamp( roughnessFactor, 0.04, 1.0 );'
  39840. ),
  39841. u
  39842. ? c.push(u.code, 'material.specularColor = mix( vec3( 0.16 * pow2( ' + u.result + ' ) ), diffuseColor, metalnessFactor );')
  39843. : c.push('material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );'),
  39844. c.push('#include <lights_fragment_begin>'),
  39845. c.push('#include <lights_fragment_end>'),
  39846. c.push(
  39847. 'vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;'
  39848. ),
  39849. c.push(`
  39850. if (outgoingLight != diffuseColor) {
  39851. float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
  39852. accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
  39853. outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${o.result} );
  39854. }
  39855. `),
  39856. l && c.push(l.code, `outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),
  39857. h
  39858. ? c.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`)
  39859. : c.push('gl_FragColor = vec4( outgoingLight, 1.0 );'),
  39860. c.push('#include <encodings_fragment>', '#include <fog_fragment>', '#include <dithering_fragment>'),
  39861. (t = c.join(`
  39862. `));
  39863. }
  39864. return t;
  39865. }
  39866. },
  39867. sk = class extends Bn {
  39868. constructor() {
  39869. super('toon'),
  39870. (this.nodeType = 'Toon'),
  39871. (this.color = new Ut(5526619)),
  39872. (this.specular = new Ut(1118481)),
  39873. (this.shininess = new Pe(30)),
  39874. (this.shadingAlpha = new Pe(1)),
  39875. (this.shadingBlend = new xt(0));
  39876. }
  39877. get category() {
  39878. return 'toon';
  39879. }
  39880. build(e) {
  39881. let t;
  39882. if ((e.define('TOON'), (e.requires.lights = !0), (e.extensions.derivatives = !0), e.isShader('vertex'))) {
  39883. let i = this.position ? this.position.analyzeAndFlow(e, 'v3', { cache: 'position' }) : void 0;
  39884. e.mergeUniform(qo.merge([ge.fog, ge.lights])),
  39885. e.addParsCode(
  39886. [
  39887. 'varying vec3 vViewPosition;',
  39888. 'varying vec3 vWPosition;',
  39889. '#include <fog_pars_vertex>',
  39890. '#include <normal_pars_vertex>',
  39891. '#include <shadowmap_pars_vertex>',
  39892. '#include <clipping_planes_pars_vertex>'
  39893. ].join(`
  39894. `)
  39895. );
  39896. let r = [
  39897. '#include <beginnormal_vertex>',
  39898. `
  39899. #ifndef USE_LAYER_DISPLACE
  39900. #include <defaultnormal_vertex>
  39901. #endif
  39902. vec3 displaced_position = position;
  39903. vec3 displaced_normal = normal;
  39904. #ifdef USE_LAYER_DISPLACE
  39905. vec3 transformed;
  39906. vec3 transformedNormal;
  39907. #endif
  39908. `,
  39909. '#include <normal_vertex>',
  39910. `
  39911. #ifndef USE_LAYER_DISPLACE
  39912. #include <begin_vertex>
  39913. #endif
  39914. `
  39915. ];
  39916. i && r.push(i.code, i.result ? 'displaced_position = ' + i.result + ';' : ''),
  39917. r.push(
  39918. 'transformed = displaced_position;',
  39919. 'transformedNormal = normalMatrix * displaced_normal;',
  39920. '#ifndef FLAT_SHADED',
  39921. ' vNormal = transformedNormal;',
  39922. '#endif'
  39923. ),
  39924. r.push(
  39925. '\t#include <project_vertex>',
  39926. '\t#include <fog_vertex>',
  39927. '\t#include <clipping_planes_vertex>',
  39928. '\tvViewPosition = - mvPosition.xyz;',
  39929. '\t#include <worldpos_vertex>',
  39930. '\t#include <shadowmap_vertex>',
  39931. '\t#include <fog_vertex>'
  39932. ),
  39933. r.push('vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;'),
  39934. (t = r.join(`
  39935. `));
  39936. } else {
  39937. e.mergeUniform({ penumbraSize: Lt.penumbraSize }),
  39938. this.color === void 0 && (this.color = new Ut(5526619)),
  39939. this.color.analyze(e, { slot: 'color' }),
  39940. this.specular.analyze(e),
  39941. this.shininess.analyze(e),
  39942. this.shadingAlpha.analyze(e),
  39943. this.shadingBlend.analyze(e),
  39944. this.afterColor && this.afterColor.analyze(e, { slot: 'afterColor' }),
  39945. this.alpha && this.alpha.analyze(e);
  39946. let i = this.color.flow(e, 'c', { slot: 'color' }),
  39947. r = this.specular.flow(e, 'c'),
  39948. s = this.shininess.flow(e, 'f'),
  39949. n = this.shadingAlpha.flow(e, 'f'),
  39950. a = this.shadingBlend.flow(e, 'i'),
  39951. o = this.afterColor ? this.afterColor.flow(e, 'c', { slot: 'afterColor' }) : void 0,
  39952. l = this.alpha ? this.alpha.flow(e, 'f') : void 0;
  39953. (e.requires.transparent = l !== void 0),
  39954. e.addParsCode(
  39955. [
  39956. `uniform float penumbraSize[${5}];`,
  39957. 'varying vec3 vWPosition;',
  39958. '#include <normal_pars_fragment>',
  39959. '#include <gradientmap_pars_fragment>',
  39960. '#include <fog_pars_fragment>',
  39961. '#include <bsdfs>',
  39962. '#include <lights_pars_begin>',
  39963. '#include <dithering_pars_fragment>',
  39964. `
  39965. varying vec3 vViewPosition;
  39966. struct ToonMaterial {
  39967. vec3 diffuseColor;
  39968. vec3 specularColor;
  39969. float specularShininess;
  39970. float specularStrength;
  39971. };
  39972. void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  39973. vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
  39974. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  39975. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
  39976. }
  39977. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  39978. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  39979. }
  39980. #define RE_Direct RE_Direct_Toon
  39981. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
  39982. #define Material_LightProbeLOD( material ) (0)
  39983. `,
  39984. '#include <shadowmap_pars_fragment>',
  39985. '#include <bumpmap_pars_fragment>',
  39986. '#include <normalmap_pars_fragment>'
  39987. ].join(`
  39988. `)
  39989. );
  39990. let h = [
  39991. '#include <normal_fragment_begin>',
  39992. `
  39993. // NOTE: gl_FrontFacing alternative using face normal estimation.
  39994. vec3 viewdx = dFdx(vViewPosition);
  39995. vec3 viewdy = dFdy(vViewPosition);
  39996. vec3 faceNormal = normalize(cross(viewdx,viewdy));
  39997. if (dot(normal, faceNormal) < 0.0) {
  39998. normal *= -1.0;
  39999. }
  40000. `,
  40001. '\tToonMaterial material;'
  40002. ];
  40003. h.push(
  40004. i.code,
  40005. '\tvec3 diffuseColor = ' + i.result + ';',
  40006. '\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );',
  40007. r.code,
  40008. '\tvec3 specular = ' + r.result + ';',
  40009. s.code,
  40010. '\tfloat shininess = max( 0.0001, ' + s.result + ' );',
  40011. '\tfloat specularStrength = 1.0;'
  40012. ),
  40013. l && h.push(l.code, '#ifdef ALPHATEST', 'if ( ' + l.result + ' <= ALPHATEST ) discard;', '#endif'),
  40014. h.push('material.diffuseColor = diffuseColor;'),
  40015. h.push(
  40016. 'material.specularColor = specular;',
  40017. 'material.specularShininess = shininess;',
  40018. 'material.specularStrength = specularStrength;',
  40019. '#include <lights_fragment_begin>',
  40020. '#include <lights_fragment_end>'
  40021. ),
  40022. h.push('vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;'),
  40023. h.push(`
  40024. if (outgoingLight != diffuseColor) {
  40025. float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
  40026. accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * lightAccu;
  40027. outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result}, ${a.result} );
  40028. }
  40029. `),
  40030. o && h.push(o.code, `outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`),
  40031. l
  40032. ? h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`)
  40033. : h.push('gl_FragColor = vec4( outgoingLight, 1.0 );'),
  40034. h.push('#include <encodings_fragment>', '#include <fog_fragment>', '#include <dithering_fragment>'),
  40035. (t = h.join(`
  40036. `));
  40037. }
  40038. return t;
  40039. }
  40040. },
  40041. Ol = class extends or {
  40042. constructor(e) {
  40043. super('b'), (this.nodeType = 'Bool'), (this.value = e ?? !1);
  40044. }
  40045. generateReadonly(e, t, i, r) {
  40046. return e.format(this.value ? 'true' : 'false', r, t);
  40047. }
  40048. },
  40049. GA = class extends or {
  40050. constructor(e) {
  40051. super('m3'), (this.nodeType = 'Matrix3'), (this.value = e ?? new Ai());
  40052. }
  40053. generateReadonly(e, t, i, r, s, n) {
  40054. return e.format('mat3(' + this.value.elements.join(', ') + ')', r, t);
  40055. }
  40056. get elements() {
  40057. return this.value.elements;
  40058. }
  40059. set elements(e) {
  40060. this.value.fromArray(e);
  40061. }
  40062. },
  40063. ta = class extends or {
  40064. constructor(e = 1, t) {
  40065. super('v4[]'),
  40066. (this.nodeType = 'Vector4Array'),
  40067. (this.size = e),
  40068. (this.value = Array.isArray(t) ? t : t instanceof $e ? new Array(e).fill(t) : new Array(e).fill(new $e(0)));
  40069. }
  40070. },
  40071. cv = ((e) => (
  40072. (e.SIMPLEX = 'simplex3d'),
  40073. (e.SIMPLEX_FRACTAL = 'simplex3dFractal'),
  40074. (e.ASHIMA = 'simplexAshima'),
  40075. (e.FBM = 'fbm'),
  40076. (e.PERLIN = 'perlin'),
  40077. e
  40078. ))(cv || {}),
  40079. wr = (function () {
  40080. let e = new Re(`vec3 random3(vec3 c) {
  40081. float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
  40082. vec3 r;
  40083. r.z = fract(512.0*j);
  40084. j *= .125;
  40085. r.x = fract(512.0*j);
  40086. j *= .125;
  40087. r.y = fract(512.0*j);
  40088. return r-0.5;
  40089. }`),
  40090. t = new Re(
  40091. `float simplex3d(vec3 p) {
  40092. vec3 s = floor(p + dot(p, vec3(F3)));
  40093. vec3 x = p - s + dot(s, vec3(G3));
  40094. vec3 e = step(vec3(0.0), x - x.yzx);
  40095. vec3 i1 = e*(1.0 - e.zxy);
  40096. vec3 i2 = 1.0 - e.zxy*(1.0 - e);
  40097. vec3 x1 = x - i1 + G3;
  40098. vec3 x2 = x - i2 + 2.0*G3;
  40099. vec3 x3 = x - 1.0 + 3.0*G3;
  40100. vec4 w, d;
  40101. w.x = dot(x, x);
  40102. w.y = dot(x1, x1);
  40103. w.z = dot(x2, x2);
  40104. w.w = dot(x3, x3);
  40105. w = max(0.6 - w, 0.0);
  40106. d.x = dot(random3(s), x);
  40107. d.y = dot(random3(s + i1), x1);
  40108. d.z = dot(random3(s + i2), x2);
  40109. d.w = dot(random3(s + 1.0), x3);
  40110. w *= w;
  40111. w *= w;
  40112. d *= w;
  40113. return dot(d, vec4(52.0));
  40114. }`,
  40115. [e]
  40116. );
  40117. (t.keywords.F3 = new vt('float F3 0.3333333')), (t.keywords.G3 = new vt('float G3 0.1666667'));
  40118. let i = new Re(
  40119. `float simplex3dFractal(vec3 m) {
  40120. mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
  40121. mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
  40122. mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
  40123. return 0.5333333 * simplex3d(m * rot1)
  40124. + 0.2666667 * simplex3d(2.0 * m * rot2)
  40125. + 0.1333333 * simplex3d(4.0 * m * rot3)
  40126. + 0.0666667 * simplex3d(8.0 * m);
  40127. }`,
  40128. [t]
  40129. ),
  40130. r = new Re('vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}'),
  40131. s = new Re('vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}'),
  40132. n = new Re(
  40133. `float simplexAshima(vec3 v) {
  40134. const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
  40135. const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
  40136. vec3 i = floor(v + dot(v, C.yyy) );
  40137. vec3 x0 = v - i + dot(i, C.xxx) ;
  40138. vec3 g = step(x0.yzx, x0.xyz);
  40139. vec3 l = 1.0 - g;
  40140. vec3 i1 = min( g.xyz, l.zxy );
  40141. vec3 i2 = max( g.xyz, l.zxy );
  40142. vec3 x1 = x0 - i1 + 1.0 * C.xxx;
  40143. vec3 x2 = x0 - i2 + 2.0 * C.xxx;
  40144. vec3 x3 = x0 - 1. + 3.0 * C.xxx;
  40145. i = mod(i, 289.0 );
  40146. vec4 p = permute( permute( permute(
  40147. i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
  40148. + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
  40149. + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
  40150. float n_ = 1.0/7.0; // N=7
  40151. vec3 ns = n_ * D.wyz - D.xzx;
  40152. vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N)
  40153. vec4 x_ = floor(j * ns.z);
  40154. vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
  40155. vec4 x = x_ *ns.x + ns.yyyy;
  40156. vec4 y = y_ *ns.x + ns.yyyy;
  40157. vec4 h = 1.0 - abs(x) - abs(y);
  40158. vec4 b0 = vec4( x.xy, y.xy );
  40159. vec4 b1 = vec4( x.zw, y.zw );
  40160. vec4 s0 = floor(b0)*2.0 + 1.0;
  40161. vec4 s1 = floor(b1)*2.0 + 1.0;
  40162. vec4 sh = -step(h, vec4(0.0));
  40163. vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
  40164. vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
  40165. vec3 p0 = vec3(a0.xy,h.x);
  40166. vec3 p1 = vec3(a0.zw,h.y);
  40167. vec3 p2 = vec3(a1.xy,h.z);
  40168. vec3 p3 = vec3(a1.zw,h.w);
  40169. vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
  40170. p0 *= norm.x;
  40171. p1 *= norm.y;
  40172. p2 *= norm.z;
  40173. p3 *= norm.w;
  40174. vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
  40175. m = m * m;
  40176. return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
  40177. dot(p2,x2), dot(p3,x3) ) );
  40178. }`,
  40179. [r, s]
  40180. ),
  40181. a = new Re('vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}'),
  40182. o = new Re('vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}', [a]),
  40183. l = new Re(
  40184. `float noise(vec3 p){
  40185. vec3 a = floor(p);
  40186. vec3 d = p - a;
  40187. d = d * d * (3.0 - 2.0 * d);
  40188. vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);
  40189. vec4 k1 = perm(b.xyxy);
  40190. vec4 k2 = perm(k1.xyxy + b.zzww);
  40191. vec4 c = k2 + a.zzzz;
  40192. vec4 k3 = perm(c);
  40193. vec4 k4 = perm(c + 1.0);
  40194. vec4 o1 = fract(k3 * (1.0 / 41.0));
  40195. vec4 o2 = fract(k4 * (1.0 / 41.0));
  40196. vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
  40197. vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
  40198. return o4.y * d.y + o4.x * (1.0 - d.y);
  40199. }`,
  40200. [o]
  40201. ),
  40202. h = new Re(
  40203. `float fbm(vec3 x) {
  40204. float v = 0.0;
  40205. float a = 0.5;
  40206. vec3 shift = vec3(100);
  40207. for (int i = 0; i < NUM_OCTAVES; ++i) {
  40208. v += a * noise(x);
  40209. x = x * 2.0 + shift;
  40210. a *= 0.5;
  40211. }
  40212. return v;
  40213. }`,
  40214. [l]
  40215. );
  40216. h.keywords.NUM_OCTAVES = new vt(`int NUM_OCTAVES ${5}`);
  40217. let u = new Re('vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}'),
  40218. c = new Re(
  40219. `float perlin(vec3 P){
  40220. vec3 Pi0 = floor(P);
  40221. vec3 Pi1 = Pi0 + vec3(1.0);
  40222. Pi0 = mod(Pi0, 289.0);
  40223. Pi1 = mod(Pi1, 289.0);
  40224. vec3 Pf0 = fract(P);
  40225. vec3 Pf1 = Pf0 - vec3(1.0);
  40226. vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
  40227. vec4 iy = vec4(Pi0.yy, Pi1.yy);
  40228. vec4 iz0 = Pi0.zzzz;
  40229. vec4 iz1 = Pi1.zzzz;
  40230. vec4 ixy = permute(permute(ix) + iy);
  40231. vec4 ixy0 = permute(ixy + iz0);
  40232. vec4 ixy1 = permute(ixy + iz1);
  40233. vec4 gx0 = ixy0 / 7.0;
  40234. vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;
  40235. gx0 = fract(gx0);
  40236. vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
  40237. vec4 sz0 = step(gz0, vec4(0.0));
  40238. gx0 -= sz0 * (step(0.0, gx0) - 0.5);
  40239. gy0 -= sz0 * (step(0.0, gy0) - 0.5);
  40240. vec4 gx1 = ixy1 / 7.0;
  40241. vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;
  40242. gx1 = fract(gx1);
  40243. vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
  40244. vec4 sz1 = step(gz1, vec4(0.0));
  40245. gx1 -= sz1 * (step(0.0, gx1) - 0.5);
  40246. gy1 -= sz1 * (step(0.0, gy1) - 0.5);
  40247. vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
  40248. vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
  40249. vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
  40250. vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
  40251. vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
  40252. vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
  40253. vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
  40254. vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
  40255. vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
  40256. g000 *= norm0.x;
  40257. g010 *= norm0.y;
  40258. g100 *= norm0.z;
  40259. g110 *= norm0.w;
  40260. vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
  40261. g001 *= norm1.x;
  40262. g011 *= norm1.y;
  40263. g101 *= norm1.z;
  40264. g111 *= norm1.w;
  40265. float n000 = dot(g000, Pf0);
  40266. float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
  40267. float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
  40268. float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
  40269. float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
  40270. float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
  40271. float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
  40272. float n111 = dot(g111, Pf1);
  40273. vec3 fade_xyz = fade(Pf0);
  40274. vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
  40275. vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
  40276. float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
  40277. return 2.2 * n_xyz;
  40278. }`,
  40279. [r, s, u]
  40280. );
  40281. return { simplex: t, simplexFractal: i, simplexAshima: n, fbm: h, perlin: c };
  40282. })(),
  40283. VA = class extends St {
  40284. constructor(e, t, i, r, s, n, a, o, l, h, u, c) {
  40285. super('v3'),
  40286. (this.nodeType = 'Noise'),
  40287. (this.scale = e),
  40288. (this.size = t),
  40289. (this.move = i),
  40290. (this.fA = r),
  40291. (this.fB = s),
  40292. (this.distortion = n),
  40293. (this.colorA = a),
  40294. (this.colorB = o),
  40295. (this.colorC = l),
  40296. (this.colorD = h),
  40297. (this.alpha = u),
  40298. (this.noiseType = c),
  40299. (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`);
  40300. }
  40301. generate(e, t, i, r, s) {
  40302. e.require('uv'), (e.requires.uv = [!0]), e.addFragmentVariable(this.calpha, 'float');
  40303. let n = Object.values(cv)[this.noiseType.value],
  40304. a = new Re(
  40305. `vec3 ${n}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, float alpha, out float calpha) {
  40306. vec3 st = position / size;
  40307. st /= scale;
  40308. vec3 q = vec3(${n}(st),
  40309. ${n}(st + vec3(1.0)),
  40310. ${n}(st + vec3(1.0)));
  40311. vec3 r = vec3(${n}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
  40312. ${n}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
  40313. ${n}(st * q));
  40314. float f = ${n}(st + r);
  40315. vec4 color;
  40316. color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
  40317. color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
  40318. color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));
  40319. float lalpha = alpha * color.a;
  40320. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  40321. accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
  40322. return clamp(color, 0.0, 1.0).rgb;
  40323. }`,
  40324. [wr.simplex, wr.simplexFractal, wr.simplexAshima, wr.fbm, wr.perlin]
  40325. ),
  40326. o = e.include(a),
  40327. l = [];
  40328. return (
  40329. l.push(this.scale.build(e, 'f')),
  40330. l.push(this.size.build(e, 'v3')),
  40331. l.push(this.move.build(e, 'f')),
  40332. l.push(this.fA.build(e, 'v2')),
  40333. l.push(this.fB.build(e, 'v2')),
  40334. l.push(this.distortion.build(e, 'v2')),
  40335. l.push(this.colorA.build(e, 'v4')),
  40336. l.push(this.colorB.build(e, 'v4')),
  40337. l.push(this.colorC.build(e, 'v4')),
  40338. l.push(this.colorD.build(e, 'v4')),
  40339. l.push(this.alpha.build(e, 'f')),
  40340. l.push(this.calpha),
  40341. e.format(o + '(' + l.join(',') + ')', this.getType(e), t)
  40342. );
  40343. }
  40344. };
  40345. VA.numOctaves = 5;
  40346. var HA = class extends St {
  40347. constructor(e, t, i, r, s, n, a) {
  40348. super('v3'),
  40349. (this.nodeType = 'Fresnel'),
  40350. (this.color = e),
  40351. (this.bias = t),
  40352. (this.scale = i),
  40353. (this.intensity = r),
  40354. (this.factor = s),
  40355. (this.alpha = n),
  40356. (this.mode = a),
  40357. (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`);
  40358. }
  40359. generate(e, t) {
  40360. if ((e.require('vWorldViewDir'), e.require('worldNormal'), e.isShader('fragment'))) {
  40361. e.addFragmentVariable(this.calpha, 'float');
  40362. let i = e.include(HA.Nodes.fresnel),
  40363. r = [];
  40364. return (
  40365. r.push(this.color.build(e, 'c')),
  40366. r.push(this.bias.build(e, 'f')),
  40367. r.push(this.scale.build(e, 'f')),
  40368. r.push(this.intensity.build(e, 'f')),
  40369. r.push(this.factor.build(e, 'f')),
  40370. r.push(this.alpha.build(e, 'f')),
  40371. r.push(this.mode.build(e, 'i')),
  40372. r.push(this.calpha),
  40373. e.format(i + '(' + r.join(',') + ')', this.getType(e), t)
  40374. );
  40375. } else
  40376. return console.warn('FresnelNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t);
  40377. }
  40378. },
  40379. WA = HA;
  40380. WA.Nodes = (function () {
  40381. return {
  40382. fresnel:
  40383. new Re(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, float alpha, int mode, out float calpha) {
  40384. float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
  40385. float lalpha = clamp( fresnel, 0.0, 1.0 ) * alpha;
  40386. calpha = lalpha / clamp(lalpha + accumAlpha, 0.001, 1.0);
  40387. accumAlpha += (1.0 - accumAlpha) * lalpha;
  40388. return color;
  40389. }`)
  40390. };
  40391. })();
  40392. var XA = class extends St {
  40393. constructor(e, t, i, r, s, n, a) {
  40394. super('v3'),
  40395. (this.nodeType = 'Rainbow'),
  40396. (this.filmThickness = e),
  40397. (this.movement = t),
  40398. (this.wavelengths = i),
  40399. (this.noiseStrength = r),
  40400. (this.noiseScale = s),
  40401. (this.offset = n),
  40402. (this.alpha = a),
  40403. (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`);
  40404. }
  40405. generate(e, t) {
  40406. if ((e.require('vWorldViewDir'), e.require('worldNormal'), e.isShader('fragment'))) {
  40407. e.require('uv'), (e.requires.uv = [!0]), e.addFragmentVariable(this.calpha, 'float');
  40408. let i = e.include(XA.Nodes.rainbow),
  40409. r = [];
  40410. return (
  40411. r.push(this.filmThickness.build(e, 'f')),
  40412. r.push(this.movement.build(e, 'f')),
  40413. r.push(this.wavelengths.build(e, 'v3')),
  40414. r.push(this.noiseStrength.build(e, 'f')),
  40415. r.push(this.noiseScale.build(e, 'f')),
  40416. r.push(this.offset.build(e, 'v3')),
  40417. r.push(this.alpha.build(e, 'f')),
  40418. r.push(this.calpha),
  40419. e.format(i + '(' + r.join(',') + ')', this.getType(e), t)
  40420. );
  40421. } else
  40422. return console.warn('RainbowNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t);
  40423. }
  40424. },
  40425. qA = XA;
  40426. qA.Nodes = (function () {
  40427. let e = new Re(
  40428. `vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
  40429. vec3 st = position / noiseScale;
  40430. vec3 q = vec3(simplex3d(st),
  40431. simplex3d(st + vec3(1.0)),
  40432. simplex3d(st + vec3(1.0)));
  40433. vec3 r = vec3(simplex3d(st + vec3(1.4, 1.3, 1.0) * q + vec3(1.7, 9.2, 1.0)),
  40434. simplex3d(st + vec3(2.0, 1.2, 1.0) * q + vec3(8.3, 2.8, 1.0)),
  40435. simplex3d(st * q));
  40436. float noise = simplex3d(st + r);
  40437. return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal))) + movement);
  40438. }`,
  40439. [wr.simplex]
  40440. );
  40441. return {
  40442. rainbow: new Re(
  40443. `vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, float alpha, out float calpha) {
  40444. vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
  40445. float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
  40446. float lalpha = alpha * rainbowContribution;
  40447. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  40448. accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
  40449. return res;
  40450. }`,
  40451. [e]
  40452. )
  40453. };
  40454. })();
  40455. var YA = class extends St {
  40456. constructor(e, t, i, r, s, n, a, o, l, h, u, c, d, p, f, g) {
  40457. super('v3'),
  40458. (this.nodeType = 'Outline'),
  40459. (this.firstTime = !0),
  40460. (this.outlineColor = e),
  40461. (this.contourColor = t),
  40462. (this.outlineWidth = i),
  40463. (this.contourWidth = r),
  40464. (this.contourThreshold = s),
  40465. (this.outlineThreshold = n),
  40466. (this.contourFrequency = a),
  40467. (this.outlineSmoothing = o),
  40468. (this.contourDirection = l),
  40469. (this.positionalLines = h),
  40470. (this.compensation = u),
  40471. (this.resolution = c),
  40472. (this.normalMap = d),
  40473. (this.depthMap = p),
  40474. (this.pixelRatio = f),
  40475. (this.alpha = g),
  40476. (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`);
  40477. }
  40478. generate(e, t) {
  40479. if ((e.require('vWorldViewDir'), e.require('worldNormal'), (e.extensions.derivatives = !0), this.firstTime)) {
  40480. let i = this.outlineWidth.build(e, 'f'),
  40481. r = this.resolution.build(e, 'v2'),
  40482. s = this.compensation.build(e, 'b'),
  40483. n = this.pixelRatio.build(e, 'f');
  40484. e.addVertexParsVariable('randomColor', 'attribute vec3'),
  40485. e.addVertexParsVariable('extrudeNormal', 'attribute vec3'),
  40486. e.addVertexParsVariable(i, 'uniform float'),
  40487. e.addVertexParsVariable(r, 'uniform vec2'),
  40488. e.addVertexParsVariable(s, 'uniform bool'),
  40489. e.addVertexParsVariable(n, 'uniform float'),
  40490. e.addVertexParsVariable('vID', 'flat out float'),
  40491. e.addFragmentParsVariable('vID', 'flat in float');
  40492. let a = `g${this.uuid.toString().replace(/-/g, '')}`;
  40493. e.addVertexFinalCode(`
  40494. vID = randomColor.r;
  40495. if (${s}) {
  40496. vec4 ${a}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
  40497. // NOTE: For certain shapes, like spheres, we get incorrect extrusion when the
  40498. // normals face the camera directly. So we hackily fix this by offsetting the normal
  40499. // by a tiny amount.
  40500. vec3 ${a}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * extrudeNormal) + 0.0000001;
  40501. vec2 ${a}_offset = normalize(${a}_clipNormal.xy) / ${r} * (${i} / 2.0) * ${a}_clipPosition.w * 2.0 * ${n};
  40502. ${a}_clipPosition.xy += ${a}_offset;
  40503. // TODO(MAX): To handle multiple outline layers, we only want to extrude
  40504. // if this offset is the biggest of all the potential offsets
  40505. gl_Position = ${a}_clipPosition;
  40506. }
  40507. `);
  40508. }
  40509. if (e.isShader('fragment')) {
  40510. e.require('uv'), (e.requires.uv = [!0]), e.addFragmentVariable(this.calpha, 'float');
  40511. let i = e.include(YA.Nodes.outline),
  40512. r = [];
  40513. return (
  40514. r.push(this.outlineColor.build(e, 'c')),
  40515. r.push(this.contourColor.build(e, 'c')),
  40516. r.push(this.outlineWidth.build(e, 'f')),
  40517. r.push(this.contourWidth.build(e, 'f')),
  40518. r.push(this.contourThreshold.build(e, 'f')),
  40519. r.push(this.outlineThreshold.build(e, 'f')),
  40520. r.push(this.contourFrequency.build(e, 'f')),
  40521. r.push(this.outlineSmoothing.build(e, 'f')),
  40522. r.push(this.contourDirection.build(e, 'v3')),
  40523. r.push(this.positionalLines.build(e, 'b')),
  40524. r.push(this.resolution.build(e, 'v2')),
  40525. r.push(this.normalMap.getTexture(e, 't')),
  40526. r.push(this.depthMap.getTexture(e, 't')),
  40527. r.push(this.pixelRatio.build(e, 'f')),
  40528. r.push(this.compensation.build(e, 'b')),
  40529. r.push(this.alpha.build(e, 'f')),
  40530. r.push(this.calpha),
  40531. (this.firstTime = !this.firstTime),
  40532. e.format(i + '(' + r.join(',') + ')', this.getType(e), t)
  40533. );
  40534. } else return console.warn('OutlineNode is not compatible with ' + e.shader + ' shader.'), '';
  40535. }
  40536. },
  40537. QA = YA;
  40538. QA.Nodes = (function () {
  40539. let e = new Re(`
  40540. float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
  40541. {
  40542. vec2 texelSize = (vec2(1.0) / resolution) * outlineWidth * pixelRatio;
  40543. vec2 uvSamples[9];
  40544. vec4 normalSamples[9];
  40545. uvSamples[0] = uv + vec2( -texelSize.x, -texelSize.y);
  40546. uvSamples[1] = uv + vec2(0.0, -texelSize.y);
  40547. uvSamples[2] = uv + vec2( texelSize.x, -texelSize.y);
  40548. uvSamples[3] = uv + vec2( -texelSize.x, 0.0);
  40549. uvSamples[4] = uv;
  40550. uvSamples[5] = uv + vec2( texelSize.x, 0.0);
  40551. uvSamples[6] = uv + vec2( -texelSize.x, texelSize.y);
  40552. uvSamples[7] = uv + vec2(0.0, texelSize.y);
  40553. uvSamples[8] = uv + vec2( texelSize.x, texelSize.y);
  40554. normalSamples[0] = texture2D(t, uvSamples[0]);
  40555. normalSamples[1] = texture2D(t, uvSamples[1]);
  40556. normalSamples[2] = texture2D(t, uvSamples[2]);
  40557. normalSamples[3] = texture2D(t, uvSamples[3]);
  40558. normalSamples[4] = texture2D(t, uvSamples[4]);
  40559. normalSamples[5] = texture2D(t, uvSamples[5]);
  40560. normalSamples[6] = texture2D(t, uvSamples[6]);
  40561. normalSamples[7] = texture2D(t, uvSamples[7]);
  40562. normalSamples[8] = texture2D(t, uvSamples[8]);
  40563. float depthBias = 0.0001;
  40564. // TODO(MAX): Can we somehow reduce the number of conditionals here with MATH?!
  40565. if (normalSamples[0].a != vID && normalSamples[0].a != 0.0) {
  40566. float depthAtSample = texture2D(d, uvSamples[0]).r + depthBias;
  40567. if (gl_FragCoord.z > depthAtSample) {
  40568. return 0.0;
  40569. }
  40570. }
  40571. if (normalSamples[1].a != vID && normalSamples[1].a != 0.0) {
  40572. float depthAtSample = texture2D(d, uvSamples[1]).r + depthBias;
  40573. if (gl_FragCoord.z > depthAtSample) {
  40574. return 0.0;
  40575. }
  40576. }
  40577. if (normalSamples[2].a != vID && normalSamples[2].a != 0.0) {
  40578. float depthAtSample = texture2D(d, uvSamples[2]).r + depthBias;
  40579. if (gl_FragCoord.z > depthAtSample) {
  40580. return 0.0;
  40581. }
  40582. }
  40583. if (normalSamples[3].a != vID && normalSamples[3].a != 0.0) {
  40584. float depthAtSample = texture2D(d, uvSamples[3]).r + depthBias;
  40585. if (gl_FragCoord.z > depthAtSample) {
  40586. return 0.0;
  40587. }
  40588. }
  40589. if (normalSamples[4].a != vID && normalSamples[4].a != 0.0) {
  40590. float depthAtSample = texture2D(d, uvSamples[4]).r + depthBias;
  40591. if (gl_FragCoord.z > depthAtSample) {
  40592. return 0.0;
  40593. }
  40594. }
  40595. if (normalSamples[5].a != vID && normalSamples[5].a != 0.0) {
  40596. float depthAtSample = texture2D(d, uvSamples[5]).r + depthBias;
  40597. if (gl_FragCoord.z > depthAtSample) {
  40598. return 0.0;
  40599. }
  40600. }
  40601. if (normalSamples[6].a != vID && normalSamples[6].a != 0.0) {
  40602. float depthAtSample = texture2D(d, uvSamples[6]).r + depthBias;
  40603. if (gl_FragCoord.z > depthAtSample) {
  40604. return 0.0;
  40605. }
  40606. }
  40607. if (normalSamples[7].a != vID && normalSamples[7].a != 0.0) {
  40608. float depthAtSample = texture2D(d, uvSamples[7]).r + depthBias;
  40609. if (gl_FragCoord.z > depthAtSample) {
  40610. return 0.0;
  40611. }
  40612. }
  40613. if (normalSamples[8].a != vID && normalSamples[8].a != 0.0) {
  40614. float depthAtSample = texture2D(d, uvSamples[8]).r + depthBias;
  40615. if (gl_FragCoord.z > depthAtSample) {
  40616. return 0.0;
  40617. }
  40618. }
  40619. vec4 sobel_edge_h = normalSamples[2] + (2.0*normalSamples[5]) + normalSamples[8] - (normalSamples[0] + (2.0*normalSamples[3]) + normalSamples[6]);
  40620. vec4 sobel_edge_v = normalSamples[0] + (2.0*normalSamples[1]) + normalSamples[2] - (normalSamples[6] + (2.0*normalSamples[7]) + normalSamples[8]);
  40621. float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));
  40622. return edgeNormal;
  40623. }
  40624. `);
  40625. return {
  40626. outline: new Re(
  40627. `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 alpha, out float calpha) {
  40628. vec3 result = outlineColor;
  40629. float resultAlpha = 0.0;
  40630. vec3 N = normalize(vWNormal);
  40631. vec2 nuv = (gl_FragCoord.xy / resolution);
  40632. float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio);
  40633. resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample);
  40634. float t = 1.0 - contourThreshold;
  40635. if(positionalLines) {
  40636. vec3 NDir = position * contourDirection;
  40637. float NT = NDir.x + NDir.y + NDir.z;
  40638. float f = fract(NT * contourFrequency * 0.01);
  40639. float df = fwidth(NT * contourFrequency);
  40640. float g = smoothstep(df * (contourWidth * 0.01), df * (contourWidth * 0.01 * 2.0), f);
  40641. if (g < 1.0 && resultAlpha == 0.0) {
  40642. result = contourColor;
  40643. resultAlpha = 1.0;
  40644. }
  40645. }
  40646. else {
  40647. vec3 NDir = N * contourDirection;
  40648. float NT = NDir.x + NDir.y + NDir.z;
  40649. float df = fwidth(NT * contourThreshold);
  40650. float f = sin(NT * 1.0 * contourFrequency);
  40651. float g = smoothstep(0.0, df * contourWidth, 1.0 - f);
  40652. if (df > (t * 0.5) && g < 1.0 && resultAlpha == 0.0) {
  40653. result = contourColor;
  40654. resultAlpha = 1.0 - g;
  40655. }
  40656. }
  40657. float lalpha = alpha * resultAlpha;
  40658. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  40659. accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
  40660. return result;
  40661. }`,
  40662. [e]
  40663. )
  40664. };
  40665. })();
  40666. var ZA = class extends St {
  40667. constructor(e, t, i, r, s, n, a, o) {
  40668. super('v3'),
  40669. (this.nodeType = 'Transmission'),
  40670. (this.thickness = e),
  40671. (this.ior = t),
  40672. (this.roughness = i),
  40673. (this.transmissionSamplerSize = r),
  40674. (this.transmissionSamplerMap = s),
  40675. (this.transmissionDepthMap = n),
  40676. (this.aspectRatio = a),
  40677. (this.alpha = o),
  40678. (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`);
  40679. }
  40680. generate(e, t) {
  40681. if (((e.extensions.shaderTextureLOD = !0), (e.extensions.derivatives = !0), e.isShader('fragment'))) {
  40682. e.define('NUM_SAMPLES', 30),
  40683. e.require('worldPosition'),
  40684. (e.requires.worldNormal = !0),
  40685. (e.requires.modelMatrix = !0),
  40686. (e.requires.projectionMatrix = !0),
  40687. e.addFragmentVariable(this.calpha, 'float');
  40688. let i = e.include(ZA.Nodes.transmission),
  40689. r = [];
  40690. return (
  40691. r.push(this.thickness.build(e, 'f')),
  40692. r.push(this.ior.build(e, 'f')),
  40693. r.push(this.roughness.build(e, 'f')),
  40694. r.push(this.transmissionSamplerSize.build(e, 'v2')),
  40695. r.push(this.transmissionSamplerMap.getTexture(e, 't')),
  40696. r.push(this.transmissionDepthMap.getTexture(e, 't')),
  40697. r.push(this.aspectRatio.build(e, 'v2')),
  40698. r.push('normal'),
  40699. r.push(this.alpha.build(e, 'f')),
  40700. r.push(this.calpha),
  40701. e.format(i + '(' + r.join(',') + ')', this.getType(e), t)
  40702. );
  40703. } else
  40704. return (
  40705. console.warn('TransmissionNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t)
  40706. );
  40707. }
  40708. },
  40709. KA = ZA;
  40710. KA.Nodes = (function () {
  40711. let e = new Re(`
  40712. float gaussian(vec2 i) {
  40713. const float sigma = float(NUM_SAMPLES) * .25;
  40714. return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma );
  40715. }`),
  40716. t = new Re(
  40717. `
  40718. vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
  40719. // Slightly modified version of this:
  40720. // https://www.shadertoy.com/view/ltScRG
  40721. const int LOD = 2;
  40722. const int sLOD = 4; // tile size = 2^LOD
  40723. vec3 O = vec3(0);
  40724. float a = 0.0;
  40725. const int s = NUM_SAMPLES/sLOD;
  40726. for ( int i = 0; i < s*s; i++ ) {
  40727. int modulo = (i)-((i)/(s))*(s);
  40728. vec2 d = vec2(float(modulo), float(i/s))*float(sLOD) - float(NUM_SAMPLES)/2.;
  40729. vec2 uv = U + (scale * aspectRatio) * d;
  40730. // What is the depth of the opaque object we're trying to sample
  40731. float opaqueDepth = unpackRGBAToDepth(texture2D(dm, uv));
  40732. if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) {
  40733. uv = unrefractedU + ((scale * min(lod / 2., 1.)) * aspectRatio) * d;
  40734. lod = lod > 4.0 ? lod : lod / 2.0;
  40735. }
  40736. float gaussian = gaussian(d);
  40737. #ifdef TEXTURE_LOD_EXT
  40738. O += gaussian * texture2DLodEXT( sp, uv, lod).rgb;
  40739. #else
  40740. O += gaussian * textureLod( sp, uv, lod).rgb;
  40741. #endif
  40742. a += gaussian;
  40743. }
  40744. return O / a;
  40745. }`,
  40746. [e]
  40747. ),
  40748. i = new Re(`
  40749. vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
  40750. // Direction of refracted light.
  40751. vec3 refractionVector = refract( -v, n, 1.0 / ior );
  40752. // Compute rotation-independant scaling of the model matrix.
  40753. vec3 modelScale;
  40754. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  40755. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  40756. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  40757. // The thickness is specified in local space.
  40758. return normalize( refractionVector ) * thickness * modelScale;
  40759. }`),
  40760. r = new Re(`
  40761. float applyIorToRoughness( float roughness, float ior ) {
  40762. // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
  40763. // an IOR of 1.5 results in the default amount of microfacet refraction.
  40764. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  40765. } `),
  40766. s = new Re(
  40767. `
  40768. vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
  40769. float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  40770. float lod = applyIorToRoughness(roughness, ior);
  40771. return blur(transmissionSamplerMap, fragCoord, vec2(lod / (transmissionSamplerSize.x / 2.)), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
  40772. }`,
  40773. [r, t]
  40774. ),
  40775. n = new Re(
  40776. `
  40777. 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 ) {
  40778. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  40779. vec3 refractedRayExit = position + transmissionRay;
  40780. // Project refracted vector on the framebuffer, while mapping to normalized device coordinates.
  40781. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  40782. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  40783. refractionCoords += 1.0;
  40784. refractionCoords /= 2.0;
  40785. vec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 );
  40786. vec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w;
  40787. unrefractedCoords += 1.0;
  40788. unrefractedCoords /= 2.0;
  40789. // Sample framebuffer to get pixel the refracted ray hits.
  40790. return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
  40791. }`,
  40792. [s, i]
  40793. );
  40794. return {
  40795. transmission: new Re(
  40796. `
  40797. vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float alpha, out float calpha) {
  40798. vec3 v = vec3(0.);
  40799. if (isOrthographic) {
  40800. v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  40801. } else {
  40802. v = normalize(vWPosition - cameraPosition);
  40803. }
  40804. vec3 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio );
  40805. float lalpha = alpha;
  40806. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  40807. accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
  40808. return transmission;
  40809. }`,
  40810. [n]
  40811. )
  40812. };
  40813. })();
  40814. var ql = class extends St {
  40815. constructor(e, t, i, r, s, n, a, o, l, h, u) {
  40816. super('v3'),
  40817. (this.nodeType = 'Depth'),
  40818. (this.gradientType = e),
  40819. (this.smooth = t),
  40820. (this.near = i),
  40821. (this.far = r),
  40822. (this.isVector = s),
  40823. (this.isWorldSpace = n),
  40824. (this.origin = a),
  40825. (this.direction = o),
  40826. (this.colors = l),
  40827. (this.steps = h),
  40828. (this.alpha = u),
  40829. (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`);
  40830. }
  40831. generate(e, t) {
  40832. let i = `g${this.uuid.toString().replace(/-/g, '')}`,
  40833. r = new Re(
  40834. `vec3 ${i}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${i}_MAX_COLORS], float steps[${i}_MAX_COLORS], float alpha, out float calpha) {
  40835. vec4 color = colors[0];
  40836. #ifdef ${i}_IS_VECTOR
  40837. #ifdef ${i}_LINEAR
  40838. #ifdef ${i}_WORLDSPACE
  40839. float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);
  40840. #else
  40841. float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);
  40842. #endif
  40843. #else
  40844. #ifdef ${i}_WORLDSPACE
  40845. float depth = vectorSphericalWorldSpaceDepth(origin, near, far);
  40846. #else
  40847. float depth = vectorSphericalObjectSpaceDepth(origin, near, far);
  40848. #endif
  40849. #endif
  40850. #else
  40851. float dist = length(vWPosition - cameraPosition);
  40852. float depth = ( dist - near ) / ( far - near );
  40853. #endif
  40854. float p;
  40855. #ifdef ${i}_SMOOTH
  40856. for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) {
  40857. p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
  40858. color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
  40859. }
  40860. #else
  40861. for ( int i = 1; i < ${i}_MAX_COLORS; i++ ) {
  40862. p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);
  40863. color = mix(color, colors[i], p);
  40864. }
  40865. #endif
  40866. float lalpha = alpha * color.a;
  40867. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  40868. accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
  40869. return color.rgb;
  40870. }`,
  40871. [
  40872. ql.Nodes.vectorLinearWorldSpaceDepth,
  40873. ql.Nodes.vectorLinearObjectSpaceDepth,
  40874. ql.Nodes.vectorSphericalObjectSpaceDepth,
  40875. ql.Nodes.vectorSphericalWorldSpaceDepth
  40876. ]
  40877. );
  40878. if (e.isShader('fragment')) {
  40879. e.define(`${i}_MAX_COLORS`, this.colors.value.length),
  40880. this.smooth.value && e.define(`${i}_SMOOTH`),
  40881. this.isVector.value > 0.5 && e.define(`${i}_IS_VECTOR`),
  40882. this.gradientType.value === 0 && e.define(`${i}_LINEAR`),
  40883. this.isWorldSpace.value > 0.5 && e.define(`${i}_WORLDSPACE`),
  40884. e.require('worldPosition'),
  40885. e.addFragmentVariable(this.calpha, 'float');
  40886. let s = e.include(r),
  40887. n = [];
  40888. return (
  40889. n.push(this.near.build(e, 'f')),
  40890. n.push(this.far.build(e, 'f')),
  40891. n.push(this.origin.build(e, 'v3')),
  40892. n.push(this.direction.build(e, 'v3')),
  40893. n.push(this.colors.build(e, 'v4[]')),
  40894. n.push(this.steps.build(e, 'f[]')),
  40895. n.push(this.alpha.build(e, 'f')),
  40896. n.push(this.calpha),
  40897. e.format(s + '(' + n.join(',') + ')', this.getType(e), t)
  40898. );
  40899. } else return console.warn('DepthNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t);
  40900. }
  40901. },
  40902. JA = ql;
  40903. JA.Nodes = (function () {
  40904. let e = new Re(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
  40905. vec3 n = normalize(direction);
  40906. float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
  40907. return ( dist - near ) / ( far - near );
  40908. }`),
  40909. t = new Re(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
  40910. vec3 n = normalize(direction);
  40911. float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
  40912. return ( dist - near ) / ( far - near );
  40913. }`),
  40914. i = new Re(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
  40915. float dist = length(vWPosition - origin);
  40916. return ( dist - near ) / ( far - near );
  40917. }`),
  40918. r = new Re(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
  40919. float dist = length(position - origin);
  40920. return ( dist - near ) / ( far - near );
  40921. }`);
  40922. return {
  40923. vectorLinearWorldSpaceDepth: e,
  40924. vectorLinearObjectSpaceDepth: t,
  40925. vectorSphericalWorldSpaceDepth: i,
  40926. vectorSphericalObjectSpaceDepth: r
  40927. };
  40928. })();
  40929. var jx = class extends St {
  40930. constructor(e, t, i, r) {
  40931. super('v3'), (this.nodeType = 'Blend'), (this.a = e), (this.b = t), (this.alpha = i), (this.mode = r);
  40932. }
  40933. generate(e, t) {
  40934. if (e.isShader('fragment')) {
  40935. let i = [];
  40936. return (
  40937. i.push(this.a.build(e, 'c')),
  40938. i.push(this.b.build(e, 'c')),
  40939. i.push(this.alpha.build(e, 'f')),
  40940. i.push(this.mode.build(e, 'i')),
  40941. e.format('spe_blend(' + i.join(',') + ')', this.getType(e), t)
  40942. );
  40943. } else return console.warn('BlendNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t);
  40944. }
  40945. },
  40946. km = ((e) => ((e.NOISE = 'noise'), (e.MAP = 'map'), e))(km || {}),
  40947. $A = class extends St {
  40948. constructor(e, t, i, r, s) {
  40949. super('v3'),
  40950. (this.displacementTypeIndex = new xt(0)),
  40951. (this.nodeType = 'VertexDisplacement'),
  40952. (this.intensity = e),
  40953. (this.movementOrTexture = t),
  40954. Object.values(km)[this.displacementTypeIndex.value] === 'map' && (this.mat = new GA(this.movementOrTexture.value.matrix)),
  40955. (this.cropOrOffset = i),
  40956. (this.scale = r),
  40957. (this.noiseFunctionIndex = s);
  40958. }
  40959. generate(e, t) {
  40960. if (e.isShader('vertex')) {
  40961. e.define('USE_LAYER_DISPLACE');
  40962. let i,
  40963. r = [];
  40964. switch ((r.push('displaced_position'), r.push('displaced_normal'), Object.values(km)[this.displacementTypeIndex.value])) {
  40965. case 'map': {
  40966. (i = e.include($A.Nodes.map)),
  40967. r.push(this.movementOrTexture.getTexture(e, 't')),
  40968. r.push('uv'),
  40969. r.push(this.cropOrOffset.build(e, 'f')),
  40970. this.mat && r.push(this.mat.build(e, 'mat3'));
  40971. break;
  40972. }
  40973. case 'noise': {
  40974. let s = Object.values(cv)[this.noiseFunctionIndex.value],
  40975. n = new Re(`vec3 orthogonal(vec3 v) {
  40976. return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
  40977. }`),
  40978. a = new Re(
  40979. `vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) {
  40980. return p + n * ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
  40981. }`,
  40982. [wr.simplex, wr.simplexFractal, wr.simplexAshima, wr.fbm, wr.perlin]
  40983. ),
  40984. o = new Re(
  40985. `vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, float intensity, out vec3 displaced_normal) {
  40986. vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement);
  40987. vec3 tangent1 = orthogonal(normal);
  40988. vec3 tangent2 = normalize(cross(normal, tangent1));
  40989. // TODO(Max): The distance to the neighbors was originally scaled by 0.1.
  40990. // This caused some small oval/circular visual artifacts in the lighting.
  40991. // For now, simply using neighbors further away betters the problem,
  40992. // but we should figure out the underlying cause when we have some time.
  40993. // Maybe its related to how we calculate the tangent and bitangent?
  40994. vec3 nearby1 = position + tangent1;
  40995. vec3 nearby2 = position + tangent2;
  40996. vec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement);
  40997. vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement);
  40998. displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
  40999. return displaced_position;
  41000. }`,
  41001. [a, n]
  41002. );
  41003. (i = e.include(o)),
  41004. r.push(this.scale.build(e, 'f')),
  41005. r.push(this.cropOrOffset.build(e, 'v3')),
  41006. r.push(this.movementOrTexture.build(e, 'f'));
  41007. break;
  41008. }
  41009. }
  41010. return r.push(this.intensity.build(e, 'f')), r.push('displaced_normal'), e.format(i + '(' + r.join(',') + ')', this.getType(e), t);
  41011. } else
  41012. return (
  41013. console.warn('VertexDisplacementNode is not compatible with ' + e.shader + ' shader.'),
  41014. e.format('vec3( 0.0 )', this.getType(e), t)
  41015. );
  41016. }
  41017. },
  41018. eS = $A;
  41019. eS.Nodes = (function () {
  41020. let e = new Re(`vec3 orthogonal(vec3 v) {
  41021. return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
  41022. }`),
  41023. t = new Re(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
  41024. vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
  41025. vec4 tmp = texture2D(tex, uvs);
  41026. vec3 col = tmp.rgb;
  41027. if (crop > 0.5) {
  41028. if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
  41029. return 0.0;
  41030. }
  41031. }
  41032. return col.r;
  41033. }`);
  41034. return {
  41035. map: new Re(
  41036. `vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
  41037. vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;
  41038. vec3 tangent1 = normalize(orthogonal(normal));
  41039. vec3 tangent2 = normalize(cross(normal, tangent1));
  41040. vec3 nearby1 = position + tangent1 * 0.1;
  41041. vec3 nearby2 = position + tangent2 * 0.1;
  41042. vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
  41043. vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
  41044. displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
  41045. return displaced_position;
  41046. }`,
  41047. [e, t]
  41048. )
  41049. };
  41050. })();
  41051. var tS = class extends St {
  41052. constructor(e, t, i, r, s, n, a, o) {
  41053. super('v3'),
  41054. (this.nodeType = 'Gradient'),
  41055. (this.gradientType = e),
  41056. (this.smooth = t),
  41057. (this.colors = i),
  41058. (this.steps = r),
  41059. (this.offset = s),
  41060. (this.morph = n),
  41061. (this.angle = a),
  41062. (this.alpha = o),
  41063. (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`);
  41064. }
  41065. generate(e, t) {
  41066. if (e.isShader('fragment')) {
  41067. e.define('GRAD_MAX', 10), e.require('uv'), (e.requires.uv = [!0]), e.addFragmentVariable(this.calpha, 'float');
  41068. let i = e.include(tS.Nodes.gradient),
  41069. r = [];
  41070. return (
  41071. r.push(this.gradientType.build(e, 'i')),
  41072. r.push(this.smooth.build(e, 'b')),
  41073. r.push(this.colors.build(e, 'v4[]')),
  41074. r.push(this.steps.build(e, 'f[]')),
  41075. r.push(this.offset.build(e, 'v2')),
  41076. r.push(this.morph.build(e, 'v2')),
  41077. r.push(this.angle.build(e, 'f')),
  41078. r.push(this.alpha.build(e, 'f')),
  41079. r.push(this.calpha),
  41080. e.format(i + '(' + r.join(',') + ')', this.getType(e), t)
  41081. );
  41082. } else
  41083. return console.warn('GradientNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t);
  41084. }
  41085. },
  41086. iS = tS;
  41087. iS.Nodes = (function () {
  41088. return {
  41089. gradient:
  41090. new Re(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, float alpha, out float calpha) {
  41091. vec4 color = colors[0];
  41092. vec2 m = morph / vUv.xy;
  41093. vec2 rot = vec2( 0.5 + m.x, m.y );
  41094. vec2 dt = vec2(
  41095. cos( angle ) * rot.x - sin( angle ) * rot.y,
  41096. sin( angle ) * rot.x + cos( angle ) * rot.y
  41097. );
  41098. vec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0;
  41099. float t = dot( pt, dt ) / dot( dt, dt );
  41100. if ( gradientType == 1 ) {
  41101. t = distance (
  41102. ( vUv + morph ) * 3.0,
  41103. ( vUv + offset ) + 1.0
  41104. ) + angle;
  41105. } else if ( gradientType == 2 ) {
  41106. float polar = atan(
  41107. vUv.x + morph.x - 0.5 + offset.x,
  41108. vUv.y + morph.y - 0.5 + offset.y
  41109. ) * -1.0;
  41110. t = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) );
  41111. }
  41112. float p;
  41113. if (smoothed) {
  41114. for ( int i = 1; i < GRAD_MAX; i++ ) {
  41115. p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
  41116. color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
  41117. }
  41118. } else {
  41119. for ( int i = 1; i < GRAD_MAX; i++ ) {
  41120. p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
  41121. color = mix(color, colors[i], p);
  41122. }
  41123. }
  41124. float lalpha = alpha * color.a;
  41125. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  41126. accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
  41127. return color.xyz;
  41128. }`)
  41129. };
  41130. })();
  41131. var od = class extends St {
  41132. constructor(e, t, i, r, s, n, a, o, l, h) {
  41133. super('v3'),
  41134. (this.nodeType = 'CustomTexture'),
  41135. (this.firstTime = !0),
  41136. (this.texture = e),
  41137. (this.textureSize = t),
  41138. (this.crop = i),
  41139. (this.projection = r),
  41140. (this.axis = s),
  41141. (this.side = n),
  41142. (this.size = a),
  41143. (this.mat = o),
  41144. (this.alpha = l),
  41145. (this.mode = h),
  41146. (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`);
  41147. }
  41148. generate(e, t) {
  41149. e.require('position'),
  41150. e.require('normal'),
  41151. e.require('uv'),
  41152. (e.requires.uv = [!0]),
  41153. (e.extensions.shaderTextureLOD = !0),
  41154. (e.extensions.derivatives = !0);
  41155. let i = `g${this.uuid.toString().replace(/-/g, '')}`,
  41156. r;
  41157. switch (this.projection.value) {
  41158. case 3:
  41159. r = e.include(od.Nodes.cylindrical);
  41160. break;
  41161. case 2:
  41162. r = e.include(od.Nodes.spherical);
  41163. break;
  41164. case 1:
  41165. let n = ['vec3(1.0, 0.0, 0.0)', 'vec3(0.0, 1.0, 0.0)', 'vec3(0.0, 0.0, 1.0)'][this.axis.value],
  41166. a = new Re(`
  41167. vec3 ${i}_planarTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
  41168. vec2 uvs = ( mat * vec3( (${i}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
  41169. vec4 tmp = texture2D( tex, uvs );
  41170. vec3 col = tmp.rgb;
  41171. float lalpha = alpha * tmp.a;
  41172. ${this.side.value === 2 ? '' : `lalpha *= step(0.0, ${this.side.value === 1 ? '-1.0 * ' : ''}dot(vObjectNormal, mat * ${n}));`}
  41173. if ( crop > 0.5 ) {
  41174. if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
  41175. lalpha = 0.0;
  41176. }
  41177. }
  41178. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  41179. accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
  41180. return col;
  41181. }`);
  41182. r = e.include(a);
  41183. break;
  41184. default:
  41185. r = e.include(od.Nodes.uv);
  41186. break;
  41187. }
  41188. if (this.projection.value === 1 && this.firstTime) {
  41189. e.addVertexParsCode(`varying vec2 ${i}_vCustomUv;`), e.addFragmentParsCode(`varying vec2 ${i}_vCustomUv;`);
  41190. let n = ['zy', 'xz', 'xy'][this.axis.value];
  41191. e.addVertexFinalCode(`${i}_vCustomUv = (1. + (transformed.${n})) / 2.;`);
  41192. }
  41193. e.addFragmentVariable(this.calpha, 'float');
  41194. let s = [];
  41195. return (
  41196. s.push(this.texture.generate(e, 't')),
  41197. s.push(this.textureSize.build(e, 'v2')),
  41198. s.push(this.crop.build(e, 'f')),
  41199. s.push(this.mat.build(e, 'mat3')),
  41200. s.push(this.size.build(e, 'v2')),
  41201. s.push(this.alpha.build(e, 'f')),
  41202. s.push(this.mode.build(e, 'i')),
  41203. s.push(this.calpha),
  41204. (this.firstTime = !this.firstTime),
  41205. e.format(r + '(' + s.join(',') + ')', this.getType(e), t)
  41206. );
  41207. }
  41208. },
  41209. rS = od;
  41210. rS.Nodes = (function () {
  41211. let e = new Re(`
  41212. vec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
  41213. vec3 posN = normalize(position);
  41214. float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
  41215. float scaledHeight = position.y / (size.y * 0.5);
  41216. float v = (scaledHeight / 2.) + .5;
  41217. vec2 calculatedUv = vec2(u,v);
  41218. vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
  41219. vec2 df = fwidth(uvs);
  41220. if(df.x > 0.5) df.x = 0.;
  41221. #ifdef GL_EXT_shader_texture_lod
  41222. vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
  41223. #else
  41224. vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
  41225. #endif
  41226. vec3 col = tmp.rgb;
  41227. float lalpha = alpha * tmp.a;
  41228. if ( crop > 0.5 ) {
  41229. if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
  41230. lalpha = 0.0;
  41231. }
  41232. }
  41233. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  41234. accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
  41235. return col;
  41236. }
  41237. `),
  41238. t = new Re(`
  41239. vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
  41240. vec3 posN = normalize(vPosition);
  41241. float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
  41242. float v = 0.5 + asin(posN.y) / 3.1415;
  41243. vec2 calculatedUv = vec2(u,v);
  41244. vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
  41245. vec2 df = fwidth(uvs);
  41246. if(df.x > 0.5) df.x = 0.;
  41247. #ifdef GL_EXT_shader_texture_lod
  41248. vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
  41249. #else
  41250. vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
  41251. #endif
  41252. vec3 col = tmp.rgb;
  41253. float lalpha = alpha * tmp.a;
  41254. if ( crop > 0.5 ) {
  41255. if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
  41256. lalpha = 0.0;
  41257. }
  41258. }
  41259. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  41260. accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
  41261. return col;
  41262. }
  41263. `),
  41264. i = new Re(`vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
  41265. vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
  41266. vec4 tmp = texture2D( tex, uvs );
  41267. vec3 col = tmp.rgb;
  41268. float lalpha = alpha * tmp.a;
  41269. if ( crop > 0.5 ) {
  41270. if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
  41271. lalpha = 0.0;
  41272. }
  41273. }
  41274. calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
  41275. accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
  41276. return col;
  41277. }`);
  41278. return { cylindrical: e, spherical: t, uv: i };
  41279. })();
  41280. var sS = class extends St {
  41281. constructor(e, t) {
  41282. super('v3'), (this.nodeType = 'CustomNormal'), (this.cnormal = e), (this.alpha = t);
  41283. }
  41284. generate(e, t) {
  41285. if (e.isShader('fragment')) {
  41286. let i = e.include(sS.Nodes.customNormal),
  41287. r = [];
  41288. return (
  41289. r.push(this.cnormal.build(e, 'v3')),
  41290. r.push('normal'),
  41291. r.push(this.alpha.build(e, 'f')),
  41292. e.format(i + '(' + r.join(',') + ')', this.getType(e), t)
  41293. );
  41294. } else
  41295. return (
  41296. console.warn('CustomNormalNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t)
  41297. );
  41298. }
  41299. },
  41300. nS = sS;
  41301. nS.Nodes = (function () {
  41302. return {
  41303. customNormal: new Re(`vec3 customNormal(vec3 cnormal, vec3 norm, float alpha) {
  41304. vec3 normal = packNormalToRGB( norm ).rgb;
  41305. normal *= step( vec3(0.5), cnormal );
  41306. accumAlpha += ( 1.0 - accumAlpha ) * alpha;
  41307. return normal;
  41308. }`)
  41309. };
  41310. })();
  41311. function sr(e, t) {
  41312. return t.color(e);
  41313. }
  41314. function nk(e, t) {
  41315. switch (e.type) {
  41316. case 'fresnel':
  41317. return lk(e, t);
  41318. case 'gradient':
  41319. return hk(e);
  41320. case 'depth':
  41321. return ck(e);
  41322. case 'normal':
  41323. return dk(e);
  41324. case 'noise':
  41325. return uk(e, t);
  41326. case 'rainbow':
  41327. return pk(e);
  41328. case 'toon':
  41329. return fk(e, t);
  41330. case 'outline':
  41331. return mk(e, t);
  41332. case 'transmission':
  41333. return gk(e, t);
  41334. case 'color':
  41335. return ok(e, t);
  41336. }
  41337. }
  41338. function ak(e) {
  41339. return { type: e.type };
  41340. }
  41341. function As(e) {
  41342. let { alpha: t, mode: i } = e;
  41343. return { ...ak(e), alpha: t, mode: i };
  41344. }
  41345. function ok(e, t) {
  41346. return { ...As(e), color: sr(e.color, t) };
  41347. }
  41348. function lk(e, t) {
  41349. let { bias: i, scale: r, intensity: s, factor: n, color: a } = e;
  41350. return { ...As(e), color: sr(a, t), bias: i, scale: r, intensity: s, factor: n };
  41351. }
  41352. function hk(e) {
  41353. let { gradientType: t, smooth: i, colors: r, steps: s, angle: n, offset: a, morph: o } = e;
  41354. return {
  41355. ...As(e),
  41356. gradientType: t,
  41357. smooth: i,
  41358. colors: r.map((l) => new $e(l[0], l[1], l[2], l[3])),
  41359. num: r.length,
  41360. steps: s,
  41361. offset: new G(...a),
  41362. morph: new G(...o),
  41363. angle: n
  41364. };
  41365. }
  41366. function ck(e) {
  41367. let { gradientType: t, near: i, far: r, isVector: s, isWorldSpace: n, origin: a, direction: o, colors: l, steps: h, smooth: u } = e;
  41368. return {
  41369. ...As(e),
  41370. gradientType: t,
  41371. near: i,
  41372. far: r,
  41373. isVector: s,
  41374. isWorldSpace: n,
  41375. origin: new E(...a),
  41376. direction: o ? new E(...o) : new E(1, 0, 0),
  41377. colors: l.map((c) => (c !== void 0 ? new $e(c[0], c[1], c[2], c[3]) : new $e(0, 0, 0, 0))),
  41378. steps: h.slice(0, l.length),
  41379. smooth: u
  41380. };
  41381. }
  41382. function dk(e) {
  41383. let { cnormal: t } = e;
  41384. return { ...As(e), cnormal: new E(t[0], t[1], t[2]) };
  41385. }
  41386. function uk(e, t) {
  41387. return {
  41388. ...As(e),
  41389. scale: e.scale,
  41390. move: e.move,
  41391. fA: new G(...e.fA),
  41392. fB: new G(...e.fB),
  41393. size: new E(...e.size),
  41394. distortion: new G(...e.distortion),
  41395. colorA: sr(e.colorA, t),
  41396. colorB: sr(e.colorB, t),
  41397. colorC: sr(e.colorC, t),
  41398. colorD: sr(e.colorD, t),
  41399. noiseType: e.noiseType
  41400. };
  41401. }
  41402. function pk(e) {
  41403. return {
  41404. ...As(e),
  41405. filmThickness: e.filmThickness,
  41406. movement: e.movement,
  41407. wavelengths: new E(...e.wavelengths),
  41408. noiseStrength: e.noiseStrength,
  41409. noiseScale: e.noiseScale,
  41410. offset: new E(...e.offset)
  41411. };
  41412. }
  41413. function fk(e, t) {
  41414. return {
  41415. ...As(e),
  41416. positioning: e.positioning,
  41417. colors: e.colors.map((i) => new $e(i[0], i[1], i[2], i[3])),
  41418. num: e.colors.length,
  41419. steps: e.steps,
  41420. source: new E(...e.source),
  41421. isWorldSpace: e.isWorldSpace,
  41422. noiseStrength: e.noiseStrength,
  41423. noiseScale: e.noiseScale,
  41424. shadowColor: sr(e.shadowColor, t),
  41425. offset: new E(...e.offset)
  41426. };
  41427. }
  41428. function mk(e, t) {
  41429. return {
  41430. ...As(e),
  41431. outlineColor: sr(e.outlineColor, t),
  41432. contourColor: sr(e.contourColor, t),
  41433. outlineWidth: e.outlineWidth,
  41434. contourWidth: e.contourWidth,
  41435. outlineThreshold: e.outlineThreshold,
  41436. contourThreshold: e.contourThreshold,
  41437. outlineSmoothing: e.outlineSmoothing,
  41438. contourFrequency: e.contourFrequency,
  41439. contourDirection: new E(...e.contourDirection),
  41440. positionalLines: e.positionalLines,
  41441. compensation: e.compensation
  41442. };
  41443. }
  41444. function gk(e, t) {
  41445. return { ...As(e), thickness: e.thickness, ior: e.ior, roughness: e.roughness };
  41446. }
  41447. var Kd = class extends ji {},
  41448. vk = class {
  41449. constructor(e = 1e3 * 10) {
  41450. (this.timeout = e),
  41451. (this.cache = new Map()),
  41452. (this.head = { data: null, time: 0, src: null, next: null, prev: null }),
  41453. (this.tail = { data: null, time: 1 / 0, src: null, next: null, prev: null }),
  41454. (this.hasClean = !1),
  41455. (this.head.next = this.tail),
  41456. (this.tail.prev = this.head);
  41457. }
  41458. log(...e) {}
  41459. remove(e) {
  41460. let t = this.cache.get(e);
  41461. t && (this.dispose(e, t.data), this.cache.delete(e), (t.prev.next = t.next), (t.next.prev = t.prev));
  41462. }
  41463. scheduleCleanup() {
  41464. this.hasClean ||
  41465. (this.log('scheduled cleanup'),
  41466. (this.hasClean = !0),
  41467. setTimeout(() => {
  41468. (this.hasClean = !1), this.log('cleaning');
  41469. let e = Date.now(),
  41470. t = this.head.next;
  41471. for (; t.time < e - this.timeout; )
  41472. this.dispose(t.src, t.data), this.cache.delete(t.src), (t = t.next), (t.prev = this.head), (this.head.next = t);
  41473. this.head.next !== this.tail ? this.scheduleCleanup() : this.log('no more cleanup');
  41474. }, this.timeout + 1e3));
  41475. }
  41476. has(e) {
  41477. return this.cache.get(e)?.data;
  41478. }
  41479. load(e) {
  41480. let t = Date.now(),
  41481. i = this.cache.get(e);
  41482. return (
  41483. i === void 0
  41484. ? ((i = { data: this.create(e), src: e, time: t, next: null, prev: null }), this.cache.set(e, i))
  41485. : ((i.time = t), (i.prev.next = i.next), (i.next.prev = i.prev)),
  41486. (i.prev = this.tail.prev),
  41487. (i.next = this.tail),
  41488. (this.tail.prev.next = i),
  41489. (this.tail.prev = i),
  41490. this.scheduleCleanup(),
  41491. i.data
  41492. );
  41493. }
  41494. },
  41495. yk = class extends vk {
  41496. create(e) {
  41497. return URL.createObjectURL(new Blob([e]));
  41498. }
  41499. dispose(e, t) {
  41500. URL.revokeObjectURL(t);
  41501. }
  41502. },
  41503. nf;
  41504. function xk(e) {
  41505. return typeof e == 'string' ? e : (nf || (nf = new yk()), nf.load(e));
  41506. }
  41507. var bk = class {
  41508. constructor(e, t) {
  41509. (this.data = e), (this.cache = t), (this.refCount = 0);
  41510. }
  41511. deref() {
  41512. this.refCount, (this.refCount -= 1), this.refCount === 0 && (this.cache.remove(this), this.dispose());
  41513. }
  41514. dispose() {
  41515. this.refCount;
  41516. }
  41517. },
  41518. wk = class {
  41519. constructor() {
  41520. this.cache = new Map();
  41521. }
  41522. remove(e) {
  41523. this.cache.delete(e.data);
  41524. }
  41525. load(e) {
  41526. let t = this.cache.get(e);
  41527. return t === void 0 && ((t = this.create(e)), this.cache.set(e, t)), (t.refCount += 1), t;
  41528. }
  41529. },
  41530. aS = class extends bk {
  41531. constructor(e, t) {
  41532. super(e, t.imageHolderCache),
  41533. (this.data = e),
  41534. (this.shared = t),
  41535. (this.loaded = !1),
  41536. (this.isVideo = !1),
  41537. (this.isVideo = e.type == 'video'),
  41538. this.updateSrc(e.data);
  41539. }
  41540. async updateSrc(e) {
  41541. if (typeof document > 'u') return;
  41542. this.disposeTextures(), (this.loaded = !1);
  41543. let t = () => {
  41544. this.loaded = !0;
  41545. let r = [1e3, 1001, 1002];
  41546. for (let s of r) {
  41547. let n = this[s];
  41548. n && ((n.image = this.img), (n.needsUpdate = !0));
  41549. }
  41550. this.shared.requestRender();
  41551. };
  41552. if (this.isVideo) {
  41553. if (
  41554. ((this.img = document.createElement('video')),
  41555. (this.img.preload = 'auto'),
  41556. (this.img.playsInline = !0),
  41557. (this.img.currentTime = 0.01),
  41558. typeof e != 'string')
  41559. ) {
  41560. var i = new FileReader();
  41561. i.readAsDataURL(new Blob([e], { type: 'video/mp4' }));
  41562. let r;
  41563. await new Promise((s) => {
  41564. i.onloadend = (n) => {
  41565. (r = n.target?.result), s(null);
  41566. };
  41567. }),
  41568. (this.img.src = r);
  41569. } else this.img.src = e;
  41570. this.img.onloadeddata = () => {
  41571. t();
  41572. };
  41573. } else (this.img = new Image()), (this.img.src = xk(e)), (this.img.onload = t);
  41574. }
  41575. getTexture(e) {
  41576. let t = this[e];
  41577. if (t) return t;
  41578. {
  41579. let i;
  41580. return (
  41581. this.isVideo ? (i = new tD(this.img, void 0, e, e)) : (i = new ci(this.img, void 0, e, e)),
  41582. this.loaded && (i.needsUpdate = !0),
  41583. (this[e] = i),
  41584. i
  41585. );
  41586. }
  41587. }
  41588. disposeTextures() {
  41589. this[1e3]?.dispose(),
  41590. (this[1e3] = void 0),
  41591. this[1001]?.dispose(),
  41592. (this[1001] = void 0),
  41593. this[1002]?.dispose(),
  41594. (this[1002] = void 0);
  41595. }
  41596. dispose() {
  41597. super.dispose(), this.disposeTextures();
  41598. }
  41599. },
  41600. ha = class extends aS {},
  41601. dv = class extends or {},
  41602. oS = {
  41603. noise: ['noiseType'],
  41604. texture: ['projection', 'axis', 'side'],
  41605. video: ['projection', 'axis', 'side'],
  41606. displace: ['noiseType'],
  41607. depth: ['smooth', 'isWorldSpace', 'gradientType', 'isVector']
  41608. },
  41609. lS = { depth: ['colors'] };
  41610. function _k(e, t, i) {
  41611. let r = oS[e.type],
  41612. s = lS[e.type];
  41613. if (s !== void 0) {
  41614. let n = e.color;
  41615. if (s.includes(t)) {
  41616. let a = n[t]?.value?.length;
  41617. if (a !== void 0 && a !== i.length) return !0;
  41618. }
  41619. }
  41620. return r !== void 0 ? r.includes(t) : !1;
  41621. }
  41622. function hS(e, t, i) {
  41623. let r = i.uniforms[`f${i.id}_texture`];
  41624. if (!r) return !1;
  41625. let s = !1,
  41626. n = e;
  41627. if ('image' in n) {
  41628. let a = n.image,
  41629. o = t.image(a),
  41630. l = r;
  41631. l.image instanceof ha || l.image.deref(), (l.image = o);
  41632. }
  41633. if ('video' in n) {
  41634. let a = n.video,
  41635. o = t.video(a),
  41636. l = r;
  41637. l.image instanceof ha || l.image.deref(), (l.image = o);
  41638. }
  41639. if ('wrapping' in n) {
  41640. let a = r;
  41641. a.wrap = n.wrapping;
  41642. }
  41643. if ('repeat' in n || 'offset' in n) {
  41644. let a = 'mat',
  41645. o = i.uniforms[`f${i.id}_${a}`];
  41646. 'repeat' in n && (o.repeat = n.repeat), 'offset' in n && (o.offset = n.offset), o.updateMatrix();
  41647. }
  41648. return s;
  41649. }
  41650. function Ak(e, t, i, r) {
  41651. let s = !1;
  41652. for (let [n, a] of Object.entries(e)) {
  41653. if (!n || a === void 0) continue;
  41654. if (mS(n, i, r)) {
  41655. n === 'visible' && i.type === 'light' && (s = !0);
  41656. continue;
  41657. }
  41658. i.visible = r.visible;
  41659. let o = i.uniforms[`f${i.id}_${n}`];
  41660. if (!!o && !(o instanceof dv))
  41661. switch (((s = s || _k(i, n, a)), o.constructor)) {
  41662. case Ut:
  41663. if (typeof a == 'string') {
  41664. let l = t.getColor(a);
  41665. l && (o.value = l);
  41666. break;
  41667. } else {
  41668. let l = a;
  41669. o.value instanceof Kd ? (o.value = new ji(l.r, l.g, l.b, l.a)) : o.setRGBA(l);
  41670. break;
  41671. }
  41672. case na:
  41673. if (typeof a == 'string') {
  41674. let l = t.getColor(a);
  41675. l && (o.value = l);
  41676. break;
  41677. } else {
  41678. let l = a;
  41679. o.value instanceof Kd ? (o.value = new ji(l.r, l.g, l.b, l.a)) : o.value.setRGBA(l.r, l.g, l.b, l.a);
  41680. break;
  41681. }
  41682. case vr: {
  41683. let l = a;
  41684. o.value.setX(l[0]), o.value.setY(l[1]);
  41685. break;
  41686. }
  41687. case fr: {
  41688. let l = a;
  41689. o.value.setX(l[0]), o.value.setY(l[1]), o.value.setZ(l[2]);
  41690. break;
  41691. }
  41692. case An: {
  41693. hS(a, t, i);
  41694. break;
  41695. }
  41696. case ta: {
  41697. o.value = a.map((l) => new $e(...l));
  41698. break;
  41699. }
  41700. default: {
  41701. o.value = a;
  41702. break;
  41703. }
  41704. }
  41705. }
  41706. return s;
  41707. }
  41708. var cS = class extends St {
  41709. constructor(e, t, i) {
  41710. super('v3'),
  41711. (this.nodeType = 'Matcap'),
  41712. (this.texture = e),
  41713. (this.alpha = t),
  41714. (this.mode = i),
  41715. (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`);
  41716. }
  41717. generate(e, t) {
  41718. if (e.isShader('fragment')) {
  41719. e.addFragmentVariable(this.calpha, 'float');
  41720. let i = e.include(cS.Nodes.matcap);
  41721. e.require('normal'), (e.requires.normal = !0);
  41722. let r = [];
  41723. return (
  41724. r.push(this.texture.generate(e, 't')),
  41725. r.push('normal'),
  41726. r.push(this.alpha.build(e, 'f')),
  41727. r.push(this.mode.build(e, 'i')),
  41728. r.push(this.calpha),
  41729. e.format(i + '(' + r.join(',') + ')', this.getType(e), t)
  41730. );
  41731. } else return console.warn('MatcapNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t);
  41732. }
  41733. },
  41734. dS = cS;
  41735. dS.Nodes = (function () {
  41736. return {
  41737. matcap: new Re(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
  41738. vec3 viewDir = normalize( vViewPosition );
  41739. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  41740. vec3 y = cross( viewDir, x );
  41741. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks
  41742. vec4 matcapColor = texture2D( matcapTex, uv );
  41743. calpha = alpha / clamp( alpha + accumAlpha, 0.00001, 1.0 );
  41744. accumAlpha += ( 1.0 - accumAlpha ) * alpha;
  41745. return matcapColor.rgb;
  41746. }
  41747. `)
  41748. };
  41749. })();
  41750. var jm = class extends dv {
  41751. constructor(e, t) {
  41752. super('t'), (this.image = e), (this.wrap = t);
  41753. }
  41754. get value() {
  41755. return this.image.getTexture(this.wrap);
  41756. }
  41757. },
  41758. Sk = class extends dv {
  41759. constructor(e) {
  41760. super('v3'), (this.image = e), (this._value = new E());
  41761. }
  41762. get value() {
  41763. return (
  41764. (this._value.x = this.image.isVideo ? (this.image.img.videoWidth ?? 0) : this.image.img.width),
  41765. (this._value.y = this.image.isVideo ? (this.image.img.videoHeight ?? 0) : this.image.img.height),
  41766. this._value
  41767. );
  41768. }
  41769. },
  41770. uS = class extends St {
  41771. constructor(e, t, i, r, s, n, a, o, l, h) {
  41772. super('v3'),
  41773. (this.nodeType = 'Toon'),
  41774. (this.positioning = e),
  41775. (this.colors = t),
  41776. (this.steps = i),
  41777. (this.source = r),
  41778. (this.isWorldSpace = s),
  41779. (this.noiseStrength = n),
  41780. (this.noiseScale = a),
  41781. (this.shadowColor = o),
  41782. (this.offset = l),
  41783. (this.alpha = h),
  41784. (this.calpha = `g${this.uuid.toString().replace(/-/g, '')}_calpha`);
  41785. }
  41786. generate(e, t) {
  41787. if ((e.require('worldNormal'), e.require('worldPosition'), e.isShader('fragment'))) {
  41788. e.define('COLORS_MAX', 10), e.addFragmentVariable(this.calpha, 'float');
  41789. let i = e.include(uS.Nodes.toon),
  41790. r = [];
  41791. return (
  41792. r.push(this.positioning.build(e, 'i')),
  41793. r.push(this.colors.build(e, 'v4[]')),
  41794. r.push(this.steps.build(e, 'f[]')),
  41795. r.push(this.source.build(e, 'v3')),
  41796. r.push(this.isWorldSpace.build(e, 'b')),
  41797. r.push(this.noiseStrength.build(e, 'f')),
  41798. r.push(this.noiseScale.build(e, 'f')),
  41799. r.push(this.shadowColor.build(e, 'v4')),
  41800. r.push(this.offset.build(e, 'v3')),
  41801. r.push(this.alpha.build(e, 'f')),
  41802. r.push(this.calpha),
  41803. e.format(i + '(' + r.join(',') + ')', this.getType(e), t)
  41804. );
  41805. } else return console.warn('ToonNode is not compatible with ' + e.shader + ' shader.'), e.format('vec3( 0.0 )', this.getType(e), t);
  41806. }
  41807. },
  41808. pS = uS;
  41809. pS.Nodes = (function () {
  41810. let e = new Re(`float rand(float n) {
  41811. return fract(sin(n) * 43758.5453123);
  41812. }`),
  41813. t = new Re(`float hash1(float p) {
  41814. p = fract(p * 0.011);
  41815. p *= p + 7.5;
  41816. p *= p + p;
  41817. return fract(p);
  41818. }`),
  41819. i = new Re(
  41820. `float valueNoise(vec3 x) {
  41821. const vec3 step = vec3(110, 241, 171);
  41822. vec3 i = floor(x);
  41823. vec3 f = fract(x);
  41824. // For performance, compute the base input to a 1D hash from the integer part of the argument and the
  41825. // incremental change to the 1D based on the 3D -> 1D wrapping
  41826. float n = dot(i, step);
  41827. vec3 u = f * f * (3.0 - 2.0 * f);
  41828. return mix(mix(mix( hash1(n + dot(step, vec3(0, 0, 0))), hash1(n + dot(step, vec3(1, 0, 0))), u.x),
  41829. mix( hash1(n + dot(step, vec3(0, 1, 0))), hash1(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
  41830. mix(mix( hash1(n + dot(step, vec3(0, 0, 1))), hash1(n + dot(step, vec3(1, 0, 1))), u.x),
  41831. mix( hash1(n + dot(step, vec3(0, 1, 1))), hash1(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
  41832. }`,
  41833. [t]
  41834. ),
  41835. r = new Re(`vec3 hash3(vec3 x) {
  41836. x = vec3(dot(x,vec3(127.1, 311.7, 74.7)),
  41837. dot(x,vec3(269.5, 183.3, 246.1)),
  41838. dot(x,vec3(113.5, 271.9, 124.6)));
  41839. return fract(sin(x)*43758.5453123);
  41840. }`),
  41841. s = new Re(
  41842. `vec3 voronoiNoise(in vec3 x)
  41843. {
  41844. vec3 p = floor(x);
  41845. vec3 f = fract(x);
  41846. float id = 0.0;
  41847. vec2 res = vec2(100.0);
  41848. for(int k=-1; k<=1; k++)
  41849. for(int j=-1; j<=1; j++)
  41850. for(int i=-1; i<=1; i++)
  41851. {
  41852. vec3 b = vec3(float(i), float(j), float(k));
  41853. // Comment out the "+ hash(p + b);" part below to get "square" cells
  41854. vec3 r = vec3(b) - f + hash3(p + b);
  41855. float d = dot(r, r);
  41856. if (d < res.x)
  41857. {
  41858. id = dot(p + b, vec3(1.0, 57.0, 113.0));
  41859. res = vec2(d, res.x);
  41860. }
  41861. else if (d < res.y)
  41862. {
  41863. res.y = d;
  41864. }
  41865. }
  41866. return vec3(sqrt(res), abs(id));
  41867. }
  41868. `,
  41869. [r]
  41870. );
  41871. return {
  41872. toon: new Re(
  41873. `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 alpha, out float calpha) {
  41874. float t = 0.0;
  41875. float shadow = 1.0;
  41876. if (positioning == 0) {
  41877. // Can't do this mode if lighting is "none"
  41878. #if (defined(PHONG) || defined(LAMBERT) || defined(STANDARD))
  41879. // Algorithm from Chapter 10 of Graphics Shaders
  41880. const vec3 weights = vec3(0.2125, 0.7154, 0.0721);
  41881. vec3 lpos;
  41882. vec3 l;
  41883. float dproduct;
  41884. #if (NUM_POINT_LIGHTS > 0)
  41885. #if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0)
  41886. PointLightShadow pointLightShadow;
  41887. #endif
  41888. #pragma unroll_loop_start
  41889. for (int i = 0; i < NUM_POINT_LIGHTS; i++) {
  41890. // Light positions are in view-space for some reason?
  41891. lpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
  41892. l = normalize(lpos - worldPosition);
  41893. dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
  41894. // TODO: we want to use "intensity" but it isn't available in the shader code
  41895. //dproduct += dot(pointLights[UNROLLED_LOOP_INDEX].color, weights);
  41896. t = max(t, dproduct);
  41897. // Accumulate shadow contribution
  41898. #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS)
  41899. pointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX];
  41900. shadow *= getPointShadow(
  41901. pointShadowMap[UNROLLED_LOOP_INDEX],
  41902. pointLightShadow.shadowMapSize,
  41903. pointLightShadow.shadowBias,
  41904. pointLightShadow.shadowRadius,
  41905. vPointShadowCoord[UNROLLED_LOOP_INDEX],
  41906. pointLightShadow.shadowCameraNear,
  41907. pointLightShadow.shadowCameraFar);
  41908. #endif
  41909. }
  41910. #pragma unroll_loop_end
  41911. #endif
  41912. #if NUM_DIR_LIGHTS > 0
  41913. #if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0)
  41914. DirectionalLightShadow directionalLightShadow;
  41915. #endif
  41916. #pragma unroll_loop_start
  41917. for (int i = 0; i < NUM_DIR_LIGHTS; i++) {
  41918. // Use the direction vector for directional lights instead
  41919. l = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz;
  41920. dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
  41921. t = max(t, dproduct);
  41922. // Accumulate shadow contribution
  41923. #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS)
  41924. directionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX];
  41925. shadow *= getShadow(
  41926. UNROLLED_LOOP_INDEX,
  41927. directionalShadowMap[UNROLLED_LOOP_INDEX],
  41928. directionalLightShadow.shadowMapSize,
  41929. directionalLightShadow.shadowBias,
  41930. directionalLightShadow.shadowRadius,
  41931. vDirectionalShadowCoord[UNROLLED_LOOP_INDEX]);
  41932. #endif
  41933. }
  41934. #pragma unroll_loop_end
  41935. #endif
  41936. #if NUM_SPOT_LIGHTS > 0
  41937. #if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0)
  41938. SpotLightShadow spotLightShadow;
  41939. #endif
  41940. #pragma unroll_loop_start
  41941. for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {
  41942. lpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
  41943. l = normalize(lpos - worldPosition);
  41944. dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
  41945. t = max(t, dproduct);
  41946. // Accumulate shadow contribution
  41947. #if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS)
  41948. spotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX];
  41949. shadow *= getShadow(
  41950. UNROLLED_LOOP_INDEX,
  41951. spotShadowMap[UNROLLED_LOOP_INDEX],
  41952. spotLightShadow.shadowMapSize,
  41953. spotLightShadow.shadowBias,
  41954. spotLightShadow.shadowRadius,
  41955. vSpotLightCoord[UNROLLED_LOOP_INDEX]);
  41956. #endif
  41957. }
  41958. #pragma unroll_loop_end
  41959. #endif
  41960. t = clamp(t, 0.0, 1.0);
  41961. #endif
  41962. } else if (positioning == 1) {
  41963. vec3 origin = mix(position, worldPosition, float(isWorldSpace));
  41964. vec3 direction = normalize(source - origin);
  41965. t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;
  41966. } else {
  41967. vec3 origin = worldPosition;
  41968. vec3 source = cameraPosition - offset;
  41969. vec3 direction = normalize(source - origin);
  41970. t = dot(direction, normalize(worldNormal)) * 0.5 + 0.5;
  41971. }
  41972. if (noiseStrength > 0.0) {
  41973. // Distort with noise
  41974. vec3 st = position / noiseScale;
  41975. // Voronoi "smooth" noise
  41976. float noise = 1.0 - voronoiNoise(st).x;
  41977. // Voronoi cellular noise
  41978. //float noise = 1.0 - rand(voronoiNoise(st).z);
  41979. // Position warp noise
  41980. // vec3 offset = vec3(
  41981. // simplex3d(st),
  41982. // simplex3d(st + vec3(111.1, 143.89, 217.19)),
  41983. // simplex3d(st + vec3(171.1, 247.89, 117.23))
  41984. // );
  41985. // st += offset;
  41986. // float noise = valueNoise(st);
  41987. t += noise * noiseStrength;
  41988. }
  41989. t = clamp(t, 0.0, 1.0);
  41990. // Compute ramp color
  41991. float p;
  41992. vec4 color = colors[0];
  41993. for (int i = 1; i < COLORS_MAX; i++) {
  41994. p = clamp((t - steps[i-1]) / (steps[i] - steps[i-1]), 0.0, 1.0);
  41995. color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
  41996. }
  41997. // Incorporate custom shadow color
  41998. if (positioning == 0) {
  41999. vec3 blendedShadow = mix(color.rgb, shadowColor.rgb, shadowColor.a);
  42000. color.rgb = mix(blendedShadow, color.rgb, shadow);
  42001. }
  42002. // Accumulate alpha as usual
  42003. float lalpha = alpha * color.a;
  42004. calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
  42005. accumAlpha += (1.0 - accumAlpha) * lalpha;
  42006. return color.xyz;
  42007. }`,
  42008. [wr.simplex, e, i, s]
  42009. )
  42010. };
  42011. })();
  42012. function Gx(e, t, i) {
  42013. e.setUvTransform(i[0], i[1], t[0], t[1], 0, 0, 0);
  42014. }
  42015. var Mk = class extends GA {
  42016. constructor(e, t) {
  42017. super(new Ai()), (this.repeat = e), (this.offset = t), Gx(this.value, e, t);
  42018. }
  42019. updateMatrix() {
  42020. Gx(this.value, this.repeat, this.offset);
  42021. }
  42022. },
  42023. va = class {
  42024. constructor(e, t, i, r) {
  42025. (this.id = e), (this.uuid = t), (this.data = i), (this.uniforms = {});
  42026. for (let s in r) this.uniforms[`f${this.id}_${s}`] = r[s];
  42027. for (let s in i) mS(s, this, i);
  42028. }
  42029. get type() {
  42030. return this.data.type;
  42031. }
  42032. static create(e, t, i, r) {
  42033. if (i.type === 'light') return yo.createLigherLayer(e, t, i, r);
  42034. if (i.type === 'texture' || i.type === 'video') {
  42035. let s = i.type === 'texture' ? r.image(i.texture.image) : r.video(i.texture.video),
  42036. n = new jm(s, i.texture.wrapping),
  42037. a = new Sk(s),
  42038. o = new Mk(i.texture.repeat, i.texture.offset),
  42039. l = new Pe(i.crop ? 1 : 0),
  42040. h = new xt(i.projection ?? 0),
  42041. u = new xt(['x', 'y', 'z'].indexOf(i.axis) ?? 0),
  42042. c = new xt(i.side ?? 0),
  42043. d = new vr(i.size ? new G(i.size[0], i.size[1]) : new G(100, 100)),
  42044. p = new Pe(i.alpha ?? 1),
  42045. f = new xt(i.mode ?? 0),
  42046. g = new rS(n, a, l, h, u, c, d, o, p, f),
  42047. m = new Pt(g.calpha, 'f');
  42048. return new pi(
  42049. e,
  42050. t,
  42051. i,
  42052. { texture: n, textureSize: a, crop: l, projection: h, axis: u, side: c, size: d, mat: o, alpha: p, mode: f },
  42053. g,
  42054. f,
  42055. m
  42056. );
  42057. } else if (i.type === 'matcap') {
  42058. let s = r.image(i.texture.image),
  42059. n = new jm(s, i.texture.wrapping),
  42060. a = new Pe(i.alpha ?? 1),
  42061. o = new xt(i.mode ?? 0),
  42062. l = new dS(n, a, o),
  42063. h = new Pt(l.calpha, 'f');
  42064. return new pi(e, t, i, { texture: n, alpha: a, mode: o }, l, o, h);
  42065. } else if (i.type === 'displace')
  42066. if (i.displacementType === 'noise') {
  42067. let s = new fr(new E(...i.offset)),
  42068. n = new Pe(i.scale ?? 10),
  42069. a = new Pe(i.intensity ?? 8),
  42070. o = new Pe(i.movement ?? 1),
  42071. l = new xt(i.noiseType ?? 0),
  42072. h = new eS(a, o, s, n, l);
  42073. return new fS(e, t, i, { offset: s, scale: n, intensity: a, movement: o, noiseType: l }, h);
  42074. } else throw new Error();
  42075. else return Tk(e, t, i, r);
  42076. }
  42077. updateByOp(e, t, i) {
  42078. let r = e;
  42079. if (r.path[0] === void 0) {
  42080. if (r.type === 0)
  42081. return 'type' in r.props || 'category' in r.props || 'visible' in r.props
  42082. ? (i.scene?.markNeedsUpdateRendererDirty(), !0)
  42083. : Ak(r.props, i.shared, this, t);
  42084. } else if (r.path[0] === 'texture') return 'texture' in t || 'video' in t ? hS(r.props, i.shared, this) : !0;
  42085. return !1;
  42086. }
  42087. dispose() {
  42088. if (Ek(this)) {
  42089. let e = this.uniforms[`f${this.id}_texture`];
  42090. if (!e) return !1;
  42091. let t = e;
  42092. t.image instanceof ha || t.image.deref();
  42093. }
  42094. }
  42095. hasValueByKey(e) {
  42096. return this.uniforms[e] !== void 0;
  42097. }
  42098. hasValue(e) {
  42099. return this.hasValueByKey(`f${this.id}_${e}`);
  42100. }
  42101. setValue(e, t) {
  42102. let i = `f${this.id}_${e}`;
  42103. this.hasValueByKey(i) && t !== void 0 && (this.uniforms[i].value = t);
  42104. }
  42105. getNode(e) {
  42106. let t = `f${this.id}_${e}`;
  42107. if (this.hasValueByKey(t)) return this.uniforms[t];
  42108. }
  42109. getValue(e) {
  42110. let t = `f${this.id}_${e}`;
  42111. if (this.hasValueByKey(t)) return this.uniforms[t].value;
  42112. }
  42113. getName(e) {
  42114. let t = /f\d+_(.*)/.exec(e);
  42115. if (t && t.length > 1) return t[1];
  42116. console.log(`Layer.getName: error ${e}`);
  42117. }
  42118. getNames() {
  42119. let e = [];
  42120. for (let t in this.uniforms) {
  42121. let i = this.getName(t);
  42122. i && e.push(i);
  42123. }
  42124. return e;
  42125. }
  42126. },
  42127. pi = class extends va {
  42128. constructor(e, t, i, r, s, n, a) {
  42129. super(e, t, i, r), (this.params = r), (this.color = s), (this.mode = n), (this.alpha = a);
  42130. }
  42131. },
  42132. fS = class extends va {
  42133. constructor(e, t, i, r, s) {
  42134. super(e, t, i, r), (this.position = s);
  42135. }
  42136. },
  42137. yo = class extends va {
  42138. constructor(e, t, i, r, s) {
  42139. super(e, t, i, s), (this.node = r);
  42140. }
  42141. static createLigherLayer(e, t, i, r) {
  42142. let s,
  42143. n = new Pe(i.alpha),
  42144. a = new xt(i.mode),
  42145. o;
  42146. if (!i.visible) (s = new jA()), (o = {});
  42147. else if (i.category === 'lambert') {
  42148. s = new tk();
  42149. let l = new Ut(r.color(i.emissive) ?? 0);
  42150. (o = { emissive: l }), (s.emissive = l);
  42151. } else if (i.category === 'toon') {
  42152. s = new sk();
  42153. let l = new Pe(i.shininess ?? 30),
  42154. h = new Ut(r.color(i.specular) ?? 1118481);
  42155. (o = { shininess: l, specular: h }), (s.shininess = l), (s.specular = h);
  42156. } else if (i.category === 'physical') {
  42157. s = new rk();
  42158. let l = new Pe(i.roughness ?? 0.3),
  42159. h = new Pe(i.metalness ?? 0),
  42160. u = new Pe(i.reflectivity ?? 0.5);
  42161. (o = { roughness: l, metalness: h, reflectivity: u }), (s.roughness = l), (s.metalness = h), (s.reflectivity = u);
  42162. } else {
  42163. s = new ik();
  42164. let l = new Pe(i.shininess ?? 30),
  42165. h = new Ut(i.specular !== void 0 ? (r.color(i.specular) ?? 1118481) : 1118481);
  42166. (o = { shininess: l, specular: h }), (s.shininess = l), (s.specular = h);
  42167. }
  42168. return (
  42169. (s.alpha = new Pe(1)),
  42170. (s.shadingAlpha = n),
  42171. (s.shadingBlend = a),
  42172. (o.alpha = s.shadingAlpha),
  42173. (o.mode = s.shadingBlend),
  42174. new yo(e, t, i, s, o)
  42175. );
  42176. }
  42177. get category() {
  42178. return this.node.category;
  42179. }
  42180. };
  42181. function Ek(e) {
  42182. let t = e instanceof va ? e.type : e;
  42183. return t === 'texture' || t === 'video' || t === 'displace_map' || t === 'matcap';
  42184. }
  42185. function Ck(e, t, i, r) {
  42186. switch (e.type) {
  42187. case 'color': {
  42188. let s = new Ut(r.color ?? 5526619),
  42189. n = new Pe(r.alpha ?? 1),
  42190. a = new Pt('alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )', 'f');
  42191. a.keywords.alpha = n;
  42192. let o = new xt(r.mode ?? 0);
  42193. return (s.alpha = n), new pi(t, i, e, { color: s, alpha: n, mode: o }, s, o, a);
  42194. }
  42195. case 'fresnel': {
  42196. let s = new Ut(r.color ?? 16777215),
  42197. n = new Pe(r.bias ?? 0.1),
  42198. a = new Pe(r.scale ?? 1),
  42199. o = new Pe(r.intensity ?? 2),
  42200. l = new Pe(r.factor ?? 1),
  42201. h = new Pe(r.alpha ?? 1),
  42202. u = new xt(r.mode ?? 0),
  42203. c = new WA(s, n, a, o, l, h, u),
  42204. d = new Pt(c.calpha, 'f');
  42205. return new pi(t, i, e, { color: s, bias: n, scale: a, intensity: o, factor: l, alpha: h, mode: u }, c, u, d);
  42206. }
  42207. case 'rainbow': {
  42208. let s = new Pe(r.filmThickness ?? 30),
  42209. n = new Pe(r.movement ?? 0),
  42210. a = new fr(r.wavelengths ?? new E(0, 0, 0)),
  42211. o = new Pe(r.noiseStrength ?? 0),
  42212. l = new Pe(r.noiseScale ?? 1),
  42213. h = new fr(r.offset ?? new E(0, 0, 0)),
  42214. u = new Pe(r.alpha ?? 1),
  42215. c = new qA(s, n, a, o, l, h, u),
  42216. d = new Pt(c.calpha, 'f'),
  42217. p = new xt(r.mode ?? 0);
  42218. return new pi(
  42219. t,
  42220. i,
  42221. e,
  42222. { filmThickness: s, movement: n, wavelengths: a, noiseStrength: o, noiseScale: l, offset: h, alpha: u, mode: p },
  42223. c,
  42224. p,
  42225. d
  42226. );
  42227. }
  42228. case 'transmission': {
  42229. let s = new Pe(r.thickness ?? 10),
  42230. n = new Pe(r.ior ?? 1.5),
  42231. a = new Pe(r.roughness ?? 0.5),
  42232. o = Lt.transmissionSize,
  42233. l = Lt.transmissionRenderTarget,
  42234. h = Lt.transmissionRenderTargetDepth,
  42235. u = window.innerWidth,
  42236. c = window.innerHeight,
  42237. d = u >= c ? new vr(c / u, 1) : new vr(1, u / c),
  42238. p = new Pe(r.alpha ?? 1),
  42239. f = new KA(s, n, a, o, l, h, d, p),
  42240. g = new Pt(f.calpha, 'f'),
  42241. m = new xt(r.mode ?? 0);
  42242. return new pi(t, i, e, { thickness: s, ior: n, roughness: a, aspectRatio: d, alpha: p, mode: m }, f, m, g);
  42243. }
  42244. case 'toon': {
  42245. let s = new xt(r.positioning ?? 0),
  42246. n;
  42247. r.colors ? (n = new ta(r.colors.length, r.colors)) : ((n = new ta(10, new $e(0, 0, 0, 1))), (n.value[1] = new $e(1, 1, 1, 1)));
  42248. let a;
  42249. r.steps ? (a = new ea(r.steps.length, r.steps)) : ((a = new ea(10, 1)), (a.value[0] = 0));
  42250. let o = new fr(r.source ?? new E(0, 0, 0)),
  42251. l = new Ol(r.isWorldSpace ?? !0),
  42252. h = new Pe(r.noiseStrength ?? 0),
  42253. u = new Pe(r.noiseScale ?? 1),
  42254. c = new na(r.shadowColor),
  42255. d = new fr(r.offset ?? new E(0, 0, 0)),
  42256. p = new Pe(r.alpha ?? 1),
  42257. f = new pS(s, n, a, o, l, h, u, c, d, p),
  42258. g = new Pt(f.calpha, 'f'),
  42259. m = new xt(r.mode ?? 0);
  42260. return new pi(
  42261. t,
  42262. i,
  42263. e,
  42264. {
  42265. positioning: s,
  42266. colors: n,
  42267. steps: a,
  42268. source: o,
  42269. isWorldSpace: l,
  42270. noiseStrength: h,
  42271. noiseScale: u,
  42272. shadowColor: c,
  42273. offset: d,
  42274. alpha: p,
  42275. mode: m
  42276. },
  42277. f,
  42278. m,
  42279. g
  42280. );
  42281. }
  42282. case 'outline': {
  42283. let s = new Ut(r.outlineColor ?? 16777215),
  42284. n = new Ut(r.contourColor ?? 16777215),
  42285. a = new Pe(r.outlineWidth ?? 0.1),
  42286. o = new Pe(r.contourWidth ?? 0.1),
  42287. l = new Pe(r.outlineThreshold ?? 0.1),
  42288. h = new Pe(r.contourThreshold ?? 0.1),
  42289. u = new Pe(r.outlineSmoothing ?? 0.1),
  42290. c = new Pe(r.contourFrequency ?? 0.1),
  42291. d = new fr(r.contourDirection ?? new E(0, 1, 0)),
  42292. p = new Ol(r.positionalLines ?? !1),
  42293. f = new Ol(r.compensation ?? !0),
  42294. g = Lt.normalRenderTarget,
  42295. m = Lt.normalRenderTargetDepth,
  42296. v = Lt.pixelRatioNode,
  42297. y = Lt.resolution,
  42298. b = new Pe(r.alpha ?? 1),
  42299. x = new QA(s, n, a, o, l, h, u, c, d, p, f, y, g, m, v, b),
  42300. w = new Pt(x.calpha, 'f'),
  42301. A = new xt(r.mode ?? 0);
  42302. return new pi(
  42303. t,
  42304. i,
  42305. e,
  42306. {
  42307. outlineColor: s,
  42308. contourColor: n,
  42309. outlineWidth: a,
  42310. contourWidth: o,
  42311. outlineThreshold: l,
  42312. contourThreshold: h,
  42313. outlineSmoothing: u,
  42314. contourFrequency: c,
  42315. contourDirection: d,
  42316. positionalLines: p,
  42317. compensation: f,
  42318. alpha: b,
  42319. mode: A
  42320. },
  42321. x,
  42322. A,
  42323. w
  42324. );
  42325. }
  42326. case 'depth': {
  42327. let s = new xt(r.gradientType ?? 0),
  42328. n = new Ol(r.smooth ?? !1),
  42329. a = new Pe(r.near ?? 50),
  42330. o = new Pe(r.far ?? 200),
  42331. l = new Pe(r.isVector ?? 1),
  42332. h = new Pe(r.isWorldSpace ?? 0),
  42333. u = new fr(r.origin ?? new E()),
  42334. c = new fr(r.direction ?? new E()),
  42335. d;
  42336. r.colors ? (d = new ta(r.colors.length, r.colors)) : ((d = new ta(2, new $e(0, 0, 0, 1))), (d.value[1] = new $e(1, 1, 1, 1)));
  42337. let p;
  42338. r.steps ? (p = new ea(r.steps.length, r.steps)) : ((p = new ea(2, 1)), (p.value[0] = 0));
  42339. let f = new Pe(r.alpha ?? 1),
  42340. g = new xt(r.mode ?? 0),
  42341. m = new JA(s, n, a, o, l, h, u, c, d, p, f),
  42342. v = new Pt(m.calpha, 'f');
  42343. return new pi(
  42344. t,
  42345. i,
  42346. e,
  42347. {
  42348. gradientType: s,
  42349. smooth: n,
  42350. near: a,
  42351. far: o,
  42352. isVector: l,
  42353. isWorldSpace: h,
  42354. origin: u,
  42355. direction: c,
  42356. colors: d,
  42357. steps: p,
  42358. alpha: f,
  42359. mode: g
  42360. },
  42361. m,
  42362. g,
  42363. v
  42364. );
  42365. }
  42366. case 'noise': {
  42367. let s = new Pe(r.scale ?? 1),
  42368. n = new fr(r.size ?? new E(100, 100, 100)),
  42369. a = new Pe(r.move ?? 1),
  42370. o = new vr(r.fA ?? new G(1.7, 9.2)),
  42371. l = new vr(r.fB ?? new G(8.3, 2.8)),
  42372. h = new vr(r.distortion ?? new G(1, 1)),
  42373. u = new na(r.colorA),
  42374. c = new na(r.colorB),
  42375. d = new na(r.colorC),
  42376. p = new na(r.colorD),
  42377. f = new Pe(r.alpha ?? 1),
  42378. g = new xt(r.mode ?? 0),
  42379. m = new xt(r.noiseType ?? 0),
  42380. v = new VA(s, n, a, o, l, h, u, c, d, p, f, m),
  42381. y = new Pt(v.calpha, 'f');
  42382. return new pi(
  42383. t,
  42384. i,
  42385. e,
  42386. {
  42387. scale: s,
  42388. size: n,
  42389. move: a,
  42390. fA: o,
  42391. fB: l,
  42392. distortion: h,
  42393. colorA: u,
  42394. colorB: c,
  42395. colorC: d,
  42396. colorD: p,
  42397. alpha: f,
  42398. mode: g,
  42399. noiseType: m
  42400. },
  42401. v,
  42402. g,
  42403. y
  42404. );
  42405. }
  42406. case 'normal': {
  42407. let s = new fr(r.cnormal ?? new E(1, 1, 1)),
  42408. n = new Pe(r.alpha ?? 1),
  42409. a = new xt(r.mode ?? 0),
  42410. o = new nS(s, n),
  42411. l = new Pt('alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )', 'f');
  42412. return (l.keywords.alpha = n), new pi(t, i, e, { cnormal: s, alpha: n, mode: a }, o, a, l);
  42413. }
  42414. case 'gradient': {
  42415. let s = new xt(r.gradientType ?? 0),
  42416. n = new Ol(r.smooth ?? !1),
  42417. a;
  42418. r.colors ? (a = new ta(r.colors.length, r.colors)) : ((a = new ta(10, new $e(0, 0, 0, 1))), (a.value[1] = new $e(1, 1, 1, 1)));
  42419. let o;
  42420. r.steps ? (o = new ea(r.steps.length, r.steps)) : ((o = new ea(10, 1)), (o.value[0] = 0));
  42421. let l = new vr(r.offset ?? new G(0, 0)),
  42422. h = new vr(r.morph ?? new G(0, 0)),
  42423. u = new Pe(r.angle ?? 0),
  42424. c = new Pe(r.alpha ?? 1),
  42425. d = new xt(r.mode ?? 0),
  42426. p = new iS(s, n, a, o, l, h, u, c),
  42427. f = new Pt(p.calpha, 'f');
  42428. return new pi(
  42429. t,
  42430. i,
  42431. e,
  42432. { gradientType: s, smooth: n, colors: a, steps: o, offset: l, morph: h, angle: u, alpha: c, mode: d },
  42433. p,
  42434. d,
  42435. f
  42436. );
  42437. }
  42438. default: {
  42439. let s = new Ut(1, 0, 0, 1),
  42440. n = new Pe(1),
  42441. a = new Pt('alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )', 'f');
  42442. a.keywords.alpha = n;
  42443. let o = new xt(0);
  42444. return (s.alpha = n), new pi(t, i, e, { color: s, alpha: n, mode: o }, s, o, a);
  42445. }
  42446. }
  42447. }
  42448. function Tk(e, t, i, r) {
  42449. let s = nk(i, r);
  42450. return Ck(i, e, t, s);
  42451. }
  42452. function mS(e, t, i) {
  42453. if (i.type === 'displace' && (e === 'intensity' || e === 'visible')) {
  42454. let r = t.uniforms[`f${t.id}_intensity`];
  42455. return r ? ((r.value = i.intensity * (i.visible ? 1 : 0)), r) : void 0;
  42456. }
  42457. if (i.type !== 'displace' && (e === 'alpha' || e === 'visible')) {
  42458. let r = t.uniforms[`f${t.id}_alpha`];
  42459. if (!r) return;
  42460. if (((r.value = i.alpha * (i.visible ? 1 : 0)), i.type === 'outline' && e === 'visible')) {
  42461. let s = t.uniforms[`f${t.id}_compensation`];
  42462. s && (s.value = i.compensation && i.visible);
  42463. }
  42464. return r;
  42465. }
  42466. }
  42467. function Jd(e, t) {
  42468. let i = 0;
  42469. for (let r of e.layers)
  42470. if (
  42471. r.data.type !== 'displace' &&
  42472. 'alpha' in r.data &&
  42473. r.data.type !== 'light' &&
  42474. r.data.type !== 'fresnel' &&
  42475. r.data.type !== 'texture' &&
  42476. r.data.type !== 'matcap' &&
  42477. r.data.type !== 'rainbow' &&
  42478. r.data.type !== 'outline'
  42479. ) {
  42480. let s = r.data.visible ? r.data.alpha : 0;
  42481. if ((s === 1 && r.data.type === 'depth') || r.data.type === 'gradient') {
  42482. for (let n of r.data.colors)
  42483. if (n[3] < 1) {
  42484. s = n[3];
  42485. break;
  42486. }
  42487. } else if (s === 1 && r.data.type === 'noise') {
  42488. let n = t.color(r.data.colorA).a,
  42489. a = t.color(r.data.colorB).a,
  42490. o = t.color(r.data.colorC).a,
  42491. l = t.color(r.data.colorD).a,
  42492. h = Math.min(n, Math.min(a, Math.min(o, l)));
  42493. h < 1 && (s = h);
  42494. }
  42495. i += (1 - i) * s;
  42496. }
  42497. return i < 1;
  42498. }
  42499. var Ln = class extends ri {
  42500. constructor() {
  42501. super(void 0),
  42502. (this.flatShading = !1),
  42503. (this.cacheKey = ''),
  42504. (this.fog = !0),
  42505. (this.dithering = !0),
  42506. (this.vertexColors = !0),
  42507. (this.transparent = !0);
  42508. }
  42509. customProgramCacheKey() {
  42510. return this.cacheKey;
  42511. }
  42512. },
  42513. Pk = class extends Ln {
  42514. constructor(e, t, i, r) {
  42515. super(), (this.flatShading = e), (this.side = t), (this.wireframe = i), (this.root = r);
  42516. }
  42517. updateAfterBuild() {
  42518. let e = this.root;
  42519. (this.lights = e.lights),
  42520. (this.vertexShader = e.vertexShader),
  42521. (this.fragmentShader = e.fragmentShader),
  42522. (this.defines = e.defines),
  42523. (this.uniforms = e.uniforms),
  42524. (this.extensions = e.extensions),
  42525. (this.transparent = e.transparent),
  42526. (this.cacheKey = e.customProgramCacheKey() + 'flat' + this.flatShading + this.side);
  42527. }
  42528. onBeforeCompile(e, t) {
  42529. this.root.onBeforeCompile(e);
  42530. }
  42531. get data() {
  42532. return this.root.data;
  42533. }
  42534. get category() {
  42535. return this.root.category;
  42536. }
  42537. getFlavor(e, t, i) {
  42538. return this.root.getFlavor(e, t, i);
  42539. }
  42540. get layers() {
  42541. return this.root.layers;
  42542. }
  42543. get fragment() {
  42544. return this.root.fragment;
  42545. }
  42546. getLayersOfType(e) {
  42547. return this.root.getLayersOfType(e);
  42548. }
  42549. getLayerByUuid(e) {
  42550. return this.root.getLayerByUuid(e);
  42551. }
  42552. updateByOp(e, t, i) {
  42553. this.root.updateByOp(e, t, i);
  42554. }
  42555. nodeMaterialDispose() {
  42556. this.root.nodeMaterialDispose();
  42557. }
  42558. },
  42559. gS = class extends Ln {
  42560. constructor(e, t) {
  42561. super(),
  42562. (this.data = e),
  42563. (this.layerIdGen = 0),
  42564. (this.flavors = []),
  42565. (this.type = 'NodeMaterial'),
  42566. (this.updaters = []),
  42567. this.reset0(e, t);
  42568. }
  42569. get nodeMaterial() {
  42570. return this;
  42571. }
  42572. getFlavor(e, t, i) {
  42573. let r = i ? 6 : (e ? 3 : 0) + t;
  42574. if (r === 0) return this;
  42575. this.flavors === void 0 && (this.flavors = []), (r -= 1);
  42576. let s = this.flavors[r];
  42577. return (
  42578. s === void 0 && ((s = new Pk(e, t, i, this)), (this.flavors[r] = s), (s.flatShading = e), (s.side = t), s.updateAfterBuild()), s
  42579. );
  42580. }
  42581. get fragment() {
  42582. return this.lightLayer.node;
  42583. }
  42584. get category() {
  42585. return this.lightLayer.category;
  42586. }
  42587. reset(e, t) {
  42588. this.data !== e && this.reset0(e, t);
  42589. }
  42590. reset0(e, t) {
  42591. this.data = e;
  42592. let i = e.layers ?? nr.defaultTwoLayerData('phong').layers;
  42593. (this.layers = i.map((r) => va.create(this.layerIdGen++, r.id, r.data, t.shared))),
  42594. this.layers.reverse(),
  42595. (this.name = e.name ?? 'Untitled Material'),
  42596. this.onUpdate(),
  42597. (this.transparent = Jd(e, t.shared));
  42598. }
  42599. getLayersOfType(e) {
  42600. return this.layers.filter((t) => t.type === e);
  42601. }
  42602. getLayerByUuid(e) {
  42603. return this.layers.find((t) => t.uuid === e);
  42604. }
  42605. onUpdate() {
  42606. (this.cacheKey = this.computeCacheKey()),
  42607. (this.lightLayer = this.layers.find((e) => e instanceof yo)),
  42608. this.lightLayer === void 0 && (this.lightLayer = new yo(0, '', { ...xr.defaultData('light', 'phong'), visible: !1 }, new jA(), {})),
  42609. this.dispose();
  42610. for (let e of this.flavors) e && e.dispose();
  42611. this.blendColors(), this.blendAfterColors(), this.blendPositions();
  42612. }
  42613. updateByOp(e, t, i) {
  42614. if ((t !== void 0 ? (this.data = t) : (t = this.data), (this.transparent = Jd(t, i.shared)), e.path[0] === 'layers')) {
  42615. this.data = t;
  42616. let r = i.shared,
  42617. s = e.path[1];
  42618. if (s === void 0) {
  42619. if ((this.layers.reverse(), e.type === 4)) {
  42620. let n = va.create(this.layerIdGen++, e.id, e.data, i.shared);
  42621. this.layers.splice(e.localIndex, 0, n), i.scene?.markNeedsUpdateRendererDirty();
  42622. } else if (e.type === 5) this.layers.splice(e.localIndex, 1)[0].dispose(), i.scene?.markNeedsUpdateRendererDirty();
  42623. else if (e.type === 6) {
  42624. let n = this.layers.findIndex((o) => o.uuid === e.id),
  42625. a = this.layers[n];
  42626. this.layers.splice(n, 1), this.layers.splice(e.localIndex, 0, a), i.scene?.markNeedsUpdateRendererDirty();
  42627. }
  42628. this.layers.reverse(), this.onUpdate();
  42629. } else {
  42630. let n = this.layers.find((a) => a.uuid === s);
  42631. if (n) {
  42632. let a = t.layers.data(s);
  42633. if (n.updateByOp({ ...e, path: e.path.slice(2) }, a, i)) {
  42634. let o = va.create(this.layerIdGen++, s, a, r);
  42635. this.layers.splice(
  42636. this.layers.findIndex((l) => l.uuid === s),
  42637. 1,
  42638. o
  42639. ),
  42640. this.onUpdate();
  42641. }
  42642. }
  42643. }
  42644. } else this.reset(t, i);
  42645. }
  42646. blendColors() {
  42647. let e = this.layers.findIndex((i) => i instanceof pi),
  42648. t = this.layers.findIndex((i) => i instanceof yo);
  42649. if (e !== -1 && e < t) {
  42650. let i = this.layers[e].color;
  42651. for (let r = e + 1; r < t; ++r) {
  42652. let s = this.layers[r];
  42653. s instanceof pi && (i = new jx(i, s.color, s.alpha, s.mode));
  42654. }
  42655. this.fragment.color = i;
  42656. } else this.fragment.color = void 0;
  42657. }
  42658. blendAfterColors() {
  42659. let e = new Pt('outgoingLight', 'f'),
  42660. t = this.layers.findIndex((i) => i instanceof yo);
  42661. if (this.layers.length > t + 1) {
  42662. for (let i = t + 1; i < this.layers.length; ++i) {
  42663. let r = this.layers[i];
  42664. r instanceof pi && (e = new jx(e, r.color, r.alpha, r.mode));
  42665. }
  42666. this.fragment.afterColor = e;
  42667. } else this.fragment.afterColor = void 0;
  42668. }
  42669. blendPositions() {
  42670. let e = this.layers.filter((t) => t instanceof fS);
  42671. if (e.length > 0) {
  42672. let t = e[0].position;
  42673. for (let i = 1; i < e.length; ++i)
  42674. e[i] && ((t = new cs(t, e[i].position, cs.ADD)), (t = new cs(t, new Pe(0.5).setReadonly(!0), cs.MUL)));
  42675. this.fragment.position = t;
  42676. } else this.fragment.position = void 0;
  42677. }
  42678. getDefines() {
  42679. return this.defines;
  42680. }
  42681. getUniforms() {
  42682. return this.uniforms;
  42683. }
  42684. getVertexShader() {
  42685. return this.vertexShader;
  42686. }
  42687. getFragmentShader() {
  42688. return this.fragmentShader;
  42689. }
  42690. onBeforeCompile(e) {
  42691. this.build(),
  42692. (e.defines = this.defines),
  42693. (e.uniforms = this.uniforms),
  42694. (e.vertexShader = this.vertexShader),
  42695. (e.fragmentShader = this.fragmentShader),
  42696. (e.extensionDerivatives = this.extensions.derivatives === !0),
  42697. (e.extensionFragDepth = this.extensions.fragDepth === !0),
  42698. (e.extensionDrawBuffers = this.extensions.drawBuffers === !0),
  42699. (e.extensionShaderTextureLOD = this.extensions.shaderTextureLOD === !0);
  42700. }
  42701. clampUniformsForPreview(e, t) {
  42702. let i = (r, s, n) => Math.min(Math.max(r, s), n);
  42703. for (let r of this.layers)
  42704. if (r.type === 'displace') {
  42705. let s = i(r.uniforms[`f${r.id}_intensity`].value, e, t);
  42706. r.uniforms[`f${r.id}_intensity`].value = s;
  42707. }
  42708. }
  42709. computeCacheKey() {
  42710. let e = '[';
  42711. for (let { data: t } of this.data.layers)
  42712. if (t.type === 'light') e += `"${t.visible ? t.category.toUpperCase() : 'Basic'}"`;
  42713. else {
  42714. let i = (oS[t.type] ?? []).map((n) => t[n]),
  42715. r = (lS[t.type] ?? []).map((n) => t[n]?.length ?? 0),
  42716. s = [...i, ...r];
  42717. s.length ? (e += `["${t.type}", "${s.join('","')}"],`) : (e += `"${t.type}",`);
  42718. }
  42719. return (e = e.slice(0, -1) + ']'), e;
  42720. }
  42721. updateFrame(e) {
  42722. for (let t = 0; t < this.updaters.length; ++t) e.updateNode(this.updaters[t]);
  42723. }
  42724. build() {
  42725. let e = new ek();
  42726. (this.lights = this.lightLayer.data.visible),
  42727. e.build(this.fragment, this.fragment),
  42728. (this.vertexShader = e.getCode('vertex')),
  42729. (this.fragmentShader = e.getCode('fragment')),
  42730. (this.defines = e.defines),
  42731. (this.uniforms = e.uniforms),
  42732. (this.extensions = e.extensions),
  42733. (this.updaters = e.updaters);
  42734. for (let t of this.flavors) t && t.updateAfterBuild();
  42735. return this;
  42736. }
  42737. nodeMaterialDispose() {
  42738. this.layers.forEach((e) => e.dispose()), super.dispose();
  42739. for (let e of this.flavors) e && e.dispose();
  42740. }
  42741. assetsLoaded() {
  42742. for (let e of this.layers)
  42743. if (e instanceof pi) {
  42744. let t = e.params.texture;
  42745. if (t instanceof jm && !t.image.loaded) return !1;
  42746. }
  42747. return !0;
  42748. }
  42749. getHash() {
  42750. let e = '{';
  42751. return (e += '"fragment":' + this.fragment.getHash()), (e += '}'), e;
  42752. }
  42753. };
  42754. Object.defineProperties(Ln.prototype, {
  42755. properties: {
  42756. get: function () {
  42757. return this.fragment.properties;
  42758. }
  42759. }
  42760. });
  42761. var Gm = class extends gS {},
  42762. Dk = Eh(X2()),
  42763. Vx = new Map();
  42764. function Lk(e) {
  42765. if (typeof e == 'string') return e;
  42766. let t = Vx.get(e);
  42767. return t || ((t = { url: URL.createObjectURL(new Blob([e])) }), Vx.set(e, t)), t.url;
  42768. }
  42769. var Yl = class {
  42770. constructor({ src: e, volume: t, delay: i, loop: r }) {
  42771. (this._volume = 1),
  42772. (this.delay = 0),
  42773. (this._loop = 1),
  42774. (this.loopsRemaining = 0),
  42775. (this._status = 'stopped'),
  42776. (this.onEnd = () => {
  42777. this.loopsRemaining === 1 / 0
  42778. ? this.replay()
  42779. : this.loopsRemaining > 1
  42780. ? (this.replay(), this.loopsRemaining--)
  42781. : ((this._status = 'stopped'), (this.loopsRemaining = this._loop));
  42782. });
  42783. let s;
  42784. typeof e == 'string' ? (s = { src: e }) : (s = { src: Lk(e), format: 'wav' }),
  42785. (this.sound = new Dk.Howl(s)),
  42786. this.sound.on('end', this.onEnd),
  42787. (this.src = e),
  42788. t !== void 0 && (this.volume = t),
  42789. i !== void 0 && (this.delay = i),
  42790. r !== void 0 && (this.loop = r);
  42791. }
  42792. get status() {
  42793. return this._status;
  42794. }
  42795. get volume() {
  42796. return this._volume;
  42797. }
  42798. set volume(e) {
  42799. (this._volume = e), this.sound.volume(e);
  42800. }
  42801. get loop() {
  42802. return this._loop;
  42803. }
  42804. set loop(e) {
  42805. (this._loop = e), (this.loopsRemaining = e);
  42806. }
  42807. replay() {
  42808. this.clearDelay(),
  42809. (this.delayTimerId = window.setTimeout(() => {
  42810. this.sound.play(), this.clearDelay();
  42811. }, this.delay));
  42812. }
  42813. fade(e, t = 1e3) {
  42814. e
  42815. ? (this.sound.volume(this._volume),
  42816. this.clearFade(),
  42817. (this.fadeTimerId = window.setTimeout(() => {
  42818. this.sound.fade(this._volume, 0, t), this.clearFade();
  42819. }, e)))
  42820. : this.sound.fade(this._volume, 0, t);
  42821. }
  42822. on(e, t, i) {
  42823. this.sound.on(e, t, i);
  42824. }
  42825. off(e, t, i) {
  42826. this.sound.off(e, t, i);
  42827. }
  42828. play() {
  42829. this._status === 'playing' ||
  42830. this.sound.playing() ||
  42831. (this._status === 'paused'
  42832. ? (this.sound.seek() === 0 ? this.replay() : this.sound.play(), (this._status = 'playing'))
  42833. : this._status === 'stopped' && (this.replay(), (this._status = 'playing')));
  42834. }
  42835. pause() {
  42836. this._status === 'playing' && (this.sound.pause(), this.clearFade(), this.clearDelay(), (this._status = 'paused'));
  42837. }
  42838. stop() {
  42839. this.sound.stop(), (this.loopsRemaining = this._loop), this.clearFade(), this.clearDelay(), (this._status = 'stopped');
  42840. }
  42841. clearFade() {
  42842. this.fadeTimerId && (clearTimeout(this.fadeTimerId), delete this.fadeTimerId);
  42843. }
  42844. clearDelay() {
  42845. this.delayTimerId && (clearTimeout(this.delayTimerId), delete this.delayTimerId);
  42846. }
  42847. dispose(e = !1) {
  42848. this.off(), this.stop(), this.clearFade(), this.clearDelay();
  42849. }
  42850. },
  42851. Ok = class {
  42852. constructor() {
  42853. (this.type = 'ShapePath'), (this.color = new Ge()), (this.subPaths = []), (this.currentPath = null);
  42854. }
  42855. moveTo(e, t) {
  42856. return (this.currentPath = new yd()), this.subPaths.push(this.currentPath), this.currentPath.moveTo(e, t), this;
  42857. }
  42858. lineTo(e, t) {
  42859. return this.currentPath?.lineTo(e, t), this;
  42860. }
  42861. quadraticCurveTo(e, t, i, r) {
  42862. return this.currentPath?.quadraticCurveTo(e, t, i, r), this;
  42863. }
  42864. bezierCurveTo(e, t, i, r, s, n) {
  42865. return this.currentPath?.bezierCurveTo(e, t, i, r, s, n), this;
  42866. }
  42867. splineThru(e) {
  42868. return this.currentPath?.splineThru(e), this;
  42869. }
  42870. toShapes() {
  42871. let e = { ORIGIN: 0, DESTINATION: 1, BETWEEN: 2, LEFT: 3, RIGHT: 4, BEHIND: 5, BEYOND: 6 },
  42872. t = { loc: e.ORIGIN, t: 0 };
  42873. function i(p, f, g, m) {
  42874. let v = p.x,
  42875. y = f.x,
  42876. b = g.x,
  42877. x = m.x,
  42878. w = p.y,
  42879. A = f.y,
  42880. S = g.y,
  42881. _ = m.y,
  42882. M = (x - b) * (w - S) - (_ - S) * (v - b),
  42883. C = (y - v) * (w - S) - (A - w) * (v - b),
  42884. T = (_ - S) * (y - v) - (x - b) * (A - w),
  42885. P = M / T,
  42886. L = C / T;
  42887. if ((T === 0 && M !== 0) || P <= 0 || P >= 1 || L < 0 || L > 1) return null;
  42888. if (M === 0 && T === 0) {
  42889. for (let D = 0; D < 2; D++)
  42890. if ((r(D === 0 ? g : m, p, f), t.loc === e.ORIGIN)) {
  42891. let k = D === 0 ? g : m;
  42892. return { x: k.x, y: k.y, t: t.t };
  42893. } else if (t.loc === e.BETWEEN) {
  42894. let k = +(v + t.t * (y - v)).toPrecision(10),
  42895. W = +(w + t.t * (A - w)).toPrecision(10);
  42896. return { x: k, y: W, t: t.t };
  42897. }
  42898. return null;
  42899. } else {
  42900. for (let W = 0; W < 2; W++)
  42901. if ((r(W === 0 ? g : m, p, f), t.loc === e.ORIGIN)) {
  42902. let X = W === 0 ? g : m;
  42903. return { x: X.x, y: X.y, t: t.t };
  42904. }
  42905. let D = +(v + P * (y - v)).toPrecision(10),
  42906. k = +(w + P * (A - w)).toPrecision(10);
  42907. return { x: D, y: k, t: P };
  42908. }
  42909. }
  42910. function r(p, f, g) {
  42911. let m = g.x - f.x,
  42912. v = g.y - f.y,
  42913. y = p.x - f.x,
  42914. b = p.y - f.y,
  42915. x = m * b - y * v;
  42916. if (p.x === f.x && p.y === f.y) {
  42917. (t.loc = e.ORIGIN), (t.t = 0);
  42918. return;
  42919. }
  42920. if (p.x === g.x && p.y === g.y) {
  42921. (t.loc = e.DESTINATION), (t.t = 1);
  42922. return;
  42923. }
  42924. if (x < -Number.EPSILON) {
  42925. t.loc = e.LEFT;
  42926. return;
  42927. }
  42928. if (x > Number.EPSILON) {
  42929. t.loc = e.RIGHT;
  42930. return;
  42931. }
  42932. if (m * y < 0 || v * b < 0) {
  42933. t.loc = e.BEHIND;
  42934. return;
  42935. }
  42936. if (Math.sqrt(m * m + v * v) < Math.sqrt(y * y + b * b)) {
  42937. t.loc = e.BEYOND;
  42938. return;
  42939. }
  42940. let w;
  42941. m !== 0 ? (w = y / m) : (w = b / v), (t.loc = e.BETWEEN), (t.t = w);
  42942. }
  42943. function s(p, f) {
  42944. let g = [],
  42945. m = [];
  42946. for (let v = 1; v < p.length; v++) {
  42947. let y = p[v - 1],
  42948. b = p[v];
  42949. for (let x = 1; x < f.length; x++) {
  42950. let w = f[x - 1],
  42951. A = f[x],
  42952. S = i(y, b, w, A);
  42953. S !== null &&
  42954. g.find((_) => _.t <= S.t + Number.EPSILON && _.t >= S.t - Number.EPSILON) === void 0 &&
  42955. (g.push(S), m.push(new G(S.x, S.y)));
  42956. }
  42957. }
  42958. return m;
  42959. }
  42960. function n(p, f, g) {
  42961. let m = new G();
  42962. f.getCenter(m);
  42963. let v = [];
  42964. return (
  42965. g.forEach((y) => {
  42966. y.boundingBox.containsPoint(m) &&
  42967. s(p, y.points).forEach((b) => {
  42968. v.push({ identifier: y.identifier, isCW: y.isCW, point: b });
  42969. });
  42970. }),
  42971. v.sort((y, b) => y.point.x - b.point.x),
  42972. v
  42973. );
  42974. }
  42975. function a(p, f, g, m, v) {
  42976. (v == null || v === '') && (v = 'nonzero');
  42977. let y = new G();
  42978. p.boundingBox.getCenter(y);
  42979. let b = [new G(g, y.y), new G(m, y.y)],
  42980. x = n(b, p.boundingBox, f);
  42981. x.sort((C, T) => C.point.x - T.point.x);
  42982. let w = [],
  42983. A = [];
  42984. x.forEach((C) => {
  42985. C.identifier === p.identifier ? w.push(C) : A.push(C);
  42986. });
  42987. let S = w[0].point.x,
  42988. _ = [],
  42989. M = 0;
  42990. for (; M < A.length && A[M].point.x < S; )
  42991. _.length > 0 && _[_.length - 1] === A[M].identifier ? _.pop() : _.push(A[M].identifier), M++;
  42992. if ((_.push(p.identifier), v === 'evenodd')) {
  42993. let C = _.length % 2 === 0,
  42994. T = _[_.length - 2];
  42995. return { identifier: p.identifier, isHole: C, for: T };
  42996. } else if (v === 'nonzero') {
  42997. let C = !0,
  42998. T = null,
  42999. P = null;
  43000. for (let L = 0; L < _.length; L++) {
  43001. let D = _[L];
  43002. f[D] && (C ? ((P = f[D].isCW), (C = !1), (T = D)) : P !== f[D].isCW && ((P = f[D].isCW), (C = !0)));
  43003. }
  43004. return { identifier: p.identifier, isHole: C, for: T };
  43005. } else console.warn('fill-rule: "' + v + '" is currently not implemented.');
  43006. }
  43007. let o = 0,
  43008. l = 999999999,
  43009. h = -999999999,
  43010. u = [];
  43011. this.subPaths.forEach((p) => {
  43012. let f = p.getPoints(),
  43013. g = -999999999,
  43014. m = 999999999,
  43015. v = -999999999,
  43016. y = 999999999;
  43017. for (let b = 0; b < f.length; b++) {
  43018. let x = f[b];
  43019. x.y > g && (g = x.y), x.y < m && (m = x.y), x.x > v && (v = x.x), x.x < y && (y = x.x);
  43020. }
  43021. h <= v && (h = v + 1),
  43022. l >= y && (l = y - 1),
  43023. f.length &&
  43024. u.push({
  43025. curves: p.curves,
  43026. points: f,
  43027. isCW: Rw.isClockWise(f),
  43028. identifier: o++,
  43029. boundingBox: new rL(new G(y, m), new G(v, g))
  43030. });
  43031. });
  43032. let c = u.map((p) => a(p, u, l, h, this.userData?.style.fillRule)),
  43033. d = [];
  43034. return (
  43035. u.forEach((p) => {
  43036. let f = c[p.identifier];
  43037. if (f && !f.isHole) {
  43038. let g = new xd();
  43039. (g.curves = p.curves),
  43040. c
  43041. .filter((m) => m?.isHole && m.for === p.identifier)
  43042. .forEach((m) => {
  43043. if (m) {
  43044. let v = u[m.identifier],
  43045. y = new yd();
  43046. (y.curves = v.curves), g.holes.push(y);
  43047. }
  43048. }),
  43049. d.push(g);
  43050. }
  43051. }),
  43052. d
  43053. );
  43054. }
  43055. },
  43056. vS,
  43057. Hx = new Promise((e) => {
  43058. vS = e;
  43059. }),
  43060. Wx = !1;
  43061. async function Ik() {
  43062. if (Wx) return;
  43063. let e = await import('./opentype.js');
  43064. vS(e), (Wx = !0);
  43065. }
  43066. var Rk = class {
  43067. async load(e, t, i = () => {}) {
  43068. let { load: r } = await Hx;
  43069. r(e, (s, n) => {
  43070. s || !n ? i(s ?? 'Something went wrong') : t(n);
  43071. });
  43072. }
  43073. async parse(e) {
  43074. let { parse: t, Bidi: i } = await Hx;
  43075. try {
  43076. let r = t(e),
  43077. s = new i(),
  43078. n = (a) => r.charToGlyphIndex(a.char);
  43079. return s.registerModifier('glyphIndex', null, n), s.applyFeatures(r, r.defaultRenderOptions.features), { font: r, bidi: s };
  43080. } catch (r) {
  43081. console.error(r);
  43082. }
  43083. }
  43084. };
  43085. async function Bk(e) {
  43086. return await (await fetch(e)).arrayBuffer();
  43087. }
  43088. var zk = new Rk();
  43089. async function Xx(e) {
  43090. let t,
  43091. i,
  43092. r = !1;
  43093. if ((e.url ? ((t = await Bk(e.url)), (i = e.url), (r = e.url.startsWith('/'))) : e.data && (t = e.data.buffer), t)) {
  43094. let s = await zk.parse(t);
  43095. if (s) return { font: s.font, url: i, intercepted: r, arr: t, bidi: s.bidi };
  43096. }
  43097. }
  43098. function Nk(e, t) {
  43099. return t.state.glyphIndex === e || t.state.fina === e || t.state.medi === e || t.state.init === e;
  43100. }
  43101. var Uk = class {
  43102. constructor(e) {
  43103. (this._arrayBuffer = new ArrayBuffer(1)),
  43104. (this._isLoaded = !1),
  43105. (this._intercepted = !1),
  43106. (this._isUserFont = e.isUserFont ?? !1),
  43107. (this._loadingPromise = Xx(e).then((t) => {
  43108. t &&
  43109. ((this._arrayBuffer = t.arr),
  43110. (this._url = t.url),
  43111. (this.font = t.font),
  43112. (this._intercepted = t.intercepted),
  43113. (this._isLoaded = !0),
  43114. (this._bidi = t.bidi));
  43115. }));
  43116. }
  43117. update(e) {
  43118. (this._isLoaded = !1),
  43119. (this._isUserFont = e.isUserFont ?? !1),
  43120. (this._loadingPromise = Xx(e).then((t) => {
  43121. t &&
  43122. ((this._arrayBuffer = t.arr),
  43123. (this._url = t.url),
  43124. (this.font = t.font),
  43125. (this._intercepted = t.intercepted),
  43126. (this._isLoaded = !0),
  43127. (this._bidi = t.bidi));
  43128. }));
  43129. }
  43130. get url() {
  43131. return this._url;
  43132. }
  43133. get intercepted() {
  43134. return this._intercepted;
  43135. }
  43136. get isLoaded() {
  43137. return this._isLoaded;
  43138. }
  43139. get loadingPromise() {
  43140. return this._loadingPromise;
  43141. }
  43142. reverseLigaturesTable(e, t, i) {
  43143. if (!this._bidi) return [];
  43144. let r = this._bidi;
  43145. r.getTextGlyphs(t);
  43146. let s = r.tokenizer.tokens,
  43147. n = [],
  43148. a = 0,
  43149. o = i.length === s.length;
  43150. for (let l = 0; l < i.length; l++) {
  43151. let h = i[l].index,
  43152. u = String.fromCharCode(i[l].unicode),
  43153. c = s[a];
  43154. if (Nk(h, c) || o) n.push({ char: u, index: h, replacements: [c.state.glyphIndex], replacementChars: [c.char] }), a++;
  43155. else {
  43156. let d = c.char,
  43157. p = '',
  43158. f = [c.state.glyphIndex],
  43159. g = [],
  43160. m = !1;
  43161. for (; !m; )
  43162. a++,
  43163. (p = t.charAt(a)),
  43164. (d += p),
  43165. f.push(e.charToGlyphIndex(p)),
  43166. (g = e.stringToGlyphs(d)),
  43167. g.length === 1 && g[0].index === h && (m = !0),
  43168. a > t.length && (m = !0);
  43169. n.push({ char: u, index: h, replacements: f, replacementChars: Array.from(d) }), a++;
  43170. }
  43171. }
  43172. return n;
  43173. }
  43174. generateShapes(e, t) {
  43175. if (!this._isLoaded) return;
  43176. let i = this.font,
  43177. r = t.fontSize / this.unitsPerEm,
  43178. s = t.fontSize * t.lineHeight,
  43179. n = e.map((v) => this.getTextWidth(v, t)),
  43180. a = t.width,
  43181. o = this.getCharWidth(
  43182. `
  43183. `,
  43184. t
  43185. ),
  43186. l = t.horizontalAlign === 1 ? o : 0,
  43187. h = this.computeSpaceWidthForLine(e, 0, t),
  43188. u = this.getLineInitialOffsetX(n[0], a, t.horizontalAlign, e[0], o),
  43189. c = this.getLineInitialOffsetY(s, e.length, t.height, r, t.verticalAlign),
  43190. d = [],
  43191. p = e.map((v) => []),
  43192. f = e.map((v) => []),
  43193. g;
  43194. for (let v = 0; v < e.length; v++) {
  43195. let y = e[v],
  43196. b = { features: { liga: !0 } },
  43197. x = [];
  43198. try {
  43199. x = i.stringToGlyphs(y, b);
  43200. } catch (A) {
  43201. console.warn(A);
  43202. }
  43203. u = this.getLineInitialOffsetX(n[v], a, t.horizontalAlign, y, o);
  43204. let w = [];
  43205. try {
  43206. w = this.reverseLigaturesTable(i, y, x);
  43207. } catch (A) {
  43208. console.warn(A);
  43209. }
  43210. h = this.computeSpaceWidthForLine(e, v, t);
  43211. for (let A = 0; A < x.length; A++) {
  43212. let S = x[A],
  43213. _ =
  43214. S.index === 0
  43215. ? `
  43216. `
  43217. : S.unicode
  43218. ? String.fromCharCode(S.unicode)
  43219. : void 0,
  43220. M = w[A],
  43221. C = 0,
  43222. T = 0;
  43223. A === 0 && t.horizontalAlign === 2 && S.leftSideBearing !== void 0 && (T = -S.leftSideBearing * r),
  43224. g && (C = i.getKerningValue(S, g) * r),
  43225. (u += T + C);
  43226. let P = 0;
  43227. if (
  43228. _ ===
  43229. `
  43230. `
  43231. )
  43232. P = l;
  43233. else if (_ === ' ') P = h;
  43234. else {
  43235. let L = this.createPath(S, r, u, c, t);
  43236. L && ((P = L.offsetX - (C + T)), d.push(L.path));
  43237. }
  43238. if (M.replacements.length === 1) f[v].push([u, c]), p[v].push(P);
  43239. else {
  43240. let L = M.replacements.map((X) => (i.glyphs.get(X).advanceWidth ?? 0) * r),
  43241. D = L.reduce((X, z) => (X += z), 0),
  43242. k = L.map((X) => X / D),
  43243. W = u;
  43244. for (let X = 0; X < k.length; X++) {
  43245. let z = P * k[X];
  43246. f[v].push([W, c]), p[v].push(z), (W += z);
  43247. }
  43248. }
  43249. (u += P), (g = S);
  43250. }
  43251. c -= s;
  43252. }
  43253. let m = [];
  43254. for (let v = 0, y = d.length; v < y; v++) m.push(...d[v].toShapes());
  43255. return { shapes: m, charWidths: p, lineWidths: n, charCoords: f };
  43256. }
  43257. get isUserFont() {
  43258. return this._isUserFont;
  43259. }
  43260. get arrayBuffer() {
  43261. return this._arrayBuffer;
  43262. }
  43263. get ascender() {
  43264. return this.font?.ascender ?? 0;
  43265. }
  43266. get descender() {
  43267. return this.font?.descender ?? 0;
  43268. }
  43269. get familyName() {
  43270. return this.font?.names.fontFamily ?? '';
  43271. }
  43272. get subfamilyName() {
  43273. return this.font?.names.fontSubfamily ?? '';
  43274. }
  43275. get unitsPerEm() {
  43276. return this.font?.unitsPerEm ?? 1;
  43277. }
  43278. getLineInitialOffsetX(e, t, i, r, s) {
  43279. return (
  43280. (i === 3 || i === 2) &&
  43281. r.indexOf(`
  43282. `) >= 0 &&
  43283. (e -= s),
  43284. i === 3 ? t * 0.5 - e * 0.5 : i === 2 ? t - e : 0
  43285. );
  43286. }
  43287. getLineInitialOffsetY(e, t, i, r, s) {
  43288. let n = t * e,
  43289. a = Math.abs(this.ascender - this.descender) * r,
  43290. o = e - a,
  43291. l = -this.ascender * r - o / 2;
  43292. return s === 3 ? -(i - n - l) : s === 2 ? -(i * 0.5 - n * 0.5 - l) : l;
  43293. }
  43294. createPath(e, t, i, r, s) {
  43295. let n = e.getPath(i, -r, s.fontSize, { kerning: !1, letterSpacing: s.letterSpacing });
  43296. if (!n) {
  43297. console.error('THREE.Font: character "' + e + '" does not exists in font family ' + this.familyName + '.');
  43298. return;
  43299. }
  43300. let a = new Ok(),
  43301. o = (e.advanceWidth ?? 1) * t;
  43302. if (e)
  43303. for (let l of n.commands) {
  43304. let h = a.currentPath?.currentPoint;
  43305. if (!(h && l.type !== 'Z' && h.x === l.x && -h.y === l.y))
  43306. switch (l.type) {
  43307. case 'M':
  43308. a.moveTo(l.x, -l.y);
  43309. break;
  43310. case 'L':
  43311. a.lineTo(l.x, -l.y);
  43312. break;
  43313. case 'Q':
  43314. a.quadraticCurveTo(l.x1, -l.y1, l.x, -l.y);
  43315. break;
  43316. case 'C':
  43317. a.bezierCurveTo(l.x1, -l.y1, l.x2, -l.y2, l.x, -l.y);
  43318. break;
  43319. }
  43320. }
  43321. return (
  43322. a.subPaths.forEach((l) => {
  43323. let h = Fk(l.curves);
  43324. h !== void 0 && l.currentPoint.distanceTo(h) > 0 && l.lineTo(h.x, h.y);
  43325. }),
  43326. { offsetX: o + s.fontSize * s.letterSpacing, path: a }
  43327. );
  43328. }
  43329. getCharWidth(e, t) {
  43330. return this.font?.getAdvanceWidth(e, t.fontSize, { kerning: !0, letterSpacing: t.letterSpacing }) ?? 0;
  43331. }
  43332. getTextWidth(e, t) {
  43333. return this.font?.getAdvanceWidth(e, t.fontSize, { kerning: !0, letterSpacing: t.letterSpacing }) ?? 0;
  43334. }
  43335. computeSpaceWidthForLine(e, t, i) {
  43336. let r = this.getCharWidth(' ', i),
  43337. s = e[t];
  43338. if (s) {
  43339. let n = this.countSpaces(s.trimEnd());
  43340. if (i.horizontalAlign === 4 && t < e.length - 1 && n) {
  43341. let a = i.width,
  43342. o = this.getTextWidth(s, i);
  43343. return (a - (o - n * r)) / n;
  43344. }
  43345. }
  43346. return r;
  43347. }
  43348. countSpaces(e) {
  43349. return (e.match(/ /g) || []).length;
  43350. }
  43351. };
  43352. function Fk(e) {
  43353. if (e.length) {
  43354. let t = e[0];
  43355. if (t instanceof Gr) return t.v1;
  43356. if (t instanceof Fr || t instanceof Pn) return t.v0;
  43357. }
  43358. }
  43359. var kk = class {
  43360. constructor() {
  43361. (this.objects = new Map()), (this.unreachable = new Set());
  43362. }
  43363. getCached(e) {
  43364. return this.objects.get(e);
  43365. }
  43366. get size() {
  43367. return this.objects.size;
  43368. }
  43369. get(e, t) {
  43370. let i = this.objects.get(e);
  43371. return i === void 0 ? ((i = this.createObject(e, t)), this.objects.set(e, i)) : (i.isShared = !0), i;
  43372. }
  43373. mutateIfUnique(e, t) {
  43374. let i = this.objects.get(e);
  43375. if (i && i.isShared !== !0) return this.objects.delete(e), this.objects.set(t, i), i;
  43376. }
  43377. startGc() {
  43378. this.unreachable = new Set(this.objects.keys());
  43379. }
  43380. markAsReachable(e, t) {
  43381. let i = this.objects.get(e);
  43382. t === i && this.unreachable.delete(e);
  43383. }
  43384. endGc() {
  43385. this.unreachable.forEach((e) => {
  43386. this.disposeObject(this.objects.get(e)), this.objects.delete(e);
  43387. }),
  43388. this.unreachable.clear();
  43389. }
  43390. dispose() {
  43391. this.objects.forEach((e) => {
  43392. this.disposeObject(e);
  43393. }),
  43394. this.objects.clear();
  43395. }
  43396. },
  43397. qx = class extends kk {
  43398. constructor(e) {
  43399. super(), (this.flatShading = e);
  43400. }
  43401. disposeObject(e) {
  43402. e.dispose();
  43403. }
  43404. createObject(e, t) {
  43405. let i = Zd(e, t, this.flatShading);
  43406. return i.computeBoundingSphere(), i;
  43407. }
  43408. },
  43409. jk = {
  43410. find(e) {},
  43411. markNeedsUpdateRendererDirty: function () {},
  43412. markGeometryCacheDirty: function () {},
  43413. addPendingExpandCloner: function (e) {},
  43414. addPendingUpdateCloner(e) {},
  43415. addPendingCommand(e) {}
  43416. },
  43417. Gk = class extends wk {
  43418. constructor(e) {
  43419. super(), (this.shared = e);
  43420. }
  43421. create(e) {
  43422. return new aS(e, this.shared);
  43423. }
  43424. },
  43425. Eu = class {
  43426. constructor(e, t = {}) {
  43427. if (
  43428. ((this.geometryCache = new qx(!0)),
  43429. (this.geometryCache2 = new qx(!1)),
  43430. (this.imageHolderCache = new Gk(this)),
  43431. (this.thisContext = { scene: jk, shared: this }),
  43432. (this.deletedMaterial = new Gm(nr.defaultTwoLayerData('phong'), this.thisContext)),
  43433. (this.deletedImage = new ha(Hd.emptyImage, this)),
  43434. (this.deletedVideo = new ha(Rd.defaultVideo, this)),
  43435. (this.materials = {}),
  43436. (this.images = {}),
  43437. (this.videos = {}),
  43438. (this.colors = {}),
  43439. (this.audios = {}),
  43440. (this.fonts = {}),
  43441. (this.penumbraSize = []),
  43442. (this.requestRender = () => {
  43443. this._requestRender && this._requestRender();
  43444. }),
  43445. t.images)
  43446. )
  43447. for (let [i, r] of Object.entries(t.images)) this.addImage(i, r);
  43448. if (t.videos) for (let [i, r] of Object.entries(t.videos)) this.addVideo(i, r);
  43449. if (t.audios) for (let [i, r] of Object.entries(t.audios)) this.addAudio(i, r.data);
  43450. this.reset(e);
  43451. }
  43452. setRequestRender(e) {
  43453. this._requestRender = e;
  43454. }
  43455. reset(e) {
  43456. for (let [t, i] of Object.entries(e.images)) this.addImage(t, i);
  43457. for (let [t, i] of Object.entries(e.videos)) this.addVideo(t, i);
  43458. for (let [t, i] of Object.entries(e.colors)) this.addColor(t, i);
  43459. for (let [t, i] of Object.entries(e.materials)) this.addMaterial(t, new Gm(i, this.thisContext));
  43460. for (let [t, i] of Object.entries(e.audios)) this.addAudio(t, i.data);
  43461. for (let [t, i] of Object.entries(e.fonts)) this.addFont(t, i);
  43462. this.penumbraSize = e.penumbraSize;
  43463. }
  43464. addMaterial(e, t) {
  43465. (t.uuid = e), (this.materials[e] = t);
  43466. }
  43467. deleteMaterial(e) {
  43468. this.materials[e] && (this.materials[e].nodeMaterialDispose(), delete this.materials[e]);
  43469. }
  43470. getMaterial(e) {
  43471. return this.materials[e];
  43472. }
  43473. getMaterialOrDeletedPlaceholder(e) {
  43474. return this.materials[e] ?? this.deletedMaterial;
  43475. }
  43476. material(e) {
  43477. return typeof e == 'string' ? this.getMaterialOrDeletedPlaceholder(e) : new gS(e, this.thisContext);
  43478. }
  43479. getMaterials() {
  43480. return this.materials;
  43481. }
  43482. addImage(e, t) {
  43483. return this.images[e]
  43484. ? (this.onColorOrImageUpdate && this.onColorOrImageUpdate(), this.images[e].updateSrc(t.data), !0)
  43485. : ((this.images[e] = new ha(t, this)), !1);
  43486. }
  43487. deleteImage(e) {
  43488. let t = this.images[e];
  43489. t && (t.dispose(), delete this.images[e]);
  43490. }
  43491. getDefaultImage() {
  43492. return this.images.image_0;
  43493. }
  43494. getImage(e) {
  43495. return this.images[e] ?? this.deletedImage;
  43496. }
  43497. image(e) {
  43498. return typeof e == 'string' ? this.getImage(e) : this.imageHolderCache.load(e);
  43499. }
  43500. addVideo(e, t) {
  43501. return this.videos[e] ? (this.videos[e].updateSrc(t.data), !0) : ((this.videos[e] = new ha(t, this)), !1);
  43502. }
  43503. deleteVideo(e) {
  43504. let t = this.videos[e];
  43505. t && (t.dispose(), delete this.videos[e]);
  43506. }
  43507. getVideo(e) {
  43508. return this.videos[e] ?? this.deletedVideo;
  43509. }
  43510. video(e) {
  43511. return typeof e == 'string' ? this.getVideo(e) : this.imageHolderCache.load(e);
  43512. }
  43513. addColor(e, t) {
  43514. return this.colors[e]
  43515. ? (this.onColorOrImageUpdate && this.onColorOrImageUpdate(),
  43516. '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),
  43517. !0)
  43518. : ('a' in t ? (this.colors[e] = new Kd(t.r, t.g, t.b, t.a)) : (this.colors[e] = new Kd(t.r, t.g, t.b, 1)), !1);
  43519. }
  43520. updateColor(e, t) {
  43521. if (this.colors[e]) {
  43522. this.onColorOrImageUpdate && this.onColorOrImageUpdate();
  43523. let i = this.colors[e];
  43524. return (
  43525. (this.colors[e].r = t.r ?? i.r),
  43526. (this.colors[e].g = t.g ?? i.g),
  43527. (this.colors[e].b = t.b ?? i.b),
  43528. (this.colors[e].a = t.a ?? i.a),
  43529. !0
  43530. );
  43531. }
  43532. return !1;
  43533. }
  43534. deleteColor(e) {
  43535. this.colors[e] && delete this.colors[e];
  43536. }
  43537. getColor(e) {
  43538. return this.colors[e];
  43539. }
  43540. color(e) {
  43541. let t;
  43542. if (typeof e == 'string') {
  43543. let i = this.getColor(e);
  43544. i
  43545. ? (t = i)
  43546. : (console.warn('Tried to create color layer params with a color key that does not exist in the assets manager'),
  43547. (t = new ji(0, 0, 0, 0)));
  43548. } else return 'a' in e ? new ji(e.r, e.g, e.b, e.a) : new ji(e.r, e.g, e.b, 1);
  43549. return t;
  43550. }
  43551. addAudio(e, t) {
  43552. this.audios[e] = t;
  43553. }
  43554. getAudio(e) {
  43555. let t = this.audios[e];
  43556. if (t instanceof Yl) return t;
  43557. {
  43558. let i = new Yl({ src: t });
  43559. return (this.audios[e] = i), i;
  43560. }
  43561. }
  43562. deleteAudio(e) {
  43563. let t = this.audios[e];
  43564. t && (t instanceof Yl && t.dispose(), delete this.audios[e]);
  43565. }
  43566. addFont(e, t) {
  43567. (this.fonts[e] = new Uk(t)), this.fonts[e].loadingPromise.then(() => this.requestRender());
  43568. }
  43569. getFont(e) {
  43570. return this.fonts[e];
  43571. }
  43572. deleteFont(e) {
  43573. this.fonts[e] && delete this.fonts[e];
  43574. }
  43575. dispose() {
  43576. Object.keys(this.materials).forEach((e) => this.deleteMaterial(e)),
  43577. (this._requestRender = void 0),
  43578. Object.values(this.audios).forEach((e) => {
  43579. e instanceof Yl && e.dispose();
  43580. }),
  43581. (this.audios = {}),
  43582. this.geometryCache.dispose(),
  43583. this.geometryCache2.dispose();
  43584. }
  43585. },
  43586. z9 = new Eu(Wd.emptyData()),
  43587. Cu = class extends ar {
  43588. updateByPatchedOp(e, t, i) {
  43589. if ((super.updateByPatchedOp(e, t, i), LN(e.path, ['materials']) !== null && e.type === 0 && Array.isArray(this.material)))
  43590. for (let [r, s] of Object.entries(e.props)) {
  43591. let n = i.shared.material(s);
  43592. this.material[Number(r)] = n;
  43593. }
  43594. else if (pn(e.path, ['material']) && this.material instanceof Ln)
  43595. 'material' in t && typeof t.material != 'string' && this.material.updateByOp(ir.drop(e, 1), t.material, i);
  43596. else if (pn(e.path, ['materials', '*']) && Array.isArray(this.material)) {
  43597. let r = e.path[1];
  43598. if ('materials' in t && r < this.material.length) {
  43599. let s = t.materials[r];
  43600. typeof s != 'string' && this.material[r].updateByOp(ir.drop(e, 2), s, i);
  43601. }
  43602. }
  43603. }
  43604. updateState(e, t) {
  43605. super.updateState(e, t),
  43606. e.castShadow !== void 0 && (this.castShadow = e.castShadow),
  43607. e.receiveShadow !== void 0 && (this.receiveShadow = e.receiveShadow);
  43608. let i = this.dataPatched;
  43609. if (
  43610. (e.geometry?.type !== 'NonParametricGeometry' &&
  43611. 'material' in e &&
  43612. e.material !== void 0 &&
  43613. (this.disposeMaterial(),
  43614. (this.material = t.shared.material(e.material).getFlavor(i.flatShading, i.side, i.wireframe)),
  43615. t.scene?.markNeedsUpdateRendererDirty()),
  43616. e.geometry?.type === 'NonParametricGeometry' &&
  43617. ('materials' in e && e.materials !== void 0
  43618. ? (this.disposeMaterial(),
  43619. (this.material = e.materials.map((r) => t.shared.material(r).getFlavor(i.flatShading, i.side, i.wireframe))),
  43620. t.scene?.markNeedsUpdateRendererDirty())
  43621. : 'material' in e &&
  43622. e.material !== void 0 &&
  43623. (this.disposeMaterial(),
  43624. (this.material = [t.shared.material(e.material).getFlavor(i.flatShading, i.side, i.wireframe)]),
  43625. t.scene?.markNeedsUpdateRendererDirty())),
  43626. e.flatShading !== void 0 || e.wireframe !== void 0 || e.side !== void 0)
  43627. )
  43628. if (Array.isArray(this.material))
  43629. for (let r = 0; r < this.material.length; r++) this.material[r] = this.material[r].getFlavor(i.flatShading, i.side, i.wireframe);
  43630. else this.material = this.material.getFlavor(i.flatShading, i.side, i.wireframe);
  43631. }
  43632. disposeMaterial() {
  43633. this.material &&
  43634. tA(this.material).forEach((e) => {
  43635. e instanceof Ln && (e instanceof Gm || e.nodeMaterialDispose());
  43636. });
  43637. }
  43638. dispose() {
  43639. this.disposeMaterial(), super.dispose();
  43640. }
  43641. },
  43642. Cr = class extends Cu {
  43643. constructor(e, t, i) {
  43644. super(e, t), (this.data = t), (this.localGeometry = void 0);
  43645. }
  43646. chooseGeoemtryCache(e) {
  43647. return e.geometryCache;
  43648. }
  43649. markGeometryAsReachable(e) {
  43650. this.geometryCreateDeleyed instanceof Ve &&
  43651. this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry, this.geometryCreateDeleyed);
  43652. }
  43653. get geometry() {
  43654. if (this.localGeometry !== void 0) return this.localGeometry;
  43655. if (this.geometryCreateDeleyed instanceof Eu) {
  43656. let e = this.geometryCreateDeleyed,
  43657. t = this.chooseGeoemtryCache(e);
  43658. this.geometryCreateDeleyed = t.get(this.dataPatched.geometry, e);
  43659. }
  43660. return this.geometryCreateDeleyed;
  43661. }
  43662. set geometry(e) {
  43663. this.localGeometry = e;
  43664. }
  43665. get is2DAndNoDepth() {
  43666. let e = this.dataPatched.geometry;
  43667. return Nd.is2DParametricMesh(e.type) && e.depth === 0;
  43668. }
  43669. get is2DType() {
  43670. return Nd.is2DParametricMesh(this.geometry.userData.type);
  43671. }
  43672. get isNonParametric() {
  43673. return this.geometry.userData.type === 'NonParametricGeometry';
  43674. }
  43675. updateByPatchedOp(e, t, i) {
  43676. super.updateByPatchedOp(e, t, i), pn(e.path, ['geometry']) && this.updateByPatchedOpGeometry(ir.drop(e, 1), t.geometry, i);
  43677. }
  43678. removeInteractionGeometry() {
  43679. this.localGeometry?.dispose(), (this.localGeometry = void 0);
  43680. }
  43681. updateGeometryInteractions(e, t) {
  43682. this.invalidateDownstreamBooleanData();
  43683. let i = this.data.geometry.type;
  43684. if (i === 'NonParametricGeometry' || i === 'SubdivGeometry') {
  43685. let r = e;
  43686. if (this.localGeometry === void 0) {
  43687. let l = { ...this.data.geometry, ...r };
  43688. this.localGeometry = Zd(l, t, this.data.flatShading);
  43689. }
  43690. let s, n, a;
  43691. r.scaleBaked ? ([s, n, a] = r.scaleBaked) : ({ width: s, height: n, depth: a } = r);
  43692. let o = this.localGeometry.userData;
  43693. o.sxPrev !== void 0 && Um(this.localGeometry.attributes, s / o.sxPrev, n / o.syPrev, a / o.szPrev),
  43694. (o.sxPrev = s),
  43695. (o.syPrev = n),
  43696. (o.szPrev = a);
  43697. } else {
  43698. let r = { ...this.data.geometry, ...e };
  43699. this.localGeometry?.dispose(), (this.localGeometry = Zd(r, t, this.data.flatShading));
  43700. }
  43701. }
  43702. refreshAttachedCloners(e) {
  43703. for (let t of this.attachedSurfaceCloners) e.scene.addPendingUpdateCloner(t.object);
  43704. }
  43705. refreshAttachedPaths(e) {
  43706. for (let t of this.attachedPaths) e.scene.addPendingCommand(() => t.updateShape());
  43707. }
  43708. createGeometryDelayed(e) {
  43709. (this.geometryCreateDeleyed = e.shared), this.refreshAttachedCloners(e), this.refreshAttachedPaths(e);
  43710. }
  43711. updateByPatchedOpGeometry(e, t, i) {
  43712. let r = !1;
  43713. e.type === 0 &&
  43714. e.path.length === 0 &&
  43715. jg(['scaleBaked'], Object.keys(e.props)) &&
  43716. this.geometryCreateDeleyed instanceof Oi &&
  43717. this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data, t) === this.geometryCreateDeleyed &&
  43718. ((r = !0),
  43719. this.geometryCreateDeleyed.mutateDirectlyScaleBaked(t, e.props.scaleBaked),
  43720. this.refreshAttachedCloners(i),
  43721. this.refreshAttachedPaths(i)),
  43722. r || (i.scene?.markGeometryCacheDirty(), this.createGeometryDelayed(i)),
  43723. this.resetBBoxNeedsUpdate(),
  43724. this.invalidateDownstreamBooleanData();
  43725. }
  43726. updateGeometryOnStateUpdate(e, t) {
  43727. this.createGeometryDelayed(t);
  43728. }
  43729. updateState(e, t) {
  43730. e.geometry !== void 0 && this.updateGeometryOnStateUpdate(e.geometry, t), super.updateState(e, t);
  43731. }
  43732. updateGeometryGroupsIfNeeded() {
  43733. Array.isArray(this.material) &&
  43734. this.geometry.groups.length === 0 &&
  43735. this.geometry.addGroup(0, Math.max(this.geometry.getIndex()?.count ?? 0, this.geometry.getAttribute('position').count), 0);
  43736. }
  43737. updateEntityBoxSize(e, t) {
  43738. let i = this.geometry.userData.parameters;
  43739. this.is2DType
  43740. ? e.set(0, 0, i.depth * 0.5)
  43741. : this.isNonParametric
  43742. ? (e.setScalar(0),
  43743. this.geometry.boundingSphere && e.copy(this.geometry.boundingSphere.center),
  43744. t.set(i.width, i.height, i.depth ?? 0).multiplyScalar(0.5))
  43745. : e.setScalar(0),
  43746. t.set(i.width, i.height, i.depth ?? 0).multiplyScalar(0.5);
  43747. }
  43748. };
  43749. function Vk(e) {
  43750. if (e.geometry.attributes.extrudeNormal || !e.geometry.attributes.position || !e.geometry.attributes.normal) return;
  43751. let t = new Map(),
  43752. i = e.geometry.attributes,
  43753. r = i.position.array,
  43754. s = i.normal.array,
  43755. n = new Float32Array(r.length);
  43756. for (let a = 0; a < r.length; a += 3) {
  43757. let o = `${r[a]}_${r[a + 1]}_${r[a + 2]}`,
  43758. l = new E(s[a], s[a + 1], s[a + 2]);
  43759. t.has(o) ? t.get(o)?.normals.push(l) : t.set(o, { normals: [l], result: new E() });
  43760. }
  43761. t.forEach((a, o) => {
  43762. for (let l of a.normals) a.result.add(l);
  43763. a.result.divideScalar(a.normals.length);
  43764. });
  43765. for (let a = 0; a < r.length; a += 3) {
  43766. let o = `${r[a]}_${r[a + 1]}_${r[a + 2]}`,
  43767. l = t.get(o)?.result;
  43768. l && ((n[a] = l.x), (n[a + 1] = l.y), (n[a + 2] = l.z));
  43769. }
  43770. e.geometry.setAttribute('extrudeNormal', new Ce(n, 3));
  43771. }
  43772. function Hk(e) {
  43773. if (e.geometry.attributes.extrudeNormals || !e.geometry.attributes.position) return;
  43774. let t = e.geometry.attributes.position.array,
  43775. i = new Float32Array(t.length),
  43776. r = new E();
  43777. 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);
  43778. e.geometry.setAttribute('extrudeNormal', new Ce(i, 3));
  43779. }
  43780. function uv(e) {
  43781. if (Array.isArray(e.material)) {
  43782. for (let t of e.material) if (t.getLayersOfType('outline').length === 0) return;
  43783. } else if (!(e.material instanceof Ln) || e.material.getLayersOfType('outline').length === 0) return;
  43784. e instanceof Cr && e.is2DAndNoDepth ? Hk(e) : Vk(e);
  43785. }
  43786. function pv(e) {
  43787. if (!e.geometry.attributes.position) return;
  43788. let t = e.geometry.attributes.position.array,
  43789. i = new Float32Array(t.length),
  43790. r = parseInt(e.uuid.replace(/\D/g, '')),
  43791. s = [it.seededRandom(r), it.seededRandom(r + 1e4), it.seededRandom(r + 2e4)];
  43792. for (let n = 0; n < t.length; n++) i[n] = s[n % 3];
  43793. e.geometry.setAttribute('randomColor', new Xe(i, 3));
  43794. }
  43795. var Wk;
  43796. av.then((e) => {
  43797. Wk = e;
  43798. });
  43799. var Kr = new Kt(),
  43800. Il = new E();
  43801. function Xk(e) {
  43802. let t = !1;
  43803. return (
  43804. e.scene.objects.traverse((i, r) => {
  43805. r.type === 'Mesh' && r.geometry.type === 'SubdivGeometry' && (t = !0);
  43806. }),
  43807. t
  43808. );
  43809. }
  43810. var Sh = class extends Cr {
  43811. constructor(e, t, i) {
  43812. super(e, t, i), (this.data = t), (this.hiddenMatrixOld = new ve()), (this.smoothShading = !0), (this.skipReactionUpdate = !1);
  43813. }
  43814. chooseGeoemtryCache(e) {
  43815. return this.dataPatched.flatShading ? e.geometryCache : e.geometryCache2;
  43816. }
  43817. get subdivPointerNew() {
  43818. return this.localGeometry !== void 0 ? this.subdivPointer : this.geometry.ensureSubdivPointer();
  43819. }
  43820. get originalGeometryNew() {
  43821. return this.localGeometry !== void 0 ? this.originalGeometry : this.geometry.originalGeometry;
  43822. }
  43823. get phongAngle() {
  43824. return this.data.geometry.phongAngle ?? 45;
  43825. }
  43826. updateEntityBoxSize(e, t) {
  43827. let i = this.geometry.userData.parameters;
  43828. e.copy(this.originalGeometryNew.boundingSphere.center), t.set(i.width, i.height, i.depth ?? 0).multiplyScalar(0.5);
  43829. }
  43830. createGeometryByControls(e) {
  43831. if (this.skipReactionUpdate === !0) return;
  43832. let t = this.localGeometry?.uuid,
  43833. {
  43834. originalGeometry: i,
  43835. subdividedGeometry: r,
  43836. subdivPointer: s
  43837. } = Oi.build(e, this.subdivPointer, this.smoothShading, this.hasNonUniformScale ? this.shearScale : void 0);
  43838. (this.subdivPointer = s),
  43839. i !== void 0 && (this.originalGeometry?.dispose(), (this.originalGeometry = i)),
  43840. r !== void 0 && (this.subdividedGeometry?.dispose(), (this.subdividedGeometry = r ?? void 0)),
  43841. (this.localGeometry = this.subdividedGeometry ?? this.originalGeometry),
  43842. uv(this),
  43843. pv(this),
  43844. this.calcBoundingBox(),
  43845. t && (this.localGeometry.uuid = t);
  43846. }
  43847. updateState(e, t) {
  43848. if ((super.updateState(e, t), e.flatShading !== void 0)) {
  43849. let i = this.material;
  43850. (this.material = i.getFlavor(!1, i.side, i.wireframe)), (this.smoothShading = !e.flatShading), this.createGeometryDelayed(t);
  43851. }
  43852. }
  43853. updateMesh(e = !1) {
  43854. Oi.buildLevel(
  43855. this.subdivPointer,
  43856. !0,
  43857. this.smoothShading ? this.phongAngle : -1,
  43858. this.originalGeometry,
  43859. e && this.hasNonUniformScale ? this.shearScaleInv : void 0
  43860. ),
  43861. this.subdividedGeometry &&
  43862. Oi.buildLevel(
  43863. this.subdivPointer,
  43864. !1,
  43865. this.smoothShading ? this.phongAngle : -1,
  43866. this.subdividedGeometry,
  43867. e && this.hasNonUniformScale ? this.shearScaleInv : void 0
  43868. );
  43869. }
  43870. updateTopology() {
  43871. this.originalGeometry.dispose(),
  43872. (this.originalGeometry = Oi.buildLevel(this.subdivPointer, !0, this.smoothShading ? this.phongAngle : -1)),
  43873. this.subdividedGeometry &&
  43874. (this.subdividedGeometry.dispose(),
  43875. (this.subdividedGeometry = Oi.buildLevel(this.subdivPointer, !1, this.smoothShading ? this.phongAngle : -1))),
  43876. (this.localGeometry = this.subdividedGeometry ?? this.originalGeometry);
  43877. }
  43878. raycast(e, t) {
  43879. let i = this.localGeometry;
  43880. (this.localGeometry = this.originalGeometryNew), ar.prototype.raycast.call(this, e, t), (this.localGeometry = i);
  43881. }
  43882. activateSVDCompensation() {
  43883. !this.hasNonUniformScale ||
  43884. (this.matrix.copy(this.matrixWorldRigid),
  43885. this.hiddenMatrixOld.copy(this.hiddenMatrix),
  43886. this.hiddenMatrix.copy(this.parent.matrixWorld).invert());
  43887. }
  43888. deactivateSVDCompensation() {
  43889. !this.hasNonUniformScale || (this.updateMatrix(), (this.hasNonUniformScale = void 0), this.hiddenMatrix.copy(this.hiddenMatrixOld));
  43890. }
  43891. calcBoundingBox() {
  43892. let e = this.originalGeometry;
  43893. e.boundingSphere === null &&
  43894. ((e.boundingSphere = new Mr()), this.subdividedGeometry && (this.subdividedGeometry.boundingSphere = e.boundingSphere));
  43895. let t = e.attributes.position,
  43896. i = e.boundingSphere.center;
  43897. Kr.setFromBufferAttribute(t),
  43898. Kr.getCenter(i),
  43899. (e.boundingSphere.radius = i.distanceTo(Kr.max)),
  43900. isNaN(e.boundingSphere.radius) &&
  43901. console.error(
  43902. 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',
  43903. this
  43904. ),
  43905. Kr.getSize(Il),
  43906. this.hasNonUniformScale && Il.divide(this.scale);
  43907. let r = { width: Il.x, height: Il.y, depth: Il.z };
  43908. return (this.geometry.userData.parameters = r), r;
  43909. }
  43910. updateBoundingSphere(e) {
  43911. let t = this.originalGeometry;
  43912. Kr.min.set(e[0], e[2], e[4]),
  43913. Kr.max.set(e[1], e[3], e[5]),
  43914. this.hasNonUniformScale && (Kr.min.applyMatrix4(this.shearScaleInv), Kr.max.applyMatrix4(this.shearScaleInv)),
  43915. t.boundingSphere === null && (t.boundingSphere = new Mr());
  43916. let i = t.boundingSphere.center;
  43917. Kr.getCenter(i), (t.boundingSphere.radius = i.distanceTo(Kr.max));
  43918. }
  43919. freeSubdivPointer() {
  43920. this.subdivPointer && (Oi.freeSubdivPointer(this.subdivPointer), (this.subdivPointer = 0)),
  43921. (this.localGeometry = void 0),
  43922. this.originalGeometry?.dispose(),
  43923. this.subdividedGeometry?.dispose();
  43924. }
  43925. dispose() {
  43926. super.dispose(), this.freeSubdivPointer();
  43927. }
  43928. updateByPatchedOpGeometry(e, t, i) {
  43929. super.updateByPatchedOpGeometry(e, t, i), this.localGeometry && this.createGeometryByControls(t);
  43930. }
  43931. },
  43932. Yx = -1,
  43933. qk = 1,
  43934. Yk = { x: [1, 0, 0], '-x': [-1, 0, 0], y: [0, 1, 0], '-y': [0, -1, 0], z: [0, 0, 1], '-z': [0, 0, -1] },
  43935. Qk = { polygon_center: 0, edge: 1, vertex: 2 },
  43936. jc = (e, t) => (i, r) => (!t || i === 0 || e === 0 ? 0 : (e * r) / 100),
  43937. Ye = (e, t) => {
  43938. let i = Math.abs(t),
  43939. r = i * -1;
  43940. return ((e - Yx) * (i - r)) / (qk - Yx) + r;
  43941. };
  43942. function Zk(e) {
  43943. let t = [],
  43944. i = {};
  43945. for (var r = 0, s = e.length; r < s; r++) {
  43946. var n = JSON.stringify(e[r].pos.map((a) => Math.round(a * 1e4) / 1e4));
  43947. i[n] || (t.push(e[r]), (i[n] = !0));
  43948. }
  43949. return t;
  43950. }
  43951. var Kk = new E(),
  43952. Gc = new E(),
  43953. Jk = new E(),
  43954. $k = new E();
  43955. function Io(e, t) {
  43956. let i = Jk.fromArray(e),
  43957. r = $k.fromArray(t);
  43958. Gc.copy(r).sub(i);
  43959. let s = Gc.length();
  43960. return Gc.normalize().multiplyScalar(s * 0.5), Kk.copy(i).add(Gc).toArray();
  43961. }
  43962. var br = new Bi(),
  43963. Vc = new E(),
  43964. $d = new E(),
  43965. aa = new E();
  43966. function e8(e) {
  43967. let t = [];
  43968. for (let i = 0; i <= e.index.count; i++)
  43969. if (
  43970. (Vc.fromArray(e.index.array, i * 3),
  43971. br.setFromAttributeAndIndices(e.attributes.position, Vc.x, Vc.y, Vc.z),
  43972. br.getNormal($d),
  43973. br.getMidpoint(aa),
  43974. !(isNaN(aa.x) || isNaN(aa.y) || isNaN(aa.z)))
  43975. ) {
  43976. let { a: r, b: s, c: n } = br,
  43977. a = r.toArray(),
  43978. o = s.toArray(),
  43979. l = n.toArray(),
  43980. h = r.distanceTo(s),
  43981. u = s.distanceTo(n),
  43982. c = n.distanceTo(r),
  43983. d = Io(a, o),
  43984. p = Io(o, l),
  43985. f = Io(l, a),
  43986. g = [h, u, c],
  43987. m = Math.max(...g),
  43988. v = g.filter((x) => Math.round(x) === Math.round(m)).length > 1,
  43989. y = [],
  43990. b = br.getMidpoint(aa).toArray();
  43991. m === h && !v && ((y = [p, f, f]), (b = d)),
  43992. m === u && !v && ((y = [d, f, f]), (b = p)),
  43993. m === c && !v && ((y = [d, p, p]), (b = f)),
  43994. v && (y = [d, p, f]),
  43995. t.push({ vertices: [a, o, l], faceCenters: y, midpoint: b, norm: br.getNormal($d).toArray() });
  43996. }
  43997. return t;
  43998. }
  43999. function t8(e) {
  44000. let t = [],
  44001. { position: i } = e.attributes;
  44002. for (let r = 0; r < i.count; r++) {
  44003. br.setFromAttributeAndIndices(i, r * 3, r * 3 + 1, r * 3 + 2), br.getNormal($d), br.getMidpoint(aa);
  44004. let s = br.a.toArray(),
  44005. n = br.b.toArray(),
  44006. a = br.c.toArray();
  44007. t.push({ vertices: [s, n, a], faceCenters: [Io(s, n), Io(n, a), Io(a, s)], midpoint: aa.toArray(), norm: $d.toArray() });
  44008. }
  44009. return t;
  44010. }
  44011. var i8 = 4,
  44012. r8 = 0.5,
  44013. af = (e) => 0.5 * (1 - Math.cos(e * Math.PI)),
  44014. s8 = class {
  44015. constructor() {
  44016. this.perlin = new Array(4095 + 1);
  44017. }
  44018. noise(e, t = 0, i = 0) {
  44019. if (this.perlin == null) {
  44020. this.perlin = new Array(4095 + 1);
  44021. for (let m = 0; m < 4095 + 1; m++) this.perlin[m] = Math.random();
  44022. }
  44023. e < 0 && (e = -e), t < 0 && (t = -t), i < 0 && (i = -i);
  44024. let r = Math.floor(e),
  44025. s = Math.floor(t),
  44026. n = Math.floor(i),
  44027. a = e - r,
  44028. o = t - s,
  44029. l = i - n,
  44030. h,
  44031. u,
  44032. c = 0,
  44033. d = 0.5,
  44034. p,
  44035. f,
  44036. g;
  44037. for (let m = 0; m < i8; m++) {
  44038. let v = r + (s << 4) + (n << 8);
  44039. (h = af(a)),
  44040. (u = af(o)),
  44041. (p = this.perlin[v & 4095]),
  44042. (p += h * (this.perlin[(v + 1) & 4095] - p)),
  44043. (f = this.perlin[(v + 16) & 4095]),
  44044. (f += h * (this.perlin[(v + 16 + 1) & 4095] - f)),
  44045. (p += u * (f - p)),
  44046. (v += 256),
  44047. (f = this.perlin[v & 4095]),
  44048. (f += h * (this.perlin[(v + 1) & 4095] - f)),
  44049. (g = this.perlin[(v + 16) & 4095]),
  44050. (g += h * (this.perlin[(v + 16 + 1) & 4095] - g)),
  44051. (f += u * (g - f)),
  44052. (p += af(l) * (f - p)),
  44053. (c += p * d),
  44054. (d *= r8),
  44055. (r <<= 1),
  44056. (a *= 2),
  44057. (s <<= 1),
  44058. (o *= 2),
  44059. (n <<= 1),
  44060. (l *= 2),
  44061. a >= 1 && (r++, a--),
  44062. o >= 1 && (s++, o--),
  44063. l >= 1 && (n++, l--);
  44064. }
  44065. return c;
  44066. }
  44067. noiseSeed(e) {
  44068. let t = (() => {
  44069. let i, r;
  44070. return {
  44071. setSeed(s) {
  44072. r = i = (s ?? Math.random() * 4294967296) >>> 0;
  44073. },
  44074. getSeed() {
  44075. return i;
  44076. },
  44077. rand() {
  44078. return (r = (1664525 * r + 1013904223) % 4294967296), r / 4294967296;
  44079. }
  44080. };
  44081. })();
  44082. t.setSeed(e), (this.perlin = new Array(4095 + 1));
  44083. for (let i = 0; i < 4095 + 1; i++) this.perlin[i] = t.rand();
  44084. }
  44085. },
  44086. n8 = s8,
  44087. Qx = new E(),
  44088. Zx = new ve(),
  44089. Kx = new Xo();
  44090. function Jx(e) {
  44091. let t = !1;
  44092. return (
  44093. e.scene.objects.traverse((i, r) => {
  44094. r.type === 'Mesh' && r.geometry.type === 'TextGeometry' && (t = !0);
  44095. }),
  44096. t
  44097. );
  44098. }
  44099. var yS = class extends Cr {
  44100. constructor(e, t, i) {
  44101. super(e, t, i), (this.data = t);
  44102. }
  44103. get textGeometry() {
  44104. return this.geometry;
  44105. }
  44106. get charWidths() {
  44107. return this.textGeometry.charWidths;
  44108. }
  44109. get charCoords() {
  44110. return this.textGeometry.charCoords;
  44111. }
  44112. get wrappedText() {
  44113. return this.textGeometry.wrappedText;
  44114. }
  44115. get font() {
  44116. return this.textGeometry.font;
  44117. }
  44118. get initialOffsetY() {
  44119. let e = this.dataPatched;
  44120. return (
  44121. this.font?.getLineInitialOffsetY(
  44122. this.lineHeight,
  44123. this.wrappedText.length,
  44124. e.geometry.height,
  44125. this.fontScale,
  44126. e.geometry.verticalAlign
  44127. ) ?? 0
  44128. );
  44129. }
  44130. get fontScale() {
  44131. let e = this.dataPatched;
  44132. return this.font ? e.geometry.fontSize / this.font.unitsPerEm : 1;
  44133. }
  44134. get AD() {
  44135. return Math.abs(this.ascender - this.descender);
  44136. }
  44137. get ascender() {
  44138. return (this.font?.ascender ?? 1) * this.fontScale;
  44139. }
  44140. get descender() {
  44141. return (this.font?.descender ?? 1) * this.fontScale;
  44142. }
  44143. get lineHeight() {
  44144. let e = this.dataPatched;
  44145. return e.geometry.fontSize * e.geometry.lineHeight;
  44146. }
  44147. raycast(e, t) {
  44148. let { matrixWorld: i } = this;
  44149. if (
  44150. !(isNaN(e.ray.origin.x) || this.scale.x === 0 || this.scale.y === 0 || this.scale.z === 0) &&
  44151. (Zx.copy(i).invert(), Kx.copy(e.ray).applyMatrix4(Zx), Kx.intersectBox(this.singleBBox, Qx))
  44152. ) {
  44153. let r = Qx.applyMatrix4(i),
  44154. s = e.ray.origin.distanceTo(r);
  44155. t.push({ distance: s, point: r.clone(), object: this });
  44156. }
  44157. }
  44158. },
  44159. Pi = 1e-4,
  44160. Jr,
  44161. xS,
  44162. bS,
  44163. wS,
  44164. $x = new E(),
  44165. eb = new E();
  44166. av.then((e) => {
  44167. (Jr = e),
  44168. (xS = [Jr.get_face_center, Jr.get_edge_midpoint, Jr.get_vertex_position]),
  44169. (bS = [Jr.get_face_normal, Jr.get_edge_normal, Jr.get_vertex_normal]),
  44170. (wS = [Jr.face_count, Jr.edge_count, Jr.vertex_count]);
  44171. });
  44172. var a8 = new ve(),
  44173. o8 = new ve(),
  44174. nn = new E(),
  44175. Qn = new E(),
  44176. Rl = new E(),
  44177. of = new E(),
  44178. l8 = new E(),
  44179. h8 = new E(),
  44180. Is = new n8(),
  44181. eu = class extends $g(bt) {
  44182. constructor(e, t) {
  44183. super(), (this.parameters = t), (this.objectForSample = void 0), (this._pendingMediaLoad = !1), (this.object = e);
  44184. }
  44185. resetOnMove() {
  44186. this.removeFromParent(), (this.parent = null);
  44187. }
  44188. expandClones(e) {
  44189. if (this.parent === null) this.updateState(this.parameters, e);
  44190. else for (let t of this.children) t instanceof la && t.expand();
  44191. }
  44192. invalidateTransform(e) {
  44193. (this.matrixWorldNeedsUpdate = !0),
  44194. this.traverse((t) => {
  44195. t instanceof la && t.object === e && (t.matrixWorldNeedsUpdate = !0);
  44196. });
  44197. }
  44198. onObjUpdateMatrix() {
  44199. this.parameters.type !== 'toObject' && (this.matrixWorldNeedsUpdate = !0);
  44200. }
  44201. update() {
  44202. switch ((this._updateCount(), this.parameters.type)) {
  44203. case 'radial':
  44204. this._updateRadial(this.parameters);
  44205. break;
  44206. case 'linear':
  44207. this._updateLinear(this.parameters);
  44208. break;
  44209. case 'grid':
  44210. this._updateGrid(this.parameters);
  44211. break;
  44212. case 'toObject':
  44213. this._updateToObject(this.parameters);
  44214. }
  44215. for (let e of this.children) e.updateMatrix(), e.hasNonUniformScale && (e.updateMatrixWorld(), e.updateMatrixWorldSVD());
  44216. }
  44217. _updateCount(e) {
  44218. let t;
  44219. if (
  44220. (e !== void 0
  44221. ? (t = e)
  44222. : (t =
  44223. this.parameters.type === 'grid'
  44224. ? Math.round(this.parameters.grid.count[0]) *
  44225. Math.round(this.parameters.grid.count[1]) *
  44226. Math.round(this.parameters.grid.count[2])
  44227. : this.parameters.count),
  44228. this.parameters.type === 'toObject' && !this.parameters.toObject.object && (t = 0),
  44229. this.parameters.type === 'toObject' && this.objectForSample)
  44230. ) {
  44231. for (let r = 0, s = this.children.length; r < s; ++r) this.remove(this.children[0]);
  44232. let i = this.children;
  44233. if (i.length === t) return;
  44234. if (i.length < t)
  44235. for (let r = 0, s = t - i.length; r < s; ++r) {
  44236. let n = new la(this.object);
  44237. n.expand(), this.add(n);
  44238. }
  44239. else for (let r = 0, s = i.length - t; r < s; ++r) this.remove(i[r]);
  44240. } else {
  44241. if (this.children.length === t) return;
  44242. if (this.children.length < t)
  44243. for (let i = 0, r = t - this.children.length; i < r; ++i) {
  44244. let s = new la(this.object);
  44245. s.expand(), this.add(s);
  44246. }
  44247. else for (let i = 0, r = this.children.length - t; i < r; ++i) this.remove(this.children[0]);
  44248. }
  44249. }
  44250. _updateRadial(e) {
  44251. let t = e.radial,
  44252. i = t.start * it.DEG2RAD,
  44253. r = t.end * it.DEG2RAD,
  44254. s = i - r,
  44255. n = new _i(t.rotation[0], t.rotation[1], t.rotation[2]),
  44256. a;
  44257. switch (t.axis) {
  44258. case 'z':
  44259. a = new E(0, 0, 1);
  44260. break;
  44261. case 'y':
  44262. a = new E(0, 1, 0);
  44263. break;
  44264. default:
  44265. case 'x':
  44266. a = new E(1, 0, 0);
  44267. break;
  44268. }
  44269. let o = e.randomnessObject ?? bn.defaultData([1, 1, 1]).randomnessObject,
  44270. l = o.noiseType === 'perlin';
  44271. Is.noiseSeed(o.seed);
  44272. let h = Hp((0, El.default)(o.seed)),
  44273. u = jc(o.strength, this.parameters.randomness);
  44274. for (let [c, d] of this.children.entries()) {
  44275. let p = c * (o.freqScale / 10) + o.movement,
  44276. f = l ? Is.noise(p) : h(p, p);
  44277. (d.scale.x = t.scale[0] + u(c, Ye(f, o.scale[0])) || Pi),
  44278. (d.scale.y = t.scale[1] + u(c, Ye(f, o.scale[1])) || Pi),
  44279. (d.scale.z = t.scale[2] + u(c, Ye(f, o.scale[2])) || Pi),
  44280. d.position.setScalar(0);
  44281. let g = (s / e.count) * c - i;
  44282. switch (t.axis) {
  44283. case 'x':
  44284. d.rotation.set(0, g, 0);
  44285. break;
  44286. case 'y':
  44287. d.rotation.set(0, 0, g);
  44288. break;
  44289. case 'z':
  44290. d.rotation.set(g, 0, 0);
  44291. break;
  44292. }
  44293. d.translateOnAxis(a, t.radius),
  44294. (d.position.x += t.position[0] + u(c, Ye(f, o.position[0]))),
  44295. (d.position.y += t.position[1] + u(c, Ye(f, o.position[1]))),
  44296. (d.position.z += t.position[2] + u(c, Ye(f, o.position[2])));
  44297. let m = u(c, Ye(f, o.rotation[0])),
  44298. v = u(c, Ye(f, o.rotation[1])),
  44299. y = u(c, Ye(f, o.rotation[2]));
  44300. t.alignment === !0
  44301. ? ((d.rotation.x += n.x + m), (d.rotation.y += n.y + v), (d.rotation.z += n.z + y))
  44302. : d.rotation.set(n.x + m, n.y + v, n.z + y);
  44303. }
  44304. }
  44305. _updateLinear(e) {
  44306. if (e.type !== 'linear') throw new Error();
  44307. let t = e.linear,
  44308. i = new _i(t.rotation[0], t.rotation[1], t.rotation[2]),
  44309. r = e.randomnessObject ?? bn.defaultData([1, 1, 1]).randomnessObject,
  44310. s = r.noiseType === 'perlin';
  44311. Is.noiseSeed(r.seed);
  44312. let n = Hp((0, El.default)(r.seed)),
  44313. a = jc(r.strength, this.parameters.randomness);
  44314. for (let [o, l] of this.children.entries()) {
  44315. let h = o * (r.freqScale / 10) + r.movement,
  44316. u = s ? Is.noise(h) : n(h, h),
  44317. c = a(o, Ye(u, r.rotation[0])),
  44318. d = a(o, Ye(u, r.rotation[1])),
  44319. p = a(o, Ye(u, r.rotation[2]));
  44320. (l.scale.x = 1 + (t.scale[0] - 1) * o + a(o, Ye(u, r.scale[0])) || Pi),
  44321. (l.scale.y = 1 + (t.scale[1] - 1) * o + a(o, Ye(u, r.scale[1])) || Pi),
  44322. (l.scale.z = 1 + (t.scale[2] - 1) * o + a(o, Ye(u, r.scale[2])) || Pi),
  44323. (l.rotation.x = i.x * o + c),
  44324. (l.rotation.y = i.y * o + d),
  44325. (l.rotation.z = i.z * o + p),
  44326. (l.position.x = t.position[0] * o + a(o, Ye(u, r.position[0]))),
  44327. (l.position.y = t.position[1] * o + a(o, Ye(u, r.position[1]))),
  44328. (l.position.z = t.position[2] * o + a(o, Ye(u, r.position[2])));
  44329. }
  44330. }
  44331. _updateGrid(e) {
  44332. let t = 0,
  44333. i = e.grid,
  44334. r = e.randomnessObject ?? bn.defaultData([1, 1, 1]).randomnessObject,
  44335. s = jc(r.strength, this.parameters.randomness),
  44336. n = r.noiseType === 'perlin';
  44337. Is.noiseSeed(r.seed);
  44338. let a = lF((0, El.default)(r.seed));
  44339. if (i.useCenter === !0) {
  44340. let o = { x: i.count[0] % 2 === 0 ? 2 : 1, y: i.count[1] % 2 === 0 ? 2 : 1, z: i.count[2] % 2 === 0 ? 2 : 1 },
  44341. l = new E(i.size[0] * (i.count[0] - o.x) * 0.5, i.size[1] * (i.count[1] - o.y) * 0.5, i.size[2] * (i.count[2] - o.z) * 0.5);
  44342. for (let h = 0; h < i.count[0]; h++)
  44343. for (let u = 0; u < i.count[1]; u++)
  44344. for (let c = 0; c < i.count[2]; c++) {
  44345. let d = [
  44346. (h + 1) * (r.freqScale / 10) + r.movement,
  44347. (u + 1) * (r.freqScale / 10) + r.movement,
  44348. (c + 1) * (r.freqScale / 10) + r.movement
  44349. ],
  44350. p = n ? Is.noise(...d) : a(...d),
  44351. f = this.children[t++];
  44352. (f.scale.x = 1 + s(t, Ye(p, r.scale[0])) || Pi),
  44353. (f.scale.y = 1 + s(t, Ye(p, r.scale[1])) || Pi),
  44354. (f.scale.z = 1 + s(t, Ye(p, r.scale[2])) || Pi);
  44355. let g = s(t, Ye(p, r.rotation[0])),
  44356. m = s(t, Ye(p, r.rotation[1])),
  44357. v = s(t, Ye(p, r.rotation[2]));
  44358. f.rotation.set(g, m, v),
  44359. (f.position.x = i.size[0] * h - l.x + s(t, Ye(p, r.position[0]))),
  44360. (f.position.y = i.size[1] * u - l.y + s(t, Ye(p, r.position[1]))),
  44361. (f.position.z = i.size[2] * c - l.z + s(t, Ye(p, r.position[2])));
  44362. }
  44363. } else
  44364. for (let o = 0; o < i.count[0]; o++)
  44365. for (let l = 0; l < i.count[1]; l++)
  44366. for (let h = 0; h < i.count[2]; h++) {
  44367. let u = [
  44368. (o + 1) * (r.freqScale / 10) + r.movement,
  44369. (l + 1) * (r.freqScale / 10) + r.movement,
  44370. (h + 1) * (r.freqScale / 10) + r.movement
  44371. ],
  44372. c = n ? Is.noise(...u) : a(...u),
  44373. d = this.children[t++];
  44374. (d.scale.x = 1 + s(t, Ye(c, r.scale[0])) || Pi),
  44375. (d.scale.y = 1 + s(t, Ye(c, r.scale[1])) || Pi),
  44376. (d.scale.z = 1 + s(t, Ye(c, r.scale[2])) || Pi);
  44377. let p = s(t, Ye(c, r.rotation[0])),
  44378. f = s(t, Ye(c, r.rotation[1])),
  44379. g = s(t, Ye(c, r.rotation[2]));
  44380. d.rotation.set(p, f, g),
  44381. (d.position.x = i.size[0] * o + s(t, Ye(c, r.position[0]))),
  44382. (d.position.y = -i.size[1] * l + s(t, Ye(c, r.position[1]))),
  44383. (d.position.z = -i.size[2] * h + s(t, Ye(c, r.position[2])));
  44384. }
  44385. }
  44386. _updateToObject(e) {
  44387. if (e.type !== 'toObject') throw new Error();
  44388. let { toObject: t } = e,
  44389. i = new _i(t.rotation[0], t.rotation[1], t.rotation[2]),
  44390. r = e.randomnessObject ?? bn.defaultData([1, 1, 1]).randomnessObject,
  44391. s = r.noiseType === 'perlin';
  44392. Is.noiseSeed(r.seed);
  44393. let n = Hp((0, El.default)(r.seed)),
  44394. a = jc(r.strength, this.parameters.randomness);
  44395. if (!t.object) {
  44396. for (let [, g] of this.children.entries()) g.position.set(0, 0, 0), g.scale.setScalar(1), g.rotation.set(0, 0, 0);
  44397. this.objectForSample = void 0;
  44398. return;
  44399. }
  44400. if (!this.objectForSample) return;
  44401. if (this.objectForSample instanceof yS)
  44402. if (!this.objectForSample.font?.isLoaded || this.objectForSample.geometry.attributes.position === void 0) {
  44403. this._pendingMediaLoad = !0;
  44404. return;
  44405. } else this._pendingMediaLoad = !1;
  44406. if (this.objectForSample.geometry === void 0 && this.objectForSample.isAncestorOf(this.object.uuid)) {
  44407. console.warn(
  44408. `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.`
  44409. );
  44410. return;
  44411. }
  44412. let o = this.getSubdivData(),
  44413. l = [],
  44414. h = (g) => {
  44415. let m = g.length,
  44416. v = g.map((x) => x[0]).reduce((x, w) => x + w, 0),
  44417. y = g.map((x) => x[1]).reduce((x, w) => x + w, 0),
  44418. b = g.map((x) => x[2]).reduce((x, w) => x + w, 0);
  44419. return [v / m, y / m, b / m];
  44420. },
  44421. u = (g) => Math.round(g * 1e6) / 1e6;
  44422. o.forEach((g) => {
  44423. let m = o.filter((v) => u(g.pos[0]) === u(v.pos[0]) && u(g.pos[1]) === u(v.pos[1]) && u(g.pos[2]) === u(v.pos[2]));
  44424. m.length > 1 ? l.push({ pos: g.pos, norm: h(m.map((v) => v.norm)) }) : l.push(g);
  44425. });
  44426. let c = Zk(l);
  44427. if (o.length > 0) {
  44428. let g = Math.round((c.length * t.count) / 100);
  44429. this._updateCount(g);
  44430. }
  44431. this.objectForSample.updateMatrixWorld();
  44432. let d = new hF(this.objectForSample).build(),
  44433. p = Yk[t.axis],
  44434. f = this.children;
  44435. d.setRandomGenerator((0, El.default)(this.object.uuid + t.seed));
  44436. for (let [g, m] of f.entries()) {
  44437. let v = g * (r.freqScale / 10) + r.movement,
  44438. y = s ? Is.noise(v) : n(v, v),
  44439. b = a(g, Ye(y, r.rotation[0])),
  44440. x = a(g, Ye(y, r.rotation[1])),
  44441. w = a(g, Ye(y, r.rotation[2]));
  44442. t.spreadType === 'random'
  44443. ? d.sample(Rl, of)
  44444. : (c.length && (Rl.fromArray(c[g].pos), of.fromArray(c[g].norm)),
  44445. this.objectForSample instanceof Sh && Rl.applyMatrix4(a8.copy(this.objectForSample.matrixWorld).invert())),
  44446. Rl.applyMatrix4(this.object.hiddenMatrix.clone().invert()),
  44447. m.position.copy(Rl),
  44448. nn.fromArray(p);
  44449. let A = t.align === 'normal' ? of : this.object.getWorldDirection(h8),
  44450. S = Qn.fromArray(t.position);
  44451. (Qn.x += Qn.x + a(g, Ye(y, r.position[0]))),
  44452. (Qn.y += Qn.y + a(g, Ye(y, r.position[1]))),
  44453. (Qn.z += Qn.z + a(g, Ye(y, r.position[2])));
  44454. let _ = Math.acos(A.dot(nn)),
  44455. M = l8.crossVectors(nn, A).normalize(),
  44456. C = o8.makeRotationAxis(M, _),
  44457. T = A.clone().cross(this.object.up).normalize(),
  44458. P = T.clone().cross(A).normalize(),
  44459. L = new ve().makeBasis(T, A, P),
  44460. D = new E(nn.y, nn.z, nn.x).normalize(),
  44461. k = D.clone().cross(nn).normalize(),
  44462. W = new ve().makeBasis(D, nn, k).invert(),
  44463. X = new ve().multiplyMatrices(L, W);
  44464. m.rotation.setFromRotationMatrix(X),
  44465. S.applyMatrix4(C),
  44466. m.position.add(S),
  44467. (m.rotation.x = m.rotation.x + i.x + b),
  44468. (m.rotation.y = m.rotation.y + i.y + x),
  44469. (m.rotation.z = m.rotation.z + i.z + w),
  44470. m.scale.setScalar(1),
  44471. (m.scale.x = m.scale.x + t.scale[0] + a(g, Ye(y, r.scale[0])) || Pi),
  44472. (m.scale.y = m.scale.y + t.scale[1] + a(g, Ye(y, r.scale[1])) || Pi),
  44473. (m.scale.z = m.scale.z + t.scale[2] + a(g, Ye(y, r.scale[2])) || Pi),
  44474. m.scale.multiply(this.object.scale),
  44475. (m.hiddenMatrix = this.object.hiddenMatrix);
  44476. }
  44477. }
  44478. getSubdivData() {
  44479. if (!this.objectForSample) return [];
  44480. let e = this.parameters.toObject.spreadType;
  44481. if (e === 'random') return [];
  44482. if (this.objectForSample instanceof Sh) {
  44483. let t = this.objectForSample,
  44484. i = Qk[e],
  44485. r = wS[i],
  44486. s = xS[i],
  44487. n = bS[i],
  44488. a = [],
  44489. o = r(t.subdivPointerNew);
  44490. for (let l = 0; l <= o - 1; l++) {
  44491. let h = s(t.subdivPointerNew, l),
  44492. u = n(t.subdivPointerNew, l);
  44493. $x.fromArray(h).applyMatrix4(t.matrixWorld), eb.fromArray(u), a.push({ pos: $x.toArray(), norm: eb.toArray() });
  44494. }
  44495. return a;
  44496. } else
  44497. return (this.objectForSample.geometry.index ? e8(this.objectForSample.geometry) : t8(this.objectForSample.geometry))
  44498. .map((t, i) =>
  44499. e === 'polygon_center'
  44500. ? { pos: t.midpoint, norm: t.norm }
  44501. : e === 'vertex'
  44502. ? [
  44503. { pos: t.vertices[0], norm: t.norm },
  44504. { pos: t.vertices[1], norm: t.norm },
  44505. { pos: t.vertices[2], norm: t.norm }
  44506. ]
  44507. : e === 'edge'
  44508. ? [
  44509. { pos: t.faceCenters[0], norm: t.norm },
  44510. { pos: t.faceCenters[1], norm: t.norm },
  44511. { pos: t.faceCenters[2], norm: t.norm }
  44512. ]
  44513. : []
  44514. )
  44515. .flat();
  44516. }
  44517. updateState(e, t) {
  44518. if (((this.parameters = yu(e)), this.parameters.type !== 'toObject'))
  44519. (this.parent === null || this.parent !== this.object) &&
  44520. (this.removeFromParent(),
  44521. this.object.parent?.add(this),
  44522. (this.matrix = this.object.matrix),
  44523. (this.hiddenMatrix = this.object.hiddenMatrix),
  44524. (this.matrixWorldNeedsUpdate = !0),
  44525. (this.matrixAutoUpdate = !1));
  44526. else if (this.parent === null || this.parent.uuid !== this.parameters.toObject.object) {
  44527. this.removeFromParent();
  44528. let i = t.find(this.parameters.toObject.object);
  44529. i instanceof ar ? (this.objectForSample = i) : (this.objectForSample = void 0),
  44530. (this.matrix = new ve()),
  44531. (this.hiddenMatrix = new ve()),
  44532. (this.matrixWorldNeedsUpdate = !0),
  44533. (this.matrixAutoUpdate = !1),
  44534. i && i.add(this);
  44535. }
  44536. this.update();
  44537. }
  44538. get pendingMediaLoad() {
  44539. return this._pendingMediaLoad;
  44540. }
  44541. },
  44542. zh = (e) => {
  44543. var t;
  44544. return (t = class extends e {}), (t.geometryHelper = new vs(30, 30, 30)), t;
  44545. },
  44546. Hc = new Xo(),
  44547. lf = new Mr(),
  44548. tb = new ve(),
  44549. Nh = (e, t, i, r, s = !1) => {
  44550. let n = t,
  44551. a = e.matrixWorld;
  44552. if (
  44553. (n.boundingSphere === null && n.computeBoundingSphere(),
  44554. lf.copy(n.boundingSphere),
  44555. lf.applyMatrix4(a),
  44556. i.ray.intersectsSphere(lf) === !1 ||
  44557. (tb.copy(a).invert(), Hc.copy(i.ray).applyMatrix4(tb), n.boundingBox !== null && Hc.intersectsBox(n.boundingBox) === !1))
  44558. )
  44559. return;
  44560. let o,
  44561. l,
  44562. h,
  44563. u,
  44564. c = n.index,
  44565. d = n.attributes.position,
  44566. p = n.drawRange,
  44567. f,
  44568. g;
  44569. if (s === !1) {
  44570. let v = Math.max(0, p.start),
  44571. y = Math.min(c.count, p.start + p.count);
  44572. for (f = v, g = y; f < g; f += 3)
  44573. if (((l = c.getX(f)), (h = c.getX(f + 1)), (u = c.getX(f + 2)), (o = m(e, i, Hc, d, l, h, u)), o)) {
  44574. (o.faceIndex = Math.floor(f / 3)), r.push(o);
  44575. return;
  44576. }
  44577. } else {
  44578. let v = n.attributes.position,
  44579. y = new E(),
  44580. b = new E(),
  44581. x = new E(),
  44582. w = new E(),
  44583. A = 2,
  44584. S = 1 / ((e.scale.x + e.scale.y + e.scale.z) / 3),
  44585. _ = S * S,
  44586. M = Math.max(0, p.start),
  44587. C = Math.min(v.count, p.start + p.count);
  44588. for (let T = M, P = C - 1; T < P; T += A) {
  44589. if ((y.fromBufferAttribute(v, T), b.fromBufferAttribute(v, T + 1), Hc.distanceSqToSegment(y, b, w, x) > _)) continue;
  44590. w.applyMatrix4(e.matrixWorld);
  44591. let L = i.ray.origin.distanceTo(w);
  44592. L < i.near || L > i.far || r.push({ distance: L, point: x.clone().applyMatrix4(e.matrixWorld), object: e });
  44593. }
  44594. }
  44595. function m(v, y, b, x, w, A, S) {
  44596. let _ = new E(),
  44597. M = new E(),
  44598. C = new E(),
  44599. T = new E(),
  44600. P = new E();
  44601. if (
  44602. (_.fromBufferAttribute(x, w),
  44603. M.fromBufferAttribute(x, A),
  44604. C.fromBufferAttribute(x, S),
  44605. b.intersectTriangle(_, M, C, !1, T) === null)
  44606. )
  44607. return null;
  44608. P.copy(T), P.applyMatrix4(v.matrixWorld);
  44609. let L = y.ray.origin.distanceTo(P);
  44610. return L < y.near || L > y.far ? null : { faceIndex: 1, distance: L, point: P.clone(), object: v };
  44611. }
  44612. },
  44613. Wc = new E(),
  44614. dr = new Yo(),
  44615. c8 = class extends Dh {
  44616. constructor(e) {
  44617. let t = new Ve(),
  44618. i = new Rn({ color: 16777215, vertexColors: !0, toneMapped: !1 }),
  44619. r = [],
  44620. s = [],
  44621. n = {},
  44622. a = new Ge(15711266),
  44623. o = new Ge(15711266),
  44624. l = new Ge(2857471);
  44625. h('n1', 'n2', a),
  44626. h('n2', 'n4', a),
  44627. h('n4', 'n3', a),
  44628. h('n3', 'n1', a),
  44629. h('f1', 'f2', a),
  44630. h('f2', 'f4', a),
  44631. h('f4', 'f3', a),
  44632. h('f3', 'f1', a),
  44633. h('n1', 'f1', a),
  44634. h('n2', 'f2', a),
  44635. h('n3', 'f3', a),
  44636. h('n4', 'f4', a),
  44637. h('p', 'n1', o),
  44638. h('p', 'n2', o),
  44639. h('p', 'n3', o),
  44640. h('p', 'n4', o),
  44641. h('u1', 'u2', l),
  44642. h('u2', 'u3', l),
  44643. h('u3', 'u1', l);
  44644. function h(c, d, p) {
  44645. u(c, p), u(d, p);
  44646. }
  44647. function u(c, d) {
  44648. r.push(0, 0, 0), s.push(d.r, d.g, d.b), n[c] === void 0 && (n[c] = []), n[c].push(r.length / 3 - 1);
  44649. }
  44650. t.setAttribute('position', new Ce(r, 3)),
  44651. t.setAttribute('color', new Ce(s, 3)),
  44652. super(t, i),
  44653. (this.type = 'CameraHelper'),
  44654. (this.camera = e),
  44655. this.camera.updateProjectionMatrix && this.camera.updateProjectionMatrix(),
  44656. (this.matrix = e.matrixWorld),
  44657. (this.matrixAutoUpdate = !1),
  44658. (this.pointMap = n),
  44659. this.update();
  44660. }
  44661. update() {
  44662. let e = this.geometry,
  44663. t = this.pointMap,
  44664. i = !0;
  44665. dr.projectionMatrixInverse.elements = [
  44666. 0.5112609807824982, -0, -0, -0, -0, 0.41421356237309503, -0, -0, -0, -0, -0, -0.099999, -0, -0, -1.0000000000000002, 0.100001
  44667. ];
  44668. let r = 1,
  44669. s = 1,
  44670. n = i ? 0.8 : 1e-4;
  44671. Rr('n1', t, e, dr, -r, -s, n), Rr('n2', t, e, dr, r, -s, n), Rr('n3', t, e, dr, -r, s, n), Rr('n4', t, e, dr, r, s, n);
  44672. let a = n;
  44673. Rr('f1', t, e, dr, -r, -s, a), Rr('f2', t, e, dr, r, -s, a), Rr('f3', t, e, dr, -r, s, a), Rr('f4', t, e, dr, r, s, a);
  44674. let o = a,
  44675. l = 0.5;
  44676. Rr('u1', t, e, dr, r * 0.7 * l, s * 1.1, o),
  44677. Rr('u2', t, e, dr, -r * 0.7 * l, s * 1.1, o),
  44678. Rr('u3', t, e, dr, 0, s * (1.1 + 0.9 * l), o),
  44679. (e.getAttribute('position').needsUpdate = !0);
  44680. }
  44681. dispose() {
  44682. this.geometry.dispose(), this.material.dispose();
  44683. }
  44684. };
  44685. function Rr(e, t, i, r, s, n, a) {
  44686. Wc.set(s, n, a).unproject(r);
  44687. let o = t[e];
  44688. if (o !== void 0) {
  44689. let l = i.getAttribute('position');
  44690. for (let h = 0, u = o.length; h < u; h++) l.setXYZ(o[h], Wc.x, Wc.y, Wc.z);
  44691. }
  44692. }
  44693. var d8 = class extends zh(c8) {
  44694. constructor(e) {
  44695. super(e), (this.object = e), (this.object = e), (this.name = `CombinedCameraHelper: ${e.uuid}`);
  44696. }
  44697. updateMatrixWorld(e) {
  44698. super.updateMatrixWorld(e), this.updateTarget();
  44699. }
  44700. updateTarget() {
  44701. let e = this.object.getTarget();
  44702. this.updateWorldMatrix(!0, !1), this.worldToLocal(e);
  44703. }
  44704. raycast(e, t) {
  44705. Nh(this.object, this.geometry, e, t, !0);
  44706. }
  44707. },
  44708. Vm;
  44709. ((e) => (e.is = (t) => 'objectHelper' in t))(Vm || (Vm = {}));
  44710. var Tu = (e, t) =>
  44711. class extends dA(e) {
  44712. constructor() {
  44713. super(...arguments), (this.objectHelper = new t(this)), (this.gizmos = {});
  44714. }
  44715. get geometryHelper() {
  44716. return t.geometryHelper;
  44717. }
  44718. raycast(i, r) {
  44719. this.objectHelper.raycast(i, r);
  44720. }
  44721. showGizmos() {
  44722. for (let i in this.gizmos) {
  44723. let r = this.gizmos[i];
  44724. r instanceof wd && (r.visible = !0);
  44725. }
  44726. }
  44727. updateEntityBoxSize(i, r) {
  44728. this.objectHelper.visible && this.geometryHelper instanceof vs
  44729. ? (i.setScalar(0),
  44730. r
  44731. .set(this.geometryHelper.parameters.width, this.geometryHelper.parameters.height, this.geometryHelper.parameters.height)
  44732. .multiplyScalar(0.5))
  44733. : super.updateEntityBoxSize(i, r);
  44734. }
  44735. hideGizmos() {
  44736. for (let i in this.gizmos) {
  44737. let r = this.gizmos[i];
  44738. r instanceof wd && (r.visible = !1);
  44739. }
  44740. }
  44741. },
  44742. hf = 790,
  44743. $a = new E(),
  44744. cf = new E(),
  44745. df = new ct(),
  44746. uf = new E(),
  44747. Bl = new E(),
  44748. pf = new E(),
  44749. Gi = class extends Tu(Yo, d8) {
  44750. constructor(e = '', t = { ...Ud.defaultData, name: '' }) {
  44751. super(),
  44752. (this._cameraType = 'OrthographicCamera'),
  44753. (this.targetOffset = xh.DefaultTargetOffset),
  44754. (this.isUpVectorFlipped = !1),
  44755. (this.angleOffsetFromUp = 0),
  44756. (this.wasMovedByUser = !1),
  44757. this.super_Entity(e, t),
  44758. (this.matrixAutoUpdate = !0),
  44759. (this.width = window.innerWidth),
  44760. (this.height = window.innerHeight);
  44761. let i = this.width,
  44762. r = this.height;
  44763. if (t.orthographic.autoZoom) {
  44764. let s = t.orthographic.autoZoomFrustumSize ?? hf,
  44765. n = i / r,
  44766. a = i > r ? n : 1,
  44767. o = i > r ? 1 : n;
  44768. this.orthoCamera = new gd(-s * 0.5 * a, s * 0.5 * a, s * 0.5 * (1 / o), -s * 0.5 * (1 / o), -5e4, 1e4);
  44769. } else this.orthoCamera = new gd(i * -0.5, i * 0.5, r * 0.5, r * -0.5, -5e4, 1e4);
  44770. (this.perspCamera = new wi(45, i / r, 50, 1e4)),
  44771. (this.left = this.orthoCamera.left),
  44772. (this.right = this.orthoCamera.right),
  44773. (this.top = this.orthoCamera.top),
  44774. (this.bottom = this.orthoCamera.bottom),
  44775. (this.far = this.orthoCamera.far),
  44776. (this.view = this.orthoCamera.view),
  44777. (this.aspect = this.perspCamera.aspect),
  44778. (this.focus = this.perspCamera.focus),
  44779. (this.filmGauge = this.perspCamera.filmGauge),
  44780. (this.filmOffset = this.perspCamera.filmOffset),
  44781. this.objectHelper.update();
  44782. }
  44783. get isPerspectiveCamera() {
  44784. return this.cameraType === 'PerspectiveCamera';
  44785. }
  44786. get isOrthographicCamera() {
  44787. return !this.isPerspectiveCamera;
  44788. }
  44789. get cameraType() {
  44790. return this._cameraType;
  44791. }
  44792. set fov(e) {
  44793. this.perspCamera.fov = e;
  44794. }
  44795. get fov() {
  44796. return this.perspCamera.fov;
  44797. }
  44798. setNear(e, t) {
  44799. e === 'PerspectiveCamera' ? (this.perspCamera.near = t) : (this.orthoCamera.near = t);
  44800. }
  44801. setZoom(e, t) {
  44802. t >= 0 && (e === 'PerspectiveCamera' ? (this.perspCamera.zoom = t) : (this.orthoCamera.zoom = t));
  44803. }
  44804. set cameraType(e) {
  44805. e === 'PerspectiveCamera' ? this.toPerspective() : e === 'OrthographicCamera' && this.toOrthographic();
  44806. }
  44807. get near() {
  44808. return this._cameraType === 'PerspectiveCamera' ? this.perspCamera.near : this.orthoCamera.near;
  44809. }
  44810. set near(e) {
  44811. this._cameraType === 'PerspectiveCamera' ? (this.perspCamera.near = e) : (this.orthoCamera.near = e);
  44812. }
  44813. get zoom() {
  44814. return this._cameraType === 'PerspectiveCamera' ? this.perspCamera.zoom : this.orthoCamera.zoom;
  44815. }
  44816. set zoom(e) {
  44817. e >= 0 && (this._cameraType === 'PerspectiveCamera' ? (this.perspCamera.zoom = e) : (this.orthoCamera.zoom = e));
  44818. }
  44819. lookAt(e, t, i) {
  44820. typeof e == 'number' && (e = new E(e, t, i)), super.lookAt(e), this.getWorldPosition($a), (this.targetOffset = $a.distanceTo(e));
  44821. }
  44822. getTarget(e = new E()) {
  44823. return this.getWorldDirection(cf), this.getWorldPosition($a), cf.multiplyScalar(this.targetOffset), e.copy($a).add(cf), e;
  44824. }
  44825. getDistanceToTarget() {
  44826. let e = this.getTarget();
  44827. return this.getWorldPosition($a), $a.distanceTo(e);
  44828. }
  44829. updateUp() {
  44830. this.getWorldQuaternion(df),
  44831. uf.set(0, 0, 1).applyQuaternion(df),
  44832. Bl.copy(bt.DEFAULT_UP),
  44833. this.isUpVectorFlipped && Bl.negate(),
  44834. Bl.applyQuaternion(df),
  44835. pf.copy(bt.DEFAULT_UP).projectOnPlane(uf),
  44836. (this.angleOffsetFromUp = pf.angleTo(Bl)),
  44837. (this.angleOffsetFromUp *= pf.cross(Bl).dot(uf) >= 0 ? 1 : -1);
  44838. }
  44839. updateTransformState(e) {
  44840. let t = super.updateTransformState(e);
  44841. return e.isUpVectorFlipped !== void 0 && (this.isUpVectorFlipped = e.isUpVectorFlipped), this.updateUp(), t;
  44842. }
  44843. getViewFrontToObject(e) {
  44844. let t = e.getWorldPosition(new E()),
  44845. i = e.getWorldDirection(new E()).multiplyScalar(this.targetOffset);
  44846. return { position: t.clone().add(i), target: t };
  44847. }
  44848. getViewToObject(e) {
  44849. let t = e.getWorldPosition(new E()),
  44850. i = this.getWorldDirection(new E()).multiplyScalar(this.targetOffset);
  44851. return { position: t.clone().sub(i), target: t };
  44852. }
  44853. setViewplaneSize(e, t) {
  44854. if (((this.aspect = e / t), this.data.type === 'OrthographicCamera' && this.data.orthographic.autoZoom)) {
  44855. let i = this.data.orthographic.autoZoomFrustumSize ?? hf,
  44856. r = e > t ? this.aspect : 1,
  44857. s = e > t ? 1 : this.aspect;
  44858. (this.left = -i * 0.5 * r), (this.right = i * 0.5 * r), (this.top = i * 0.5 * (1 / s)), (this.bottom = -i * 0.5 * (1 / s));
  44859. } else (this.left = -e * 0.5), (this.right = e * 0.5), (this.top = t * 0.5), (this.bottom = -t * 0.5);
  44860. this.updateProjectionMatrix();
  44861. }
  44862. toOrthographic() {
  44863. (this.orthoCamera.left = this.left),
  44864. (this.orthoCamera.right = this.right),
  44865. (this.orthoCamera.top = this.top),
  44866. (this.orthoCamera.bottom = this.bottom),
  44867. (this.orthoCamera.view = this.view),
  44868. (this.orthoCamera.far = this.far),
  44869. this.orthoCamera.updateProjectionMatrix(),
  44870. (this.projectionMatrix = this.orthoCamera.projectionMatrix),
  44871. (this.projectionMatrixInverse = this.orthoCamera.projectionMatrixInverse),
  44872. (this._cameraType = 'OrthographicCamera'),
  44873. this.objectHelper && this.objectHelper.update();
  44874. }
  44875. toPerspective() {
  44876. (this.perspCamera.aspect = this.aspect),
  44877. (this.perspCamera.fov = this.fov),
  44878. (this.perspCamera.view = this.view),
  44879. (this.perspCamera.far = this.far),
  44880. this.perspCamera.updateProjectionMatrix(),
  44881. (this.projectionMatrix = this.perspCamera.projectionMatrix),
  44882. (this.projectionMatrixInverse = this.perspCamera.projectionMatrixInverse),
  44883. (this._cameraType = 'PerspectiveCamera'),
  44884. this.objectHelper && this.objectHelper.update();
  44885. }
  44886. setFocalLength(e) {
  44887. this.perspCamera.setFocalLength(e), this.toPerspective();
  44888. }
  44889. getFocalLength() {
  44890. return this.perspCamera.getFocalLength();
  44891. }
  44892. getEffectiveFOV() {
  44893. return this.perspCamera.getEffectiveFOV();
  44894. }
  44895. getFilmWidth() {
  44896. return this.perspCamera.getFilmWidth();
  44897. }
  44898. getFilmHeight() {
  44899. return this.perspCamera.getFilmHeight();
  44900. }
  44901. setViewOffset(e, t, i, r, s, n) {
  44902. this._cameraType === 'PerspectiveCamera'
  44903. ? this.perspCamera.setViewOffset(e, t, i, r, s, n)
  44904. : this.orthoCamera.setViewOffset(e, t, i, r, s, n);
  44905. }
  44906. clearViewOffset() {
  44907. this._cameraType === 'PerspectiveCamera'
  44908. ? (this.perspCamera.clearViewOffset(), this.toPerspective())
  44909. : (this.orthoCamera.clearViewOffset(), this.toOrthographic());
  44910. }
  44911. updateProjectionMatrix() {
  44912. this._cameraType === 'PerspectiveCamera' ? this.toPerspective() : this._cameraType === 'OrthographicCamera' && this.toOrthographic();
  44913. }
  44914. updateMatrixWorld(e) {
  44915. super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  44916. }
  44917. updateWorldMatrix(e, t) {
  44918. super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  44919. }
  44920. copy(e, t) {
  44921. return (
  44922. super.copy(e, t),
  44923. this.orthoCamera.copy(e.orthoCamera),
  44924. this.perspCamera.copy(e.perspCamera),
  44925. (this.left = e.left),
  44926. (this.right = e.right),
  44927. (this.top = e.top),
  44928. (this.bottom = e.bottom),
  44929. (this.far = e.far),
  44930. (this.view = e.view === null ? null : Object.assign({}, e.view)),
  44931. (this._cameraType = e._cameraType),
  44932. (this.aspect = e.aspect),
  44933. (this.fov = e.fov),
  44934. (this.focus = e.focus),
  44935. (this.filmGauge = e.filmGauge),
  44936. (this.filmOffset = e.filmOffset),
  44937. (this.targetOffset = e.targetOffset),
  44938. this.updateProjectionMatrix(),
  44939. this
  44940. );
  44941. }
  44942. toCameraState(e = []) {
  44943. let t = {
  44944. type: this.cameraType,
  44945. far: this.far,
  44946. orthographic: { near: this.orthoCamera.near, zoom: this.orthoCamera.zoom, autoZoom: !0, autoZoomFrustumSize: hf },
  44947. perspective: { near: this.perspCamera.near, fov: this.perspCamera.fov, zoom: this.perspCamera.zoom },
  44948. up: this.up.toArray(),
  44949. targetOffset: this.targetOffset,
  44950. isUpVectorFlipped: this.isUpVectorFlipped
  44951. };
  44952. return tm(t, e);
  44953. }
  44954. updateCameraSubtype(e, t) {
  44955. let i = e === 'perspective' ? 'PerspectiveCamera' : 'OrthographicCamera';
  44956. t.zoom !== void 0 && this.setZoom(i, t.zoom),
  44957. t.near !== void 0 && this.setNear(i, t.near),
  44958. t.fov !== void 0 && i === 'PerspectiveCamera' && (this.fov = t.fov);
  44959. }
  44960. updateState(e, t) {
  44961. this.updateCameraState(e, t);
  44962. }
  44963. updateCameraState(e, t) {
  44964. this.updateState_Entity(e, t),
  44965. e.far !== void 0 && (this.far = e.far),
  44966. e.orthographic !== void 0 && this.updateCameraSubtype('orthographic', e.orthographic),
  44967. e.perspective !== void 0 && this.updateCameraSubtype('perspective', e.perspective),
  44968. e.type !== void 0 && (this.cameraType = e.type),
  44969. e.up !== void 0 && this.up.fromArray(e.up),
  44970. e.targetOffset !== void 0 && (this.targetOffset = e.targetOffset),
  44971. e.isUpVectorFlipped !== void 0 && (this.isUpVectorFlipped = e.isUpVectorFlipped),
  44972. this.updateProjectionMatrix();
  44973. }
  44974. updateByPatchedOp(e, t, i) {
  44975. super.updateByPatchedOp(e, t, i), e.path.length === 1 && e.type === 0 && this.updateCameraSubtype(e.path[0], e.props);
  44976. }
  44977. toState(e) {
  44978. return { ...super.toState(e), ...this.toCameraState(e), type: this.cameraType };
  44979. }
  44980. },
  44981. ib = new ve();
  44982. function rb(e) {
  44983. let t = !1;
  44984. return (
  44985. e.scene.objects.traverse((i, r) => {
  44986. r.geometry?.type === 'BooleanGeometry' && (t = !0);
  44987. }),
  44988. t
  44989. );
  44990. }
  44991. var Ho = class extends Cu {
  44992. constructor(e, t, i) {
  44993. super(e, t),
  44994. (this.data = t),
  44995. (this.meshSetAddresses = []),
  44996. (this.needsTransformForDownstream = !1),
  44997. (this.geometry = new Ve()),
  44998. (this.geometry.userData.parameters = { width: 0, height: 0, depth: 0 });
  44999. }
  45000. get booleanOp() {
  45001. return this.data.geometry.operation;
  45002. }
  45003. get phongAngle() {
  45004. return this.data.geometry.phongAngle ?? 45;
  45005. }
  45006. get isLOD() {
  45007. return this.recomputeBoolean(), !1;
  45008. }
  45009. updateByPatchedOp(e, t, i) {
  45010. super.updateByPatchedOp(e, t, i),
  45011. e.path.length === 1 &&
  45012. e.path[0] === 'geometry' &&
  45013. e.type === 0 &&
  45014. e.props.operation !== void 0 &&
  45015. (this.freeBooleanPointer(), this.resetBBoxNeedsUpdate());
  45016. }
  45017. freeBooleanPointer() {
  45018. super.freeBooleanPointer(), this.geometry.dispose();
  45019. }
  45020. recomputeBoolean(e, t = !0) {
  45021. if (this.booleanMeshSetAddress !== -1 && !e) return;
  45022. for (let r = 0; r < this.children.length; r++) {
  45023. let s = this.children[r];
  45024. s instanceof Ho && s.recomputeBoolean(e === !0, t);
  45025. }
  45026. this.meshSetAddresses = [];
  45027. for (let r = 0; r < this.children.length; r++) {
  45028. let s = this.children[r];
  45029. if (
  45030. s instanceof ar &&
  45031. s.dataPatched.visible === !0 &&
  45032. s.geometry.attributes.position?.count > 0 &&
  45033. s.geometry.drawRange.count > 0
  45034. ) {
  45035. if (s.booleanMeshSetAddress === -1) {
  45036. if (
  45037. ((s.geometry.index ?? s.geometry.getAttribute('position')).count / 3 < 15e5 &&
  45038. (s.booleanMeshSetAddress = dn.getMeshSet(s.geometry, e === !0, t)),
  45039. s.booleanMeshSetAddress === -1)
  45040. )
  45041. return;
  45042. dn.transformMeshSet(s.booleanMeshSetAddress, s.matrix),
  45043. s.booleanMatrixInvOld.copy(s.matrix).invert(),
  45044. (s.booleanWasTransformed = !1);
  45045. } else
  45046. s instanceof Ho && s.needsTransformForDownstream === !0
  45047. ? (dn.transformMeshSet(s.booleanMeshSetAddress, s.matrix), (s.needsTransformForDownstream = !1))
  45048. : s.booleanWasTransformed === !0 &&
  45049. (ib.multiplyMatrices(s.matrix, s.booleanMatrixInvOld),
  45050. dn.transformMeshSet(s.booleanMeshSetAddress, ib),
  45051. s.booleanMatrixInvOld.copy(s.matrix).invert(),
  45052. (s.booleanWasTransformed = !1));
  45053. this.meshSetAddresses.push(s.booleanMeshSetAddress);
  45054. }
  45055. }
  45056. if (this.meshSetAddresses.length === 0) {
  45057. this.geometry.setAttribute('position', new uE([], 0)), this.geometry.setDrawRange(0, 0);
  45058. return;
  45059. }
  45060. if (e === !0) return dn.calcBooleanTopological(this.meshSetAddresses, this.booleanOp);
  45061. let i = this.geometry;
  45062. i.dispose(), (this.geometry = new Ve()), (this.geometry.userData = i.userData), (this.geometry.boundingSphere = i.boundingSphere);
  45063. try {
  45064. this.booleanMeshSetAddress = dn.calcBoolean(this.meshSetAddresses, this.booleanOp, this.geometry, this.phongAngle);
  45065. } catch (r) {
  45066. (this.booleanMeshSetAddress = 0), console.error(r);
  45067. }
  45068. this.booleanMatrixInvOld.copy(this.matrix).invert(), (this.needsTransformForDownstream = !0), uv(this), pv(this);
  45069. }
  45070. dispose() {
  45071. super.dispose(), this.geometry.dispose();
  45072. }
  45073. },
  45074. Hm;
  45075. ((e) => {
  45076. function t(i) {
  45077. return Ct.is(i) && i instanceof Ih;
  45078. }
  45079. e.is = t;
  45080. })(Hm || (Hm = {}));
  45081. var fv = (e, t) =>
  45082. class extends Tu(e, t) {
  45083. updateState_Light(i, r) {
  45084. this.updateState_Entity(i, r),
  45085. i.color !== void 0 && (this.color = r.shared.color(i.color)),
  45086. i.intensity !== void 0 && (this.intensity = i.intensity),
  45087. i.depth !== void 0 && ((this.shadow.camera.far = i.depth), (this.shadow.needsUpdate = !0)),
  45088. i.shadows !== void 0 && (this.castShadow = i.shadows);
  45089. }
  45090. },
  45091. js = (e) => e instanceof ar,
  45092. Sn = (e) => e !== null && e instanceof Ho,
  45093. u8 = (e) => e instanceof Gi,
  45094. p8 = (e) => Hm.is(e),
  45095. f8 = (e) => Vm.is(e),
  45096. mv = class extends zh(oL) {
  45097. constructor(e, t = 15) {
  45098. super(t),
  45099. (this.object = e),
  45100. this.object.updateMatrixWorld(),
  45101. (this.name = `EmptyObjectHelper: ${e.uuid}`),
  45102. (this.matrix = e.matrixWorld),
  45103. (this.matrixAutoUpdate = !1);
  45104. }
  45105. raycast(e, t) {
  45106. Nh(this.object, mv.geometryHelper, e, t);
  45107. }
  45108. update() {}
  45109. },
  45110. Wm = class extends Tu(po, mv) {
  45111. constructor(e, t) {
  45112. super(), this.super_Entity(e, t), this.objectHelper.update();
  45113. }
  45114. updateState(e, t) {
  45115. this.updateState_Entity(e, t);
  45116. }
  45117. },
  45118. _S = class extends zh(aL) {
  45119. constructor(e, t = 15, i = 10066329) {
  45120. super(e, t, i), (this.object = e), (this.added = !1), (this.name = `DirectionalLightHelper: ${e.uuid}`);
  45121. }
  45122. raycast(e, t) {
  45123. Nh(this.object, _S.geometryHelper, e, t);
  45124. }
  45125. },
  45126. AS = class extends zh(nL) {
  45127. constructor(e, t = 15, i = 6710886) {
  45128. super(e, t, i), (this.object = e), (this.name = `PointLightHelper: ${e.uuid}`);
  45129. }
  45130. raycast(e, t) {
  45131. Nh(this.object, AS.geometryHelper, e, t);
  45132. }
  45133. },
  45134. Xm = class extends zh(sL) {
  45135. constructor(e, t = 6710886) {
  45136. super(e, t), (this.object = e), (this.name = `SpotLightHelper: ${e.uuid}`);
  45137. }
  45138. raycast(e, t) {
  45139. Nh(this.object, Xm.geometryHelper, e, t);
  45140. }
  45141. update() {
  45142. if (this.object !== void 0) {
  45143. let e = Xm._vector,
  45144. t = this.object.distance ? this.object.distance : 1e3,
  45145. i = t * Math.tan(this.object.angle);
  45146. this.cone.scale.set(i, i, t), e.setFromMatrixPosition(this.object.target.matrixWorld), this.cone.lookAt(e);
  45147. let r = this.color !== void 0 ? this.color : this.light.color;
  45148. if (this.cone.material instanceof Array)
  45149. for (let s = 0, n = this.cone.material.length; s < n; s++) this.cone.material[s].color.set(r);
  45150. else this.cone.material.color.set(r);
  45151. }
  45152. }
  45153. },
  45154. SS = Xm;
  45155. SS._vector = new E();
  45156. function m8(e, t) {
  45157. (e.shadow.camera.right = t / 2),
  45158. (e.shadow.camera.left = -t / 2),
  45159. (e.shadow.camera.top = t / 2),
  45160. (e.shadow.camera.bottom = -t / 2),
  45161. (e.shadow.needsUpdate = !0);
  45162. }
  45163. var g8 = class extends fv(WD, _S) {
  45164. constructor(e, t, i) {
  45165. super(),
  45166. this.super_Entity(e, t),
  45167. (this.castShadow = !0),
  45168. (this.shadow.mapSize.width = 2048),
  45169. (this.shadow.mapSize.height = 2048),
  45170. (this.shadow.normalBias = 1),
  45171. this.layers.enable(3);
  45172. let r = this.shadow.camera;
  45173. (r.top = 1250), (r.bottom = -1250), (r.right = 1250), (r.left = -1250), (r.near = -1e4), (r.far = 2500);
  45174. let s = new bd(this.shadow.camera);
  45175. (s.visible = !1), (this.gizmos.shadowmap = s);
  45176. }
  45177. update() {
  45178. this.shadow.camera.updateProjectionMatrix();
  45179. for (let e in this.gizmos) {
  45180. let t = this.gizmos[e];
  45181. t instanceof bd && t.update();
  45182. }
  45183. }
  45184. updateMatrixWorld(e) {
  45185. super.updateMatrixWorld(e), this.objectHelper && this.objectHelper.update();
  45186. }
  45187. updateState(e, t) {
  45188. this.updateState_Light(e, t);
  45189. let i = (e.depth !== void 0 && e.depth !== this.shadow.camera.far) || (e.size !== void 0 && e.size / 2 !== this.shadow.camera.right);
  45190. e.size !== void 0 && m8(this, e.size),
  45191. e.shadowRadius !== void 0 && (this.shadow.radius = e.shadowRadius),
  45192. e.shadowResolution !== void 0 &&
  45193. (this.shadow.mapSize.set(e.shadowResolution, e.shadowResolution),
  45194. this.shadow.map && (this.shadow.map.dispose(), (this.shadow.map = null))),
  45195. i && this.update();
  45196. }
  45197. },
  45198. v8 = class extends fv(VD, AS) {
  45199. constructor(e, t, i) {
  45200. super(),
  45201. this.super_Entity(e, t),
  45202. (this.castShadow = !0),
  45203. (this.shadow.mapSize.width = 1024),
  45204. (this.shadow.mapSize.height = 1024),
  45205. (this.shadow.normalBias = 1),
  45206. this.layers.enable(3);
  45207. let r = this.shadow.camera;
  45208. (r.fov = 90), (r.aspect = 1), (r.near = 100), (r.far = 2500);
  45209. let s = new E(-r.far + this.position.x, -r.far + this.position.y, -r.far + this.position.z),
  45210. n = new E(r.far + this.position.x, r.far + this.position.y, r.far + this.position.z),
  45211. a = new Kt(s, n),
  45212. o = new wd(a, new Ge(16755200));
  45213. (o.visible = !1), (this.gizmos.shadowmap = o), this.update();
  45214. }
  45215. update() {
  45216. if (this.shadow && (this.shadow.camera.updateProjectionMatrix(), this.gizmos))
  45217. for (let e in this.gizmos) {
  45218. let t = this.gizmos[e];
  45219. if (t instanceof wd) {
  45220. let i = this.shadow.camera,
  45221. r = new E(-i.far + this.position.x, -i.far + this.position.y, -i.far + this.position.z),
  45222. s = new E(i.far + this.position.x, i.far + this.position.y, i.far + this.position.z);
  45223. t.box.set(r, s), t.updateMatrixWorld(!0);
  45224. }
  45225. }
  45226. }
  45227. updateMatrixWorld(e) {
  45228. super.updateMatrixWorld(e), this.objectHelper && this.objectHelper.update();
  45229. }
  45230. updateState(e, t) {
  45231. this.updateState_Light(e, t),
  45232. e.distance !== void 0 && (this.distance = e.distance),
  45233. e.decay !== void 0 && (this.decay = e.decay),
  45234. e.shadowRadius !== void 0 && (this.shadow.radius = e.shadowRadius),
  45235. e.shadowResolution !== void 0 &&
  45236. (this.shadow.mapSize.set(e.shadowResolution, e.shadowResolution),
  45237. this.shadow.map && (this.shadow.map.dispose(), (this.shadow.map = null)));
  45238. }
  45239. },
  45240. sb = new E(),
  45241. nb = new E(),
  45242. ab = new ct(),
  45243. y8 = class extends fv(jD, SS) {
  45244. constructor(e, t, i) {
  45245. super(),
  45246. this.super_Entity(e, t),
  45247. (this.castShadow = !0),
  45248. (this.shadow.mapSize.width = 1024),
  45249. (this.shadow.mapSize.height = 1024),
  45250. (this.shadow.normalBias = 1),
  45251. this.layers.enable(3);
  45252. let r = this.shadow.camera;
  45253. (r.fov = it.RAD2DEG * 2 * this.angle), (r.aspect = 1), (r.near = 100), (r.far = 2500);
  45254. let s = new bd(this.shadow.camera);
  45255. (s.visible = !1), (this.gizmos.shadowmap = s), this.update();
  45256. }
  45257. update() {
  45258. this.shadow.camera.updateProjectionMatrix();
  45259. for (let e in this.gizmos) {
  45260. let t = this.gizmos[e];
  45261. t instanceof bd && t.update();
  45262. }
  45263. }
  45264. updateMatrixWorld(e) {
  45265. super.updateMatrixWorld(e),
  45266. nb.setFromMatrixPosition(this.matrixWorld),
  45267. ab.setFromRotationMatrix(this.matrixWorld),
  45268. sb.copy(this.up).applyQuaternion(ab).negate().multiplyScalar(this.distance),
  45269. this.target.position.copy(nb).add(sb),
  45270. this.target.updateMatrixWorld(),
  45271. this.objectHelper && this.objectHelper.update();
  45272. }
  45273. updateState(e, t) {
  45274. this.updateState_Light(e, t),
  45275. e.distance !== void 0 && (this.distance = e.distance),
  45276. e.decay !== void 0 && (this.decay = e.decay),
  45277. e.angle !== void 0 && (this.angle = e.angle),
  45278. e.penumbra !== void 0 && (this.penumbra = e.penumbra),
  45279. e.shadowRadius !== void 0 && (this.shadow.radius = e.shadowRadius),
  45280. e.shadowResolution !== void 0 &&
  45281. (this.shadow.mapSize.set(e.shadowResolution, e.shadowResolution),
  45282. this.shadow.map && (this.shadow.map.dispose(), (this.shadow.map = null)));
  45283. }
  45284. },
  45285. x8 = class extends Cr {
  45286. get forceComputeSize() {
  45287. return !0;
  45288. }
  45289. get shape() {
  45290. return this.geometry.userData.shape;
  45291. }
  45292. updateEntityBoxSize(e, t) {
  45293. let i = this.geometry.getAttribute('position');
  45294. i !== void 0
  45295. ? lv(i, this.geometry.drawRange.start, this.geometry.drawRange.count < 1 / 0 ? this.geometry.drawRange.count : i.count, e, t)
  45296. : super.updateEntityBoxSize(e, t);
  45297. }
  45298. },
  45299. gv = class extends Cr {
  45300. constructor(e, t, i) {
  45301. super(e, t, i), (this._shapeId = null), (this._context = i);
  45302. }
  45303. updateState(e, t) {
  45304. super.updateState(e, t), this.updateShape();
  45305. }
  45306. updateShape() {
  45307. let e = this.data.geometry.extrusion.shape,
  45308. t;
  45309. if (e.type === 'Custom') {
  45310. let r = e.shapeId;
  45311. if ((r !== this._shapeId && this.detachShape(), r)) {
  45312. this._shapeId = r;
  45313. let s = this._context.scene.find(r);
  45314. s?.data && (s.attachedPaths.add(this), (t = s.geometry.userData?.shape)),
  45315. t || this._context.scene.addPendingCommand(() => this.updateShape());
  45316. }
  45317. } else {
  45318. let r;
  45319. switch (e.type) {
  45320. case 'Rectangle':
  45321. r = PA;
  45322. break;
  45323. case 'Ellipse':
  45324. r = sv;
  45325. break;
  45326. case 'Polygon':
  45327. r = TA;
  45328. break;
  45329. case 'Star':
  45330. r = DA;
  45331. break;
  45332. default:
  45333. throw new Error(`Unknown shape type: ${e.type}`);
  45334. }
  45335. t = r.create({ parameters: e }).userData.shape;
  45336. }
  45337. let i = this.geometry;
  45338. t && i.inputs && ((i.inputs.shapeData = t), i.build(), this.attachedSurfaceCloners.forEach((r) => r.update()));
  45339. }
  45340. detachShape() {
  45341. this._shapeId !== null && this._context.scene.find(this._shapeId)?.attachedPaths.delete(this);
  45342. }
  45343. createGeometryDelayed(e) {
  45344. (this.geometryCreateDeleyed = e.shared), this.updateShape(), this.refreshAttachedPaths(e);
  45345. }
  45346. updateTransformState(e) {
  45347. return super.updateTransformState(e);
  45348. }
  45349. updateGeometryInteractions(e, t) {
  45350. super.updateGeometryInteractions(e, t), this.updateShape();
  45351. }
  45352. updateEntityBoxSize(e, t) {
  45353. let i = this.geometry.getAttribute('position');
  45354. i !== void 0
  45355. ? lv(i, this.geometry.drawRange.start, this.geometry.drawRange.count < 1 / 0 ? this.geometry.drawRange.count : i.count, e, t)
  45356. : super.updateEntityBoxSize(e, t);
  45357. }
  45358. },
  45359. Ro = class extends Tu(po, mv) {
  45360. constructor(e, t, i) {
  45361. super(),
  45362. t.type === 'Instance' && typeof e == 'string' && (t = this.transformAssignData(t, i)),
  45363. this.super_Entity(e, t),
  45364. this.objectHelper.update();
  45365. }
  45366. get isComponentRoot() {
  45367. return this.data.type === 'Component' && typeof this.identity == 'string';
  45368. }
  45369. get isInstanceRoot() {
  45370. return this.data.type === 'Instance' && typeof this.identity == 'string';
  45371. }
  45372. transformAssignData(e, t) {
  45373. let i = t.scene.data.objects.get(e.component);
  45374. if (i) {
  45375. let r, s;
  45376. for (let n of Go.rootOverrideProps)
  45377. e[n] === void 0 ? (r === void 0 && (r = { ...e }), (r[n] = i.data[n])) : (s === void 0 && (s = {}), (s[n] = e[n]));
  45378. return (this.overrideData = s), r ?? e;
  45379. }
  45380. return e;
  45381. }
  45382. updateByOp(e, t, i, r) {
  45383. let s;
  45384. if (this.isInstanceRoot && !r && ((t = this.transformAssignData(t, i)), e.type === 0 && e.path.length === 0 && this.component))
  45385. for (let n of Go.rootOverrideProps)
  45386. n in e.props &&
  45387. e.props[n] === void 0 &&
  45388. (s === void 0 && (s = { ...e, props: { ...e.props } }), (s.props[n] = this.component.data[n]));
  45389. super.updateByOp(s ?? e, t, i, r);
  45390. }
  45391. updateState(e, t) {
  45392. this.updateState_Entity(e, t);
  45393. }
  45394. expandInstanceChildren(e) {
  45395. let t = this.data;
  45396. if (this.component === void 0) {
  45397. this.component = e.scene.find(t.component) ?? null;
  45398. let i = !1;
  45399. if (this.component !== this.oldComponent) {
  45400. if (this.oldComponent) {
  45401. let r = 0;
  45402. for (let s of this.children)
  45403. if (Ct.is(s)) e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s), vv(s), (r += 1);
  45404. else break;
  45405. this.children.splice(0, r);
  45406. }
  45407. i = !0;
  45408. }
  45409. this.component && MS(e, [this.uuid], t.overrides, this, this.component, this.component, 0, i), (this.oldComponent = this.component);
  45410. }
  45411. }
  45412. };
  45413. function vv(e) {
  45414. if (e.component) {
  45415. let t = e.component.instances.indexOf(e);
  45416. t >= 0 && e.component.instances.splice(t, 1);
  45417. for (let i of e.children) Ct.is(i) && vv(i);
  45418. }
  45419. }
  45420. function ob(e, t, i, r) {
  45421. return e.component === t && jg(e.identity, r) ? (e.overrideData === i ? 2 : 1) : 0;
  45422. }
  45423. function MS(e, t, i, r, s, n, a, o) {
  45424. if (a > 50) return !1;
  45425. if (r.component !== s) {
  45426. if (r.component) {
  45427. let h = r.component.instances.indexOf(r);
  45428. h >= 0 && r.component.instances.splice(h, 1);
  45429. }
  45430. s.instances.push(r), (r.component = s);
  45431. }
  45432. s instanceof Ro && s.isInstanceRoot && s.expandInstanceChildren(e);
  45433. let l = 0;
  45434. for (let h of s.children)
  45435. if (Ct.is(h)) {
  45436. let u = [...t, ...(typeof h.identity == 'string' ? [h.identity] : h.identity)],
  45437. c = Fd.resolve(i, u, 1),
  45438. d = null,
  45439. p;
  45440. if (!o) {
  45441. let f = r.children[l];
  45442. if (((d = Ct.is(f) ? f : null), d !== null)) {
  45443. let g = ob(d, h, c, u);
  45444. (p = g >= 1 ? d.stateSelection : void 0), g !== 2 && (d = null);
  45445. }
  45446. if (d === null && ((d = e.scene.findInstance(u) ?? null), d !== null)) {
  45447. let g = ob(d, h, c, u);
  45448. if (((p = g >= 1 ? d.stateSelection : void 0), g !== 2)) d = null;
  45449. else {
  45450. let m = d.parent.children.indexOf(d);
  45451. d.parent.children.splice(m, 1),
  45452. r.children.splice(l, 0, d),
  45453. d.parent === r
  45454. ? m <= l && console.error('not possible')
  45455. : ((d.parent = r),
  45456. (d.matrixWorldNeedsUpdate = !0),
  45457. d.resetBBoxNeedsUpdate(),
  45458. d.updateVisible(),
  45459. e.pendingDeletes.delete(d));
  45460. }
  45461. }
  45462. }
  45463. if (d === null) {
  45464. let f = c ? fa.apply(h.data, c) : h.data;
  45465. _a.is(f.type) && (f = { ...f, type: 'Empty' }),
  45466. (d = wn.createEntity(u, f, e)),
  45467. (d.overrideData = c),
  45468. r.add(d),
  45469. r.children.splice(r.children.length - 1, 1),
  45470. r.children.splice(l, 0, d),
  45471. d.updateState(d.data, e),
  45472. p && d.changeSelectedState(p, e),
  45473. e.scene.registerInstanceAndSetUuid(d);
  45474. }
  45475. (l += 1), MS(e, t, i, d, h, n, a + 1, o);
  45476. }
  45477. if (!o) {
  45478. let h = l;
  45479. for (;;) {
  45480. let u = r.children[l];
  45481. if (Ct.is(u)) e.pendingDeletes.add(u);
  45482. else break;
  45483. l += 1;
  45484. }
  45485. r.children.splice(h, l - h);
  45486. }
  45487. return !0;
  45488. }
  45489. function b8(e, t, i) {
  45490. let r;
  45491. return t.geometry.type === 'TextGeometry'
  45492. ? new yS(e, t, i)
  45493. : (t.geometry.type === 'SubdivGeometry'
  45494. ? (r = new Sh(e, t, i))
  45495. : t.geometry.type === 'PathGeometry'
  45496. ? (r = new gv(e, t, i))
  45497. : t.geometry.type === 'VectorGeometry'
  45498. ? (r = new x8(e, t, i))
  45499. : t.geometry.type === 'BooleanGeometry'
  45500. ? (r = new Ho(e, t, i))
  45501. : (r = new Cr(e, t, i)),
  45502. r);
  45503. }
  45504. function yv(e, t, i) {
  45505. return t.type === 'Mesh'
  45506. ? b8(e, t, i)
  45507. : t.type === 'Empty'
  45508. ? new Wm(e, t)
  45509. : t.type === 'PointLight'
  45510. ? new v8(e, t, i)
  45511. : t.type === 'SpotLight'
  45512. ? new y8(e, t, i)
  45513. : t.type === 'DirectionalLight'
  45514. ? new g8(e, t, i)
  45515. : t.type === 'Component' || t.type === 'Instance'
  45516. ? new Ro(e, t, i)
  45517. : _a.is(t.type)
  45518. ? new Gi(e, t)
  45519. : (console.error(t), new Wm(e, t));
  45520. }
  45521. wn.createEntity = yv;
  45522. function w8(e, t, i) {
  45523. let r = yv(e.identity, t, i),
  45524. s = e.children,
  45525. n = e.attachedPaths,
  45526. a = e.parent,
  45527. o = e.component,
  45528. l = e.instances,
  45529. h = e.overrideData,
  45530. u = e.uuid,
  45531. c = e.stateSelection;
  45532. e.dispose();
  45533. for (let d of Object.keys(e)) delete e[d];
  45534. Object.setPrototypeOf(e, Object.getPrototypeOf(r));
  45535. for (let d of Object.keys(r)) e[d] = r[d];
  45536. (e.children = [...e.children, ...s]),
  45537. (e.attachedPaths = n),
  45538. (e.parent = a),
  45539. (e.component = o),
  45540. (e.instances = l),
  45541. (e.uuid = u),
  45542. (e.overrideData = h),
  45543. e.updateState(e.data, i),
  45544. c && e.changeSelectedState(c, i),
  45545. e.resetBBoxNeedsUpdate();
  45546. }
  45547. wn.changeEntityProptotype = w8;
  45548. wn.Cloner = eu;
  45549. function _8(e, t, i, r) {
  45550. e.updateByOp(t, i, r, !1);
  45551. }
  45552. function lb(e, t) {
  45553. let i = !1,
  45554. r = t.getLayersOfType('transmission'),
  45555. s = t.getLayersOfType('outline');
  45556. return (
  45557. s.length > 0 && (e.layers.set(8), r.length > 0 && e.layers.enable(3), (i = !0), pv(e), uv(e)),
  45558. r.length === 0 && s.length === 0 && e.layers.set(0),
  45559. i
  45560. );
  45561. }
  45562. function hb(e, t) {
  45563. if (!t.layers) return !1;
  45564. let i = !1,
  45565. r = t.getLayersOfType('transmission').filter((n) => n.data.visible),
  45566. s = t.getLayersOfType('outline').filter((n) => n.data.visible);
  45567. return (
  45568. r.length > 0 && (e.layers.set(3), s.length > 0 && e.layers.enable(8), (i = !0)), r.length === 0 && s.length === 0 && e.layers.set(0), i
  45569. );
  45570. }
  45571. function A8(e) {
  45572. let t = !1;
  45573. return (
  45574. e.traverseEntity((i) => {
  45575. if (i instanceof Cu)
  45576. if (Array.isArray(i.material)) for (let r = 0; r < i.material.length; r++) lb(i, i.material[r]) && (t = !0);
  45577. else lb(i, i.material) && (t = !0);
  45578. }),
  45579. t
  45580. );
  45581. }
  45582. function S8(e) {
  45583. let t = !1;
  45584. return (
  45585. e.traverseEntity((i) => {
  45586. if (i instanceof Cu)
  45587. if (Array.isArray(i.material)) for (let r = 0; r < i.material.length; r++) hb(i, i.material[r]) && (t = !0);
  45588. else hb(i, i.material) && (t = !0);
  45589. }),
  45590. t
  45591. );
  45592. }
  45593. var M8 = new kw(),
  45594. E8 = new ve(),
  45595. C8 = new Xo();
  45596. function T8(e, t, i) {
  45597. let r = e.cloner;
  45598. if (r)
  45599. for (let s of r.children) {
  45600. let n = E8.copy(s.matrixWorld).invert(),
  45601. a = C8.copy(t.ray).applyMatrix4(n),
  45602. o = e.matrixWorld;
  45603. a.applyMatrix4(o);
  45604. let l = M8;
  45605. l.set(a.origin, a.direction), (l.near = t.near), (l.far = t.far), l.intersectObject(e, !1).length > 0 && i.push({ object: e });
  45606. }
  45607. }
  45608. var P8 = (e) => `
  45609. // PCSS implementation based on:
  45610. // https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
  45611. // NOTE: This number affects how big the shadow blur can
  45612. // possibly get. Bigger number == bigger blur, but less precise results
  45613. const float gPenumbraFilterSize = 80.0;
  45614. const int gPenumbraSamples = ${e};
  45615. const int gShadowSamples = ${e};
  45616. const float gShadowSamplesRpc = 1.0f / float(gShadowSamples);
  45617. vec2 vogelDiskSample(int sample_index, int sample_count, float angle)
  45618. {
  45619. const float goldenAngle = 2.399963f; // radians
  45620. float r = sqrt(float(sample_index) + 0.5f) / sqrt(float(sample_count));
  45621. float theta = float(sample_index) * goldenAngle + angle;
  45622. float sine = sin(theta);
  45623. float cosine = cos(theta);
  45624. return vec2(cosine, sine) * r;
  45625. }
  45626. // NOTE: For now we aren't using this screen-space noise. But we should enable
  45627. // it again once we do some sort of temporal AA. Then we could potentially lower
  45628. // the number of samples needed and still get a pretty smooth result.
  45629. // Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso
  45630. float getNoiseInterleavedGradient(vec2 screenPos)
  45631. {
  45632. vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);
  45633. return fract(magic.z * fract(dot(screenPos, magic.xy)));
  45634. }
  45635. #ifdef USE_SHADOWMAP
  45636. #if NUM_DIR_LIGHT_SHADOWS > 0
  45637. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  45638. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  45639. struct DirectionalLightShadow {
  45640. float shadowBias;
  45641. float shadowNormalBias;
  45642. float shadowRadius;
  45643. vec2 shadowMapSize;
  45644. };
  45645. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  45646. #endif
  45647. #if NUM_SPOT_LIGHT_SHADOWS > 0
  45648. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  45649. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_SHADOWS ];
  45650. struct SpotLightShadow {
  45651. float shadowBias;
  45652. float shadowNormalBias;
  45653. float shadowRadius;
  45654. vec2 shadowMapSize;
  45655. };
  45656. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  45657. #endif
  45658. #if NUM_POINT_LIGHT_SHADOWS > 0
  45659. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  45660. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  45661. struct PointLightShadow {
  45662. float shadowBias;
  45663. float shadowNormalBias;
  45664. float shadowRadius;
  45665. vec2 shadowMapSize;
  45666. float shadowCameraNear;
  45667. float shadowCameraFar;
  45668. };
  45669. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  45670. #endif
  45671. /*
  45672. #if NUM_RECT_AREA_LIGHTS > 0
  45673. // TODO (abelnation): create uniforms for area light shadows
  45674. #endif
  45675. */
  45676. float computePenumbra(int index, sampler2D shadowMap, float temporalAngle, float texelSize, vec2 uv, float compare, float texelScalar, float shadowRadius)
  45677. {
  45678. float penumbra = 1.0;
  45679. float blockerDepthAvg = 0.0;
  45680. float blockerCount = 0.0;
  45681. #pragma unroll_loop_start
  45682. for(int i = 0; i < gPenumbraSamples; i ++)
  45683. {
  45684. vec2 offset = (vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize) * texelScalar;
  45685. float depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) );
  45686. if(depth < compare + 0.0001)
  45687. {
  45688. blockerDepthAvg += depth;
  45689. blockerCount++;
  45690. }
  45691. }
  45692. #pragma unroll_loop_end
  45693. if (blockerCount > 0.0)
  45694. {
  45695. blockerDepthAvg /= blockerCount;
  45696. // Compute penumbra
  45697. penumbra = (compare - blockerDepthAvg) / (blockerDepthAvg);
  45698. penumbra *= penumbra;
  45699. penumbra *= 200.0 * penumbraSize[min(index, ${5} - 1)]; // Magic number that affects how quickly the penumbra grows
  45700. return clamp(penumbra, 0.00, 1.0);
  45701. }
  45702. return 0.0;
  45703. }
  45704. vec4 shadowmod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}
  45705. vec4 shadowperm(vec4 x){return shadowmod289(((x * 34.0) + 1.0) * x);}
  45706. float shadowNoise(vec3 p){
  45707. vec3 a = floor(p);
  45708. vec3 d = p - a;
  45709. d = d * d * (3.0 - 2.0 * d);
  45710. vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);
  45711. vec4 k1 = shadowperm(b.xyxy);
  45712. vec4 k2 = shadowperm(k1.xyxy + b.zzww);
  45713. vec4 c = k2 + a.zzzz;
  45714. vec4 k3 = shadowperm(c);
  45715. vec4 k4 = shadowperm(c + 1.0);
  45716. vec4 o1 = fract(k3 * (1.0 / 41.0));
  45717. vec4 o2 = fract(k4 * (1.0 / 41.0));
  45718. vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
  45719. vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
  45720. return o4.y * d.y + o4.x * (1.0 - d.y);
  45721. }
  45722. float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, float compare, float shadowRadius)
  45723. {
  45724. float shadow = 0.0f;
  45725. float temporalOffset = shadowNoise(floor(vWPosition * 10.));
  45726. // NOTE: When using TAA, we should use screen space interleaved gradient noise
  45727. //float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy);
  45728. float temporalAngle = temporalOffset * PI2;
  45729. float texelScalar = (gPenumbraFilterSize) / (texelSize * 1024.);
  45730. float penumbra = computePenumbra(index, shadowMap, temporalAngle, texelSize, uv, compare, texelScalar, shadowRadius);
  45731. if (penumbra == -1.0) {
  45732. return 1.0;
  45733. }
  45734. #pragma unroll_loop_start
  45735. for (int i = 0; i < gShadowSamples; i++)
  45736. {
  45737. vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
  45738. // Overall blurring offset
  45739. vec2 offset = vogelSample * (shadowRadius * 2.);
  45740. // Penumbra offset
  45741. offset += vogelSample * (penumbra * texelScalar);
  45742. shadow += step( compare, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );
  45743. }
  45744. #pragma unroll_loop_end
  45745. return shadow * gShadowSamplesRpc;
  45746. }
  45747. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  45748. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  45749. }
  45750. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  45751. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  45752. }
  45753. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  45754. float occlusion = 1.0;
  45755. vec2 distribution = texture2DDistribution( shadow, uv );
  45756. float hard_shadow = step( compare , distribution.x ); // Hard Shadow
  45757. if (hard_shadow != 1.0 ) {
  45758. float distance = compare - distribution.x ;
  45759. float variance = max( 0.00000, distribution.y * distribution.y );
  45760. float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality
  45761. softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed
  45762. occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
  45763. }
  45764. return occlusion;
  45765. }
  45766. float getShadow( int i, sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  45767. float shadow = 1.0;
  45768. shadowCoord.xyz /= shadowCoord.w;
  45769. shadowCoord.z += shadowBias;
  45770. // if ( something && something ) breaks ATI OpenGL shader compiler
  45771. // if ( all( something, something ) ) using this instead
  45772. bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
  45773. bool inFrustum = all( inFrustumVec );
  45774. bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
  45775. bool frustumTest = all( frustumTestVec );
  45776. if ( frustumTest ) {
  45777. #if defined( SHADOWMAP_TYPE_PCF )
  45778. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  45779. return vogelShadow(i, shadowMap, shadowCoord.xy, texelSize.x, shadowCoord.z, shadowRadius );
  45780. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  45781. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  45782. float dx = texelSize.x;
  45783. float dy = texelSize.y;
  45784. vec2 uv = shadowCoord.xy;
  45785. vec2 f = fract( uv * shadowMapSize + 0.5 );
  45786. uv -= f * texelSize;
  45787. shadow = (
  45788. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  45789. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  45790. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  45791. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  45792. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  45793. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  45794. f.x ) +
  45795. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  45796. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  45797. f.x ) +
  45798. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  45799. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  45800. f.y ) +
  45801. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  45802. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  45803. f.y ) +
  45804. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  45805. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  45806. f.x ),
  45807. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  45808. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  45809. f.x ),
  45810. f.y )
  45811. ) * ( 1.0 / 9.0 );
  45812. #elif defined( SHADOWMAP_TYPE_VSM )
  45813. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  45814. #else // no percentage-closer filtering:
  45815. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  45816. #endif
  45817. }
  45818. return shadow;
  45819. }
  45820. // cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D
  45821. // vector suitable for 2D texture mapping. This code uses the following layout for the
  45822. // 2D texture:
  45823. //
  45824. // xzXZ
  45825. // y Y
  45826. //
  45827. // Y - Positive y direction
  45828. // y - Negative y direction
  45829. // X - Positive x direction
  45830. // x - Negative x direction
  45831. // Z - Positive z direction
  45832. // z - Negative z direction
  45833. //
  45834. // Source and test bed:
  45835. // https://gist.github.com/tschw/da10c43c467ce8afd0c4
  45836. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  45837. // Number of texels to avoid at the edge of each square
  45838. vec3 absV = abs( v );
  45839. // Intersect unit cube
  45840. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  45841. absV *= scaleToCube;
  45842. // Apply scale to avoid seams
  45843. // two texels less per square (one texel will do for NEAREST)
  45844. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  45845. // Unwrap
  45846. // space: -1 ... 1 range for each square
  45847. //
  45848. // #X## dim := ( 4 , 2 )
  45849. // # # center := ( 1 , 1 )
  45850. vec2 planar = v.xy;
  45851. float almostATexel = 1.5 * texelSizeY;
  45852. float almostOne = 1.0 - almostATexel;
  45853. if ( absV.z >= almostOne ) {
  45854. if ( v.z > 0.0 )
  45855. planar.x = 4.0 - v.x;
  45856. } else if ( absV.x >= almostOne ) {
  45857. float signX = sign( v.x );
  45858. planar.x = v.z * signX + 2.0 * signX;
  45859. } else if ( absV.y >= almostOne ) {
  45860. float signY = sign( v.y );
  45861. planar.x = v.x + 2.0 * signY + 2.0;
  45862. planar.y = v.z * signY - 2.0;
  45863. }
  45864. // Transform to UV space
  45865. // scale := 0.5 / dim
  45866. // translate := ( center + 0.5 ) / dim
  45867. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  45868. }
  45869. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  45870. float shadow = 1.0;
  45871. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  45872. // for point lights, the uniform @vShadowCoord is re-purposed to hold
  45873. // the vector from the light to the world-space position of the fragment.
  45874. vec3 lightToPosition = shadowCoord.xyz;
  45875. // dp = normalized distance from light to fragment position
  45876. float compare = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?
  45877. compare += shadowBias;
  45878. // bd3D = base direction 3D
  45879. vec3 bd3D = normalize( lightToPosition );
  45880. float temporalOffset = shadowNoise(floor(vWPosition * 10.));
  45881. float temporalAngle = temporalOffset * PI2;
  45882. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_VSM )
  45883. for (int i = 0; i < gShadowSamples; i++) {
  45884. vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
  45885. // Overall blurring offset
  45886. vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);
  45887. // NOTE: Removed for now
  45888. // Penumbra offset
  45889. //offset += vec3(vogelSample.x, vogelSample.y, vogelSample.y) * (penumbra * gPenumbraFilterSize);
  45890. shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );
  45891. }
  45892. return shadow * gShadowSamplesRpc;
  45893. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  45894. for (int i = 0; i < 16; i++) {
  45895. vec2 vogelSample = vogelDiskSample(i, gShadowSamples, temporalAngle) * texelSize;
  45896. // Overall blurring offset
  45897. vec3 offset = vec3(vogelSample.x, vogelSample.y, -vogelSample.x) * (shadowRadius + 5.);
  45898. shadow += texture2DCompare( shadowMap, cubeToUV( bd3D + offset, texelSize.y ), compare );
  45899. }
  45900. return shadow * (1.0 / 16.0);
  45901. #else // no percentage-closer filtering
  45902. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), compare );
  45903. #endif
  45904. }
  45905. #endif
  45906. `,
  45907. D8 = Ze.lights_fragment_begin,
  45908. L8 = Ze.shadowmask_pars_fragment,
  45909. cb = !1,
  45910. O8 = (e) => {
  45911. switch (e) {
  45912. case 'low':
  45913. return 8;
  45914. case 'medium':
  45915. return 16;
  45916. case 'high':
  45917. return 32;
  45918. default:
  45919. return 16;
  45920. }
  45921. },
  45922. I8 = (e = 'medium') => {
  45923. if (cb) return;
  45924. cb = !0;
  45925. let t = O8(e);
  45926. Ze.shadowmap_pars_fragment = P8(t);
  45927. let i = D8.slice();
  45928. (i = i.replace('getShadow( spotShadowMap[ i ]', `getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`)),
  45929. (i = i.replace('getShadow( directionalShadowMap[ i ]', 'getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]')),
  45930. (Ze.lights_fragment_begin = i);
  45931. let r = L8.slice();
  45932. (r = r.replaceAll('getShadow(', 'getShadow( UNROLLED_LOOP_INDEX, ')), (Ze.shadowmask_pars_fragment = r);
  45933. },
  45934. R8 = `
  45935. attribute vec3 randomColor;
  45936. varying vec3 vNormal;
  45937. flat out vec3 vColor;
  45938. void main()
  45939. {
  45940. vNormal = normal;
  45941. vColor = randomColor;
  45942. gl_Position = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
  45943. }
  45944. `,
  45945. B8 = `
  45946. uniform float depthContrast;
  45947. varying vec3 vNormal;
  45948. flat in vec3 vColor;
  45949. void main()
  45950. {
  45951. vec3 normal = (normalize(vNormal)).rgb;
  45952. float contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5;
  45953. vec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4);
  45954. gl_FragColor = vec4(resultColor, vColor.r);
  45955. }
  45956. `,
  45957. ff = new ri({ vertexShader: R8, fragmentShader: B8, uniforms: { depthContrast: { value: 1 } } }),
  45958. z8 = class {
  45959. constructor() {
  45960. this._constraints = new Map();
  45961. }
  45962. setConstraint(e, t) {
  45963. t === null ? this._constraints.delete(e) : this._constraints.set(e, t);
  45964. }
  45965. removeDependencies(e) {
  45966. this._constraints.delete(e);
  45967. }
  45968. applyConstraints(e) {
  45969. let t = new Set();
  45970. this._constraints.forEach((i, r) => {
  45971. let s = [r, i],
  45972. n = i;
  45973. for (; this._constraints.has(n); ) (n = this._constraints.get(n)), t.has(n) || s.push(n);
  45974. for (let a = s.length - 2; a >= 0; a--)
  45975. if (!t.has(s[a])) {
  45976. let o = e.find(s[a]);
  45977. o ? o.applyPathSnapping(e) : console.warn(`missing entity ${s[a]}`), t.add(s[a]);
  45978. }
  45979. });
  45980. }
  45981. findDependency(e, t) {
  45982. let i = e;
  45983. for (; this._constraints.has(i); ) if (((i = this._constraints.get(i)), i === t)) return !0;
  45984. return !1;
  45985. }
  45986. },
  45987. qm = new Ph();
  45988. qm.wireframe = !0;
  45989. var db = new E(),
  45990. ES = class extends pa {
  45991. constructor(e, t) {
  45992. super(),
  45993. (this.data = e),
  45994. (this.backupFog = new Mw(16777215, 0.1, 2e3)),
  45995. (this.fogUseBGColor = !1),
  45996. (this.enableHelpers = !1),
  45997. (this.wireframeState = !1),
  45998. (this.needsTransmissionDirty = !0),
  45999. (this.needsNormalDirty = !0),
  46000. (this._needsTransmission = !1),
  46001. (this._needsNormal = !1),
  46002. (this.geometryCacheChanged = !1),
  46003. (this.bgColor = new ji(1, 1, 1, 1)),
  46004. (this.entityByUuid = {}),
  46005. (this.entityIdentityToEntity = {}),
  46006. (this.toExpandCloner = new Set()),
  46007. (this.toUpdateCloner = new Set()),
  46008. (this.pendingCommands = []),
  46009. (this.pathConstraints = new z8()),
  46010. (this.needsRecomputeInstances = !1),
  46011. (this.ambientLight = new FD(13882323, 8553090, 0.75)),
  46012. (this.ambientLight.name = 'Default Ambient Light'),
  46013. this.ambientLight.layers.enable(3),
  46014. (this.personalCamera = this.createPersonalCamera()),
  46015. (this.activeCamera = this.personalCamera),
  46016. (this.postprocessing = e.postprocessing),
  46017. this.init(e, t),
  46018. (this.matrixAutoUpdate = !1);
  46019. }
  46020. markGeometryCacheDirty() {
  46021. this.geometryCacheChanged = !0;
  46022. }
  46023. markNeedsUpdateRendererDirty() {
  46024. (this.needsTransmissionDirty = !0), (this.needsNormalDirty = !0);
  46025. }
  46026. needsTransmission() {
  46027. return (
  46028. this.needsTransmissionDirty && ((this._needsTransmission = S8(this)), (this.needsTransmissionDirty = !1)), this._needsTransmission
  46029. );
  46030. }
  46031. needsNormal() {
  46032. return this.needsNormalDirty && ((this._needsNormal = A8(this)), (this.needsNormalDirty = !1)), this._needsNormal;
  46033. }
  46034. registerInstanceAndSetUuid(e) {
  46035. let t = e.identity.join('-'),
  46036. i = this.entityIdentityToEntity[t];
  46037. i && (e.uuid = i.uuid), (this.entityIdentityToEntity[t] = e), (this.entityByUuid[e.uuid] = e);
  46038. }
  46039. findInstance(e) {
  46040. return this.entityIdentityToEntity[e.join('-')];
  46041. }
  46042. getWithSortKey(e) {
  46043. let t = this.find(e);
  46044. if (t === void 0) return;
  46045. let i = [],
  46046. r = t;
  46047. for (; r !== this; ) {
  46048. let s = r;
  46049. r = r.parent;
  46050. let n = r.children.indexOf(s);
  46051. i.splice(0, 0, n);
  46052. }
  46053. return { entity: t, sortKey: i };
  46054. }
  46055. getAllSorted(e) {
  46056. let t = [];
  46057. for (let i of e) {
  46058. let r = this.getWithSortKey(i.id);
  46059. r !== void 0 && t.push(r);
  46060. }
  46061. return t.sort((i, r) => eU(i.sortKey, r.sortKey)), t.map((i) => i.entity);
  46062. }
  46063. nonExistOrDescendantOf(e, t) {
  46064. let i = this.find(e);
  46065. if (i === void 0) return !0;
  46066. for (; i; ) {
  46067. if (i.uuid === t) return !0;
  46068. i = i.parent;
  46069. }
  46070. return !1;
  46071. }
  46072. find(e) {
  46073. if (e === '' || e === void 0) return;
  46074. let t = this.entityByUuid[e];
  46075. return t === void 0 ? this.getObjectByProperty('uuid', e) : t;
  46076. }
  46077. debugEnsureEntity(e) {
  46078. let t = this.find(e);
  46079. if (t) {
  46080. if (Array.isArray(t.identity) && this.findInstance(t.identity) === void 0) {
  46081. console.error('not found instance');
  46082. debugger;
  46083. }
  46084. } else {
  46085. console.error('not found');
  46086. debugger;
  46087. }
  46088. }
  46089. addPendingExpandCloner(e) {
  46090. this.toExpandCloner.add(e);
  46091. }
  46092. addPendingUpdateCloner(e) {
  46093. this.toUpdateCloner.add(e);
  46094. }
  46095. markToExpandCloner(e) {
  46096. this.toExpandCloner.add(e),
  46097. e.traverseEntityAncestors((t) => {
  46098. this.toExpandCloner.add(t);
  46099. });
  46100. }
  46101. doPendingExpandCloner() {
  46102. this.toExpandCloner.forEach((e) => {
  46103. e.expandCloner(this);
  46104. }),
  46105. this.toExpandCloner.clear();
  46106. }
  46107. doPendingUpdateCloner() {
  46108. this.toUpdateCloner.forEach((e) => {
  46109. e.cloner?.update();
  46110. }),
  46111. this.toUpdateCloner.clear();
  46112. }
  46113. doPendingUpdates() {
  46114. this.doPendingExpandCloner(), this.doPendingUpdateCloner(), this.applyPendingCommands();
  46115. }
  46116. addPendingCommand(e) {
  46117. this.pendingCommands.push(e);
  46118. }
  46119. applyPendingCommands() {
  46120. this.pendingCommands.forEach((e) => e()), (this.pendingCommands.length = 0);
  46121. }
  46122. updateTreeByOp(e, t) {
  46123. if (e.path.length === 0 && e.type === 7) {
  46124. let i = e.parent === null ? this : this.find(e.parent);
  46125. if (i === void 0) throw new Error('unexpected');
  46126. let r = this.createObject(e.id, e.data, e.children, i, e.localIndex, t);
  46127. r.updateVisible(),
  46128. r.resetBBoxNeedsUpdate(),
  46129. js(r) && Sn(r.parent) && (r.invalidateUpstreamBooleanData(), r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),
  46130. this.markNeedsRecomputeInstancesForAncessors(i),
  46131. this.markNeedsRecomputeInstancesForChildren(r),
  46132. this.markToExpandCloner(r);
  46133. } else if (e.path.length === 0 && e.type === 8) {
  46134. let i = this.find(e.id);
  46135. if (i === void 0) throw new Error('unexpected');
  46136. this.markToExpandCloner(i), i.resetBBoxNeedsUpdate(), this.unregisterObject(i);
  46137. let r = i.parent;
  46138. this.markNeedsRecomputeInstancesForAncessors(r),
  46139. this.markNeedsRecomputeInstancesForChildren(i),
  46140. i.parent.remove(i),
  46141. Sn(i.parent) && (i.parent.invalidateUpstreamBooleanData(), i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),
  46142. js(i) && (i.freeBooleanPointer(), r instanceof Ho && r.invalidateDownstreamBooleanData().recomputeBoolean()),
  46143. i instanceof gv && i.detachShape(),
  46144. this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),
  46145. this.pathConstraints.removeDependencies(i.uuid);
  46146. } else if (e.path.length === 0 && e.type === 9) {
  46147. let i = this.find(e.id);
  46148. if (i === void 0) throw new Error('unexpected');
  46149. this.markNeedsRecomputeInstancesForChildren(i);
  46150. let r = i.parent;
  46151. this.markNeedsRecomputeInstancesForAncessors(r), i.cloner?.resetOnMove(), this.markToExpandCloner(i);
  46152. let s = e.parent === null ? this : this.find(e.parent);
  46153. if (s === void 0) throw new Error('unexpected');
  46154. s.add(i),
  46155. this.markNeedsRecomputeInstancesForAncessors(s),
  46156. this.markToExpandCloner(i),
  46157. i.invalidateClonerTransform(i),
  46158. i.updateVisible(),
  46159. i.resetBBoxNeedsUpdate();
  46160. let n = e.localIndex;
  46161. s.children.splice(n, 0, s.children.pop()),
  46162. js(i) &&
  46163. (i.invalidateUpstreamBooleanData(),
  46164. Sn(i.parent)
  46165. ? i.parent.invalidateDownstreamBooleanData().recomputeBoolean()
  46166. : r instanceof Ho && r.invalidateDownstreamBooleanData().recomputeBoolean());
  46167. }
  46168. this.markNeedsUpdateRendererDirty(), this.markGeometryCacheDirty();
  46169. }
  46170. updateEntityByOp(e, t, i, r) {
  46171. if (t.type === 0) {
  46172. if (
  46173. (('overrides' in t.props || 'component' in t.props) && this.markNeedsRecomputeInstances(),
  46174. t.path.includes('overrides') && 'states' in t.props)
  46175. ) {
  46176. let { states: n, rest: a } = t.props;
  46177. (t = { ...t, props: a }), this.markNeedsRecomputeInstances();
  46178. }
  46179. t.path[0] === 'pathSnapping' && t.props.pathId !== void 0 && this.pathConstraints.setConstraint(e, t.props.pathId);
  46180. }
  46181. let s = this.find(e);
  46182. if (s)
  46183. try {
  46184. _8(s, t, i, { scene: this, shared: r }), s instanceof Cr && s.updateGeometryGroupsIfNeeded();
  46185. } catch (n) {
  46186. console.error(n);
  46187. }
  46188. }
  46189. get enableFog() {
  46190. return this.fog !== null;
  46191. }
  46192. set enableFog(e) {
  46193. this.fog = e === !0 ? this.backupFog : null;
  46194. }
  46195. init(e, t) {
  46196. if (
  46197. (this.createChildrenObjects(e.objects, this, t),
  46198. this.personalCamera.removeFromParent(),
  46199. this.add(this.personalCamera),
  46200. this.ambientLight.removeFromParent(),
  46201. this.add(this.ambientLight),
  46202. this.setBackgroundColor(sr(e.backgroundColor, t)),
  46203. this.updateFog(e.fog, t),
  46204. this.updateAmbientLight(e.environment.ambientLight, t),
  46205. (this.activeCamera = this.personalCamera),
  46206. e.publish.playCamera !== null)
  46207. ) {
  46208. let i = this.find(e.publish.playCamera);
  46209. i instanceof Gi && this.switchActiveCamera(i);
  46210. }
  46211. this.expandInstances(t, !0),
  46212. this.traverseEntity((i) => {
  46213. Sn(i) && i.recomputeBoolean(), i instanceof Gi && i.updateUp();
  46214. }),
  46215. this.doPendingExpandCloner(),
  46216. this.applyPendingCommands();
  46217. }
  46218. markNeedsRecomputeInstances() {
  46219. this.needsRecomputeInstances = !0;
  46220. }
  46221. markNeedsRecomputeInstancesForChildren(e) {
  46222. e.traverseEntity((t) => {
  46223. (t.data.type === 'Component' || t.data.type === 'Instance') && this.markNeedsRecomputeInstances();
  46224. });
  46225. }
  46226. markNeedsRecomputeInstancesForAncessors(e) {
  46227. Ct.is(e) &&
  46228. (e.data.type === 'Component' && this.markNeedsRecomputeInstances(),
  46229. e.traverseAncestors((t) => {
  46230. Ct.is(t) && t.data.type === 'Component' && this.markNeedsRecomputeInstances();
  46231. }));
  46232. }
  46233. relativeizeInner(e, t, i, r, s, n, a) {
  46234. e &&
  46235. e !== r.uuid &&
  46236. r.find(e) &&
  46237. s.forInstancesRec((o) => {
  46238. o.isInstanceRoot ||
  46239. (o.data = Pd(o.data, (l) => {
  46240. let h = l.events.data(a.id),
  46241. u = o.goUp(n);
  46242. if (u) {
  46243. let c = [...tA(u.identity), e].join('-'),
  46244. d = this.entityIdentityToEntity[c];
  46245. if (d) {
  46246. let p = d.uuid;
  46247. fs.zoom(h, t)[i] = p;
  46248. } else console.warn('cannot find instance');
  46249. }
  46250. }).data);
  46251. });
  46252. }
  46253. rewriteEventsBeforeGoToPlayMode() {
  46254. this.traverseEntity((e) => {
  46255. if (e instanceof Ro && typeof e.identity == 'string' && e.data.type === 'Component')
  46256. return (
  46257. e.traverseEntity((t, i) => {
  46258. t.data.events.forEach((r) => {
  46259. r.data.type === 'GameControl'
  46260. ? t.forInstancesRec((s) => {
  46261. s.isInstanceRoot ||
  46262. (s.data = Pd(s.data, (n) => {
  46263. n.events.delete(r.id);
  46264. }).data);
  46265. })
  46266. : r.data.type === 'Conditional'
  46267. ? (r.data.condition.type === 'Distance'
  46268. ? (this.relativeizeInner(r.data.condition.fromObject, ['condition'], 'fromObject', e, t, i, r),
  46269. this.relativeizeInner(r.data.condition.toObject, ['condition'], 'toObject', e, t, i, r))
  46270. : r.data.condition.type === 'State'
  46271. ? this.relativeizeInner(r.data.condition.object, ['condition'], 'object', e, t, i, r)
  46272. : r.data.condition.type === 'Comparison' &&
  46273. (r.data.condition.lOperand.type === 'Property' &&
  46274. this.relativeizeInner(r.data.condition.lOperand.value[0], ['condition', 'lOperand', 'value'], 0, e, t, i, r),
  46275. r.data.condition.rOperand.type === 'Property' &&
  46276. this.relativeizeInner(r.data.condition.rOperand.value[0], ['condition', 'rOperand', 'value'], 0, e, t, i, r)),
  46277. r.data.inActions.forEach((s) => {
  46278. s.data.type === 'Transition' && this.relativeizeInner(s.data.object, ['inActions', s.id], 'object', e, t, i, r);
  46279. }),
  46280. r.data.outActions.forEach((s) => {
  46281. s.data.type === 'Transition' && this.relativeizeInner(s.data.object, ['outActions', s.id], 'object', e, t, i, r);
  46282. }))
  46283. : 'actions' in r.data &&
  46284. r.data.actions.forEach((s) => {
  46285. s.data.type === 'Transition' && this.relativeizeInner(s.data.object, ['actions', s.id], 'object', e, t, i, r);
  46286. });
  46287. });
  46288. }),
  46289. !0
  46290. );
  46291. });
  46292. }
  46293. expandInstances(e, t) {
  46294. let i = new Set();
  46295. this.traverseEntity((r) => {
  46296. if (r instanceof Ro && r.isInstanceRoot)
  46297. return r.expandInstanceChildren({ scene: this, shared: e, pendingDeletes: i }), t || r.resetBBoxNeedsUpdate(), !0;
  46298. });
  46299. for (let r of i) this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r), vv(r);
  46300. }
  46301. recomputeInstances(e) {
  46302. this.needsRecomputeInstances &&
  46303. ((this.needsRecomputeInstances = !1),
  46304. this.traverseEntity((t) => {
  46305. t instanceof Ro && t.isInstanceRoot && (t.component = void 0);
  46306. }),
  46307. this.expandInstances(e, !1));
  46308. }
  46309. disposeAndUnregisterEntityRecursivelyIfNotReregistered(e) {
  46310. e.traverseEntity((t) => {
  46311. let i = typeof t.identity == 'string' ? t.identity : t.identity.join('-');
  46312. this.entityIdentityToEntity[i] === t && (delete this.entityByUuid[t.uuid], delete this.entityIdentityToEntity[i]), t.dispose();
  46313. });
  46314. }
  46315. clearScene() {
  46316. for (let e of this.children) Ct.is(e) && e.disposeRecursively();
  46317. this.children.length = 0;
  46318. }
  46319. resetAfterClear(e, t) {
  46320. this.init(e, t);
  46321. }
  46322. createPersonalCamera() {
  46323. let e = new Gi(ES.PERSONAL_CAMERA_ID, { ...Ud.defaultData, name: 'Personal Camera' });
  46324. return (e.objectHelper.visible = !1), this.registerObjectCreatedInLegacy(e), e;
  46325. }
  46326. raycast(e) {
  46327. let t = [],
  46328. i = (r) => {
  46329. for (let s of r.children) {
  46330. let n = s.cloner;
  46331. Ct.is(s) &&
  46332. !s.raycastLock &&
  46333. (s.visible || n?.object.data.visible) &&
  46334. ((js(s) || (f8(s) && this.enableHelpers && s.objectHelper.visible)) && (e.intersectObject(s, !1, t), T8(s, e, t)), i(s));
  46335. }
  46336. };
  46337. return i(this), t;
  46338. }
  46339. forEachEntity(e) {
  46340. for (let t of this.children) Ct.is(t) && e(t);
  46341. }
  46342. traverseEntity(e) {
  46343. for (let t of this.children) Ct.is(t) && t.traverseEntity(e);
  46344. }
  46345. traverseObject(e) {
  46346. for (let t of this.children) Yd.is(t) && t.traverseObject(e);
  46347. }
  46348. traverseVisibleEntity(e) {
  46349. for (let t of this.children) Ct.is(t) && t.visible && t.traverseVisibleEntity(e);
  46350. }
  46351. updateFog(e, t) {
  46352. (this.enableFog = e.enabled),
  46353. (this.fogUseBGColor = e.useBackgroundColor),
  46354. e.useBackgroundColor ? this.backupFog.color.set(this.bgColor) : (this.backupFog.color = sr(e.color, t)),
  46355. (this.backupFog.near = e.near),
  46356. (this.backupFog.far = e.far);
  46357. }
  46358. dispose() {
  46359. this.clearScene();
  46360. }
  46361. updateAmbientLight(e, t) {
  46362. e.color !== void 0 && (this.ambientLight.color = sr(e.color, t)),
  46363. e.intensity !== void 0 && (this.ambientLight.intensity = e.intensity),
  46364. e.groundColor !== void 0 && (this.ambientLight.groundColor = sr(e.groundColor, t)),
  46365. e.enabled !== void 0 && (this.ambientLight.visible = e.enabled);
  46366. }
  46367. switchActiveCamera(e) {
  46368. this.activeCamera !== this.personalCamera && (this.activeCamera.objectHelper.visible = !0),
  46369. (this.activeCamera = e),
  46370. (e.objectHelper.visible = !1);
  46371. }
  46372. setBackgroundColor(e) {
  46373. (this.bgColor = e), this.fogUseBGColor === !0 && (this.backupFog.color = e);
  46374. }
  46375. createChildrenObjects(e, t, i) {
  46376. let r = 0;
  46377. for (let s of e) this.createObject(s.id, s.data, s.children, t, r, i), (r += 1);
  46378. }
  46379. registerObjectCreatedInLegacy(e) {
  46380. this.entityByUuid[e.uuid] = e;
  46381. }
  46382. unregisterObject(e) {
  46383. delete this.entityByUuid[e.uuid];
  46384. for (let t of e.children) this.unregisterObject(t);
  46385. }
  46386. createObject(e, t, i, r, s, n) {
  46387. let a = { scene: this, shared: n },
  46388. o = yv(e, t, a);
  46389. return (
  46390. o &&
  46391. ((this.entityByUuid[e] = o),
  46392. r.add(o),
  46393. r.children.splice(s, 0, r.children.pop()),
  46394. i.length > 0 && (o.isInstanceRoot ? console.error('instance should not have children!') : this.createChildrenObjects(i, o, n)),
  46395. o.updateState(t, a),
  46396. o instanceof Cr && o.updateGeometryGroupsIfNeeded(),
  46397. o.updateVisible(),
  46398. o.cloner && this.toExpandCloner.add(o),
  46399. t.pathSnapping?.pathId && this.pathConstraints.setConstraint(e, t.pathSnapping.pathId)),
  46400. o
  46401. );
  46402. }
  46403. getCenter(e) {
  46404. let t = [];
  46405. for (let r = 0, s = e.length; r < s; ++r) {
  46406. let { id: n, recursive: a } = e[r],
  46407. o = this.find(n),
  46408. l = a ? o.recursiveBBox : o.singleBBox;
  46409. t.push(...l.vertices);
  46410. }
  46411. let i = new Kt();
  46412. return i.setFromPoints(t), i.getCenter(db), db;
  46413. }
  46414. copyMatrixWorld(e, t) {
  46415. if (e === null) {
  46416. t.identity();
  46417. return;
  46418. }
  46419. let i = this.find(e);
  46420. i ? t.copy(i.matrixWorld) : t.identity();
  46421. }
  46422. copyParentMatrixWorld(e, t) {
  46423. if (e === null) {
  46424. t.identity();
  46425. return;
  46426. }
  46427. let i = this.find(e)?.parent;
  46428. i ? t.copy(i.matrixWorld) : t.identity();
  46429. }
  46430. traverseMaterial(e) {
  46431. this.traverseEntity((t) => {
  46432. if (t instanceof ar)
  46433. if (Array.isArray(t.material)) for (let i = 0; i < t.material.length; i++) t.material[i] instanceof Ln && e(t.material[i]);
  46434. else t.material instanceof Ln && e(t.material);
  46435. });
  46436. }
  46437. updateCanvasSize(e, t) {
  46438. this.activeCamera.setViewplaneSize(e, t);
  46439. let i, r;
  46440. e >= t ? ((i = t / e), (r = 1)) : ((i = 1), (r = e / t)),
  46441. this.traverseMaterial((s) => {
  46442. s.getLayersOfType('transmission').forEach((n) => {
  46443. (n.uniforms[`f${n.id}_aspectRatio`].value.x = i), (n.uniforms[`f${n.id}_aspectRatio`].value.y = r);
  46444. });
  46445. });
  46446. }
  46447. },
  46448. sl = ES;
  46449. sl.PERSONAL_CAMERA_ID = 'f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera';
  46450. var ld = (e, t) => {
  46451. let i = t.x - e.x,
  46452. r = t.y - e.y;
  46453. return Math.sqrt(i * i + r * r);
  46454. },
  46455. N8 = (e, t) => {
  46456. let i = t.x - e.x,
  46457. r = t.y - e.y;
  46458. return F8(Math.atan2(r, i));
  46459. },
  46460. U8 = (e, t, i) => {
  46461. let r = { x: 0, y: 0 };
  46462. return (i = Ym(i)), (r.x = e.x - t * Math.cos(i)), (r.y = e.y - t * Math.sin(i)), r;
  46463. },
  46464. Ym = (e) => e * (Math.PI / 180),
  46465. F8 = (e) => e * (180 / Math.PI),
  46466. k8 = (e) => (isNaN(e.buttons) ? e.pressure !== 0 : e.buttons !== 0),
  46467. mf = new Map(),
  46468. ub = (e) => {
  46469. mf.has(e) && clearTimeout(mf.get(e)), mf.set(e, setTimeout(e, 100));
  46470. },
  46471. tu = (e, t, i) => {
  46472. let r = t.split(/[ ,]+/g),
  46473. s;
  46474. for (let n = 0; n < r.length; n += 1)
  46475. (s = r[n]), e.addEventListener ? e.addEventListener(s, i, !1) : e.attachEvent && e.attachEvent(s, i);
  46476. },
  46477. pb = (e, t, i) => {
  46478. let r = t.split(/[ ,]+/g),
  46479. s;
  46480. for (let n = 0; n < r.length; n += 1)
  46481. (s = r[n]), e.removeEventListener ? e.removeEventListener(s, i) : e.detachEvent && e.detachEvent(s, i);
  46482. },
  46483. CS = (e) => (e.preventDefault(), e.type.match(/^touch/) ? e.changedTouches : e),
  46484. fb = () => {
  46485. if (typeof window > 'u') return;
  46486. let e =
  46487. window.pageXOffset !== void 0
  46488. ? window.pageXOffset
  46489. : (document.documentElement || document.body.parentNode || document.body).scrollLeft,
  46490. t =
  46491. window.pageYOffset !== void 0
  46492. ? window.pageYOffset
  46493. : (document.documentElement || document.body.parentNode || document.body).scrollTop;
  46494. return { x: e, y: t };
  46495. },
  46496. Qm = (e, t) => {
  46497. t.top || t.right || t.bottom || t.left
  46498. ? ((e.style.top = t.top), (e.style.right = t.right), (e.style.bottom = t.bottom), (e.style.left = t.left))
  46499. : ((e.style.left = t.x + 'px'), (e.style.top = t.y + 'px'));
  46500. },
  46501. xv = (e, t, i) => {
  46502. let r = TS(e);
  46503. for (let s in r)
  46504. if (r.hasOwnProperty(s))
  46505. if (typeof t == 'string') r[s] = t + ' ' + i;
  46506. else {
  46507. let n = '';
  46508. for (let a = 0, o = t.length; a < o; a += 1) n += t[a] + ' ' + i + ', ';
  46509. r[s] = n.slice(0, -2);
  46510. }
  46511. return r;
  46512. },
  46513. j8 = (e, t) => {
  46514. let i = TS(e);
  46515. for (let r in i) i.hasOwnProperty(r) && (i[r] = t);
  46516. return i;
  46517. },
  46518. TS = (e) => {
  46519. let t = {};
  46520. return (
  46521. (t[e] = ''),
  46522. ['webkit', 'Moz', 'o'].forEach(function (i) {
  46523. t[i + e.charAt(0).toUpperCase() + e.slice(1)] = '';
  46524. }),
  46525. t
  46526. );
  46527. },
  46528. gf = (e, t) => {
  46529. for (let i in t) t.hasOwnProperty(i) && (e[i] = t[i]);
  46530. return e;
  46531. },
  46532. G8 = (e, t) => {
  46533. let i = {};
  46534. for (let r in e) e.hasOwnProperty(r) && t.hasOwnProperty(r) ? (i[r] = t[r]) : e.hasOwnProperty(r) && (i[r] = e[r]);
  46535. return i;
  46536. },
  46537. Zm = (e, t) => {
  46538. if (e.length) for (let i = 0, r = e.length; i < r; i += 1) t(e[i]);
  46539. else t(e);
  46540. },
  46541. V8 = (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) });
  46542. typeof window < 'u' && ((PS = 'ontouchstart' in window), (DS = !!window.PointerEvent), (LS = !!window.MSPointerEvent));
  46543. var PS,
  46544. DS,
  46545. LS,
  46546. zl = {
  46547. touch: { start: 'touchstart', move: 'touchmove', end: 'touchend, touchcancel' },
  46548. mouse: { start: 'mousedown', move: 'mousemove', end: 'mouseup' },
  46549. pointer: { start: 'pointerdown', move: 'pointermove', end: 'pointerup, pointercancel' },
  46550. MSPointer: { start: 'MSPointerDown', move: 'MSPointerMove', end: 'MSPointerUp' }
  46551. },
  46552. xo,
  46553. Mh = {};
  46554. DS ? (xo = zl.pointer) : LS ? (xo = zl.MSPointer) : PS ? ((xo = zl.touch), (Mh = zl.mouse)) : (xo = zl.mouse);
  46555. function Pa() {}
  46556. Pa.prototype.on = function (e, t) {
  46557. var i = this,
  46558. r = e.split(/[ ,]+/g),
  46559. s;
  46560. i._handlers_ = i._handlers_ || {};
  46561. for (var n = 0; n < r.length; n += 1) (s = r[n]), (i._handlers_[s] = i._handlers_[s] || []), i._handlers_[s].push(t);
  46562. return i;
  46563. };
  46564. Pa.prototype.off = function (e, t) {
  46565. var i = this;
  46566. return (
  46567. (i._handlers_ = i._handlers_ || {}),
  46568. e === void 0
  46569. ? (i._handlers_ = {})
  46570. : t === void 0
  46571. ? (i._handlers_[e] = null)
  46572. : i._handlers_[e] && i._handlers_[e].indexOf(t) >= 0 && i._handlers_[e].splice(i._handlers_[e].indexOf(t), 1),
  46573. i
  46574. );
  46575. };
  46576. Pa.prototype.trigger = function (e, t) {
  46577. var i = this,
  46578. r = e.split(/[ ,]+/g),
  46579. s;
  46580. i._handlers_ = i._handlers_ || {};
  46581. for (var n = 0; n < r.length; n += 1)
  46582. (s = r[n]),
  46583. i._handlers_[s] &&
  46584. i._handlers_[s].length &&
  46585. i._handlers_[s].forEach(function (a) {
  46586. a.call(i, { type: s, target: i }, t);
  46587. });
  46588. };
  46589. Pa.prototype.config = function (e) {
  46590. var t = this;
  46591. (t.options = t.defaults || {}), e && (t.options = G8(t.options, e));
  46592. };
  46593. Pa.prototype.bindEvt = function (e, t) {
  46594. var i = this;
  46595. return (
  46596. (i._domHandlers_ = i._domHandlers_ || {}),
  46597. (i._domHandlers_[t] = function () {
  46598. typeof i['on' + t] == 'function' ? i['on' + t].apply(i, arguments) : console.warn('[WARNING] : Missing "on' + t + '" handler.');
  46599. }),
  46600. tu(e, xo[t], i._domHandlers_[t]),
  46601. Mh[t] && tu(e, Mh[t], i._domHandlers_[t]),
  46602. i
  46603. );
  46604. };
  46605. Pa.prototype.unbindEvt = function (e, t) {
  46606. var i = this;
  46607. return (
  46608. (i._domHandlers_ = i._domHandlers_ || {}),
  46609. pb(e, xo[t], i._domHandlers_[t]),
  46610. Mh[t] && pb(e, Mh[t], i._domHandlers_[t]),
  46611. delete i._domHandlers_[t],
  46612. this
  46613. );
  46614. };
  46615. var bv = Pa;
  46616. function ai(e, t) {
  46617. return (
  46618. (this.identifier = t.identifier),
  46619. (this.position = t.position),
  46620. (this.frontPosition = t.frontPosition),
  46621. (this.collection = e),
  46622. (this.defaults = {
  46623. size: 100,
  46624. threshold: 0.1,
  46625. color: 'white',
  46626. fadeTime: 250,
  46627. dataOnly: !1,
  46628. restJoystick: !0,
  46629. restOpacity: 1,
  46630. mode: 'dynamic',
  46631. zone: document.body,
  46632. lockX: !1,
  46633. lockY: !1,
  46634. shape: 'circle'
  46635. }),
  46636. this.config(t),
  46637. this.options.mode === 'dynamic' && (this.options.restOpacity = 0),
  46638. (this.id = ai.id),
  46639. (ai.id += 1),
  46640. this.buildEl().stylize(),
  46641. (this.instance = {
  46642. el: this.ui.el,
  46643. on: this.on.bind(this),
  46644. off: this.off.bind(this),
  46645. show: this.show.bind(this),
  46646. hide: this.hide.bind(this),
  46647. add: this.addToDom.bind(this),
  46648. remove: this.removeFromDom.bind(this),
  46649. destroy: this.destroy.bind(this),
  46650. setPosition: this.setPosition.bind(this),
  46651. resetDirection: this.resetDirection.bind(this),
  46652. computeDirection: this.computeDirection.bind(this),
  46653. trigger: this.trigger.bind(this),
  46654. position: this.position,
  46655. frontPosition: this.frontPosition,
  46656. ui: this.ui,
  46657. identifier: this.identifier,
  46658. id: this.id,
  46659. options: this.options
  46660. }),
  46661. this.instance
  46662. );
  46663. }
  46664. ai.prototype = new bv();
  46665. ai.constructor = ai;
  46666. ai.id = 0;
  46667. ai.prototype.buildEl = function (e) {
  46668. return (
  46669. (this.ui = {}),
  46670. this.options.dataOnly
  46671. ? this
  46672. : ((this.ui.el = document.createElement('div')),
  46673. (this.ui.back = document.createElement('div')),
  46674. (this.ui.front = document.createElement('div')),
  46675. (this.ui.el.className = 'nipple collection_' + this.collection.id),
  46676. (this.ui.back.className = 'back'),
  46677. (this.ui.front.className = 'front'),
  46678. this.ui.el.setAttribute('id', 'nipple_' + this.collection.id + '_' + this.id),
  46679. this.ui.el.appendChild(this.ui.back),
  46680. this.ui.el.appendChild(this.ui.front),
  46681. this)
  46682. );
  46683. };
  46684. ai.prototype.stylize = function () {
  46685. if (this.options.dataOnly) return this;
  46686. var e = this.options.fadeTime + 'ms',
  46687. t = j8('borderRadius', '50%'),
  46688. i = xv('transition', 'opacity', e),
  46689. r = {};
  46690. return (
  46691. (r.el = { position: 'absolute', opacity: this.options.restOpacity, display: 'block', zIndex: 999 }),
  46692. (r.back = {
  46693. position: 'absolute',
  46694. display: 'block',
  46695. width: this.options.size + 'px',
  46696. height: this.options.size + 'px',
  46697. marginLeft: -this.options.size / 2 + 'px',
  46698. marginTop: -this.options.size / 2 + 'px',
  46699. background: 'rgba(255, 255, 255, .4)',
  46700. border: 'solid 2px rgba(0, 0, 0, .1)'
  46701. }),
  46702. (r.front = {
  46703. width: this.options.size / 2 + 'px',
  46704. height: this.options.size / 2 + 'px',
  46705. position: 'absolute',
  46706. display: 'block',
  46707. marginLeft: -this.options.size / 4 + 'px',
  46708. marginTop: -this.options.size / 4 + 'px',
  46709. background: 'rgba(255, 255, 255, .8)',
  46710. border: 'solid 2px rgba(0, 0, 0, .1)'
  46711. }),
  46712. gf(r.el, i),
  46713. this.options.shape === 'circle' && gf(r.back, t),
  46714. gf(r.front, t),
  46715. this.applyStyles(r),
  46716. this
  46717. );
  46718. };
  46719. ai.prototype.applyStyles = function (e) {
  46720. 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];
  46721. return this;
  46722. };
  46723. ai.prototype.addToDom = function () {
  46724. return this.options.dataOnly || document.body.contains(this.ui.el) ? this : (this.options.zone.appendChild(this.ui.el), this);
  46725. };
  46726. ai.prototype.removeFromDom = function () {
  46727. return this.options.dataOnly || !document.body.contains(this.ui.el) ? this : (this.options.zone.removeChild(this.ui.el), this);
  46728. };
  46729. ai.prototype.destroy = function () {
  46730. clearTimeout(this.removeTimeout),
  46731. clearTimeout(this.showTimeout),
  46732. clearTimeout(this.restTimeout),
  46733. this.trigger('destroyed', this.instance),
  46734. this.removeFromDom(),
  46735. this.off();
  46736. };
  46737. ai.prototype.show = function (e) {
  46738. var t = this;
  46739. return (
  46740. t.options.dataOnly ||
  46741. (clearTimeout(t.removeTimeout),
  46742. clearTimeout(t.showTimeout),
  46743. clearTimeout(t.restTimeout),
  46744. t.addToDom(),
  46745. t.restCallback(),
  46746. setTimeout(function () {
  46747. t.ui.el.style.opacity = 1;
  46748. }, 0),
  46749. (t.showTimeout = setTimeout(function () {
  46750. t.trigger('shown', t.instance), typeof e == 'function' && e.call(this);
  46751. }, t.options.fadeTime))),
  46752. t
  46753. );
  46754. };
  46755. ai.prototype.hide = function (e) {
  46756. var t = this;
  46757. if (t.options.dataOnly) return t;
  46758. if (
  46759. ((t.ui.el.style.opacity = t.options.restOpacity),
  46760. clearTimeout(t.removeTimeout),
  46761. clearTimeout(t.showTimeout),
  46762. clearTimeout(t.restTimeout),
  46763. (t.removeTimeout = setTimeout(function () {
  46764. var i = t.options.mode === 'dynamic' ? 'none' : 'block';
  46765. (t.ui.el.style.display = i), typeof e == 'function' && e.call(t), t.trigger('hidden', t.instance);
  46766. }, t.options.fadeTime)),
  46767. t.options.restJoystick)
  46768. ) {
  46769. let i = t.options.restJoystick,
  46770. r = {};
  46771. (r.x = i === !0 || i.x !== !1 ? 0 : t.instance.frontPosition.x),
  46772. (r.y = i === !0 || i.y !== !1 ? 0 : t.instance.frontPosition.y),
  46773. t.setPosition(e, r);
  46774. }
  46775. return t;
  46776. };
  46777. ai.prototype.setPosition = function (e, t) {
  46778. var i = this;
  46779. i.frontPosition = { x: t.x, y: t.y };
  46780. var r = i.options.fadeTime + 'ms',
  46781. s = {};
  46782. s.front = xv('transition', ['top', 'left'], r);
  46783. var n = { front: {} };
  46784. (n.front = { left: i.frontPosition.x + 'px', top: i.frontPosition.y + 'px' }),
  46785. i.applyStyles(s),
  46786. i.applyStyles(n),
  46787. (i.restTimeout = setTimeout(function () {
  46788. typeof e == 'function' && e.call(i), i.restCallback();
  46789. }, i.options.fadeTime));
  46790. };
  46791. ai.prototype.restCallback = function () {
  46792. var e = this,
  46793. t = {};
  46794. (t.front = xv('transition', 'none', '')), e.applyStyles(t), e.trigger('rested', e.instance);
  46795. };
  46796. ai.prototype.resetDirection = function () {
  46797. this.direction = { x: !1, y: !1, angle: !1 };
  46798. };
  46799. ai.prototype.computeDirection = function (e) {
  46800. var t = e.angle.radian,
  46801. i = Math.PI / 4,
  46802. r = Math.PI / 2,
  46803. s,
  46804. n,
  46805. a;
  46806. if (
  46807. (t > i && t < i * 3 && !e.lockX
  46808. ? (s = 'up')
  46809. : t > -i && t <= i && !e.lockY
  46810. ? (s = 'left')
  46811. : t > -i * 3 && t <= -i && !e.lockX
  46812. ? (s = 'down')
  46813. : e.lockY || (s = 'right'),
  46814. e.lockY || (t > -r && t < r ? (n = 'left') : (n = 'right')),
  46815. e.lockX || (t > 0 ? (a = 'up') : (a = 'down')),
  46816. e.force > this.options.threshold)
  46817. ) {
  46818. var o = {},
  46819. l;
  46820. for (l in this.direction) this.direction.hasOwnProperty(l) && (o[l] = this.direction[l]);
  46821. var h = {};
  46822. (this.direction = { x: n, y: a, angle: s }), (e.direction = this.direction);
  46823. for (l in o) o[l] === this.direction[l] && (h[l] = !0);
  46824. if (h.x && h.y && h.angle) return e;
  46825. (!h.x || !h.y) && this.trigger('plain', e),
  46826. h.x || this.trigger('plain:' + n, e),
  46827. h.y || this.trigger('plain:' + a, e),
  46828. h.angle || this.trigger('dir dir:' + s, e);
  46829. } else this.resetDirection();
  46830. return e;
  46831. };
  46832. var H8 = ai;
  46833. function Ht(e, t) {
  46834. var i = this;
  46835. (i.nipples = []),
  46836. (i.idles = []),
  46837. (i.actives = []),
  46838. (i.ids = []),
  46839. (i.pressureIntervals = {}),
  46840. (i.manager = e),
  46841. (i.id = Ht.id),
  46842. (Ht.id += 1),
  46843. (i.defaults = {
  46844. zone: document.body,
  46845. multitouch: !1,
  46846. maxNumberOfNipples: 10,
  46847. mode: 'dynamic',
  46848. position: { top: 0, left: 0 },
  46849. catchDistance: 200,
  46850. size: 100,
  46851. threshold: 0.1,
  46852. color: 'white',
  46853. fadeTime: 250,
  46854. dataOnly: !1,
  46855. restJoystick: !0,
  46856. restOpacity: 1,
  46857. lockX: !1,
  46858. lockY: !1,
  46859. shape: 'circle',
  46860. dynamicPage: !1,
  46861. follow: !1
  46862. }),
  46863. i.config(t),
  46864. (i.options.mode === 'static' || i.options.mode === 'semi') && (i.options.multitouch = !1),
  46865. i.options.multitouch || (i.options.maxNumberOfNipples = 1);
  46866. let r = getComputedStyle(i.options.zone.parentElement);
  46867. return r && r.display === 'flex' && (i.parentIsFlex = !0), i.updateBox(), i.prepareNipples(), i.bindings(), i.begin(), i.nipples;
  46868. }
  46869. Ht.prototype = new bv();
  46870. Ht.constructor = Ht;
  46871. Ht.id = 0;
  46872. Ht.prototype.prepareNipples = function () {
  46873. var e = this,
  46874. t = e.nipples;
  46875. (t.on = e.on.bind(e)),
  46876. (t.off = e.off.bind(e)),
  46877. (t.options = e.options),
  46878. (t.destroy = e.destroy.bind(e)),
  46879. (t.ids = e.ids),
  46880. (t.id = e.id),
  46881. (t.processOnMove = e.processOnMove.bind(e)),
  46882. (t.processOnEnd = e.processOnEnd.bind(e)),
  46883. (t.get = function (i) {
  46884. if (i === void 0) return t[0];
  46885. for (var r = 0, s = t.length; r < s; r += 1) if (t[r].identifier === i) return t[r];
  46886. return !1;
  46887. });
  46888. };
  46889. Ht.prototype.bindings = function () {
  46890. var e = this;
  46891. e.bindEvt(e.options.zone, 'start'), (e.options.zone.style.touchAction = 'none'), (e.options.zone.style.msTouchAction = 'none');
  46892. };
  46893. Ht.prototype.begin = function () {
  46894. var e = this,
  46895. t = e.options;
  46896. if (t.mode === 'static') {
  46897. var i = e.createNipple(t.position, e.manager.getIdentifier());
  46898. i.add(), e.idles.push(i);
  46899. }
  46900. };
  46901. Ht.prototype.createNipple = function (e, t) {
  46902. var i = this,
  46903. r = i.manager.scroll,
  46904. s = {},
  46905. n = i.options,
  46906. a = { x: i.parentIsFlex ? r.x : r.x + i.box.left, y: i.parentIsFlex ? r.y : r.y + i.box.top };
  46907. if (e.x && e.y) s = { x: e.x - a.x, y: e.y - a.y };
  46908. else if (e.top || e.right || e.bottom || e.left) {
  46909. var o = document.createElement('DIV');
  46910. (o.style.display = 'hidden'),
  46911. (o.style.top = e.top),
  46912. (o.style.right = e.right),
  46913. (o.style.bottom = e.bottom),
  46914. (o.style.left = e.left),
  46915. (o.style.position = 'absolute'),
  46916. n.zone.appendChild(o);
  46917. var l = o.getBoundingClientRect();
  46918. n.zone.removeChild(o), (s = e), (e = { x: l.left + r.x, y: l.top + r.y });
  46919. }
  46920. var h = new H8(i, {
  46921. color: n.color,
  46922. size: n.size,
  46923. threshold: n.threshold,
  46924. fadeTime: n.fadeTime,
  46925. dataOnly: n.dataOnly,
  46926. restJoystick: n.restJoystick,
  46927. restOpacity: n.restOpacity,
  46928. mode: n.mode,
  46929. identifier: t,
  46930. position: e,
  46931. zone: n.zone,
  46932. frontPosition: { x: 0, y: 0 },
  46933. shape: n.shape
  46934. });
  46935. return (
  46936. n.dataOnly || (Qm(h.ui.el, s), Qm(h.ui.front, h.frontPosition)),
  46937. i.nipples.push(h),
  46938. i.trigger('added ' + h.identifier + ':added', h),
  46939. i.manager.trigger('added ' + h.identifier + ':added', h),
  46940. i.bindNipple(h),
  46941. h
  46942. );
  46943. };
  46944. Ht.prototype.updateBox = function () {
  46945. var e = this;
  46946. e.box = e.options.zone.getBoundingClientRect();
  46947. };
  46948. Ht.prototype.bindNipple = function (e) {
  46949. var t = this,
  46950. i,
  46951. r = function (s, n) {
  46952. (i = s.type + ' ' + n.id + ':' + s.type), t.trigger(i, n);
  46953. };
  46954. e.on('destroyed', t.onDestroyed.bind(t)),
  46955. e.on('shown hidden rested dir plain', r),
  46956. e.on('dir:up dir:right dir:down dir:left', r),
  46957. e.on('plain:up plain:right plain:down plain:left', r);
  46958. };
  46959. Ht.prototype.pressureFn = function (e, t, i) {
  46960. var r = this,
  46961. s = 0;
  46962. clearInterval(r.pressureIntervals[i]),
  46963. (r.pressureIntervals[i] = setInterval(
  46964. function () {
  46965. var n = e.force || e.pressure || e.webkitForce || 0;
  46966. n !== s && (t.trigger('pressure', n), r.trigger('pressure ' + t.identifier + ':pressure', n), (s = n));
  46967. }.bind(r),
  46968. 100
  46969. ));
  46970. };
  46971. Ht.prototype.onstart = function (e) {
  46972. var t = this,
  46973. i = t.options,
  46974. r = e;
  46975. (e = CS(e)), t.updateBox();
  46976. var s = function (n) {
  46977. t.actives.length < i.maxNumberOfNipples
  46978. ? t.processOnStart(n)
  46979. : r.type.match(/^touch/) &&
  46980. (Object.keys(t.manager.ids).forEach(function (a) {
  46981. if (
  46982. Object.values(r.touches).findIndex(function (l) {
  46983. return l.identifier === a;
  46984. }) < 0
  46985. ) {
  46986. var o = [e[0]];
  46987. (o.identifier = a), t.processOnEnd(o);
  46988. }
  46989. }),
  46990. t.actives.length < i.maxNumberOfNipples && t.processOnStart(n));
  46991. };
  46992. return Zm(e, s), t.manager.bindDocument(), !1;
  46993. };
  46994. Ht.prototype.processOnStart = function (e) {
  46995. var t = this,
  46996. i = t.options,
  46997. r,
  46998. s = t.manager.getIdentifier(e),
  46999. n = e.force || e.pressure || e.webkitForce || 0,
  47000. a = { x: e.pageX, y: e.pageY },
  47001. o = t.getOrCreate(s, a);
  47002. o.identifier !== s && t.manager.removeIdentifier(o.identifier), (o.identifier = s);
  47003. var l = function (u) {
  47004. u.trigger('start', u),
  47005. t.trigger('start ' + u.id + ':start', u),
  47006. u.show(),
  47007. n > 0 && t.pressureFn(e, u, u.identifier),
  47008. t.processOnMove(e);
  47009. };
  47010. 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);
  47011. else {
  47012. var h = ld(a, o.position);
  47013. if (h <= i.catchDistance) l(o);
  47014. else {
  47015. o.destroy(), t.processOnStart(e);
  47016. return;
  47017. }
  47018. }
  47019. return o;
  47020. };
  47021. Ht.prototype.getOrCreate = function (e, t) {
  47022. var i = this,
  47023. r = i.options,
  47024. s;
  47025. return /(semi|static)/.test(r.mode)
  47026. ? ((s = i.idles[0]),
  47027. s ? (i.idles.splice(0, 1), s) : r.mode === 'semi' ? i.createNipple(t, e) : (console.warn("Coudln't find the needed nipple."), !1))
  47028. : ((s = i.createNipple(t, e)), s);
  47029. };
  47030. Ht.prototype.processOnMove = function (e) {
  47031. var t = this,
  47032. i = t.options,
  47033. r = t.manager.getIdentifier(e),
  47034. s = t.nipples.get(r),
  47035. n = t.manager.scroll;
  47036. if (!k8(e)) {
  47037. this.processOnEnd(e);
  47038. return;
  47039. }
  47040. if (!s) {
  47041. console.error('Found zombie joystick with ID ' + r), t.manager.removeIdentifier(r);
  47042. return;
  47043. }
  47044. if (i.dynamicPage) {
  47045. var a = s.el.getBoundingClientRect();
  47046. s.position = { x: n.x + a.left, y: n.y + a.top };
  47047. }
  47048. s.identifier = r;
  47049. var o = s.options.size / 2,
  47050. l = { x: e.pageX, y: e.pageY };
  47051. i.lockX && (l.y = s.position.y), i.lockY && (l.x = s.position.x);
  47052. var h = ld(l, s.position),
  47053. u = N8(l, s.position),
  47054. c = Ym(u),
  47055. d = h / o,
  47056. p = { distance: h, position: l },
  47057. f,
  47058. g;
  47059. if (
  47060. (s.options.shape === 'circle'
  47061. ? ((f = Math.min(h, o)), (g = U8(s.position, f, u)))
  47062. : ((g = V8(l, s.position, o)), (f = ld(g, s.position))),
  47063. i.follow)
  47064. ) {
  47065. if (h > o) {
  47066. let b = l.x - g.x,
  47067. x = l.y - g.y;
  47068. (s.position.x += b),
  47069. (s.position.y += x),
  47070. (s.el.style.top = s.position.y - (t.box.top + n.y) + 'px'),
  47071. (s.el.style.left = s.position.x - (t.box.left + n.x) + 'px'),
  47072. (h = ld(l, s.position));
  47073. }
  47074. } else (l = g), (h = f);
  47075. var m = l.x - s.position.x,
  47076. v = l.y - s.position.y;
  47077. (s.frontPosition = { x: m, y: v }), i.dataOnly || Qm(s.ui.front, s.frontPosition);
  47078. var y = {
  47079. identifier: s.identifier,
  47080. position: l,
  47081. force: d,
  47082. pressure: e.force || e.pressure || e.webkitForce || 0,
  47083. distance: h,
  47084. angle: { radian: c, degree: u },
  47085. vector: { x: m / o, y: -v / o },
  47086. raw: p,
  47087. instance: s,
  47088. lockX: i.lockX,
  47089. lockY: i.lockY
  47090. };
  47091. (y = s.computeDirection(y)),
  47092. (y.angle = { radian: Ym(180 - u), degree: 180 - u }),
  47093. s.trigger('move', y),
  47094. t.trigger('move ' + s.id + ':move', y);
  47095. };
  47096. Ht.prototype.processOnEnd = function (e) {
  47097. var t = this,
  47098. i = t.options,
  47099. r = t.manager.getIdentifier(e),
  47100. s = t.nipples.get(r),
  47101. n = t.manager.removeIdentifier(s.identifier);
  47102. !s ||
  47103. (i.dataOnly ||
  47104. s.hide(function () {
  47105. i.mode === 'dynamic' &&
  47106. (s.trigger('removed', s),
  47107. t.trigger('removed ' + s.id + ':removed', s),
  47108. t.manager.trigger('removed ' + s.id + ':removed', s),
  47109. s.destroy());
  47110. }),
  47111. clearInterval(t.pressureIntervals[s.identifier]),
  47112. s.resetDirection(),
  47113. s.trigger('end', s),
  47114. t.trigger('end ' + s.id + ':end', s),
  47115. t.ids.indexOf(s.identifier) >= 0 && t.ids.splice(t.ids.indexOf(s.identifier), 1),
  47116. t.actives.indexOf(s) >= 0 && t.actives.splice(t.actives.indexOf(s), 1),
  47117. /(semi|static)/.test(i.mode) ? t.idles.push(s) : t.nipples.indexOf(s) >= 0 && t.nipples.splice(t.nipples.indexOf(s), 1),
  47118. t.manager.unbindDocument(),
  47119. /(semi|static)/.test(i.mode) && (t.manager.ids[n.id] = n.identifier));
  47120. };
  47121. Ht.prototype.onDestroyed = function (e, t) {
  47122. var i = this;
  47123. i.nipples.indexOf(t) >= 0 && i.nipples.splice(i.nipples.indexOf(t), 1),
  47124. i.actives.indexOf(t) >= 0 && i.actives.splice(i.actives.indexOf(t), 1),
  47125. i.idles.indexOf(t) >= 0 && i.idles.splice(i.idles.indexOf(t), 1),
  47126. i.ids.indexOf(t.identifier) >= 0 && i.ids.splice(i.ids.indexOf(t.identifier), 1),
  47127. i.manager.removeIdentifier(t.identifier),
  47128. i.manager.unbindDocument();
  47129. };
  47130. Ht.prototype.destroy = function () {
  47131. var e = this;
  47132. e.unbindEvt(e.options.zone, 'start'),
  47133. e.nipples.forEach(function (i) {
  47134. i.destroy();
  47135. });
  47136. for (var t in e.pressureIntervals) e.pressureIntervals.hasOwnProperty(t) && clearInterval(e.pressureIntervals[t]);
  47137. e.trigger('destroyed', e.nipples), e.manager.unbindDocument(), e.off();
  47138. };
  47139. var W8 = Ht;
  47140. function di(e) {
  47141. var t = this;
  47142. (t.ids = {}), (t.index = 0), (t.collections = []), (t.scroll = fb()), t.config(e), t.prepareCollections();
  47143. var i = function () {
  47144. var s;
  47145. t.collections.forEach(function (n) {
  47146. n.forEach(function (a) {
  47147. (s = a.el.getBoundingClientRect()), (a.position = { x: t.scroll.x + s.left, y: t.scroll.y + s.top });
  47148. });
  47149. });
  47150. };
  47151. if (typeof window > 'u') return t.collections;
  47152. tu(window, 'resize', function () {
  47153. ub(i);
  47154. });
  47155. var r = function () {
  47156. t.scroll = fb();
  47157. };
  47158. return (
  47159. tu(window, 'scroll', function () {
  47160. ub(r);
  47161. }),
  47162. t.collections
  47163. );
  47164. }
  47165. di.prototype = new bv();
  47166. di.constructor = di;
  47167. di.prototype.prepareCollections = function () {
  47168. var e = this;
  47169. (e.collections.create = e.create.bind(e)),
  47170. (e.collections.on = e.on.bind(e)),
  47171. (e.collections.off = e.off.bind(e)),
  47172. (e.collections.destroy = e.destroy.bind(e)),
  47173. (e.collections.get = function (t) {
  47174. var i;
  47175. return (
  47176. e.collections.every(function (r) {
  47177. return (i = r.get(t)), !i;
  47178. }),
  47179. i
  47180. );
  47181. });
  47182. };
  47183. di.prototype.create = function (e) {
  47184. return this.createCollection(e);
  47185. };
  47186. di.prototype.createCollection = function (e) {
  47187. var t = this,
  47188. i = new W8(t, e);
  47189. return t.bindCollection(i), t.collections.push(i), i;
  47190. };
  47191. di.prototype.bindCollection = function (e) {
  47192. var t = this,
  47193. i,
  47194. r = function (s, n) {
  47195. (i = s.type + ' ' + n.id + ':' + s.type), t.trigger(i, n);
  47196. };
  47197. e.on('destroyed', t.onDestroyed.bind(t)),
  47198. e.on('shown hidden rested dir plain', r),
  47199. e.on('dir:up dir:right dir:down dir:left', r),
  47200. e.on('plain:up plain:right plain:down plain:left', r);
  47201. };
  47202. di.prototype.bindDocument = function () {
  47203. var e = this;
  47204. e.binded || (e.bindEvt(document, 'move').bindEvt(document, 'end'), (e.binded = !0));
  47205. };
  47206. di.prototype.unbindDocument = function (e) {
  47207. var t = this;
  47208. (!Object.keys(t.ids).length || e === !0) && (t.unbindEvt(document, 'move').unbindEvt(document, 'end'), (t.binded = !1));
  47209. };
  47210. di.prototype.getIdentifier = function (e) {
  47211. var t;
  47212. return (
  47213. e ? ((t = e.identifier === void 0 ? e.pointerId : e.identifier), t === void 0 && (t = this.latest || 0)) : (t = this.index),
  47214. this.ids[t] === void 0 && ((this.ids[t] = this.index), (this.index += 1)),
  47215. (this.latest = t),
  47216. this.ids[t]
  47217. );
  47218. };
  47219. di.prototype.removeIdentifier = function (e) {
  47220. var t = {};
  47221. for (var i in this.ids)
  47222. if (this.ids[i] === e) {
  47223. (t.id = i), (t.identifier = this.ids[i]), delete this.ids[i];
  47224. break;
  47225. }
  47226. return t;
  47227. };
  47228. di.prototype.onmove = function (e) {
  47229. var t = this;
  47230. return t.onAny('move', e), !1;
  47231. };
  47232. di.prototype.onend = function (e) {
  47233. var t = this;
  47234. return t.onAny('end', e), !1;
  47235. };
  47236. di.prototype.oncancel = function (e) {
  47237. var t = this;
  47238. return t.onAny('end', e), !1;
  47239. };
  47240. di.prototype.onAny = function (e, t) {
  47241. var i = this,
  47242. r,
  47243. s = 'processOn' + e.charAt(0).toUpperCase() + e.slice(1);
  47244. t = CS(t);
  47245. var n = function (o, l, h) {
  47246. h.ids.indexOf(l) >= 0 && (h[s](o), (o._found_ = !0));
  47247. },
  47248. a = function (o) {
  47249. (r = i.getIdentifier(o)), Zm(i.collections, n.bind(null, o, r)), o._found_ || i.removeIdentifier(r);
  47250. };
  47251. return Zm(t, a), !1;
  47252. };
  47253. di.prototype.destroy = function () {
  47254. var e = this;
  47255. e.unbindDocument(!0),
  47256. (e.ids = {}),
  47257. (e.index = 0),
  47258. e.collections.forEach(function (t) {
  47259. t.destroy();
  47260. }),
  47261. e.off();
  47262. };
  47263. di.prototype.onDestroyed = function (e, t) {
  47264. var i = this;
  47265. if (i.collections.indexOf(t) < 0) return !1;
  47266. i.collections.splice(i.collections.indexOf(t), 1);
  47267. };
  47268. var X8 = di,
  47269. mb = new X8(),
  47270. q8 = {
  47271. create: function (e) {
  47272. return mb.create(e);
  47273. },
  47274. factory: mb
  47275. },
  47276. Y8 = Eh(rw());
  47277. function eo(e, t) {
  47278. let i = new Ve();
  47279. if (!e.getAttribute('position')) return i.setAttribute('position', new Ce([], 3)), i.setIndex([]), i;
  47280. let { positions: r, triIndices: s } = ov(e.getAttribute('position'), e.getIndex());
  47281. return i.setAttribute('position', new Ce(r, 3)), i.setIndex(s), t && i.applyMatrix4(t), i;
  47282. }
  47283. var Q8 = new ve(),
  47284. Z8 = new ve(),
  47285. $r = [
  47286. [0, 0, 0],
  47287. [0, 0, 0],
  47288. [0, 0, 0]
  47289. ];
  47290. function OS(e) {
  47291. let t = e.elements;
  47292. ($r[0][0] = t[0]),
  47293. ($r[0][1] = t[4]),
  47294. ($r[0][2] = t[8]),
  47295. ($r[1][0] = t[1]),
  47296. ($r[1][1] = t[5]),
  47297. ($r[1][2] = t[9]),
  47298. ($r[2][0] = t[2]),
  47299. ($r[2][1] = t[6]),
  47300. ($r[2][2] = t[10]);
  47301. let { u: i, v: r } = (0, Y8.SVD)($r),
  47302. s = Q8.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),
  47303. n = Z8.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);
  47304. return s.multiply(n.transpose());
  47305. }
  47306. var K8 = class extends kw {
  47307. constructor() {
  47308. super(), this.layers.enable(3), this.layers.enable(8);
  47309. }
  47310. setFromCamera(e, t) {
  47311. t.isOrthographicCamera
  47312. ? (this.ray.origin.set(e.x, e.y, -1).unproject(t),
  47313. this.ray.direction.set(0, 0, -1).transformDirection(t.matrixWorld),
  47314. (this.camera = t))
  47315. : t.isPerspectiveCamera
  47316. ? (this.ray.origin.set(e.x, e.y, -1).unproject(t),
  47317. this.ray.direction.set(e.x, e.y, 0.5).unproject(t).sub(this.ray.origin).normalize(),
  47318. (this.camera = t))
  47319. : console.error('Raycaster: Unsupported camera type.');
  47320. }
  47321. intersectVisibleObjects(e, t = !0, i = []) {
  47322. return (
  47323. e.forEach((r) => {
  47324. r.visible && this.intersectObject(r, t, i);
  47325. }),
  47326. i
  47327. );
  47328. }
  47329. createRaycastLineHelper() {
  47330. let e = new Rn({ color: 65280, linewidth: 10 }),
  47331. t = new E(this.ray.origin.x, this.ray.origin.y, this.ray.origin.z),
  47332. i = new E(this.ray.direction.x, this.ray.direction.y, this.ray.direction.z),
  47333. r = this.camera.far - this.camera.near,
  47334. s = new E().addVectors(t, i.multiplyScalar(r)),
  47335. n = new Ve();
  47336. return n.setFromPoints([t, s]), new vd(n, e);
  47337. }
  47338. },
  47339. IS = (e) => e instanceof Wm || e instanceof Ro;
  47340. function J8(e, t) {
  47341. return e.distance - t.distance;
  47342. }
  47343. function RS(e, t, i) {
  47344. if (!(!mn(t) || !t.visible)) {
  47345. js(t) && t.raycast(e, i);
  47346. for (let r of t.children) RS(e, r, i);
  47347. }
  47348. }
  47349. function Km(e, t, i) {
  47350. if (!i.some((s) => iu(e, s) !== void 0)) return [];
  47351. let r = [];
  47352. return t.children.forEach((s) => RS(e, s, r)), r.sort(J8), r;
  47353. }
  47354. function Jm(e) {
  47355. let t = [];
  47356. if (e.length) {
  47357. let i = e[0].object;
  47358. mn(i) && t.push(i);
  47359. let r = i.parent;
  47360. for (; r; ) IS(r) && t.push(r), (r = r.parent);
  47361. }
  47362. return t;
  47363. }
  47364. function iu(e, t) {
  47365. if (js(t)) {
  47366. if (t.visible) {
  47367. let i = [];
  47368. return t.raycast(e, i), i.length ? i[0] : void 0;
  47369. }
  47370. } else if (IS(t)) return BS(e, t);
  47371. }
  47372. function BS(e, t) {
  47373. if (!(!mn(t) || !t.visible)) {
  47374. if (js(t)) {
  47375. let i = [];
  47376. if ((t.raycast(e, i), i.length)) return i[0];
  47377. }
  47378. for (let i of t.children) {
  47379. let r = BS(e, i);
  47380. if (r) return r;
  47381. }
  47382. }
  47383. }
  47384. function $8(e, t, i) {
  47385. return { x: ((e - (i.left + window.scrollX)) / i.width) * 2 - 1, y: -((t - (i.top + window.scrollY)) / i.height) * 2 + 1 };
  47386. }
  47387. var ej = class {
  47388. constructor(e, t, i, r, s, n) {
  47389. (this.isExport = n),
  47390. (this.raycaster = new K8()),
  47391. (this.raycasterNeedsUpdate = !0),
  47392. (this.stopRaycast = !1),
  47393. (this._useWindowEvents = !1),
  47394. (this.sharedAssets = new Eu(Wd.emptyData())),
  47395. (this.scene = new sl({ ...Em.defaultData }, this.sharedAssets)),
  47396. (this.camera = new Gi()),
  47397. (this.renderer = e),
  47398. (this._useWindowEvents = t.data.publish.mouseEventTarget === 'window'),
  47399. (this.domElement = e.domElement),
  47400. (this.eventElement = this._useWindowEvents ? window : e.domElement),
  47401. (this.stopRaycast = s),
  47402. (this.sharedAssets = r),
  47403. (this.scene = t),
  47404. (this.camera = i);
  47405. }
  47406. set useWindowEvents(e) {
  47407. (this._useWindowEvents = e), (this.eventElement = e ? window : this.renderer.domElement);
  47408. }
  47409. get useWindowEvents() {
  47410. return this._useWindowEvents;
  47411. }
  47412. updateRaycaster(e) {
  47413. if (!this.raycasterNeedsUpdate) return;
  47414. this.raycasterNeedsUpdate = !1;
  47415. let { pageX: t, pageY: i } = e.touches !== void 0 && e.touches.length > 0 ? e.touches[0] : e,
  47416. r = this.domElement.getBoundingClientRect();
  47417. this.raycaster.setFromCamera($8(t, i, r), this.camera);
  47418. }
  47419. },
  47420. zS = ((e) => (
  47421. (e[(e.keydown = 0)] = 'keydown'),
  47422. (e[(e.keyup = 1)] = 'keyup'),
  47423. (e[(e.pointerdown = 2)] = 'pointerdown'),
  47424. (e[(e.pointerup = 3)] = 'pointerup'),
  47425. (e[(e.pointermove = 4)] = 'pointermove'),
  47426. (e[(e.wheel = 5)] = 'wheel'),
  47427. (e[(e.scroll = 6)] = 'scroll'),
  47428. e
  47429. ))(zS || {}),
  47430. zn = class {
  47431. constructor(e) {
  47432. (this.eventContext = e), (this.domEventsNeeded = new Set()), (this.hasVideoAction = !1);
  47433. }
  47434. connect() {}
  47435. disconnect() {}
  47436. },
  47437. NS = new Map(),
  47438. ih = new Map(),
  47439. bo = class {
  47440. constructor(e, t, i, r) {
  47441. this.data = t;
  47442. let { audio: s, volume: n, delay: a, loop: o } = t;
  47443. if (!s) throw new Error('Missing property');
  47444. let l = typeof s == 'string' ? r.getAudio(s).src : s.data;
  47445. (this.audioPlayer = new Yl({ src: l, volume: n, delay: a, loop: o })),
  47446. ih.has(i.uuid) ? ih.get(i.uuid).push(this) : ih.set(i.uuid, [this]),
  47447. NS.set(e, this);
  47448. }
  47449. playByToggle() {
  47450. this.data.toggle === 'stop'
  47451. ? this.audioPlayer.status === 'playing'
  47452. ? this.audioPlayer.stop()
  47453. : (this.audioPlayer.stop(), this.audioPlayer.play())
  47454. : this.data.toggle === 'pause'
  47455. ? this.audioPlayer.status === 'playing'
  47456. ? this.audioPlayer.pause()
  47457. : this.audioPlayer.play()
  47458. : (this.audioPlayer.stop(), this.audioPlayer.play());
  47459. }
  47460. dispose() {
  47461. this.audioPlayer.stop();
  47462. }
  47463. },
  47464. $m = class {
  47465. constructor(e) {
  47466. this.data = e;
  47467. }
  47468. dispatch() {
  47469. this.data.playAudio
  47470. ? this.pauseAudio(this.data.playAudio)
  47471. : this.data.object
  47472. ? this.pauseAllAudiosFromObject(this.data.object)
  47473. : this.pauseAllAudios();
  47474. }
  47475. pauseAudio(e) {
  47476. let t = NS.get(e);
  47477. !t ||
  47478. (this.data.delay > 0
  47479. ? (this.disposeDelay(),
  47480. (this.timeoutId = window.setTimeout(() => {
  47481. t.audioPlayer[this.data.interaction](), this.disposeDelay();
  47482. }, this.data.delay)))
  47483. : t.audioPlayer[this.data.interaction]());
  47484. }
  47485. pauseAllAudiosFromObject(e) {
  47486. let t = ih.get(e);
  47487. !t?.length ||
  47488. (this.data.delay > 0
  47489. ? (this.disposeDelay(),
  47490. (this.timeoutId = window.setTimeout(() => {
  47491. t.forEach((i) => i.audioPlayer[this.data.interaction]()), this.disposeDelay();
  47492. }, this.data.delay)))
  47493. : t.forEach((i) => i.audioPlayer[this.data.interaction]()));
  47494. }
  47495. pauseAllAudios() {
  47496. let e = [...ih.values()];
  47497. !e.length ||
  47498. (this.data.delay > 0
  47499. ? (this.disposeDelay(),
  47500. (this.timeoutId = window.setTimeout(() => {
  47501. e.forEach((t) => {
  47502. t.forEach((i) => {
  47503. i.audioPlayer[this.data.interaction]();
  47504. });
  47505. }),
  47506. this.disposeDelay();
  47507. }, this.data.delay)))
  47508. : e.forEach((t) => {
  47509. t.forEach((i) => {
  47510. i.audioPlayer[this.data.interaction]();
  47511. });
  47512. }));
  47513. }
  47514. disposeDelay() {
  47515. clearTimeout(this.timeoutId), delete this.timeoutId;
  47516. }
  47517. dispose() {
  47518. clearTimeout(this.timeoutId), delete this.timeoutId;
  47519. }
  47520. },
  47521. wo = class {
  47522. constructor(e, t, i, r) {
  47523. if (((this.data = t), t.interaction === 'play')) this.interaction = new bo(e, t, i, r);
  47524. else if (t.interaction === 'pause' || t.interaction === 'stop') this.interaction = new $m(t);
  47525. else throw new Error('Missing property');
  47526. }
  47527. dispatchBasic() {
  47528. this.interaction instanceof bo ? this.interaction.playByToggle() : this.interaction.dispatch();
  47529. }
  47530. dispatchConditional() {
  47531. this.interaction instanceof bo ? this.interaction.audioPlayer.play() : this.interaction.dispatch();
  47532. }
  47533. dispatchGameControl(e) {
  47534. this.interaction instanceof bo && (e === 'start' ? this.interaction.audioPlayer.play() : this.interaction.audioPlayer.stop());
  47535. }
  47536. dispose() {
  47537. this.interaction.dispose();
  47538. }
  47539. };
  47540. function tj(e, t) {
  47541. let i = e.material.layers.find((r) => r.uuid === t);
  47542. return i.color.texture.image.img instanceof HTMLVideoElement ? i.color.texture.image.img : void 0;
  47543. }
  47544. var US = new Map(),
  47545. rh = new Map(),
  47546. sh = class {
  47547. constructor(e, t, i) {
  47548. (this.data = t), (this.delay = 0), (this.status = 'stopped');
  47549. let { layerId: r, loop: s, volume: n, delay: a } = t;
  47550. if (((this.object = i), r === void 0)) throw new Error('Missing property');
  47551. let o = tj(i, r);
  47552. if (o)
  47553. (this.videoElement = o),
  47554. (this.videoElement.loop = s === 1 / 0),
  47555. (this.videoElement.autoplay = !0),
  47556. n !== void 0 && (this.videoElement.volume = n);
  47557. else throw new Error('Missing property');
  47558. a !== void 0 && (this.delay = a), rh.has(i.uuid) ? rh.get(i.uuid).push(this) : rh.set(i.uuid, [this]), US.set(e, this), this.pause();
  47559. }
  47560. mute() {
  47561. this.videoElement.muted = !0;
  47562. }
  47563. unMute() {
  47564. this.videoElement.muted = !1;
  47565. }
  47566. play(e) {
  47567. let t = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
  47568. e
  47569. ? (this.mute(), (this.delay += 150))
  47570. : t
  47571. ? (this.mute(),
  47572. window.setTimeout(() => {
  47573. this.unMute();
  47574. }, 100))
  47575. : this.unMute(),
  47576. (this.delayTimerId = window.setTimeout(() => {
  47577. this.videoElement.play(), this.clearDelay();
  47578. }, this.delay)),
  47579. (this.status = 'playing');
  47580. }
  47581. clearDelay() {
  47582. this.delayTimerId && (clearTimeout(this.delayTimerId), delete this.delayTimerId);
  47583. }
  47584. pause() {
  47585. this.videoElement.pause(), (this.status = 'paused');
  47586. }
  47587. stop() {
  47588. this.videoElement.pause(), (this.videoElement.currentTime = 0), (this.status = 'stopped'), this.clearDelay();
  47589. }
  47590. playByToggle() {
  47591. this.data.toggle === 'stop'
  47592. ? this.status === 'playing'
  47593. ? this.stop()
  47594. : (this.stop(), this.play())
  47595. : this.data.toggle === 'pause'
  47596. ? this.status === 'playing'
  47597. ? this.pause()
  47598. : this.play()
  47599. : (this.stop(), this.play());
  47600. }
  47601. dispose() {
  47602. this.stop(), (this.videoElement.muted = !0);
  47603. }
  47604. },
  47605. eg = class {
  47606. constructor(e) {
  47607. this.data = e;
  47608. }
  47609. dispatch() {
  47610. this.data.playVideo
  47611. ? this.pauseVideo(this.data.playVideo)
  47612. : this.data.object
  47613. ? this.pauseAllVideosFromObject(this.data.object)
  47614. : this.pauseAllVideos();
  47615. }
  47616. pauseVideo(e) {
  47617. let t = US.get(e);
  47618. !t ||
  47619. (this.data.delay > 0
  47620. ? (this.disposeDelay(),
  47621. (this.timeoutId = window.setTimeout(() => {
  47622. t[this.data.interaction](), this.disposeDelay();
  47623. }, this.data.delay)))
  47624. : t[this.data.interaction]());
  47625. }
  47626. pauseAllVideosFromObject(e) {
  47627. let t = rh.get(e);
  47628. !t?.length ||
  47629. (this.data.delay > 0
  47630. ? (this.disposeDelay(),
  47631. (this.timeoutId = window.setTimeout(() => {
  47632. t.forEach((i) => i[this.data.interaction]()), this.disposeDelay();
  47633. }, this.data.delay)))
  47634. : t.forEach((i) => i[this.data.interaction]()));
  47635. }
  47636. pauseAllVideos() {
  47637. let e = [...rh.values()];
  47638. !e.length ||
  47639. (this.data.delay > 0
  47640. ? (this.disposeDelay(),
  47641. (this.timeoutId = window.setTimeout(() => {
  47642. e.forEach((t) => {
  47643. t.forEach((i) => {
  47644. i[this.data.interaction]();
  47645. });
  47646. }),
  47647. this.disposeDelay();
  47648. }, this.data.delay)))
  47649. : e.forEach((t) => {
  47650. t.forEach((i) => {
  47651. i[this.data.interaction]();
  47652. });
  47653. }));
  47654. }
  47655. disposeDelay() {
  47656. clearTimeout(this.timeoutId), delete this.timeoutId;
  47657. }
  47658. dispose() {
  47659. clearTimeout(this.timeoutId), delete this.timeoutId;
  47660. }
  47661. },
  47662. ru = class {
  47663. constructor(e, t, i) {
  47664. if (((this.data = t), t.interaction === 'play')) this.interaction = new sh(e, t, i);
  47665. else if (t.interaction === 'pause' || t.interaction === 'stop') this.interaction = new eg(t);
  47666. else throw new Error('Missing property');
  47667. }
  47668. dispatchBasic() {
  47669. this.interaction instanceof sh ? this.interaction.playByToggle() : this.interaction.dispatch();
  47670. }
  47671. dispatchConditional() {
  47672. this.interaction instanceof sh ? this.interaction.play() : this.interaction.dispatch();
  47673. }
  47674. dispose() {
  47675. this.interaction.dispose();
  47676. }
  47677. },
  47678. ij = 'text/plain',
  47679. rj = 'us-ascii',
  47680. gb = (e, t) => t.some((i) => (i instanceof RegExp ? i.test(e) : i === e)),
  47681. sj = (e, { stripHash: t }) => {
  47682. let i = /^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);
  47683. if (!i) throw new Error(`Invalid URL: ${e}`);
  47684. let { type: r, data: s, hash: n } = i.groups,
  47685. a = r.split(';');
  47686. n = t ? '' : n;
  47687. let o = !1;
  47688. a[a.length - 1] === 'base64' && (a.pop(), (o = !0));
  47689. let l = (a.shift() || '').toLowerCase(),
  47690. h = [
  47691. ...a
  47692. .map((u) => {
  47693. let [c, d = ''] = u.split('=').map((p) => p.trim());
  47694. return c === 'charset' && ((d = d.toLowerCase()), d === rj) ? '' : `${c}${d ? `=${d}` : ''}`;
  47695. })
  47696. .filter(Boolean)
  47697. ];
  47698. return (
  47699. o && h.push('base64'), (h.length > 0 || (l && l !== ij)) && h.unshift(l), `data:${h.join(';')},${o ? s.trim() : s}${n ? `#${n}` : ''}`
  47700. );
  47701. };
  47702. function nj(e, t) {
  47703. if (
  47704. ((t = {
  47705. defaultProtocol: 'http:',
  47706. normalizeProtocol: !0,
  47707. forceHttp: !1,
  47708. forceHttps: !1,
  47709. stripAuthentication: !0,
  47710. stripHash: !1,
  47711. stripTextFragment: !0,
  47712. stripWWW: !0,
  47713. removeQueryParameters: [/^utm_\w+/i],
  47714. removeTrailingSlash: !0,
  47715. removeSingleSlash: !0,
  47716. removeDirectoryIndex: !1,
  47717. sortQueryParameters: !0,
  47718. ...t
  47719. }),
  47720. (e = e.trim()),
  47721. /^data:/i.test(e))
  47722. )
  47723. return sj(e, t);
  47724. if (/^view-source:/i.test(e)) throw new Error('`view-source:` is not supported as it is a non-standard protocol');
  47725. let i = e.startsWith('//');
  47726. (!i && /^\.*\//.test(e)) || (e = e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//, t.defaultProtocol));
  47727. let r = new URL(e);
  47728. if (t.forceHttp && t.forceHttps) throw new Error('The `forceHttp` and `forceHttps` options cannot be used together');
  47729. if (
  47730. (t.forceHttp && r.protocol === 'https:' && (r.protocol = 'http:'),
  47731. t.forceHttps && r.protocol === 'http:' && (r.protocol = 'https:'),
  47732. t.stripAuthentication && ((r.username = ''), (r.password = '')),
  47733. t.stripHash ? (r.hash = '') : t.stripTextFragment && (r.hash = r.hash.replace(/#?:~:text.*?$/i, '')),
  47734. r.pathname)
  47735. ) {
  47736. let n = /\b[a-z][a-z\d+\-.]{1,50}:\/\//g,
  47737. a = 0,
  47738. o = '';
  47739. for (;;) {
  47740. let h = n.exec(r.pathname);
  47741. if (!h) break;
  47742. let u = h[0],
  47743. c = h.index,
  47744. d = r.pathname.slice(a, c);
  47745. (o += d.replace(/\/{2,}/g, '/')), (o += u), (a = c + u.length);
  47746. }
  47747. let l = r.pathname.slice(a, r.pathname.length);
  47748. (o += l.replace(/\/{2,}/g, '/')), (r.pathname = o);
  47749. }
  47750. if (r.pathname)
  47751. try {
  47752. r.pathname = decodeURI(r.pathname);
  47753. } catch {}
  47754. if (
  47755. (t.removeDirectoryIndex === !0 && (t.removeDirectoryIndex = [/^index\.[a-z]+$/]),
  47756. Array.isArray(t.removeDirectoryIndex) && t.removeDirectoryIndex.length > 0)
  47757. ) {
  47758. let n = r.pathname.split('/'),
  47759. a = n[n.length - 1];
  47760. gb(a, t.removeDirectoryIndex) && ((n = n.slice(0, -1)), (r.pathname = n.slice(1).join('/') + '/'));
  47761. }
  47762. if (
  47763. (r.hostname &&
  47764. ((r.hostname = r.hostname.replace(/\.$/, '')),
  47765. t.stripWWW &&
  47766. /^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname) &&
  47767. (r.hostname = r.hostname.replace(/^www\./, ''))),
  47768. Array.isArray(t.removeQueryParameters))
  47769. )
  47770. for (let n of [...r.searchParams.keys()]) gb(n, t.removeQueryParameters) && r.searchParams.delete(n);
  47771. if ((t.removeQueryParameters === !0 && (r.search = ''), t.sortQueryParameters)) {
  47772. r.searchParams.sort();
  47773. try {
  47774. r.search = decodeURIComponent(r.search);
  47775. } catch {}
  47776. }
  47777. t.removeTrailingSlash && (r.pathname = r.pathname.replace(/\/$/, ''));
  47778. let s = e;
  47779. return (
  47780. (e = r.toString()),
  47781. !t.removeSingleSlash && r.pathname === '/' && !s.endsWith('/') && r.hash === '' && (e = e.replace(/\/$/, '')),
  47782. (t.removeTrailingSlash || r.pathname === '/') && r.hash === '' && t.removeSingleSlash && (e = e.replace(/\/$/, '')),
  47783. i && !t.normalizeProtocol && (e = e.replace(/^http:\/\//, '//')),
  47784. t.stripProtocol && (e = e.replace(/^(?:https?:)?\/\//, '')),
  47785. e
  47786. );
  47787. }
  47788. var aj = class {
  47789. constructor({ url: e, context: t }, i) {
  47790. if (((this.managers = i), !e)) throw new Error('Missing property');
  47791. (this.url = e.startsWith('mailto:') ? e : nj(e, { removeTrailingSlash: !1, removeSingleSlash: !1 })), (this.context = t ?? 'tab');
  47792. }
  47793. dispatch() {
  47794. Mm
  47795. ? window.location.assign(this.url)
  47796. : (this.context === 'tab'
  47797. ? window.open(this.url, '_blank')
  47798. : this.context === 'window'
  47799. ? window.open(this.url, '_blank', `width=${window.innerWidth}, height=${window.innerHeight}`)
  47800. : window.open(this.url, '_parent'),
  47801. this.managers.controlsManager.orbitControls?.onPointerUp(Qe[0]),
  47802. tU());
  47803. }
  47804. },
  47805. oj = class {
  47806. constructor(e, t, i, r) {
  47807. (this.scene = t), (this.sharedAssets = i), (this.sceneData = e), (this.managers = r);
  47808. }
  47809. dispatch() {
  47810. i2(this.sceneData, this.scene, this.sharedAssets, !0),
  47811. this.managers.eventManager?.reset(),
  47812. this.managers.controlsManager.orbitControls?.reset(),
  47813. this.managers.controlsManager?.gameControls.forEach((e) => e.reset(!0));
  47814. }
  47815. },
  47816. FS = {
  47817. update: null,
  47818. begin: null,
  47819. loopBegin: null,
  47820. changeBegin: null,
  47821. change: null,
  47822. changeComplete: null,
  47823. timelineChangeComplete: null,
  47824. loopComplete: null,
  47825. complete: null,
  47826. loop: 1,
  47827. direction: 'normal',
  47828. autoplay: !0,
  47829. timelineOffset: 0,
  47830. rewind: !0
  47831. },
  47832. wv = { duration: 1e3, delay: 0, endDelay: 0, startOnceDelay: 0, pingPongDelayCorrection: 0, easing: 'easeOutElastic(1, .5)', round: 0 },
  47833. lj = [
  47834. 'translateX',
  47835. 'translateY',
  47836. 'translateZ',
  47837. 'rotate',
  47838. 'rotateX',
  47839. 'rotateY',
  47840. 'rotateZ',
  47841. 'scale',
  47842. 'scaleX',
  47843. 'scaleY',
  47844. 'scaleZ',
  47845. 'skew',
  47846. 'skewX',
  47847. 'skewY',
  47848. 'perspective',
  47849. 'matrix',
  47850. 'matrix3d'
  47851. ],
  47852. su = { CSS: {}, springs: {} };
  47853. function ds(e, t, i) {
  47854. return Math.min(Math.max(e, t), i);
  47855. }
  47856. function nh(e, t) {
  47857. return e.indexOf(t) > -1;
  47858. }
  47859. function vf(e, t) {
  47860. return e.apply(null, t);
  47861. }
  47862. var je = {
  47863. arr: function (e) {
  47864. return Array.isArray(e);
  47865. },
  47866. obj: function (e) {
  47867. return nh(Object.prototype.toString.call(e), 'Object');
  47868. },
  47869. pth: function (e) {
  47870. return je.obj(e) && e.hasOwnProperty('totalLength');
  47871. },
  47872. svg: function (e) {
  47873. return e instanceof SVGElement;
  47874. },
  47875. inp: function (e) {
  47876. return e instanceof HTMLInputElement;
  47877. },
  47878. dom: function (e) {
  47879. return !('isNode' in e) && (e.nodeType || je.svg(e));
  47880. },
  47881. str: function (e) {
  47882. return typeof e == 'string';
  47883. },
  47884. fnc: function (e) {
  47885. return typeof e == 'function';
  47886. },
  47887. und: function (e) {
  47888. return typeof e > 'u';
  47889. },
  47890. hex: function (e) {
  47891. return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e);
  47892. },
  47893. rgb: function (e) {
  47894. return /^rgb/.test(e);
  47895. },
  47896. hsl: function (e) {
  47897. return /^hsl/.test(e);
  47898. },
  47899. col: function (e) {
  47900. return je.hex(e) || je.rgb(e) || je.hsl(e);
  47901. },
  47902. key: function (e) {
  47903. return !FS.hasOwnProperty(e) && !wv.hasOwnProperty(e) && e !== 'targets' && e !== 'keyframes';
  47904. }
  47905. };
  47906. function kS(e) {
  47907. var t = /\(([^)]+)\)/.exec(e);
  47908. return t
  47909. ? t[1].split(',').map(function (i) {
  47910. return parseFloat(i);
  47911. })
  47912. : [];
  47913. }
  47914. function jS(e, t) {
  47915. var i = kS(e),
  47916. r = ds(je.und(i[0]) ? 1 : i[0], 0.1, 100),
  47917. s = ds(je.und(i[1]) ? 100 : i[1], 0.1, 100),
  47918. n = ds(je.und(i[2]) ? 10 : i[2], 0.1, 100),
  47919. a = ds(je.und(i[3]) ? 0 : i[3], 0.1, 100),
  47920. o = Math.sqrt(s / r),
  47921. l = n / (2 * Math.sqrt(s * r)),
  47922. h = l < 1 ? o * Math.sqrt(1 - l * l) : 0,
  47923. u = 1,
  47924. c = l < 1 ? (l * o + -a) / h : -a + o;
  47925. function d(f) {
  47926. var g = t ? (t * f) / 1e3 : f;
  47927. return (
  47928. l < 1 ? (g = Math.exp(-g * l * o) * (u * Math.cos(h * g) + c * Math.sin(h * g))) : (g = (u + c * g) * Math.exp(-g * o)),
  47929. f === 0 || f === 1 ? f : 1 - g
  47930. );
  47931. }
  47932. function p() {
  47933. var f = su.springs[e];
  47934. if (f) return f;
  47935. for (var g = 1 / 6, m = 0, v = 0; ; )
  47936. if (((m += g), d(m) === 1)) {
  47937. if ((v++, v >= 16)) break;
  47938. } else v = 0;
  47939. var y = m * g * 1e3;
  47940. return (su.springs[e] = y), y;
  47941. }
  47942. return t ? d : p;
  47943. }
  47944. function hj(e) {
  47945. return (
  47946. e === void 0 && (e = 10),
  47947. function (t) {
  47948. return Math.ceil(ds(t, 1e-6, 1) * e) * (1 / e);
  47949. }
  47950. );
  47951. }
  47952. var cj = (function () {
  47953. var e = 11,
  47954. t = 1 / (e - 1);
  47955. function i(u, c) {
  47956. return 1 - 3 * c + 3 * u;
  47957. }
  47958. function r(u, c) {
  47959. return 3 * c - 6 * u;
  47960. }
  47961. function s(u) {
  47962. return 3 * u;
  47963. }
  47964. function n(u, c, d) {
  47965. return ((i(c, d) * u + r(c, d)) * u + s(c)) * u;
  47966. }
  47967. function a(u, c, d) {
  47968. return 3 * i(c, d) * u * u + 2 * r(c, d) * u + s(c);
  47969. }
  47970. function o(u, c, d, p, f) {
  47971. var g,
  47972. m,
  47973. v = 0;
  47974. do {
  47975. (m = c + (d - c) / 2), (g = n(m, p, f) - u), g > 0 ? (d = m) : (c = m);
  47976. } while (Math.abs(g) > 1e-7 && ++v < 10);
  47977. return m;
  47978. }
  47979. function l(u, c, d, p) {
  47980. for (var f = 0; f < 4; ++f) {
  47981. var g = a(c, d, p);
  47982. if (g === 0) return c;
  47983. var m = n(c, d, p) - u;
  47984. c -= m / g;
  47985. }
  47986. return c;
  47987. }
  47988. function h(u, c, d, p) {
  47989. if (!(0 <= u && u <= 1 && 0 <= d && d <= 1)) return;
  47990. var f = new Float32Array(e);
  47991. if (u !== c || d !== p) for (var g = 0; g < e; ++g) f[g] = n(g * t, u, d);
  47992. function m(v) {
  47993. for (var y = 0, b = 1, x = e - 1; b !== x && f[b] <= v; ++b) y += t;
  47994. --b;
  47995. var w = (v - f[b]) / (f[b + 1] - f[b]),
  47996. A = y + w * t,
  47997. S = a(A, u, d);
  47998. return S >= 0.001 ? l(v, A, u, d) : S === 0 ? A : o(v, y, y + t, u, d);
  47999. }
  48000. return function (v) {
  48001. return (u === c && d === p) || v === 0 || v === 1 ? v : n(m(v), c, p);
  48002. };
  48003. }
  48004. return h;
  48005. })(),
  48006. GS = (function () {
  48007. var e = {
  48008. linear: function () {
  48009. return function (r) {
  48010. return r;
  48011. };
  48012. }
  48013. },
  48014. t = {
  48015. Sine: function () {
  48016. return function (r) {
  48017. return 1 - Math.cos((r * Math.PI) / 2);
  48018. };
  48019. },
  48020. Circ: function () {
  48021. return function (r) {
  48022. return 1 - Math.sqrt(1 - r * r);
  48023. };
  48024. },
  48025. Back: function () {
  48026. return function (r) {
  48027. return r * r * (3 * r - 2);
  48028. };
  48029. },
  48030. Bounce: function () {
  48031. return function (r) {
  48032. for (var s, n = 4; r < ((s = Math.pow(2, --n)) - 1) / 11; );
  48033. return 1 / Math.pow(4, 3 - n) - 7.5625 * Math.pow((s * 3 - 2) / 22 - r, 2);
  48034. };
  48035. },
  48036. Elastic: function (r, s) {
  48037. r === void 0 && (r = 1), s === void 0 && (s = 0.5);
  48038. var n = ds(r, 1, 10),
  48039. a = ds(s, 0.1, 2);
  48040. return function (o) {
  48041. return o === 0 || o === 1
  48042. ? o
  48043. : -n * Math.pow(2, 10 * (o - 1)) * Math.sin(((o - 1 - (a / (Math.PI * 2)) * Math.asin(1 / n)) * (Math.PI * 2)) / a);
  48044. };
  48045. }
  48046. },
  48047. i = ['Quad', 'Cubic', 'Quart', 'Quint', 'Expo'];
  48048. return (
  48049. i.forEach(function (r, s) {
  48050. t[r] = function () {
  48051. return function (n) {
  48052. return Math.pow(n, s + 2);
  48053. };
  48054. };
  48055. }),
  48056. Object.keys(t).forEach(function (r) {
  48057. var s = t[r];
  48058. (e['easeIn' + r] = s),
  48059. (e['easeOut' + r] = function (n, a) {
  48060. return function (o) {
  48061. return 1 - s(n, a)(1 - o);
  48062. };
  48063. }),
  48064. (e['easeInOut' + r] = function (n, a) {
  48065. return function (o) {
  48066. return o < 0.5 ? s(n, a)(o * 2) / 2 : 1 - s(n, a)(o * -2 + 2) / 2;
  48067. };
  48068. });
  48069. }),
  48070. e
  48071. );
  48072. })();
  48073. function _v(e, t) {
  48074. if (je.fnc(e)) return e;
  48075. var i = e.split('(')[0],
  48076. r = GS[i],
  48077. s = kS(e);
  48078. switch (i) {
  48079. case 'spring':
  48080. return jS(e, t);
  48081. case 'cubicBezier':
  48082. return vf(cj, s);
  48083. case 'steps':
  48084. return vf(hj, s);
  48085. default:
  48086. return vf(r, s);
  48087. }
  48088. }
  48089. function VS(e) {
  48090. try {
  48091. var t = document.querySelectorAll(e);
  48092. return t;
  48093. } catch {
  48094. return;
  48095. }
  48096. }
  48097. function Pu(e, t) {
  48098. for (var i = e.length, r = arguments.length >= 2 ? arguments[1] : void 0, s = [], n = 0; n < i; n++)
  48099. if (n in e) {
  48100. var a = e[n];
  48101. t.call(r, a, n, e) && s.push(a);
  48102. }
  48103. return s;
  48104. }
  48105. function Du(e) {
  48106. return e.reduce(function (t, i) {
  48107. return t.concat(je.arr(i) ? Du(i) : i);
  48108. }, []);
  48109. }
  48110. function vb(e) {
  48111. return je.arr(e) ? e : (je.str(e) && (e = VS(e) || e), e instanceof NodeList || e instanceof HTMLCollection ? [].slice.call(e) : [e]);
  48112. }
  48113. function Av(e, t) {
  48114. return e.some(function (i) {
  48115. return i === t;
  48116. });
  48117. }
  48118. function Sv(e) {
  48119. var t = {};
  48120. for (var i in e) t[i] = e[i];
  48121. return t;
  48122. }
  48123. function tg(e, t) {
  48124. var i = Sv(e);
  48125. for (var r in e) i[r] = t.hasOwnProperty(r) ? t[r] : e[r];
  48126. return i;
  48127. }
  48128. function Lu(e, t) {
  48129. var i = Sv(e);
  48130. for (var r in t) i[r] = je.und(e[r]) ? t[r] : e[r];
  48131. return i;
  48132. }
  48133. function dj(e) {
  48134. var t = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);
  48135. return t ? 'rgba(' + t[1] + ',1)' : e;
  48136. }
  48137. function uj(e) {
  48138. var t = /^#?([a-f\d])([a-f\d])([a-f\d])$/i,
  48139. i = e.replace(t, function (o, l, h, u) {
  48140. return l + l + h + h + u + u;
  48141. }),
  48142. r = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),
  48143. s = parseInt(r[1], 16),
  48144. n = parseInt(r[2], 16),
  48145. a = parseInt(r[3], 16);
  48146. return 'rgba(' + s + ',' + n + ',' + a + ',1)';
  48147. }
  48148. function pj(e) {
  48149. var t = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),
  48150. i = parseInt(t[1], 10) / 360,
  48151. r = parseInt(t[2], 10) / 100,
  48152. s = parseInt(t[3], 10) / 100,
  48153. n = t[4] || 1;
  48154. function a(d, p, f) {
  48155. return (
  48156. f < 0 && (f += 1), f > 1 && (f -= 1), f < 1 / 6 ? d + (p - d) * 6 * f : f < 1 / 2 ? p : f < 2 / 3 ? d + (p - d) * (2 / 3 - f) * 6 : d
  48157. );
  48158. }
  48159. var o, l, h;
  48160. if (r == 0) o = l = h = s;
  48161. else {
  48162. var u = s < 0.5 ? s * (1 + r) : s + r - s * r,
  48163. c = 2 * s - u;
  48164. (o = a(c, u, i + 1 / 3)), (l = a(c, u, i)), (h = a(c, u, i - 1 / 3));
  48165. }
  48166. return 'rgba(' + o * 255 + ',' + l * 255 + ',' + h * 255 + ',' + n + ')';
  48167. }
  48168. function fj(e) {
  48169. if (je.rgb(e)) return dj(e);
  48170. if (je.hex(e)) return uj(e);
  48171. if (je.hsl(e)) return pj(e);
  48172. }
  48173. function Hs(e) {
  48174. 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);
  48175. if (t) return t[1];
  48176. }
  48177. function mj(e) {
  48178. if (nh(e, 'translate') || e === 'perspective') return 'px';
  48179. if (nh(e, 'rotate') || nh(e, 'skew')) return 'deg';
  48180. }
  48181. function ig(e, t) {
  48182. return je.fnc(e) ? e(t.target, t.id, t.total) : e;
  48183. }
  48184. function us(e, t) {
  48185. return e.getAttribute(t);
  48186. }
  48187. function Mv(e, t, i) {
  48188. var r = Hs(t);
  48189. if (Av([i, 'deg', 'rad', 'turn'], r)) return t;
  48190. var s = su.CSS[t + i];
  48191. if (!je.und(s)) return s;
  48192. var n = 100,
  48193. a = document.createElement(e.tagName),
  48194. o = e.parentNode && e.parentNode !== document ? e.parentNode : document.body;
  48195. o.appendChild(a), (a.style.position = 'absolute'), (a.style.width = n + i);
  48196. var l = n / a.offsetWidth;
  48197. o.removeChild(a);
  48198. var h = l * parseFloat(t);
  48199. return (su.CSS[t + i] = h), h;
  48200. }
  48201. function HS(e, t, i) {
  48202. if (t in e.style) {
  48203. var r = t.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(),
  48204. s = e.style[t] || getComputedStyle(e).getPropertyValue(r) || '0';
  48205. return i ? Mv(e, s, i) : s;
  48206. }
  48207. }
  48208. function Ev(e, t) {
  48209. if (je.dom(e) && !je.inp(e) && (us(e, t) || (je.svg(e) && e[t]))) return 'attribute';
  48210. if (je.dom(e) && Av(lj, t)) return 'transform';
  48211. if (je.dom(e) && t !== 'transform' && HS(e, t)) return 'css';
  48212. if (e[t] != null) return 'object';
  48213. }
  48214. function WS(e) {
  48215. if (je.dom(e)) {
  48216. for (var t = e.style.transform || '', i = /(\w+)\(([^)]*)\)/g, r = new Map(), s; (s = i.exec(t)); ) r.set(s[1], s[2]);
  48217. return r;
  48218. }
  48219. }
  48220. function gj(e, t, i, r) {
  48221. var s = nh(t, 'scale') ? 1 : 0 + mj(t),
  48222. n = WS(e).get(t) || s;
  48223. return i && (i.transforms.list.set(t, n), (i.transforms.last = t)), r ? Mv(e, n, r) : n;
  48224. }
  48225. function Cv(e, t, i, r) {
  48226. switch (Ev(e, t)) {
  48227. case 'transform':
  48228. return gj(e, t, r, i);
  48229. case 'css':
  48230. return HS(e, t, i);
  48231. case 'attribute':
  48232. return us(e, t);
  48233. default:
  48234. return e[t] || 0;
  48235. }
  48236. }
  48237. function Tv(e, t) {
  48238. var i = /^(\*=|\+=|-=)/.exec(e);
  48239. if (!i) return e;
  48240. var r = Hs(e) || 0,
  48241. s = parseFloat(t),
  48242. n = parseFloat(e.replace(i[0], ''));
  48243. switch (i[0][0]) {
  48244. case '+':
  48245. return s + n + r;
  48246. case '-':
  48247. return s - n + r;
  48248. case '*':
  48249. return s * n + r;
  48250. }
  48251. }
  48252. function XS(e, t) {
  48253. if (je.col(e)) return fj(e);
  48254. if (/\s/g.test(e)) return e;
  48255. var i = Hs(e),
  48256. r = i ? e.substr(0, e.length - i.length) : e;
  48257. return t ? r + t : r;
  48258. }
  48259. function Pv(e, t) {
  48260. return Math.sqrt(Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2));
  48261. }
  48262. function vj(e) {
  48263. return Math.PI * 2 * us(e, 'r');
  48264. }
  48265. function yj(e) {
  48266. return us(e, 'width') * 2 + us(e, 'height') * 2;
  48267. }
  48268. function xj(e) {
  48269. return Pv({ x: us(e, 'x1'), y: us(e, 'y1') }, { x: us(e, 'x2'), y: us(e, 'y2') });
  48270. }
  48271. function qS(e) {
  48272. for (var t = e.points, i = 0, r, s = 0; s < t.numberOfItems; s++) {
  48273. var n = t.getItem(s);
  48274. s > 0 && (i += Pv(r, n)), (r = n);
  48275. }
  48276. return i;
  48277. }
  48278. function bj(e) {
  48279. var t = e.points;
  48280. return qS(e) + Pv(t.getItem(t.numberOfItems - 1), t.getItem(0));
  48281. }
  48282. function YS(e) {
  48283. if (e.getTotalLength) return e.getTotalLength();
  48284. switch (e.tagName.toLowerCase()) {
  48285. case 'circle':
  48286. return vj(e);
  48287. case 'rect':
  48288. return yj(e);
  48289. case 'line':
  48290. return xj(e);
  48291. case 'polyline':
  48292. return qS(e);
  48293. case 'polygon':
  48294. return bj(e);
  48295. }
  48296. }
  48297. function wj(e) {
  48298. var t = YS(e);
  48299. return e.setAttribute('stroke-dasharray', t), t;
  48300. }
  48301. function _j(e) {
  48302. for (var t = e.parentNode; je.svg(t) && je.svg(t.parentNode); ) t = t.parentNode;
  48303. return t;
  48304. }
  48305. function QS(e, t) {
  48306. var i = t || {},
  48307. r = i.el || _j(e),
  48308. s = r.getBoundingClientRect(),
  48309. n = us(r, 'viewBox'),
  48310. a = s.width,
  48311. o = s.height,
  48312. l = i.viewBox || (n ? n.split(' ') : [0, 0, a, o]);
  48313. return { el: r, viewBox: l, x: l[0] / 1, y: l[1] / 1, w: a / l[2], h: o / l[3] };
  48314. }
  48315. function Aj(e, t) {
  48316. var i = je.str(e) ? VS(e)[0] : e,
  48317. r = t || 100;
  48318. return function (s) {
  48319. return { property: s, el: i, svg: QS(i), totalLength: YS(i) * (r / 100) };
  48320. };
  48321. }
  48322. function Sj(e, t) {
  48323. function i(o) {
  48324. o === void 0 && (o = 0);
  48325. var l = t + o >= 1 ? t + o : 0;
  48326. return e.el.getPointAtLength(l);
  48327. }
  48328. var r = QS(e.el, e.svg),
  48329. s = i(),
  48330. n = i(-1),
  48331. a = i(1);
  48332. switch (e.property) {
  48333. case 'x':
  48334. return (s.x - r.x) * r.w;
  48335. case 'y':
  48336. return (s.y - r.y) * r.h;
  48337. case 'angle':
  48338. return (Math.atan2(a.y - n.y, a.x - n.x) * 180) / Math.PI;
  48339. }
  48340. }
  48341. function yb(e, t) {
  48342. var i = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,
  48343. r = XS(je.pth(e) ? e.totalLength : e, t) + '';
  48344. return { original: r, numbers: r.match(i) ? r.match(i).map(Number) : [0], strings: je.str(e) || t ? r.split(i) : [] };
  48345. }
  48346. function ZS(e) {
  48347. var t = e ? Du(je.arr(e) ? e.map(vb) : vb(e)) : [];
  48348. return Pu(t, function (i, r, s) {
  48349. return s.indexOf(i) === r;
  48350. });
  48351. }
  48352. function KS(e) {
  48353. var t = ZS(e);
  48354. return t.map(function (i, r) {
  48355. return { target: i, id: r, total: t.length, transforms: { list: WS(i) } };
  48356. });
  48357. }
  48358. function Mj(e, t) {
  48359. var i = Sv(t);
  48360. if ((/^spring/.test(i.easing) && (i.duration = jS(i.easing)), je.arr(e))) {
  48361. var r = e.length,
  48362. s = r === 2 && !je.obj(e[0]);
  48363. s ? (e = { value: e }) : je.fnc(t.duration) || (i.duration = t.duration / r);
  48364. }
  48365. var n = je.arr(e) ? e : [e];
  48366. return n
  48367. .map(function (a, o) {
  48368. var l = je.obj(a) && !je.pth(a) ? a : { value: a };
  48369. return je.und(l.delay) && (l.delay = o ? 0 : t.delay), je.und(l.endDelay) && (l.endDelay = o === n.length - 1 ? t.endDelay : 0), l;
  48370. })
  48371. .map(function (a) {
  48372. return Lu(a, i);
  48373. });
  48374. }
  48375. function Ej(e) {
  48376. for (
  48377. var t = Pu(
  48378. Du(
  48379. e.map(function (n) {
  48380. return Object.keys(n);
  48381. })
  48382. ),
  48383. function (n) {
  48384. return je.key(n);
  48385. }
  48386. ).reduce(function (n, a) {
  48387. return n.indexOf(a) < 0 && n.push(a), n;
  48388. }, []),
  48389. i = {},
  48390. r = function (n) {
  48391. var a = t[n];
  48392. i[a] = e.map(function (o) {
  48393. var l = {};
  48394. for (var h in o) je.key(h) ? h == a && (l.value = o[h]) : (l[h] = o[h]);
  48395. return l;
  48396. });
  48397. },
  48398. s = 0;
  48399. s < t.length;
  48400. s++
  48401. )
  48402. r(s);
  48403. return i;
  48404. }
  48405. function Cj(e, t) {
  48406. var i = [],
  48407. r = t.keyframes;
  48408. r && (t = Lu(Ej(r), t));
  48409. for (var s in t) je.key(s) && i.push({ name: s, tweens: Mj(t[s], e) });
  48410. return i;
  48411. }
  48412. function Tj(e, t) {
  48413. var i = {};
  48414. for (var r in e) {
  48415. var s = ig(e[r], t);
  48416. je.arr(s) &&
  48417. ((s = s.map(function (n) {
  48418. return ig(n, t);
  48419. })),
  48420. s.length === 1 && (s = s[0])),
  48421. (i[r] = s);
  48422. }
  48423. return (i.duration = parseFloat(i.duration)), (i.delay = parseFloat(i.delay)), i;
  48424. }
  48425. function Pj(e, t) {
  48426. var i;
  48427. return e.tweens.map(function (r) {
  48428. var s = Tj(r, t),
  48429. n = s.value,
  48430. a = je.arr(n) ? n[1] : n,
  48431. o = Hs(a),
  48432. l = Cv(t.target, e.name, o, t),
  48433. h = i ? i.to.original : l,
  48434. u = je.arr(n) ? n[0] : h,
  48435. c = Hs(u) || Hs(l),
  48436. d = o || c;
  48437. return (
  48438. je.und(a) && (a = h),
  48439. (s.from = yb(u, d)),
  48440. (s.to = yb(Tv(a, u), d)),
  48441. (s.start = i ? i.end : 0),
  48442. (s.end = s.start + s.delay + s.duration + s.endDelay),
  48443. (s.easing = _v(s.easing, s.duration)),
  48444. (s.isPath = je.pth(n)),
  48445. (s.isColor = je.col(s.from.original)),
  48446. s.isColor && (s.round = 1),
  48447. (i = s),
  48448. s
  48449. );
  48450. });
  48451. }
  48452. var JS = {
  48453. css: function (e, t, i) {
  48454. return (e.style[t] = i);
  48455. },
  48456. attribute: function (e, t, i) {
  48457. return e.setAttribute(t, i);
  48458. },
  48459. object: function (e, t, i) {
  48460. return (e[t] = i);
  48461. },
  48462. transform: function (e, t, i, r, s) {
  48463. if ((r.list.set(t, i), t === r.last || s)) {
  48464. var n = '';
  48465. r.list.forEach(function (a, o) {
  48466. n += o + '(' + a + ') ';
  48467. }),
  48468. (e.style.transform = n);
  48469. }
  48470. }
  48471. };
  48472. function $S(e, t) {
  48473. var i = KS(e);
  48474. i.forEach(function (r) {
  48475. for (var s in t) {
  48476. var n = ig(t[s], r),
  48477. a = r.target,
  48478. o = Hs(n),
  48479. l = Cv(a, s, o, r),
  48480. h = o || Hs(l),
  48481. u = Tv(XS(n, h), l),
  48482. c = Ev(a, s);
  48483. JS[c](a, s, u, r.transforms, !0);
  48484. }
  48485. });
  48486. }
  48487. function Dj(e, t) {
  48488. var i = Ev(e.target, t.name);
  48489. if (i) {
  48490. var r = Pj(t, e),
  48491. s = r[r.length - 1];
  48492. return { type: i, property: t.name, animatable: e, tweens: r, duration: s.end, delay: r[0].delay, endDelay: s.endDelay };
  48493. }
  48494. }
  48495. function Lj(e, t) {
  48496. return Pu(
  48497. Du(
  48498. e.map(function (i) {
  48499. return t.map(function (r) {
  48500. return Dj(i, r);
  48501. });
  48502. })
  48503. ),
  48504. function (i) {
  48505. return !je.und(i);
  48506. }
  48507. );
  48508. }
  48509. function e2(e, t) {
  48510. var i = e.length,
  48511. r = function (n) {
  48512. return n.timelineOffset ? n.timelineOffset : 0;
  48513. },
  48514. s = {};
  48515. return (
  48516. (s.duration = i
  48517. ? Math.max.apply(
  48518. Math,
  48519. e.map(function (n) {
  48520. let a = n.startOnceDelay ?? 0,
  48521. o = n.pingPongDelayCorrection ?? 0;
  48522. return r(n) + a + o + n.duration * (n.loop ?? 1);
  48523. })
  48524. )
  48525. : t.duration),
  48526. (s.delay = i
  48527. ? Math.min.apply(
  48528. Math,
  48529. e.map(function (n) {
  48530. let a = n.startOnceDelay ?? 0,
  48531. o = n.pingPongDelayCorrection ?? 0;
  48532. return r(n) + a + o + n.delay;
  48533. })
  48534. )
  48535. : t.delay),
  48536. (s.endDelay = i
  48537. ? s.duration -
  48538. Math.max.apply(
  48539. Math,
  48540. e.map(function (n) {
  48541. let a = n.startOnceDelay ?? 0,
  48542. o = n.pingPongDelayCorrection ?? 0;
  48543. return r(n) + a + o + n.duration * (n.loop ?? 1) - n.endDelay;
  48544. })
  48545. )
  48546. : t.endDelay),
  48547. s
  48548. );
  48549. }
  48550. var xb = 0;
  48551. function Oj(e) {
  48552. var t = tg(FS, e),
  48553. i = tg(wv, e),
  48554. r = Cj(i, e),
  48555. s = KS(e.targets),
  48556. n = Lj(s, r),
  48557. a = e2(n, i),
  48558. o = xb;
  48559. return (
  48560. xb++,
  48561. Lu(t, {
  48562. id: o,
  48563. children: [],
  48564. animatables: s,
  48565. animations: n,
  48566. duration: a.duration,
  48567. delay: a.delay,
  48568. endDelay: a.endDelay,
  48569. startOnceDelay: i.startOnceDelay,
  48570. pingPongDelayCorrection: i.pingPongDelayCorrection
  48571. })
  48572. );
  48573. }
  48574. var Sr = [],
  48575. bb = [],
  48576. hd,
  48577. Ij = (function () {
  48578. function e() {
  48579. hd = requestAnimationFrame(t);
  48580. }
  48581. function t(i) {
  48582. var r = Sr.length;
  48583. if (r) {
  48584. for (var s = 0; s < r; ) {
  48585. var n = Sr[s];
  48586. n.paused ? (Sr.splice(s, 1), (r -= 1)) : (n.tick(i), s++);
  48587. }
  48588. e();
  48589. } else hd = cancelAnimationFrame(hd);
  48590. }
  48591. return e;
  48592. })();
  48593. function Rj(e) {
  48594. document.hidden
  48595. ? (Sr.forEach(function (t) {
  48596. return t.pause(e.timeStamp);
  48597. }),
  48598. (bb = Sr.slice(0)),
  48599. (Vt.running = Sr = []))
  48600. : bb.forEach(function (t) {
  48601. return t.play(e.timeStamp);
  48602. });
  48603. }
  48604. typeof document < 'u' && document.addEventListener('visibilitychange', Rj);
  48605. function Vt(e) {
  48606. e === void 0 && (e = {});
  48607. var t = 0,
  48608. i = 0,
  48609. r = 0,
  48610. s,
  48611. n,
  48612. a = 0,
  48613. o = null;
  48614. function l(x) {
  48615. var w =
  48616. window.Promise &&
  48617. new Promise(function (A) {
  48618. return (o = A);
  48619. });
  48620. return (x.finished = w), w;
  48621. }
  48622. var h = Oj(e),
  48623. u = l(h);
  48624. function c() {
  48625. var x = h.direction;
  48626. x !== 'alternate' && (h.direction = x !== 'normal' ? 'normal' : 'reverse'),
  48627. (h.reversed = !h.reversed),
  48628. n.forEach(function (w) {
  48629. return (w.reversed = h.reversed);
  48630. });
  48631. }
  48632. function d(x) {
  48633. return h.reversed ? h.duration - x : x;
  48634. }
  48635. function p() {
  48636. (t = 0), (i = d(h.currentTime) * (1 / Vt.speed));
  48637. }
  48638. function f(x, w) {
  48639. w &&
  48640. (h.reversed
  48641. ? w.seek(w.duration * w.loop - (x - w.timelineOffset - w.pingPongDelayCorrection))
  48642. : w.seek(x - w.timelineOffset - w.startOnceDelay - w.pingPongDelayCorrection));
  48643. }
  48644. function g(x) {
  48645. if (h.reversed) for (var w = a; w--; ) f(x, n[w]);
  48646. else for (var A = 0; A < a; A++) f(x, n[A]);
  48647. }
  48648. function m(x) {
  48649. var w = 0,
  48650. A = h.animations,
  48651. S = A.length;
  48652. for (h.reversePlayback === !0 && h.rewind === !1 && (x = h.duration + h.delay - h.endDelay - x); w < S; ) {
  48653. var _ = A[w],
  48654. M = _.animatable,
  48655. C = _.tweens,
  48656. T = C.length - 1,
  48657. P = C[T];
  48658. T &&
  48659. (P =
  48660. Pu(C, function (ee) {
  48661. return x < ee.end;
  48662. })[0] || P);
  48663. for (
  48664. var L = ds(x - P.start - P.delay, 0, P.duration) / P.duration,
  48665. D = isNaN(L) ? 1 : P.easing(L),
  48666. k = P.to.strings,
  48667. W = P.round,
  48668. X = [],
  48669. z = P.to.numbers.length,
  48670. j = void 0,
  48671. U = 0;
  48672. U < z;
  48673. U++
  48674. ) {
  48675. var N = void 0;
  48676. if (h.reversePlayback === !0 && h.rewind === !1)
  48677. var H = P.to.numbers[U],
  48678. B = P.from.numbers[U] || 0;
  48679. else
  48680. var B = P.to.numbers[U],
  48681. H = P.from.numbers[U] || 0;
  48682. P.isPath ? (N = Sj(P.value, D * B)) : (N = H + D * (B - H)), W && ((P.isColor && U > 2) || (N = Math.round(N * W) / W)), X.push(N);
  48683. }
  48684. var Q = k.length;
  48685. if (!Q) j = X[0];
  48686. else {
  48687. j = k[0];
  48688. for (var Y = 0; Y < Q; Y++) {
  48689. var F = k[Y],
  48690. se = k[Y + 1],
  48691. V = X[Y];
  48692. isNaN(V) || (se ? (j += V + se) : (j += V + ' '));
  48693. }
  48694. }
  48695. JS[_.type](M.target, _.property, j, M.transforms), (_.currentValue = j), w++;
  48696. }
  48697. }
  48698. function v(x) {
  48699. h[x] && !h.passThrough && h[x](h);
  48700. }
  48701. function y() {
  48702. h.remaining && h.remaining !== !0 && h.remaining--;
  48703. }
  48704. function b(x) {
  48705. var w = h.duration,
  48706. A = h.delay,
  48707. S = w - h.endDelay,
  48708. _ = d(x);
  48709. if (
  48710. ((h.progress = ds((_ / w) * 100, 0, 100)),
  48711. (h.reversePlayback = _ < h.currentTime),
  48712. a && g(_),
  48713. !h.began && h.currentTime >= 0 && ((h.began = !0), v('begin')),
  48714. !h.loopBegan && h.currentTime > 0 && ((h.loopBegan = !0), v('loopBegin')),
  48715. (h.reversed || _ >= 0) && _ <= A && h.currentTime !== 0 && (m(0), v('change')),
  48716. ((_ >= S && h.currentTime !== w) || !w) && (m(w), v('change')),
  48717. _ > A && _ < S
  48718. ? (h.changeBegan || ((h.changeBegan = !0), (h.changeCompleted = !1), v('changeBegin')), m(_), v('change'))
  48719. : h.changeBegan
  48720. ? ((h.changeCompleted = !0), (h.changeBegan = !1), v('change'), a && v('timelineChangeComplete'))
  48721. : h.began && _ > S && v('changeComplete'),
  48722. (h.currentTime = ds(_, 0, w)),
  48723. h.began && v('update'),
  48724. x >= w)
  48725. )
  48726. if ((y(), !h.remaining))
  48727. (h.paused = !0),
  48728. h.completed || ((h.completed = !0), v('loopComplete'), v('complete'), !h.passThrough && 'Promise' in window && (o(), (u = l(h))));
  48729. else {
  48730. a ? (t += h.duration / Vt.speed) : (t += h.duration);
  48731. for (let M of n) M.setStartTime(0), (M.remaining = M.loop);
  48732. v('loopComplete'), (h.loopBegan = !1), h.direction === 'alternate' && c();
  48733. }
  48734. }
  48735. return (
  48736. (h.reset = function () {
  48737. var x = h.direction;
  48738. (h.passThrough = !1),
  48739. (h.currentTime = 0),
  48740. (h.progress = 0),
  48741. (h.paused = !0),
  48742. (h.began = !1),
  48743. (h.loopBegan = !1),
  48744. (h.changeBegan = !1),
  48745. (h.completed = !1),
  48746. (h.changeCompleted = !1),
  48747. (h.reversePlayback = !1),
  48748. (h.reversed = x === 'reverse'),
  48749. (h.remaining = h.loop),
  48750. (n = h.children),
  48751. (a = n.length);
  48752. for (var w = a; w--; ) h.children[w].reset();
  48753. ((h.reversed && h.loop !== !0) || (x === 'alternate' && h.loop === 1)) && h.remaining++, m(h.reversed ? h.duration : 0);
  48754. }),
  48755. (h.setStartTime = function (x) {
  48756. t = x;
  48757. }),
  48758. (h.set = function (x, w) {
  48759. return $S(x, w), h;
  48760. }),
  48761. (h.tick = function (x) {
  48762. (r = x), t || (t = r), b((r + (i - t)) * Vt.speed);
  48763. }),
  48764. (h.seek = function (x) {
  48765. b(x - t);
  48766. }),
  48767. (h.pause = function (x) {
  48768. (h.paused = !0), a && (s = x ?? performance.now());
  48769. }),
  48770. (h.play = function (x) {
  48771. !h.paused ||
  48772. (h.completed && h.reset(), (h.paused = !1), Sr.push(h), a && s !== void 0 && (t += (x ?? performance.now()) - s), hd || Ij());
  48773. }),
  48774. (h.reverse = function () {
  48775. c(), (h.completed = !h.reversed), p();
  48776. }),
  48777. (h.restart = function () {
  48778. h.reset(), h.play();
  48779. }),
  48780. h.reset(),
  48781. h.autoplay && h.play(),
  48782. h
  48783. );
  48784. }
  48785. function wb(e, t) {
  48786. for (var i = t.length; i--; ) Av(e, t[i].animatable.target) && t.splice(i, 1);
  48787. }
  48788. function Bj(e) {
  48789. for (var t = ZS(e), i = Sr.length; i--; ) {
  48790. var r = Sr[i],
  48791. s = r.animations,
  48792. n = r.children;
  48793. wb(t, s);
  48794. for (var a = n.length; a--; ) {
  48795. var o = n[a],
  48796. l = o.animations;
  48797. wb(t, l), !l.length && !o.children.length && n.splice(a, 1);
  48798. }
  48799. !s.length && !n.length && r.pause();
  48800. }
  48801. }
  48802. function zj(e, t) {
  48803. t === void 0 && (t = {});
  48804. var i = t.direction || 'normal',
  48805. r = t.easing ? _v(t.easing) : null,
  48806. s = t.grid,
  48807. n = t.axis,
  48808. a = t.from || 0,
  48809. o = a === 'first',
  48810. l = a === 'center',
  48811. h = a === 'last',
  48812. u = je.arr(e),
  48813. c = parseFloat(u ? e[0] : e),
  48814. d = u ? parseFloat(e[1]) : 0,
  48815. p = Hs(u ? e[1] : e) || 0,
  48816. f = t.start || 0 + (u ? c : 0),
  48817. g = [],
  48818. m = 0;
  48819. return function (v, y, b) {
  48820. if ((o && (a = 0), l && (a = (b - 1) / 2), h && (a = b - 1), !g.length)) {
  48821. for (var x = 0; x < b; x++) {
  48822. if (!s) g.push(Math.abs(a - x));
  48823. else {
  48824. var w = l ? (s[0] - 1) / 2 : a % s[0],
  48825. A = l ? (s[1] - 1) / 2 : Math.floor(a / s[0]),
  48826. S = x % s[0],
  48827. _ = Math.floor(x / s[0]),
  48828. M = w - S,
  48829. C = A - _,
  48830. T = Math.sqrt(M * M + C * C);
  48831. n === 'x' && (T = -M), n === 'y' && (T = -C), g.push(T);
  48832. }
  48833. m = Math.max.apply(Math, g);
  48834. }
  48835. r &&
  48836. (g = g.map(function (L) {
  48837. return r(L / m) * m;
  48838. })),
  48839. i === 'reverse' &&
  48840. (g = g.map(function (L) {
  48841. return n ? (L < 0 ? L * -1 : -L) : Math.abs(m - L);
  48842. }));
  48843. }
  48844. var P = u ? (d - c) / m : c;
  48845. return f + P * (Math.round(g[y] * 100) / 100) + p;
  48846. };
  48847. }
  48848. function Nj(e) {
  48849. e === void 0 && (e = {});
  48850. var t = Vt(e);
  48851. return (
  48852. (t.duration = 0),
  48853. (t.add = function (i, r) {
  48854. var s = Sr.indexOf(t),
  48855. n = t.children;
  48856. s > -1 && Sr.splice(s, 1);
  48857. function a(d) {
  48858. d.passThrough = !0;
  48859. }
  48860. for (var o = 0; o < n.length; o++) a(n[o]);
  48861. var l = Lu(i, tg(wv, e));
  48862. l.targets = l.targets || e.targets;
  48863. var h = t.duration;
  48864. (l.autoplay = !1), (l.timelineOffset = je.und(r) ? h : Tv(r, h)), a(t);
  48865. var u = Vt(l);
  48866. a(u), n.push(u);
  48867. var c = e2(n, e);
  48868. return (
  48869. (t.delay = c.delay),
  48870. (t.endDelay = c.endDelay),
  48871. (t.duration = c.duration),
  48872. u.loop === !0 && (t.duration = 1 / 0),
  48873. t.seek(0),
  48874. t.reset(),
  48875. t.autoplay && t.play(),
  48876. t
  48877. );
  48878. }),
  48879. t
  48880. );
  48881. }
  48882. Vt.version = '3.2.0';
  48883. Vt.speed = 1;
  48884. Vt.running = Sr;
  48885. Vt.remove = Bj;
  48886. Vt.get = Cv;
  48887. Vt.set = $S;
  48888. Vt.convertPx = Mv;
  48889. Vt.path = Aj;
  48890. Vt.setDashoffset = wj;
  48891. Vt.stagger = zj;
  48892. Vt.timeline = Nj;
  48893. Vt.easing = _v;
  48894. Vt.penner = GS;
  48895. Vt.random = function (e, t) {
  48896. return Math.floor(Math.random() * (t - e + 1)) + e;
  48897. };
  48898. var Uj = Vt,
  48899. _b = new E(),
  48900. Ab = new E(),
  48901. Sb = new ct();
  48902. function Fj(e, t, i, r) {
  48903. if (r === 0) return i.copy(e);
  48904. if (r === 1) return i.copy(t);
  48905. let s = e.w * t.w + e.x * t.x + e.y * t.y + e.z * t.z;
  48906. if (s >= 1) return i.copy(e);
  48907. let n = 1 - s * s;
  48908. if (n <= Number.EPSILON) {
  48909. let u = 1 - r;
  48910. return (i.w = u * e.w + r * t.w), (i.x = u * e.x + r * t.x), (i.y = u * e.y + r * t.y), (i.z = u * e.z + r * t.z), i.normalize(), i;
  48911. }
  48912. let a = Math.sqrt(n),
  48913. o = Math.atan2(a, s),
  48914. l = Math.sin((1 - r) * o) / a,
  48915. h = Math.sin(r * o) / a;
  48916. 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;
  48917. }
  48918. function Sa(e, t, i, r, s) {
  48919. let n = i[e] ? i[e] : void 0,
  48920. a = r[e];
  48921. if (a == null) return;
  48922. let o = n ?? t[e],
  48923. l = a;
  48924. if (o !== l)
  48925. return {
  48926. update: (h) => {
  48927. let u = it.lerp(o, l, h);
  48928. s ? (t[e] = Math.trunc(u)) : (t[e] = u);
  48929. },
  48930. start: () => {
  48931. t[e] = o;
  48932. },
  48933. end: () => {
  48934. t[e] = l;
  48935. }
  48936. };
  48937. }
  48938. function t2(e, t, i, r, s) {
  48939. let n = i[e] ? i[e] : void 0,
  48940. a = r[e];
  48941. if (!a) return;
  48942. let o = t[e],
  48943. l = [...(n ?? o)],
  48944. h = [...a];
  48945. if (!(l.length !== h.length || jg(l, h)))
  48946. return {
  48947. update: (u) => {
  48948. l.forEach((c, d) => {
  48949. let p = it.lerp(c, h[d], u);
  48950. t[e][d] = s ? Math.trunc(p) : p;
  48951. });
  48952. },
  48953. start: () => {
  48954. Object.assign(t[e], l);
  48955. },
  48956. end: () => {
  48957. Object.assign(t[e], h);
  48958. }
  48959. };
  48960. }
  48961. function Mb(e, t, i, r) {
  48962. let s = i[e] ? i[e] : void 0,
  48963. n = r[e];
  48964. if (!n) return;
  48965. let a = t[e],
  48966. o = s ? new E().fromArray(s) : a.clone(),
  48967. l = new E().fromArray(n);
  48968. if (!o.equals(l))
  48969. return {
  48970. update: (h) => {
  48971. a.lerpVectors(o, l, h);
  48972. },
  48973. start: () => {
  48974. a.copy(o);
  48975. },
  48976. end: () => {
  48977. a.copy(l);
  48978. }
  48979. };
  48980. }
  48981. function kj(e, t, i, r) {
  48982. let s = i[e] ? i[e] : void 0,
  48983. n = r[e];
  48984. if (!n) return;
  48985. let a = t[e],
  48986. o = s ? new ve().fromArray(s) : a.clone(),
  48987. l = new E(),
  48988. h = new ct(),
  48989. u = new E();
  48990. o.decompose(l, h, u);
  48991. let c = new ve().fromArray(n),
  48992. d = new E(),
  48993. p = new ct(),
  48994. f = new E();
  48995. if ((c.decompose(d, p, f), !o.equals(c)))
  48996. return {
  48997. update: (g) => {
  48998. Sb.slerpQuaternions(h, p, g), _b.lerpVectors(l, d, g), Ab.lerpVectors(u, f, g), a.compose(_b, Sb, Ab);
  48999. },
  49000. start: () => {
  49001. a.compose(l, h, u);
  49002. },
  49003. end: () => {
  49004. a.compose(d, p, f);
  49005. }
  49006. };
  49007. }
  49008. function jj(e, t, i, r, s) {
  49009. let n = i[e] ? i[e] : void 0,
  49010. a = r[e];
  49011. if (!a) return;
  49012. let o = t[e],
  49013. l = n ? (typeof n == 'string' ? s.getColor(n).clone() : new Ge().setRGB(n.r, n.g, n.b)) : o.clone(),
  49014. h = typeof a == 'string' ? s.getColor(a).clone() : new Ge().setRGB(a.r, a.g, a.b);
  49015. if (l.equals(h)) return;
  49016. let u = o.clone();
  49017. return (
  49018. (t[e] = u),
  49019. {
  49020. update: (c) => {
  49021. u.lerpColors(l, h, c);
  49022. },
  49023. start: () => {
  49024. u.copy(l);
  49025. },
  49026. end: () => {
  49027. u.copy(h);
  49028. }
  49029. }
  49030. );
  49031. }
  49032. function Nn(e, t, i, r) {
  49033. if (typeof t[e] == 'number') return Sa(e, t, i ?? {}, r);
  49034. if (Array.isArray(t[e])) return t2(e, t, i ?? {}, r);
  49035. }
  49036. function Gj(e, t, i) {
  49037. let r = [],
  49038. s = e.cameraType === 'OrthographicCamera' ? t.orthographic?.zoom : t.perspective?.zoom,
  49039. n = e.cameraType === 'OrthographicCamera' ? i.orthographic?.zoom : i.perspective?.zoom;
  49040. if (n !== void 0) {
  49041. let a = s ?? e.zoom,
  49042. o = n;
  49043. a !== o &&
  49044. r.push({
  49045. update: (l) => {
  49046. (e.zoom = it.lerp(a, o, l)), e.updateProjectionMatrix();
  49047. },
  49048. start: () => {
  49049. (e.zoom = a), e.updateProjectionMatrix();
  49050. },
  49051. end: () => {
  49052. (e.zoom = o), e.updateProjectionMatrix();
  49053. }
  49054. });
  49055. }
  49056. if (i.targetOffset !== void 0) {
  49057. let a = Sa('targetOffset', e, t, i);
  49058. a && r.push(a);
  49059. }
  49060. return r;
  49061. }
  49062. function Vj(e, t, i, r) {
  49063. if (i.scaleBaked === void 0) return;
  49064. let s = t.scaleBaked ?? e.data.geometry.scaleBaked,
  49065. n = i.scaleBaked;
  49066. if (ma.isEqual(s, n)) return;
  49067. let a = [];
  49068. return (
  49069. a.push({
  49070. update: (o) => {
  49071. e.updateGeometryInteractions({ scaleBaked: [it.lerp(s[0], n[0], o), it.lerp(s[1], n[1], o), it.lerp(s[2], n[2], o)] }, r),
  49072. e.invalidateDownstreamBooleanData();
  49073. },
  49074. start: () => {
  49075. e.updateGeometryInteractions({ scaleBaked: s }, r), e.invalidateDownstreamBooleanData();
  49076. },
  49077. end: () => {
  49078. e.updateGeometryInteractions({ scaleBaked: n }, r), e.invalidateDownstreamBooleanData();
  49079. }
  49080. }),
  49081. a
  49082. );
  49083. }
  49084. function Hj(e, t, i) {
  49085. if (!i.extrusion) return;
  49086. let r = e.extrusion,
  49087. s = t.extrusion ?? {},
  49088. n = i.extrusion,
  49089. a = [];
  49090. return (
  49091. eA.forEach((o) => {
  49092. let l = Nn(o, r, s, n);
  49093. l && a.push(l);
  49094. }),
  49095. a
  49096. );
  49097. }
  49098. function Wj(e, t, i, r) {
  49099. let s = [];
  49100. if (!('geometry' in i)) return s;
  49101. let n = e.geometry.userData.parameters,
  49102. a = 'geometry' in t ? t.geometry : {},
  49103. o = i.geometry;
  49104. if (e instanceof Sh) {
  49105. let l = Vj(e, a, o, r);
  49106. l && s.push(...l);
  49107. } else {
  49108. let l = {};
  49109. if (
  49110. (Object.assign(l, gh(n, F1)),
  49111. F1.forEach((h) => {
  49112. let u = Nn(h, l, a, o);
  49113. u && s.push(u);
  49114. }),
  49115. e instanceof gv)
  49116. ) {
  49117. Object.assign(l, { extrusion: { ...n.extrusion } });
  49118. let h = Hj(l, a, o);
  49119. h && s.push(...h);
  49120. }
  49121. s.length &&
  49122. s.push({
  49123. update: (h) => {
  49124. e.updateGeometryInteractions(l, r), e.updateGeometryGroupsIfNeeded();
  49125. },
  49126. start: (h) => {
  49127. e.updateGeometryInteractions(l, r), e.updateGeometryGroupsIfNeeded();
  49128. },
  49129. end: (h) => {
  49130. e.updateGeometryInteractions(l, r), e.updateGeometryGroupsIfNeeded();
  49131. }
  49132. });
  49133. }
  49134. return s;
  49135. }
  49136. function Xj(e, t, i, r) {
  49137. let s = [];
  49138. if (i.intensity !== void 0) {
  49139. let n = Sa('intensity', e, t, i);
  49140. n && s.push(n);
  49141. }
  49142. if (i.color !== void 0) {
  49143. let n = jj('color', e, t, i, r);
  49144. n && s.push(n);
  49145. }
  49146. return s;
  49147. }
  49148. function qj(e, t, i, r) {
  49149. let s = [];
  49150. if (Array.isArray(e.material)) {
  49151. if (!('materials' in i && i.materials)) return s;
  49152. let n = 'materials' in t && t.materials ? t.materials : [],
  49153. a = i.materials;
  49154. e.material.forEach((o, l) => {
  49155. if (!a[l]) return;
  49156. let h = n[l] ?? {},
  49157. u = a[l];
  49158. typeof h == 'string' || typeof u == 'string' || s.push(...Eb(o, h, u, r));
  49159. });
  49160. } else {
  49161. if (!('material' in i && i.material)) return s;
  49162. let n = 'material' in t && t.material ? t.material : {},
  49163. a = i.material;
  49164. if (typeof n == 'string' || typeof a == 'string') return s;
  49165. s.push(...Eb(e.material, n, a, r));
  49166. }
  49167. return s;
  49168. }
  49169. function Eb(e, t, i, r) {
  49170. let s = [],
  49171. n = Jd(i, r) || (!!t.layers && Jd(t, r));
  49172. s.push(iG(e, n));
  49173. for (let a of e.layers) {
  49174. let o = t.layers?.data(a.uuid),
  49175. l = i.layers.data(a.uuid);
  49176. if (!l || !(a.visible ?? !0) || !(l.visible ?? !0)) continue;
  49177. let h = a.getNames().filter((u) => !K_.some((c) => u.includes(c)));
  49178. for (let u of h)
  49179. try {
  49180. let c = a.getValue(u),
  49181. d;
  49182. if (u === 'colors') d = eG(a, o, l, u);
  49183. else if (Array.isArray(c)) u === 'steps' && (d = $j(a, o, l, u));
  49184. else if (typeof c == 'number') d = Yj(a, o, l, u);
  49185. else {
  49186. if (typeof c == 'boolean') continue;
  49187. c instanceof G
  49188. ? (d = Qj(a, o, l, u))
  49189. : c instanceof E
  49190. ? (d = Zj(a, o, l, u))
  49191. : c instanceof ji
  49192. ? (d = Jj(a, o, l, u, r))
  49193. : c instanceof Ge
  49194. ? (d = Kj(a, o, l, u, r))
  49195. : 'isTexture' in c && (d = tG(a, o, l, u));
  49196. }
  49197. d && (Array.isArray(d) ? s.push(...d) : s.push(d));
  49198. } catch (c) {
  49199. console.error(`lerpMaterial: unexpected material layer for ${u}`, c);
  49200. }
  49201. }
  49202. return s;
  49203. }
  49204. function Yj(e, t, i, r) {
  49205. if (!e.hasValue(r) || !(r in i)) return;
  49206. let s = t ? t[r] : e.getValue(r),
  49207. n = i[r];
  49208. if (s !== n)
  49209. return {
  49210. update: (a) => {
  49211. e.setValue(r, it.lerp(s, n, a));
  49212. },
  49213. start: () => {
  49214. e.setValue(r, s);
  49215. },
  49216. end: () => {
  49217. e.setValue(r, n);
  49218. }
  49219. };
  49220. }
  49221. function Qj(e, t, i, r) {
  49222. if (!e.hasValue(r) || !(r in i)) return;
  49223. let s = e.getValue(r),
  49224. n = t ? new G().fromArray(t[r]) : s.clone(),
  49225. a = new G().fromArray(i[r]);
  49226. if (!n.equals(a))
  49227. return {
  49228. update: (o) => {
  49229. s.lerpVectors(n, a, o);
  49230. },
  49231. start: () => {
  49232. s.copy(n);
  49233. },
  49234. end: () => {
  49235. s.copy(a);
  49236. }
  49237. };
  49238. }
  49239. function Zj(e, t, i, r) {
  49240. if (!e.hasValue(r) || !(r in i)) return;
  49241. let s = e.getValue(r),
  49242. n = t ? new E().fromArray(t[r]) : s.clone(),
  49243. a = new E().fromArray(i[r]);
  49244. if (!n.equals(a))
  49245. return {
  49246. update: (o) => {
  49247. s.lerpVectors(n, a, o);
  49248. },
  49249. start: () => {
  49250. s.copy(n);
  49251. },
  49252. end: () => {
  49253. s.copy(a);
  49254. }
  49255. };
  49256. }
  49257. function Kj(e, t, i, r, s) {
  49258. if (!e.hasValue(r) || !(r in i)) return;
  49259. let n = t ? t[r] : void 0,
  49260. a = i[r],
  49261. o = e.getValue(r),
  49262. l = n ? (typeof n == 'string' ? s.getColor(n).clone() : new Ge().setRGB(n.r, n.g, n.b)) : o.clone(),
  49263. h = typeof a == 'string' ? s.getColor(a).clone() : new Ge().setRGB(a.r, a.g, a.b);
  49264. if (l.equals(h)) return;
  49265. let u = o.clone();
  49266. return (
  49267. e.setValue(r, u),
  49268. {
  49269. update: (c) => {
  49270. u.lerpColors(l, h, c);
  49271. },
  49272. start: () => {
  49273. u.copy(l);
  49274. },
  49275. end: () => {
  49276. u.copy(h);
  49277. }
  49278. }
  49279. );
  49280. }
  49281. function Jj(e, t, i, r, s) {
  49282. if (!e.hasValue(r) || !(r in i)) return;
  49283. let n = t ? t[r] : void 0,
  49284. a = i[r],
  49285. o = e.getValue(r),
  49286. l = n ? (typeof n == 'string' ? s.getColor(n).clone() : new Ge().setRGB(n.r, n.g, n.b)) : o.clone(),
  49287. h = typeof a == 'string' ? s.getColor(a).clone() : new ji(a.r, a.g, a.b, a.a);
  49288. if (l.equals(h)) return;
  49289. let u = o.clone();
  49290. return (
  49291. e.setValue(r, u),
  49292. {
  49293. update: (c) => {
  49294. u.lerpColors(l, h, c);
  49295. },
  49296. start: () => {
  49297. u.copy(l);
  49298. },
  49299. end: () => {
  49300. u.copy(h);
  49301. }
  49302. }
  49303. );
  49304. }
  49305. function $j(e, t, i, r = 'steps') {
  49306. if (!e.hasValue(r) || !(r in i)) return;
  49307. let s = [],
  49308. n = e.getValue(r),
  49309. a = t ? t[r] : n,
  49310. o = i[r];
  49311. for (let l = 0; l < n.length; ++l) {
  49312. let h = a[l],
  49313. u = o[l];
  49314. h !== u &&
  49315. s.push({
  49316. update: (c) => {
  49317. n[l] = it.lerp(h, u, c);
  49318. },
  49319. start: () => {
  49320. n[l] = h;
  49321. },
  49322. end: () => {
  49323. n[l] = u;
  49324. }
  49325. });
  49326. }
  49327. return s.length ? s : void 0;
  49328. }
  49329. function eG(e, t, i, r = 'colors') {
  49330. if (!e.hasValue(r) || !(r in i)) return;
  49331. let s = [],
  49332. n = e.getValue(r),
  49333. a = t ? t[r] : n.map((l) => l.toArray()),
  49334. o = i[r];
  49335. for (let l = 0; l < n.length; ++l) {
  49336. let h = [...a[l]],
  49337. u = [...o[l]];
  49338. Id.isEqual(h, u) ||
  49339. s.push({
  49340. update: (c) => {
  49341. n[l].fromArray(Id.lerp(h, u, c));
  49342. },
  49343. start: () => {
  49344. n[l].fromArray(h);
  49345. },
  49346. end: () => {
  49347. n[l].fromArray(u);
  49348. }
  49349. });
  49350. }
  49351. return s.length ? s : void 0;
  49352. }
  49353. function tG(e, t, i, r = 'texture') {
  49354. if (!e.hasValue(r) || !(r in i)) return;
  49355. let s = e.getNode('mat');
  49356. if (!s) return;
  49357. let n = t ? t[r] : s,
  49358. a = i[r],
  49359. o = [...n.repeat],
  49360. l = [...n.offset],
  49361. h = [...a.repeat],
  49362. u = [...a.offset];
  49363. if (!mo.isEqual(o, h) || !mo.isEqual(l, u))
  49364. return {
  49365. update: (c) => {
  49366. (s.repeat = mo.lerp(o, h, c)), (s.offset = mo.lerp(l, u, c)), s.updateMatrix();
  49367. },
  49368. start: () => {
  49369. (s.repeat = [...o]), (s.offset = [...l]), s.updateMatrix();
  49370. },
  49371. end: () => {
  49372. (s.repeat = [...h]), (s.offset = [...u]), s.updateMatrix();
  49373. }
  49374. };
  49375. }
  49376. function iG(e, t) {
  49377. return {
  49378. update: () => {
  49379. e.transparent = t;
  49380. }
  49381. };
  49382. }
  49383. var yf = new E(),
  49384. Cb = new _i();
  49385. function rG(e, t, i, r) {
  49386. let s = [],
  49387. n,
  49388. a,
  49389. o,
  49390. l,
  49391. h,
  49392. u,
  49393. c = { slide: (t.pathSnapping ?? e.dataPatched.pathSnapping).slide, offset: (t.pathSnapping ?? e.dataPatched.pathSnapping).offset };
  49394. if (
  49395. ((h = Sa('slide', c, t.pathSnapping ?? e.dataPatched.pathSnapping, i.pathSnapping ?? e.dataPatched.pathSnapping)),
  49396. h && s.push(h),
  49397. (u = Sa('offset', c, t.pathSnapping ?? e.dataPatched.pathSnapping, i.pathSnapping ?? e.dataPatched.pathSnapping)),
  49398. u && s.push(u),
  49399. !h &&
  49400. !u &&
  49401. ((n = Mb('position', e, t, i)),
  49402. n && s.push(n),
  49403. (a = Mb('scale', e, t, i)),
  49404. a && s.push(a),
  49405. (o = sG(e, t, i, r)),
  49406. o && s.push(o),
  49407. (l = kj('hiddenMatrix', e, t, i)),
  49408. l && s.push(l)),
  49409. n || a || o || l || h || u)
  49410. ) {
  49411. let d = () => {
  49412. e.updateMatrix(),
  49413. e.hasNonUniformScale && (e.updateMatrixWorld(), e.updateMatrixWorldSVD()),
  49414. e.parent?.matrixWorldFusedFalse &&
  49415. (e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse, e.matrix), (e.matrixWorldNeedsUpdate = !1)),
  49416. js(e) && Sn(e.parent) && e.invalidateDownstreamBooleanData(!0),
  49417. e.updatePathSnapping(Object.assign({}, t.pathSnapping, c));
  49418. };
  49419. s.push({ update: d, start: d, end: d });
  49420. }
  49421. return s;
  49422. }
  49423. function sG(e, t, i, r) {
  49424. let s = t?.rotation ? t.rotation : void 0,
  49425. n = i.rotation;
  49426. if (!n) return;
  49427. let a = s ? new E().fromArray(s) : new E().setFromEuler(e.rotation),
  49428. o = new E().fromArray(n);
  49429. if (a.equals(o)) return;
  49430. let l = yf.subVectors(o, a);
  49431. if (r && l.toArray().every((h) => Math.abs(h) < 2 * Math.PI)) {
  49432. let h = new ct().setFromEuler(Cb.setFromVector3(a)),
  49433. u = new ct().setFromEuler(Cb.setFromVector3(o));
  49434. return {
  49435. update: (c) => {
  49436. Fj(h, u, e.quaternion, c);
  49437. },
  49438. start: () => {
  49439. e.rotation.setFromVector3(a);
  49440. },
  49441. end: () => {
  49442. e.rotation.setFromVector3(o);
  49443. }
  49444. };
  49445. } else
  49446. return {
  49447. update: (h) => {
  49448. yf.lerpVectors(a, o, h), e.rotation.setFromVector3(yf);
  49449. },
  49450. start: () => {
  49451. e.rotation.setFromVector3(a);
  49452. },
  49453. end: () => {
  49454. e.rotation.setFromVector3(o);
  49455. }
  49456. };
  49457. }
  49458. function nG(e, t, i) {
  49459. let r = [];
  49460. if (!('cloner' in i) || !e.cloner) return r;
  49461. let s = e.cloner,
  49462. n = 'cloner' in t ? t.cloner : {},
  49463. a = i.cloner;
  49464. W_.forEach((d) => {
  49465. let p;
  49466. d === 'count' ? (p = Sa('count', s.parameters, n, a, !0)) : (p = Nn(d, s.parameters, n ?? {}, a)), p && r.push(p);
  49467. });
  49468. let o = aG(s, n, a);
  49469. o?.length && r.push(...o);
  49470. let l = oG(s, n, a);
  49471. l?.length && r.push(...l);
  49472. let h = lG(s, n, a);
  49473. h?.length && r.push(...h);
  49474. let u = hG(s, n, a);
  49475. u?.length && r.push(...u);
  49476. let c = cG(s, n, a);
  49477. return (
  49478. c?.length && r.push(...c),
  49479. r.length &&
  49480. r.push({
  49481. update: () => {
  49482. s.update();
  49483. }
  49484. }),
  49485. r
  49486. );
  49487. }
  49488. function aG(e, t, i) {
  49489. if (e.parameters.type !== 'radial') return;
  49490. let r = t.radial,
  49491. s = i.radial;
  49492. if (!s) return;
  49493. let n = e.parameters.radial,
  49494. a = [];
  49495. return (
  49496. X_.forEach((o) => {
  49497. let l = Nn(o, n, r ?? {}, s);
  49498. l && a.push(l);
  49499. }),
  49500. a
  49501. );
  49502. }
  49503. function oG(e, t, i) {
  49504. if (e.parameters.type !== 'linear') return;
  49505. let r = t.linear,
  49506. s = i.linear;
  49507. if (!s) return;
  49508. let n = [],
  49509. a = e.parameters.linear;
  49510. return (
  49511. q_.forEach((o) => {
  49512. let l = Nn(o, a, r ?? {}, s);
  49513. l && n.push(l);
  49514. }),
  49515. n
  49516. );
  49517. }
  49518. function lG(e, t, i) {
  49519. if (e.parameters.type !== 'grid') return;
  49520. let r = t.grid,
  49521. s = i.grid;
  49522. if (!s) return;
  49523. let n = [],
  49524. a = e.parameters.grid;
  49525. return (
  49526. Y_.forEach((o) => {
  49527. let l;
  49528. o === 'count' ? (l = t2(o, a, r ?? {}, s, !0)) : (l = Nn(o, a, r ?? {}, s)), l && n.push(l);
  49529. }),
  49530. n
  49531. );
  49532. }
  49533. function hG(e, t, i) {
  49534. if (e.parameters.type !== 'toObject') return;
  49535. let r = t.toObject,
  49536. s = i.toObject;
  49537. if (!s) return;
  49538. let n = [],
  49539. a = e.parameters.toObject;
  49540. return (
  49541. Q_.forEach((o) => {
  49542. let l;
  49543. o === 'count' ? (l = Sa(o, a, r ?? {}, s, !0)) : (l = Nn(o, a, r ?? {}, s)), l && n.push(l);
  49544. }),
  49545. n
  49546. );
  49547. }
  49548. function cG(e, t, i) {
  49549. if (!e.parameters.randomness) return;
  49550. let r = t.randomnessObject,
  49551. s = i.randomnessObject;
  49552. if (!s) return;
  49553. let n = [],
  49554. a = e.parameters.randomnessObject;
  49555. return (
  49556. Z_.forEach((o) => {
  49557. let l = Nn(o, a, r ?? {}, s);
  49558. l && n.push(l);
  49559. }),
  49560. n
  49561. );
  49562. }
  49563. function Tb(e, t, i, r, s) {
  49564. let n = [];
  49565. return (
  49566. e.data.visible && n.push(...rG(e, t, i, s)),
  49567. e.data.visible && n.push(...nG(e, t, i)),
  49568. js(e)
  49569. ? (e instanceof Cr && e.data.visible && n.push(...Wj(e, t, i, r)), e.data.visible && n.push(...qj(e, t, i, r)))
  49570. : p8(e)
  49571. ? e.data.visible && n.push(...Xj(e, t, i, r))
  49572. : u8(e) && n.push(...Gj(e, t, i)),
  49573. n.length
  49574. ? {
  49575. update: (a) => {
  49576. n.forEach((o) => o.update(a));
  49577. },
  49578. start: (a) => {
  49579. n.forEach((o) => o.start?.(a));
  49580. },
  49581. end: (a) => {
  49582. n.forEach((o) => o.end?.(a));
  49583. }
  49584. }
  49585. : void 0
  49586. );
  49587. }
  49588. var Pb = new E();
  49589. function i2(e, t, i, r = !1) {
  49590. let s = [];
  49591. t.traverseObject((n) => {
  49592. if (
  49593. (r &&
  49594. (n.rigidBody?.setTranslation(n.position0, !0),
  49595. n.rigidBody?.setRotation(n.rotation0, !0),
  49596. n.rigidBody?.setLinvel(Pb, !0),
  49597. n.rigidBody?.setAngvel(Pb, !0)),
  49598. !Ct.is(n))
  49599. )
  49600. return;
  49601. let a = n.uuid,
  49602. o = n.data;
  49603. if ((delete n.states, !o.states)) return;
  49604. let l = !1;
  49605. s.some((h) => e.objects.isDescendantOf(a, h))
  49606. ? (l = !0)
  49607. : o.physics?.fusedBody === !0 && o.physics.rigidBody === 'dynamic' && s.push(a),
  49608. (n.data = o),
  49609. (n.currentState = null),
  49610. (n.reversibleToState = null),
  49611. (n.currentTransitionEvent = null);
  49612. for (let h of o.states)
  49613. (e.environment.usePhysics === !0 &&
  49614. o.physics &&
  49615. (o.physics.rigidBody === 'dynamic' || l) &&
  49616. (h.data.position !== void 0 || h.data.rotation !== void 0 || h.data.hiddenMatrix !== void 0)) ||
  49617. (n.states || (n.states = {}), (n.states[h.id] = oa.patch(o, h.data)));
  49618. dG(t, n, null, i, o.events.find((h) => h.data.type === 'Follow' || h.data.type === 'LookAt') !== void 0);
  49619. });
  49620. }
  49621. function dG(e, t, i, r, s = !1) {
  49622. t instanceof Cr && t.removeInteractionGeometry(),
  49623. t.changeSelectedState(i, { scene: e, shared: r }, s),
  49624. t instanceof Cr && t.updateGeometryGroupsIfNeeded();
  49625. }
  49626. function uG(e) {
  49627. let t;
  49628. switch (e.easing) {
  49629. case 0:
  49630. t = 'cubicBezier( 0, 0, 1, 1 )';
  49631. break;
  49632. case 1:
  49633. t = 'cubicBezier( .25, .1, .25, 1 )';
  49634. break;
  49635. case 2:
  49636. t = 'cubicBezier( .42, 0, 1, 1 )';
  49637. break;
  49638. case 3:
  49639. t = 'cubicBezier( 0, 0, .58, 1 )';
  49640. break;
  49641. case 4:
  49642. t = 'cubicBezier( .42, 0, .58, 1 )';
  49643. break;
  49644. case 5:
  49645. let { control1: i, control2: r } = e;
  49646. t = `cubicBezier(
  49647. ${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
  49648. )`;
  49649. break;
  49650. case 6:
  49651. let { mass: s, stiffness: n, damping: a, velocity: o } = e;
  49652. t = `spring( ${s}, ${n}, ${a}, ${o} )`;
  49653. break;
  49654. default:
  49655. t = 'linear';
  49656. }
  49657. return { duration: e.duration, easing: t };
  49658. }
  49659. function r2(e) {
  49660. let t = { delay: 0, loop: e.repeat === -1 ? !0 : e.repeat + 1 };
  49661. if (e.repeat === 0) (t.direction = 'normal'), (t.rewind = e.direction === 'pingpong-rewind');
  49662. else
  49663. switch (e.direction) {
  49664. case 'pingpong':
  49665. (t.direction = 'alternate'), (t.rewind = !1);
  49666. break;
  49667. case 'pingpong-rewind':
  49668. (t.direction = 'alternate'), (t.rewind = !0);
  49669. break;
  49670. default:
  49671. (t.direction = 'normal'), (t.rewind = !1);
  49672. break;
  49673. }
  49674. switch (((t.delay = 0), (t.endDelay = 0), (t.startOnceDelay = 0), (t.pingPongDelayCorrection = 0), e.delayDirection)) {
  49675. case 'start-once':
  49676. t.startOnceDelay = e.delay;
  49677. break;
  49678. case 'start':
  49679. t.delay = e.delay;
  49680. break;
  49681. case 'end':
  49682. t.endDelay = e.delay;
  49683. break;
  49684. case 'start-end':
  49685. case void 0:
  49686. (t.delay = e.delay), (t.endDelay = e.delay);
  49687. break;
  49688. }
  49689. return t.direction === 'alternate' && ((t.delay /= 2), (t.endDelay /= 2), t.delay !== 0 && (t.pingPongDelayCorrection = t.delay)), t;
  49690. }
  49691. var pG = { type: 'beginState' },
  49692. fG = { type: 'completeState', isfromEntity: !1 },
  49693. Db = class {
  49694. constructor(e, t, i, r, s, n) {
  49695. if (
  49696. ((this.object = e),
  49697. (this.data = r),
  49698. (this.sharedAssets = s),
  49699. (this.allowSlerp = n),
  49700. (this.targets = { t: 0 }),
  49701. (this.firstLoop = !0),
  49702. (this._changeBegan = !1),
  49703. (this._changeCompleted = !0),
  49704. (this.onChange = () => {
  49705. this.callback && (this.callback.update(this.targets.t), this.object.dispatchEvent({ type: 'requestRender' })),
  49706. this.targets.t === 0 || this.targets.t === 1
  49707. ? this._changeCompleted || ((this._changeCompleted = !0), (this._changeBegan = !1), this.onChangeComplete())
  49708. : (this._changeCompleted && (this._changeCompleted = !1),
  49709. this._changeBegan || ((this._changeBegan = !0), this.onChangeBegin()));
  49710. }),
  49711. (this.onChangeBegin = () => {
  49712. this.object.reversibleToState = this.to.id;
  49713. let a = this.targets.t > 0.5 ? this.from.id : this.to.id;
  49714. this.object.prevState !== this.object.currentState && (this.object.prevState = this.object.currentState),
  49715. (this.object.currentState = a),
  49716. this.object.dispatchEvent({ type: 'beginState', state: a }),
  49717. this.object.traverseEntity((o) => {
  49718. o !== this.object && o instanceof Gi && o.dispatchEvent(pG);
  49719. });
  49720. }),
  49721. (this.onChangeComplete = () => {
  49722. this.firstLoop && (this.onFirstLoop(), (this.firstLoop = !1)), (this.object.reversibleToState = this.to.id);
  49723. let a = this.targets.t < 0.5 ? this.from.id : this.to.id;
  49724. this.object.prevState !== this.object.currentState && (this.object.prevState = this.object.currentState),
  49725. (this.object.currentState = a),
  49726. this.object.dispatchEvent({ type: 'completeState', state: a }),
  49727. this.object.traverseEntity((o) => {
  49728. o !== this.object && o instanceof Gi && o.dispatchEvent(fG);
  49729. });
  49730. }),
  49731. (this.onFirstLoop = () => {
  49732. this.useCurrentState && (this.callback = Tb(this.object, this.from.data, this.to.data, this.sharedAssets, this.allowSlerp));
  49733. }),
  49734. t === void 0)
  49735. ) {
  49736. let a = cd(this.object, this.object.currentState === i ? this.object.prevState : this.object.currentState);
  49737. if (!a) throw new Error('Missing property');
  49738. this.from = a;
  49739. } else {
  49740. let a = cd(this.object, t);
  49741. if (!a) throw new Error('Missing property');
  49742. this.from = a;
  49743. }
  49744. if (i === void 0) throw new Error('Missing property');
  49745. {
  49746. let a = cd(this.object, i);
  49747. if (!a) throw new Error('Missing property');
  49748. this.to = a;
  49749. }
  49750. (this.useCurrentState = t === void 0 || i === void 0),
  49751. (this.params = { targets: this.targets, t: 1, autoplay: !1, ...r2(r), ...uG(r), change: this.onChange }),
  49752. (this.callback = Tb(
  49753. this.object,
  49754. t === void 0 ? {} : this.from.data,
  49755. i === void 0 ? {} : this.to.data,
  49756. this.sharedAssets,
  49757. this.allowSlerp
  49758. ));
  49759. }
  49760. get changeBegan() {
  49761. return this._changeBegan;
  49762. }
  49763. get changeCompleted() {
  49764. return this._changeCompleted;
  49765. }
  49766. },
  49767. _o = class extends Vi {
  49768. constructor(e, t, i) {
  49769. if (
  49770. (super(),
  49771. (this.data = e),
  49772. (this.scene = t),
  49773. (this.sharedAssets = i),
  49774. (this.toggleIsForward = !1),
  49775. (this.timelineNeedsRebuild = !1),
  49776. (this.useToggle = !1),
  49777. (this.onTimelineChangeComplete = () => {
  49778. this.data.tweens[0].data.direction !== 'normal' && (this.toggleIsForward = !this.toggleIsForward),
  49779. this.timelineNeedsRebuild !== !1 &&
  49780. (this.timeline?.pause(), this.buildTimeline({ isForward: this.toggleIsForward, isRebuild: !0 }), this.timeline.play());
  49781. }),
  49782. !e.object)
  49783. )
  49784. throw new Error('Missing property');
  49785. let r = t.find(e.object);
  49786. if (!r) throw new Error('Missing property');
  49787. if (!r.states) throw new Error('Missing property');
  49788. if (((this.object = r), e.tweens.length < 2)) throw new Error('Missing property');
  49789. (this.tweens = Array(this.data.tweens.length - 1)),
  49790. (this.startOnceDelay = e.tweens[0].data.delayDirection === 'start-once' ? e.tweens[0].data.delay : 0),
  49791. this.init();
  49792. }
  49793. get playing() {
  49794. return this.tweens.some((e) => e.changeBegan) ?? !1;
  49795. }
  49796. init() {
  49797. (this.initialCurrentState = cd(this.object, this.object.currentState).id), (this.toggleIsForward = !1);
  49798. }
  49799. get currentState() {
  49800. return this.useToggle ? this.initialCurrentState : this.object.currentState;
  49801. }
  49802. buildTimeline({ isForward: e = !0, isRebuild: t = !1 } = {}) {
  49803. try {
  49804. let i = r2(this.data.tweens[0].data),
  49805. r = i.loop;
  49806. t && typeof i.loop == 'number' && i.loop--,
  49807. this.timeline?.pause(),
  49808. (this.timeline = Uj.timeline({
  49809. autoplay: !1,
  49810. ...i,
  49811. ...(r === !0 || r > 1 ? { timelineChangeComplete: this.onTimelineChangeComplete } : {})
  49812. }));
  49813. let s = this.tweens.findIndex((n) => n?.changeBegan);
  49814. if (
  49815. ((this.timelineNeedsRebuild = s !== -1 && (r === !0 || r > 1)),
  49816. i.pingPongDelayCorrection && t === !1 && (this.timelineNeedsRebuild = !0),
  49817. e)
  49818. ) {
  49819. let n = s === -1 ? 0 : s;
  49820. for (let a = n; a < this.data.tweens.length - 1; a++) {
  49821. let o = this.data.tweens[a],
  49822. l = this.data.tweens[a + 1],
  49823. h;
  49824. a === n && (this.object.wasMovedByUser === !0 || this.object.previousAction?.playing === !0)
  49825. ? ((h = void 0), this.object instanceof Gi && (this.object.wasMovedByUser = !1))
  49826. : (h = o.data.state === void 0 ? this.currentState : o.data.state);
  49827. let u = new Db(
  49828. this.object,
  49829. h,
  49830. l.data.state === void 0 ? this.currentState : l.data.state,
  49831. l.data,
  49832. this.sharedAssets,
  49833. this.data.allowSlerp ?? !1
  49834. );
  49835. s !== -1 && a === n && Object.assign(u.params, { startOnceDelay: 0 }),
  49836. (this.tweens[a] = u),
  49837. this.timeline.add(
  49838. u.params,
  49839. this.timeline.duration + (a === n ? i.delay : 0) + (a === n && !t ? i.pingPongDelayCorrection : 0)
  49840. );
  49841. }
  49842. this.timeline.duration += i.endDelay;
  49843. } else {
  49844. let n = s === -1 ? this.data.tweens.length - 1 : s + 1;
  49845. for (let a = n; a > 0; a--) {
  49846. let o = this.data.tweens[a],
  49847. l = this.data.tweens[a - 1],
  49848. h;
  49849. a === n && (this.object.wasMovedByUser === !0 || this.object.previousAction?.playing === !0)
  49850. ? ((h = void 0), this.object instanceof Gi && (this.object.wasMovedByUser = !1))
  49851. : (h = o.data.state === void 0 ? this.currentState : o.data.state);
  49852. let u = new Db(
  49853. this.object,
  49854. h,
  49855. l.data.state === void 0 ? this.currentState : l.data.state,
  49856. o.data,
  49857. this.sharedAssets,
  49858. this.data.allowSlerp ?? !1
  49859. );
  49860. s !== -1 && a === n && Object.assign(u.params, { startOnceDelay: 0 }),
  49861. (this.tweens[a - 1] = u),
  49862. this.timeline.add(u.params, this.timeline.duration + (a === n ? i.endDelay : 0));
  49863. }
  49864. this.timeline.duration += i.delay + (t ? 0 : i.pingPongDelayCorrection);
  49865. }
  49866. } catch (i) {
  49867. i instanceof Error && console.error(i.message);
  49868. }
  49869. this.object.previousAction?.playing === !0 && this.object.previousAction.pause(), (this.object.previousAction = this);
  49870. }
  49871. play() {
  49872. if (this.playing) return !1;
  49873. clearTimeout(this.timeoutId),
  49874. (this.timeoutId = window.setTimeout(() => {
  49875. try {
  49876. this.buildTimeline(), this.timeline.play();
  49877. } catch (e) {
  49878. e instanceof Error && console.error(e.message);
  49879. }
  49880. }, this.startOnceDelay));
  49881. }
  49882. pause() {
  49883. this.timeline?.pause(), clearTimeout(this.timeoutId), (this.tweens = Array(this.data.tweens.length - 1)), delete this.timeoutId;
  49884. }
  49885. stop() {
  49886. this.pause();
  49887. let e = this.data.tweens[0].data.state === void 0 ? this.initialCurrentState : this.data.tweens[0].data.state;
  49888. this.object.changeSelectedState(e, { scene: this.scene, shared: this.sharedAssets }), (this.object.currentState = e);
  49889. }
  49890. seek(e) {
  49891. this.timeline === void 0 && this.buildTimeline(), this.timeline?.seek(e * this.timeline.duration);
  49892. }
  49893. toggle(e) {
  49894. (this.useToggle = !0),
  49895. clearTimeout(this.timeoutId),
  49896. (this.toggleIsForward = e ?? !this.toggleIsForward),
  49897. this.playing
  49898. ? (this.timeline?.pause(), this.buildTimeline({ isForward: this.toggleIsForward }), this.timeline.play())
  49899. : (this.timeoutId = window.setTimeout(() => {
  49900. this.timeline?.pause(), this.buildTimeline({ isForward: this.toggleIsForward }), this.timeline.play();
  49901. }, this.startOnceDelay));
  49902. }
  49903. playFromCurrent() {
  49904. this.toggle(!0);
  49905. }
  49906. reverseFromCurrent() {
  49907. this.toggle(!1);
  49908. }
  49909. dispose() {
  49910. this.pause();
  49911. }
  49912. };
  49913. function cd(e, t) {
  49914. let i, r;
  49915. if ((typeof t == 'string' ? ((i = t), (r = e.states?.[i])) : t === null && ((i = null), (r = e.data)), !(i === void 0 || r === void 0)))
  49916. return { id: i, data: r };
  49917. }
  49918. function On(e, t, i, r, s, n) {
  49919. let a = { Audio: [], Video: [], Link: [], Reset: [], Transition: [] };
  49920. return (
  49921. t.forEach(({ id: o, data: l }) => {
  49922. try {
  49923. l.type === 'Audio'
  49924. ? _l[e.type].includes('Audio') && a.Audio.push(new wo(o, l, i, s))
  49925. : l.type === 'Video'
  49926. ? _l[e.type].includes('Video') && a.Video.push(new ru(o, l, i))
  49927. : l.type === 'Link'
  49928. ? _l[e.type].includes('Link') && a.Link.push(new aj(l, n))
  49929. : l.type === 'Reset'
  49930. ? _l[e.type].includes('Reset') && a.Reset.push(new oj(r.data, r, s, n))
  49931. : l.type === 'Transition' && _l[e.type].includes('Transition') && a.Transition.push(new _o(l, r, s));
  49932. } catch {}
  49933. }),
  49934. a
  49935. );
  49936. }
  49937. function In(e) {
  49938. Object.values(e).forEach((t) => {
  49939. t.forEach((i) => {
  49940. (i instanceof wo || i instanceof ru || i instanceof _o) && i.dispose();
  49941. });
  49942. });
  49943. }
  49944. var Dv = [
  49945. ['start', 'Start'],
  49946. ['keyDown', 'KeyDown'],
  49947. ['keyUp', 'KeyUp'],
  49948. ['mouseDown', 'MouseDown'],
  49949. ['mouseUp', 'MouseUp'],
  49950. ['mouseHover', 'MouseHover'],
  49951. ['collision', 'Collision'],
  49952. ['lookAt', 'LookAt'],
  49953. ['follow', 'Follow'],
  49954. ['scroll', 'Scroll']
  49955. ],
  49956. s2 = (e) => Dv.find(([t, i]) => i === e)?.[0],
  49957. Uh = (e) => Dv.find(([t]) => t === e)?.[1],
  49958. mG = (e, t) => {
  49959. let i = s2(e);
  49960. if (i) {
  49961. let r = new CustomEvent(i, { bubbles: !0 });
  49962. return Object.defineProperty(r, 'target', { writable: !1, value: t }), r;
  49963. }
  49964. },
  49965. gG = class extends zn {
  49966. constructor(e) {
  49967. super(e),
  49968. (this.objectsPerEvents = new Map()),
  49969. (this.splineEvents = {}),
  49970. (this.onBeginEvent = (i) => {
  49971. if (!i.eventName || !i.target || i.eventName === 'Scroll') return;
  49972. let r = this.splineEvents[s2(i.eventName)]?.[i.target.uuid];
  49973. if (!r) return;
  49974. i.eventName === 'Scroll' && i.deltaY !== void 0 && Object.assign(r, { deltaY: i.deltaY });
  49975. let { domElement: s } = this.eventContext;
  49976. s.dispatchEvent(r);
  49977. });
  49978. let { scene: t } = this.eventContext;
  49979. t.traverseEntity((i) => {
  49980. if (i.data?.events.length) {
  49981. for (let [r, s] of Dv)
  49982. if (i.data.events.some((n) => n.data.type === s && !n.data.disabled)) {
  49983. this.objectsPerEvents.has(r) ? this.objectsPerEvents.get(r)?.push(i) : this.objectsPerEvents.set(r, [i]);
  49984. let n = { id: i.uuid, name: i.name },
  49985. a = mG(s, n),
  49986. o = this.splineEvents[r];
  49987. o ? (o[i.uuid] = a) : (this.splineEvents[r] = { [i.uuid]: a });
  49988. }
  49989. }
  49990. });
  49991. }
  49992. connect() {
  49993. this.objectsPerEvents.forEach((e) => {
  49994. e.forEach((t) => {
  49995. t.addEventListener('beginEvent', this.onBeginEvent);
  49996. });
  49997. });
  49998. }
  49999. disconnect() {
  50000. this.objectsPerEvents.forEach((e) => {
  50001. e.forEach((t) => {
  50002. t.removeEventListener('beginEvent', this.onBeginEvent);
  50003. });
  50004. });
  50005. }
  50006. },
  50007. vG = class {
  50008. constructor(e, t, i, r, s, n) {
  50009. if (
  50010. ((this.id = e),
  50011. (this.data = t),
  50012. (this.object = i),
  50013. (this.entered = !1),
  50014. (this.useToggle = t.toggle),
  50015. (t.type === 'KeyDown' || t.type === 'KeyUp' || t.type === 'KeyPress') && !t.key)
  50016. )
  50017. throw new Error('Missing property');
  50018. this.actions = On(t, t.actions, i, r, s, n);
  50019. }
  50020. disconnect() {
  50021. In(this.actions);
  50022. }
  50023. dispatch() {
  50024. let e = new Set();
  50025. this.actions.Transition.forEach((t) => {
  50026. t.object.currentTransitionEvent !== this ? ((t.object.currentTransitionEvent = this), t.init()) : this.useToggle === !1 && e.add(t);
  50027. }),
  50028. this.useToggle
  50029. ? this.actions.Transition.forEach((t) => {
  50030. t.toggle();
  50031. })
  50032. : this.data.type === 'MousePress' || this.data.type === 'KeyPress'
  50033. ? this.entered || ((this.entered = !0), this.actions.Transition.forEach((t) => t.playFromCurrent()))
  50034. : this.actions.Transition.some((t) => t.playing) ||
  50035. this.actions.Transition.forEach((t) => {
  50036. e.has(t) === !1 && t.play();
  50037. }),
  50038. this.actions.Link.forEach((t) => {
  50039. t.dispatch();
  50040. }),
  50041. this.actions.Reset.forEach((t) => {
  50042. t.dispatch();
  50043. }),
  50044. this.actions.Audio.forEach((t) => {
  50045. t.dispatchBasic();
  50046. }),
  50047. this.actions.Video.forEach((t) => {
  50048. t.dispatchBasic();
  50049. });
  50050. }
  50051. dispatchRelease() {
  50052. this.entered && ((this.entered = !1), this.actions.Transition.forEach((e) => e.reverseFromCurrent()));
  50053. }
  50054. dispatchUserEvent(e) {
  50055. this.actions.Transition.forEach((t) => {
  50056. t.object.currentTransitionEvent !== this && ((t.object.currentTransitionEvent = this), t.init());
  50057. }),
  50058. e ? this.actions.Transition.forEach((t) => t.reverseFromCurrent()) : this.actions.Transition.forEach((t) => t.playFromCurrent()),
  50059. this.actions.Link.forEach((t) => {
  50060. t.dispatch();
  50061. }),
  50062. this.actions.Reset.forEach((t) => {
  50063. t.dispatch();
  50064. }),
  50065. this.actions.Audio.forEach((t) => {
  50066. t.dispatchBasic();
  50067. }),
  50068. this.actions.Video.forEach((t) => {
  50069. t.dispatchBasic();
  50070. });
  50071. }
  50072. },
  50073. yG = class extends zn {
  50074. constructor(e, t, i) {
  50075. super(e),
  50076. (this.objectsPerTypes = { MouseDown: [], MouseUp: [], MousePress: [], KeyDown: [], KeyUp: [], KeyPress: [] }),
  50077. (this.eventsPerObjects = { MouseDown: {}, MouseUp: {}, MousePress: {}, KeyDown: {}, KeyUp: {}, KeyPress: {} }),
  50078. (this.heldKeys = {}),
  50079. (this.heldKeysPress = {}),
  50080. (this._prevObjects = []),
  50081. (this.onMouseDown = (n) => {
  50082. Qe.length > 1 || (this.eventContext.updateRaycaster(n), this.handleMouseEvent('MouseDown'));
  50083. }),
  50084. (this.onMouseUp = (n) => {
  50085. Qe.length > 1 || (this.eventContext.updateRaycaster(n), this.handleMouseEvent('MouseUp'));
  50086. }),
  50087. (this.onMousePressDown = (n) => {
  50088. Qe.length > 1 || (this.eventContext.updateRaycaster(n), this.handleMousePressEvent());
  50089. }),
  50090. (this.onMousePressRelease = (n) => {
  50091. Qe.length > 1 || (this.eventContext.updateRaycaster(n), this.handleMousePressEvent(!0));
  50092. }),
  50093. (this.onKeyDown = (n) => {
  50094. this.heldKeys[n.key] || this.handleKeyEvent(n, 'KeyDown'), (this.heldKeys[n.key] = !0);
  50095. }),
  50096. (this.onKeyUp = (n) => {
  50097. this.handleKeyEvent(n, 'KeyUp');
  50098. }),
  50099. (this.onKeyPressDown = (n) => {
  50100. this.heldKeysPress[n.key] || this.handleKeyEvent(n, 'KeyPress'), (this.heldKeysPress[n.key] = !0);
  50101. }),
  50102. (this.onKeyPressUp = (n) => {
  50103. this.handleKeyEvent(n, 'KeyPress', !0);
  50104. }),
  50105. (this.releaseHeldKey = (n) => {
  50106. delete this.heldKeys[n.key];
  50107. }),
  50108. (this.releaseHeldKeyPress = (n) => {
  50109. delete this.heldKeysPress[n.key];
  50110. }),
  50111. (this._onUserEvent = ({ eventName: n, target: a, reverse: o }) => {
  50112. if (!n || !a) return;
  50113. let l = Uh(n);
  50114. l &&
  50115. (l === 'MouseDown' || l === 'MouseUp' || l === 'MousePress'
  50116. ? (a.dispatchEvent({ type: 'beginEvent', eventName: l }),
  50117. this.eventsPerObjects[l]?.[a.uuid]?.forEach((h) => {
  50118. h.dispatchUserEvent(o);
  50119. }))
  50120. : (l === 'KeyDown' || l === 'KeyUp' || l === 'KeyPress') &&
  50121. (a.dispatchEvent({ type: 'beginEvent', eventName: l }),
  50122. this.eventsPerObjects[l]?.[a.uuid]?.forEach((h) => {
  50123. h.dispatchUserEvent();
  50124. })));
  50125. });
  50126. let { scene: r, sharedAssets: s } = this.eventContext;
  50127. r.traverseEntity((n) => {
  50128. if (!n.data?.events.length) return;
  50129. let a = n.visible ? ['MouseDown', 'MouseUp', 'MousePress', 'KeyDown', 'KeyUp', 'KeyPress'] : ['KeyDown', 'KeyUp', 'KeyPress'];
  50130. for (let o of a) {
  50131. let l = this.eventsPerObjects[o];
  50132. n.data.events
  50133. .filter(({ data: h }) => h.type === o && h.disabled !== !0)
  50134. .forEach(({ id: h, data: u }) => {
  50135. try {
  50136. let c = new vG(h, u, n, r, s, { controlsManager: t, eventManager: i });
  50137. c.actions.Video.length && (this.hasVideoAction = !0), l[n.uuid] ? l[n.uuid].push(c) : (l[n.uuid] = [c]);
  50138. } catch {}
  50139. }),
  50140. l[n.uuid]?.length && this.objectsPerTypes[o].push(n);
  50141. }
  50142. });
  50143. }
  50144. connect() {
  50145. let { domElement: e } = this.eventContext;
  50146. (this.heldKeys = {}),
  50147. (this.heldKeysPress = {}),
  50148. this.domEventsNeeded.clear(),
  50149. this.objectsPerTypes.MouseDown?.length &&
  50150. (this.domEventsNeeded.add('pointerdown'), e.addEventListener('pointerdown', this.onMouseDown)),
  50151. this.objectsPerTypes.MouseUp?.length && (this.domEventsNeeded.add('pointerup'), e.addEventListener('pointerup', this.onMouseUp)),
  50152. this.objectsPerTypes.MousePress?.length &&
  50153. (this.domEventsNeeded.add('pointerdown'),
  50154. e.addEventListener('pointerdown', this.onMousePressDown),
  50155. this.domEventsNeeded.add('pointerup'),
  50156. e.addEventListener('pointerup', this.onMousePressRelease)),
  50157. this.objectsPerTypes.KeyDown?.length &&
  50158. (this.domEventsNeeded.add('keydown'),
  50159. document.addEventListener('keydown', this.onKeyDown),
  50160. document.addEventListener('keyup', this.releaseHeldKey)),
  50161. this.objectsPerTypes.KeyUp?.length && (this.domEventsNeeded.add('keyup'), document.addEventListener('keyup', this.onKeyUp)),
  50162. this.objectsPerTypes.KeyPress?.length &&
  50163. (this.domEventsNeeded.add('keydown'),
  50164. document.addEventListener('keydown', this.onKeyPressDown),
  50165. document.addEventListener('keyup', this.releaseHeldKeyPress),
  50166. this.domEventsNeeded.add('keyup'),
  50167. document.addEventListener('keyup', this.onKeyPressUp)),
  50168. Object.entries(this.objectsPerTypes).forEach(([t, i]) => {
  50169. i.forEach((r) => {
  50170. r.addEventListener('userEvent', this._onUserEvent);
  50171. });
  50172. });
  50173. }
  50174. disconnect() {
  50175. let { domElement: e } = this.eventContext;
  50176. this.domEventsNeeded.clear(),
  50177. (this.heldKeys = {}),
  50178. (this.heldKeysPress = {}),
  50179. e.removeEventListener('pointerdown', this.onMouseDown),
  50180. e.removeEventListener('pointerdown', this.onMousePressDown),
  50181. e.removeEventListener('pointerup', this.onMouseUp),
  50182. e.removeEventListener('pointerup', this.onMousePressRelease),
  50183. document.removeEventListener('keydown', this.onKeyDown),
  50184. document.removeEventListener('keyup', this.onKeyUp),
  50185. document.removeEventListener('keydown', this.onKeyPressDown),
  50186. document.removeEventListener('keyup', this.onKeyPressUp),
  50187. document.removeEventListener('keyup', this.releaseHeldKey),
  50188. Object.values(this.eventsPerObjects).forEach((t) => {
  50189. Object.values(t).forEach((i) => {
  50190. i.forEach((r) => {
  50191. r.disconnect();
  50192. });
  50193. });
  50194. }),
  50195. Object.entries(this.objectsPerTypes).forEach(([t, i]) => {
  50196. i.forEach((r) => {
  50197. r.removeEventListener('userEvent', this._onUserEvent);
  50198. });
  50199. });
  50200. }
  50201. handleMouseEvent(e) {
  50202. let { stopRaycast: t, raycaster: i, scene: r } = this.eventContext,
  50203. s = this.objectsPerTypes[e];
  50204. if (s.length)
  50205. if (t) {
  50206. let n = Km(i, r, s);
  50207. Jm(n).forEach((a) => {
  50208. this.eventsPerObjects[e][a.uuid] && this.handleObjectMouseEventDispatch(a, e);
  50209. });
  50210. } else
  50211. s.forEach((n) => {
  50212. iu(i, n) && this.handleObjectMouseEventDispatch(n, e);
  50213. });
  50214. }
  50215. handleMousePressEvent(e = !1) {
  50216. let t = 'MousePress',
  50217. i = this.objectsPerTypes[t],
  50218. r = [];
  50219. if (i.length) {
  50220. if (!e) {
  50221. let { stopRaycast: s, raycaster: n, scene: a } = this.eventContext;
  50222. if (s) {
  50223. let o = Km(n, a, i);
  50224. r = Jm(o);
  50225. } else
  50226. i.forEach((o) => {
  50227. iu(n, o) && r.push(o);
  50228. });
  50229. }
  50230. this._prevObjects.length &&
  50231. this._prevObjects.forEach((s) => {
  50232. r.includes(s) || this.handleObjectMouseEventDispatchRelease(s, t);
  50233. }),
  50234. r.length &&
  50235. r.forEach((s) => {
  50236. this.handleObjectMouseEventDispatch(s, t);
  50237. }),
  50238. (this._prevObjects = r);
  50239. }
  50240. }
  50241. handleObjectMouseEventDispatch(e, t) {
  50242. e.dispatchEvent({ type: 'beginEvent', eventName: t }),
  50243. this.eventsPerObjects[t]?.[e.uuid]?.forEach((i) => {
  50244. i.dispatch();
  50245. });
  50246. }
  50247. handleObjectMouseEventDispatchRelease(e, t) {
  50248. e.dispatchEvent({ type: 'beginEvent', eventName: t }),
  50249. this.eventsPerObjects[t]?.[e.uuid]?.forEach((i) => {
  50250. i.dispatchRelease();
  50251. });
  50252. }
  50253. handleKeyEvent(e, t, i = !1) {
  50254. this.objectsPerTypes[t].forEach((r) => {
  50255. let s = this.eventsPerObjects[t][r.uuid];
  50256. s.some(({ data: n }) => 'key' in n && n.key === e.key) && r.dispatchEvent({ type: 'beginEvent', eventName: t }),
  50257. s.forEach((n) => {
  50258. 'key' in n.data && n.data.key === e.key && (i ? n.dispatchRelease() : n.dispatch());
  50259. });
  50260. });
  50261. }
  50262. },
  50263. xG = new E(),
  50264. bG = new E(),
  50265. n2 = class {
  50266. constructor(e, t, i, r) {
  50267. (this.actionsIn = On(e, e.inActions, t, i, r)), (this.actionsOut = On(e, e.outActions, t, i, r));
  50268. }
  50269. disconnect() {
  50270. In(this.actionsIn), In(this.actionsOut);
  50271. }
  50272. },
  50273. wG = class extends n2 {
  50274. constructor(e, t, i, r, s) {
  50275. super(t, i, r, s),
  50276. (this.id = e),
  50277. (this.data = t),
  50278. (this.object = i),
  50279. (this.stage = 'out'),
  50280. (this.objects = []),
  50281. (this.onUpdateMatrix = () => {
  50282. let l = xG.setFromMatrixPosition(this.objects[0].matrixWorld),
  50283. h = bG.setFromMatrixPosition(this.objects[1].matrixWorld),
  50284. u = l.distanceTo(h) <= this.distance ? 'in' : 'out';
  50285. if (this.stage !== u) {
  50286. let c = u === 'in' ? this.actionsIn : this.actionsOut;
  50287. c.Audio.forEach((d) => d.dispatchConditional()),
  50288. c.Video.forEach((d) => d.dispatchConditional()),
  50289. c.Transition.forEach((d) => {
  50290. d.object.currentTransitionEvent !== this && (d.object.currentTransitionEvent = this), d.init();
  50291. }),
  50292. c.Transition.forEach((d) => d.play()),
  50293. (this.stage = u);
  50294. }
  50295. });
  50296. let { distance: n, fromObject: a, toObject: o } = t.condition;
  50297. this.distance = n;
  50298. for (let l of [a, o]) {
  50299. if (!l) throw new Error('Missing property');
  50300. let h = r.find(l);
  50301. if (!h) throw new Error('Missing property');
  50302. this.objects.push(h);
  50303. }
  50304. }
  50305. connect() {
  50306. this.objects.forEach((e) => {
  50307. e.addEventListener('updateMatrix', this.onUpdateMatrix);
  50308. }),
  50309. this.onUpdateMatrix();
  50310. }
  50311. disconnect() {
  50312. super.disconnect(),
  50313. (this.stage = 'out'),
  50314. this.objects.forEach((e) => {
  50315. e.removeEventListener('updateMatrix', this.onUpdateMatrix);
  50316. });
  50317. }
  50318. },
  50319. _G = class extends n2 {
  50320. constructor(e, t, i, r, s) {
  50321. super(t, i, r, s),
  50322. (this.id = e),
  50323. (this.data = t),
  50324. (this.object = i),
  50325. (this.onBegin = ({ target: o, state: l }) => {
  50326. this.toState !== l &&
  50327. (this.actionsOut.Audio.forEach((h) => h.dispatchConditional()),
  50328. this.actionsOut.Video.forEach((h) => h.dispatchConditional()),
  50329. this.actionsIn.Transition.forEach((h) => h.pause()),
  50330. (this.object.currentTransitionEvent = this),
  50331. this.actionsOut.Transition.forEach((h) => h.play()));
  50332. }),
  50333. (this.onComplete = ({ target: o, state: l }) => {
  50334. this.toState === l &&
  50335. (this.actionsIn.Audio.forEach((h) => h.dispatchConditional()),
  50336. this.actionsIn.Video.forEach((h) => h.dispatchConditional()),
  50337. this.actionsOut.Transition.forEach((h) => h.pause()),
  50338. (this.object.currentTransitionEvent = this),
  50339. this.actionsIn.Transition.forEach((h) => h.play()));
  50340. });
  50341. let { condition: n } = t;
  50342. if (!n.object) throw new Error('Missing property');
  50343. let a = r.find(n.object);
  50344. if (!a) throw new Error('Missing property');
  50345. if (((this.toObject = a), n.state && !this.toObject.states?.[n.state])) throw new Error('Missing property');
  50346. this.toState = n.state;
  50347. }
  50348. connect() {
  50349. (this.actionsOut.Audio.length || this.actionsOut.Video.length || this.actionsOut.Transition.length) &&
  50350. this.toObject.addEventListener('beginState', this.onBegin),
  50351. (this.actionsIn.Audio.length || this.actionsIn.Video.length || this.actionsIn.Transition.length) &&
  50352. this.toObject.addEventListener('completeState', this.onComplete);
  50353. }
  50354. disconnect() {
  50355. super.disconnect(),
  50356. (this.actionsOut.Audio.length || this.actionsOut.Video.length || this.actionsOut.Transition.length) &&
  50357. this.toObject.removeEventListener('beginState', this.onBegin),
  50358. (this.actionsIn.Audio.length || this.actionsIn.Video.length || this.actionsIn.Transition.length) &&
  50359. this.toObject.removeEventListener('completeState', this.onComplete);
  50360. }
  50361. },
  50362. AG = class extends zn {
  50363. constructor(e) {
  50364. super(e), (this.eventsPerConditions = { Comparison: [], Distance: [], State: [] }), (this.hasVideoAction = !1);
  50365. let { scene: t, sharedAssets: i } = this.eventContext;
  50366. t.traverseEntity((r) => {
  50367. if (r.data?.events.length) {
  50368. for (let { id: s, data: n } of r.data.events)
  50369. if (!n.disabled && n.type === 'Conditional')
  50370. try {
  50371. let a;
  50372. n.condition.type === 'Comparison' ||
  50373. (n.condition.type === 'Distance'
  50374. ? (a = new wG(s, n, r, t, i))
  50375. : n.condition.type === 'State' && (a = new _G(s, n, r, t, i))),
  50376. a &&
  50377. (this.eventsPerConditions[n.condition.type].push(a),
  50378. (a.actionsIn.Video.length || a.actionsOut.Video.length) && (this.hasVideoAction = !0));
  50379. } catch {}
  50380. }
  50381. });
  50382. }
  50383. connect() {
  50384. super.connect(), Object.values(this.eventsPerConditions).forEach((e) => e.forEach((t) => t.connect()));
  50385. }
  50386. disconnect() {
  50387. super.disconnect(), Object.values(this.eventsPerConditions).forEach((e) => e.forEach((t) => t.disconnect()));
  50388. }
  50389. },
  50390. to = new E(),
  50391. xf = new E(),
  50392. Rs = new E(),
  50393. Bs = new E(),
  50394. Lb = new yr(),
  50395. SG = 0.01,
  50396. MG = { type: 'requestRender' },
  50397. EG = (function () {
  50398. let e = new E(),
  50399. t = new E();
  50400. return (i, r, s) => (s > 0 ? (e.subVectors(i, r), e.length() <= s ? i : t.copy(r).add(e.normalize().multiplyScalar(s))) : r);
  50401. })(),
  50402. Ob = (function () {
  50403. let e = new ve();
  50404. return (t, i) => {
  50405. t.position.copy(i),
  50406. t.parent !== null && (e.copy(t.parent.matrixWorld).invert(), t.position.applyMatrix4(e)),
  50407. e.copy(t.hiddenMatrix).invert(),
  50408. t.position.applyMatrix4(e),
  50409. t.updateMatrix(),
  50410. t.hasNonUniformScale && (t.updateMatrixWorld(), t.updateMatrixWorldSVD()),
  50411. t instanceof ar && Sn(t.parent) && t.invalidateDownstreamBooleanData(!0);
  50412. };
  50413. })(),
  50414. CG = class {
  50415. constructor(e, t, i) {
  50416. (this.data = e),
  50417. (this.object = t),
  50418. (this.paused = !1),
  50419. (this.currentDampingFactor = 1),
  50420. (this.snapComplete = !1),
  50421. (this.isReset = !1),
  50422. (this.worldPosition0 = new E()),
  50423. (this.timeoutId = null),
  50424. (this.delayFinished = !0),
  50425. (this.wasOutside = !1),
  50426. (this.data = { ...dm.defaultData, ...e, ...(e.resetOnPointerLeave === void 0 && { resetOnPointerLeave: !1 }) }),
  50427. e.target === void 0 ||
  50428. e.target === 'cursor' ||
  50429. (e.target === 'personal camera' ? (this.target = i.find(sl.PERSONAL_CAMERA_ID)) : (this.target = i.find(e.target))),
  50430. this.data.dampingFactor && (this.currentDampingFactor = this.data.dampingFactor),
  50431. (this.resetDampingFactor = 80 / this.data.resetSpeed + 1),
  50432. this.object.getWorldPosition(this.worldPosition0);
  50433. }
  50434. },
  50435. TG = class extends zn {
  50436. constructor(e) {
  50437. super(e),
  50438. (this.events = []),
  50439. (this.pairOfEventListeners = []),
  50440. (this.onMouseMove = (i) => {
  50441. if (!(Qe.length > 1)) {
  50442. this.eventContext.updateRaycaster(i);
  50443. for (let r of this.events) r.target === void 0 && this.updateSingleEvent(r);
  50444. }
  50445. }),
  50446. (this.onMouseEnter = (i) => {
  50447. for (let r of this.events) r.target === void 0 && ((r.isReset = !1), (r.currentDampingFactor = r.data.dampingFactor));
  50448. }),
  50449. (this.onMouseLeave = (i) => {
  50450. for (let r of this.events)
  50451. r.target === void 0 &&
  50452. (r.data.resetOnPointerLeave && ((r.isReset = !0), (r.currentDampingFactor = r.resetDampingFactor)),
  50453. this.updateSingleEvent(r));
  50454. }),
  50455. (this.onTargetChange = (i) => () => {
  50456. this.updateSingleEvent(i);
  50457. });
  50458. let { scene: t } = this.eventContext;
  50459. t.traverseEntity((i) => {
  50460. let r = i.data?.events.find((s) => s.data.type === 'Follow' && !s.data.disabled);
  50461. r && (!t.data.environment.usePhysics || i.dataPatched.physics?.rigidBody !== 'dynamic') && this.events.push(new CG(r.data, i, t));
  50462. });
  50463. }
  50464. connect() {
  50465. if (!this.events.length) return;
  50466. let { domElement: e, eventElement: t } = this.eventContext;
  50467. this.domEventsNeeded.clear(),
  50468. rr && (this.domEventsNeeded.add('pointerdown'), e.addEventListener('pointerdown', this.onMouseMove)),
  50469. this.domEventsNeeded.add('pointermove'),
  50470. t.addEventListener('pointermove', this.onMouseMove),
  50471. this.eventContext.useWindowEvents ||
  50472. (e.addEventListener('pointerenter', this.onMouseEnter), e.addEventListener('pointerleave', this.onMouseLeave));
  50473. for (let i of this.events)
  50474. if (i.target !== void 0) {
  50475. let r = i.target,
  50476. s = this.onTargetChange(i);
  50477. this.pairOfEventListeners.push([r, s]), r.addEventListener('requestRender', s);
  50478. }
  50479. }
  50480. disconnect() {
  50481. if (!this.events.length) return;
  50482. let { domElement: e, eventElement: t } = this.eventContext;
  50483. this.domEventsNeeded.clear(),
  50484. rr && e.removeEventListener('pointerdown', this.onMouseMove),
  50485. t.removeEventListener('pointermove', this.onMouseMove),
  50486. e.removeEventListener('pointerenter', this.onMouseEnter),
  50487. e.removeEventListener('pointerleave', this.onMouseLeave);
  50488. for (let [i, r] of this.pairOfEventListeners) i.removeEventListener('requestRender', r);
  50489. for (let i of this.events) (i.paused = !0), (i.isReset = !1);
  50490. }
  50491. onAnimationFrameDamping() {
  50492. for (let e of this.events) e.paused || this.updateSingleEvent(e);
  50493. }
  50494. updateSingleEvent(e) {
  50495. let { plane: t, limitDistance: i, limitDistanceEnabled: r } = e.data;
  50496. if ((e.object.getWorldPosition(Rs), e.isReset)) Bs.copy(e.worldPosition0);
  50497. else if (e.target) e.target.getWorldPosition(Bs);
  50498. else {
  50499. let { camera: n, raycaster: a } = this.eventContext;
  50500. if (
  50501. (t === 'custom'
  50502. ? (n.getWorldDirection(xf), xf.negate(), to.copy(xf))
  50503. : t === 'xy'
  50504. ? to.set(0, 0, 1)
  50505. : t === 'xz'
  50506. ? to.set(0, 1, 0)
  50507. : t === 'yz' && to.set(1, 0, 0),
  50508. Lb.setFromNormalAndCoplanarPoint(to, Rs),
  50509. !a.ray.intersectPlane(Lb, Bs))
  50510. )
  50511. return;
  50512. }
  50513. if (!e.isReset) {
  50514. if (Bs.distanceTo(e.worldPosition0) > i && r && e.target)
  50515. if (
  50516. ((e.snapComplete = !1),
  50517. e.data.snapDelay &&
  50518. ((e.delayFinished = !1),
  50519. typeof window < 'u' && e.timeoutId !== null && (window.clearTimeout(e.timeoutId), (e.timeoutId = null))),
  50520. (e.wasOutside = !0),
  50521. e.data.resetAfterDistanceLimit)
  50522. )
  50523. Bs.copy(e.worldPosition0), (e.currentDampingFactor = e.resetDampingFactor);
  50524. else return;
  50525. else if (
  50526. (e.wasOutside &&
  50527. (e.data.snapDelay &&
  50528. typeof window < 'u' &&
  50529. (e.timeoutId = window.setTimeout(() => {
  50530. (e.delayFinished = !0), (e.paused = !1), this.updateSingleEvent(e);
  50531. }, e.data.snapDelay * 1e3)),
  50532. (e.currentDampingFactor = e.data.dampingFactor),
  50533. (e.wasOutside = !1)),
  50534. e.delayFinished === !1)
  50535. )
  50536. return;
  50537. }
  50538. e.data.enabledTranslation[0] === !1 && (Bs.x = Rs.x),
  50539. e.data.enabledTranslation[1] === !1 && (Bs.y = Rs.y),
  50540. e.data.enabledTranslation[2] === !1 && (Bs.z = Rs.z);
  50541. let s = EG(Rs, Bs, e.wasOutside ? 0 : e.data.maxDelta);
  50542. if (e.currentDampingFactor > 1) {
  50543. let n = to.subVectors(s, Rs).divideScalar(e.currentDampingFactor);
  50544. Rs.add(n), Ob(e.object, Rs), (e.paused = n.length() < SG);
  50545. } else Ob(e.object, s), (e.paused = !0);
  50546. e.object?.dispatchEvent({ type: 'beginEvent', eventName: 'Follow' }), e.object.dispatchEvent(MG);
  50547. }
  50548. },
  50549. Nl = new E(),
  50550. Xc = new E(),
  50551. Ul = new ve(),
  50552. io = new ct(),
  50553. an = new ct(),
  50554. Fl = new E(),
  50555. kl = new E(),
  50556. Zn = new E(),
  50557. zs = new E(),
  50558. bf = new yr(),
  50559. PG = 1e-6,
  50560. DG = { type: 'requestRender' },
  50561. LG = { type: 'changeRotation' },
  50562. Ib = (function () {
  50563. let e = new ve();
  50564. return function (t, i) {
  50565. t.parent !== null ? e.multiplyMatrices(t.parent.matrixWorld, t.hiddenMatrix) : e.copy(t.hiddenMatrix),
  50566. i.premultiply(OS(e).invert()),
  50567. t.rotation.setFromRotationMatrix(i),
  50568. t.updateMatrix(),
  50569. t instanceof ar && Sn(t.parent) && t.invalidateDownstreamBooleanData(!0);
  50570. };
  50571. })(),
  50572. OG = class {
  50573. constructor(e, t, i) {
  50574. (this.object = t),
  50575. (this.paused = !1),
  50576. (this.currentDampingFactor = 1),
  50577. (this.isReset = !1),
  50578. (this.worldQuaternion0 = new ct()),
  50579. (this.timeoutId = null),
  50580. (this.delayFinished = !0),
  50581. (this.wasOutside = !1),
  50582. (this.data = { ...um.defaultData, ...e, ...(e.resetOnPointerLeave === void 0 && { resetOnPointerLeave: !1 }) }),
  50583. e.target === void 0 ||
  50584. e.target === 'cursor' ||
  50585. (e.target === 'personal camera' ? (this.target = i.find(sl.PERSONAL_CAMERA_ID)) : (this.target = i.find(e.target))),
  50586. this.data.dampingFactor && (this.currentDampingFactor = this.data.dampingFactor),
  50587. this.object.getWorldQuaternion(this.worldQuaternion0),
  50588. (this.resetDampingFactor = 80 / this.data.resetSpeed + 1);
  50589. }
  50590. },
  50591. IG = class extends zn {
  50592. constructor(e) {
  50593. super(e),
  50594. (this.events = []),
  50595. (this.pairOfEventListeners = []),
  50596. (this.pairOfUserEventListeners = []),
  50597. (this.onMouseMove = (i) => {
  50598. if (!(Qe.length > 1)) {
  50599. (this._lastMouseEvent = i), this.eventContext.updateRaycaster(i);
  50600. for (let r of this.events) r.target === void 0 && this.updateSingleEvent(r);
  50601. }
  50602. }),
  50603. (this.onMouseEnter = (i) => {
  50604. for (let r of this.events) r.target === void 0 && ((r.isReset = !1), (r.currentDampingFactor = r.data.dampingFactor));
  50605. }),
  50606. (this.onMouseLeave = (i) => {
  50607. for (let r of this.events)
  50608. r.target === void 0 &&
  50609. (r.data.resetOnPointerLeave && ((r.isReset = !0), (r.currentDampingFactor = r.resetDampingFactor)),
  50610. this.updateSingleEvent(r));
  50611. }),
  50612. (this.onScroll = (i) => {
  50613. if (this._lastMouseEvent) {
  50614. let r = new PointerEvent('pointermove', {
  50615. clientX: this._lastMouseEvent.clientX,
  50616. clientY: this._lastMouseEvent.clientY,
  50617. bubbles: !0,
  50618. cancelable: !0,
  50619. view: window
  50620. });
  50621. this.eventContext.eventElement.dispatchEvent(r);
  50622. }
  50623. }),
  50624. (this.onTargetChange = (i) => () => {
  50625. this.updateSingleEvent(i);
  50626. }),
  50627. (this.createUserEventListener =
  50628. (i) =>
  50629. ({ eventName: r, target: s }) => {
  50630. if (!r || !s) return;
  50631. let n = Uh(r);
  50632. n && n === 'LookAt' && this.updateSingleEvent(i);
  50633. });
  50634. let { scene: t } = this.eventContext;
  50635. t.traverseEntity((i) => {
  50636. let r = i.data?.events.find((s) => s.data.type === 'LookAt' && !s.data.disabled);
  50637. r && (!t.data.environment.usePhysics || i.dataPatched.physics?.rigidBody !== 'dynamic') && this.events.push(new OG(r.data, i, t));
  50638. });
  50639. }
  50640. connect() {
  50641. if (!this.events.length) return;
  50642. let { domElement: e, eventElement: t } = this.eventContext;
  50643. this.domEventsNeeded.clear(),
  50644. rr && (this.domEventsNeeded.add('pointerdown'), e.addEventListener('pointerdown', this.onMouseMove)),
  50645. this.domEventsNeeded.add('pointermove'),
  50646. t.addEventListener('pointermove', this.onMouseMove),
  50647. this.eventContext.useWindowEvents
  50648. ? t.addEventListener('scroll', this.onScroll)
  50649. : (e.addEventListener('pointerenter', this.onMouseEnter), e.addEventListener('pointerleave', this.onMouseLeave));
  50650. for (let i of this.events) {
  50651. if (i.target !== void 0) {
  50652. let n = this.onTargetChange(i),
  50653. a = i.target;
  50654. this.pairOfEventListeners.push([a, n]), a.addEventListener('requestRender', n);
  50655. }
  50656. let r = this.createUserEventListener(i),
  50657. s = i.object;
  50658. this.pairOfUserEventListeners.push([s, r]), s.addEventListener('userEvent', r);
  50659. }
  50660. }
  50661. disconnect() {
  50662. if (!this.events.length) return;
  50663. let { domElement: e, eventElement: t } = this.eventContext;
  50664. this.domEventsNeeded.clear(),
  50665. rr && e.removeEventListener('pointerdown', this.onMouseMove),
  50666. t.removeEventListener('pointermove', this.onMouseMove),
  50667. e.removeEventListener('pointerenter', this.onMouseEnter),
  50668. e.removeEventListener('pointerleave', this.onMouseLeave),
  50669. t.removeEventListener('scroll', this.onScroll);
  50670. for (let [i, r] of this.pairOfEventListeners) i.removeEventListener('requestRender', r);
  50671. for (let [i, r] of this.pairOfUserEventListeners) i.removeEventListener('userEvent', r);
  50672. for (let i of this.events) (i.paused = !0), (i.isReset = !1);
  50673. }
  50674. onAnimationFrameDamping() {
  50675. for (let e of this.events) e.paused || this.updateSingleEvent(e);
  50676. }
  50677. updateSingleEvent(e) {
  50678. let { tilt: t, axis: i, distance: r, plane: s, limitDistance: n, enabledRotation: a, limitDistanceEnabled: o } = e.data,
  50679. { camera: l, raycaster: h } = this.eventContext,
  50680. { object: u, target: c } = e;
  50681. if ((u.getWorldPosition(Fl), !e.isReset))
  50682. if (e.target) e.target.getWorldPosition(kl);
  50683. else {
  50684. if (
  50685. (s === 'custom'
  50686. ? (l.getWorldDirection(Xc), Xc.negate(), bf.setFromNormalAndCoplanarPoint(Xc, Fl))
  50687. : (s === 'xy' ? Nl.set(0, 0, 1) : s === 'xz' ? Nl.set(0, 1, 0) : s === 'yz' && Nl.set(1, 0, 0),
  50688. bf.setFromNormalAndCoplanarPoint(Nl, Fl)),
  50689. !h.ray.intersectPlane(bf, kl))
  50690. )
  50691. return;
  50692. r > 0 && (s === 'custom' || s === void 0) && kl.addScaledVector(Xc, r);
  50693. }
  50694. if (
  50695. (e.isReset ||
  50696. (c
  50697. ? t === 'target'
  50698. ? Zn.copy(c.up).applyMatrix4(Ul.extractRotation(c.matrixWorld)).normalize()
  50699. : a.some((d) => d === !1)
  50700. ? (i === 'x'
  50701. ? (zs.set(0, 0, 1), a[2] === !1 && zs.set(0, 1, 0))
  50702. : i === 'y'
  50703. ? (zs.set(1, 0, 0), a[0] === !1 && zs.set(0, 0, 1))
  50704. : (zs.set(0, 1, 0), a[1] === !1 && zs.set(1, 0, 0)),
  50705. Zn.copy(zs).applyQuaternion(e.worldQuaternion0).normalize())
  50706. : Zn.set(0, 1, 0)
  50707. : s === 'custom'
  50708. ? Zn.set(0, 1, 0)
  50709. : Zn.copy(Nl)),
  50710. e.isReset)
  50711. )
  50712. an.copy(e.worldQuaternion0);
  50713. else if (Fl.distanceTo(kl) > n && o && c)
  50714. if (
  50715. (e.data.snapDelay &&
  50716. ((e.delayFinished = !1),
  50717. typeof window < 'u' && e.timeoutId !== null && (window.clearTimeout(e.timeoutId), (e.timeoutId = null))),
  50718. (e.wasOutside = !0),
  50719. e.data.resetAfterDistanceLimit)
  50720. )
  50721. an.copy(e.worldQuaternion0), (e.currentDampingFactor = e.resetDampingFactor);
  50722. else return;
  50723. else {
  50724. if (
  50725. (e.wasOutside &&
  50726. (e.data.snapDelay &&
  50727. typeof window < 'u' &&
  50728. (e.timeoutId = window.setTimeout(() => {
  50729. (e.delayFinished = !0), (e.paused = !1), this.updateSingleEvent(e);
  50730. }, e.data.snapDelay * 1e3)),
  50731. (e.currentDampingFactor = e.data.dampingFactor),
  50732. (e.wasOutside = !1)),
  50733. e.delayFinished === !1)
  50734. )
  50735. return;
  50736. RG(Ul, kl, Fl, Zn, i, zs),
  50737. an.setFromRotationMatrix(Ul),
  50738. io.setFromUnitVectors(zs.applyQuaternion(an), Zn),
  50739. a.some((d) => d === !1) && t !== 'target' && an.premultiply(io).normalize();
  50740. }
  50741. e.currentDampingFactor > 1
  50742. ? (u.updateWorldMatrix(!0, !1),
  50743. io.setFromRotationMatrix(OS(u.matrixWorld)),
  50744. io.slerp(an, 1 / e.currentDampingFactor),
  50745. Ib(u, Ul.makeRotationFromQuaternion(io)),
  50746. (e.paused = 8 * (1 - io.dot(an)) < PG))
  50747. : (Ib(u, Ul.makeRotationFromQuaternion(an)), (e.paused = !0)),
  50748. e.object?.dispatchEvent({ type: 'beginEvent', eventName: 'LookAt' }),
  50749. u.dispatchEvent(DG),
  50750. u.dispatchEvent(LG);
  50751. }
  50752. },
  50753. ur = new E(),
  50754. ei = new E(),
  50755. Gt = new E();
  50756. function RG(e, t, i, r, s, n) {
  50757. let a = e.elements;
  50758. Gt.subVectors(t, i),
  50759. Gt.lengthSq() === 0 && (Gt.z = 1),
  50760. Gt.normalize(),
  50761. ei.crossVectors(r, Gt),
  50762. ei.lengthSq() === 0 && (Math.abs(r.z) === 1 ? (Gt.x += 1e-4) : (Gt.z += 1e-4), Gt.normalize(), ei.crossVectors(r, Gt)),
  50763. ei.normalize(),
  50764. ur.crossVectors(Gt, ei),
  50765. s === 'x'
  50766. ? n.z === 1
  50767. ? ([ei, ur, Gt] = [Gt, ei, ur])
  50768. : (ei.negate(), ([ei, Gt] = [Gt, ei]))
  50769. : s === 'y'
  50770. ? n.x === 1
  50771. ? ([ei, ur, Gt] = [ur, Gt, ei])
  50772. : (ei.negate(), ([ur, Gt] = [Gt, ur]))
  50773. : n.x === 1 && (ei.negate(), ([ei, ur] = [ur, ei])),
  50774. (a[0] = ei.x),
  50775. (a[4] = ur.x),
  50776. (a[8] = Gt.x),
  50777. (a[1] = ei.y),
  50778. (a[5] = ur.y),
  50779. (a[9] = Gt.y),
  50780. (a[2] = ei.z),
  50781. (a[6] = ur.z),
  50782. (a[10] = Gt.z);
  50783. }
  50784. var BG = class {
  50785. constructor(e, t, i, r, s) {
  50786. (this.id = e), (this.data = t), (this.object = i), (this.entered = !1), (this.actions = On(t, t.actions, i, r, s));
  50787. }
  50788. disconnect() {
  50789. In(this.actions);
  50790. }
  50791. dispatchEnter() {
  50792. this.actions.Transition.forEach((e) => {
  50793. e.object.currentTransitionEvent !== this && ((e.object.currentTransitionEvent = this), e.init());
  50794. }),
  50795. this.entered || ((this.entered = !0), this.actions.Transition.forEach((e) => e.playFromCurrent()));
  50796. }
  50797. dispatchLeave() {
  50798. this.actions.Transition.forEach((e) => {
  50799. e.object.currentTransitionEvent !== this && ((e.object.currentTransitionEvent = this), e.init());
  50800. }),
  50801. this.entered && ((this.entered = !1), this.actions.Transition.forEach((e) => e.reverseFromCurrent()));
  50802. }
  50803. dispatchUserEvent(e) {
  50804. this.actions.Transition.forEach((t) => {
  50805. t.object.currentTransitionEvent !== this && ((t.object.currentTransitionEvent = this), t.init());
  50806. }),
  50807. e ? this.actions.Transition.forEach((t) => t.reverseFromCurrent()) : this.actions.Transition.forEach((t) => t.playFromCurrent());
  50808. }
  50809. },
  50810. zG = class extends zn {
  50811. constructor(e) {
  50812. super(e),
  50813. (this.eventsPerObjects = {}),
  50814. (this.objects = []),
  50815. (this._prevObjects = []),
  50816. (this.onMouseDown = (r) => {
  50817. Qe.length > 1 || (this.eventContext.updateRaycaster(r), this.handleMouseHoverEvent());
  50818. }),
  50819. (this.onMouseUp = (r) => {
  50820. Qe.length > 1 || this.handleMouseHoverEvent(!0);
  50821. }),
  50822. (this.onMouseMove = (r) => {
  50823. Qe.length > 1 || (this.eventContext.updateRaycaster(r), this.handleMouseHoverEvent());
  50824. }),
  50825. (this.onUserEvent = ({ eventName: r, target: s, reverse: n }) => {
  50826. if (!r || !s) return;
  50827. let a = Uh(r);
  50828. a &&
  50829. a === 'MouseHover' &&
  50830. (s.dispatchEvent({ type: 'beginEvent', eventName: 'MouseHover' }),
  50831. this.eventsPerObjects[s.uuid]?.forEach((o) => o.dispatchUserEvent(n)));
  50832. });
  50833. let { scene: t, sharedAssets: i } = this.eventContext;
  50834. t.traverseEntity((r) => {
  50835. if (!(!r.visible || !r.data?.events.length)) {
  50836. for (let { id: s, data: n } of r.data.events)
  50837. if (!n.disabled && n.type === 'MouseHover')
  50838. try {
  50839. let a = new BG(s, n, r, t, i);
  50840. this.eventsPerObjects[r.uuid] ? this.eventsPerObjects[r.uuid].push(a) : (this.eventsPerObjects[r.uuid] = [a]);
  50841. } catch {}
  50842. this.eventsPerObjects[r.uuid]?.length && this.objects.push(r);
  50843. }
  50844. });
  50845. }
  50846. connect() {
  50847. if (!this.objects.length) return;
  50848. let { domElement: e } = this.eventContext;
  50849. this.domEventsNeeded.clear(),
  50850. rr &&
  50851. (this.domEventsNeeded.add('pointerdown'),
  50852. e.addEventListener('pointerdown', this.onMouseDown),
  50853. this.domEventsNeeded.add('pointerup'),
  50854. e.addEventListener('pointerup', this.onMouseUp)),
  50855. this.domEventsNeeded.add('pointermove'),
  50856. e.addEventListener('pointermove', this.onMouseMove),
  50857. this.objects.forEach((t) => {
  50858. t.addEventListener('userEvent', this.onUserEvent);
  50859. });
  50860. }
  50861. disconnect() {
  50862. if (!this.objects.length) return;
  50863. let { domElement: e } = this.eventContext;
  50864. this.domEventsNeeded.clear(),
  50865. rr && (e.removeEventListener('pointerdown', this.onMouseDown), e.removeEventListener('pointerup', this.onMouseUp)),
  50866. e.removeEventListener('pointermove', this.onMouseMove),
  50867. Object.values(this.eventsPerObjects).forEach((t) => {
  50868. t.forEach((i) => {
  50869. i.disconnect();
  50870. });
  50871. }),
  50872. this.objects.forEach((t) => {
  50873. t.removeEventListener('userEvent', this.onUserEvent);
  50874. });
  50875. }
  50876. handleMouseHoverEvent(e = !1) {
  50877. let t = [];
  50878. if (!e) {
  50879. let { stopRaycast: i, raycaster: r, scene: s } = this.eventContext;
  50880. if (i) {
  50881. let n = Km(r, s, this.objects);
  50882. t = Jm(n);
  50883. } else
  50884. this.objects.forEach((n) => {
  50885. iu(r, n) && t.push(n);
  50886. });
  50887. }
  50888. this._prevObjects.length &&
  50889. this._prevObjects.forEach((i) => {
  50890. t.includes(i) ||
  50891. (i.dispatchEvent({ type: 'beginEvent', eventName: 'MouseHover' }),
  50892. this.eventsPerObjects[i.uuid]?.forEach((r) => r.dispatchLeave()));
  50893. }),
  50894. t.length &&
  50895. t.forEach((i) => {
  50896. i.dispatchEvent({ type: 'beginEvent', eventName: 'MouseHover' }),
  50897. this.eventsPerObjects[i.uuid]?.forEach((r) => r.dispatchEnter());
  50898. }),
  50899. (this._prevObjects = t);
  50900. }
  50901. },
  50902. NG = class {
  50903. constructor(e, t, i, r, s) {
  50904. (this.id = e), (this.data = t), (this.object = i), (this.scrollCounter = 0), (this.actions = On(t, t.actions, i, r, s));
  50905. }
  50906. connect() {
  50907. this.scrollCounter = 0;
  50908. }
  50909. disconnect() {
  50910. In(this.actions);
  50911. }
  50912. dispatch(e) {
  50913. this.actions.Transition.forEach((r) => {
  50914. r.object.currentTransitionEvent !== this && ((r.object.currentTransitionEvent = this), r.init());
  50915. });
  50916. let t = e > 0 ? 1 : -1;
  50917. (this.scrollCounter += t), (this.scrollCounter = Math.min(Math.max(this.scrollCounter, 0), this.data.steps));
  50918. let i = this.scrollCounter / this.data.steps;
  50919. this.actions.Transition.forEach((r) => r.seek(i));
  50920. }
  50921. dispatchUserEvent(e) {
  50922. this.actions.Transition.forEach((t) => {
  50923. t.object.currentTransitionEvent !== this && ((t.object.currentTransitionEvent = this), t.init());
  50924. }),
  50925. e
  50926. ? this.actions.Transition.forEach((t) => t.reverseFromCurrent())
  50927. : this.actions.Transition.forEach((t) => {
  50928. t.playFromCurrent();
  50929. });
  50930. }
  50931. },
  50932. UG = class {
  50933. constructor(e, t, i, r, s, n) {
  50934. (this.id = e),
  50935. (this.data = t),
  50936. (this.object = i),
  50937. (this.domElement = n),
  50938. (this.scrollStart = 0),
  50939. (this.scrollEnd = 0),
  50940. (this.actions = On(t, t.actions, i, r, s));
  50941. }
  50942. computeScrollBounds() {
  50943. let e = this.domElement.getBoundingClientRect(),
  50944. t = document.body,
  50945. i = document.documentElement,
  50946. r = window.pageYOffset || i.scrollTop || t.scrollTop,
  50947. s = i.clientTop || t.clientTop || 0,
  50948. n = Math.round(e.top + r - s);
  50949. if (this.data.startFrom === 'enter') {
  50950. let a = window.innerHeight,
  50951. o = e.height,
  50952. l = this.data.enterAnchor,
  50953. h = l === 'top' ? a : l === 'bottom' ? a - o : a - o * 0.5;
  50954. this.scrollStart = n - h;
  50955. } else this.scrollStart = 0;
  50956. (this.scrollStart += this.data.startOffset ?? 0),
  50957. (this.scrollEnd = this.scrollStart + (this.data.endAfter ?? 400)),
  50958. this.dispatch({ x: window.scrollX, y: window.scrollY });
  50959. }
  50960. connect() {
  50961. this.computeScrollBounds();
  50962. }
  50963. disconnect() {
  50964. In(this.actions);
  50965. }
  50966. handleResize() {
  50967. this.computeScrollBounds();
  50968. }
  50969. dispatch({ x: e, y: t }) {
  50970. this.actions.Transition.forEach((s) => {
  50971. s.object.currentTransitionEvent !== this && ((s.object.currentTransitionEvent = this), s.init());
  50972. });
  50973. let i = this.scrollEnd - this.scrollStart,
  50974. r = Math.min(1, Math.max(0, (t - this.scrollStart) / i));
  50975. this.actions.Transition.forEach((s) => s.seek(r));
  50976. }
  50977. dispatchUserEvent(e) {
  50978. this.actions.Transition.forEach((t) => {
  50979. t.object.currentTransitionEvent !== this && ((t.object.currentTransitionEvent = this), t.init());
  50980. }),
  50981. e
  50982. ? this.actions.Transition.forEach((t) => t.reverseFromCurrent())
  50983. : this.actions.Transition.forEach((t) => {
  50984. t.playFromCurrent();
  50985. });
  50986. }
  50987. },
  50988. FG = class extends zn {
  50989. constructor(e) {
  50990. super(e),
  50991. (this.wheelEventsPerObject = new Map()),
  50992. (this.scrollEventsPerObject = new Map()),
  50993. (this.isInview = !0),
  50994. (this.handleResize = () => {
  50995. [...this.scrollEventsPerObject.entries()].forEach(([n, a]) => {
  50996. a.forEach((o) => o.handleResize());
  50997. });
  50998. }),
  50999. (this.onScroll = (n) => {
  51000. if (!this.isInview) return;
  51001. let a = { y: window.scrollY, x: window.scrollX };
  51002. [...this.scrollEventsPerObject.entries()].forEach(([o, l]) => {
  51003. o.dispatchEvent({ type: 'beginEvent', eventName: 'Scroll', scroll: a }), l.forEach((h) => h.dispatch(a));
  51004. });
  51005. }),
  51006. (this.onWheel = (n) => {
  51007. !this.isInview ||
  51008. n.ctrlKey ||
  51009. [...this.wheelEventsPerObject.entries()].forEach(([a, o]) => {
  51010. a.dispatchEvent({ type: 'beginEvent', eventName: 'Scroll', deltaY: n.deltaY }), o.forEach((l) => l.dispatch(n.deltaY));
  51011. });
  51012. }),
  51013. (this.onUserEvent = ({ eventName: n, target: a, reverse: o }) => {
  51014. if (!n || !a) return;
  51015. let l = Uh(n);
  51016. l &&
  51017. l === 'Scroll' &&
  51018. (a.dispatchEvent({ type: 'beginEvent', eventName: 'Scroll' }),
  51019. this.wheelEventsPerObject.get(a)?.forEach((h) => {
  51020. h.dispatchUserEvent(o);
  51021. }));
  51022. });
  51023. let { scene: t, sharedAssets: i, domElement: r, isExport: s } = this.eventContext;
  51024. t.traverseEntity((n) => {
  51025. if (n.data?.events.length) {
  51026. for (let { id: a, data: o } of n.data.events)
  51027. if (!o.disabled && o.type === 'Scroll')
  51028. if (o.trigger === 'load' || !s) {
  51029. let l = new NG(a, o, n, t, i);
  51030. this.wheelEventsPerObject.has(n) ? this.wheelEventsPerObject.get(n)?.push(l) : this.wheelEventsPerObject.set(n, [l]);
  51031. } else {
  51032. let l = new UG(a, o, n, t, i, r);
  51033. this.scrollEventsPerObject.has(n) ? this.scrollEventsPerObject.get(n)?.push(l) : this.scrollEventsPerObject.set(n, [l]);
  51034. }
  51035. }
  51036. }),
  51037. (this.intersectionObserver = new IntersectionObserver(
  51038. (n) => {
  51039. let a = n[0];
  51040. a && (this.isInview = a.isIntersecting);
  51041. },
  51042. { root: null }
  51043. ));
  51044. }
  51045. connect() {
  51046. this.intersectionObserver.observe(this.eventContext.domElement),
  51047. [...this.wheelEventsPerObject.entries()].forEach(([e, t]) => {
  51048. t.forEach((i) => i.connect()), e.addEventListener('userEvent', this.onUserEvent);
  51049. }),
  51050. [...this.scrollEventsPerObject.entries()].forEach(([e, t]) => {
  51051. t.forEach((i) => i.connect()), e.addEventListener('userEvent', this.onUserEvent);
  51052. }),
  51053. [...this.wheelEventsPerObject.values()].some((e) => e.length) &&
  51054. (this.domEventsNeeded.add('wheel'), window.addEventListener('wheel', this.onWheel)),
  51055. [...this.scrollEventsPerObject.values()].some((e) => e.length) &&
  51056. (this.domEventsNeeded.add('scroll'),
  51057. window.addEventListener('scroll', this.onScroll),
  51058. window.addEventListener('resize', this.handleResize));
  51059. }
  51060. disconnect() {
  51061. window.removeEventListener('wheel', this.onWheel),
  51062. window.removeEventListener('scroll', this.onScroll),
  51063. window.removeEventListener('resize', this.handleResize),
  51064. this.intersectionObserver.unobserve(this.eventContext.domElement),
  51065. this.domEventsNeeded.clear(),
  51066. [...this.wheelEventsPerObject.entries()].forEach(([e, t]) => {
  51067. t.forEach((i) => i.disconnect()), e.removeEventListener('userEvent', this.onUserEvent);
  51068. }),
  51069. [...this.scrollEventsPerObject.entries()].forEach(([e, t]) => {
  51070. t.forEach((i) => i.disconnect()), e.removeEventListener('userEvent', this.onUserEvent);
  51071. });
  51072. }
  51073. },
  51074. kG = class {
  51075. constructor(e, t, i, r, s) {
  51076. (this.id = e), (this.data = t), (this.object = i), (this.actions = On(t, t.actions, i, r, s));
  51077. }
  51078. disconnect() {
  51079. In(this.actions);
  51080. }
  51081. dispatch() {
  51082. this.actions.Transition.forEach((e) => {
  51083. e.play();
  51084. });
  51085. }
  51086. dispatchAfter(e) {
  51087. this.actions.Audio.forEach((t) => {
  51088. (t.interaction.data.triggerAfter ?? 'any') === e &&
  51089. (t.interaction instanceof bo ? t.interaction.audioPlayer.play() : t.interaction instanceof $m && t.interaction.dispatch());
  51090. }),
  51091. this.actions.Video.forEach((t) => {
  51092. let i = t.interaction.data.triggerAfter ?? 'autoplay';
  51093. i === e &&
  51094. (t.interaction instanceof sh ? t.interaction.play(i === 'autoplay') : t.interaction instanceof eg && t.interaction.dispatch());
  51095. });
  51096. }
  51097. dispatchUserEvent(e) {
  51098. this.actions.Transition.forEach((t) => {
  51099. t.object.currentTransitionEvent !== this && ((t.object.currentTransitionEvent = this), t.init());
  51100. }),
  51101. e ? this.actions.Transition.forEach((t) => t.reverseFromCurrent()) : this.actions.Transition.forEach((t) => t.playFromCurrent()),
  51102. this.actions.Audio.forEach((t) => {
  51103. t.interaction instanceof bo ? t.interaction.audioPlayer.play() : t.interaction instanceof $m && t.interaction.dispatch();
  51104. }),
  51105. this.actions.Video.forEach((t) => {
  51106. t.interaction instanceof sh ? t.interaction.play() : t.interaction instanceof eg && t.interaction.dispatch();
  51107. });
  51108. }
  51109. },
  51110. jG = class extends zn {
  51111. constructor(e) {
  51112. super(e),
  51113. (this.eventsPerObject = new Map()),
  51114. (this.eventsAfterPerObject = new Map()),
  51115. (this.onMouseDown = () => {
  51116. [...this.eventsAfterPerObject.entries()].forEach(([r, s]) => {
  51117. r.dispatchEvent({ type: 'beginEvent', eventName: 'Start' }),
  51118. s.forEach((n) => {
  51119. n.dispatchAfter('mouseDown');
  51120. });
  51121. });
  51122. }),
  51123. (this.onKeyDown = () => {
  51124. [...this.eventsAfterPerObject.entries()].forEach(([r, s]) => {
  51125. r.dispatchEvent({ type: 'beginEvent', eventName: 'Start' }),
  51126. s.forEach((n) => {
  51127. n.dispatchAfter('keyDown');
  51128. });
  51129. });
  51130. }),
  51131. (this.onAny = () => {
  51132. let { domElement: r, isExport: s } = this.eventContext;
  51133. (s ? document : r).removeEventListener('pointerdown', this.onAny),
  51134. document.removeEventListener('keydown', this.onAny),
  51135. [...this.eventsAfterPerObject.entries()].forEach(([n, a]) => {
  51136. n.dispatchEvent({ type: 'beginEvent', eventName: 'Start' }),
  51137. a.forEach((o) => {
  51138. o.dispatchAfter('any');
  51139. });
  51140. });
  51141. }),
  51142. (this.onPlay = () => {
  51143. [...this.eventsAfterPerObject.entries()].forEach(([r, s]) => {
  51144. r.dispatchEvent({ type: 'beginEvent', eventName: 'Start' }),
  51145. s.forEach((n) => {
  51146. n.dispatchAfter('autoplay');
  51147. });
  51148. });
  51149. }),
  51150. (this.onUserEvent = ({ eventName: r, target: s, reverse: n }) => {
  51151. if (!r || !s) return;
  51152. let a = Uh(r);
  51153. a &&
  51154. a === 'Start' &&
  51155. (s.dispatchEvent({ type: 'beginEvent', eventName: 'Start' }),
  51156. this.eventsPerObject.get(s)?.forEach((o) => {
  51157. o.dispatchUserEvent(n);
  51158. }),
  51159. this.eventsAfterPerObject.get(s)?.forEach((o) => {
  51160. o.dispatchUserEvent(n);
  51161. }));
  51162. });
  51163. let { scene: t, sharedAssets: i } = this.eventContext;
  51164. t.traverseEntity((r) => {
  51165. if (r.data?.events.length)
  51166. for (let { id: s, data: n } of r.data.events) {
  51167. if (n.disabled || n.type !== 'Start') continue;
  51168. let a = new kG(s, n, r, t, i);
  51169. a.actions.Transition.length &&
  51170. (this.eventsPerObject.has(r) ? this.eventsPerObject.get(r)?.push(a) : this.eventsPerObject.set(r, [a])),
  51171. a.actions.Audio.length &&
  51172. (this.eventsAfterPerObject.has(r) ? this.eventsAfterPerObject.get(r)?.push(a) : this.eventsAfterPerObject.set(r, [a])),
  51173. a.actions.Video.length &&
  51174. ((this.hasVideoAction = !0),
  51175. this.eventsAfterPerObject.has(r) ? this.eventsAfterPerObject.get(r)?.push(a) : this.eventsAfterPerObject.set(r, [a]));
  51176. }
  51177. });
  51178. }
  51179. connect() {
  51180. if ([...this.eventsAfterPerObject.values()].some((e) => e.length)) {
  51181. let { domElement: e, isExport: t } = this.eventContext,
  51182. i = t ? document : e;
  51183. i.addEventListener('pointerdown', this.onMouseDown, { once: !0 }),
  51184. document.addEventListener('keydown', this.onKeyDown, { once: !0 }),
  51185. i.addEventListener('pointerdown', this.onAny),
  51186. document.addEventListener('keydown', this.onAny),
  51187. [...this.eventsAfterPerObject.entries()].forEach(([r, s]) => {
  51188. r.addEventListener('userEvent', this.onUserEvent);
  51189. }),
  51190. this.onPlay();
  51191. }
  51192. [...this.eventsPerObject.entries()].forEach(([e, t]) => {
  51193. e.dispatchEvent({ type: 'beginEvent', eventName: 'Start' }),
  51194. t.forEach((i) => i.dispatch()),
  51195. e.addEventListener('userEvent', this.onUserEvent);
  51196. });
  51197. }
  51198. disconnect() {
  51199. if ([...this.eventsAfterPerObject.values()].some((e) => e.length)) {
  51200. let { domElement: e, isExport: t } = this.eventContext,
  51201. i = t ? document : e;
  51202. i.removeEventListener('pointerdown', this.onMouseDown),
  51203. document.removeEventListener('keydown', this.onKeyDown),
  51204. i.removeEventListener('pointerdown', this.onAny),
  51205. document.removeEventListener('keydown', this.onAny),
  51206. [...this.eventsAfterPerObject.entries()].forEach(([r, s]) => {
  51207. r.removeEventListener('userEvent', this.onUserEvent), s.forEach((n) => n.disconnect());
  51208. });
  51209. }
  51210. [...this.eventsPerObject.entries()].forEach(([e, t]) => {
  51211. e.removeEventListener('userEvent', this.onUserEvent), t.forEach((i) => i.disconnect());
  51212. });
  51213. }
  51214. },
  51215. GG = class {
  51216. constructor(e, t, i, r, s) {
  51217. (this.id = e),
  51218. (this.data = t),
  51219. (this.object = i),
  51220. (this.disabled = !0),
  51221. (this.actions = On(t, t.actions, i, r, s)),
  51222. (this.target = t.target),
  51223. (this.useToggle = t.toggle);
  51224. }
  51225. disconnect() {
  51226. In(this.actions);
  51227. }
  51228. dispatch() {
  51229. this.disabled ||
  51230. (this.actions.Transition.forEach((e) => {
  51231. e.object.currentTransitionEvent !== this && ((e.object.currentTransitionEvent = this), e.init());
  51232. }),
  51233. this.object.dispatchEvent({ type: 'beginEvent', eventName: 'Collision' }),
  51234. this.useToggle
  51235. ? this.actions.Transition.forEach((e) => {
  51236. e.toggle();
  51237. })
  51238. : this.actions.Transition.forEach((e) => {
  51239. e.play();
  51240. }),
  51241. this.actions.Link.forEach((e) => {
  51242. e.dispatch();
  51243. }),
  51244. this.actions.Audio.forEach((e) => {
  51245. e.dispatchBasic();
  51246. }),
  51247. this.actions.Video.forEach((e) => {
  51248. e.dispatchBasic();
  51249. }));
  51250. }
  51251. },
  51252. Bt;
  51253. yN.then((e) => (Bt = e));
  51254. var Ri = new E(),
  51255. on = new ct(),
  51256. Kn = new E(),
  51257. wf = new _i(0, 0, 0, 'YXZ'),
  51258. VG = { type: 'updateMatrix' },
  51259. a2 = { type: 'beginEvent', eventName: 'Collision' };
  51260. function HG(e) {
  51261. if (e.scene.environment.usePhysics) return !0;
  51262. let t = !1;
  51263. return (
  51264. e.scene.objects.traverse((i, r) => {
  51265. for (let s of r.events)
  51266. if (s.data.disabled !== !0 && s.data.type === 'GameControl' && s.data.collisionEnabled) {
  51267. t = !0;
  51268. break;
  51269. }
  51270. }),
  51271. t
  51272. );
  51273. }
  51274. var Rb = (e) =>
  51275. e.states.some(
  51276. (t) =>
  51277. t.data.position !== void 0 ||
  51278. t.data.rotation !== void 0 ||
  51279. t.data.hiddenMatrix !== void 0 ||
  51280. t.data.cloner !== void 0 ||
  51281. t.data.pathSnapping !== void 0
  51282. ),
  51283. Bb = (e) => e.events.find((t) => t.data.disabled !== !0 && t.data.type === 'Follow'),
  51284. WG = class {
  51285. constructor(e, t, i, r, s, n = !1) {
  51286. (this.scene = t),
  51287. (this.sharedAssets = s),
  51288. (this.isExport = n),
  51289. (this.orbitControlsNeedsUpdate = !0),
  51290. (this.gameControls = []),
  51291. (this.gameControlStates = []),
  51292. (this.joysticks = []),
  51293. (this.joystickToGameControls = []),
  51294. (this.sharedGameControlGlobals = { entitiesWithTransformAnim: [], eventsPerObjects: {}, colliderToEntity: {}, gamePads: [] }),
  51295. (this.needsCollisionDetection = !1),
  51296. (this.initializationCounter = -1),
  51297. (this.rigidBodyToMesh = new Map()),
  51298. (this.nActiveRigidBodies = 0),
  51299. (this.collisionEvents = []),
  51300. (this.processRigidBody = (m) => {
  51301. if (m.bodyType() !== Bt.RigidBodyType.Dynamic) return;
  51302. m.isSleeping() || this.nActiveRigidBodies++;
  51303. let [v, y, b] = this.rigidBodyToMesh.get(m.handle);
  51304. if (
  51305. (Ri.copy(m.translation()).multiplyScalar(this.pixelsPerMeter),
  51306. on.copy(m.rotation()),
  51307. v.matrixWorld.compose(Ri, on, y),
  51308. v.hasNonUniformScale && v.matrixWorld.multiply(v.shearScale),
  51309. v.dispatchEvent(VG),
  51310. b)
  51311. ) {
  51312. let x = v.cloner;
  51313. if (x && x.objectForSample === void 0) {
  51314. x.matrixWorld.copy(v.matrixWorld);
  51315. for (let w of x.children) w.updateMatrixWorld(!0);
  51316. }
  51317. for (let w of v.children) w.updateMatrixWorld(!0);
  51318. }
  51319. }),
  51320. (this.handleCollisionEvents = (m, v, y) => {
  51321. if (y !== !1)
  51322. if (this.gameControls.some((b) => b.object === this.sharedGameControlGlobals.colliderToEntity[m])) {
  51323. let b = this.sharedGameControlGlobals.colliderToEntity[v],
  51324. x = this.sharedGameControlGlobals.eventsPerObjects[b.uuid];
  51325. if (x === void 0) return;
  51326. for (let w of x) w.data.target === 'character' && this.dispatchCollisionEvent(w, b);
  51327. } else if (this.gameControls.some((b) => b.object === this.sharedGameControlGlobals.colliderToEntity[v])) {
  51328. let b = this.sharedGameControlGlobals.colliderToEntity[m],
  51329. x = this.sharedGameControlGlobals.eventsPerObjects[b.uuid];
  51330. if (x === void 0) return;
  51331. for (let w of x) w.data.target === 'character' && this.dispatchCollisionEvent(w, b);
  51332. } else {
  51333. let b = this.sharedGameControlGlobals.colliderToEntity[m],
  51334. x = this.sharedGameControlGlobals.eventsPerObjects[b.uuid];
  51335. if (x !== void 0) for (let S of x) S.data.target === 'scene' && this.dispatchCollisionEvent(S, b);
  51336. let w = this.sharedGameControlGlobals.colliderToEntity[v],
  51337. A = this.sharedGameControlGlobals.eventsPerObjects[w?.uuid];
  51338. if (A !== void 0) for (let S of A) S.data.target === 'scene' && this.dispatchCollisionEvent(S, w);
  51339. }
  51340. }),
  51341. (this.domElement = i.domElement);
  51342. let a;
  51343. e.scene.publish.playCamera === null ? (a = sl.PERSONAL_CAMERA_ID) : (a = e.scene.publish.playCamera);
  51344. let o = this.scene.find(a),
  51345. l = !1,
  51346. h,
  51347. u = 5,
  51348. c = 8,
  51349. d = 9,
  51350. p = 'drag';
  51351. if (
  51352. ((this.usePhysics = e.scene.environment.usePhysics ?? Ki.defaultData.usePhysics),
  51353. (this.pixelsPerMeter = e.scene.environment.pixelsPerMeter ?? Ki.defaultData.pixelsPerMeter),
  51354. e.scene.objects.data(e.scene.publish.gameControlObject)?.events.forEach((m) => {
  51355. m.data.disabled !== !0 &&
  51356. m.data.type === 'GameControl' &&
  51357. ((h = m.data.keyAssignments),
  51358. (u = m.data.joystickPosLoc),
  51359. (c = m.data.joystickRotLoc),
  51360. (d = m.data.jumpTouchButtonLoc),
  51361. (p = m.data.rotByTouch));
  51362. }),
  51363. this.scene.traverseEntity((m) => {
  51364. m.dataPatched.events.forEach((v) => {
  51365. if (v.data.disabled || v.data.type !== 'GameControl') return;
  51366. let y = m;
  51367. for (; (y = y.parent)?.parent !== null; ) if (y.dataPatched.physics?.fusedBody) return;
  51368. v.data.collisionEnabled && (this.needsCollisionDetection = !0), this.gameControlStates.push([m, v.data]);
  51369. });
  51370. }),
  51371. this.usePhysics && this.initPhysics(e.scene.environment.gravity ?? Ki.defaultData.gravity),
  51372. this.gameControlStates.forEach(([m, v]) => {
  51373. l = l || v.camera === o.uuid || m.uuid === o.uuid;
  51374. let y = new o2(
  51375. m,
  51376. i.domElement,
  51377. { ...v, keyAssignments: h },
  51378. e.scene.environment,
  51379. this.sharedGameControlGlobals,
  51380. m.uuid !== o.uuid && v.camera === o.uuid,
  51381. o,
  51382. this.scene,
  51383. s
  51384. );
  51385. y.addEventListener('change', r),
  51386. y.addEventListener('end', r),
  51387. y.addEventListener('start', r),
  51388. this.gameControls.push(y),
  51389. rr &&
  51390. v.touchControl &&
  51391. (this.joystickToGameControls[u] !== void 0
  51392. ? this.joystickToGameControls[u].push([y, 'pos'])
  51393. : (this.joystickToGameControls[u] = [[y, 'pos']]),
  51394. v.moveMode === 'walk' &&
  51395. (this.joystickToGameControls[d] !== void 0
  51396. ? this.joystickToGameControls[d].push([y, 'jmp'])
  51397. : (this.joystickToGameControls[d] = [[y, 'jmp']])),
  51398. p === 'joystick' &&
  51399. (this.joystickToGameControls[c] !== void 0
  51400. ? this.joystickToGameControls[c].push([y, 'rot'])
  51401. : (this.joystickToGameControls[c] = [[y, 'rot']])));
  51402. }),
  51403. l === !1)
  51404. ) {
  51405. let { enableRotate: m, enablePan: v, enableZoom: y, autoRotate: b, hoverRotatePanMode: x } = e.scene.publish.orbitControls;
  51406. (m || v || y || b || x !== 0) &&
  51407. ((this.orbitControls = new l2(o, i.domElement, { isExport: this.isExport, isPlayMode: !0 })),
  51408. this.orbitControls.addEventListener('change', r),
  51409. this.orbitControls.addEventListener('end', r),
  51410. this.orbitControls.addEventListener('start', r),
  51411. this.orbitControls.fromJSON(e.scene.publish.orbitControls, e.scene.publish.mouseEventTarget),
  51412. (this.orbitControls.useKeyEvents = !1),
  51413. this.orbitControls.addEventListenersToCamera(),
  51414. this.orbitControls.connect(),
  51415. this.orbitControls.update());
  51416. }
  51417. let f = i.domElement.width / i.getPixelRatio(),
  51418. g = i.domElement.height / i.getPixelRatio();
  51419. this.joystickToGameControls.forEach((m, v) => {
  51420. let y = document.body.appendChild(document.createElement('div')),
  51421. [b, x, w] = (e.scene.publish.joystickSizeAndXYOffset ?? Vo.defaultData.joystickSizeAndXYOffset)[v],
  51422. A = (f - 5 * b) / 4 + b,
  51423. S = {},
  51424. _ = m.some((P) => P[1] === 'jmp'),
  51425. M = _ ? 0 : b;
  51426. v < 10
  51427. ? (v < 5 ? (S.top = M / 2) : (S.bottom = M / 2), (S.left = M / 2 + (v % 5) * A))
  51428. : v === 10
  51429. ? ((S.left = M / 2), (S.top = g / 2))
  51430. : ((S.right = M / 2), (S.top = g / 2)),
  51431. S.top ? (S.top -= x[1]) : (S.bottom += x[1]),
  51432. S.left ? (S.left += x[0]) : (S.right -= x[0]);
  51433. for (let P in S) S[P] += 'px';
  51434. if (_) {
  51435. let P = y.appendChild(document.createElement('div'));
  51436. Object.assign(P.style, S, {
  51437. position: 'absolute',
  51438. width: b + 'px',
  51439. height: b + 'px',
  51440. backgroundColor: `rgba(255,255,255,${w === 'show' ? 0.4 : 0})`,
  51441. zIndex: '9999',
  51442. borderRadius: b + 'px',
  51443. border: w === 'show' ? 'solid 2px rgba(0, 0, 0, .1)' : 'none',
  51444. display: 'flex',
  51445. alignItems: 'center',
  51446. justifyContent: 'center',
  51447. touchAction: 'none'
  51448. });
  51449. let L = (b / 16) * 16 * 0.4;
  51450. w === 'show' &&
  51451. (P.innerHTML = `
  51452. <svg width="${L}" height="${b * 0.4}" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
  51453. <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
  51454. </svg>
  51455. `),
  51456. P.addEventListener('pointerdown', () => {
  51457. m.forEach((D) => {
  51458. D[0].movementState.jump = 1;
  51459. }),
  51460. r();
  51461. }),
  51462. P.addEventListener('touchend', (D) => D.preventDefault()),
  51463. (this.joysticks[v] = [void 0, y]);
  51464. return;
  51465. }
  51466. let C = { zone: y, mode: 'static', position: S, size: b };
  51467. w === 'hide' && (C.restOpacity = 0);
  51468. let T = q8.create(C);
  51469. T.on('move', (P, L) => {
  51470. m.forEach((D) => {
  51471. let k = D[0];
  51472. D[1] === 'pos'
  51473. ? L.force < 0.2
  51474. ? (k.moveForce = 0)
  51475. : ((k.movementState.movePosZ = Math.sin(-L.angle.radian)),
  51476. (k.movementState.movePosX = Math.cos(-L.angle.radian)),
  51477. L.force < 0.3 ? (k.moveForce = (L.force - 0.2) / 0.1) : (k.moveForce = 1))
  51478. : L.force < 0.2
  51479. ? (k.rotForce = 0)
  51480. : ((k.movementState.rotPosX = L.vector.y),
  51481. (k.movementState.rotPosY = -L.vector.x),
  51482. L.force < 0.3 ? (k.rotForce = (L.force - 0.2) / 0.1) : (k.rotForce = 1));
  51483. }),
  51484. r();
  51485. }),
  51486. T.on('end', (P, L) => {
  51487. m.forEach((D) => {
  51488. let k = D[0];
  51489. D[1] === 'pos'
  51490. ? ((k.movementState.movePosZ = 0), (k.movementState.movePosX = 0), (k.moveForce = 1))
  51491. : ((k.movementState.rotPosX = 0), (k.movementState.rotPosY = 0), (k.rotForce = 1));
  51492. });
  51493. }),
  51494. (this.joysticks[v] = [T, y]);
  51495. }),
  51496. this.usePhysics === !1 && this.needsCollisionDetection && this.initBVH(),
  51497. this.initializationCounter++,
  51498. window.setTimeout(() => this.collisionEvents.forEach((m) => (m.disabled = !1)), 80);
  51499. }
  51500. attachVRControllers(e) {
  51501. e.forEach((t) => {
  51502. t.addEventListener('connected', (i) => {
  51503. 'gamepad' in i.data && 'axes' in i.data.gamepad && this.sharedGameControlGlobals.gamePads.push(i.data.gamepad);
  51504. });
  51505. });
  51506. }
  51507. initBVH() {
  51508. let e = [];
  51509. if (
  51510. (this.scene.traverseObject((t) => {
  51511. let i;
  51512. if (t instanceof eu) return;
  51513. t instanceof la ? (i = t.object) : (i = t);
  51514. let r = i.dataPatched;
  51515. if (!r.visible || Bb(r)) return !0;
  51516. let s = t.geometry;
  51517. if (Rb(r) || i.dataPatched.events.some((n) => n.data.disabled !== !0 && n.data.type === 'GameControl')) {
  51518. t.updateMatrixWorldSVD();
  51519. let n = [];
  51520. if (
  51521. (s?.getAttribute('position') !== void 0 && n.push(eo(s, t.shearScale)),
  51522. t.traverseObject(this.gatherChildrenGeom(t, n)),
  51523. t.children.forEach((a) => a.updateMatrixWorld(!0)),
  51524. n.length > 0)
  51525. ) {
  51526. let a = go(n, !1);
  51527. (t.boundsTree = new gi(a)), this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t);
  51528. }
  51529. return !0;
  51530. } else s && e.push(eo(s, t.matrixWorld));
  51531. }),
  51532. e.length > 0)
  51533. ) {
  51534. let t = go(e, !1);
  51535. this.sharedGameControlGlobals.staticMeshBVH = new gi(t);
  51536. }
  51537. }
  51538. addCollider(e, t, i, r, s, n = !0) {
  51539. if (r?.getAttribute('position').count === 0 || r?.getIndex()?.count === 0) return;
  51540. let a;
  51541. s !== void 0
  51542. ? s.collider.type === 'sphere'
  51543. ? (a = Bt.ColliderDesc.ball(s.collider.radius / this.pixelsPerMeter))
  51544. : s.collider.type === 'capsule'
  51545. ? (a = Bt.ColliderDesc.capsule(
  51546. (s.collider.height / 2 - s.collider.radius) / this.pixelsPerMeter,
  51547. s.collider.radius / this.pixelsPerMeter
  51548. ))
  51549. : (a = Bt.ColliderDesc.cuboid(
  51550. s.collider.width / this.pixelsPerMeter / 2,
  51551. s.collider.height / this.pixelsPerMeter / 2,
  51552. s.collider.depth / this.pixelsPerMeter / 2
  51553. ))
  51554. : r &&
  51555. (i.colliderType === 'trimesh'
  51556. ? (a = Bt.ColliderDesc.trimesh(r.getAttribute('position').array, r.getIndex().array))
  51557. : (a = Bt.ColliderDesc.convexMesh(r.getAttribute('position').array, n ? r.getIndex().array : void 0))),
  51558. a
  51559. .setFrictionCombineRule(Bt.CoefficientCombineRule.Average)
  51560. .setRestitutionCombineRule(Bt.CoefficientCombineRule.Average)
  51561. .setDensity(i.density)
  51562. .setFriction(i.friction)
  51563. .setRestitution(i.restitution);
  51564. let o = this.sharedGameControlGlobals.rapierWorld.createCollider(a, t);
  51565. if (((this.sharedGameControlGlobals.colliderToEntity[o.handle] = e), s !== void 0)) {
  51566. Ri.fromArray(s.collider.position).multiply(Kn.setFromMatrixScale(e.matrixWorld)).divideScalar(this.pixelsPerMeter),
  51567. o.setTranslationWrtParent(Ri);
  51568. let l = new ct().setFromEuler(new _i().setFromVector3(new E().fromArray(s.collider.rotation)));
  51569. o.setRotationWrtParent(l), o.setActiveEvents(Bt.ActiveEvents.COLLISION_EVENTS);
  51570. } else
  51571. this.sharedGameControlGlobals.eventsPerObjects[e.uuid]?.some((l) => l.target === 'scene') &&
  51572. o.setActiveEvents(Bt.ActiveEvents.COLLISION_EVENTS);
  51573. }
  51574. gatherChildrenGeom(e, t) {
  51575. return (i, r) => {
  51576. if (r === 0) return;
  51577. r === 1
  51578. ? e.hasNonUniformScale
  51579. ? i.matrixWorld.multiplyMatrices(e.shearScale, i.hiddenMatrix)
  51580. : i.matrixWorld.copy(i.hiddenMatrix)
  51581. : i.matrixWorld.multiplyMatrices(i.parent.matrixWorld, i.hiddenMatrix),
  51582. i.matrixWorld.multiply(i.matrix);
  51583. let s = i.geometry;
  51584. s?.getAttribute('position') !== void 0 && t.push(eo(s, i.matrixWorld));
  51585. };
  51586. }
  51587. initPhysics(e) {
  51588. (this.sharedGameControlGlobals.rapierWorld = new Bt.World(new Bt.Vector3(0, e ?? -10, 0))), (this.events = new Bt.EventQueue(!0));
  51589. let t = [];
  51590. if (
  51591. (this.scene.traverseObject((a) => {
  51592. let o;
  51593. if (a instanceof eu)
  51594. if (a.objectForSample) {
  51595. if (a.objectForSample.dataPatched.physics.fusedBody) return;
  51596. o = a.object;
  51597. } else
  51598. return a.object.dataPatched.physics.fusedBody === !0 && a.object.dataPatched.physics.rigidBody === 'dynamic' ? !0 : void 0;
  51599. else a instanceof la ? (o = a.object) : (o = a);
  51600. let l = o.dataPatched;
  51601. if (!l.physics || !l.visible) return !0;
  51602. a.updateMatrixWorldSVD();
  51603. let h = Rb(l),
  51604. u = Bb(l),
  51605. c,
  51606. d = !1;
  51607. for (let f of l.events)
  51608. if (f.data.disabled !== !0) {
  51609. if (f.data.type === 'GameControl') c = f.data;
  51610. else if (f.data.type === 'Collision') {
  51611. d = !0;
  51612. let g = new GG(f.id, f.data, o, this.scene, this.sharedAssets);
  51613. this.collisionEvents.push(g),
  51614. this.sharedGameControlGlobals.eventsPerObjects[o.uuid]
  51615. ? this.sharedGameControlGlobals.eventsPerObjects[o.uuid].push(g)
  51616. : (this.sharedGameControlGlobals.eventsPerObjects[o.uuid] = [g]);
  51617. }
  51618. }
  51619. l.physics.rigidBody === 'dynamic' && l.physics.fusedBody === !1 && (a.matrixWorldFusedFalse = a.matrixWorld.clone());
  51620. let p = a.geometry;
  51621. if (l.physics.rigidBody === 'dynamic' || h || u || d || c !== void 0) {
  51622. let f = [];
  51623. if ((p?.getAttribute('position') !== void 0 && f.push(eo(p, a.shearScale)), l.physics.fusedBody)) {
  51624. let g = this.gatherChildrenGeom(a, f);
  51625. a.traverseObject(g), a.children.forEach((v) => v.updateMatrixWorld(!0));
  51626. let m = a.cloner;
  51627. m &&
  51628. m.objectForSample === void 0 &&
  51629. l.physics.rigidBody === 'dynamic' &&
  51630. (m.traverseObject(g), m.children.forEach((v) => v.updateMatrixWorld(!0)));
  51631. }
  51632. if (f.length > 0 || c !== void 0) {
  51633. let g;
  51634. c !== void 0
  51635. ? (g = Bt.RigidBodyDesc.kinematicPositionBased())
  51636. : l.physics.rigidBody === 'dynamic'
  51637. ? ((g = Bt.RigidBodyDesc.dynamic()),
  51638. g
  51639. .setLinearDamping(l.physics.damping)
  51640. .setAdditionalMass(1e-9)
  51641. .setGravityScale(l.physics.gravityScale)
  51642. .enabledRotations(...l.physics.enabledRotation)
  51643. .enabledTranslations(...l.physics.enabledTranslation))
  51644. : h || u
  51645. ? ((g = Bt.RigidBodyDesc.kinematicPositionBased()), this.sharedGameControlGlobals.entitiesWithTransformAnim.push(a))
  51646. : (g = Bt.RigidBodyDesc.fixed());
  51647. let m;
  51648. (m = f.length > 0 ? go(f) : void 0),
  51649. (a.hasNonUniformScale ? a.matrixWorldRigid : a.matrixWorld).decompose(Ri, on, Kn),
  51650. (a.position0 = Ri.clone().divideScalar(this.pixelsPerMeter)),
  51651. (a.rotation0 = on.clone()),
  51652. Ri.divideScalar(this.pixelsPerMeter),
  51653. g.setTranslation(Ri.x, Ri.y, Ri.z).setRotation(on),
  51654. p
  51655. ? m?.scale(1 / this.pixelsPerMeter, 1 / this.pixelsPerMeter, 1 / this.pixelsPerMeter)
  51656. : m?.scale(Kn.x / this.pixelsPerMeter, Kn.y / this.pixelsPerMeter, Kn.z / this.pixelsPerMeter);
  51657. let v = this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);
  51658. c === void 0 && l.physics.rigidBody === 'dynamic' && this.rigidBodyToMesh.set(v.handle, [a, Kn.clone(), l.physics.fusedBody]),
  51659. (a.rigidBody = v);
  51660. let y = !(
  51661. l.geometry === void 0 ||
  51662. l.geometry.type === 'SubdivGeometry' ||
  51663. l.geometry.type === 'NonParametricGeometry' ||
  51664. l.geometry.type === 'BooleanGeometry' ||
  51665. l.geometry.type === 'VectorGeometry' ||
  51666. l.geometry.type === 'StarGeometry' ||
  51667. l.geometry.type === 'RectangleGeometry' ||
  51668. l.geometry.type === 'EllipseGeometry' ||
  51669. l.geometry.type === 'TriangleGeometry' ||
  51670. l.geometry.type === 'TorusGeometry' ||
  51671. l.geometry.type === 'HelixGeometry'
  51672. );
  51673. try {
  51674. this.addCollider(o, v, l.physics, m, c, y);
  51675. } catch {
  51676. try {
  51677. this.addCollider(o, v, l.physics, m, c, !1);
  51678. } catch (b) {
  51679. console.error(b);
  51680. }
  51681. }
  51682. }
  51683. } else
  51684. p && t.push(eo(p, a.matrixWorld)),
  51685. l.physics.fusedBody &&
  51686. a.traverse((f) => {
  51687. !f.geometry || f === a || t.push(eo(f.geometry, f.matrixWorld));
  51688. });
  51689. if (l.physics?.fusedBody === !0 || c) return !0;
  51690. }),
  51691. t.length === 0)
  51692. )
  51693. return;
  51694. let i = go(t);
  51695. i.scale(1 / this.pixelsPerMeter, 1 / this.pixelsPerMeter, 1 / this.pixelsPerMeter);
  51696. let r = Bt.RigidBodyDesc.fixed(),
  51697. s = this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),
  51698. n = Bt.ColliderDesc.trimesh(i.getAttribute('position').array, i.getIndex().array)
  51699. .setFrictionCombineRule(Bt.CoefficientCombineRule.Multiply)
  51700. .setRestitutionCombineRule(Bt.CoefficientCombineRule.Multiply)
  51701. .setFriction(1)
  51702. .setRestitution(1);
  51703. this.sharedGameControlGlobals.rapierWorld.createCollider(n, s);
  51704. }
  51705. updatePositions() {
  51706. return (
  51707. (this.nActiveRigidBodies = 0),
  51708. this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),
  51709. this.nActiveRigidBodies > 0
  51710. );
  51711. }
  51712. dispose() {
  51713. this.scene.traverse((e) => {
  51714. let t = e;
  51715. t.matrixWorldFusedFalse && (t.matrixWorldFusedFalse = void 0),
  51716. t.rigidBody && (t.rigidBody = void 0),
  51717. t.position0 && (t.position0 = void 0),
  51718. t.rotation0 && (t.rotation0 = void 0);
  51719. }),
  51720. this.sharedGameControlGlobals.rapierWorld?.free(),
  51721. (this.sharedGameControlGlobals.staticMeshBVH = void 0),
  51722. (this.sharedGameControlGlobals.entitiesWithTransformAnim = []),
  51723. this.gameControls.forEach((e) => {
  51724. e.reset(), e.dispose();
  51725. }),
  51726. (this.gameControls = []),
  51727. this.joysticks.forEach(([e, t]) => {
  51728. e?.destroy(), t.remove();
  51729. }),
  51730. (this.joystickToGameControls = []),
  51731. (this.joysticks = []),
  51732. this.orbitControls && (this.orbitControls.dispose(), (this.orbitControls = void 0));
  51733. for (let e of Object.values(this.sharedGameControlGlobals.eventsPerObjects)) e.forEach((t) => t.disconnect());
  51734. (this.sharedGameControlGlobals.eventsPerObjects = {}), this.scene.updateMatrixWorld(!0);
  51735. }
  51736. update(e, t, i) {
  51737. let r = !0;
  51738. if (
  51739. (this.orbitControls !== void 0 && this.orbitControls.needsUpdate && (r = !this.orbitControls.update()),
  51740. this.initializationCounter >= 0 && this.initializationCounter < 2)
  51741. )
  51742. this.initializationCounter++, (r = !1);
  51743. else if (this.initializationCounter === 2) for (let s of this.gameControls) r = !s.update(e, t, i) && r;
  51744. if (this.usePhysics) {
  51745. for (let s of this.sharedGameControlGlobals.entitiesWithTransformAnim) {
  51746. (s.hasNonUniformScale ? s.matrixWorldRigid : s.matrixWorld).decompose(Ri, on, Kn), wf.setFromQuaternion(on);
  51747. let n = s;
  51748. n.prevR === void 0 ? ((n.prevR = wf.clone()), (n.prevT = Ri.clone())) : (n.prevR.copy(wf), n.prevT.copy(Ri)),
  51749. s.rigidBody.setNextKinematicTranslation(Ri.divideScalar(this.pixelsPerMeter)),
  51750. s.rigidBody.setNextKinematicRotation(on);
  51751. }
  51752. this.sharedGameControlGlobals.rapierWorld.step(this.events),
  51753. this.events?.drainCollisionEvents(this.handleCollisionEvents),
  51754. (r = !this.updatePositions() && r);
  51755. }
  51756. return r;
  51757. }
  51758. dispatchCollisionEvent(e, t) {
  51759. t.dispatchEvent(a2), e.dispatch();
  51760. }
  51761. updateUseWindowEvents(e) {
  51762. this.orbitControls?.updateUseWindowEvents(e);
  51763. }
  51764. },
  51765. _f = { type: 'change' },
  51766. XG = { type: 'lock' },
  51767. qG = { type: 'unlock' },
  51768. N9 = new E(),
  51769. zb = new E(),
  51770. Nb = new E(),
  51771. YG = new E(),
  51772. Di = new E(),
  51773. Qi = new E(),
  51774. ln = new E(),
  51775. Af = new ve(),
  51776. Ub = new ve(),
  51777. QG = new ve(),
  51778. U9 = new ve(),
  51779. Br = new ct(),
  51780. Ns = new ct(),
  51781. es = new _i(0, 0, 0, 'YXZ'),
  51782. ZG = new E(1, 0, 0),
  51783. zr = new E(0, 1, 0),
  51784. KG = new E(0, 0, 1),
  51785. Fb = new E(1, 1, 1),
  51786. JG = 1,
  51787. $G = 0.025,
  51788. eV = 16e-6,
  51789. kb = 12,
  51790. tV = 20,
  51791. xi = new _r(),
  51792. pr = new Kt(),
  51793. iV = { type: 'requestRender' },
  51794. jb = Math.PI / 6,
  51795. rg = class extends Vi {
  51796. constructor(e, t, i, r, s, n, a, o, l) {
  51797. super(),
  51798. (this.object = e),
  51799. (this.domElement = t),
  51800. (this.sharedGameControlGlobals = s),
  51801. (this.cameraFollow = n),
  51802. (this.camera = a),
  51803. (this.scene = o),
  51804. (this.sharedAssets = l),
  51805. (this.enableDamping = !0),
  51806. (this.position0 = new E()),
  51807. (this.rotation0 = new _i(0, 0, 0, 'XYZ')),
  51808. (this.scale0 = new E()),
  51809. (this.hiddenMatrix0 = new ve()),
  51810. (this.target0 = new E()),
  51811. (this.zoom0 = 1),
  51812. (this.rotForce = 1),
  51813. (this.moveForce = 1),
  51814. (this.euler0 = new _i(0, 0, 0, 'YXZ')),
  51815. (this.position0Cam = new E()),
  51816. (this.quat0Cam = new ct()),
  51817. (this.scale0Cam = new E()),
  51818. (this.hiddenMatrix0Cam = new ve()),
  51819. (this.threshEndTranslate = 0.01),
  51820. (this.threshEndRotate = 1e-8),
  51821. (this.threshEndRotVel = 0.005),
  51822. (this.collider = {
  51823. type: 'capsule',
  51824. radius: 40,
  51825. segment: new _r(new E(0, -40, 0), new E(0, 40, 0)),
  51826. matrix: new ve(),
  51827. position: new E(),
  51828. rotation: new ct()
  51829. }),
  51830. (this.euler = new _i(0, 0, 0, 'YXZ')),
  51831. (this.eulerDelta = new E()),
  51832. (this.lastPosition = new E()),
  51833. (this.lastCameraQuaternion = new ct()),
  51834. (this.lastCameraPosition = new E()),
  51835. (this.PI_2 = Math.PI / 2),
  51836. (this.prevMouse = new G()),
  51837. (this.velocityTarget = new E()),
  51838. (this.velocity = new E()),
  51839. (this.directionXZ = new E()),
  51840. (this.rotVelocityStick = new E()),
  51841. (this.rotVelocityTarget = new E()),
  51842. (this.rotVelocity = new E()),
  51843. (this.rotDirection = new E()),
  51844. (this.nonColliderRotOffset = new ve()),
  51845. (this.nonColliderPosOffset = new ve()),
  51846. (this.firstPointerId = -1),
  51847. (this.rot = new E()),
  51848. (this.movementState = {
  51849. moveNegZ: 0,
  51850. movePosZ: 0,
  51851. moveNegX: 0,
  51852. movePosX: 0,
  51853. moveNegY: 0,
  51854. movePosY: 0,
  51855. rotPosX: 0,
  51856. rotNegX: 0,
  51857. rotPosY: 0,
  51858. rotNegY: 0,
  51859. jump: 0
  51860. }),
  51861. (this.vrEulerYOffset = 0),
  51862. (this.onObject = !1),
  51863. (this.actionState = {}),
  51864. (this.keyAssignments = [
  51865. ['moveNegZ', 'W'],
  51866. ['moveNegX', 'A'],
  51867. ['movePosZ', 'S'],
  51868. ['movePosX', 'D'],
  51869. ['rotPosX', 'ArrowUp'],
  51870. ['rotPosY', 'ArrowLeft'],
  51871. ['rotNegX', 'ArrowDown'],
  51872. ['rotNegY', 'ArrowRight'],
  51873. ['jump', ' ']
  51874. ]),
  51875. (this.collisionEnabled = !0),
  51876. (this.offsetMatrix = new ve()),
  51877. (this.objectToTarget = new E()),
  51878. (this.objectToTarget0 = new E()),
  51879. (this.objectToCamXZ = new E()),
  51880. (this.objectToCamXZ0 = new E()),
  51881. (this.targetToCamera = new E()),
  51882. (this.targetToCamera0 = new E()),
  51883. (this.cameraPolarAxis0 = new E()),
  51884. (this.targetPos = new E()),
  51885. (this.targetQuat = new ct()),
  51886. (this.lerpFactorPos = new E().setScalar(0.3)),
  51887. (this.lerpFactorPosStart = 0.3),
  51888. (this.lerpFactorPosEnd = 0.3),
  51889. (this.lerpFactorRotStart = 0.3),
  51890. (this.lerpFactorRotEnd = 0.3),
  51891. (this.lerpFactorPosCamera = 0.3),
  51892. (this.lerpFactorRotCamera = 0.3),
  51893. (this.objXZQuat = new ct()),
  51894. (this.objXZQuatInv = new ct()),
  51895. (this.objXZRotMat = new ve()),
  51896. (this.isFirstPerson = !1),
  51897. (this.actions = {}),
  51898. (this.didHit = !1),
  51899. (this.groundVelocity = new E()),
  51900. (this.pushedVelocity = new E()),
  51901. (this.groundYRotation = 0),
  51902. (this.objectRealQuat = new ct()),
  51903. (this.colliderWorldQuat = new ct()),
  51904. (this.groundNormal = new E()),
  51905. (this.groundTilt = new ct()),
  51906. (this.groundTiltInv = new ct()),
  51907. (this.lastHitObj = null),
  51908. (this.isFirstFrame = !0),
  51909. (this.rotationAccumWhenOrientWithCamera = 0),
  51910. (this.onPointerDown = (f) => {
  51911. f.target !== this.domElement ||
  51912. this.firstPointerId !== -1 ||
  51913. ((this.firstPointerId = f.pointerId),
  51914. this.domElement.ownerDocument.addEventListener('pointermove', this.onPointerMove),
  51915. this.domElement.ownerDocument.addEventListener('pointerup', this.onPointerUp),
  51916. this.rotBy !== 'keys' && !rr && (!V1 || H1 >= 15.5) && this.domElement.requestPointerLock(),
  51917. this.prevMouse.set(f.clientX, f.clientY));
  51918. }),
  51919. (this.onPointerUp = (f) => {
  51920. (this.firstPointerId = -1),
  51921. this.domElement.ownerDocument.removeEventListener('pointermove', this.onPointerMove),
  51922. this.domElement.ownerDocument.removeEventListener('pointerup', this.onPointerUp),
  51923. f.pointerType === 'mouse' && this.domElement.ownerDocument.exitPointerLock();
  51924. }),
  51925. (this.onPointerMove = (f) => {
  51926. if (f.pointerId !== this.firstPointerId) return;
  51927. let g = f.clientX - this.prevMouse.x,
  51928. m = f.clientY - this.prevMouse.y;
  51929. this.prevMouse.set(f.clientX, f.clientY),
  51930. f.pointerType === 'mouse' &&
  51931. this.rotBy !== 'keys' &&
  51932. (V1 && H1 < 15.5 && !rr
  51933. ? ((this.eulerDelta.y = -g * this.mouseOrbitSensitivity), (this.eulerDelta.x = -m * this.mouseOrbitSensitivity))
  51934. : ((this.eulerDelta.y = -f.movementX * this.mouseOrbitSensitivity),
  51935. (this.eulerDelta.x = -f.movementY * this.mouseOrbitSensitivity))),
  51936. f.pointerType !== 'mouse' &&
  51937. this.rotByTouch === 'drag' &&
  51938. ((this.eulerDelta.y = -g * this.mouseOrbitSensitivity * 5), (this.eulerDelta.x = -m * this.mouseOrbitSensitivity * 5)),
  51939. this.dispatchEvent(_f);
  51940. }),
  51941. (this.onPointerlockChange = (f) => {
  51942. this.domElement.ownerDocument.pointerLockElement === this.domElement
  51943. ? (this.dispatchEvent(XG), (rg.isLocked = !0))
  51944. : (this.dispatchEvent(qG), (rg.isLocked = !1));
  51945. }),
  51946. (this.onPointerlockError = () => {
  51947. console.error('SPE.GameControls: Unable to use Pointer Lock API');
  51948. }),
  51949. (this.onKeyDown = (f) => {
  51950. !(f.target instanceof HTMLInputElement) &&
  51951. (f.code === 'ArrowLeft' || f.code === 'ArrowUp' || f.code === 'ArrowRight' || f.code === 'ArrowDown' || f.code === 'Space') &&
  51952. f.preventDefault();
  51953. for (let g of this.keyAssignments)
  51954. if (f.key.toUpperCase() === g[1] || f.key === g[1]) {
  51955. this.movementState[g[0]] = 1;
  51956. break;
  51957. }
  51958. this.dispatchEvent(_f);
  51959. }),
  51960. (this.onKeyUp = (f) => {
  51961. for (let g of this.keyAssignments)
  51962. if (f.key.toUpperCase() === g[1] || f.key === g[1] || f.code.slice(3, f.code.length).toUpperCase() === g[1]) {
  51963. this.movementState[g[0]] = 0;
  51964. break;
  51965. }
  51966. }),
  51967. (this.copyVRGamePadValues = (f, g) => {
  51968. for (let m = 2; m < 4; m++) {
  51969. let v = f.axes[m];
  51970. g === 0
  51971. ? m === 2
  51972. ? (this.movementState.movePosX = v)
  51973. : (this.movementState.movePosZ = v)
  51974. : (f.buttons[3].pressed ? (this.movementState.jump = 1) : (this.movementState.jump = 0),
  51975. m === 2
  51976. ? (Math.abs(this.movementState.rotPosY) < 0.3 && Math.abs(v) >= 0.3 && (this.vrEulerYOffset += v < 0 ? 1 : -1),
  51977. (this.movementState.rotPosY = v))
  51978. : this.moveMode === 'fly' && (this.movementState.moveNegY = v));
  51979. }
  51980. }),
  51981. e === a && (this.isFirstPerson = !0),
  51982. this.position0.copy(this.object.position),
  51983. this.rotation0.copy(this.object.rotation),
  51984. this.scale0.copy(this.object.scale),
  51985. this.hiddenMatrix0.copy(this.object.hiddenMatrix),
  51986. this.object.parent ? this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert() : this.object.hiddenMatrix.identity(),
  51987. this.object.matrix.copy(this.object.matrixWorld),
  51988. this.object.matrix.decompose(this.object.position, this.object.quaternion, this.object.scale),
  51989. this.object.rotation.reorder('YXZ'),
  51990. this.euler0.copy(this.object.rotation);
  51991. let h = this.object.rotation.y;
  51992. if (
  51993. (this.objectRealQuat.copy(this.object.quaternion),
  51994. (this.object.rotation.y = 0),
  51995. this.objXZQuat.copy(this.object.quaternion),
  51996. this.objXZQuatInv.copy(this.objXZQuat).invert(),
  51997. this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion),
  51998. this.object.rotation.set(0, h, 0),
  51999. this.rot.setFromEuler(this.object.rotation),
  52000. (this.object.matrixAutoUpdate = !1),
  52001. (this.isFirstPerson || this.cameraFollow === !0) && (this.target0.copy(this.camera.getTarget()), (this.zoom0 = this.camera.zoom)),
  52002. this.cameraFollow === !0)
  52003. ) {
  52004. this.position0Cam.copy(this.camera.position),
  52005. this.quat0Cam.copy(this.camera.quaternion),
  52006. this.scale0Cam.copy(this.camera.scale),
  52007. this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),
  52008. this.camera.parent
  52009. ? (this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld), this.camera.matrix.copy(this.camera.matrixWorld))
  52010. : this.camera.hiddenMatrix.identity(),
  52011. this.camera.matrix.copy(this.camera.matrixWorld),
  52012. this.camera.matrix.decompose(this.camera.position, this.camera.quaternion, this.camera.scale),
  52013. (this.camera.matrixAutoUpdate = !1),
  52014. this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);
  52015. let f = new E(0, 0, -1).applyQuaternion(this.camera.quaternion),
  52016. g = new E().subVectors(this.object.position, this.camera.position);
  52017. this.objectToCamXZ.copy(g), (this.objectToCamXZ.y = 0), this.objectToCamXZ0.copy(this.objectToCamXZ);
  52018. let m, v;
  52019. Math.abs(f.y) < 1e-6
  52020. ? ((g.y = 0), (f.y = 0), (v = g.projectOnVector(f)))
  52021. : g.y / f.y > 0
  52022. ? (v = f.multiplyScalar(g.y / f.y))
  52023. : (v = f.multiplyScalar(g.length())),
  52024. this.targetToCamera0.copy(v).negate(),
  52025. (m = this.camera.position.clone().add(v)),
  52026. this.objectToTarget0.subVectors(m, this.object.position);
  52027. let y = new _i().setFromQuaternion(this.camera.quaternion, 'YXZ');
  52028. (this.cameraPolarOffset = -y.x), (y.x = 0), (y.z = 0), (y.y -= Math.PI / 2), this.cameraPolarAxis0.set(0, 0, -1).applyEuler(y);
  52029. }
  52030. if (
  52031. (this.object instanceof Gi && (this.object.matrixAutoUpdate = !1),
  52032. this.euler.setFromQuaternion(this.object.quaternion, 'YXZ'),
  52033. this.connect(),
  52034. (this.rotByTouch = i.rotByTouch ?? 'joystick'),
  52035. (this.rotBy = i.rotBy ?? 'keys'),
  52036. (this.rotationMode = i.rotationMode ?? 'normal'),
  52037. (this.moveMode = i.moveMode ?? 'walk'),
  52038. (this.collisionEnabled = i.collisionEnabled),
  52039. (this.speedTranslate = (i.speedTranslate ?? 250) * JG),
  52040. (this.speedOrbit = (i.speedRotate ?? 100) * $G),
  52041. (this.mouseOrbitSensitivity = (i.speedRotate ?? 100) * eV),
  52042. (this.keyAssignments = i.keyAssignments.map((f) => {
  52043. let g = [f[0], f[1]];
  52044. return (
  52045. g[1] === '▲'
  52046. ? (g[1] = 'ArrowUp')
  52047. : g[1] === '◀'
  52048. ? (g[1] = 'ArrowLeft')
  52049. : g[1] === '▼'
  52050. ? (g[1] = 'ArrowDown')
  52051. : g[1] === '▶'
  52052. ? (g[1] = 'ArrowRight')
  52053. : g[1] === '⇧'
  52054. ? (g[1] = 'Shift')
  52055. : g[1] === '↵'
  52056. ? (g[1] = 'Enter')
  52057. : g[1] === 'Space'
  52058. ? (g[1] = ' ')
  52059. : g[1] === '⌘'
  52060. ? (g[1] = 'Meta')
  52061. : g[1] === 'Ctrl'
  52062. ? (g[1] = 'Control')
  52063. : g[1] === 'Esc' && (g[1] = 'Escape'),
  52064. g
  52065. );
  52066. })),
  52067. i.rotBy === 'mouse')
  52068. ) {
  52069. let f;
  52070. (f = this.keyAssignments.findIndex((g) => g[0] === 'rotNegX')),
  52071. f !== -1 && (this.keyAssignments[f][1] = ''),
  52072. (f = this.keyAssignments.findIndex((g) => g[0] === 'rotPosX')),
  52073. f !== -1 && (this.keyAssignments[f][1] = ''),
  52074. (f = this.keyAssignments.findIndex((g) => g[0] === 'rotPosY')),
  52075. f !== -1 && (this.keyAssignments[f][1] = ''),
  52076. (f = this.keyAssignments.findIndex((g) => g[0] === 'rotNegY')),
  52077. f !== -1 && (this.keyAssignments[f][1] = '');
  52078. }
  52079. (this.lerpFactorPosStart = 1 - 0.02 ** (1 / ((i.delayPos[0] ?? 0.3) * 60))),
  52080. (this.lerpFactorPosEnd = 1 - 0.02 ** (1 / ((i.delayPos[1] ?? 0.3) * 60))),
  52081. this.lerpFactorPos.setScalar(this.lerpFactorPosStart),
  52082. (this.lerpFactorRotStart = 1 - 0.02 ** (1 / ((i.delayRot[0] ?? 0.3) * 60))),
  52083. (this.lerpFactorRotEnd = 1 - 0.02 ** (1 / ((i.delayRot[1] ?? 0.3) * 60))),
  52084. (this.lerpFactorPosCamera = 1 - 0.02 ** (1 / ((i.delayPosCamera ?? 0.3) * 60))),
  52085. (this.lerpFactorRotCamera = 1 - 0.02 ** (1 / ((i.delayRotCamera ?? 0.3) * 60))),
  52086. (this.gravity = (r.gravity ?? Ki.defaultData.gravity) * kb),
  52087. (this.pixelsPerMeter = r.pixelsPerMeter ?? Ki.defaultData.pixelsPerMeter),
  52088. (this.usePhysics = r.usePhysics ?? Ki.defaultData.usePhysics),
  52089. (this.jumpPower = i.jumpPower * tV),
  52090. (this.resetYPosition = this.object.position.y + Math.abs(i.resetYPosition) * (this.gravity > 0 ? 1 : -1)),
  52091. (this.alignToGround = i.alignToGround ?? !1),
  52092. (this.orientMode = i.autoOrientMove ? i.orientMode : 'none'),
  52093. (this.orientWith = i.orientWith ?? Cm.defaultDataThirdPerson.orientWith);
  52094. let u = r.skinWidthRelative ?? Ki.defaultData.skinWidthRelative,
  52095. c = r.stepThreshRelative ?? Ki.defaultData.stepThreshRelative;
  52096. (this.slopeThresh = ((r.slopeThresh ?? Ki.defaultData.slopeThresh) * Math.PI) / 180),
  52097. i.collider.type === 'capsule'
  52098. ? ((this.collider.radius = i.collider.radius),
  52099. (this.collider.segment.start.y = i.collider.height / 2 - i.collider.radius),
  52100. (this.collider.segment.end.y = -this.collider.segment.start.y),
  52101. (this.offset = (i.collider.height * u) / this.pixelsPerMeter),
  52102. (this.stepThresh = (i.collider.height * c) / this.pixelsPerMeter))
  52103. : i.collider.type === 'sphere'
  52104. ? ((this.collider.radius = i.collider.radius),
  52105. (this.collider.segment.start.y = 0),
  52106. (this.collider.segment.end.y = 0),
  52107. (this.offset = (2 * i.collider.radius * u) / this.pixelsPerMeter),
  52108. (this.stepThresh = (2 * i.collider.radius * c) / this.pixelsPerMeter))
  52109. : ((this.offset = (i.collider.height * u) / this.pixelsPerMeter),
  52110. (this.stepThresh = (i.collider.height * c) / this.pixelsPerMeter)),
  52111. (this.collider.type = i.collider.type);
  52112. let d = new E().fromArray(i.collider.position),
  52113. p = new ct().setFromEuler(new _i().fromArray([...i.collider.rotation, 'XYZ']));
  52114. this.collider.position.copy(d).multiply(this.object.scale),
  52115. this.collider.rotation.copy(p),
  52116. this.collider.matrix.compose(d, p, Fb),
  52117. i.cameraXAxis !== void 0 &&
  52118. ((this.cameraXAxis = i.cameraXAxis),
  52119. (this.cameraYAxis = i.cameraYAxis),
  52120. (this.minPolarAngle = i.cameraRotXLimits[0]),
  52121. (this.maxPolarAngle = i.cameraRotXLimits[1]),
  52122. (this.minAzimuthAngleRel = i.cameraRotYLimits[0]),
  52123. (this.maxAzimuthAngleRel = i.cameraRotYLimits[1])),
  52124. i.gameActions !== void 0 &&
  52125. Object.entries(i.gameActions).forEach(([f, g], m) => {
  52126. g.forEach(({ id: v, data: y }) => {
  52127. try {
  52128. this.actions[f] === void 0 && (this.actions[f] = []),
  52129. y.type === 'Transition'
  52130. ? this.actions[f].push(new _o(y, o, l))
  52131. : y.type === 'Audio'
  52132. ? this.actions[f].push(new wo(v, y, e, l))
  52133. : y.type === 'Video' && this.actions[f].push(new ru(v, y, e));
  52134. } catch {}
  52135. });
  52136. }),
  52137. this.dispatchStopEvent('move'),
  52138. this.dispatchStopEvent('jump'),
  52139. this.dispatchStartEvent('idle');
  52140. }
  52141. reset(e = !1) {
  52142. if (
  52143. (this.object.rotation.copy(this.rotation0),
  52144. this.object.position.copy(this.position0),
  52145. this.object.scale.copy(this.scale0),
  52146. this.object.hiddenMatrix.copy(this.hiddenMatrix0),
  52147. e === !0)
  52148. ) {
  52149. this.object.updateMatrix(),
  52150. this.object.updateMatrixWorld(),
  52151. this.object.matrix.copy(this.object.matrixWorld),
  52152. this.object.matrix.decompose(this.object.position, this.object.quaternion, this.object.scale),
  52153. this.object.parent ? this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert() : this.object.hiddenMatrix.identity(),
  52154. this.object.rotation.reorder('YXZ');
  52155. let t = this.object.rotation.y;
  52156. (this.object.rotation.y = 0),
  52157. this.objXZQuat.copy(this.object.quaternion),
  52158. this.objXZQuatInv.copy(this.objXZQuat).invert(),
  52159. this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion),
  52160. this.object.rotation.set(0, t, 0),
  52161. this.rot.setFromEuler(this.object.rotation),
  52162. this.euler.setFromQuaternion(this.object.quaternion, 'YXZ'),
  52163. this.velocityTarget.set(0, 0, 0),
  52164. this.velocity.set(0, 0, 0);
  52165. }
  52166. e === !1 && (this.object instanceof Gi ? (this.object.matrixAutoUpdate = !0) : this.object.updateMatrix()),
  52167. this.cameraFollow === !0 &&
  52168. (this.camera.quaternion.copy(this.quat0Cam),
  52169. this.camera.position.copy(this.position0Cam),
  52170. this.camera.scale.copy(this.scale0Cam),
  52171. this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),
  52172. (this.camera.matrixAutoUpdate = !0)),
  52173. this.dispatchEvent(_f);
  52174. }
  52175. connect() {
  52176. this.domElement.ownerDocument.addEventListener('pointerdown', this.onPointerDown),
  52177. this.domElement.ownerDocument.addEventListener('keydown', this.onKeyDown),
  52178. this.domElement.ownerDocument.addEventListener('keyup', this.onKeyUp),
  52179. this.domElement.ownerDocument.addEventListener('pointerlockchange', this.onPointerlockChange),
  52180. this.domElement.ownerDocument.addEventListener('pointerlockerror', this.onPointerlockError);
  52181. }
  52182. disconnect() {
  52183. this.domElement.ownerDocument.removeEventListener('pointerdown', this.onPointerDown),
  52184. this.domElement.ownerDocument.removeEventListener('keydown', this.onKeyDown),
  52185. this.domElement.ownerDocument.removeEventListener('keyup', this.onKeyUp),
  52186. this.domElement.ownerDocument.removeEventListener('pointerlockchange', this.onPointerlockChange),
  52187. this.domElement.ownerDocument.removeEventListener('pointerlockerror', this.onPointerlockError);
  52188. }
  52189. dispose() {
  52190. this.disconnect(),
  52191. Object.values(this.actions).forEach((e) => {
  52192. e.forEach((t) => {
  52193. (t instanceof _o || t instanceof wo || t instanceof ru) && t.dispose();
  52194. });
  52195. });
  52196. }
  52197. dispatchStartEvent(e) {
  52198. this.actions[e] !== void 0 &&
  52199. (this.actionState[e] ||
  52200. ((this.actionState[e] = !0),
  52201. this.actions[e].forEach((t) => {
  52202. t instanceof _o ? t.play() : t instanceof wo && t.dispatchGameControl('start');
  52203. })));
  52204. }
  52205. dispatchStopEvent(e) {
  52206. this.actions[e] !== void 0 &&
  52207. (!this.actionState[e] ||
  52208. ((this.actionState[e] = !1),
  52209. this.actions[e].forEach((t) => {
  52210. t instanceof _o ? t.stop() : t instanceof wo && t.dispatchGameControl('stop');
  52211. }),
  52212. this.object.traverseEntity((t) => {
  52213. t.currentState !== null && t.changeSelectedState(null, { scene: this.scene, shared: this.sharedAssets });
  52214. })));
  52215. }
  52216. update(e, t, i) {
  52217. if (this.gravity < 0 ? this.object.position.y < this.resetYPosition : this.object.position.y > this.resetYPosition)
  52218. return this.reset(!0), !0;
  52219. this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);
  52220. let r = (this.isFirstFrame ? 16.6 : e) / 1e3;
  52221. this.isFirstFrame && (this.isFirstFrame = !1);
  52222. let s = r * 60,
  52223. n = !1;
  52224. if (this.usePhysics && this.collisionEnabled) {
  52225. let o = Qi.set(
  52226. 0,
  52227. (this.velocity.y === 0
  52228. ? this.pixelsPerMeter * Math.max(Math.abs(this.gravity) / (10 * kb), 1) * (this.gravity > 0 ? 1 : -1)
  52229. : this.velocity.y) * r,
  52230. 0
  52231. ).divideScalar(this.pixelsPerMeter),
  52232. l = this.sharedGameControlGlobals.rapierWorld.castShape(
  52233. Di.copy(this.collider.position)
  52234. .applyQuaternion(this.objectRealQuat)
  52235. .add(this.object.position)
  52236. .divideScalar(this.pixelsPerMeter),
  52237. this.colliderWorldQuat,
  52238. o,
  52239. this.object.rigidBody?.collider(0).shape,
  52240. 1,
  52241. !1,
  52242. void 0,
  52243. void 0,
  52244. void 0,
  52245. this.object.rigidBody
  52246. );
  52247. if (l) {
  52248. (this.onObject = !0),
  52249. this.groundNormal.set(l.normal2.x, l.normal2.y, l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),
  52250. this.alignToGround && this.groundTiltAdjustment(this.groundNormal),
  52251. Math.acos(this.groundNormal.y) < this.slopeThresh && (n = !0),
  52252. l.collider.parent()?.bodyType() === 0 && Math.acos(this.groundNormal.y) * (180 / Math.PI) > 45 && (this.onObject = !1);
  52253. let h = l.collider.parent();
  52254. (this.groundYRotation = 0), this.groundVelocity.set(0, 0, 0);
  52255. for (let u of this.sharedGameControlGlobals.entitiesWithTransformAnim)
  52256. if (u.rigidBody === h) {
  52257. (u.hasNonUniformScale ? u.matrixWorldRigid : u.matrixWorld).decompose(Di, Ns, Qi),
  52258. this.groundVelocity.subVectors(Di, u.prevT),
  52259. this.object.getWorldPosition(Qi).add(this.collider.position).sub(u.position),
  52260. (this.groundYRotation = es.setFromQuaternion(Ns).y - u.prevR.y),
  52261. ln.copy(Qi).applyAxisAngle(zr, this.groundYRotation),
  52262. this.groundVelocity.add(ln.sub(Qi)).divideScalar(r);
  52263. break;
  52264. }
  52265. } else this.onObject = !1;
  52266. }
  52267. this.moveMode === 'walk' &&
  52268. this.collisionEnabled &&
  52269. (this.movementState.jump === 1 &&
  52270. this.onObject &&
  52271. ((this.velocityTarget.y = this.jumpPower),
  52272. (this.movementState.jump = 0),
  52273. this.dispatchStopEvent('idle'),
  52274. this.dispatchStopEvent('move'),
  52275. this.dispatchStopEvent('jump'),
  52276. this.dispatchStartEvent('jump'),
  52277. (this.onObject = !1)),
  52278. this.onObject ? (this.velocityTarget.y /= 2) : (this.velocityTarget.y += this.gravity * s)),
  52279. this.moveMode === 'fly' &&
  52280. (this.velocityTarget.y = (this.movementState.movePosY - this.movementState.moveNegY) * this.speedTranslate),
  52281. (this.directionXZ.z = this.movementState.movePosZ - this.movementState.moveNegZ),
  52282. (this.directionXZ.x = this.movementState.movePosX - this.movementState.moveNegX),
  52283. this.directionXZ.normalize(),
  52284. this.movementState.moveNegZ || this.movementState.movePosZ
  52285. ? (this.velocityTarget.z = this.directionXZ.z * this.speedTranslate * this.moveForce)
  52286. : (this.velocityTarget.z = 0),
  52287. this.movementState.moveNegX || this.movementState.movePosX
  52288. ? (this.velocityTarget.x = this.directionXZ.x * this.speedTranslate * this.moveForce)
  52289. : (this.velocityTarget.x = 0),
  52290. (this.moveMode === 'walk' ? this.velocityTarget.x + this.velocityTarget.z === 0 : this.velocityTarget.manhattanLength() === 0)
  52291. ? this.lerpFactorPos.setScalar(this.lerpFactorPosEnd)
  52292. : this.lerpFactorPos.setScalar(this.lerpFactorPosStart),
  52293. this.moveMode === 'walk' && (this.lerpFactorPos.y = 1),
  52294. (this.didHit === !1 && this.pushedVelocity.manhattanLength() === 0) || this.usePhysics === !1
  52295. ? ((this.velocity.x += (this.velocityTarget.x - this.velocity.x) * (1 - (1 - this.lerpFactorPos.x) ** s)),
  52296. (this.velocity.y += (this.velocityTarget.y - this.velocity.y) * (1 - (1 - this.lerpFactorPos.y) ** s)),
  52297. (this.velocity.z += (this.velocityTarget.z - this.velocity.z) * (1 - (1 - this.lerpFactorPos.z) ** s)))
  52298. : this.velocity.copy(this.velocityTarget),
  52299. (
  52300. this.moveMode === 'walk'
  52301. ? this.velocity.x ** 2 + this.velocity.z ** 2 < this.speedTranslate
  52302. : this.velocity.lengthSq() < this.speedTranslate
  52303. )
  52304. ? (this.dispatchStopEvent('move'), this.onObject && (this.dispatchStopEvent('jump'), this.dispatchStartEvent('idle')))
  52305. : (this.dispatchStopEvent('idle'), this.onObject && (this.dispatchStopEvent('jump'), this.dispatchStartEvent('move')));
  52306. let a = YG.copy(this.velocity);
  52307. if (this.orientMode !== 'none' && this.isFirstPerson === !1) {
  52308. let o = Qi.copy(a);
  52309. (o.y = 0), a.set(0, a.y, o.length() * -1);
  52310. }
  52311. if (
  52312. (es.setFromVector3(this.rot),
  52313. this.moveMode === 'walk' && (es.x = 0),
  52314. a.applyEuler(es),
  52315. n && (Ns.setFromUnitVectors(zr, this.groundNormal), a.applyQuaternion(Ns)),
  52316. i)
  52317. ) {
  52318. let o = es.set(0, this.vrEulerYOffset * jb, 0);
  52319. i.applyEuler(o), (a.x += i.x), (a.z += i.z), (this.nonColliderPosOffset.elements[13] += i.y * r);
  52320. }
  52321. if (this.usePhysics === !0) {
  52322. let o = Qi;
  52323. this.pushedVelocity.set(0, 0, 0);
  52324. for (let l of this.sharedGameControlGlobals.entitiesWithTransformAnim) {
  52325. let h = ln.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),
  52326. u = l.rigidBody
  52327. .collider(0)
  52328. .castCollider(h, this.object.rigidBody.collider(0), Di.copy(a).divideScalar(this.pixelsPerMeter), r, !1);
  52329. if ((h.multiplyScalar(this.pixelsPerMeter), u !== null)) {
  52330. this.pushedVelocity.copy(h), o.copy(u.normal1).applyQuaternion(l.quaternion);
  52331. break;
  52332. }
  52333. }
  52334. if (this.pushedVelocity.manhattanLength() !== 0) {
  52335. let l = o.dot(a);
  52336. l < 0 && a.addScaledVector(o, -l), a.add(this.pushedVelocity);
  52337. } else a.add(this.groundVelocity);
  52338. }
  52339. if (
  52340. ((this.rotDirection.y = Number(this.movementState.rotPosY) - Number(this.movementState.rotNegY)),
  52341. (this.rotDirection.x = Number(this.movementState.rotPosX) - Number(this.movementState.rotNegX)),
  52342. this.rotDirection.normalize(),
  52343. (this.rotationMode === 'normal' && (this.movementState.rotPosX || this.movementState.rotNegX)) ||
  52344. (this.rotationMode === 'steer' &&
  52345. (this.movementState.rotPosX || this.movementState.rotNegX) &&
  52346. (this.movementState.movePosZ || this.movementState.moveNegZ || this.moveMode === 'walk'))
  52347. ? (this.rotVelocityStick.x = -this.rotDirection.x * this.speedOrbit * this.rotForce)
  52348. : (this.rotVelocityStick.x = 0),
  52349. (this.rotationMode === 'normal' && (this.movementState.rotPosY || this.movementState.rotNegY)) ||
  52350. (this.rotationMode === 'steer' &&
  52351. (this.movementState.rotPosY || this.movementState.rotNegY) &&
  52352. (this.movementState.movePosZ || this.movementState.moveNegZ))
  52353. ? (this.rotVelocityStick.y = -this.rotDirection.y * this.speedOrbit * this.rotForce)
  52354. : (this.rotVelocityStick.y = 0),
  52355. this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r), this.rotVelocityStick),
  52356. this.rotVelocityTarget.manhattanLength() === 0
  52357. ? this.rotVelocity.lerp(this.rotVelocityTarget, 1 - (1 - this.lerpFactorRotEnd) ** s)
  52358. : this.rotVelocity.lerp(this.rotVelocityTarget, 1 - (1 - this.lerpFactorRotStart) ** s),
  52359. (this.euler.x += this.rotVelocity.x * r),
  52360. (this.euler.y += this.rotVelocity.y * r + this.groundYRotation),
  52361. this.rotVelocityTarget.y === 0 && this.directionXZ.manhattanLength() === 0
  52362. ? (this.rotationAccumWhenOrientWithCamera = 0)
  52363. : (this.cameraFollow === !1 || this.cameraYAxis === 'Locked') &&
  52364. (this.rotationAccumWhenOrientWithCamera += this.rotVelocity.y * r),
  52365. this.isFirstPerson === !1 && this.orientMode !== 'none' && this.directionXZ.manhattanLength() > 0)
  52366. ) {
  52367. let o = Di,
  52368. l = Qi.copy(this.directionXZ);
  52369. (l.x *= -1), this.camera.getWorldDirection(o);
  52370. let h = ln.copy(zr).multiplyScalar(o.dot(zr));
  52371. if (
  52372. (o.sub(h),
  52373. this.orientWith === 'camera'
  52374. ? (this.rot.y = o.angleTo(l) * (o.cross(l).y > 0 ? -1 : 1) + this.rotationAccumWhenOrientWithCamera)
  52375. : (this.rot.y = this.euler.y + Math.atan2(-this.directionXZ.z, this.directionXZ.x) - Math.PI / 2),
  52376. this.orientMode === 'radial')
  52377. ) {
  52378. this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(zr, this.euler.y - this.euler0.y);
  52379. let u = Qi.copy(this.objectToCamXZ).normalize(),
  52380. c = ln.copy(a).multiplyScalar(r);
  52381. c.y = 0;
  52382. let d = c.sub(Di.copy(u).multiplyScalar(c.dot(u))).cross(u).y;
  52383. this.euler.y -= Math.atan2(d, this.objectToCamXZ.length());
  52384. }
  52385. } else
  52386. (this.rot.y += this.rotVelocity.y * r + this.groundYRotation),
  52387. this.rotVelocityTarget.y !== 0 && (this.cameraFollow === !1 || this.cameraYAxis === 'Locked') && (this.euler.y = this.rot.y);
  52388. if (
  52389. (this.cameraFollow === !0 &&
  52390. (this.moveMode === 'walk'
  52391. ? this.cameraXAxis === 'Limit'
  52392. ? (this.euler.x = it.clamp(
  52393. this.euler.x,
  52394. -this.maxPolarAngle + this.cameraPolarOffset + 1e-6,
  52395. -this.minPolarAngle + this.cameraPolarOffset - 1e-6
  52396. ))
  52397. : (this.euler.x = it.clamp(this.euler.x, -this.PI_2 + this.cameraPolarOffset, this.PI_2 + this.cameraPolarOffset))
  52398. : this.cameraXAxis === 'Limit' && (this.euler.x = it.clamp(this.euler.x, -this.PI_2, this.PI_2))),
  52399. this.moveMode === 'fly'
  52400. ? (this.rot.x = this.euler.x)
  52401. : this.isFirstPerson &&
  52402. (t ? (es.copy(t), (es.y = 0)) : (es.copy(this.euler), (es.y = 0)), this.nonColliderRotOffset.makeRotationFromEuler(es)),
  52403. t &&
  52404. (this.moveMode === 'walk' ? ((this.rot.y = t.y), (this.rot.x = 0), (this.rot.z = 0)) : this.rot.setFromEuler(t),
  52405. (this.rot.y += this.vrEulerYOffset * jb)),
  52406. Br.setFromAxisAngle(ZG, this.rot.x),
  52407. Ns.setFromAxisAngle(zr, this.rot.y),
  52408. Ns.multiply(Br),
  52409. Br.setFromAxisAngle(KG, this.rot.z),
  52410. Ns.multiply(Br),
  52411. this.object.quaternion.copy(Ns),
  52412. this.objectRealQuat.multiplyQuaternions(this.object.quaternion, this.objXZQuat),
  52413. this.objectRealQuat.multiply(this.objXZQuat),
  52414. this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),
  52415. this.collisionEnabled)
  52416. )
  52417. if (this.usePhysics) {
  52418. let o = Qi.copy(a).multiplyScalar(r / this.pixelsPerMeter),
  52419. l = null;
  52420. this.didHit = !1;
  52421. let h = new E();
  52422. for (let u = 0; u < 5; u++) {
  52423. let c = o.length(),
  52424. d = ln.copy(o).normalize();
  52425. if (
  52426. ((l = this.sharedGameControlGlobals.rapierWorld.castShape(
  52427. Di.copy(this.collider.position)
  52428. .applyQuaternion(this.objectRealQuat)
  52429. .add(this.object.position)
  52430. .divideScalar(this.pixelsPerMeter)
  52431. .add(h),
  52432. this.colliderWorldQuat,
  52433. d,
  52434. this.object.rigidBody?.collider(0).shape,
  52435. c,
  52436. !1,
  52437. 8,
  52438. void 0,
  52439. void 0,
  52440. this.object.rigidBody
  52441. )),
  52442. l !== null)
  52443. ) {
  52444. this.didHit = !0;
  52445. let p = this.sharedGameControlGlobals.colliderToEntity[l.collider.handle];
  52446. if (p !== this.lastHitObj && u === 0) {
  52447. this.lastHitObj = p;
  52448. let v = this.sharedGameControlGlobals.eventsPerObjects[p?.uuid];
  52449. if (v) for (let y of v) y.data.target === 'character' && (p.dispatchEvent(a2), y.dispatch());
  52450. }
  52451. let f = zb.set(l.normal2.x, l.normal2.y, l.normal2.z).applyQuaternion(this.colliderWorldQuat),
  52452. g = Nb.copy(d).multiplyScalar(l.toi).dot(f),
  52453. m = l.toi;
  52454. if (
  52455. (m === 0 && (this.object.position.y += this.offset * this.pixelsPerMeter),
  52456. g > this.offset && ((m = (l.toi * (g - this.offset)) / g), h.addScaledVector(d, m)),
  52457. o.copy(d).multiplyScalar(c - m),
  52458. Math.acos(-f.y) > this.slopeThresh)
  52459. ) {
  52460. let v = Di.copy(this.collider.position)
  52461. .applyQuaternion(this.objectRealQuat)
  52462. .add(this.object.position)
  52463. .divideScalar(this.pixelsPerMeter)
  52464. .add(h),
  52465. y = ln.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);
  52466. y.y = 0;
  52467. let b = v.add(y);
  52468. b.y += this.stepThresh;
  52469. let x = this.sharedGameControlGlobals.rapierWorld.castShape(
  52470. b,
  52471. this.colliderWorldQuat,
  52472. o,
  52473. this.object.rigidBody?.collider(0).shape,
  52474. 1,
  52475. !1,
  52476. 8,
  52477. void 0,
  52478. void 0,
  52479. this.object.rigidBody
  52480. );
  52481. x !== null && x.toi === 0 && ((f.y = 0), f.normalize());
  52482. }
  52483. o.addScaledVector(f, -o.dot(f));
  52484. } else {
  52485. u === 0 && this.directionXZ.manhattanLength() !== 0 && (this.lastHitObj = null), h.add(o);
  52486. break;
  52487. }
  52488. }
  52489. this.object.position.addScaledVector(h, this.pixelsPerMeter),
  52490. this.object.rigidBody?.setTranslation(Di.copy(this.object.position).divideScalar(this.pixelsPerMeter), !0),
  52491. this.object.rigidBody?.setRotation(Br.copy(this.object.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat), !0);
  52492. } else {
  52493. let o = this.onObject ? 1 : 5,
  52494. l = a.multiplyScalar(r / o);
  52495. for (let h = 0; h < o; h++) this.object.position.add(l), this.collisionAdjustment(r / o);
  52496. }
  52497. else this.object.position.addScaledVector(a, r);
  52498. if (
  52499. (this.moveMode === 'walk' && this.onObject && ((this.velocityTarget.y = 0), (this.velocity.y = 0)),
  52500. this.object.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),
  52501. this.object.updateMatrix(),
  52502. this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),
  52503. this.object.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),
  52504. this.cameraFollow === !0)
  52505. ) {
  52506. this.updateFollowArms();
  52507. let o = this.objectToTarget.add(this.object.position),
  52508. l = this.targetToCamera.add(o);
  52509. Af.lookAt(l, o, zr).setPosition(l),
  52510. Af.decompose(this.targetPos, this.targetQuat, Di),
  52511. this.camera.quaternion.slerp(this.targetQuat, 1 - (1 - this.lerpFactorRotCamera) ** s),
  52512. this.camera.position.lerp(this.targetPos, 1 - (1 - this.lerpFactorPosCamera) ** s),
  52513. this.camera.updateMatrix(),
  52514. this.camera.updateMatrixWorld(),
  52515. this.cameraYAxis === 'Limit' &&
  52516. this.orientMode === 'cartesian' &&
  52517. (this.euler.y = it.clamp(this.euler.y, this.minAzimuthAngleRel, this.maxAzimuthAngleRel)),
  52518. (this.euler.x = it.clamp(
  52519. this.euler.x,
  52520. -this.PI_2 + (this.cameraPolarOffset < 0 ? this.cameraPolarOffset : 0),
  52521. this.PI_2 + (this.cameraPolarOffset > 0 ? this.cameraPolarOffset : 0)
  52522. ));
  52523. }
  52524. return (
  52525. this.eulerDelta.set(0, 0, 0),
  52526. this.lastPosition.distanceToSquared(this.object.position) < this.threshEndTranslate &&
  52527. Math.abs(this.rotVelocity.x) < this.threshEndRotVel &&
  52528. Math.abs(this.rotVelocity.y) < this.threshEndRotVel &&
  52529. (this.camera === void 0 ||
  52530. this.isFirstPerson ||
  52531. (this.lastCameraPosition.distanceToSquared(this.camera.position) < this.threshEndTranslate &&
  52532. 8 * (1 - this.lastCameraQuaternion.dot(this.camera.quaternion)) < this.threshEndRotate)) &&
  52533. (this.moveMode === 'fly' || this.onObject === !0 || this.collisionEnabled === !1)
  52534. ? !1
  52535. : (this.camera && (this.lastCameraPosition.copy(this.camera.position), this.lastCameraQuaternion.copy(this.camera.quaternion)),
  52536. this.lastPosition.copy(this.object.position),
  52537. this.object.dispatchEvent(iV),
  52538. !0)
  52539. );
  52540. }
  52541. updateFollowArms() {
  52542. this.objectToTarget.copy(this.objectToTarget0), this.targetToCamera.copy(this.targetToCamera0);
  52543. let e = Br.setFromAxisAngle(
  52544. zr,
  52545. this.cameraYAxis === 'Limit' && this.orientMode !== 'radial'
  52546. ? it.clamp(this.euler.y - this.euler0.y, this.minAzimuthAngleRel, this.maxAzimuthAngleRel)
  52547. : this.euler.y - this.euler0.y
  52548. );
  52549. (this.cameraYAxis !== 'Locked' || this.orientMode === 'radial') && this.objectToTarget.applyQuaternion(e);
  52550. let t;
  52551. this.cameraXAxis === 'Limit'
  52552. ? (t = it.clamp(
  52553. this.euler.x,
  52554. -this.maxPolarAngle + this.cameraPolarOffset + 1e-6,
  52555. -this.minPolarAngle + this.cameraPolarOffset - 1e-6
  52556. ))
  52557. : (t = it.clamp(this.euler.x, -this.PI_2 + this.cameraPolarOffset + 1e-6, this.PI_2 + this.cameraPolarOffset - 1e-6));
  52558. let i = Di.copy(this.cameraPolarAxis0);
  52559. (this.cameraYAxis !== 'Locked' || this.orientMode === 'radial') && i.applyQuaternion(e);
  52560. let r = Ns.setFromAxisAngle(i, t);
  52561. this.cameraYAxis !== 'Locked' && this.targetToCamera.applyQuaternion(e),
  52562. this.cameraXAxis !== 'Locked' && this.targetToCamera.applyQuaternion(r);
  52563. }
  52564. groundTiltAdjustment(e) {
  52565. (zr.angleTo(e) * 180) / Math.PI < 15 || (zr.angleTo(e) * 180) / Math.PI > 85 ? Br.identity() : Br.setFromUnitVectors(zr, e),
  52566. this.groundTilt.slerp(Br, 0.06),
  52567. this.groundTiltInv.copy(this.groundTilt).invert();
  52568. }
  52569. collisionAdjustment(e) {
  52570. let t = Nb.set(0, 0, 0);
  52571. this.object.updateMatrix();
  52572. let i = Af.multiplyMatrices(this.object.matrix, this.objXZRotMat)
  52573. .multiply(this.collider.matrix)
  52574. .decompose(Di, Br, Qi)
  52575. .compose(Di, Br, Fb);
  52576. this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach((s) => {
  52577. if (s === this.object || s.isDescendantOf(this.object)) return;
  52578. pr.makeEmpty(), s.updateMatrixWorldSVD();
  52579. let n = s.matrixWorldRigid,
  52580. a = Ub.copy(n).invert(),
  52581. o = QG.copy(Ub).multiply(i);
  52582. xi.copy(this.collider.segment), xi.start.applyMatrix4(o), xi.end.applyMatrix4(o);
  52583. let l = zb.copy(this.object.position).applyMatrix4(a);
  52584. pr.expandByPoint(xi.start),
  52585. pr.expandByPoint(xi.end),
  52586. pr.min.addScalar(-this.collider.radius),
  52587. pr.max.addScalar(this.collider.radius),
  52588. s.boundsTree.shapecast({
  52589. intersectsBounds: (h) => h.intersectsBox(pr),
  52590. intersectsTriangle: (h) => {
  52591. let u = Di,
  52592. c = Qi,
  52593. d = h.closestPointToSegment(xi, u, c);
  52594. if (d < this.collider.radius) {
  52595. let p = this.collider.radius - d,
  52596. f = c.sub(u).normalize(),
  52597. g = ln.copy(l);
  52598. g.addScaledVector(f, p);
  52599. let m = g.applyMatrix4(n).sub(this.object.position);
  52600. t.add(m), xi.start.addScaledVector(f, p), xi.end.addScaledVector(f, p);
  52601. }
  52602. }
  52603. });
  52604. }),
  52605. pr.makeEmpty(),
  52606. xi.copy(this.collider.segment),
  52607. xi.start.applyMatrix4(i),
  52608. xi.end.applyMatrix4(i),
  52609. pr.expandByPoint(xi.start),
  52610. pr.expandByPoint(xi.end),
  52611. pr.min.addScalar(-this.collider.radius),
  52612. pr.max.addScalar(this.collider.radius),
  52613. this.sharedGameControlGlobals.staticMeshBVH?.shapecast({
  52614. intersectsBounds: (s) => s.intersectsBox(pr),
  52615. intersectsTriangle: (s) => {
  52616. let n = Di,
  52617. a = Qi,
  52618. o = s.closestPointToSegment(xi, n, a);
  52619. if (o < this.collider.radius) {
  52620. let l = this.collider.radius - o,
  52621. h = a.sub(n).normalize();
  52622. this.alignToGround && this.groundTiltAdjustment(h),
  52623. t.addScaledVector(h, l),
  52624. xi.start.addScaledVector(h, l),
  52625. xi.end.addScaledVector(h, l);
  52626. }
  52627. }
  52628. }),
  52629. (this.onObject = Math.abs(t.y) > Math.abs(e * this.velocity.y * 0.25)),
  52630. this.onObject && this.dispatchStopEvent('jump');
  52631. let r = Math.max(0, t.length() - 1e-5);
  52632. t.normalize().multiplyScalar(r), this.object.position.add(t);
  52633. }
  52634. },
  52635. o2 = rg;
  52636. o2.isLocked = !1;
  52637. var Sf = { type: 'change' },
  52638. Gb = { type: 'changeZoom' },
  52639. rV = { type: 'changePan' },
  52640. ro = { type: 'start' },
  52641. so = { type: 'end', changed: !0 },
  52642. sV = { type: 'end', changed: !1 },
  52643. Mf = new ct(),
  52644. Vb = new G(),
  52645. nV = 2 * Math.PI,
  52646. aV = 1e-8,
  52647. oV = 0.01,
  52648. Ef = new E(),
  52649. qc = new G(),
  52650. Cf = new E(),
  52651. Yc = new ct(),
  52652. Hb = new ve(),
  52653. lV = { type: 'requestRender' },
  52654. l2 = class extends Vi {
  52655. constructor(e, t, i = { isPlayMode: !1, isExport: !1 }) {
  52656. super(),
  52657. (this.object = e),
  52658. (this.domElement = t),
  52659. (this.options = i),
  52660. (this.enabled = !0),
  52661. (this.useKeyEvents = !0),
  52662. (this.enableDamping = !1),
  52663. (this.enableZoom = !0),
  52664. (this.enableRotate = !0),
  52665. (this.enablePan = !0),
  52666. (this.autoRotate = !1),
  52667. (this.rotationLimitsMode = 0),
  52668. (this.panLimitsMode = 0),
  52669. (this.rotationSoftLimit = 2),
  52670. (this.panSoftLimit = 2),
  52671. (this.hoverRotatePanMode = 0),
  52672. (this.zoomLimitsEnabled = !1),
  52673. (this.mouseButtons = [0, 5]),
  52674. (this.mouseButtonsPlay = [3, 4, 5]),
  52675. (this.touches = [null, hr.DOLLY_ROTATE, hr.PAN]),
  52676. (this.offset = new E()),
  52677. (this.eye = new E()),
  52678. (this.lastPosition = new E()),
  52679. (this.lastQuaternion = new ct()),
  52680. (this.current = new G()),
  52681. (this.overShoot = new G()),
  52682. (this.overRatio = new G()),
  52683. (this.spherical = new Ey()),
  52684. (this.sphericalDelta = new Ey()),
  52685. (this.panOffset = new E()),
  52686. (this.panLeftV = new E()),
  52687. (this.panUpV = new E()),
  52688. (this.panV = new E()),
  52689. (this.rotateStart = new G()),
  52690. (this.rotateEnd = new G()),
  52691. (this.rotateDelta = new G()),
  52692. (this.panStart = new G()),
  52693. (this.panEnd = new G()),
  52694. (this.panDelta = new G()),
  52695. (this.dollyStart = new G()),
  52696. (this.dollyEnd = new G()),
  52697. (this.dollyDelta = new G()),
  52698. (this.rotationRangeFactor = new G()),
  52699. (this.panRangeFactor = new G()),
  52700. (this.state = -1),
  52701. (this.zoomChanged = !1),
  52702. (this.isPointerDown = !1),
  52703. (this.isThetaFlipped = !1),
  52704. (this.prevScale = 0),
  52705. (this.scale = 1),
  52706. (this.gesture = !1),
  52707. (this.timer = -1),
  52708. (this.timerHover = -1),
  52709. (this.minDistance = 0),
  52710. (this.maxDistance = 1 / 0),
  52711. (this.minZoom = 0),
  52712. (this.maxZoom = 1 / 0),
  52713. (this.minPhi = 0),
  52714. (this.maxPhi = Math.PI),
  52715. (this.minTheta = -1 / 0),
  52716. (this.maxTheta = 1 / 0),
  52717. (this.minH = 0),
  52718. (this.maxH = Math.PI),
  52719. (this.minV = -1 / 0),
  52720. (this.maxV = 1 / 0),
  52721. (this.autoRotateClockwise = !0),
  52722. (this.isPanOverShoot = !1),
  52723. (this.isRotateOverShoot = !1),
  52724. (this.resetHoverEffectOnPointerLeave = !1),
  52725. (this.hasChange = !1),
  52726. (this.useWindowEvents = !1),
  52727. (this.isTouchZoom = !0),
  52728. (this.autoRotateSpeed = 2),
  52729. (this.dampingFactor = 0.125),
  52730. (this.zoomSpeed = 2),
  52731. (this.rotateSpeed = 1),
  52732. (this.panSpeed = 1),
  52733. (this.hoverRotatePanStrength = 0.1),
  52734. (this.thetaIsFree = !1),
  52735. (this.phiIsFree = !1),
  52736. (this.needsUpdate = !0),
  52737. (this.update = () => {
  52738. this.object.updateWorldMatrix(!0, !1),
  52739. this.object.matrixWorld.decompose(Cf, Yc, Ef),
  52740. this.offset.copy(Cf).sub(this.target),
  52741. this.spherical.setFromVector3(this.offset),
  52742. this.object.isUpVectorFlipped && ((this.spherical.phi *= -1), (this.spherical.theta -= Math.PI)),
  52743. this.autoRotate &&
  52744. this.state === -1 &&
  52745. this.rotateLeft((this.autoRotateClockwise === !0 ? 1 : -1) * this.getAutoRotationAngle()),
  52746. this.rotationLimitsMode !== 0 &&
  52747. this.applyLimits(
  52748. this.sphericalDelta,
  52749. this.rotationLimitsMode,
  52750. this.rotationSoftLimit,
  52751. this.maxTheta,
  52752. this.minTheta,
  52753. this.maxPhi,
  52754. this.minPhi,
  52755. this.rotationRangeFactor
  52756. ),
  52757. this.rotationLimitsMode !== 2 && (this.spherical.phi += this.sphericalDelta.phi),
  52758. (this.rotationLimitsMode !== 1 || this.autoRotate === !0) && (this.spherical.theta += this.sphericalDelta.theta),
  52759. (this.spherical.radius *= this.scale),
  52760. this.zoomLimitsEnabled &&
  52761. (this.spherical.radius = Math.max(this.minDistance, Math.min(this.maxDistance, this.spherical.radius))),
  52762. this.panLimitsMode !== 0 &&
  52763. (this.target.applyQuaternion(Mf.copy(Yc).invert()),
  52764. this.panOffset.applyQuaternion(Mf),
  52765. this.applyLimits(
  52766. this.panOffset,
  52767. this.panLimitsMode,
  52768. this.panSoftLimit,
  52769. this.maxH,
  52770. this.minH,
  52771. this.maxV,
  52772. this.minV,
  52773. this.panRangeFactor
  52774. ),
  52775. this.target.applyQuaternion(Yc),
  52776. this.panOffset.applyQuaternion(Yc)),
  52777. this.panLimitsMode === 2 && (this.panOffset.y = 0),
  52778. this.panLimitsMode === 1 && (this.panOffset.x = 0),
  52779. this.state === -1 && !this.gesture
  52780. ? (this.panOffset.multiplyScalar(1 - this.dampingFactor), this.target.add(this.panOffset))
  52781. : (this.target.add(this.panOffset), this.panOffset.set(0, 0, 0)),
  52782. this.offset.setFromSpherical(this.spherical),
  52783. Cf.copy(this.target).add(this.offset),
  52784. this.object.position.copy(this.target).add(this.offset),
  52785. this.object.parent && (Hb.copy(this.object.parent.matrixWorld).invert(), this.object.position.applyMatrix4(Hb));
  52786. let r = this.spherical.phi % nV;
  52787. return (
  52788. this.eye.copy(this.offset).normalize(),
  52789. this.object.up.copy(bt.DEFAULT_UP).applyAxisAngle(this.eye, this.object.angleOffsetFromUp),
  52790. (r > 0 && r > Math.PI) || (r < 0 && r > -Math.PI)
  52791. ? (this.object.up.negate(), this.object.lookAt(this.target), (this.object.isUpVectorFlipped = !0))
  52792. : (this.object.lookAt(this.target), (this.object.isUpVectorFlipped = !1)),
  52793. this.state === -1 || this.enableDamping === !0
  52794. ? ((this.sphericalDelta.theta *= 1 - this.dampingFactor), (this.sphericalDelta.phi *= 1 - this.dampingFactor))
  52795. : this.sphericalDelta.set(0, 0, 0),
  52796. (this.scale = 1),
  52797. (this.object.wasMovedByUser = !0),
  52798. this.zoomChanged ||
  52799. this.lastPosition.distanceToSquared(this.object.position) > oV ||
  52800. 8 * (1 - this.lastQuaternion.dot(this.object.quaternion)) > aV
  52801. ? (this.dispatchEvent(Sf),
  52802. this.object.dispatchEvent(lV),
  52803. this.lastPosition.copy(this.object.position),
  52804. this.lastQuaternion.copy(this.object.quaternion),
  52805. (this.zoomChanged = !1),
  52806. !0)
  52807. : ((this.isPanOverShoot = !1),
  52808. (this.isRotateOverShoot = !1),
  52809. this.sphericalDelta.set(0, 0, 0),
  52810. this.panOffset.set(0, 0, 0),
  52811. !1)
  52812. );
  52813. }),
  52814. (this.onPointerDown = (r) => {
  52815. this.enabled !== !1 &&
  52816. (r.pointerType === 'touch' || (r.pointerType === 'pen' && rr) ? this.onPointerDownTouch(r) : this.onPointerDownMouse(r),
  52817. this.state !== -1 &&
  52818. ((this.isPointerDown = !0),
  52819. this.dispatchEvent(ro),
  52820. this.domElement.addEventListener('pointermove', this.onPointerMove),
  52821. this.domElement.addEventListener('pointerup', this.onPointerUp),
  52822. r.stopPropagation(),
  52823. r.pointerType === 'touch' || (r.pointerType === 'pen' && rr) || this.domElement.setPointerCapture(r.pointerId)));
  52824. }),
  52825. (this.onPointerLeave = (r) => {
  52826. this.resetHoverEffectOnPointerLeave && !this.useWindowEvents
  52827. ? (this.hoverRotatePanMode === 1
  52828. ? ((this.sphericalDelta.theta = -this.spherical.theta),
  52829. (this.sphericalDelta.phi = -this.spherical.phi),
  52830. Ef.subVectors(this.position0, this.target0),
  52831. this.spherical.setFromVector3(Ef),
  52832. (this.sphericalDelta.theta += this.spherical.theta),
  52833. (this.sphericalDelta.phi += this.spherical.phi),
  52834. (this.sphericalDelta.theta /= 8),
  52835. (this.sphericalDelta.phi /= 8))
  52836. : this.hoverRotatePanMode === 2 && this.panOffset.subVectors(this.target0, this.target).divideScalar(8),
  52837. this.update())
  52838. : (this.pointerLeaveEvent = r);
  52839. }),
  52840. (this.onPointerEnter = (r) => {
  52841. this.resetHoverEffectOnPointerLeave || this.pointerLeaveEvent === void 0
  52842. ? qc.set(r.clientX - this.domElement.clientWidth / 2, r.clientY - this.domElement.clientHeight / 2)
  52843. : qc.set(r.clientX - this.pointerLeaveEvent.clientX, r.clientY - this.pointerLeaveEvent.clientY),
  52844. this.hoverRotatePanMode === 1
  52845. ? (this.rotateDelta
  52846. .copy(qc)
  52847. .multiplyScalar(this.rotateSpeed * this.hoverRotatePanStrength)
  52848. .rotateAround(Vb, -this.object.angleOffsetFromUp),
  52849. this.rotateLeft((2 * Math.PI * this.rotateDelta.x) / this.domElement.clientHeight),
  52850. this.rotateUp((2 * Math.PI * this.rotateDelta.y) / this.domElement.clientHeight),
  52851. this.rotateStart.set(r.clientX, r.clientY))
  52852. : this.hoverRotatePanMode === 2 &&
  52853. (this.panDelta.copy(qc).multiplyScalar(this.panSpeed * this.hoverRotatePanStrength),
  52854. this.pan(this.panDelta.x, this.panDelta.y),
  52855. this.panStart.set(r.clientX, r.clientY)),
  52856. this.update();
  52857. }),
  52858. (this.onPointerMove = (r) => {
  52859. this.enabled !== !1 &&
  52860. (r.pointerType === 'touch' || (r.pointerType === 'pen' && rr) ? this.onPointerMoveTouch(r) : this.onPointerMoveMouse(r),
  52861. r.stopPropagation());
  52862. }),
  52863. (this.onPointerUp = (r) => {
  52864. (this.isPointerDown = !1),
  52865. Qe.length === 0 &&
  52866. (this.domElement.removeEventListener('pointermove', this.onPointerMove),
  52867. this.domElement.removeEventListener('pointerup', this.onPointerUp)),
  52868. this.hasChange ? this.dispatchEvent(so) : this.dispatchEvent(sV),
  52869. (this.state = -1),
  52870. r &&
  52871. (r.stopPropagation(),
  52872. r.pointerType === 'touch' || (r.pointerType === 'pen' && rr) || this.domElement.releasePointerCapture(r.pointerId));
  52873. }),
  52874. (this.onPointerDownMouse = (r) => {
  52875. let s;
  52876. switch ((this.useKeyEvents ? (s = this.mouseButtons[r.button]) : (s = this.mouseButtonsPlay[r.button]), s)) {
  52877. case 0:
  52878. if (r.altKey === !0 && !r.shiftKey && !Ac(r)) {
  52879. if (this.enableRotate === !1) return;
  52880. this.handleMouseDownRotate(r), (this.state = 0);
  52881. } else if (this.key === ' ') {
  52882. if (this.enablePan === !1) return;
  52883. this.handleMouseDownPan(r), (this.state = 2);
  52884. }
  52885. break;
  52886. case 4:
  52887. if (this.enablePan === !1) return;
  52888. this.handleMouseDownPan(r), (this.state = 2);
  52889. break;
  52890. case 3:
  52891. if (Ac(r) || r.shiftKey) {
  52892. if (this.enablePan === !1) return;
  52893. this.handleMouseDownPan(r), (this.state = 2);
  52894. } else {
  52895. if (this.enableRotate === !1) return;
  52896. this.handleMouseDownRotate(r), (this.state = 0);
  52897. }
  52898. break;
  52899. case 5:
  52900. if (Ac(r) || r.shiftKey) {
  52901. if (this.enableRotate === !1) return;
  52902. this.handleMouseDownRotate(r), (this.state = 0);
  52903. } else {
  52904. if (this.enablePan === !1) return;
  52905. this.handleMouseDownPan(r), (this.state = 2);
  52906. }
  52907. break;
  52908. default:
  52909. this.state = -1;
  52910. }
  52911. }),
  52912. (this.onPointerMoveMouse = (r) => {
  52913. switch (this.state) {
  52914. case 0:
  52915. if (this.enableRotate === !1) return;
  52916. this.handleMouseMoveRotate(r);
  52917. break;
  52918. case 1:
  52919. if (this.enableZoom === !1) return;
  52920. this.handleMouseMoveDolly(r);
  52921. break;
  52922. case 2:
  52923. if (this.enablePan === !1) return;
  52924. this.handleMouseMovePan(r);
  52925. break;
  52926. }
  52927. }),
  52928. (this.onPointerDownTouch = (r) => {
  52929. switch (this.touches[Qe.length - 1]) {
  52930. case hr.ROTATE:
  52931. if (this.enableRotate === !1) {
  52932. this.state = -1;
  52933. return;
  52934. }
  52935. this.handleTouchStartRotate(), (this.state = 3);
  52936. break;
  52937. case hr.PAN:
  52938. if (this.enablePan === !1) {
  52939. this.state = -1;
  52940. return;
  52941. }
  52942. this.handleTouchStartPan(), (this.state = 4);
  52943. break;
  52944. case hr.DOLLY_PAN:
  52945. if ((this.enableZoom === !1 && this.enablePan === !1) || this.isTouchZoom === !1) return;
  52946. this.handleTouchStartDollyPan(), (this.state = 5);
  52947. break;
  52948. case hr.DOLLY_ROTATE:
  52949. if ((this.enableZoom === !1 && this.enableRotate === !1) || this.isTouchZoom === !1) return;
  52950. this.handleTouchStartDollyRotate(), (this.state = 6);
  52951. break;
  52952. default:
  52953. this.state = -1;
  52954. }
  52955. }),
  52956. (this.onPointerMoveTouch = (r) => {
  52957. switch (this.state) {
  52958. case 3:
  52959. if (this.enableRotate === !1) return;
  52960. this.handleTouchMoveRotate(r), this.update();
  52961. break;
  52962. case 4:
  52963. if (this.enablePan === !1) return;
  52964. this.handleTouchMovePan(r), this.update();
  52965. break;
  52966. case 5:
  52967. if ((this.enableZoom === !1 && this.enablePan === !1) || this.isTouchZoom === !1) return;
  52968. this.handleTouchMoveDollyPan(r), this.update();
  52969. break;
  52970. case 6:
  52971. if ((this.enableZoom === !1 && this.enableRotate === !1) || this.isTouchZoom === !1) return;
  52972. this.handleTouchMoveDollyRotate(r), this.update();
  52973. break;
  52974. default:
  52975. this.state = -1;
  52976. }
  52977. }),
  52978. (this.dispatchEndDebounced = __(() => this.dispatchEvent(so), 33)),
  52979. (this.onMouseWheel = (r) => {
  52980. this.enabled === !1 ||
  52981. (this.enableZoom === !1 && this.enablePan === !1) ||
  52982. (this.options.isExport === !1 &&
  52983. this.domElement.clientHeight === document.body.clientHeight &&
  52984. this.domElement.clientWidth === document.body.clientWidth &&
  52985. r.preventDefault(),
  52986. this.dispatchEvent(ro),
  52987. this.handleMouseWheel(r),
  52988. this.dispatchEndDebounced());
  52989. }),
  52990. (this.onGesture = (r) => {
  52991. if (this.enabled !== !1)
  52992. if ((r.preventDefault(), r.type === 'gesturechange')) {
  52993. if (this.enableZoom === !1 || this.isTouchZoom === !1) return;
  52994. this.dispatchEvent(ro),
  52995. r.scale > this.prevScale
  52996. ? this.dollyIn(this.getZoomScale())
  52997. : r.scale < this.prevScale && this.dollyOut(this.getZoomScale()),
  52998. (this.prevScale = r.scale),
  52999. this.update();
  53000. } else this.dispatchEvent(so);
  53001. }),
  53002. (this.onContextMenu = (r) => {
  53003. this.enabled !== !1 && r.preventDefault();
  53004. }),
  53005. (this.onTouchEnd = (r) => {
  53006. r.preventDefault();
  53007. }),
  53008. (this.onKeyDown = (r) => {
  53009. this.enabled !== !1 && ((this.key = r.key), r.key === ' ' && this.dispatchEvent(ro));
  53010. }),
  53011. (this.onKeyUp = (r) => {
  53012. this.enabled !== !1 &&
  53013. ((this.key = void 0), this.state !== -1 && this.onPointerUp(Qe[0]), r.key === ' ' && this.dispatchEvent(so));
  53014. }),
  53015. (this.onPointerHover = (r) => {
  53016. r.pointerType !== 'mouse' ||
  53017. this.enabled === !1 ||
  53018. this.state !== -1 ||
  53019. (this.hoverRotatePanMode === 2 && this.isPanOverShoot) ||
  53020. (this.hoverRotatePanMode === 1 && this.isRotateOverShoot) ||
  53021. ((this.isPointerDown = !0),
  53022. this.hoverRotatePanMode === 2
  53023. ? this.handleMouseMovePan(r, this.hoverRotatePanStrength)
  53024. : this.hoverRotatePanMode === 1 && this.handleMouseMoveRotate(r, this.hoverRotatePanStrength));
  53025. }),
  53026. (this.onBeginState = () => {
  53027. (this.enabled = !1), (this.needsUpdate = !1);
  53028. }),
  53029. (this.onCompleteState = (r) => {
  53030. (r.isfromEntity && this.options.isPlayMode) ||
  53031. ((this.enabled = !0), (this.needsUpdate = !0), this.object.updateUp(), this.object.getTarget(this.target));
  53032. }),
  53033. (this.target = this.object.getTarget()),
  53034. (this.target0 = this.target.clone()),
  53035. (this.position0 = this.object.position.clone()),
  53036. (this.zoom0 = this.object.zoom),
  53037. (this.quat0 = this.object.quaternion.clone()),
  53038. (this.isUpVectorFlipped0 = this.object.isUpVectorFlipped),
  53039. this.offset.copy(this.object.position).sub(this.target),
  53040. this.spherical.setFromVector3(this.offset),
  53041. this.object.isUpVectorFlipped && ((this.spherical.phi *= -1), (this.spherical.theta -= Math.PI)),
  53042. this.addEventListenersToCamera();
  53043. }
  53044. dispatchEvent(e) {
  53045. e.type === 'start' ? (this.hasChange = !1) : (this.hasChange = !0), super.dispatchEvent(e);
  53046. }
  53047. addEventListenersToCamera() {
  53048. this.object.addEventListener('beginState', this.onBeginState), this.object.addEventListener('completeState', this.onCompleteState);
  53049. }
  53050. removeEventListenersFromCamera() {
  53051. this.object.removeEventListener('beginState', this.onBeginState),
  53052. this.object.removeEventListener('completeState', this.onCompleteState);
  53053. }
  53054. reset() {
  53055. this.object.quaternion.copy(this.quat0),
  53056. this.target.copy(this.target0),
  53057. this.object.position.copy(this.position0),
  53058. (this.object.zoom = this.zoom0),
  53059. (this.object.isUpVectorFlipped = this.isUpVectorFlipped0),
  53060. this.object.updateProjectionMatrix(),
  53061. this.dispatchEvent(Sf),
  53062. (this.state = -1),
  53063. (this.pointerLeaveEvent = void 0);
  53064. }
  53065. resetTo(e, t, i, r, s = !1) {
  53066. this.object.quaternion.copy(r),
  53067. this.target.copy(e),
  53068. this.object.position.copy(t),
  53069. (this.object.zoom = i),
  53070. (this.object.isUpVectorFlipped = s),
  53071. this.object.updateProjectionMatrix(),
  53072. this.dispatchEvent(Sf),
  53073. this.update(),
  53074. (this.state = -1);
  53075. }
  53076. updateUseWindowEvents(e) {
  53077. if (
  53078. (window.removeEventListener('pointermove', this.onPointerHover),
  53079. this.domElement.removeEventListener('pointermove', this.onPointerHover),
  53080. (this.useWindowEvents = e),
  53081. this.hoverRotatePanMode !== 0 &&
  53082. (this.useWindowEvents
  53083. ? window.addEventListener('pointermove', this.onPointerHover)
  53084. : this.domElement.addEventListener('pointermove', this.onPointerHover)),
  53085. this.domElement.removeEventListener('pointerleave', this.onPointerLeave),
  53086. this.domElement.removeEventListener('pointerenter', this.onPointerEnter),
  53087. window.removeEventListener('pointerleave', this.onPointerLeave),
  53088. window.removeEventListener('pointerenter', this.onPointerEnter),
  53089. this.hoverRotatePanMode !== 0 && !this.useWindowEvents)
  53090. ) {
  53091. let t = this.useWindowEvents ? window : this.domElement;
  53092. t.addEventListener('pointerleave', this.onPointerLeave), t.addEventListener('pointerenter', this.onPointerEnter);
  53093. }
  53094. }
  53095. fromJSON(e, t) {
  53096. this.setEnableDampingSpeed(e.enableDamping),
  53097. (this.enablePan = e.enablePan),
  53098. (this.enableZoom = e.enableZoom),
  53099. (this.enableRotate = e.enableRotate),
  53100. (this.rotationLimitsMode = e.rotationLimitsMode),
  53101. (this.thetaIsFree =
  53102. e.rotationHorizontalOffset.min === e.rotationHorizontalOffset.max && e.rotationHorizontalOffset.min === Math.PI),
  53103. (this.phiIsFree = e.rotationVerticalOffset.min === e.rotationVerticalOffset.max && e.rotationVerticalOffset.min === Math.PI),
  53104. (this.panLimitsMode = e.panLimitsMode),
  53105. (this.panSoftLimit = e.panSoftLimit),
  53106. (this.rotationSoftLimit = e.rotationSoftLimit),
  53107. (this.hoverRotatePanMode = e.hoverRotatePanMode),
  53108. (this.useWindowEvents = t === 'window'),
  53109. this.hoverRotatePanMode !== 0 &&
  53110. (this.useWindowEvents
  53111. ? window.addEventListener('pointermove', this.onPointerHover)
  53112. : this.domElement.addEventListener('pointermove', this.onPointerHover));
  53113. let i = e.hoverRotatePanStrength / 100;
  53114. (this.hoverRotatePanStrength = i ** 2),
  53115. (this.zoomLimitsEnabled = e.zoomLimitsEnabled),
  53116. (this.minZoom = e.zoomLimits.min),
  53117. (this.maxZoom = Math.max(e.zoomLimits.min, e.zoomLimits.max)),
  53118. (this.minDistance = 1e3 / e.zoomLimits.max),
  53119. (this.maxDistance = Math.max(this.minDistance, 1e3 / e.zoomLimits.min)),
  53120. (this.autoRotate = e.autoRotate),
  53121. (this.autoRotateSpeed = e.autoRotateSpeed),
  53122. (this.autoRotateClockwise = e.autoRotateClockwise);
  53123. let r = this.object.getTarget().applyQuaternion(Mf.copy(this.object.quaternion).invert());
  53124. (this.minV = -e.panVerticalOffset.min + r.y),
  53125. (this.maxV = e.panVerticalOffset.max + r.y),
  53126. (this.minH = -e.panHorizontalOffset.min + r.x),
  53127. (this.maxH = e.panHorizontalOffset.max + r.x),
  53128. this.panRangeFactor.set(this.maxH - this.minH, this.maxV - this.minV).divideScalar(2),
  53129. this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),
  53130. (this.minPhi = ts(this.spherical.phi - e.rotationVerticalOffset.min)),
  53131. (this.maxPhi = ts(this.spherical.phi + e.rotationVerticalOffset.max)),
  53132. (this.minTheta = ts(ts(this.spherical.theta) - e.rotationHorizontalOffset.min)),
  53133. (this.maxTheta = ts(ts(this.spherical.theta) + e.rotationHorizontalOffset.max)),
  53134. (this.isThetaFlipped = this.minTheta > this.maxTheta),
  53135. e.orbitTouches === 1 && (this.touches[0] = hr.ROTATE),
  53136. e.panTouches === 1 && (this.touches[0] = hr.PAN),
  53137. e.orbitTouches === 2 && (this.touches[1] = hr.DOLLY_ROTATE),
  53138. e.panTouches === 2 && (this.touches[1] = hr.DOLLY_PAN),
  53139. e.orbitTouches === 3 && (this.touches[2] = hr.ROTATE),
  53140. e.panTouches === 3 && (this.touches[2] = hr.PAN),
  53141. (this.isTouchZoom = e.isTouchZoom),
  53142. (this.resetHoverEffectOnPointerLeave = e.resetHoverEffectOnPointerLeave ?? !1);
  53143. }
  53144. connect() {
  53145. if (
  53146. (this.domElement.addEventListener('contextmenu', this.onContextMenu),
  53147. this.domElement.addEventListener('pointerdown', this.onPointerDown),
  53148. this.domElement.addEventListener('wheel', this.onMouseWheel),
  53149. window.addEventListener('keydown', this.onKeyDown, !1),
  53150. window.addEventListener('keyup', this.onKeyUp, !1),
  53151. Mm ||
  53152. (this.domElement.addEventListener('gesturestart', this.onGesture),
  53153. this.domElement.addEventListener('gesturechange', this.onGesture),
  53154. this.domElement.addEventListener('gestureend', this.onGesture)),
  53155. this.domElement.addEventListener('touchend', this.onTouchEnd),
  53156. this.hoverRotatePanMode !== 0 && !this.useWindowEvents)
  53157. ) {
  53158. let e = this.useWindowEvents ? window : this.domElement;
  53159. e.addEventListener('pointerleave', this.onPointerLeave), e.addEventListener('pointerenter', this.onPointerEnter);
  53160. }
  53161. this.pointerLeaveEvent = void 0;
  53162. }
  53163. dispose() {
  53164. this.removeEventListenersFromCamera(),
  53165. this.domElement.removeEventListener('contextmenu', this.onContextMenu),
  53166. this.domElement.removeEventListener('pointerdown', this.onPointerDown),
  53167. this.domElement.removeEventListener('wheel', this.onMouseWheel),
  53168. window.removeEventListener('keydown', this.onKeyDown, !1),
  53169. window.removeEventListener('keyup', this.onKeyUp, !1),
  53170. this.domElement.removeEventListener('pointermove', this.onPointerHover),
  53171. window.removeEventListener('pointermove', this.onPointerHover),
  53172. Mm ||
  53173. (this.domElement.removeEventListener('gesturestart', this.onGesture),
  53174. this.domElement.removeEventListener('gesturechange', this.onGesture),
  53175. this.domElement.removeEventListener('gestureend', this.onGesture)),
  53176. this.domElement.removeEventListener('touchend', this.onTouchEnd),
  53177. this.domElement.removeEventListener('pointerleave', this.onPointerLeave),
  53178. this.domElement.removeEventListener('pointerenter', this.onPointerEnter),
  53179. window.removeEventListener('pointerleave', this.onPointerLeave),
  53180. window.removeEventListener('pointerenter', this.onPointerEnter),
  53181. this.domElement.removeEventListener('pointermove', this.onPointerMove),
  53182. this.domElement.removeEventListener('pointerup', this.onPointerUp);
  53183. }
  53184. applyLimits(e, t, i, r, s, n, a, o) {
  53185. this.overShoot.set(0, 0);
  53186. let l, h, u;
  53187. e instanceof E
  53188. ? ((l = e.x), (h = e.y), this.current.set(this.target.x, this.target.y), (u = !0))
  53189. : ((l = e.theta), (h = e.phi), this.current.set(ts(this.spherical.theta), ts(this.spherical.phi)), (u = !1)),
  53190. i === 0 && ((this.current.x += l), (this.current.y += h)),
  53191. (t === 3 || t === 2) &&
  53192. (!u && this.isThetaFlipped
  53193. ? this.current.x > r && this.current.x < 0
  53194. ? (this.overShoot.x = r - this.current.x)
  53195. : this.current.x < s && this.current.x > 0 && (this.overShoot.x = s - this.current.x)
  53196. : this.current.x > r
  53197. ? (this.overShoot.x = r - this.current.x)
  53198. : this.current.x < s && (this.overShoot.x = s - this.current.x)),
  53199. (t === 3 || t === 1) &&
  53200. (this.current.y > n ? (this.overShoot.y = n - this.current.y) : this.current.y < a && (this.overShoot.y = a - this.current.y)),
  53201. u || ((this.overShoot.x = ts(this.overShoot.x)), (this.overShoot.y = ts(this.overShoot.y))),
  53202. i !== 0
  53203. ? (this.overRatio.copy(this.overShoot).divide(o),
  53204. (this.overRatio.x = Math.min(Math.abs(this.overRatio.x), 1)),
  53205. (this.overRatio.y = Math.min(Math.abs(this.overRatio.y), 1)),
  53206. i === 1 && ((this.overRatio.x = Wb(Math.abs(this.overRatio.x))), (this.overRatio.y = Wb(Math.abs(this.overRatio.y)))),
  53207. this.isPointerDown || i === 1
  53208. ? i === 2 && ((this.overRatio.x > 0.9 && !this.thetaIsFree) || (this.overRatio.y > 0.9 && !this.phiIsFree))
  53209. ? (this.isPointerDown = !1)
  53210. : (l * this.overShoot.x < 0 && !this.thetaIsFree && (l *= 1 - this.overRatio.x),
  53211. h * this.overShoot.y < 0 && !this.phiIsFree && (h *= 1 - this.overRatio.y))
  53212. : i === 2 &&
  53213. ((!u && ((this.overRatio.x > 0.002 && !this.thetaIsFree) || (this.overRatio.y > 0.002 && !this.phiIsFree))) ||
  53214. (u && (Math.abs(this.overShoot.x) > 2 || Math.abs(this.overShoot.y) > 2))
  53215. ? (this.thetaIsFree || (l = this.overShoot.x * 0.05),
  53216. this.phiIsFree || (h = this.overShoot.y * 0.05),
  53217. u ? (this.isPanOverShoot = !0) : (this.isRotateOverShoot = !0))
  53218. : u
  53219. ? (this.isPanOverShoot = !1)
  53220. : (this.isRotateOverShoot = !1)))
  53221. : ((l += this.overShoot.x), (h += this.overShoot.y)),
  53222. e instanceof E ? ((e.x = l), (e.y = h)) : (this.thetaIsFree || (e.theta = l), this.phiIsFree || (e.phi = h));
  53223. }
  53224. setEnableDampingSpeed(e) {
  53225. (this.enableDamping = e), (this.rotateSpeed = e === !0 ? 0.2 : 1);
  53226. }
  53227. stopDamping() {
  53228. (this.sphericalDelta.theta = 0), (this.sphericalDelta.phi = 0);
  53229. }
  53230. getAutoRotationAngle() {
  53231. return ((2 * Math.PI) / 60 / 60) * this.autoRotateSpeed;
  53232. }
  53233. getZoomScale() {
  53234. return Math.pow(0.95, this.zoomSpeed);
  53235. }
  53236. rotateLeft(e) {
  53237. this.sphericalDelta.theta -= e;
  53238. }
  53239. rotateUp(e) {
  53240. this.sphericalDelta.phi -= e;
  53241. }
  53242. panLeft(e, t) {
  53243. this.panLeftV.setFromMatrixColumn(t, 0), this.panLeftV.multiplyScalar(-e), this.panOffset.add(this.panLeftV);
  53244. }
  53245. panUp(e, t) {
  53246. this.panUpV.setFromMatrixColumn(t, 1), this.panUpV.multiplyScalar(e), this.panOffset.add(this.panUpV);
  53247. }
  53248. pan(e, t) {
  53249. let i = this.domElement;
  53250. if (i && this.object.isPerspectiveCamera) {
  53251. let r = this.object.position;
  53252. this.panV.copy(r).sub(this.target);
  53253. let s = this.panV.length();
  53254. (s *= Math.tan(((this.object.fov / 2) * Math.PI) / 180)),
  53255. this.panLeft((2 * e * s) / i.clientHeight, this.object.matrixWorld),
  53256. this.panUp((2 * t * s) / i.clientHeight, this.object.matrixWorld);
  53257. } else
  53258. i &&
  53259. this.object.isOrthographicCamera &&
  53260. (this.panLeft((e * (this.object.right - this.object.left)) / this.object.zoom / i.clientWidth, this.object.matrixWorld),
  53261. this.panUp((t * (this.object.top - this.object.bottom)) / this.object.zoom / i.clientHeight, this.object.matrixWorld));
  53262. this.dispatchEvent(rV);
  53263. }
  53264. dollyOut(e) {
  53265. this.object.isPerspectiveCamera
  53266. ? (this.scale /= e)
  53267. : this.object.isOrthographicCamera &&
  53268. ((this.object.zoom *= e),
  53269. this.zoomLimitsEnabled && (this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom))),
  53270. this.object.updateProjectionMatrix(),
  53271. (this.zoomChanged = !0)),
  53272. this.dispatchEvent(Gb);
  53273. }
  53274. dollyIn(e) {
  53275. this.object.isPerspectiveCamera
  53276. ? (this.scale *= e)
  53277. : this.object.isOrthographicCamera &&
  53278. ((this.object.zoom /= e),
  53279. this.zoomLimitsEnabled && (this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom))),
  53280. this.object.updateProjectionMatrix(),
  53281. (this.zoomChanged = !0)),
  53282. this.dispatchEvent(Gb);
  53283. }
  53284. zoomOut(e = this.getZoomScale()) {
  53285. this.dispatchEvent(ro), this.dollyOut(e), this.dispatchEvent(so);
  53286. }
  53287. zoomIn(e = this.getZoomScale()) {
  53288. this.dispatchEvent(ro), this.dollyIn(e), this.dispatchEvent(so);
  53289. }
  53290. handleMouseDownRotate(e) {
  53291. this.rotateStart.set(e.clientX, e.clientY);
  53292. }
  53293. handleMouseDownDolly(e) {
  53294. this.dollyStart.set(e.clientX, e.clientY);
  53295. }
  53296. handleMouseDownPan(e) {
  53297. this.panStart.set(e.clientX, e.clientY);
  53298. }
  53299. handleMouseMoveRotate(e, t = 1) {
  53300. e.movementX !== void 0
  53301. ? this.rotateDelta.set(e.movementX, e.movementY)
  53302. : (this.rotateEnd.set(e.clientX, e.clientY),
  53303. this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart),
  53304. this.rotateStart.copy(this.rotateEnd)),
  53305. this.rotateDelta.multiplyScalar(this.rotateSpeed * t).rotateAround(Vb, -this.object.angleOffsetFromUp);
  53306. let i = this.domElement,
  53307. r = this.useWindowEvents ? window.innerHeight : i.clientHeight,
  53308. s = (2 * Math.PI * this.rotateDelta.x) / r,
  53309. n = (2 * Math.PI * this.rotateDelta.y) / r;
  53310. this.rotateLeft(s), this.rotateUp(n), this.update();
  53311. }
  53312. handleMouseMoveDolly(e) {
  53313. this.dollyEnd.set(e.clientX, e.clientY),
  53314. this.dollyDelta.subVectors(this.dollyEnd, this.dollyStart),
  53315. this.dollyDelta.y > 0 ? this.dollyOut(this.getZoomScale()) : this.dollyDelta.y < 0 && this.dollyIn(this.getZoomScale()),
  53316. this.dollyStart.copy(this.dollyEnd),
  53317. this.update();
  53318. }
  53319. handleMouseMovePan(e, t = 1) {
  53320. e.movementX !== void 0
  53321. ? this.panDelta.set(e.movementX, e.movementY)
  53322. : (this.panEnd.set(e.clientX, e.clientY), this.panDelta.subVectors(this.panEnd, this.panStart), this.panStart.copy(this.panEnd)),
  53323. this.panDelta.multiplyScalar(this.panSpeed * t),
  53324. this.pan(this.panDelta.x, this.panDelta.y),
  53325. this.update();
  53326. }
  53327. handleMouseWheel(e) {
  53328. if ($N === !1 && Ac(e) === !1 && hV(e) === !0) {
  53329. if (this.enablePan === !1) return;
  53330. this.gesture
  53331. ? (this.panDelta.set(-e.deltaX, -e.deltaY).multiplyScalar(this.panSpeed),
  53332. (this.panDelta.x = Math.min(Math.abs(this.panDelta.x), 100) * (this.panDelta.x < 0 ? -1 : 1)),
  53333. (this.panDelta.y = Math.min(Math.abs(this.panDelta.y), 100) * (this.panDelta.y < 0 ? -1 : 1)),
  53334. e.altKey
  53335. ? this.pan(0, this.panDelta.y)
  53336. : e.shiftKey
  53337. ? this.pan(this.panDelta.x, 0)
  53338. : this.pan(this.panDelta.x, this.panDelta.y),
  53339. this.update())
  53340. : ((this.gesture = !0), (this.isPointerDown = !0)),
  53341. window.clearTimeout(this.timer),
  53342. (this.timer = window.setTimeout(() => {
  53343. (this.gesture = !1), (this.isPointerDown = !1);
  53344. }, 30));
  53345. } else {
  53346. if (this.enableZoom === !1) return;
  53347. e.deltaY === 0
  53348. ? e.deltaX < 0
  53349. ? this.dollyIn(this.getZoomScale())
  53350. : e.deltaX > 0 && this.dollyOut(this.getZoomScale())
  53351. : e.deltaY < 0
  53352. ? this.dollyIn(this.getZoomScale())
  53353. : e.deltaY > 0 && this.dollyOut(this.getZoomScale()),
  53354. this.update(),
  53355. (this.gesture = !1),
  53356. (this.isPointerDown = !1);
  53357. }
  53358. }
  53359. handleTouchStartRotate() {
  53360. if (Qe.length === 2) {
  53361. let e = 0.5 * (Qe[0].pageX + Qe[1].pageX),
  53362. t = 0.5 * (Qe[0].pageY + Qe[1].pageY);
  53363. this.rotateStart.set(e, t);
  53364. } else this.rotateStart.set(Qe[0].pageX, Qe[0].pageY);
  53365. }
  53366. handleTouchStartPan() {
  53367. if (Qe.length === 2) {
  53368. let e = 0.5 * (Qe[0].pageX + Qe[1].pageX),
  53369. t = 0.5 * (Qe[0].pageY + Qe[1].pageY);
  53370. this.panStart.set(e, t);
  53371. } else this.panStart.set(Qe[0].pageX, Qe[0].pageY);
  53372. }
  53373. handleTouchStartDolly() {
  53374. let e = Qe[0].pageX - Qe[1].pageX,
  53375. t = Qe[0].pageY - Qe[1].pageY,
  53376. i = Math.sqrt(e * e + t * t);
  53377. this.dollyStart.set(0, i);
  53378. }
  53379. handleTouchStartDollyPan() {
  53380. this.enableZoom && this.handleTouchStartDolly(), this.enablePan && this.handleTouchStartPan();
  53381. }
  53382. handleTouchStartDollyRotate() {
  53383. this.enableZoom && this.handleTouchStartDolly(), this.enableRotate && this.handleTouchStartRotate();
  53384. }
  53385. handleTouchMoveRotate(e) {
  53386. if (Qe.length === 2) {
  53387. let i = Np(e),
  53388. r = 0.5 * (e.pageX + i.x),
  53389. s = 0.5 * (e.pageY + i.y);
  53390. this.rotateEnd.set(r, s);
  53391. } else {
  53392. if (e.pointerId !== Qe[0].pointerId) return;
  53393. this.rotateEnd.set(e.pageX, e.pageY);
  53394. }
  53395. this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart).multiplyScalar(this.rotateSpeed);
  53396. let t = this.domElement;
  53397. t &&
  53398. (this.rotateLeft((2 * Math.PI * this.rotateDelta.x) / t.clientHeight),
  53399. this.rotateUp((2 * Math.PI * this.rotateDelta.y) / t.clientHeight)),
  53400. this.rotateStart.copy(this.rotateEnd);
  53401. }
  53402. handleTouchMovePan(e) {
  53403. if (Qe.length === 2) {
  53404. let t = Np(e),
  53405. i = 0.5 * (e.pageX + t.x),
  53406. r = 0.5 * (e.pageY + t.y);
  53407. this.panEnd.set(i, r);
  53408. } else {
  53409. if (e.pointerId !== Qe[0].pointerId) return;
  53410. this.panEnd.set(e.pageX, e.pageY);
  53411. }
  53412. this.panDelta.subVectors(this.panEnd, this.panStart).multiplyScalar(this.panSpeed),
  53413. this.pan(this.panDelta.x, this.panDelta.y),
  53414. this.panStart.copy(this.panEnd);
  53415. }
  53416. handleTouchMoveDolly(e) {
  53417. let t = Np(e),
  53418. i = e.pageX - t.x,
  53419. r = e.pageY - t.y,
  53420. s = Math.sqrt(i * i + r * r);
  53421. this.dollyEnd.set(0, s),
  53422. this.dollyDelta.set(0, Math.pow(this.dollyEnd.y / this.dollyStart.y, this.zoomSpeed)),
  53423. this.dollyOut(this.dollyDelta.y),
  53424. this.dollyStart.copy(this.dollyEnd);
  53425. }
  53426. handleTouchMoveDollyPan(e) {
  53427. this.enableZoom && this.handleTouchMoveDolly(e), this.enablePan && this.handleTouchMovePan(e);
  53428. }
  53429. handleTouchMoveDollyRotate(e) {
  53430. this.enableZoom && this.handleTouchMoveDolly(e), this.enableRotate && this.handleTouchMoveRotate(e);
  53431. }
  53432. };
  53433. function ts(e) {
  53434. let t = Math.PI * 2;
  53435. for (; e <= -Math.PI; ) e += t;
  53436. for (; e > Math.PI; ) e -= t;
  53437. return e;
  53438. }
  53439. function Wb(e) {
  53440. return 1 - Math.pow(1 - e, 4);
  53441. }
  53442. function hV(e) {
  53443. return e.wheelDeltaY === 0 || e.deltaY === 0
  53444. ? Su && e.shiftKey && Math.abs(e.wheelDeltaX) >= 120
  53445. ? !1
  53446. : e.wheelDeltaX
  53447. ? e.wheelDeltaX === -3 * e.deltaX
  53448. : e.deltaMode === 0
  53449. : e.wheelDeltaY
  53450. ? e.wheelDeltaY === -3 * e.deltaY
  53451. : e.deltaMode === 0;
  53452. }
  53453. var Tf = new WeakMap(),
  53454. cV = class extends bg {
  53455. constructor(e) {
  53456. super(e),
  53457. (this.decoderPath = ''),
  53458. (this.decoderConfig = {}),
  53459. (this.decoderBinary = null),
  53460. (this.decoderPending = null),
  53461. (this.workerLimit = 4),
  53462. (this.workerPool = []),
  53463. (this.workerNextTaskID = 1),
  53464. (this.workerSourceURL = ''),
  53465. (this.defaultAttributeIDs = { position: 'POSITION', normal: 'NORMAL', color: 'COLOR', uv: 'TEX_COORD' }),
  53466. (this.defaultAttributeTypes = { position: 'Float32Array', normal: 'Float32Array', color: 'Float32Array', uv: 'Float32Array' });
  53467. }
  53468. setDecoderPath(e) {
  53469. return (this.decoderPath = e), this;
  53470. }
  53471. setDecoderConfig(e) {
  53472. return (this.decoderConfig = e), this;
  53473. }
  53474. setWorkerLimit(e) {
  53475. return (this.workerLimit = e), this;
  53476. }
  53477. load(e, t, i, r) {
  53478. let s = new Xf(this.manager);
  53479. s.setPath(this.path),
  53480. s.setResponseType('arraybuffer'),
  53481. s.setRequestHeader(this.requestHeader),
  53482. s.setWithCredentials(this.withCredentials),
  53483. s.load(
  53484. e,
  53485. (n) => {
  53486. this.decodeDracoFile(n, t).catch(r);
  53487. },
  53488. i,
  53489. r
  53490. );
  53491. }
  53492. decodeDracoFile(e, t, i, r) {
  53493. let s = { attributeIDs: i || this.defaultAttributeIDs, attributeTypes: r || this.defaultAttributeTypes, useUniqueIDs: !!i };
  53494. return this.decodeGeometry(e, s).then(t);
  53495. }
  53496. decodeGeometry(e, t) {
  53497. let i = JSON.stringify(t);
  53498. if (Tf.has(e)) {
  53499. let o = Tf.get(e);
  53500. if (o.key === i) return o.promise;
  53501. if (e.byteLength === 0)
  53502. throw new Error('THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.');
  53503. }
  53504. let r,
  53505. s = this.workerNextTaskID++,
  53506. n = e.byteLength,
  53507. a = this._getWorker(s, n)
  53508. .then(
  53509. (o) => (
  53510. (r = o),
  53511. new Promise((l, h) => {
  53512. (r._callbacks[s] = { resolve: l, reject: h }), r.postMessage({ type: 'decode', id: s, taskConfig: t, buffer: e }, [e]);
  53513. })
  53514. )
  53515. )
  53516. .then((o) => this._createGeometry(o.geometry));
  53517. return (
  53518. a
  53519. .catch(() => !0)
  53520. .then(() => {
  53521. r && s && this._releaseTask(r, s);
  53522. }),
  53523. Tf.set(e, { key: i, promise: a }),
  53524. a
  53525. );
  53526. }
  53527. _createGeometry(e) {
  53528. let t = new Ve();
  53529. e.index && t.setIndex(new Xe(e.index.array, 1));
  53530. for (let i = 0; i < e.attributes.length; i++) {
  53531. let r = e.attributes[i],
  53532. s = r.name,
  53533. n = r.array,
  53534. a = r.itemSize;
  53535. t.setAttribute(s, new Xe(n, a));
  53536. }
  53537. return t;
  53538. }
  53539. _loadLibrary(e, t) {
  53540. let i = new Xf(this.manager);
  53541. return (
  53542. i.setPath(this.decoderPath),
  53543. i.setResponseType(t),
  53544. i.setWithCredentials(this.withCredentials),
  53545. new Promise((r, s) => {
  53546. i.load(e, r, void 0, s);
  53547. })
  53548. );
  53549. }
  53550. preload() {
  53551. return this._initDecoder(), this;
  53552. }
  53553. _initDecoder() {
  53554. if (this.decoderPending) return this.decoderPending;
  53555. let e = typeof WebAssembly != 'object' || this.decoderConfig.type === 'js',
  53556. t = [];
  53557. return (
  53558. e
  53559. ? t.push(this._loadLibrary('draco_decoder.js', 'text'))
  53560. : (t.push(this._loadLibrary('draco_wasm_wrapper.js', 'text')), t.push(this._loadLibrary('draco_decoder.wasm', 'arraybuffer'))),
  53561. (this.decoderPending = Promise.all(t).then((i) => {
  53562. let r = i[0];
  53563. e || (this.decoderConfig.wasmBinary = i[1]);
  53564. let s = dV.toString(),
  53565. n = ['/* draco decoder */', r, '', '/* worker */', s.substring(s.indexOf('{') + 1, s.lastIndexOf('}'))].join(`
  53566. `);
  53567. this.workerSourceURL = URL.createObjectURL(new Blob([n]));
  53568. })),
  53569. this.decoderPending
  53570. );
  53571. }
  53572. _getWorker(e, t) {
  53573. return this._initDecoder().then(() => {
  53574. if (this.workerPool.length < this.workerLimit) {
  53575. let r = new Worker(this.workerSourceURL);
  53576. (r._callbacks = {}),
  53577. (r._taskCosts = {}),
  53578. (r._taskLoad = 0),
  53579. r.postMessage({ type: 'init', decoderConfig: this.decoderConfig }),
  53580. (r.onmessage = function (s) {
  53581. let n = s.data;
  53582. switch (n.type) {
  53583. case 'decode':
  53584. r._callbacks[n.id].resolve(n);
  53585. break;
  53586. case 'error':
  53587. r._callbacks[n.id].reject(n);
  53588. break;
  53589. default:
  53590. console.error('THREE.DRACOLoader: Unexpected message, "' + n.type + '"');
  53591. }
  53592. }),
  53593. this.workerPool.push(r);
  53594. } else
  53595. this.workerPool.sort(function (r, s) {
  53596. return r._taskLoad > s._taskLoad ? -1 : 1;
  53597. });
  53598. let i = this.workerPool[this.workerPool.length - 1];
  53599. return (i._taskCosts[e] = t), (i._taskLoad += t), i;
  53600. });
  53601. }
  53602. _releaseTask(e, t) {
  53603. (e._taskLoad -= e._taskCosts[t]), delete e._callbacks[t], delete e._taskCosts[t];
  53604. }
  53605. debug() {
  53606. console.log(
  53607. 'Task load: ',
  53608. this.workerPool.map((e) => e._taskLoad)
  53609. );
  53610. }
  53611. dispose() {
  53612. for (let e = 0; e < this.workerPool.length; ++e) this.workerPool[e].terminate();
  53613. return (this.workerPool.length = 0), this.workerSourceURL !== '' && URL.revokeObjectURL(this.workerSourceURL), this;
  53614. }
  53615. };
  53616. function dV() {
  53617. let e, t;
  53618. onmessage = function (a) {
  53619. let o = a.data;
  53620. switch (o.type) {
  53621. case 'init':
  53622. (e = o.decoderConfig),
  53623. (t = new Promise(function (u) {
  53624. (e.onModuleLoaded = function (c) {
  53625. u({ draco: c });
  53626. }),
  53627. DracoDecoderModule(e);
  53628. }));
  53629. break;
  53630. case 'decode':
  53631. let l = o.buffer,
  53632. h = o.taskConfig;
  53633. t.then((u) => {
  53634. let c = u.draco,
  53635. d = new c.Decoder(),
  53636. p = new c.DecoderBuffer();
  53637. p.Init(new Int8Array(l), l.byteLength);
  53638. try {
  53639. let f = i(c, d, p, h),
  53640. g = f.attributes.map((m) => m.array.buffer);
  53641. f.index && g.push(f.index.array.buffer), self.postMessage({ type: 'decode', id: o.id, geometry: f }, g);
  53642. } catch (f) {
  53643. console.error(f), self.postMessage({ type: 'error', id: o.id, error: f.message });
  53644. } finally {
  53645. c.destroy(p), c.destroy(d);
  53646. }
  53647. });
  53648. break;
  53649. }
  53650. };
  53651. function i(a, o, l, h) {
  53652. let u = h.attributeIDs,
  53653. c = h.attributeTypes,
  53654. d,
  53655. p,
  53656. f = o.GetEncodedGeometryType(l);
  53657. if (f === a.TRIANGULAR_MESH) (d = new a.Mesh()), (p = o.DecodeBufferToMesh(l, d));
  53658. else if (f === a.POINT_CLOUD) (d = new a.PointCloud()), (p = o.DecodeBufferToPointCloud(l, d));
  53659. else throw new Error('THREE.DRACOLoader: Unexpected geometry type.');
  53660. if (!p.ok() || d.ptr === 0) throw new Error('THREE.DRACOLoader: Decoding failed: ' + p.error_msg());
  53661. let g = { index: null, attributes: [] };
  53662. for (let m in u) {
  53663. let v = self[c[m]],
  53664. y,
  53665. b;
  53666. if (h.useUniqueIDs) (b = u[m]), (y = o.GetAttributeByUniqueId(d, b));
  53667. else {
  53668. if (((b = o.GetAttributeId(d, a[u[m]])), b === -1)) continue;
  53669. y = o.GetAttribute(d, b);
  53670. }
  53671. g.attributes.push(s(a, o, d, m, v, y));
  53672. }
  53673. return f === a.TRIANGULAR_MESH && (g.index = r(a, o, d)), a.destroy(d), g;
  53674. }
  53675. function r(a, o, l) {
  53676. let h = l.num_faces() * 3,
  53677. u = h * 4,
  53678. c = a._malloc(u);
  53679. o.GetTrianglesUInt32Array(l, u, c);
  53680. let d = new Uint32Array(a.HEAPF32.buffer, c, h).slice();
  53681. return a._free(c), { array: d, itemSize: 1 };
  53682. }
  53683. function s(a, o, l, h, u, c) {
  53684. let d = c.num_components(),
  53685. p = l.num_points() * d,
  53686. f = p * u.BYTES_PER_ELEMENT,
  53687. g = n(a, u),
  53688. m = a._malloc(f);
  53689. o.GetAttributeDataArrayForAllPoints(l, c, g, f, m);
  53690. let v = new u(a.HEAPF32.buffer, m, p).slice();
  53691. return a._free(m), { name: h, array: v, itemSize: d };
  53692. }
  53693. function n(a, o) {
  53694. switch (o) {
  53695. case Float32Array:
  53696. return a.DT_FLOAT32;
  53697. case Int8Array:
  53698. return a.DT_INT8;
  53699. case Int16Array:
  53700. return a.DT_INT16;
  53701. case Int32Array:
  53702. return a.DT_INT32;
  53703. case Uint8Array:
  53704. return a.DT_UINT8;
  53705. case Uint16Array:
  53706. return a.DT_UINT16;
  53707. case Uint32Array:
  53708. return a.DT_UINT32;
  53709. }
  53710. }
  53711. }
  53712. var Mn;
  53713. function uV() {
  53714. return Mn || ((Mn = new cV()), Mn.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.2/').preload()), Mn.decoderPending;
  53715. }
  53716. async function pV(e) {
  53717. if (Mn) {
  53718. let t = { attributeIDs: Mn.defaultAttributeIDs, attributeTypes: Mn.defaultAttributeTypes, useUniqueIDs: !1 },
  53719. i;
  53720. try {
  53721. i = await Mn.decodeGeometry(new Int8Array(e).buffer, t);
  53722. } catch (r) {
  53723. console.error(r);
  53724. }
  53725. if (i)
  53726. return {
  53727. index: i.index ? { array: i.index.array } : void 0,
  53728. attributes: Object.entries(i.attributes).map(([r, s]) => ({ name: r, itemSize: s.itemSize, array: s.array }))
  53729. };
  53730. }
  53731. return null;
  53732. }
  53733. async function fV(e, t) {
  53734. let [i, r] = L_(hm.deserialize(new Uint8Array(e)));
  53735. RU(i);
  53736. let s = [];
  53737. i.scene.objects.traverse((n, a) => {
  53738. a.type === 'Mesh' && a.geometry.type === 'NonParametricGeometry' && a.geometry.data.draco !== void 0 && s.push(a);
  53739. }),
  53740. s.length && (await uV());
  53741. for (let n of s) {
  53742. let a = await pV(Si(n.geometry.data.draco));
  53743. if (a) {
  53744. a.index && (n.geometry.data.index = { array: a.index.array, itemSize: 1, normalized: !1, type: 'Uint32Array' });
  53745. let o = {};
  53746. a.attributes.forEach(({ name: l, array: h, itemSize: u }) => {
  53747. o[l] = { array: h, itemSize: u, type: 'Float32Array', normalized: !1 };
  53748. }),
  53749. (n.geometry.data.attributes = o),
  53750. (n.geometry.data.draco = void 0);
  53751. }
  53752. }
  53753. return t && t(i), r.result().data;
  53754. }
  53755. var Xb = Object.keys(zS).filter((e) => isNaN(Number(e))),
  53756. mV = class {
  53757. constructor(e, t, i, r, s, n, a, o, l, h, u) {
  53758. (this.preventScroll = s),
  53759. (this.preventTouchScroll = n),
  53760. (this.hideCursor = a),
  53761. (this.requestRender = l),
  53762. (this.isEnable = !1),
  53763. (this.onResetRaycaster = () => {
  53764. this.eventContext.raycasterNeedsUpdate = !0;
  53765. }),
  53766. (this.onTouchMovePreventScroll = (c) => {
  53767. (c.touches.length > 1 || this.preventTouchScroll) && c.preventDefault();
  53768. }),
  53769. (this.onMouseWheelPreventScroll = (c) => {
  53770. this.preventScroll && c.preventDefault();
  53771. }),
  53772. (this.eventContext = new ej(e, t, i, o, r, u ?? !1)),
  53773. (this.handlers = {
  53774. Spline: new gG(this.eventContext),
  53775. Conditional: new AG(this.eventContext),
  53776. Start: new jG(this.eventContext),
  53777. Basic: new yG(this.eventContext, h, this),
  53778. MouseHover: new zG(this.eventContext),
  53779. Scroll: new FG(this.eventContext),
  53780. Follow: new TG(this.eventContext),
  53781. LookAt: new IG(this.eventContext)
  53782. });
  53783. }
  53784. activate() {
  53785. let { scene: e, domElement: t, eventElement: i } = this.eventContext;
  53786. this.hideCursor && (t.style.cursor = 'none'),
  53787. (this.isEnable = !0),
  53788. e.traverseEntity((r) => {
  53789. r.addEventListener('requestRender', this.requestRender);
  53790. }),
  53791. Object.values(this.handlers).forEach((r) => r.connect()),
  53792. Xb.forEach((r) => {
  53793. Object.values(this.handlers).some((s) => s.domEventsNeeded.has(r)) &&
  53794. (t.addEventListener(r, this.onResetRaycaster), i.addEventListener(r, this.onResetRaycaster));
  53795. }),
  53796. t.addEventListener('wheel', this.onMouseWheelPreventScroll),
  53797. t.addEventListener('touchmove', this.onTouchMovePreventScroll);
  53798. }
  53799. deactivate() {
  53800. let { scene: e, domElement: t } = this.eventContext;
  53801. (this.isEnable = !1),
  53802. (t.style.cursor = ''),
  53803. Object.values(this.handlers).forEach((i) => i.disconnect()),
  53804. e.traverseEntity((i) => {
  53805. i.removeEventListener('requestRender', this.requestRender);
  53806. }),
  53807. Xb.forEach((i) => {
  53808. t.removeEventListener(i, this.onResetRaycaster);
  53809. }),
  53810. t.removeEventListener('touchmove', this.onTouchMovePreventScroll),
  53811. t.removeEventListener('wheel', this.onMouseWheelPreventScroll);
  53812. }
  53813. reset() {
  53814. this.deactivate(), this.activate();
  53815. }
  53816. updateUseWindowEvents(e) {
  53817. let t = this.isEnable;
  53818. t && this.deactivate(), (this.eventContext.useWindowEvents = e), t && this.activate();
  53819. }
  53820. },
  53821. gV = class {
  53822. constructor(e, t, i, r, s) {
  53823. (this._aspect = 1),
  53824. (this._renderer = e),
  53825. (this._camera = t),
  53826. (this._frameSize = new G().copy(i)),
  53827. (this._editorSize = new G().copy(r)),
  53828. (this._aspect = t.aspect),
  53829. (this._fov = s ?? t.fov);
  53830. }
  53831. set frameSize(e) {
  53832. this._frameSize.copy(e);
  53833. }
  53834. updateRenderer() {
  53835. !this._renderer || this._renderer.setSize(this._frameSize.x, this._frameSize.y);
  53836. }
  53837. updateViewport() {
  53838. if (!this._renderer || !this._camera || this._camera.cameraType !== 'PerspectiveCamera') return;
  53839. let e = this._frameSize.x,
  53840. t = this._frameSize.y,
  53841. i = this._editorSize.y;
  53842. (this._aspect = e / t), t <= i && (this._camera.zoom *= i / t), this._renderer.setViewport(0, 0, e, t);
  53843. }
  53844. updateCamera() {
  53845. if (this._camera)
  53846. if (this._camera.cameraType === 'PerspectiveCamera') {
  53847. let e = this._frameSize.y,
  53848. t = this._editorSize.y,
  53849. i = this._fov;
  53850. if (e > t) {
  53851. let r = vV(e, 1080, 2160, 1, 15) / 100;
  53852. (i *= e / t), (i *= 1 - r);
  53853. }
  53854. (this._camera.aspect = this._aspect), (this._camera.fov = i), this._camera.updateProjectionMatrix();
  53855. } else this._camera.setViewplaneSize(this._frameSize.x, this._frameSize.y);
  53856. }
  53857. setCamera(e) {
  53858. (this._camera = e), (this._aspect = e.aspect), (this._fov = e.fov);
  53859. }
  53860. revert() {
  53861. let e = window.innerWidth,
  53862. t = window.innerHeight;
  53863. this._renderer && (this._renderer.setViewport(0, 0, e, t), this._renderer.setSize(e, t)),
  53864. this._camera &&
  53865. ((this._camera.aspect = e / t),
  53866. (this._camera.fov = this._fov),
  53867. this._camera.setViewplaneSize(e, t),
  53868. this._camera.updateProjectionMatrix());
  53869. }
  53870. };
  53871. function vV(e, t, i, r, s) {
  53872. return ((e - t) / (i - t)) * (s - r) + r;
  53873. }
  53874. var h2 = { RED: 0, GREEN: 1, BLUE: 2, ALPHA: 3 },
  53875. Fh = 'varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}',
  53876. yV = `#ifdef FRAMEBUFFER_PRECISION_HIGH
  53877. uniform mediump sampler2D inputBuffer;
  53878. #else
  53879. uniform lowp sampler2D inputBuffer;
  53880. #endif
  53881. uniform lowp sampler2D cocBuffer;uniform vec2 texelSize;uniform float scale;
  53882. #if PASS == 1
  53883. uniform vec4 kernel64[32];
  53884. #else
  53885. uniform vec4 kernel16[8];
  53886. #endif
  53887. varying vec2 vUv;void main(){
  53888. #ifdef FOREGROUND
  53889. vec2 CoCNearFar=texture2D(cocBuffer,vUv).rg;float CoC=CoCNearFar.r*scale;
  53890. #else
  53891. float CoC=texture2D(cocBuffer,vUv).g*scale;
  53892. #endif
  53893. if(CoC==0.0){gl_FragColor=texture2D(inputBuffer,vUv);}else{
  53894. #ifdef FOREGROUND
  53895. vec2 step=texelSize*max(CoC,CoCNearFar.g*scale);
  53896. #else
  53897. vec2 step=texelSize*CoC;
  53898. #endif
  53899. #if PASS == 1
  53900. 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;
  53901. #else
  53902. vec4 maxValue=texture2D(inputBuffer,vUv);for(int i=0;i<8;++i){vec4 kernel=kernel16[i];vec2 uv=step*kernel.xy+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);uv=step*kernel.zw+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);}gl_FragColor=maxValue;
  53903. #endif
  53904. }}`,
  53905. Qc = class extends ri {
  53906. constructor(e = !1, t = !1) {
  53907. super({
  53908. name: 'BokehMaterial',
  53909. defines: { PASS: e ? '2' : '1' },
  53910. uniforms: {
  53911. kernel64: new Oe(null),
  53912. kernel16: new Oe(null),
  53913. inputBuffer: new Oe(null),
  53914. cocBuffer: new Oe(null),
  53915. texelSize: new Oe(new G()),
  53916. scale: new Oe(1)
  53917. },
  53918. blending: fi,
  53919. depthWrite: !1,
  53920. depthTest: !1,
  53921. fragmentShader: yV,
  53922. vertexShader: Fh
  53923. }),
  53924. (this.toneMapped = !1),
  53925. t && (this.defines.FOREGROUND = '1'),
  53926. this.generateKernel();
  53927. }
  53928. set inputBuffer(e) {
  53929. this.uniforms.inputBuffer.value = e;
  53930. }
  53931. setInputBuffer(e) {
  53932. this.uniforms.inputBuffer.value = e;
  53933. }
  53934. set cocBuffer(e) {
  53935. this.uniforms.cocBuffer.value = e;
  53936. }
  53937. setCoCBuffer(e) {
  53938. this.uniforms.cocBuffer.value = e;
  53939. }
  53940. get scale() {
  53941. return this.uniforms.scale.value;
  53942. }
  53943. set scale(e) {
  53944. this.uniforms.scale.value = e;
  53945. }
  53946. getScale(e) {
  53947. return (this.uniforms.scale.value = e);
  53948. }
  53949. setScale(e) {
  53950. this.uniforms.scale.value = e;
  53951. }
  53952. generateKernel() {
  53953. let e = 2.39996323,
  53954. t = new Float32Array(128),
  53955. i = new Float32Array(32),
  53956. r = 0,
  53957. s = 0;
  53958. for (let o = 0; o < 80; ++o) {
  53959. let l = o * e,
  53960. h = Math.sqrt(o) / Math.sqrt(80),
  53961. u = h * Math.cos(l),
  53962. c = h * Math.sin(l);
  53963. o % 5 === 0 ? ((i[s++] = u), (i[s++] = c)) : ((t[r++] = u), (t[r++] = c));
  53964. }
  53965. let n = [],
  53966. a = [];
  53967. for (let o = 0; o < 128; ) n.push(new $e(t[o++], t[o++], t[o++], t[o++]));
  53968. for (let o = 0; o < 32; ) a.push(new $e(i[o++], i[o++], i[o++], i[o++]));
  53969. (this.uniforms.kernel64.value = n), (this.uniforms.kernel16.value = a);
  53970. }
  53971. setTexelSize(e, t) {
  53972. this.uniforms.texelSize.value.set(e, t);
  53973. }
  53974. setSize(e, t) {
  53975. this.uniforms.texelSize.value.set(1 / e, 1 / t);
  53976. }
  53977. };
  53978. function qb(e, t, i) {
  53979. return e * (t - i) - t;
  53980. }
  53981. function sg(e, t, i) {
  53982. return Math.min(Math.max((e + t) / (t - i), 0), 1);
  53983. }
  53984. var xV = `#include <common>
  53985. #include <packing>
  53986. #ifdef GL_FRAGMENT_PRECISION_HIGH
  53987. uniform highp sampler2D depthBuffer;
  53988. #else
  53989. uniform mediump sampler2D depthBuffer;
  53990. #endif
  53991. uniform float focusDistance;uniform float focusRange;uniform float cameraNear;uniform float cameraFar;varying vec2 vUv;float readDepth(const in vec2 uv){
  53992. #if DEPTH_PACKING == 3201
  53993. return unpackRGBAToDepth(texture2D(depthBuffer,uv));
  53994. #else
  53995. return texture2D(depthBuffer,uv).r;
  53996. #endif
  53997. }void main(){float depth=readDepth(vUv);
  53998. #ifdef PERSPECTIVE_CAMERA
  53999. float viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar);
  54000. #else
  54001. float linearDepth=depth;
  54002. #endif
  54003. 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));}`,
  54004. bV = class extends ri {
  54005. constructor(e) {
  54006. super({
  54007. name: 'CircleOfConfusionMaterial',
  54008. defines: { DEPTH_PACKING: '0' },
  54009. uniforms: {
  54010. depthBuffer: new Oe(null),
  54011. focusDistance: new Oe(0),
  54012. focusRange: new Oe(0),
  54013. cameraNear: new Oe(0.3),
  54014. cameraFar: new Oe(1e3)
  54015. },
  54016. blending: fi,
  54017. depthWrite: !1,
  54018. depthTest: !1,
  54019. fragmentShader: xV,
  54020. vertexShader: Fh
  54021. }),
  54022. (this.toneMapped = !1),
  54023. (this.uniforms.focalLength = this.uniforms.focusRange),
  54024. this.adoptCameraSettings(e);
  54025. }
  54026. get near() {
  54027. return this.uniforms.cameraNear.value;
  54028. }
  54029. get far() {
  54030. return this.uniforms.cameraFar.value;
  54031. }
  54032. set depthBuffer(e) {
  54033. this.uniforms.depthBuffer.value = e;
  54034. }
  54035. set depthPacking(e) {
  54036. (this.defines.DEPTH_PACKING = e.toFixed(0)), (this.needsUpdate = !0);
  54037. }
  54038. setDepthBuffer(e, t = qs) {
  54039. (this.depthBuffer = e), (this.depthPacking = t);
  54040. }
  54041. get focusDistance() {
  54042. return this.uniforms.focusDistance.value;
  54043. }
  54044. set focusDistance(e) {
  54045. this.uniforms.focusDistance.value = e;
  54046. }
  54047. get worldFocusDistance() {
  54048. return -qb(this.focusDistance, this.near, this.far);
  54049. }
  54050. set worldFocusDistance(e) {
  54051. this.focusDistance = sg(-e, this.near, this.far);
  54052. }
  54053. getFocusDistance(e) {
  54054. this.uniforms.focusDistance.value = e;
  54055. }
  54056. setFocusDistance(e) {
  54057. this.uniforms.focusDistance.value = e;
  54058. }
  54059. get focalLength() {
  54060. return this.focusRange;
  54061. }
  54062. set focalLength(e) {
  54063. this.focusRange = e;
  54064. }
  54065. get focusRange() {
  54066. return this.uniforms.focusRange.value;
  54067. }
  54068. set focusRange(e) {
  54069. this.uniforms.focusRange.value = e;
  54070. }
  54071. get worldFocusRange() {
  54072. return -qb(this.focusRange, this.near, this.far);
  54073. }
  54074. set worldFocusRange(e) {
  54075. this.focusRange = sg(-e, this.near, this.far);
  54076. }
  54077. getFocalLength(e) {
  54078. return this.focusRange;
  54079. }
  54080. setFocalLength(e) {
  54081. this.focusRange = e;
  54082. }
  54083. adoptCameraSettings(e) {
  54084. e &&
  54085. ((this.uniforms.cameraNear.value = e.near),
  54086. (this.uniforms.cameraFar.value = e.far),
  54087. e instanceof wi ? (this.defines.PERSPECTIVE_CAMERA = '1') : delete this.defines.PERSPECTIVE_CAMERA,
  54088. (this.needsUpdate = !0));
  54089. }
  54090. },
  54091. wV = `#include <common>
  54092. #include <dithering_pars_fragment>
  54093. #ifdef FRAMEBUFFER_PRECISION_HIGH
  54094. uniform mediump sampler2D inputBuffer;
  54095. #else
  54096. uniform lowp sampler2D inputBuffer;
  54097. #endif
  54098. 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;
  54099. #include <encodings_fragment>
  54100. #include <dithering_fragment>
  54101. }`,
  54102. _V =
  54103. '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);}',
  54104. Yb = class extends ri {
  54105. constructor(e = new G()) {
  54106. super({
  54107. name: 'KawaseBlurMaterial',
  54108. uniforms: {
  54109. inputBuffer: new Oe(null),
  54110. texelSize: new Oe(new G()),
  54111. halfTexelSize: new Oe(new G()),
  54112. kernel: new Oe(0),
  54113. scale: new Oe(1)
  54114. },
  54115. blending: fi,
  54116. depthWrite: !1,
  54117. depthTest: !1,
  54118. fragmentShader: wV,
  54119. vertexShader: _V
  54120. }),
  54121. (this.toneMapped = !1),
  54122. this.setTexelSize(e.x, e.y);
  54123. }
  54124. set inputBuffer(e) {
  54125. this.uniforms.inputBuffer.value = e;
  54126. }
  54127. setInputBuffer(e) {
  54128. this.inputBuffer = e;
  54129. }
  54130. get scale() {
  54131. return this.uniforms.scale.value;
  54132. }
  54133. set scale(e) {
  54134. this.uniforms.scale.value = e;
  54135. }
  54136. getScale() {
  54137. return this.uniforms.scale.value;
  54138. }
  54139. setScale(e) {
  54140. this.uniforms.scale.value = e;
  54141. }
  54142. getKernel() {
  54143. return null;
  54144. }
  54145. get kernel() {
  54146. return this.uniforms.kernel.value;
  54147. }
  54148. set kernel(e) {
  54149. this.uniforms.kernel.value = e;
  54150. }
  54151. setKernel(e) {
  54152. this.kernel = e;
  54153. }
  54154. setTexelSize(e, t) {
  54155. this.uniforms.texelSize.value.set(e, t), this.uniforms.halfTexelSize.value.set(e, t).multiplyScalar(0.5);
  54156. }
  54157. setSize(e, t) {
  54158. let i = this.uniforms;
  54159. i.texelSize.value.set(1 / e, 1 / t), i.halfTexelSize.value.copy(i.texelSize.value).multiplyScalar(0.5);
  54160. }
  54161. },
  54162. AV = `#ifdef FRAMEBUFFER_PRECISION_HIGH
  54163. uniform mediump sampler2D inputBuffer;
  54164. #else
  54165. uniform lowp sampler2D inputBuffer;
  54166. #endif
  54167. uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel;
  54168. #include <encodings_fragment>
  54169. }`,
  54170. SV = class extends ri {
  54171. constructor() {
  54172. super({
  54173. name: 'CopyMaterial',
  54174. uniforms: { inputBuffer: new Oe(null), opacity: new Oe(1) },
  54175. blending: fi,
  54176. depthWrite: !1,
  54177. depthTest: !1,
  54178. fragmentShader: AV,
  54179. vertexShader: Fh
  54180. }),
  54181. (this.toneMapped = !1);
  54182. }
  54183. set inputBuffer(e) {
  54184. this.uniforms.inputBuffer.value = e;
  54185. }
  54186. setInputBuffer(e) {
  54187. this.uniforms.inputBuffer.value = e;
  54188. }
  54189. getOpacity(e) {
  54190. return this.uniforms.opacity.value;
  54191. }
  54192. setOpacity(e) {
  54193. this.uniforms.opacity.value = e;
  54194. }
  54195. },
  54196. MV = `varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;
  54197. #if THREE_REVISION < 143
  54198. #define luminance(v) linearToRelativeLuminance(v)
  54199. #endif
  54200. #if EDGE_DETECTION_MODE != 0
  54201. varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;
  54202. #endif
  54203. #if EDGE_DETECTION_MODE == 1
  54204. #include <common>
  54205. #endif
  54206. #if EDGE_DETECTION_MODE == 0 || PREDICATION_MODE == 1
  54207. #ifdef GL_FRAGMENT_PRECISION_HIGH
  54208. uniform highp sampler2D depthBuffer;
  54209. #else
  54210. uniform mediump sampler2D depthBuffer;
  54211. #endif
  54212. float readDepth(const in vec2 uv){
  54213. #if DEPTH_PACKING == 3201
  54214. return unpackRGBAToDepth(texture2D(depthBuffer,uv));
  54215. #else
  54216. return texture2D(depthBuffer,uv).r;
  54217. #endif
  54218. }vec3 gatherNeighbors(){float p=readDepth(vUv);float pLeft=readDepth(vUv0);float pTop=readDepth(vUv1);return vec3(p,pLeft,pTop);}
  54219. #elif PREDICATION_MODE == 2
  54220. 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);}
  54221. #endif
  54222. #if PREDICATION_MODE != 0
  54223. 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);}
  54224. #endif
  54225. #if EDGE_DETECTION_MODE != 0
  54226. uniform sampler2D inputBuffer;
  54227. #endif
  54228. void main(){
  54229. #if EDGE_DETECTION_MODE == 0
  54230. const vec2 threshold=vec2(DEPTH_THRESHOLD);
  54231. #elif PREDICATION_MODE != 0
  54232. vec2 threshold=calculatePredicatedThreshold();
  54233. #else
  54234. const vec2 threshold=vec2(EDGE_THRESHOLD);
  54235. #endif
  54236. #if EDGE_DETECTION_MODE == 0
  54237. 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);
  54238. #elif EDGE_DETECTION_MODE == 1
  54239. 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);
  54240. #elif EDGE_DETECTION_MODE == 2
  54241. 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);
  54242. #endif
  54243. }`,
  54244. EV = `uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;
  54245. #if EDGE_DETECTION_MODE != 0
  54246. varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;
  54247. #endif
  54248. 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);
  54249. #if EDGE_DETECTION_MODE != 0
  54250. 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);
  54251. #endif
  54252. gl_Position=vec4(position.xy,1.0,1.0);}`,
  54253. Lv = { DEPTH: 0, LUMA: 1, COLOR: 2 },
  54254. c2 = { DISABLED: 0, DEPTH: 1, CUSTOM: 2 },
  54255. CV = class extends ri {
  54256. constructor(e = new G(), t = Lv.COLOR) {
  54257. super({
  54258. name: 'EdgeDetectionMaterial',
  54259. defines: {
  54260. THREE_REVISION: Wo.replace(/\D+/g, ''),
  54261. LOCAL_CONTRAST_ADAPTATION_FACTOR: '2.0',
  54262. EDGE_THRESHOLD: '0.1',
  54263. DEPTH_THRESHOLD: '0.01',
  54264. PREDICATION_MODE: '0',
  54265. PREDICATION_THRESHOLD: '0.01',
  54266. PREDICATION_SCALE: '2.0',
  54267. PREDICATION_STRENGTH: '1.0',
  54268. DEPTH_PACKING: '0'
  54269. },
  54270. uniforms: { inputBuffer: new Oe(null), depthBuffer: new Oe(null), predicationBuffer: new Oe(null), texelSize: new Oe(e) },
  54271. blending: fi,
  54272. depthWrite: !1,
  54273. depthTest: !1,
  54274. fragmentShader: MV,
  54275. vertexShader: EV
  54276. }),
  54277. (this.toneMapped = !1),
  54278. (this.edgeDetectionMode = t);
  54279. }
  54280. set depthBuffer(e) {
  54281. this.uniforms.depthBuffer.value = e;
  54282. }
  54283. set depthPacking(e) {
  54284. (this.defines.DEPTH_PACKING = e.toFixed(0)), (this.needsUpdate = !0);
  54285. }
  54286. setDepthBuffer(e, t = qs) {
  54287. (this.depthBuffer = e), (this.depthPacking = t);
  54288. }
  54289. get edgeDetectionMode() {
  54290. return Number(this.defines.EDGE_DETECTION_MODE);
  54291. }
  54292. set edgeDetectionMode(e) {
  54293. (this.defines.EDGE_DETECTION_MODE = e.toFixed(0)), (this.needsUpdate = !0);
  54294. }
  54295. getEdgeDetectionMode() {
  54296. return this.edgeDetectionMode;
  54297. }
  54298. setEdgeDetectionMode(e) {
  54299. this.edgeDetectionMode = e;
  54300. }
  54301. get localContrastAdaptationFactor() {
  54302. return Number(this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR);
  54303. }
  54304. set localContrastAdaptationFactor(e) {
  54305. (this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR = e.toFixed('6')), (this.needsUpdate = !0);
  54306. }
  54307. getLocalContrastAdaptationFactor() {
  54308. return this.localContrastAdaptationFactor;
  54309. }
  54310. setLocalContrastAdaptationFactor(e) {
  54311. this.localContrastAdaptationFactor = e;
  54312. }
  54313. get edgeDetectionThreshold() {
  54314. return Number(this.defines.EDGE_THRESHOLD);
  54315. }
  54316. set edgeDetectionThreshold(e) {
  54317. (this.defines.EDGE_THRESHOLD = e.toFixed('6')), (this.defines.DEPTH_THRESHOLD = (e * 0.1).toFixed('6')), (this.needsUpdate = !0);
  54318. }
  54319. getEdgeDetectionThreshold() {
  54320. return this.edgeDetectionThreshold;
  54321. }
  54322. setEdgeDetectionThreshold(e) {
  54323. this.edgeDetectionThreshold = e;
  54324. }
  54325. get predicationMode() {
  54326. return Number(this.defines.PREDICATION_MODE);
  54327. }
  54328. set predicationMode(e) {
  54329. (this.defines.PREDICATION_MODE = e.toFixed(0)), (this.needsUpdate = !0);
  54330. }
  54331. getPredicationMode() {
  54332. return this.predicationMode;
  54333. }
  54334. setPredicationMode(e) {
  54335. this.predicationMode = e;
  54336. }
  54337. set predicationBuffer(e) {
  54338. this.uniforms.predicationBuffer.value = e;
  54339. }
  54340. setPredicationBuffer(e) {
  54341. this.uniforms.predicationBuffer.value = e;
  54342. }
  54343. get predicationThreshold() {
  54344. return Number(this.defines.PREDICATION_THRESHOLD);
  54345. }
  54346. set predicationThreshold(e) {
  54347. (this.defines.PREDICATION_THRESHOLD = e.toFixed('6')), (this.needsUpdate = !0);
  54348. }
  54349. getPredicationThreshold() {
  54350. return this.predicationThreshold;
  54351. }
  54352. setPredicationThreshold(e) {
  54353. this.predicationThreshold = e;
  54354. }
  54355. get predicationScale() {
  54356. return Number(this.defines.PREDICATION_SCALE);
  54357. }
  54358. set predicationScale(e) {
  54359. (this.defines.PREDICATION_SCALE = e.toFixed('6')), (this.needsUpdate = !0);
  54360. }
  54361. getPredicationScale() {
  54362. return this.predicationScale;
  54363. }
  54364. setPredicationScale(e) {
  54365. this.predicationScale = e;
  54366. }
  54367. get predicationStrength() {
  54368. return Number(this.defines.PREDICATION_STRENGTH);
  54369. }
  54370. set predicationStrength(e) {
  54371. (this.defines.PREDICATION_STRENGTH = e.toFixed('6')), (this.needsUpdate = !0);
  54372. }
  54373. getPredicationStrength() {
  54374. return this.predicationStrength;
  54375. }
  54376. setPredicationStrength(e) {
  54377. this.predicationStrength = e;
  54378. }
  54379. setSize(e, t) {
  54380. this.uniforms.texelSize.value.set(1 / e, 1 / t);
  54381. }
  54382. },
  54383. TV = `#include <common>
  54384. #include <packing>
  54385. #include <dithering_pars_fragment>
  54386. #define packFloatToRGBA(v) packDepthToRGBA(v)
  54387. #define unpackRGBAToFloat(v) unpackRGBAToDepth(v)
  54388. #ifdef FRAMEBUFFER_PRECISION_HIGH
  54389. uniform mediump sampler2D inputBuffer;
  54390. #else
  54391. uniform lowp sampler2D inputBuffer;
  54392. #endif
  54393. #ifdef GL_FRAGMENT_PRECISION_HIGH
  54394. uniform highp sampler2D depthBuffer;
  54395. #else
  54396. uniform mediump sampler2D depthBuffer;
  54397. #endif
  54398. uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;
  54399. #if THREE_REVISION < 143
  54400. #define luminance(v) linearToRelativeLuminance(v)
  54401. #endif
  54402. #if THREE_REVISION >= 137
  54403. 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);}
  54404. #endif
  54405. float readDepth(const in vec2 uv){
  54406. #if DEPTH_PACKING == 3201
  54407. return unpackRGBAToDepth(texture2D(depthBuffer,uv));
  54408. #else
  54409. return texture2D(depthBuffer,uv).r;
  54410. #endif
  54411. }float getViewZ(const in float depth){
  54412. #ifdef PERSPECTIVE_CAMERA
  54413. return perspectiveDepthToViewZ(depth,cameraNear,cameraFar);
  54414. #else
  54415. return orthographicDepthToViewZ(depth,cameraNear,cameraFar);
  54416. #endif
  54417. }FRAGMENT_HEADvoid main(){FRAGMENT_MAIN_UVvec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGEgl_FragColor=color0;
  54418. #ifdef ENCODE_OUTPUT
  54419. #include <encodings_fragment>
  54420. #endif
  54421. #include <dithering_fragment>
  54422. }`,
  54423. PV =
  54424. '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);}',
  54425. Nr = {
  54426. FRAGMENT_HEAD: 'FRAGMENT_HEAD',
  54427. FRAGMENT_MAIN_UV: 'FRAGMENT_MAIN_UV',
  54428. FRAGMENT_MAIN_IMAGE: 'FRAGMENT_MAIN_IMAGE',
  54429. VERTEX_HEAD: 'VERTEX_HEAD',
  54430. VERTEX_MAIN_SUPPORT: 'VERTEX_MAIN_SUPPORT'
  54431. },
  54432. ng = class extends ri {
  54433. constructor(e, t, i, r, s = !1) {
  54434. super({
  54435. name: 'EffectMaterial',
  54436. defines: { THREE_REVISION: Wo.replace(/\D+/g, ''), DEPTH_PACKING: '0', ENCODE_OUTPUT: '1' },
  54437. uniforms: {
  54438. inputBuffer: new Oe(null),
  54439. depthBuffer: new Oe(null),
  54440. resolution: new Oe(new G()),
  54441. texelSize: new Oe(new G()),
  54442. cameraNear: new Oe(0.3),
  54443. cameraFar: new Oe(1e3),
  54444. aspect: new Oe(1),
  54445. time: new Oe(0)
  54446. },
  54447. blending: fi,
  54448. depthWrite: !1,
  54449. depthTest: !1,
  54450. dithering: s
  54451. }),
  54452. (this.toneMapped = !1),
  54453. e && this.setShaderParts(e),
  54454. t && this.setDefines(t),
  54455. i && this.setUniforms(i),
  54456. this.adoptCameraSettings(r);
  54457. }
  54458. set inputBuffer(e) {
  54459. this.uniforms.inputBuffer.value = e;
  54460. }
  54461. setInputBuffer(e) {
  54462. this.uniforms.inputBuffer.value = e;
  54463. }
  54464. get depthBuffer() {
  54465. return this.uniforms.depthBuffer.value;
  54466. }
  54467. set depthBuffer(e) {
  54468. this.uniforms.depthBuffer.value = e;
  54469. }
  54470. get depthPacking() {
  54471. return Number(this.defines.DEPTH_PACKING);
  54472. }
  54473. set depthPacking(e) {
  54474. (this.defines.DEPTH_PACKING = e.toFixed(0)), (this.needsUpdate = !0);
  54475. }
  54476. setDepthBuffer(e, t = qs) {
  54477. (this.depthBuffer = e), (this.depthPacking = t);
  54478. }
  54479. setShaderParts(e) {
  54480. return (
  54481. (this.fragmentShader = TV.replace(Nr.FRAGMENT_HEAD, e.get(Nr.FRAGMENT_HEAD))
  54482. .replace(Nr.FRAGMENT_MAIN_UV, e.get(Nr.FRAGMENT_MAIN_UV))
  54483. .replace(Nr.FRAGMENT_MAIN_IMAGE, e.get(Nr.FRAGMENT_MAIN_IMAGE))),
  54484. (this.vertexShader = PV.replace(Nr.VERTEX_HEAD, e.get(Nr.VERTEX_HEAD)).replace(
  54485. Nr.VERTEX_MAIN_SUPPORT,
  54486. e.get(Nr.VERTEX_MAIN_SUPPORT)
  54487. )),
  54488. (this.needsUpdate = !0),
  54489. this
  54490. );
  54491. }
  54492. setDefines(e) {
  54493. for (let t of e.entries()) this.defines[t[0]] = t[1];
  54494. return (this.needsUpdate = !0), this;
  54495. }
  54496. setUniforms(e) {
  54497. for (let t of e.entries()) this.uniforms[t[0]] = t[1];
  54498. return this;
  54499. }
  54500. setExtensions(e) {
  54501. this.extensions = {};
  54502. for (let t of e) this.extensions[t] = !0;
  54503. return this;
  54504. }
  54505. get encodeOutput() {
  54506. return this.defines.ENCODE_OUTPUT !== void 0;
  54507. }
  54508. set encodeOutput(e) {
  54509. this.encodeOutput !== e && (e ? (this.defines.ENCODE_OUTPUT = '1') : delete this.defines.ENCODE_OUTPUT, (this.needsUpdate = !0));
  54510. }
  54511. isOutputEncodingEnabled(e) {
  54512. return this.encodeOutput;
  54513. }
  54514. setOutputEncodingEnabled(e) {
  54515. this.encodeOutput = e;
  54516. }
  54517. get time() {
  54518. return this.uniforms.time.value;
  54519. }
  54520. set time(e) {
  54521. this.uniforms.time.value = e;
  54522. }
  54523. setDeltaTime(e) {
  54524. this.uniforms.time.value += e;
  54525. }
  54526. adoptCameraSettings(e) {
  54527. e &&
  54528. ((this.uniforms.cameraNear.value = e.near),
  54529. (this.uniforms.cameraFar.value = e.far),
  54530. e instanceof wi ? (this.defines.PERSPECTIVE_CAMERA = '1') : delete this.defines.PERSPECTIVE_CAMERA,
  54531. (this.needsUpdate = !0));
  54532. }
  54533. setSize(e, t) {
  54534. let i = this.uniforms;
  54535. i.resolution.value.set(e, t), i.texelSize.value.set(1 / e, 1 / t), (i.aspect.value = e / t);
  54536. }
  54537. static get Section() {
  54538. return Nr;
  54539. }
  54540. },
  54541. DV = `#include <common>
  54542. #if THREE_REVISION < 143
  54543. #define luminance(v) linearToRelativeLuminance(v)
  54544. #endif
  54545. #ifdef FRAMEBUFFER_PRECISION_HIGH
  54546. uniform mediump sampler2D inputBuffer;
  54547. #else
  54548. uniform lowp sampler2D inputBuffer;
  54549. #endif
  54550. #ifdef RANGE
  54551. uniform vec2 range;
  54552. #elif defined(THRESHOLD)
  54553. uniform float threshold;uniform float smoothing;
  54554. #endif
  54555. varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb);
  54556. #ifdef RANGE
  54557. float low=step(range.x,l);float high=step(l,range.y);l*=low*high;
  54558. #elif defined(THRESHOLD)
  54559. l=smoothstep(threshold,threshold+smoothing,l);
  54560. #endif
  54561. #ifdef COLOR
  54562. gl_FragColor=vec4(texel.rgb*l,l);
  54563. #else
  54564. gl_FragColor=vec4(l);
  54565. #endif
  54566. }`,
  54567. LV = class extends ri {
  54568. constructor(e = !1, t = null) {
  54569. super({
  54570. name: 'LuminanceMaterial',
  54571. defines: { THREE_REVISION: Wo.replace(/\D+/g, '') },
  54572. uniforms: { inputBuffer: new Oe(null), threshold: new Oe(0), smoothing: new Oe(1), range: new Oe(null) },
  54573. blending: fi,
  54574. depthWrite: !1,
  54575. depthTest: !1,
  54576. fragmentShader: DV,
  54577. vertexShader: Fh
  54578. }),
  54579. (this.toneMapped = !1),
  54580. (this.colorOutput = e),
  54581. (this.luminanceRange = t);
  54582. }
  54583. set inputBuffer(e) {
  54584. this.uniforms.inputBuffer.value = e;
  54585. }
  54586. setInputBuffer(e) {
  54587. this.uniforms.inputBuffer.value = e;
  54588. }
  54589. get threshold() {
  54590. return this.uniforms.threshold.value;
  54591. }
  54592. set threshold(e) {
  54593. this.smoothing > 0 || e > 0 ? (this.defines.THRESHOLD = '1') : delete this.defines.THRESHOLD, (this.uniforms.threshold.value = e);
  54594. }
  54595. getThreshold() {
  54596. return this.threshold;
  54597. }
  54598. setThreshold(e) {
  54599. this.threshold = e;
  54600. }
  54601. get smoothing() {
  54602. return this.uniforms.smoothing.value;
  54603. }
  54604. set smoothing(e) {
  54605. this.threshold > 0 || e > 0 ? (this.defines.THRESHOLD = '1') : delete this.defines.THRESHOLD, (this.uniforms.smoothing.value = e);
  54606. }
  54607. getSmoothingFactor() {
  54608. return this.smoothing;
  54609. }
  54610. setSmoothingFactor(e) {
  54611. this.smoothing = e;
  54612. }
  54613. get useThreshold() {
  54614. return this.threshold > 0 || this.smoothing > 0;
  54615. }
  54616. set useThreshold(e) {}
  54617. get colorOutput() {
  54618. return this.defines.COLOR !== void 0;
  54619. }
  54620. set colorOutput(e) {
  54621. e ? (this.defines.COLOR = '1') : delete this.defines.COLOR, (this.needsUpdate = !0);
  54622. }
  54623. isColorOutputEnabled(e) {
  54624. return this.colorOutput;
  54625. }
  54626. setColorOutputEnabled(e) {
  54627. this.colorOutput = e;
  54628. }
  54629. get useRange() {
  54630. return this.luminanceRange !== null;
  54631. }
  54632. set useRange(e) {
  54633. this.luminanceRange = null;
  54634. }
  54635. get luminanceRange() {
  54636. return this.uniforms.range.value;
  54637. }
  54638. set luminanceRange(e) {
  54639. e !== null ? (this.defines.RANGE = '1') : delete this.defines.RANGE, (this.uniforms.range.value = e), (this.needsUpdate = !0);
  54640. }
  54641. getLuminanceRange() {
  54642. return this.luminanceRange;
  54643. }
  54644. setLuminanceRange(e) {
  54645. this.luminanceRange = e;
  54646. }
  54647. },
  54648. OV = `#ifdef FRAMEBUFFER_PRECISION_HIGH
  54649. uniform mediump sampler2D inputBuffer;
  54650. #else
  54651. uniform lowp sampler2D inputBuffer;
  54652. #endif
  54653. #ifdef MASK_PRECISION_HIGH
  54654. uniform mediump sampler2D maskTexture;
  54655. #else
  54656. uniform lowp sampler2D maskTexture;
  54657. #endif
  54658. #if MASK_FUNCTION != 0
  54659. uniform float strength;
  54660. #endif
  54661. varying vec2 vUv;void main(){
  54662. #if COLOR_CHANNEL == 0
  54663. float mask=texture2D(maskTexture,vUv).r;
  54664. #elif COLOR_CHANNEL == 1
  54665. float mask=texture2D(maskTexture,vUv).g;
  54666. #elif COLOR_CHANNEL == 2
  54667. float mask=texture2D(maskTexture,vUv).b;
  54668. #else
  54669. float mask=texture2D(maskTexture,vUv).a;
  54670. #endif
  54671. #if MASK_FUNCTION == 0
  54672. #ifdef INVERTED
  54673. mask=step(mask,0.0);
  54674. #else
  54675. mask=1.0-step(mask,0.0);
  54676. #endif
  54677. #else
  54678. mask=clamp(mask*strength,0.0,1.0);
  54679. #ifdef INVERTED
  54680. mask=1.0-mask;
  54681. #endif
  54682. #endif
  54683. #if MASK_FUNCTION == 2
  54684. gl_FragColor=vec4(mask*texture2D(inputBuffer,vUv).rgb,mask);
  54685. #else
  54686. gl_FragColor=mask*texture2D(inputBuffer,vUv);
  54687. #endif
  54688. }`,
  54689. d2 = { DISCARD: 0, MULTIPLY: 1, MULTIPLY_RGB_SET_ALPHA: 2 },
  54690. IV = class extends ri {
  54691. constructor(e = null) {
  54692. super({
  54693. name: 'MaskMaterial',
  54694. uniforms: { maskTexture: new Oe(e), inputBuffer: new Oe(null), strength: new Oe(1) },
  54695. blending: fi,
  54696. depthWrite: !1,
  54697. depthTest: !1,
  54698. fragmentShader: OV,
  54699. vertexShader: Fh
  54700. }),
  54701. (this.toneMapped = !1),
  54702. this.setColorChannel(h2.RED),
  54703. this.setMaskFunction(d2.DISCARD);
  54704. }
  54705. set inputBuffer(e) {
  54706. this.uniforms.inputBuffer.value = e;
  54707. }
  54708. setInputBuffer(e) {
  54709. this.uniforms.inputBuffer.value = e;
  54710. }
  54711. set maskTexture(e) {
  54712. (this.uniforms.maskTexture.value = e),
  54713. delete this.defines.MASK_PRECISION_HIGH,
  54714. e.type !== Mi && (this.defines.MASK_PRECISION_HIGH = '1'),
  54715. (this.needsUpdate = !0);
  54716. }
  54717. setMaskTexture(e) {
  54718. this.maskTexture = e;
  54719. }
  54720. set colorChannel(e) {
  54721. (this.defines.COLOR_CHANNEL = e.toFixed(0)), (this.needsUpdate = !0);
  54722. }
  54723. setColorChannel(e) {
  54724. this.colorChannel = e;
  54725. }
  54726. set maskFunction(e) {
  54727. (this.defines.MASK_FUNCTION = e.toFixed(0)), (this.needsUpdate = !0);
  54728. }
  54729. setMaskFunction(e) {
  54730. this.maskFunction = e;
  54731. }
  54732. get inverted() {
  54733. return this.defines.INVERTED !== void 0;
  54734. }
  54735. set inverted(e) {
  54736. this.inverted && !e ? delete this.defines.INVERTED : e && (this.defines.INVERTED = '1'), (this.needsUpdate = !0);
  54737. }
  54738. isInverted() {
  54739. return this.inverted;
  54740. }
  54741. setInverted(e) {
  54742. this.inverted = e;
  54743. }
  54744. get strength() {
  54745. return this.uniforms.strength.value;
  54746. }
  54747. set strength(e) {
  54748. this.uniforms.strength.value = e;
  54749. }
  54750. getStrength() {
  54751. return this.strength;
  54752. }
  54753. setStrength(e) {
  54754. this.strength = e;
  54755. }
  54756. },
  54757. RV = `#define sampleLevelZeroOffset(t, coord, offset) texture2D(t, coord + offset * texelSize)
  54758. #if __VERSION__ < 300
  54759. #define round(v) floor(v + 0.5)
  54760. #endif
  54761. #ifdef FRAMEBUFFER_PRECISION_HIGH
  54762. uniform mediump sampler2D inputBuffer;
  54763. #else
  54764. uniform lowp sampler2D inputBuffer;
  54765. #endif
  54766. 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){
  54767. #if !defined(DISABLE_CORNER_DETECTION)
  54768. 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);
  54769. #endif
  54770. }void detectVerticalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){
  54771. #if !defined(DISABLE_CORNER_DETECTION)
  54772. 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);
  54773. #endif
  54774. }void main(){vec4 weights=vec4(0.0);vec4 subsampleIndices=vec4(0.0);vec2 e=texture2D(inputBuffer,vUv).rg;if(e.g>0.0){
  54775. #if !defined(DISABLE_DIAG_DETECTION)
  54776. weights.rg=calculateDiagWeights(vUv,e,subsampleIndices);if(weights.r==-weights.g){
  54777. #endif
  54778. 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);
  54779. #if !defined(DISABLE_DIAG_DETECTION)
  54780. }else{e.r=0.0;}
  54781. #endif
  54782. }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;}`,
  54783. BV =
  54784. '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);}',
  54785. zV = class extends ri {
  54786. constructor(e = new G(), t = new G()) {
  54787. super({
  54788. name: 'SMAAWeightsMaterial',
  54789. defines: {
  54790. MAX_SEARCH_STEPS_INT: '16',
  54791. MAX_SEARCH_STEPS_FLOAT: '16.0',
  54792. MAX_SEARCH_STEPS_DIAG_INT: '8',
  54793. MAX_SEARCH_STEPS_DIAG_FLOAT: '8.0',
  54794. CORNER_ROUNDING: '25',
  54795. CORNER_ROUNDING_NORM: '0.25',
  54796. AREATEX_MAX_DISTANCE: '16.0',
  54797. AREATEX_MAX_DISTANCE_DIAG: '20.0',
  54798. AREATEX_PIXEL_SIZE: '(1.0 / vec2(160.0, 560.0))',
  54799. AREATEX_SUBTEX_SIZE: '(1.0 / 7.0)',
  54800. SEARCHTEX_SIZE: 'vec2(66.0, 33.0)',
  54801. SEARCHTEX_PACKED_SIZE: 'vec2(64.0, 16.0)'
  54802. },
  54803. uniforms: {
  54804. inputBuffer: new Oe(null),
  54805. searchTexture: new Oe(null),
  54806. areaTexture: new Oe(null),
  54807. resolution: new Oe(t),
  54808. texelSize: new Oe(e)
  54809. },
  54810. blending: fi,
  54811. depthWrite: !1,
  54812. depthTest: !1,
  54813. fragmentShader: RV,
  54814. vertexShader: BV
  54815. }),
  54816. (this.toneMapped = !1);
  54817. }
  54818. set inputBuffer(e) {
  54819. this.uniforms.inputBuffer.value = e;
  54820. }
  54821. setInputBuffer(e) {
  54822. this.uniforms.inputBuffer.value = e;
  54823. }
  54824. get searchTexture() {
  54825. return this.uniforms.searchTexture.value;
  54826. }
  54827. set searchTexture(e) {
  54828. this.uniforms.searchTexture.value = e;
  54829. }
  54830. get areaTexture() {
  54831. return this.uniforms.areaTexture.value;
  54832. }
  54833. set areaTexture(e) {
  54834. this.uniforms.areaTexture.value = e;
  54835. }
  54836. setLookupTextures(e, t) {
  54837. (this.searchTexture = e), (this.areaTexture = t);
  54838. }
  54839. get orthogonalSearchSteps() {
  54840. return Number(this.defines.MAX_SEARCH_STEPS_INT);
  54841. }
  54842. set orthogonalSearchSteps(e) {
  54843. let t = Math.min(Math.max(e, 0), 112);
  54844. (this.defines.MAX_SEARCH_STEPS_INT = t.toFixed('0')), (this.defines.MAX_SEARCH_STEPS_FLOAT = t.toFixed('1')), (this.needsUpdate = !0);
  54845. }
  54846. setOrthogonalSearchSteps(e) {
  54847. this.orthogonalSearchSteps = e;
  54848. }
  54849. get diagonalSearchSteps() {
  54850. return Number(this.defines.MAX_SEARCH_STEPS_DIAG_INT);
  54851. }
  54852. set diagonalSearchSteps(e) {
  54853. let t = Math.min(Math.max(e, 0), 20);
  54854. (this.defines.MAX_SEARCH_STEPS_DIAG_INT = t.toFixed('0')),
  54855. (this.defines.MAX_SEARCH_STEPS_DIAG_FLOAT = t.toFixed('1')),
  54856. (this.needsUpdate = !0);
  54857. }
  54858. setDiagonalSearchSteps(e) {
  54859. this.diagonalSearchSteps = e;
  54860. }
  54861. get diagonalDetection() {
  54862. return this.defines.DISABLE_DIAG_DETECTION === void 0;
  54863. }
  54864. set diagonalDetection(e) {
  54865. e ? delete this.defines.DISABLE_DIAG_DETECTION : (this.defines.DISABLE_DIAG_DETECTION = '1'), (this.needsUpdate = !0);
  54866. }
  54867. isDiagonalDetectionEnabled() {
  54868. return this.diagonalDetection;
  54869. }
  54870. setDiagonalDetectionEnabled(e) {
  54871. this.diagonalDetection = e;
  54872. }
  54873. get cornerRounding() {
  54874. return Number(this.defines.CORNER_ROUNDING);
  54875. }
  54876. set cornerRounding(e) {
  54877. let t = Math.min(Math.max(e, 0), 100);
  54878. (this.defines.CORNER_ROUNDING = t.toFixed('4')),
  54879. (this.defines.CORNER_ROUNDING_NORM = (t / 100).toFixed('4')),
  54880. (this.needsUpdate = !0);
  54881. }
  54882. setCornerRounding(e) {
  54883. this.cornerRounding = e;
  54884. }
  54885. get cornerDetection() {
  54886. return this.defines.DISABLE_CORNER_DETECTION === void 0;
  54887. }
  54888. set cornerDetection(e) {
  54889. e ? delete this.defines.DISABLE_CORNER_DETECTION : (this.defines.DISABLE_CORNER_DETECTION = '1'), (this.needsUpdate = !0);
  54890. }
  54891. isCornerRoundingEnabled() {
  54892. return this.cornerDetection;
  54893. }
  54894. setCornerRoundingEnabled(e) {
  54895. this.cornerDetection = e;
  54896. }
  54897. setSize(e, t) {
  54898. let i = this.uniforms;
  54899. i.texelSize.value.set(1 / e, 1 / t), i.resolution.value.set(e, t);
  54900. }
  54901. },
  54902. NV = new Yo(),
  54903. hn = null;
  54904. function UV() {
  54905. if (hn === null) {
  54906. let e = new Float32Array([-1, -1, 0, 3, -1, 0, -1, 3, 0]),
  54907. t = new Float32Array([0, 0, 2, 0, 0, 2]);
  54908. (hn = new Ve()),
  54909. hn.setAttribute !== void 0
  54910. ? (hn.setAttribute('position', new Xe(e, 3)), hn.setAttribute('uv', new Xe(t, 2)))
  54911. : (hn.addAttribute('position', new Xe(e, 3)), hn.addAttribute('uv', new Xe(t, 2)));
  54912. }
  54913. return hn;
  54914. }
  54915. var Tr = class {
  54916. constructor(e = 'Pass', t = new pa(), i = NV) {
  54917. (this.name = e),
  54918. (this.renderer = null),
  54919. (this.scene = t),
  54920. (this.camera = i),
  54921. (this.screen = null),
  54922. (this.rtt = !0),
  54923. (this.needsSwap = !0),
  54924. (this.needsDepthTexture = !1),
  54925. (this.enabled = !0);
  54926. }
  54927. get renderToScreen() {
  54928. return !this.rtt;
  54929. }
  54930. set renderToScreen(e) {
  54931. if (this.rtt === e) {
  54932. let t = this.getFullscreenMaterial();
  54933. t !== null && (t.needsUpdate = !0), (this.rtt = !e);
  54934. }
  54935. }
  54936. setRenderer(e) {
  54937. this.renderer = e;
  54938. }
  54939. isEnabled() {
  54940. return this.enabled;
  54941. }
  54942. setEnabled(e) {
  54943. this.enabled = e;
  54944. }
  54945. get fullscreenMaterial() {
  54946. return this.screen !== null ? this.screen.material : null;
  54947. }
  54948. set fullscreenMaterial(e) {
  54949. let t = this.screen;
  54950. t !== null
  54951. ? (t.material = e)
  54952. : ((t = new tr(UV(), e)),
  54953. (t.frustumCulled = !1),
  54954. this.scene === null && (this.scene = new pa()),
  54955. this.scene.add(t),
  54956. (this.screen = t));
  54957. }
  54958. getFullscreenMaterial() {
  54959. return this.fullscreenMaterial;
  54960. }
  54961. setFullscreenMaterial(e) {
  54962. this.fullscreenMaterial = e;
  54963. }
  54964. getDepthTexture() {
  54965. return null;
  54966. }
  54967. setDepthTexture(e, t = qs) {}
  54968. render(e, t, i, r, s) {
  54969. throw new Error('Render method not implemented!');
  54970. }
  54971. setSize(e, t) {}
  54972. initialize(e, t, i) {}
  54973. dispose() {
  54974. for (let e of Object.keys(this)) {
  54975. let t = this[e];
  54976. if (t !== null && typeof t.dispose == 'function') {
  54977. if (t instanceof pa || t === this.renderer) continue;
  54978. this[e].dispose();
  54979. }
  54980. }
  54981. }
  54982. },
  54983. nu = class extends Tr {
  54984. constructor(e, t = !0) {
  54985. super('CopyPass'),
  54986. (this.fullscreenMaterial = new SV()),
  54987. (this.needsSwap = !1),
  54988. (this.renderTarget = e),
  54989. e === void 0 &&
  54990. ((this.renderTarget = new ii(1, 1, { minFilter: mt, magFilter: mt, stencilBuffer: !1, depthBuffer: !1 })),
  54991. (this.renderTarget.texture.name = 'CopyPass.Target')),
  54992. (this.autoResize = t);
  54993. }
  54994. get resize() {
  54995. return this.autoResize;
  54996. }
  54997. set resize(e) {
  54998. this.autoResize = e;
  54999. }
  55000. get texture() {
  55001. return this.renderTarget.texture;
  55002. }
  55003. getTexture() {
  55004. return this.renderTarget.texture;
  55005. }
  55006. setAutoResizeEnabled(e) {
  55007. this.autoResize = e;
  55008. }
  55009. render(e, t, i, r, s) {
  55010. (this.fullscreenMaterial.inputBuffer = t.texture),
  55011. e.setRenderTarget(this.renderToScreen ? null : this.renderTarget),
  55012. e.render(this.scene, this.camera);
  55013. }
  55014. setSize(e, t) {
  55015. this.autoResize && this.renderTarget.setSize(e, t);
  55016. }
  55017. initialize(e, t, i) {
  55018. i !== void 0 &&
  55019. ((this.renderTarget.texture.type = i),
  55020. i !== Mi
  55021. ? (this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH = '1')
  55022. : e.outputEncoding === Ke && (this.renderTarget.texture.encoding = Ke));
  55023. }
  55024. },
  55025. FV = class extends Tr {
  55026. constructor() {
  55027. super('ClearMaskPass', null, null), (this.needsSwap = !1);
  55028. }
  55029. render(e, t, i, r, s) {
  55030. let n = e.state.buffers.stencil;
  55031. n.setLocked(!1), n.setTest(!1);
  55032. }
  55033. },
  55034. Pf = new Ge(),
  55035. Ou = class extends Tr {
  55036. constructor(e = !0, t = !0, i = !1) {
  55037. super('ClearPass', null, null),
  55038. (this.needsSwap = !1),
  55039. (this.color = e),
  55040. (this.depth = t),
  55041. (this.stencil = i),
  55042. (this.overrideClearColor = null),
  55043. (this.overrideClearAlpha = -1);
  55044. }
  55045. setClearFlags(e, t, i) {
  55046. (this.color = e), (this.depth = t), (this.stencil = i);
  55047. }
  55048. getOverrideClearColor() {
  55049. return this.overrideClearColor;
  55050. }
  55051. setOverrideClearColor(e) {
  55052. this.overrideClearColor = e;
  55053. }
  55054. getOverrideClearAlpha() {
  55055. return this.overrideClearAlpha;
  55056. }
  55057. setOverrideClearAlpha(e) {
  55058. this.overrideClearAlpha = e;
  55059. }
  55060. render(e, t, i, r, s) {
  55061. let n = this.overrideClearColor,
  55062. a = this.overrideClearAlpha,
  55063. o = e.getClearAlpha(),
  55064. l = n !== null,
  55065. h = a >= 0;
  55066. l ? (Pf.copy(e.getClearColor(Pf)), e.setClearColor(n, h ? a : o)) : h && e.setClearAlpha(a),
  55067. e.setRenderTarget(this.renderToScreen ? null : t),
  55068. e.clear(this.color, this.depth, this.stencil),
  55069. l ? e.setClearColor(Pf, o) : h && e.setClearAlpha(o);
  55070. }
  55071. },
  55072. cn = -1,
  55073. Fi = class extends Vi {
  55074. constructor(e, t = cn, i = cn, r = 1) {
  55075. super(),
  55076. (this.resizable = e),
  55077. (this.base = new G(1, 1)),
  55078. (this.preferred = new G(t, i)),
  55079. (this.target = this.preferred),
  55080. (this.s = r);
  55081. }
  55082. get width() {
  55083. let { base: e, preferred: t, scale: i } = this,
  55084. r;
  55085. return (
  55086. t.width !== cn
  55087. ? (r = t.width)
  55088. : t.height !== cn
  55089. ? (r = Math.round(t.height * (e.width / Math.max(e.height, 1))))
  55090. : (r = Math.round(e.width * i)),
  55091. r
  55092. );
  55093. }
  55094. set width(e) {
  55095. this.preferredWidth = e;
  55096. }
  55097. get height() {
  55098. let { base: e, preferred: t, scale: i } = this,
  55099. r;
  55100. return (
  55101. t.height !== cn
  55102. ? (r = t.height)
  55103. : t.width !== cn
  55104. ? (r = Math.round(t.width / Math.max(e.width / Math.max(e.height, 1), 1)))
  55105. : (r = Math.round(e.height * i)),
  55106. r
  55107. );
  55108. }
  55109. set height(e) {
  55110. this.preferredHeight = e;
  55111. }
  55112. getWidth() {
  55113. return this.width;
  55114. }
  55115. getHeight() {
  55116. return this.height;
  55117. }
  55118. get scale() {
  55119. return this.s;
  55120. }
  55121. set scale(e) {
  55122. this.s !== e &&
  55123. ((this.s = e),
  55124. this.preferred.setScalar(cn),
  55125. this.dispatchEvent({ type: 'change' }),
  55126. this.resizable.setSize(this.base.width, this.base.height));
  55127. }
  55128. getScale() {
  55129. return this.scale;
  55130. }
  55131. setScale(e) {
  55132. this.scale = e;
  55133. }
  55134. get baseWidth() {
  55135. return this.base.width;
  55136. }
  55137. set baseWidth(e) {
  55138. this.base.width !== e &&
  55139. ((this.base.width = e), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height));
  55140. }
  55141. getBaseWidth() {
  55142. return this.base.width;
  55143. }
  55144. setBaseWidth(e) {
  55145. this.base.width !== e &&
  55146. ((this.base.width = e), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height));
  55147. }
  55148. get baseHeight() {
  55149. return this.base.height;
  55150. }
  55151. set baseHeight(e) {
  55152. this.base.height !== e &&
  55153. ((this.base.height = e), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height));
  55154. }
  55155. getBaseHeight() {
  55156. return this.baseHeight;
  55157. }
  55158. setBaseHeight(e) {
  55159. this.baseHeight = e;
  55160. }
  55161. setBaseSize(e, t) {
  55162. (this.base.width !== e || this.base.height !== t) &&
  55163. (this.base.set(e, t), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height));
  55164. }
  55165. get preferredWidth() {
  55166. return this.preferred.width;
  55167. }
  55168. set preferredWidth(e) {
  55169. this.preferred.width !== e &&
  55170. ((this.preferred.width = e), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height));
  55171. }
  55172. getPreferredWidth() {
  55173. return this.preferredWidth;
  55174. }
  55175. setPreferredWidth(e) {
  55176. this.preferredWidth = e;
  55177. }
  55178. get preferredHeight() {
  55179. return this.preferred.height;
  55180. }
  55181. set preferredHeight(e) {
  55182. this.preferred.height !== e &&
  55183. ((this.preferred.height = e), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height));
  55184. }
  55185. getPreferredHeight() {
  55186. return this.preferredHeight;
  55187. }
  55188. setPreferredHeight(e) {
  55189. this.preferredHeight = e;
  55190. }
  55191. setPreferredSize(e, t) {
  55192. (this.preferred.width !== e || this.preferred.height !== t) &&
  55193. (this.preferred.set(e, t), this.dispatchEvent({ type: 'change' }), this.resizable.setSize(this.base.width, this.base.height));
  55194. }
  55195. copy(e) {
  55196. this.base.set(e.getBaseWidth(), e.getBaseHeight()),
  55197. this.preferred.set(e.getPreferredWidth(), e.getPreferredHeight()),
  55198. this.dispatchEvent({ type: 'change' }),
  55199. this.resizable.setSize(this.base.width, this.base.height);
  55200. }
  55201. static get AUTO_SIZE() {
  55202. return cn;
  55203. }
  55204. },
  55205. Df = !1,
  55206. Qb = class {
  55207. constructor(e = null) {
  55208. (this.originalMaterials = new Map()),
  55209. (this.material = null),
  55210. (this.materials = null),
  55211. (this.materialsBackSide = null),
  55212. (this.materialsDoubleSide = null),
  55213. (this.materialsFlatShaded = null),
  55214. (this.materialsFlatShadedBackSide = null),
  55215. (this.materialsFlatShadedDoubleSide = null),
  55216. this.setMaterial(e),
  55217. (this.meshCount = 0),
  55218. (this.replaceMaterial = (t) => {
  55219. if (t.isMesh) {
  55220. let i;
  55221. if (t.material.flatShading)
  55222. switch (t.material.side) {
  55223. case er:
  55224. i = this.materialsFlatShadedDoubleSide;
  55225. break;
  55226. case hi:
  55227. i = this.materialsFlatShadedBackSide;
  55228. break;
  55229. default:
  55230. i = this.materialsFlatShaded;
  55231. break;
  55232. }
  55233. else
  55234. switch (t.material.side) {
  55235. case er:
  55236. i = this.materialsDoubleSide;
  55237. break;
  55238. case hi:
  55239. i = this.materialsBackSide;
  55240. break;
  55241. default:
  55242. i = this.materials;
  55243. break;
  55244. }
  55245. this.originalMaterials.set(t, t.material),
  55246. t.isSkinnedMesh ? (t.material = i[2]) : t.isInstancedMesh ? (t.material = i[1]) : (t.material = i[0]),
  55247. ++this.meshCount;
  55248. }
  55249. });
  55250. }
  55251. setMaterial(e) {
  55252. if ((this.disposeMaterials(), (this.material = e), e !== null)) {
  55253. let t = (this.materials = [e.clone(), e.clone(), e.clone()]);
  55254. for (let i of t) (i.uniforms = Object.assign({}, e.uniforms)), (i.side = Vr);
  55255. (t[2].skinning = !0),
  55256. (this.materialsBackSide = t.map((i) => {
  55257. let r = i.clone();
  55258. return (r.uniforms = Object.assign({}, e.uniforms)), (r.side = hi), r;
  55259. })),
  55260. (this.materialsDoubleSide = t.map((i) => {
  55261. let r = i.clone();
  55262. return (r.uniforms = Object.assign({}, e.uniforms)), (r.side = er), r;
  55263. })),
  55264. (this.materialsFlatShaded = t.map((i) => {
  55265. let r = i.clone();
  55266. return (r.uniforms = Object.assign({}, e.uniforms)), (r.flatShading = !0), r;
  55267. })),
  55268. (this.materialsFlatShadedBackSide = t.map((i) => {
  55269. let r = i.clone();
  55270. return (r.uniforms = Object.assign({}, e.uniforms)), (r.flatShading = !0), (r.side = hi), r;
  55271. })),
  55272. (this.materialsFlatShadedDoubleSide = t.map((i) => {
  55273. let r = i.clone();
  55274. return (r.uniforms = Object.assign({}, e.uniforms)), (r.flatShading = !0), (r.side = er), r;
  55275. }));
  55276. }
  55277. }
  55278. render(e, t, i) {
  55279. let r = e.shadowMap.enabled;
  55280. if (((e.shadowMap.enabled = !1), Df)) {
  55281. let s = this.originalMaterials;
  55282. (this.meshCount = 0), t.traverse(this.replaceMaterial), e.render(t, i);
  55283. for (let n of s) n[0].material = n[1];
  55284. this.meshCount !== s.size && s.clear();
  55285. } else {
  55286. let s = t.overrideMaterial;
  55287. (t.overrideMaterial = this.material), e.render(t, i), (t.overrideMaterial = s);
  55288. }
  55289. e.shadowMap.enabled = r;
  55290. }
  55291. disposeMaterials() {
  55292. if (this.material !== null) {
  55293. let e = this.materials
  55294. .concat(this.materialsBackSide)
  55295. .concat(this.materialsDoubleSide)
  55296. .concat(this.materialsFlatShaded)
  55297. .concat(this.materialsFlatShadedBackSide)
  55298. .concat(this.materialsFlatShadedDoubleSide);
  55299. for (let t of e) t.dispose();
  55300. }
  55301. }
  55302. dispose() {
  55303. this.originalMaterials.clear(), this.disposeMaterials();
  55304. }
  55305. static get workaroundEnabled() {
  55306. return Df;
  55307. }
  55308. static set workaroundEnabled(e) {
  55309. Df = e;
  55310. }
  55311. },
  55312. kV = class extends Tr {
  55313. constructor(e, t, i = null) {
  55314. super('RenderPass', e, t),
  55315. (this.needsSwap = !1),
  55316. (this.clearPass = new Ou()),
  55317. (this.overrideMaterialManager = i === null ? null : new Qb(i)),
  55318. (this.ignoreBackground = !1),
  55319. (this.skipShadowMapUpdate = !1),
  55320. (this.selection = null);
  55321. }
  55322. get renderToScreen() {
  55323. return super.renderToScreen;
  55324. }
  55325. set renderToScreen(e) {
  55326. (super.renderToScreen = e), (this.clearPass.renderToScreen = e);
  55327. }
  55328. get overrideMaterial() {
  55329. let e = this.overrideMaterialManager;
  55330. return e !== null ? e.material : null;
  55331. }
  55332. set overrideMaterial(e) {
  55333. let t = this.overrideMaterialManager;
  55334. e !== null
  55335. ? t !== null
  55336. ? t.setMaterial(e)
  55337. : (this.overrideMaterialManager = new Qb(e))
  55338. : t !== null && (t.dispose(), (this.overrideMaterialManager = null));
  55339. }
  55340. getOverrideMaterial() {
  55341. return this.overrideMaterial;
  55342. }
  55343. setOverrideMaterial(e) {
  55344. this.overrideMaterial = e;
  55345. }
  55346. get clear() {
  55347. return this.clearPass.enabled;
  55348. }
  55349. set clear(e) {
  55350. this.clearPass.enabled = e;
  55351. }
  55352. getSelection() {
  55353. return this.selection;
  55354. }
  55355. setSelection(e) {
  55356. this.selection = e;
  55357. }
  55358. isBackgroundDisabled() {
  55359. return this.ignoreBackground;
  55360. }
  55361. setBackgroundDisabled(e) {
  55362. this.ignoreBackground = e;
  55363. }
  55364. isShadowMapDisabled() {
  55365. return this.skipShadowMapUpdate;
  55366. }
  55367. setShadowMapDisabled(e) {
  55368. this.skipShadowMapUpdate = e;
  55369. }
  55370. getClearPass() {
  55371. return this.clearPass;
  55372. }
  55373. render(e, t, i, r, s) {
  55374. let n = this.scene,
  55375. a = this.camera,
  55376. o = this.selection,
  55377. l = a.layers.mask,
  55378. h = n.background,
  55379. u = e.shadowMap.autoUpdate,
  55380. c = this.renderToScreen ? null : t;
  55381. o !== null && a.layers.set(o.getLayer()),
  55382. this.skipShadowMapUpdate && (e.shadowMap.autoUpdate = !1),
  55383. (this.ignoreBackground || this.clearPass.overrideClearColor !== null) && (n.background = null),
  55384. this.clearPass.enabled && this.clearPass.render(e, t),
  55385. e.setRenderTarget(c),
  55386. this.overrideMaterialManager !== null ? this.overrideMaterialManager.render(e, n, a) : e.render(n, a),
  55387. (a.layers.mask = l),
  55388. (n.background = h),
  55389. (e.shadowMap.autoUpdate = u);
  55390. }
  55391. },
  55392. Zb = class extends Tr {
  55393. constructor(e, t, { resolutionScale: i = 1, width: r = Fi.AUTO_SIZE, height: s = Fi.AUTO_SIZE, renderTarget: n } = {}) {
  55394. super('DepthPass'), (this.needsSwap = !1), (this.renderPass = new kV(e, t, new Aw({ depthPacking: cw })));
  55395. let a = this.renderPass;
  55396. (a.skipShadowMapUpdate = !0), (a.ignoreBackground = !0);
  55397. let o = a.getClearPass();
  55398. (o.overrideClearColor = new Ge(16777215)),
  55399. (o.overrideClearAlpha = 1),
  55400. (this.renderTarget = n),
  55401. this.renderTarget === void 0 &&
  55402. ((this.renderTarget = new ii(1, 1, { minFilter: Ot, magFilter: Ot, stencilBuffer: !1 })),
  55403. (this.renderTarget.texture.name = 'DepthPass.Target'));
  55404. let l = (this.resolution = new Fi(this, r, s, i));
  55405. l.addEventListener('change', (h) => this.setSize(l.baseWidth, l.baseHeight));
  55406. }
  55407. get texture() {
  55408. return this.renderTarget.texture;
  55409. }
  55410. getTexture() {
  55411. return this.renderTarget.texture;
  55412. }
  55413. getResolution() {
  55414. return this.resolution;
  55415. }
  55416. getResolutionScale() {
  55417. return this.resolution.scale;
  55418. }
  55419. setResolutionScale(e) {
  55420. this.resolution.scale = e;
  55421. }
  55422. render(e, t, i, r, s) {
  55423. let n = this.renderToScreen ? null : this.renderTarget;
  55424. this.renderPass.render(e, n);
  55425. }
  55426. setSize(e, t) {
  55427. let i = this.resolution;
  55428. i.setBaseSize(e, t), this.renderTarget.setSize(i.width, i.height);
  55429. }
  55430. },
  55431. F9 = new Float32Array([255 / 256 / 256 ** 3, 255 / 256 / 256 ** 2, 255 / 256 / 256, 255 / 256]),
  55432. nt = {
  55433. SKIP: 0,
  55434. ADD: 1,
  55435. ALPHA: 2,
  55436. AVERAGE: 3,
  55437. COLOR_BURN: 4,
  55438. COLOR_DODGE: 5,
  55439. DARKEN: 6,
  55440. DIFFERENCE: 7,
  55441. EXCLUSION: 8,
  55442. LIGHTEN: 9,
  55443. MULTIPLY: 10,
  55444. DIVIDE: 11,
  55445. NEGATION: 12,
  55446. NORMAL: 13,
  55447. OVERLAY: 14,
  55448. REFLECT: 15,
  55449. SCREEN: 16,
  55450. SOFT_LIGHT: 17,
  55451. SUBTRACT: 18
  55452. },
  55453. jV = '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);}',
  55454. GV =
  55455. '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));}',
  55456. VV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}',
  55457. HV =
  55458. '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);}',
  55459. WV =
  55460. '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);}',
  55461. XV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}',
  55462. qV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}',
  55463. YV = '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);}',
  55464. QV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}',
  55465. ZV = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}',
  55466. KV =
  55467. '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);}',
  55468. JV = '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);}',
  55469. $V = 'vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}',
  55470. eH =
  55471. '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);}',
  55472. tH =
  55473. '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);}',
  55474. iH = '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);}',
  55475. rH =
  55476. '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);}',
  55477. sH = '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);}',
  55478. nH = new Map([
  55479. [nt.SKIP, null],
  55480. [nt.ADD, jV],
  55481. [nt.ALPHA, GV],
  55482. [nt.AVERAGE, VV],
  55483. [nt.COLOR_BURN, HV],
  55484. [nt.COLOR_DODGE, WV],
  55485. [nt.DARKEN, XV],
  55486. [nt.DIFFERENCE, qV],
  55487. [nt.EXCLUSION, YV],
  55488. [nt.LIGHTEN, QV],
  55489. [nt.MULTIPLY, ZV],
  55490. [nt.DIVIDE, KV],
  55491. [nt.NEGATION, JV],
  55492. [nt.NORMAL, $V],
  55493. [nt.OVERLAY, eH],
  55494. [nt.REFLECT, tH],
  55495. [nt.SCREEN, iH],
  55496. [nt.SOFT_LIGHT, rH],
  55497. [nt.SUBTRACT, sH]
  55498. ]),
  55499. aH = class extends Vi {
  55500. constructor(e, t = 1) {
  55501. super(), (this.f = e), (this.opacity = new Oe(t));
  55502. }
  55503. getOpacity() {
  55504. return this.opacity.value;
  55505. }
  55506. setOpacity(e) {
  55507. this.opacity.value = e;
  55508. }
  55509. get blendFunction() {
  55510. return this.f;
  55511. }
  55512. set blendFunction(e) {
  55513. (this.f = e), this.dispatchEvent({ type: 'change' });
  55514. }
  55515. getBlendFunction() {
  55516. return this.blendFunction;
  55517. }
  55518. setBlendFunction(e) {
  55519. this.blendFunction = e;
  55520. }
  55521. getShaderCode() {
  55522. return nH.get(this.blendFunction);
  55523. }
  55524. },
  55525. ms = { NONE: 0, DEPTH: 1, CONVOLUTION: 2 },
  55526. Ss = class extends Vi {
  55527. constructor(
  55528. e,
  55529. t,
  55530. {
  55531. attributes: i = ms.NONE,
  55532. blendFunction: r = nt.SCREEN,
  55533. defines: s = new Map(),
  55534. uniforms: n = new Map(),
  55535. extensions: a = null,
  55536. vertexShader: o = null
  55537. } = {}
  55538. ) {
  55539. super(),
  55540. (this.name = e),
  55541. (this.renderer = null),
  55542. (this.attributes = i),
  55543. (this.fragmentShader = t),
  55544. (this.vertexShader = o),
  55545. (this.defines = s),
  55546. (this.uniforms = n),
  55547. (this.extensions = a),
  55548. (this.blendMode = new aH(r)),
  55549. this.blendMode.addEventListener('change', (l) => this.setChanged());
  55550. }
  55551. getName() {
  55552. return this.name;
  55553. }
  55554. setRenderer(e) {
  55555. this.renderer = e;
  55556. }
  55557. getDefines() {
  55558. return this.defines;
  55559. }
  55560. getUniforms() {
  55561. return this.uniforms;
  55562. }
  55563. getExtensions() {
  55564. return this.extensions;
  55565. }
  55566. getBlendMode() {
  55567. return this.blendMode;
  55568. }
  55569. getAttributes() {
  55570. return this.attributes;
  55571. }
  55572. setAttributes(e) {
  55573. (this.attributes = e), this.setChanged();
  55574. }
  55575. getFragmentShader() {
  55576. return this.fragmentShader;
  55577. }
  55578. setFragmentShader(e) {
  55579. (this.fragmentShader = e), this.setChanged();
  55580. }
  55581. getVertexShader() {
  55582. return this.vertexShader;
  55583. }
  55584. setVertexShader(e) {
  55585. (this.vertexShader = e), this.setChanged();
  55586. }
  55587. setChanged() {
  55588. this.dispatchEvent({ type: 'change' });
  55589. }
  55590. setDepthTexture(e, t = qs) {}
  55591. update(e, t, i) {}
  55592. setSize(e, t) {}
  55593. initialize(e, t, i) {}
  55594. dispose() {
  55595. for (let e of Object.keys(this)) {
  55596. let t = this[e];
  55597. if (t !== null && typeof t.dispose == 'function') {
  55598. if (t instanceof pa || t === this.renderer) continue;
  55599. this[e].dispose();
  55600. }
  55601. }
  55602. }
  55603. };
  55604. function Kb(e, t, i) {
  55605. for (let r of t) {
  55606. let s = '$1' + e + r.charAt(0).toUpperCase() + r.slice(1),
  55607. n = new RegExp('([^\\.])(\\b' + r + '\\b)', 'g');
  55608. for (let a of i.entries()) a[1] !== null && i.set(a[0], a[1].replace(n, s));
  55609. }
  55610. }
  55611. function oH(e, t, i, r, s, n, a) {
  55612. let o = new Map([
  55613. ['fragment', t.getFragmentShader()],
  55614. ['vertex', t.getVertexShader()]
  55615. ]),
  55616. l = o.get('fragment') !== void 0 && /mainImage/.test(o.get('fragment')),
  55617. h = o.get('fragment') !== void 0 && /mainUv/.test(o.get('fragment')),
  55618. u = [],
  55619. c = [],
  55620. d = !1,
  55621. p = !1;
  55622. if (o.get('fragment') === void 0) console.error('Missing fragment shader', t);
  55623. else if (h && (a & ms.CONVOLUTION) !== 0)
  55624. console.error('Effects that transform UV coordinates are incompatible with convolution effects', t);
  55625. else if (!l && !h) console.error('The fragment shader contains neither a mainImage nor a mainUv function', t);
  55626. else {
  55627. let f = /(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g,
  55628. g = ng.Section;
  55629. if (h) {
  55630. let v = ` ${e}MainUv(UV);
  55631. `;
  55632. i.set(g.FRAGMENT_MAIN_UV, i.get(g.FRAGMENT_MAIN_UV) + v), (d = !0);
  55633. }
  55634. if (o.get('vertex') !== null && /mainSupport/.test(o.get('vertex'))) {
  55635. let v = ` ${e}MainSupport(`;
  55636. (v += /mainSupport *\([\w\s]*?uv\s*?\)/.test(o.get('vertex'))
  55637. ? `vUv);
  55638. `
  55639. : `);
  55640. `),
  55641. i.set(g.VERTEX_MAIN_SUPPORT, i.get(g.VERTEX_MAIN_SUPPORT) + v),
  55642. (u = u.concat([...o.get('vertex').matchAll(/(?:varying\s+\w+\s+(\w*))/g)].map((y) => y[1]))),
  55643. (c = c.concat(u).concat([...o.get('vertex').matchAll(f)].map((y) => y[1])));
  55644. }
  55645. (c = c.concat([...o.get('fragment').matchAll(f)].map((v) => v[1]))),
  55646. (c = c.concat([...t.defines.keys()].map((v) => v.replace(/\([\w\s,]*\)/g, '')))),
  55647. (c = c.concat([...t.uniforms.keys()])),
  55648. t.uniforms.forEach((v, y) => n.set(e + y.charAt(0).toUpperCase() + y.slice(1), v)),
  55649. t.defines.forEach((v, y) => s.set(e + y.charAt(0).toUpperCase() + y.slice(1), v)),
  55650. Kb(e, c, s),
  55651. Kb(e, c, o);
  55652. let m = t.blendMode;
  55653. if ((r.set(m.blendFunction, m), l)) {
  55654. let v = /MainImage *\([\w\s,]*?depth[\w\s,]*?\)/,
  55655. y = `${e}MainImage(color0, UV, `;
  55656. (a & ms.DEPTH) !== 0 && v.test(o.get('fragment')) && ((y += 'depth, '), (p = !0)),
  55657. (y += `color1);
  55658. `);
  55659. let b = e + 'BlendOpacity';
  55660. n.set(b, m.opacity),
  55661. (y += `color0 = blend${m.blendFunction}(color0, color1, ${b});
  55662. `),
  55663. i.set(g.FRAGMENT_MAIN_IMAGE, i.get(g.FRAGMENT_MAIN_IMAGE) + y),
  55664. (y = `uniform float ${b};
  55665. `),
  55666. i.set(g.FRAGMENT_HEAD, i.get(g.FRAGMENT_HEAD) + y);
  55667. }
  55668. i.set(
  55669. g.FRAGMENT_HEAD,
  55670. i.get(g.FRAGMENT_HEAD) +
  55671. o.get('fragment') +
  55672. `
  55673. `
  55674. ),
  55675. o.get('vertex') !== null &&
  55676. i.set(
  55677. g.VERTEX_HEAD,
  55678. i.get(g.VERTEX_HEAD) +
  55679. o.get('vertex') +
  55680. `
  55681. `
  55682. );
  55683. }
  55684. return { varyings: u, transformedUv: d, readDepth: p };
  55685. }
  55686. var Lf = class extends Tr {
  55687. constructor(e, ...t) {
  55688. super('EffectPass'),
  55689. (this.fullscreenMaterial = new ng(null, null, null, e)),
  55690. (this.effects = t.sort((i, r) => r.attributes - i.attributes)),
  55691. (this.skipRendering = !1),
  55692. (this.uniformCount = 0),
  55693. (this.varyingCount = 0),
  55694. (this.minTime = 1),
  55695. (this.maxTime = Number.POSITIVE_INFINITY);
  55696. }
  55697. get encodeOutput() {
  55698. return this.fullscreenMaterial.encodeOutput;
  55699. }
  55700. set encodeOutput(e) {
  55701. this.fullscreenMaterial.encodeOutput = e;
  55702. }
  55703. get dithering() {
  55704. return this.fullscreenMaterial.dithering;
  55705. }
  55706. set dithering(e) {
  55707. let t = this.fullscreenMaterial;
  55708. (t.dithering = e), (t.needsUpdate = !0);
  55709. }
  55710. verifyResources() {
  55711. let e = this.renderer.capabilities,
  55712. t = Math.min(e.maxFragmentUniforms, e.maxVertexUniforms);
  55713. this.uniformCount > t &&
  55714. console.warn(
  55715. "The current rendering context doesn't support more than " + t + ' uniforms, but ' + this.uniformCount + ' were defined'
  55716. ),
  55717. (t = e.maxVaryings),
  55718. this.varyingCount > t &&
  55719. console.warn(
  55720. "The current rendering context doesn't support more than " + t + ' varyings, but ' + this.varyingCount + ' were defined'
  55721. );
  55722. }
  55723. updateMaterial() {
  55724. let e = ng.Section,
  55725. t = new Map([
  55726. [e.FRAGMENT_HEAD, ''],
  55727. [e.FRAGMENT_MAIN_UV, ''],
  55728. [e.FRAGMENT_MAIN_IMAGE, ''],
  55729. [e.VERTEX_HEAD, ''],
  55730. [e.VERTEX_MAIN_SUPPORT, '']
  55731. ]),
  55732. i = new Map(),
  55733. r = new Map(),
  55734. s = new Map(),
  55735. n = new Set(),
  55736. a = 0,
  55737. o = 0,
  55738. l = 0,
  55739. h = !1,
  55740. u = !1;
  55741. for (let d of this.effects)
  55742. if (d.blendMode.blendFunction === nt.SKIP) l |= d.getAttributes() & ms.DEPTH;
  55743. else if ((l & d.getAttributes() & ms.CONVOLUTION) !== 0) console.error('Convolution effects cannot be merged', d);
  55744. else {
  55745. l |= d.getAttributes();
  55746. let p = 'e' + a++,
  55747. f = oH(p, d, t, i, r, s, l);
  55748. if (((o += f.varyings.length), (h = h || f.transformedUv), (u = u || f.readDepth), d.extensions !== null))
  55749. for (let g of d.extensions) n.add(g);
  55750. }
  55751. let c = /\bblend\b/g;
  55752. for (let d of i.values()) {
  55753. let p = d.getShaderCode().replace(c, `blend${d.blendFunction}`);
  55754. t.set(
  55755. e.FRAGMENT_HEAD,
  55756. t.get(e.FRAGMENT_HEAD) +
  55757. p +
  55758. `
  55759. `
  55760. );
  55761. }
  55762. if ((l & ms.DEPTH) !== 0) {
  55763. if (u) {
  55764. let d = `float depth = readDepth(UV);
  55765. `;
  55766. t.set(e.FRAGMENT_MAIN_IMAGE, d + t.get(e.FRAGMENT_MAIN_IMAGE));
  55767. }
  55768. this.needsDepthTexture = this.getDepthTexture() === null;
  55769. } else this.needsDepthTexture = !1;
  55770. if (h) {
  55771. let d = `vec2 transformedUv = vUv;
  55772. `;
  55773. t.set(e.FRAGMENT_MAIN_UV, d + t.get(e.FRAGMENT_MAIN_UV)), r.set('UV', 'transformedUv');
  55774. } else r.set('UV', 'vUv');
  55775. t.forEach((d, p, f) =>
  55776. f.set(
  55777. p,
  55778. d.trim().replace(
  55779. /^#/,
  55780. `
  55781. #`
  55782. )
  55783. )
  55784. ),
  55785. (this.uniformCount = s.size),
  55786. (this.varyingCount = o),
  55787. (this.skipRendering = a === 0),
  55788. (this.needsSwap = !this.skipRendering),
  55789. this.fullscreenMaterial.setShaderParts(t).setExtensions(n).setUniforms(s).setDefines(r);
  55790. }
  55791. recompile() {
  55792. this.updateMaterial(), this.verifyResources();
  55793. }
  55794. getDepthTexture() {
  55795. return this.fullscreenMaterial.depthBuffer;
  55796. }
  55797. setDepthTexture(e, t = qs) {
  55798. (this.fullscreenMaterial.depthBuffer = e), (this.fullscreenMaterial.depthPacking = t);
  55799. for (let i of this.effects) i.setDepthTexture(e, t);
  55800. }
  55801. render(e, t, i, r, s) {
  55802. for (let n of this.effects) n.update(e, t, r);
  55803. if (!this.skipRendering || this.renderToScreen) {
  55804. let n = this.fullscreenMaterial;
  55805. (n.inputBuffer = t.texture), (n.time += r), e.setRenderTarget(this.renderToScreen ? null : i), e.render(this.scene, this.camera);
  55806. }
  55807. }
  55808. setSize(e, t) {
  55809. this.fullscreenMaterial.setSize(e, t);
  55810. for (let i of this.effects) i.setSize(e, t);
  55811. }
  55812. initialize(e, t, i) {
  55813. this.renderer = e;
  55814. for (let r of this.effects) r.initialize(e, t, i), r.addEventListener('change', (s) => this.handleEvent(s));
  55815. this.updateMaterial(),
  55816. this.verifyResources(),
  55817. i !== void 0 && i !== Mi && (this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH = '1');
  55818. }
  55819. dispose() {
  55820. super.dispose();
  55821. for (let e of this.effects) e.dispose();
  55822. }
  55823. handleEvent(e) {
  55824. switch (e.type) {
  55825. case 'change':
  55826. this.recompile();
  55827. break;
  55828. }
  55829. }
  55830. },
  55831. lH = [
  55832. new Float32Array([0, 0]),
  55833. new Float32Array([0, 1, 1]),
  55834. new Float32Array([0, 1, 1, 2]),
  55835. new Float32Array([0, 1, 2, 2, 3]),
  55836. new Float32Array([0, 1, 2, 3, 4, 4, 5]),
  55837. new Float32Array([0, 1, 2, 3, 4, 5, 7, 8, 9, 10])
  55838. ],
  55839. u2 = class extends Tr {
  55840. constructor({ resolutionScale: e = 0.5, width: t = Fi.AUTO_SIZE, height: i = Fi.AUTO_SIZE, kernelSize: r = Ov.LARGE } = {}) {
  55841. super('KawaseBlurPass'),
  55842. (this.renderTargetA = new ii(1, 1, { minFilter: mt, magFilter: mt, stencilBuffer: !1, depthBuffer: !1 })),
  55843. (this.renderTargetA.texture.name = 'Blur.Target.A'),
  55844. (this.renderTargetB = this.renderTargetA.clone()),
  55845. (this.renderTargetB.texture.name = 'Blur.Target.B');
  55846. let s = (this.resolution = new Fi(this, t, i, e));
  55847. s.addEventListener('change', (n) => this.setSize(s.baseWidth, s.baseHeight)),
  55848. (this.blurMaterial = new Yb()),
  55849. (this.ditheredBlurMaterial = new Yb()),
  55850. (this.ditheredBlurMaterial.uniforms.scale = this.blurMaterial.uniforms.scale),
  55851. (this.ditheredBlurMaterial.dithering = !0),
  55852. (this.dithering = !1),
  55853. (this.kernelSize = r);
  55854. }
  55855. getResolution() {
  55856. return this.resolution;
  55857. }
  55858. get width() {
  55859. return this.resolution.width;
  55860. }
  55861. set width(e) {
  55862. this.resolution.preferredWidth = e;
  55863. }
  55864. get height() {
  55865. return this.resolution.height;
  55866. }
  55867. set height(e) {
  55868. this.resolution.preferredHeight = e;
  55869. }
  55870. get scale() {
  55871. return this.blurMaterial.scale;
  55872. }
  55873. set scale(e) {
  55874. this.blurMaterial.scale = e;
  55875. }
  55876. getScale() {
  55877. return this.blurMaterial.scale;
  55878. }
  55879. setScale(e) {
  55880. this.blurMaterial.scale = e;
  55881. }
  55882. getKernelSize() {
  55883. return this.kernelSize;
  55884. }
  55885. setKernelSize(e) {
  55886. this.kernelSize = e;
  55887. }
  55888. getResolutionScale() {
  55889. return this.resolution.scale;
  55890. }
  55891. setResolutionScale(e) {
  55892. this.resolution.scale = e;
  55893. }
  55894. render(e, t, i, r, s) {
  55895. let n = this.scene,
  55896. a = this.camera,
  55897. o = this.renderTargetA,
  55898. l = this.renderTargetB,
  55899. h = lH[this.kernelSize],
  55900. u = this.blurMaterial,
  55901. c = t,
  55902. d,
  55903. p;
  55904. for (this.fullscreenMaterial = u, d = 0, p = h.length - 1; d < p; ++d) {
  55905. let f = (d & 1) === 0 ? o : l;
  55906. (u.kernel = h[d]), (u.inputBuffer = c.texture), e.setRenderTarget(f), e.render(n, a), (c = f);
  55907. }
  55908. this.dithering && ((u = this.ditheredBlurMaterial), (this.fullscreenMaterial = u)),
  55909. (u.kernel = h[d]),
  55910. (u.inputBuffer = c.texture),
  55911. e.setRenderTarget(this.renderToScreen ? null : i),
  55912. e.render(n, a);
  55913. }
  55914. setSize(e, t) {
  55915. let i = this.resolution;
  55916. i.setBaseSize(e, t);
  55917. let r = i.width,
  55918. s = i.height;
  55919. this.renderTargetA.setSize(r, s),
  55920. this.renderTargetB.setSize(r, s),
  55921. this.blurMaterial.setSize(r, s),
  55922. this.ditheredBlurMaterial.setSize(r, s);
  55923. }
  55924. initialize(e, t, i) {
  55925. i !== void 0 &&
  55926. ((this.renderTargetA.texture.type = i),
  55927. (this.renderTargetB.texture.type = i),
  55928. i !== Mi
  55929. ? ((this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH = '1'),
  55930. (this.ditheredBlurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH = '1'))
  55931. : e.outputEncoding === Ke && ((this.renderTargetA.texture.encoding = Ke), (this.renderTargetB.texture.encoding = Ke)));
  55932. }
  55933. static get AUTO_SIZE() {
  55934. return Fi.AUTO_SIZE;
  55935. }
  55936. },
  55937. hH = class extends Tr {
  55938. constructor({ width: e = Fi.AUTO_SIZE, height: t = Fi.AUTO_SIZE, renderTarget: i, luminanceRange: r, colorOutput: s } = {}) {
  55939. super('LuminancePass'),
  55940. (this.fullscreenMaterial = new LV(s, r)),
  55941. (this.needsSwap = !1),
  55942. (this.renderTarget = i),
  55943. this.renderTarget === void 0 &&
  55944. ((this.renderTarget = new ii(1, 1, { minFilter: mt, magFilter: mt, stencilBuffer: !1, depthBuffer: !1 })),
  55945. (this.renderTarget.texture.name = 'LuminancePass.Target'),
  55946. (this.renderTarget.texture.generateMipmaps = !1));
  55947. let n = (this.resolution = new Fi(this, e, t));
  55948. n.addEventListener('change', (a) => this.setSize(n.baseWidth, n.baseHeight));
  55949. }
  55950. get texture() {
  55951. return this.renderTarget.texture;
  55952. }
  55953. getTexture() {
  55954. return this.renderTarget.texture;
  55955. }
  55956. getResolution() {
  55957. return this.resolution;
  55958. }
  55959. render(e, t, i, r, s) {
  55960. let n = this.fullscreenMaterial;
  55961. (n.inputBuffer = t.texture), e.setRenderTarget(this.renderToScreen ? null : this.renderTarget), e.render(this.scene, this.camera);
  55962. }
  55963. setSize(e, t) {
  55964. let i = this.resolution;
  55965. i.setBaseSize(e, t), this.renderTarget.setSize(i.width, i.height);
  55966. }
  55967. initialize(e, t, i) {
  55968. i !== void 0 && i !== Mi && (this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH = '1');
  55969. }
  55970. },
  55971. cH = class extends Tr {
  55972. constructor(e, t) {
  55973. super('MaskPass', e, t), (this.needsSwap = !1), (this.clearPass = new Ou(!1, !1, !0)), (this.inverse = !1);
  55974. }
  55975. get inverted() {
  55976. return this.inverse;
  55977. }
  55978. set inverted(e) {
  55979. this.inverse = e;
  55980. }
  55981. get clear() {
  55982. return this.clearPass.enabled;
  55983. }
  55984. set clear(e) {
  55985. this.clearPass.enabled = e;
  55986. }
  55987. getClearPass() {
  55988. return this.clearPass;
  55989. }
  55990. isInverted() {
  55991. return this.inverted;
  55992. }
  55993. setInverted(e) {
  55994. this.inverted = e;
  55995. }
  55996. render(e, t, i, r, s) {
  55997. let n = e.getContext(),
  55998. a = e.state.buffers,
  55999. o = this.scene,
  56000. l = this.camera,
  56001. h = this.clearPass,
  56002. u = this.inverted ? 0 : 1,
  56003. c = 1 - u;
  56004. a.color.setMask(!1),
  56005. a.depth.setMask(!1),
  56006. a.color.setLocked(!0),
  56007. a.depth.setLocked(!0),
  56008. a.stencil.setTest(!0),
  56009. a.stencil.setOp(n.REPLACE, n.REPLACE, n.REPLACE),
  56010. a.stencil.setFunc(n.ALWAYS, u, 4294967295),
  56011. a.stencil.setClear(c),
  56012. a.stencil.setLocked(!0),
  56013. this.clearPass.enabled && (this.renderToScreen ? h.render(e, null) : (h.render(e, t), h.render(e, i))),
  56014. this.renderToScreen
  56015. ? (e.setRenderTarget(null), e.render(o, l))
  56016. : (e.setRenderTarget(t), e.render(o, l), e.setRenderTarget(i), e.render(o, l)),
  56017. a.color.setLocked(!1),
  56018. a.depth.setLocked(!1),
  56019. a.stencil.setLocked(!1),
  56020. a.stencil.setFunc(n.EQUAL, 1, 4294967295),
  56021. a.stencil.setOp(n.KEEP, n.KEEP, n.KEEP),
  56022. a.stencil.setLocked(!0);
  56023. }
  56024. },
  56025. un = class extends Tr {
  56026. constructor(e, t = 'inputBuffer') {
  56027. super('ShaderPass'), (this.fullscreenMaterial = e), (this.inputBufferUniform = null), this.setInput(t);
  56028. }
  56029. setInput(e) {
  56030. if (((this.inputBufferUniform = null), this.fullscreenMaterial !== null)) {
  56031. let t = this.fullscreenMaterial.uniforms;
  56032. t !== void 0 && t[e] !== void 0 && (this.inputBufferUniform = t[e]);
  56033. }
  56034. }
  56035. render(e, t, i, r, s) {
  56036. this.inputBufferUniform !== null && t !== null && (this.inputBufferUniform.value = t.texture),
  56037. e.setRenderTarget(this.renderToScreen ? null : i),
  56038. e.render(this.scene, this.camera);
  56039. }
  56040. initialize(e, t, i) {
  56041. i !== void 0 && i !== Mi && (this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH = '1');
  56042. }
  56043. },
  56044. Of = 1 / 1e3,
  56045. dH = 1e3,
  56046. uH = class {
  56047. constructor() {
  56048. (this.previousTime = 0),
  56049. (this.currentTime = 0),
  56050. (this.delta = 0),
  56051. (this.fixedDelta = 1e3 / 60),
  56052. (this.elapsed = 0),
  56053. (this.timescale = 1),
  56054. (this.fixedDeltaEnabled = !1),
  56055. (this.autoReset = !1);
  56056. }
  56057. setFixedDeltaEnabled(e) {
  56058. return (this.fixedDeltaEnabled = e), this;
  56059. }
  56060. isAutoResetEnabled(e) {
  56061. return this.autoReset;
  56062. }
  56063. setAutoResetEnabled(e) {
  56064. return (
  56065. typeof document < 'u' &&
  56066. document.hidden !== void 0 &&
  56067. (e ? document.addEventListener('visibilitychange', this) : document.removeEventListener('visibilitychange', this),
  56068. (this.autoReset = e)),
  56069. this
  56070. );
  56071. }
  56072. getDelta() {
  56073. return this.delta * Of;
  56074. }
  56075. getFixedDelta() {
  56076. return this.fixedDelta * Of;
  56077. }
  56078. setFixedDelta(e) {
  56079. return (this.fixedDelta = e * dH), this;
  56080. }
  56081. getElapsed() {
  56082. return this.elapsed * Of;
  56083. }
  56084. getTimescale() {
  56085. return this.timescale;
  56086. }
  56087. setTimescale(e) {
  56088. return (this.timescale = e), this;
  56089. }
  56090. update(e) {
  56091. return (
  56092. this.fixedDeltaEnabled
  56093. ? (this.delta = this.fixedDelta)
  56094. : ((this.previousTime = this.currentTime),
  56095. (this.currentTime = e !== void 0 ? e : performance.now()),
  56096. (this.delta = this.currentTime - this.previousTime)),
  56097. (this.delta *= this.timescale),
  56098. (this.elapsed += this.delta),
  56099. this
  56100. );
  56101. }
  56102. reset() {
  56103. return (this.delta = 0), (this.elapsed = 0), (this.currentTime = performance.now()), this;
  56104. }
  56105. handleEvent(e) {
  56106. document.hidden || (this.currentTime = performance.now());
  56107. }
  56108. dispose() {
  56109. this.setAutoResetEnabled(!1);
  56110. }
  56111. },
  56112. pH = class {
  56113. constructor(e = null, { depthBuffer: t = !0, stencilBuffer: i = !1, multisampling: r = 0, frameBufferType: s } = {}) {
  56114. (this.renderer = null),
  56115. (this.inputBuffer = this.createBuffer(t, i, s, r)),
  56116. (this.outputBuffer = this.inputBuffer.clone()),
  56117. (this.copyPass = new nu()),
  56118. (this.depthTexture = null),
  56119. (this.passes = []),
  56120. (this.timer = new uH()),
  56121. (this.autoRenderToScreen = !0),
  56122. this.setRenderer(e);
  56123. }
  56124. get multisampling() {
  56125. return this.inputBuffer.samples || 0;
  56126. }
  56127. set multisampling(e) {
  56128. let t = this.inputBuffer,
  56129. i = this.multisampling;
  56130. i > 0 && e > 0
  56131. ? ((this.inputBuffer.samples = e), (this.outputBuffer.samples = e), this.inputBuffer.dispose(), this.outputBuffer.dispose())
  56132. : i !== e &&
  56133. (this.inputBuffer.dispose(),
  56134. this.outputBuffer.dispose(),
  56135. (this.inputBuffer = this.createBuffer(t.depthBuffer, t.stencilBuffer, t.texture.type, e)),
  56136. (this.inputBuffer.depthTexture = this.depthTexture),
  56137. (this.outputBuffer = this.inputBuffer.clone()));
  56138. }
  56139. getTimer() {
  56140. return this.timer;
  56141. }
  56142. getRenderer() {
  56143. return this.renderer;
  56144. }
  56145. setRenderer(e) {
  56146. if (((this.renderer = e), e !== null)) {
  56147. let t = e.getSize(new G()),
  56148. i = e.getContext().getContextAttributes().alpha,
  56149. r = this.inputBuffer.texture.type;
  56150. r === Mi &&
  56151. e.outputEncoding === Ke &&
  56152. ((this.inputBuffer.texture.encoding = Ke),
  56153. (this.outputBuffer.texture.encoding = Ke),
  56154. this.inputBuffer.dispose(),
  56155. this.outputBuffer.dispose()),
  56156. (e.autoClear = !1),
  56157. this.setSize(t.width, t.height);
  56158. for (let s of this.passes) s.initialize(e, i, r);
  56159. }
  56160. }
  56161. replaceRenderer(e, t = !0) {
  56162. let i = this.renderer,
  56163. r = i.domElement.parentNode;
  56164. return this.setRenderer(e), t && r !== null && (r.removeChild(i.domElement), r.appendChild(e.domElement)), i;
  56165. }
  56166. createDepthTexture() {
  56167. let e = (this.depthTexture = new pg());
  56168. return (
  56169. (this.inputBuffer.depthTexture = e),
  56170. this.inputBuffer.dispose(),
  56171. this.inputBuffer.stencilBuffer ? ((e.format = ba), (e.type = ca)) : (e.type = gn),
  56172. e
  56173. );
  56174. }
  56175. deleteDepthTexture() {
  56176. if (this.depthTexture !== null) {
  56177. this.depthTexture.dispose(), (this.depthTexture = null), (this.inputBuffer.depthTexture = null), this.inputBuffer.dispose();
  56178. for (let e of this.passes) e.setDepthTexture(null);
  56179. }
  56180. }
  56181. createBuffer(e, t, i, r) {
  56182. let s = this.renderer,
  56183. n = s === null ? new G() : s.getDrawingBufferSize(new G()),
  56184. a = { minFilter: mt, magFilter: mt, stencilBuffer: t, depthBuffer: e, type: i },
  56185. o = new ii(n.width, n.height, a);
  56186. return (
  56187. r > 0 && ((o.ignoreDepthForMultisampleCopy = !1), (o.samples = r)),
  56188. i === Mi && s !== null && s.outputEncoding === Ke && (o.texture.encoding = Ke),
  56189. (o.texture.name = 'EffectComposer.Buffer'),
  56190. (o.texture.generateMipmaps = !1),
  56191. o
  56192. );
  56193. }
  56194. addPass(e, t) {
  56195. let i = this.passes,
  56196. r = this.renderer,
  56197. s = r.getDrawingBufferSize(new G()),
  56198. n = r.getContext().getContextAttributes().alpha,
  56199. a = this.inputBuffer.texture.type;
  56200. if (
  56201. (e.setRenderer(r),
  56202. e.setSize(s.width, s.height),
  56203. e.initialize(r, n, a),
  56204. this.autoRenderToScreen &&
  56205. (i.length > 0 && (i[i.length - 1].renderToScreen = !1), e.renderToScreen && (this.autoRenderToScreen = !1)),
  56206. t !== void 0 ? i.splice(t, 0, e) : i.push(e),
  56207. this.autoRenderToScreen && (i[i.length - 1].renderToScreen = !0),
  56208. e.needsDepthTexture || this.depthTexture !== null)
  56209. )
  56210. if (this.depthTexture === null) {
  56211. let o = this.createDepthTexture();
  56212. for (e of i) e.setDepthTexture(o);
  56213. } else e.setDepthTexture(this.depthTexture);
  56214. }
  56215. removePass(e) {
  56216. let t = this.passes,
  56217. i = t.indexOf(e);
  56218. if (i !== -1 && t.splice(i, 1).length > 0) {
  56219. if (this.depthTexture !== null) {
  56220. let r = (s, n) => s || n.needsDepthTexture;
  56221. t.reduce(r, !1) || (e.getDepthTexture() === this.depthTexture && e.setDepthTexture(null), this.deleteDepthTexture());
  56222. }
  56223. this.autoRenderToScreen && i === t.length && ((e.renderToScreen = !1), t.length > 0 && (t[t.length - 1].renderToScreen = !0));
  56224. }
  56225. }
  56226. removeAllPasses() {
  56227. let e = this.passes;
  56228. this.deleteDepthTexture(), e.length > 0 && (this.autoRenderToScreen && (e[e.length - 1].renderToScreen = !1), (this.passes = []));
  56229. }
  56230. render(e) {
  56231. let t = this.renderer,
  56232. i = this.copyPass,
  56233. r = this.inputBuffer,
  56234. s = this.outputBuffer,
  56235. n = !1,
  56236. a,
  56237. o,
  56238. l;
  56239. e === void 0 && (e = this.timer.update().getDelta());
  56240. for (let h of this.passes)
  56241. h.enabled &&
  56242. (h.render(t, r, s, e, n),
  56243. h.needsSwap &&
  56244. (n &&
  56245. ((i.renderToScreen = h.renderToScreen),
  56246. (a = t.getContext()),
  56247. (o = t.state.buffers.stencil),
  56248. o.setFunc(a.NOTEQUAL, 1, 4294967295),
  56249. i.render(t, r, s, e, n),
  56250. o.setFunc(a.EQUAL, 1, 4294967295)),
  56251. (l = r),
  56252. (r = s),
  56253. (s = l)),
  56254. h instanceof cH ? (n = !0) : h instanceof FV && (n = !1));
  56255. }
  56256. setSize(e, t, i) {
  56257. let r = this.renderer;
  56258. if (e === void 0 || t === void 0) {
  56259. let n = r.getSize(new G());
  56260. (e = n.width), (t = n.height);
  56261. }
  56262. r.setSize(e, t, i);
  56263. let s = r.getDrawingBufferSize(new G());
  56264. this.inputBuffer.setSize(s.width, s.height), this.outputBuffer.setSize(s.width, s.height);
  56265. for (let n of this.passes) n.setSize(s.width, s.height);
  56266. }
  56267. reset() {
  56268. let e = this.timer.isAutoResetEnabled();
  56269. this.dispose(), (this.autoRenderToScreen = !0), this.timer.setAutoResetEnabled(e);
  56270. }
  56271. dispose() {
  56272. for (let e of this.passes) e.dispose();
  56273. (this.passes = []),
  56274. this.inputBuffer !== null && this.inputBuffer.dispose(),
  56275. this.outputBuffer !== null && this.outputBuffer.dispose(),
  56276. this.deleteDepthTexture(),
  56277. this.copyPass.dispose(),
  56278. this.timer.dispose();
  56279. }
  56280. },
  56281. Ov = { VERY_SMALL: 0, SMALL: 1, MEDIUM: 2, LARGE: 3, VERY_LARGE: 4, HUGE: 5 },
  56282. fH = `#ifdef FRAMEBUFFER_PRECISION_HIGH
  56283. uniform mediump sampler2D map;
  56284. #else
  56285. uniform lowp sampler2D map;
  56286. #endif
  56287. 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);}`,
  56288. mH = class extends Ss {
  56289. constructor({
  56290. blendFunction: e = nt.SCREEN,
  56291. luminanceThreshold: t = 0.9,
  56292. luminanceSmoothing: i = 0.025,
  56293. resolutionScale: r = 0.5,
  56294. intensity: s = 1,
  56295. width: n = Fi.AUTO_SIZE,
  56296. height: a = Fi.AUTO_SIZE,
  56297. kernelSize: o = Ov.LARGE
  56298. } = {}) {
  56299. super('BloomEffect', fH, {
  56300. blendFunction: e,
  56301. uniforms: new Map([
  56302. ['map', new Oe(null)],
  56303. ['intensity', new Oe(s)]
  56304. ])
  56305. }),
  56306. (this.renderTarget = new ii(1, 1, { minFilter: mt, magFilter: mt, stencilBuffer: !1, depthBuffer: !1 })),
  56307. (this.renderTarget.texture.name = 'Bloom.Target'),
  56308. (this.renderTarget.texture.generateMipmaps = !1),
  56309. (this.uniforms.get('map').value = this.renderTarget.texture),
  56310. (this.luminancePass = new hH({ renderTarget: this.renderTarget, colorOutput: !0 })),
  56311. (this.luminanceMaterial.threshold = t),
  56312. (this.luminanceMaterial.smoothingFactor = i),
  56313. (this.blurPass = new u2({ resolutionScale: r, width: n, height: a, kernelSize: o }));
  56314. let l = this.blurPass.getResolution();
  56315. l.addEventListener('change', (h) => this.setSize(l.baseWidth, l.baseHeight));
  56316. }
  56317. get texture() {
  56318. return this.renderTarget.texture;
  56319. }
  56320. getTexture() {
  56321. return this.renderTarget.texture;
  56322. }
  56323. get resolution() {
  56324. return this.blurPass.resolution;
  56325. }
  56326. getResolution() {
  56327. return this.blurPass.resolution;
  56328. }
  56329. getBlurPass() {
  56330. return this.blurPass;
  56331. }
  56332. getLuminancePass() {
  56333. return this.luminancePass;
  56334. }
  56335. get luminanceMaterial() {
  56336. return this.luminancePass.fullscreenMaterial;
  56337. }
  56338. getLuminanceMaterial() {
  56339. return this.luminancePass.fullscreenMaterial;
  56340. }
  56341. get width() {
  56342. return this.resolution.width;
  56343. }
  56344. set width(e) {
  56345. this.resolution.preferredWidth = e;
  56346. }
  56347. get height() {
  56348. return this.resolution.height;
  56349. }
  56350. set height(e) {
  56351. this.resolution.preferredHeight = e;
  56352. }
  56353. get dithering() {
  56354. return this.blurPass.dithering;
  56355. }
  56356. set dithering(e) {
  56357. this.blurPass.dithering = e;
  56358. }
  56359. get kernelSize() {
  56360. return this.blurPass.kernelSize;
  56361. }
  56362. set kernelSize(e) {
  56363. this.blurPass.kernelSize = e;
  56364. }
  56365. get distinction() {
  56366. return console.warn(this.name, 'distinction was removed'), 1;
  56367. }
  56368. set distinction(e) {
  56369. console.warn(this.name, 'distinction was removed');
  56370. }
  56371. get intensity() {
  56372. return this.uniforms.get('intensity').value;
  56373. }
  56374. set intensity(e) {
  56375. this.uniforms.get('intensity').value = e;
  56376. }
  56377. getIntensity() {
  56378. return this.intensity;
  56379. }
  56380. setIntensity(e) {
  56381. this.intensity = e;
  56382. }
  56383. getResolutionScale() {
  56384. return this.resolution.scale;
  56385. }
  56386. setResolutionScale(e) {
  56387. this.resolution.scale = e;
  56388. }
  56389. update(e, t, i) {
  56390. let r = this.renderTarget;
  56391. this.luminancePass.enabled ? (this.luminancePass.render(e, t, r), this.blurPass.render(e, r, r)) : this.blurPass.render(e, t, r);
  56392. }
  56393. setSize(e, t) {
  56394. let i = this.resolution;
  56395. i.setBaseSize(e, t), this.renderTarget.setSize(i.width, i.height), this.luminancePass.resolution.copy(i);
  56396. }
  56397. initialize(e, t, i) {
  56398. this.blurPass.initialize(e, t, i),
  56399. i !== void 0 && ((this.renderTarget.texture.type = i), e.outputEncoding === Ke && (this.renderTarget.texture.encoding = Ke));
  56400. }
  56401. },
  56402. gH =
  56403. '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);}',
  56404. vH = class extends Ss {
  56405. constructor({ blendFunction: e = nt.NORMAL, brightness: t = 0, contrast: i = 0 } = {}) {
  56406. super('BrightnessContrastEffect', gH, {
  56407. blendFunction: e,
  56408. uniforms: new Map([
  56409. ['brightness', new Oe(t)],
  56410. ['contrast', new Oe(i)]
  56411. ])
  56412. });
  56413. }
  56414. get brightness() {
  56415. return this.uniforms.get('brightness').value;
  56416. }
  56417. set brightness(e) {
  56418. this.uniforms.get('brightness').value = e;
  56419. }
  56420. getBrightness(e) {
  56421. return this.brightness;
  56422. }
  56423. setBrightness(e) {
  56424. this.brightness = e;
  56425. }
  56426. get contrast() {
  56427. return this.uniforms.get('contrast').value;
  56428. }
  56429. set contrast(e) {
  56430. this.uniforms.get('contrast').value = e;
  56431. }
  56432. getContrast(e) {
  56433. return this.contrast;
  56434. }
  56435. setContrast(e) {
  56436. this.contrast = e;
  56437. }
  56438. },
  56439. yH =
  56440. 'void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=vec4(vec3(average(inputColor.rgb)),inputColor.a);}',
  56441. xH = class extends Ss {
  56442. constructor(e = nt.NORMAL) {
  56443. super('ColorAverageEffect', yH, { blendFunction: e });
  56444. }
  56445. },
  56446. bH =
  56447. '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));}',
  56448. wH =
  56449. '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;}',
  56450. _H = class extends Ss {
  56451. constructor({ blendFunction: e = nt.NORMAL, offset: t = new G(0.001, 5e-4) } = {}) {
  56452. super('ChromaticAberrationEffect', bH, {
  56453. vertexShader: wH,
  56454. blendFunction: e,
  56455. attributes: ms.CONVOLUTION,
  56456. uniforms: new Map([['offset', new Oe(t)]])
  56457. });
  56458. }
  56459. get offset() {
  56460. return this.uniforms.get('offset').value;
  56461. }
  56462. set offset(e) {
  56463. this.uniforms.get('offset').value = e;
  56464. }
  56465. getOffset() {
  56466. return this.offset;
  56467. }
  56468. setOffset(e) {
  56469. this.offset = e;
  56470. }
  56471. },
  56472. AH = `#ifdef FRAMEBUFFER_PRECISION_HIGH
  56473. uniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuffer;
  56474. #else
  56475. uniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer;
  56476. #endif
  56477. 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;}`,
  56478. SH = class extends Ss {
  56479. constructor(
  56480. e,
  56481. {
  56482. blendFunction: t = nt.NORMAL,
  56483. worldFocusDistance: i,
  56484. worldFocusRange: r,
  56485. focusDistance: s = 0,
  56486. focalLength: n = 0.1,
  56487. focusRange: a = n,
  56488. bokehScale: o = 1,
  56489. width: l = Fi.AUTO_SIZE,
  56490. height: h = Fi.AUTO_SIZE
  56491. } = {}
  56492. ) {
  56493. super('DepthOfFieldEffect', AH, {
  56494. blendFunction: t,
  56495. attributes: ms.DEPTH,
  56496. uniforms: new Map([
  56497. ['nearColorBuffer', new Oe(null)],
  56498. ['farColorBuffer', new Oe(null)],
  56499. ['nearCoCBuffer', new Oe(null)],
  56500. ['scale', new Oe(1)]
  56501. ])
  56502. }),
  56503. (this.camera = e),
  56504. (this.renderTarget = new ii(1, 1, { minFilter: mt, magFilter: mt, stencilBuffer: !1, depthBuffer: !1 })),
  56505. (this.renderTarget.texture.name = 'DoF.Intermediate'),
  56506. (this.renderTarget.texture.generateMipmaps = !1),
  56507. (this.renderTargetMasked = this.renderTarget.clone()),
  56508. (this.renderTargetMasked.texture.name = 'DoF.Masked.Far'),
  56509. (this.renderTargetNear = this.renderTarget.clone()),
  56510. (this.renderTargetNear.texture.name = 'DoF.Bokeh.Near'),
  56511. (this.uniforms.get('nearColorBuffer').value = this.renderTargetNear.texture),
  56512. (this.renderTargetFar = this.renderTarget.clone()),
  56513. (this.renderTargetFar.texture.name = 'DoF.Bokeh.Far'),
  56514. (this.uniforms.get('farColorBuffer').value = this.renderTargetFar.texture),
  56515. (this.renderTargetCoC = this.renderTarget.clone()),
  56516. (this.renderTargetCoC.texture.name = 'DoF.CoC'),
  56517. (this.renderTargetCoCBlurred = this.renderTargetCoC.clone()),
  56518. (this.renderTargetCoCBlurred.texture.name = 'DoF.CoC.Blurred'),
  56519. (this.uniforms.get('nearCoCBuffer').value = this.renderTargetCoCBlurred.texture),
  56520. (this.cocPass = new un(new bV(e)));
  56521. let u = this.cocMaterial;
  56522. (u.focusDistance = s),
  56523. (u.focusRange = a),
  56524. i !== void 0 && (u.worldFocusDistance = i),
  56525. r !== void 0 && (u.worldFocusRange = r),
  56526. (this.blurPass = new u2({ kernelSize: Ov.MEDIUM, width: l, height: h }));
  56527. let c = this.blurPass.getResolution();
  56528. c.addEventListener('change', (p) => this.setSize(c.getBaseWidth(), c.getBaseHeight())),
  56529. (this.maskPass = new un(new IV(this.renderTargetCoC.texture)));
  56530. let d = this.maskPass.fullscreenMaterial;
  56531. (d.maskFunction = d2.MULTIPLY),
  56532. (d.colorChannel = h2.GREEN),
  56533. (this.bokehNearBasePass = new un(new Qc(!1, !0))),
  56534. (this.bokehNearBasePass.fullscreenMaterial.cocBuffer = this.renderTargetCoCBlurred.texture),
  56535. (this.bokehNearFillPass = new un(new Qc(!0, !0))),
  56536. (this.bokehNearFillPass.fullscreenMaterial.cocBuffer = this.renderTargetCoCBlurred.texture),
  56537. (this.bokehFarBasePass = new un(new Qc(!1, !1))),
  56538. (this.bokehFarBasePass.fullscreenMaterial.cocBuffer = this.renderTargetCoC.texture),
  56539. (this.bokehFarFillPass = new un(new Qc(!0, !1))),
  56540. (this.bokehFarFillPass.fullscreenMaterial.cocBuffer = this.renderTargetCoC.texture),
  56541. (this.target = null),
  56542. (this.bokehScale = o);
  56543. }
  56544. get cocTexture() {
  56545. return this.renderTargetCoC.texture;
  56546. }
  56547. get cocMaterial() {
  56548. return this.cocPass.fullscreenMaterial;
  56549. }
  56550. get circleOfConfusionMaterial() {
  56551. return this.cocMaterial;
  56552. }
  56553. getCircleOfConfusionMaterial() {
  56554. return this.circleOfConfusionMaterial;
  56555. }
  56556. getBlurPass() {
  56557. return this.blurPass;
  56558. }
  56559. get resolution() {
  56560. return this.blurPass.getResolution();
  56561. }
  56562. getResolution() {
  56563. return this.blurPass.getResolution();
  56564. }
  56565. get bokehScale() {
  56566. return this.uniforms.get('scale').value;
  56567. }
  56568. set bokehScale(e) {
  56569. let t = [this.bokehNearBasePass, this.bokehNearFillPass, this.bokehFarBasePass, this.bokehFarFillPass];
  56570. for (let i of t) i.fullscreenMaterial.setScale(e);
  56571. this.maskPass.fullscreenMaterial.setStrength(e), (this.uniforms.get('scale').value = e);
  56572. }
  56573. getBokehScale() {
  56574. return this.bokehScale;
  56575. }
  56576. setBokehScale(e) {
  56577. this.bokehScale = e;
  56578. }
  56579. getTarget() {
  56580. return this.target;
  56581. }
  56582. setTarget(e) {
  56583. this.target = e;
  56584. }
  56585. calculateFocusDistance(e) {
  56586. let t = this.camera,
  56587. i = t.position.distanceTo(e);
  56588. return sg(-i, t.near, t.far);
  56589. }
  56590. setDepthTexture(e, t = qs) {
  56591. (this.circleOfConfusionMaterial.depthBuffer = e), (this.circleOfConfusionMaterial.depthPacking = t);
  56592. }
  56593. update(e, t, i) {
  56594. let r = this.renderTarget,
  56595. s = this.renderTargetCoC,
  56596. n = this.renderTargetCoCBlurred,
  56597. a = this.renderTargetMasked;
  56598. if (this.target !== null) {
  56599. let o = this.calculateFocusDistance(this.target);
  56600. this.circleOfConfusionMaterial.focusDistance = o;
  56601. }
  56602. this.cocPass.render(e, null, s),
  56603. this.blurPass.render(e, s, n),
  56604. this.maskPass.render(e, t, a),
  56605. this.bokehFarBasePass.render(e, a, r),
  56606. this.bokehFarFillPass.render(e, r, this.renderTargetFar),
  56607. this.bokehNearBasePass.render(e, t, r),
  56608. this.bokehNearFillPass.render(e, r, this.renderTargetNear);
  56609. }
  56610. setSize(e, t) {
  56611. let i = this.resolution;
  56612. i.setBaseSize(e, t);
  56613. let r = i.width,
  56614. s = i.height,
  56615. n = [
  56616. this.cocPass,
  56617. this.blurPass,
  56618. this.maskPass,
  56619. this.bokehNearBasePass,
  56620. this.bokehNearFillPass,
  56621. this.bokehFarBasePass,
  56622. this.bokehFarFillPass
  56623. ];
  56624. n.push(this.renderTargetCoC, this.renderTargetMasked),
  56625. n.forEach((a) => a.setSize(e, t)),
  56626. (n = [this.renderTarget, this.renderTargetNear, this.renderTargetFar, this.renderTargetCoCBlurred]),
  56627. n.forEach((a) => a.setSize(r, s)),
  56628. [this.bokehNearBasePass, this.bokehNearFillPass, this.bokehFarBasePass, this.bokehFarFillPass].forEach((a) =>
  56629. a.fullscreenMaterial.setSize(r, s)
  56630. );
  56631. }
  56632. initialize(e, t, i) {
  56633. [this.cocPass, this.maskPass, this.bokehNearBasePass, this.bokehNearFillPass, this.bokehFarBasePass, this.bokehFarFillPass].forEach(
  56634. (r) => r.initialize(e, t, i)
  56635. ),
  56636. this.blurPass.initialize(e, t, Mi),
  56637. i !== void 0 &&
  56638. ((this.renderTarget.texture.type = i),
  56639. (this.renderTargetNear.texture.type = i),
  56640. (this.renderTargetFar.texture.type = i),
  56641. (this.renderTargetMasked.texture.type = i),
  56642. e.outputEncoding === Ke &&
  56643. ((this.renderTarget.texture.encoding = Ke),
  56644. (this.renderTargetNear.texture.encoding = Ke),
  56645. (this.renderTargetFar.texture.encoding = Ke),
  56646. (this.renderTargetMasked.texture.encoding = Ke)));
  56647. }
  56648. },
  56649. k9 = new E(),
  56650. j9 = new ve(),
  56651. MH =
  56652. '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);}',
  56653. EH = class extends Ss {
  56654. constructor({ blendFunction: e = nt.NORMAL, hue: t = 0, saturation: i = 0 } = {}) {
  56655. super('HueSaturationEffect', MH, {
  56656. blendFunction: e,
  56657. uniforms: new Map([
  56658. ['hue', new Oe(new E())],
  56659. ['saturation', new Oe(i)]
  56660. ])
  56661. }),
  56662. (this.hue = t);
  56663. }
  56664. get saturation() {
  56665. return this.uniforms.get('saturation').value;
  56666. }
  56667. set saturation(e) {
  56668. this.uniforms.get('saturation').value = e;
  56669. }
  56670. getSaturation() {
  56671. return this.saturation;
  56672. }
  56673. setSaturation(e) {
  56674. this.saturation = e;
  56675. }
  56676. get hue() {
  56677. let e = this.uniforms.get('hue').value;
  56678. return Math.acos((e.x * 3 - 1) / 2);
  56679. }
  56680. set hue(e) {
  56681. let t = Math.sin(e),
  56682. i = Math.cos(e);
  56683. this.uniforms.get('hue').value.set((2 * i + 1) / 3, (-Math.sqrt(3) * t - i + 1) / 3, (Math.sqrt(3) * t - i + 1) / 3);
  56684. }
  56685. getHue() {
  56686. return this.hue;
  56687. }
  56688. setHue(e) {
  56689. this.hue = e;
  56690. }
  56691. },
  56692. G9 = new Ge(),
  56693. CH = `void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*time));
  56694. #ifdef PREMULTIPLY
  56695. outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a);
  56696. #else
  56697. outputColor=vec4(noise,inputColor.a);
  56698. #endif
  56699. }`,
  56700. TH = class extends Ss {
  56701. constructor({ blendFunction: e = nt.SCREEN, premultiply: t = !1 } = {}) {
  56702. super('NoiseEffect', CH, { blendFunction: e }), (this.premultiply = t);
  56703. }
  56704. get premultiply() {
  56705. return this.defines.has('PREMULTIPLY');
  56706. }
  56707. set premultiply(e) {
  56708. this.premultiply !== e && (e ? this.defines.set('PREMULTIPLY', '1') : this.defines.delete('PREMULTIPLY'), this.setChanged());
  56709. }
  56710. isPremultiplied() {
  56711. return this.premultiply;
  56712. }
  56713. setPremultiplied(e) {
  56714. this.premultiply = e;
  56715. }
  56716. },
  56717. PH =
  56718. '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));}}',
  56719. DH = class extends Ss {
  56720. constructor(e = 30) {
  56721. super('PixelationEffect', PH, {
  56722. uniforms: new Map([
  56723. ['active', new Oe(!1)],
  56724. ['d', new Oe(new G())]
  56725. ])
  56726. }),
  56727. (this.resolution = new G()),
  56728. (this.d = 0),
  56729. (this.granularity = e);
  56730. }
  56731. get granularity() {
  56732. return this.d;
  56733. }
  56734. set granularity(e) {
  56735. let t = Math.floor(e);
  56736. t % 2 > 0 && (t += 1),
  56737. (this.d = t),
  56738. (this.uniforms.get('active').value = t > 0),
  56739. this.setSize(this.resolution.width, this.resolution.height);
  56740. }
  56741. getGranularity() {
  56742. return this.granularity;
  56743. }
  56744. setGranularity(e) {
  56745. this.granularity = e;
  56746. }
  56747. setSize(e, t) {
  56748. this.resolution.set(e, t), this.uniforms.get('d').value.setScalar(this.d).divide(this.resolution);
  56749. }
  56750. },
  56751. V9 = Math.PI * 0.5,
  56752. H9 = new E(),
  56753. W9 = new E(),
  56754. Jb =
  56755. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC',
  56756. $b =
  56757. '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',
  56758. LH =
  56759. '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;}',
  56760. OH =
  56761. '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);}',
  56762. co = { LOW: 0, MEDIUM: 1, HIGH: 2, ULTRA: 3 },
  56763. IH = class extends Ss {
  56764. constructor({ preset: e = co.MEDIUM, edgeDetectionMode: t = Lv.COLOR, predicationMode: i = c2.DISABLED } = {}) {
  56765. super('SMAAEffect', LH, {
  56766. vertexShader: OH,
  56767. blendFunction: nt.NORMAL,
  56768. attributes: ms.CONVOLUTION | ms.DEPTH,
  56769. uniforms: new Map([['weightMap', new Oe(null)]])
  56770. });
  56771. let r, s;
  56772. arguments.length > 1 &&
  56773. ((r = arguments[0]), (s = arguments[1]), arguments.length > 2 && (e = arguments[2]), arguments.length > 3 && (t = arguments[3])),
  56774. (this.renderTargetEdges = new ii(1, 1, { minFilter: mt, stencilBuffer: !1, depthBuffer: !1 })),
  56775. (this.renderTargetEdges.texture.name = 'SMAA.Edges'),
  56776. (this.renderTargetWeights = this.renderTargetEdges.clone()),
  56777. (this.renderTargetWeights.texture.name = 'SMAA.Weights'),
  56778. (this.uniforms.get('weightMap').value = this.renderTargetWeights.texture),
  56779. (this.clearPass = new Ou(!0, !1, !1)),
  56780. (this.clearPass.overrideClearColor = new Ge(0)),
  56781. (this.clearPass.overrideClearAlpha = 1),
  56782. (this.edgeDetectionPass = new un(new CV())),
  56783. (this.edgeDetectionMaterial.edgeDetectionMode = t),
  56784. (this.edgeDetectionMaterial.predicationMode = i),
  56785. (this.weightsPass = new un(new zV()));
  56786. let n = new Uw();
  56787. (n.onLoad = () => {
  56788. let a = new ci(r);
  56789. (a.name = 'SMAA.Search'),
  56790. (a.magFilter = Ot),
  56791. (a.minFilter = Ot),
  56792. (a.generateMipmaps = !1),
  56793. (a.needsUpdate = !0),
  56794. (a.flipY = !0),
  56795. (this.weightsMaterial.searchTexture = a);
  56796. let o = new ci(s);
  56797. (o.name = 'SMAA.Area'),
  56798. (o.magFilter = mt),
  56799. (o.minFilter = mt),
  56800. (o.generateMipmaps = !1),
  56801. (o.needsUpdate = !0),
  56802. (o.flipY = !1),
  56803. (this.weightsMaterial.areaTexture = o),
  56804. this.dispatchEvent({ type: 'load' });
  56805. }),
  56806. n.itemStart('search'),
  56807. n.itemStart('area'),
  56808. r !== void 0 && s !== void 0
  56809. ? (n.itemEnd('search'), n.itemEnd('area'))
  56810. : typeof Image < 'u' &&
  56811. ((r = new Image()),
  56812. (s = new Image()),
  56813. r.addEventListener('load', () => n.itemEnd('search')),
  56814. s.addEventListener('load', () => n.itemEnd('area')),
  56815. (r.src = Jb),
  56816. (s.src = $b)),
  56817. this.applyPreset(e);
  56818. }
  56819. get edgesTexture() {
  56820. return this.renderTargetEdges.texture;
  56821. }
  56822. getEdgesTexture() {
  56823. return this.edgesTexture;
  56824. }
  56825. get weightsTexture() {
  56826. return this.renderTargetWeights.texture;
  56827. }
  56828. getWeightsTexture() {
  56829. return this.weightsTexture;
  56830. }
  56831. get edgeDetectionMaterial() {
  56832. return this.edgeDetectionPass.fullscreenMaterial;
  56833. }
  56834. get colorEdgesMaterial() {
  56835. return this.edgeDetectionMaterial;
  56836. }
  56837. getEdgeDetectionMaterial() {
  56838. return this.edgeDetectionMaterial;
  56839. }
  56840. get weightsMaterial() {
  56841. return this.weightsPass.fullscreenMaterial;
  56842. }
  56843. getWeightsMaterial() {
  56844. return this.weightsMaterial;
  56845. }
  56846. setEdgeDetectionThreshold(e) {
  56847. this.edgeDetectionMaterial.edgeDetectionThreshold = e;
  56848. }
  56849. setOrthogonalSearchSteps(e) {
  56850. this.weightsMaterial.orthogonalSearchSteps = e;
  56851. }
  56852. applyPreset(e) {
  56853. let t = this.edgeDetectionMaterial,
  56854. i = this.weightsMaterial;
  56855. switch (e) {
  56856. case co.LOW:
  56857. (t.edgeDetectionThreshold = 0.15), (i.orthogonalSearchSteps = 4), (i.diagonalDetection = !1), (i.cornerDetection = !1);
  56858. break;
  56859. case co.MEDIUM:
  56860. (t.edgeDetectionThreshold = 0.1), (i.orthogonalSearchSteps = 8), (i.diagonalDetection = !1), (i.cornerDetection = !1);
  56861. break;
  56862. case co.HIGH:
  56863. (t.edgeDetectionThreshold = 0.1),
  56864. (i.orthogonalSearchSteps = 16),
  56865. (i.diagonalSearchSteps = 8),
  56866. (i.cornerRounding = 25),
  56867. (i.diagonalDetection = !0),
  56868. (i.cornerDetection = !0);
  56869. break;
  56870. case co.ULTRA:
  56871. (t.edgeDetectionThreshold = 0.05),
  56872. (i.orthogonalSearchSteps = 32),
  56873. (i.diagonalSearchSteps = 16),
  56874. (i.cornerRounding = 25),
  56875. (i.diagonalDetection = !0),
  56876. (i.cornerDetection = !0);
  56877. break;
  56878. }
  56879. }
  56880. setDepthTexture(e, t = qs) {
  56881. (this.edgeDetectionMaterial.depthBuffer = e), (this.edgeDetectionMaterial.depthPacking = t);
  56882. }
  56883. update(e, t, i) {
  56884. this.clearPass.render(e, this.renderTargetEdges),
  56885. this.edgeDetectionPass.render(e, t, this.renderTargetEdges),
  56886. this.weightsPass.render(e, this.renderTargetEdges, this.renderTargetWeights);
  56887. }
  56888. setSize(e, t) {
  56889. this.edgeDetectionMaterial.setSize(e, t),
  56890. this.weightsMaterial.setSize(e, t),
  56891. this.renderTargetEdges.setSize(e, t),
  56892. this.renderTargetWeights.setSize(e, t);
  56893. }
  56894. dispose() {
  56895. let { searchTexture: e, areaTexture: t } = this.weightsMaterial;
  56896. e !== null && t !== null && (e.dispose(), t.dispose()), super.dispose();
  56897. }
  56898. static get searchImageDataURL() {
  56899. return Jb;
  56900. }
  56901. static get areaImageDataURL() {
  56902. return $b;
  56903. }
  56904. },
  56905. RH = `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;
  56906. #if VIGNETTE_TECHNIQUE == 0
  56907. float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset));
  56908. #else
  56909. vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord));
  56910. #endif
  56911. outputColor=vec4(color,inputColor.a);}`,
  56912. Zc = { DEFAULT: 0, ESKIL: 1 },
  56913. BH = class extends Ss {
  56914. constructor({ blendFunction: e = nt.NORMAL, technique: t = Zc.DEFAULT, eskil: i = !1, offset: r = 0.5, darkness: s = 0.5 } = {}) {
  56915. super('VignetteEffect', RH, {
  56916. blendFunction: e,
  56917. defines: new Map([['VIGNETTE_TECHNIQUE', t.toFixed(0)]]),
  56918. uniforms: new Map([
  56919. ['offset', new Oe(r)],
  56920. ['darkness', new Oe(s)]
  56921. ])
  56922. });
  56923. }
  56924. get technique() {
  56925. return Number(this.defines.get('VIGNETTE_TECHNIQUE'));
  56926. }
  56927. set technique(e) {
  56928. this.technique !== e && (this.defines.set('VIGNETTE_TECHNIQUE', e.toFixed(0)), this.setChanged());
  56929. }
  56930. get eskil() {
  56931. return this.technique === Zc.ESKIL;
  56932. }
  56933. set eskil(e) {
  56934. this.technique = e ? Zc.ESKIL : Zc.DEFAULT;
  56935. }
  56936. getTechnique() {
  56937. return this.technique;
  56938. }
  56939. setTechnique(e) {
  56940. this.technique = e;
  56941. }
  56942. get offset() {
  56943. return this.uniforms.get('offset').value;
  56944. }
  56945. set offset(e) {
  56946. this.uniforms.get('offset').value = e;
  56947. }
  56948. getOffset() {
  56949. return this.offset;
  56950. }
  56951. setOffset(e) {
  56952. this.offset = e;
  56953. }
  56954. get darkness() {
  56955. return this.uniforms.get('darkness').value;
  56956. }
  56957. set darkness(e) {
  56958. this.uniforms.get('darkness').value = e;
  56959. }
  56960. getDarkness() {
  56961. return this.darkness;
  56962. }
  56963. setDarkness(e) {
  56964. this.darkness = e;
  56965. }
  56966. },
  56967. X9 = [new Float32Array(3), new Float32Array(3)],
  56968. q9 = [new Float32Array(3), new Float32Array(3), new Float32Array(3), new Float32Array(3)],
  56969. Y9 = [
  56970. [new Float32Array([0, 0, 0]), new Float32Array([1, 0, 0]), new Float32Array([1, 1, 0]), new Float32Array([1, 1, 1])],
  56971. [new Float32Array([0, 0, 0]), new Float32Array([1, 0, 0]), new Float32Array([1, 0, 1]), new Float32Array([1, 1, 1])],
  56972. [new Float32Array([0, 0, 0]), new Float32Array([0, 0, 1]), new Float32Array([1, 0, 1]), new Float32Array([1, 1, 1])],
  56973. [new Float32Array([0, 0, 0]), new Float32Array([0, 1, 0]), new Float32Array([1, 1, 0]), new Float32Array([1, 1, 1])],
  56974. [new Float32Array([0, 0, 0]), new Float32Array([0, 1, 0]), new Float32Array([0, 1, 1]), new Float32Array([1, 1, 1])],
  56975. [new Float32Array([0, 0, 0]), new Float32Array([0, 0, 1]), new Float32Array([0, 1, 1]), new Float32Array([1, 1, 1])]
  56976. ],
  56977. Q9 = [new Float32Array(2), new Float32Array(2)],
  56978. Z9 = new Float32Array([0, -0.25, 0.25, -0.125, 0.125, -0.375, 0.375]),
  56979. K9 = [
  56980. new Float32Array([0, 0]),
  56981. new Float32Array([0.25, -0.25]),
  56982. new Float32Array([-0.25, 0.25]),
  56983. new Float32Array([0.125, -0.125]),
  56984. new Float32Array([-0.125, 0.125])
  56985. ],
  56986. J9 = [
  56987. new Uint8Array([0, 0]),
  56988. new Uint8Array([3, 0]),
  56989. new Uint8Array([0, 3]),
  56990. new Uint8Array([3, 3]),
  56991. new Uint8Array([1, 0]),
  56992. new Uint8Array([4, 0]),
  56993. new Uint8Array([1, 3]),
  56994. new Uint8Array([4, 3]),
  56995. new Uint8Array([0, 1]),
  56996. new Uint8Array([3, 1]),
  56997. new Uint8Array([0, 4]),
  56998. new Uint8Array([3, 4]),
  56999. new Uint8Array([1, 1]),
  57000. new Uint8Array([4, 1]),
  57001. new Uint8Array([1, 4]),
  57002. new Uint8Array([4, 4])
  57003. ],
  57004. $9 = [
  57005. new Uint8Array([0, 0]),
  57006. new Uint8Array([1, 0]),
  57007. new Uint8Array([0, 2]),
  57008. new Uint8Array([1, 2]),
  57009. new Uint8Array([2, 0]),
  57010. new Uint8Array([3, 0]),
  57011. new Uint8Array([2, 2]),
  57012. new Uint8Array([3, 2]),
  57013. new Uint8Array([0, 1]),
  57014. new Uint8Array([1, 1]),
  57015. new Uint8Array([0, 3]),
  57016. new Uint8Array([1, 3]),
  57017. new Uint8Array([2, 1]),
  57018. new Uint8Array([3, 1]),
  57019. new Uint8Array([2, 3]),
  57020. new Uint8Array([3, 3])
  57021. ],
  57022. e7 = new Map([
  57023. [bi(0, 0, 0, 0), new Float32Array([0, 0, 0, 0])],
  57024. [bi(0, 0, 0, 1), new Float32Array([0, 0, 0, 1])],
  57025. [bi(0, 0, 1, 0), new Float32Array([0, 0, 1, 0])],
  57026. [bi(0, 0, 1, 1), new Float32Array([0, 0, 1, 1])],
  57027. [bi(0, 1, 0, 0), new Float32Array([0, 1, 0, 0])],
  57028. [bi(0, 1, 0, 1), new Float32Array([0, 1, 0, 1])],
  57029. [bi(0, 1, 1, 0), new Float32Array([0, 1, 1, 0])],
  57030. [bi(0, 1, 1, 1), new Float32Array([0, 1, 1, 1])],
  57031. [bi(1, 0, 0, 0), new Float32Array([1, 0, 0, 0])],
  57032. [bi(1, 0, 0, 1), new Float32Array([1, 0, 0, 1])],
  57033. [bi(1, 0, 1, 0), new Float32Array([1, 0, 1, 0])],
  57034. [bi(1, 0, 1, 1), new Float32Array([1, 0, 1, 1])],
  57035. [bi(1, 1, 0, 0), new Float32Array([1, 1, 0, 0])],
  57036. [bi(1, 1, 0, 1), new Float32Array([1, 1, 0, 1])],
  57037. [bi(1, 1, 1, 0), new Float32Array([1, 1, 1, 0])],
  57038. [bi(1, 1, 1, 1), new Float32Array([1, 1, 1, 1])]
  57039. ]);
  57040. function If(e, t, i) {
  57041. return e + (t - e) * i;
  57042. }
  57043. function bi(e, t, i, r) {
  57044. let s = If(e, t, 0.75),
  57045. n = If(i, r, 1 - 0.25);
  57046. return If(s, n, 1 - 0.125);
  57047. }
  57048. var Qs = class {
  57049. constructor(e, t) {
  57050. (this.enabled = !1),
  57051. (this.effect = new e(t)),
  57052. Object.defineProperty(this, 'opacity', {
  57053. enumerable: !0,
  57054. set(i) {
  57055. this.effect.blendMode.opacity.value = i;
  57056. },
  57057. get() {
  57058. return this.effect.blendMode.opacity.value;
  57059. }
  57060. }),
  57061. Object.defineProperty(this, 'blendFunction', {
  57062. enumerable: !0,
  57063. set(i) {
  57064. this.effect.blendMode.setBlendFunction(Number(i));
  57065. },
  57066. get() {
  57067. return this.effect.blendMode.blendFunction;
  57068. }
  57069. }),
  57070. (this.blendFunction = nt.NORMAL);
  57071. }
  57072. },
  57073. zH = class extends Qs {
  57074. constructor() {
  57075. super(mH), (this.blendFunction = nt.SCREEN);
  57076. }
  57077. set intensity(e) {
  57078. this.effect.intensity = e;
  57079. }
  57080. get intensity() {
  57081. return this.effect.intensity;
  57082. }
  57083. set luminanceThreshold(e) {
  57084. this.effect.luminanceMaterial.threshold = e;
  57085. }
  57086. get luminanceThreshold() {
  57087. return this.effect.luminanceMaterial.threshold;
  57088. }
  57089. set luminanceSmoothing(e) {
  57090. this.effect.luminanceMaterial.smoothing = e;
  57091. }
  57092. get luminanceSmoothing() {
  57093. return this.effect.luminanceMaterial.smoothing;
  57094. }
  57095. set blurScale(e) {
  57096. this.effect.blurPass.scale = e;
  57097. }
  57098. get blurScale() {
  57099. return this.effect.blurPass.scale;
  57100. }
  57101. set kernelSize(e) {
  57102. this.effect.blurPass.kernelSize = e;
  57103. }
  57104. get kernelSize() {
  57105. return this.effect.blurPass.kernelSize;
  57106. }
  57107. },
  57108. NH = class extends Qs {
  57109. constructor() {
  57110. super(vH);
  57111. }
  57112. set contrast(e) {
  57113. this.effect.uniforms.get('contrast').value = e;
  57114. }
  57115. get contrast() {
  57116. return this.effect.uniforms.get('contrast').value;
  57117. }
  57118. set brightness(e) {
  57119. this.effect.uniforms.get('brightness').value = e;
  57120. }
  57121. get brightness() {
  57122. return this.effect.uniforms.get('brightness').value;
  57123. }
  57124. },
  57125. UH = class extends Qs {
  57126. constructor() {
  57127. super(_H), (this.effect.offset = new G(0.01, 0.01));
  57128. }
  57129. set offset(e) {
  57130. this.effect.offset.set(e[0] / 1e3, e[1] / 1e3);
  57131. }
  57132. get offset() {
  57133. return [this.effect.offset.x * 1e3, this.effect.offset.y * 1e3];
  57134. }
  57135. },
  57136. FH = class extends Qs {
  57137. constructor() {
  57138. super(xH);
  57139. }
  57140. },
  57141. kH = class extends Qs {
  57142. constructor() {
  57143. super(EH), (this._hue = 0);
  57144. }
  57145. set hue(e) {
  57146. (this._hue = e), this.effect.setHue(e);
  57147. }
  57148. get hue() {
  57149. return this._hue;
  57150. }
  57151. set saturation(e) {
  57152. this.effect.uniforms.get('saturation').value = e;
  57153. }
  57154. get saturation() {
  57155. return this.effect.uniforms.get('saturation').value;
  57156. }
  57157. },
  57158. jH = class extends Qs {
  57159. constructor() {
  57160. super(TH), (this.blendFunction = nt.OVERLAY);
  57161. }
  57162. },
  57163. GH = class extends Qs {
  57164. constructor() {
  57165. super(BH);
  57166. }
  57167. get eskil() {
  57168. return this.effect.eskil;
  57169. }
  57170. set eskil(e) {
  57171. this.effect.eskil = e;
  57172. }
  57173. get darkness() {
  57174. return this.effect.uniforms.get('darkness').value;
  57175. }
  57176. set darkness(e) {
  57177. this.effect.uniforms.get('darkness').value = e;
  57178. }
  57179. get offset() {
  57180. return this.effect.uniforms.get('offset').value;
  57181. }
  57182. set offset(e) {
  57183. this.effect.uniforms.get('offset').value = e;
  57184. }
  57185. },
  57186. VH = class extends Qs {
  57187. constructor(e) {
  57188. super(SH, e);
  57189. }
  57190. set focalLength(e) {
  57191. this.effect.circleOfConfusionMaterial.uniforms.focalLength.value = e;
  57192. }
  57193. get focalLength() {
  57194. return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value;
  57195. }
  57196. set focusDistance(e) {
  57197. this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value = e;
  57198. }
  57199. get focusDistance() {
  57200. return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value;
  57201. }
  57202. get bokehScale() {
  57203. return this.effect.bokehScale;
  57204. }
  57205. set bokehScale(e) {
  57206. this.effect.bokehScale = e;
  57207. }
  57208. },
  57209. HH = class extends Qs {
  57210. constructor() {
  57211. super(DH);
  57212. }
  57213. get granularity() {
  57214. return this.effect.getGranularity();
  57215. }
  57216. set granularity(e) {
  57217. this.effect.setGranularity(e);
  57218. }
  57219. },
  57220. WH = class extends Tr {
  57221. constructor(e, t, i) {
  57222. super('TransmissionPass', e, t),
  57223. (this.copyPass = new nu(i.transmissionRenderTarget)),
  57224. (this.depthPass = new Zb(e, t, { renderTarget: i.transmissionDepthTarget })),
  57225. (this.needsSwap = !1);
  57226. }
  57227. updatePasses(e) {
  57228. (this.copyPass = new nu(e.transmissionRenderTarget)),
  57229. (this.depthPass = new Zb(this.scene, this.camera, { renderTarget: e.transmissionDepthTarget }));
  57230. }
  57231. setCamera(e) {
  57232. this.camera = e;
  57233. }
  57234. setScene(e) {
  57235. this.scene = e;
  57236. }
  57237. render(e, t, i) {
  57238. let r = this.camera.layers.mask;
  57239. this.copyPass.render(e, t, i),
  57240. this.camera.layers.disable(3),
  57241. this.depthPass.render(e, t, i),
  57242. (e.shadowMap.needsUpdate = !1),
  57243. (e.shadowMap.autoUpdate = !1);
  57244. let s = this.renderToScreen ? null : t;
  57245. this.camera.layers.set(3), e.setRenderTarget(s), e.render(this.scene, this.camera), (this.camera.layers.mask = r);
  57246. }
  57247. },
  57248. ew = new pa(),
  57249. XH = new ri({
  57250. transparent: !0,
  57251. vertexShader: `
  57252. void main() {
  57253. gl_Position = vec4(0.0);
  57254. }
  57255. `,
  57256. fragmentShader: `
  57257. void main() {
  57258. gl_FragColor = vec4(0.0);
  57259. }
  57260. `
  57261. }),
  57262. Rf = class extends Tr {
  57263. constructor(e, t) {
  57264. super('OpaquePass', e ?? ew, t),
  57265. (this.hasTransmissionPass = !1),
  57266. (this.clear = !0),
  57267. (this.needsSwap = !1),
  57268. (this.originalMaterials = new Map());
  57269. }
  57270. setCamera(e) {
  57271. this.camera = e;
  57272. }
  57273. setScene(e) {
  57274. this.scene = e ?? ew;
  57275. }
  57276. getScene() {
  57277. return this.scene;
  57278. }
  57279. render(e, t) {
  57280. this.originalMaterials.clear(),
  57281. this.camera.layers.enable(3),
  57282. this.hasTransmissionPass &&
  57283. this.scene.traverse((r) => {
  57284. r.layers.isEnabled(3) && r instanceof ar && (this.originalMaterials.set(r.id, r.material), (r.material = XH));
  57285. }),
  57286. this.camera.layers.enable(8),
  57287. (e.shadowMap.needsUpdate = !0),
  57288. (e.shadowMap.autoUpdate = !0);
  57289. let i = this.renderToScreen ? null : t;
  57290. e.setRenderTarget(i),
  57291. this.clear && e.clear(),
  57292. e.render(this.scene, this.camera),
  57293. this.hasTransmissionPass &&
  57294. this.originalMaterials.forEach((r, s) => {
  57295. let n = this.scene.getObjectById(s);
  57296. n && (n.material = r);
  57297. });
  57298. }
  57299. };
  57300. function tw(e, t) {
  57301. return t && t.enabled && e.push(t.effect), e;
  57302. }
  57303. var qH = (e) => (Object.values(nt).includes(e) ? e : nt.NORMAL),
  57304. YH = class extends Vi {
  57305. constructor(e) {
  57306. super(),
  57307. (this.postprocessingState = bh.defaultData),
  57308. (this._scene = new pa()),
  57309. (this._camera = new Gi()),
  57310. (this.effects = new Map()),
  57311. (this._renderToScreen = !0),
  57312. (this.clock = new qD()),
  57313. (this.renderer = e),
  57314. (this.debug = !1),
  57315. this.effects.set('bloom', new zH()),
  57316. this.effects.set('chromaticAberration', new UH()),
  57317. this.effects.set('vignette', new GH()),
  57318. this.effects.set('noise', new jH()),
  57319. this.effects.set('colorAverage', new FH()),
  57320. this.effects.set('hueSaturation', new kH()),
  57321. this.effects.set('brightnessContrast', new NH()),
  57322. this.effects.set('depthOfField', new VH()),
  57323. this.effects.set('pixelation', new HH()),
  57324. (this.effectComposer = new pH(this.renderer)),
  57325. (this.opaquePass = new Rf(this.scene, this.camera)),
  57326. (this.transmissionPass = new WH(this.scene, this.camera, this.renderer)),
  57327. (this.helperPass = new Rf(void 0, this.camera)),
  57328. (this.helperPass.hasTransmissionPass = !1),
  57329. (this.helperPass.clear = !1),
  57330. (this.helperClearPass = new Ou(!1, !0, !1)),
  57331. (this.helperPassOnTop = new Rf(void 0, this.camera)),
  57332. (this.helperPassOnTop.hasTransmissionPass = !1),
  57333. (this.helperPassOnTop.clear = !1),
  57334. this._initCopyPass(),
  57335. this._initSmaa(),
  57336. this._initPasses();
  57337. }
  57338. get scene() {
  57339. return this._scene;
  57340. }
  57341. set scene(e) {
  57342. (this._scene = e), this.opaquePass.setScene(e), this.transmissionPass.setScene(e);
  57343. }
  57344. set sceneHelpers(e) {
  57345. this.helperPass.setScene(e);
  57346. }
  57347. get sceneHelpers() {
  57348. return this.helperPass.getScene();
  57349. }
  57350. set sceneHelpersOnTop(e) {
  57351. this.helperPassOnTop.setScene(e);
  57352. }
  57353. get sceneHelpersOnTop() {
  57354. return this.helperPassOnTop.getScene();
  57355. }
  57356. get camera() {
  57357. return this._camera;
  57358. }
  57359. set camera(e) {
  57360. (this._camera = e),
  57361. this.opaquePass.setCamera(e),
  57362. this.transmissionPass.setCamera(e),
  57363. this.helperPass.setCamera(e),
  57364. this.helperPassOnTop.setCamera(e);
  57365. }
  57366. setTransmissionPassEnabled(e) {
  57367. (this.transmissionPass.enabled = e), (this.opaquePass.hasTransmissionPass = e);
  57368. }
  57369. disableHelpers() {
  57370. (this.helperPass.enabled = !1), (this.helperClearPass.enabled = !1), (this.helperPassOnTop.enabled = !1);
  57371. }
  57372. enableHelpers() {
  57373. (this.helperPass.enabled = !0), (this.helperClearPass.enabled = !0), (this.helperPassOnTop.enabled = !0);
  57374. }
  57375. _initSmaa() {
  57376. let e = new IH({ preset: co.ULTRA, edgeDetectionMode: Lv.COLOR }),
  57377. t = () => {
  57378. e.removeEventListener('load', t), this.dispatchEvent({ type: 'smaaloaded' });
  57379. };
  57380. e.addEventListener('load', t),
  57381. (e.edgeDetectionMaterial.predicationMode = c2.DEPTH),
  57382. (e.edgeDetectionMaterial.edgeDetectionThreshold = 0.05),
  57383. (e.edgeDetectionMaterial.predicationThreshold = 0.002),
  57384. (e.edgeDetectionMaterial.predicationScale = 1),
  57385. (this.smaaPass = new Lf(this.camera, e));
  57386. }
  57387. _initPasses() {
  57388. if (
  57389. (this.uvEffectPass?.dispose(),
  57390. this.effectPass?.dispose(),
  57391. this.effectComposer.removeAllPasses(),
  57392. this.transmissionPass.updatePasses(this.renderer),
  57393. this.effectComposer.addPass(this.opaquePass),
  57394. this.effectComposer.addPass(this.transmissionPass),
  57395. this.postprocessingState.enabled)
  57396. ) {
  57397. let e = [this.effects.get('pixelation')].reduce(tw, []);
  57398. e.length > 0 && ((this.uvEffectPass = new Lf(this.camera, ...e)), this.effectComposer.addPass(this.uvEffectPass));
  57399. let t = [
  57400. this.effects.get('chromaticAberration'),
  57401. this.effects.get('bloom'),
  57402. this.effects.get('colorAverage'),
  57403. this.effects.get('hueSaturation'),
  57404. this.effects.get('brightnessContrast'),
  57405. this.effects.get('vignette'),
  57406. this.effects.get('noise')
  57407. ].reduce(tw, []);
  57408. t.length > 0 && ((this.effectPass = new Lf(this.camera, ...t)), this.effectComposer.addPass(this.effectPass));
  57409. }
  57410. this.effectComposer.addPass(this.helperPass),
  57411. this.effectComposer.addPass(this.helperClearPass),
  57412. this.effectComposer.addPass(this.helperPassOnTop),
  57413. this.effectComposer.addPass(this.smaaPass);
  57414. }
  57415. _initCopyPass() {
  57416. if (this._savePass) return;
  57417. let e = new G();
  57418. this.renderer.getDrawingBufferSize(e),
  57419. (this._rt = new ii(e.x, e.y, { depthBuffer: !1, stencilBuffer: !1, wrapS: oh, wrapT: oh })),
  57420. (this._rt.samples = 0),
  57421. (this._savePass = new nu(this._rt, !1)),
  57422. (this._savePass.renderToScreen = !1);
  57423. }
  57424. get renderToScreen() {
  57425. return this._renderToScreen;
  57426. }
  57427. set renderToScreen(e) {
  57428. if (this._renderToScreen === e) return;
  57429. let t = this.effectComposer;
  57430. !t ||
  57431. (e === !0
  57432. ? (t.removePass(this._savePass), (t.passes[t.passes.length - 1].renderToScreen = !0), (t.autoRenderToScreen = !0))
  57433. : ((t.autoRenderToScreen = !1),
  57434. (t.passes[t.passes.length - 1].renderToScreen = !1),
  57435. (this._savePass.renderToScreen = !1),
  57436. this.postprocessingState.enabled || (this._savePass.needsDepthTexture = !0),
  57437. t.addPass(this._savePass)),
  57438. (this._renderToScreen = e));
  57439. }
  57440. get texture() {
  57441. return this._rt && this._rt.texture;
  57442. }
  57443. get renderTarget() {
  57444. return this._rt;
  57445. }
  57446. updatePostprocessing(e) {
  57447. let { enabled: t, ...i } = e,
  57448. r = !1;
  57449. t !== this.postprocessingState.enabled && (r = !0);
  57450. for (let s of Object.entries(i)) {
  57451. let n = s[1],
  57452. a = this.effects.get(s[0]);
  57453. if (a) {
  57454. a.enabled !== n.enabled && (r = !0), (a.enabled = n.enabled);
  57455. for (let [o, l] of Object.entries(n)) o === 'blendFunction' ? (a.blendFunction = qH(l)) : (a[o] = l);
  57456. }
  57457. }
  57458. (this.postprocessingState = e), r && this._initPasses();
  57459. }
  57460. render() {
  57461. this.effectComposer.render(this.clock.getDelta());
  57462. }
  57463. setScissor(e, t, i, r) {
  57464. e instanceof $e
  57465. ? (this.effectComposer.inputBuffer.scissor.set(e.x, e.y, e.z, e.w),
  57466. this.effectComposer.outputBuffer.scissor.set(e.x, e.y, e.z, e.w))
  57467. : (this.effectComposer.inputBuffer.scissor.set(e, t, i, r), this.effectComposer.outputBuffer.scissor.set(e, t, i, r));
  57468. let s = this.renderer.getPixelRatio();
  57469. this.effectComposer.inputBuffer.scissor.multiplyScalar(s),
  57470. this.effectComposer.outputBuffer.scissor.multiplyScalar(s),
  57471. this.renderer.setScissor(e, t, i, r);
  57472. }
  57473. setScissorTest(e) {
  57474. (this.effectComposer.inputBuffer.scissorTest = e),
  57475. (this.effectComposer.outputBuffer.scissorTest = e),
  57476. this.renderer.setScissorTest(e);
  57477. }
  57478. setViewport(e, t, i, r) {
  57479. e instanceof $e
  57480. ? (this.effectComposer.inputBuffer.viewport.copy(e), this.effectComposer.outputBuffer.viewport.copy(e))
  57481. : (this.effectComposer.inputBuffer.viewport.set(e, t, i, r), this.effectComposer.outputBuffer.viewport.set(e, t, i, r));
  57482. }
  57483. resize(e, t, i) {
  57484. if ((this.effectComposer.setSize(e, t, i), this._rt)) {
  57485. let r = this.renderer.getPixelRatio();
  57486. this._rt.setSize(e * r, t * r);
  57487. }
  57488. }
  57489. dispose() {
  57490. this.uvEffectPass?.dispose(), this.effectPass?.dispose(), this.effectComposer.dispose();
  57491. }
  57492. },
  57493. iw = new ci(),
  57494. QH = class extends Sw {
  57495. constructor(e) {
  57496. super(e),
  57497. (this._pixelRatio = this.getPixelRatio()),
  57498. (this.viewportWidth = 1),
  57499. (this.viewportHeight = 1),
  57500. (this.resolution = new G()),
  57501. (this.pipeline = new YH(this)),
  57502. (this.overrideTransmission = e?.overrideTransmission),
  57503. (this.autoClear = !1);
  57504. let t = this.setPixelRatio.bind(this),
  57505. i = this.setSize.bind(this),
  57506. r = this.getContext();
  57507. if (r && 'drawingBufferColorSpace' in r)
  57508. try {
  57509. r.drawingBufferColorSpace = 'display-p3';
  57510. } catch (s) {
  57511. console.warn(s);
  57512. }
  57513. (this.setPixelRatio = (s) => {
  57514. (this._pixelRatio = s), t(s);
  57515. }),
  57516. (this.setSize = (s, n, a = !0) => {
  57517. (this.viewportWidth !== s || this.viewportHeight !== n) &&
  57518. ((this.viewportWidth = s),
  57519. (this.viewportHeight = n),
  57520. i(s, n, a),
  57521. this.normalRenderTarget?.setSize(s * this._pixelRatio, n * this._pixelRatio),
  57522. this.transmissionRenderTarget?.setSize((s * this._pixelRatio) / 2, (n * this._pixelRatio) / 2),
  57523. this.transmissionDepthTarget?.setSize((s * this._pixelRatio) / 2, (n * this._pixelRatio) / 2),
  57524. this.pipeline.resize(s, n, a));
  57525. }),
  57526. (this._superDispose = this.dispose),
  57527. (this.dispose = this._currentDispose);
  57528. }
  57529. createTransmissionRenderTarget() {
  57530. this.transmissionRenderTarget === void 0 &&
  57531. ((this.transmissionRenderTarget = new ii(
  57532. (this.viewportWidth * this._pixelRatio) / 2,
  57533. (this.viewportHeight * this._pixelRatio) / 2,
  57534. { generateMipmaps: !0, minFilter: Bo, magFilter: mt, wrapS: Ji, wrapT: Ji, depthBuffer: !1 }
  57535. )),
  57536. (this.transmissionDepthTarget = new ii((this.viewportWidth * this._pixelRatio) / 2, (this.viewportHeight * this._pixelRatio) / 2, {
  57537. minFilter: Ot,
  57538. magFilter: Ot,
  57539. depthBuffer: !1
  57540. })));
  57541. }
  57542. createNormalRenderTarget() {
  57543. this.normalRenderTarget === void 0 &&
  57544. (this.normalRenderTarget = new ii(this.viewportWidth * this._pixelRatio, this.viewportHeight * this._pixelRatio, {
  57545. generateMipmaps: !1,
  57546. minFilter: Ot,
  57547. magFilter: Ot,
  57548. type: vn,
  57549. depthTexture: new pg(this.viewportWidth * this._pixelRatio, this.viewportHeight * this._pixelRatio)
  57550. }));
  57551. }
  57552. renderNormal(e, t) {
  57553. this.normalRenderTarget &&
  57554. (this.setClearColor(0),
  57555. t.layers.enable(8),
  57556. t.layers.disable(0),
  57557. t.layers.disable(3),
  57558. this.setRenderTarget(this.normalRenderTarget),
  57559. this.clear(),
  57560. t instanceof Gi ? (ff.uniforms.depthContrast.value = (t.far - t.near) / 1e4) : (ff.uniforms.depthContrast.value = 1),
  57561. (e.overrideMaterial = ff),
  57562. this.render(e, t),
  57563. this.setClearColor(e.bgColor, e.bgColor.a),
  57564. this.setRenderTarget(null),
  57565. (e.overrideMaterial = e.wireframeState ? qm : null),
  57566. t.layers.enable(0),
  57567. t.layers.enable(3));
  57568. }
  57569. renderSplineScene(e, t, i, r, s) {
  57570. this.setClearColor(e.bgColor, e.bgColor.a),
  57571. i.penumbraSize.forEach((a, o) => {
  57572. Lt.penumbraSize.value[o] = a;
  57573. }),
  57574. (Lt.pixelRatioNode.value = this.getPixelRatio()),
  57575. this.resolution.x !== 0 && this.resolution.y !== 0
  57576. ? Lt.resolution.value.set(this.resolution.x, this.resolution.y)
  57577. : Lt.resolution.value.set(this.viewportWidth * this._pixelRatio, this.viewportHeight * this._pixelRatio),
  57578. this.overrideNormal !== void 0
  57579. ? ((Lt.normalRenderTarget.value = this.overrideNormal), (Lt.normalRenderTargetDepth.value = iw))
  57580. : e.needsNormal() &&
  57581. (this.createNormalRenderTarget(),
  57582. (Lt.normalRenderTarget.value = this.normalRenderTarget.texture),
  57583. (Lt.normalRenderTargetDepth.value = this.normalRenderTarget.depthTexture),
  57584. this.renderNormal(e, t));
  57585. let n = !1;
  57586. if (this.overrideTransmission !== void 0)
  57587. (Lt.transmissionRenderTarget.value = this.overrideTransmission),
  57588. (Lt.transmissionRenderTargetDepth.value = iw),
  57589. this.pipeline.setTransmissionPassEnabled(!1);
  57590. else {
  57591. let a = e.needsTransmission();
  57592. a &&
  57593. (this.transmissionRenderTarget === void 0 && (n = !0),
  57594. this.createTransmissionRenderTarget(),
  57595. (Lt.transmissionRenderTarget.value = this.transmissionRenderTarget.texture),
  57596. (Lt.transmissionRenderTargetDepth.value = this.transmissionDepthTarget.texture)),
  57597. this.pipeline.setTransmissionPassEnabled(a);
  57598. }
  57599. t.layers.enable(3),
  57600. t.layers.enable(8),
  57601. (this.pipeline.sceneHelpers = r),
  57602. (this.pipeline.sceneHelpersOnTop = s),
  57603. (this.pipeline.scene = e),
  57604. (this.pipeline.camera = t),
  57605. n && this.pipeline.transmissionPass.updatePasses(this),
  57606. this.pipeline.postprocessingState !== e.postprocessing && this.pipeline.updatePostprocessing(e.postprocessing),
  57607. this.clearAlphaOverride !== void 0 && this.setClearAlpha(this.clearAlphaOverride),
  57608. (e.overrideMaterial = e.wireframeState ? qm : null),
  57609. this.pipeline.render();
  57610. }
  57611. _currentDispose() {
  57612. this._superDispose(),
  57613. this.pipeline.dispose(),
  57614. this.transmissionRenderTarget?.dispose(),
  57615. this.transmissionDepthTarget?.dispose(),
  57616. this.normalRenderTarget?.dispose(),
  57617. this.normalRenderTarget?.depthTexture?.dispose();
  57618. }
  57619. },
  57620. ZH = class {
  57621. get sharedAssets() {
  57622. return this.shared;
  57623. }
  57624. constructor(e, t = {}) {
  57625. (this.shared = new Eu(e.shared, t)),
  57626. (this.scene = new sl(e.scene, this.sharedAssets)),
  57627. this.scene.switchActiveCamera(this.scene.activeCamera);
  57628. }
  57629. reset(e, t) {
  57630. this.scene.clearScene(), this.sharedAssets.reset(e.shared), this.scene.resetAfterClear(e.scene, this.sharedAssets);
  57631. }
  57632. dispose() {
  57633. this.scene.dispose(), this.shared.dispose();
  57634. }
  57635. gc() {
  57636. this.shared.geometryCache.startGc(),
  57637. this.shared.geometryCache2.startGc(),
  57638. this.scene.traverseEntity((e) => {
  57639. e instanceof Cr && e.markGeometryAsReachable(this.shared);
  57640. }),
  57641. this.shared.geometryCache.endGc(),
  57642. this.shared.geometryCache2.endGc();
  57643. }
  57644. },
  57645. KH = class {
  57646. constructor({ x: e = 10, y: t = 10 }) {
  57647. this._startTime = 0;
  57648. let i = document.getElementById('spe-perfs');
  57649. i
  57650. ? (this.element = i)
  57651. : ((this.element = document.createElement('div')),
  57652. document.body.appendChild(this.element),
  57653. (this.element.style.position = 'absolute'),
  57654. (this.element.style.zIndex = '10000'),
  57655. (this.element.style.fontFamily = 'monospace'),
  57656. (this.element.style.background = 'black'),
  57657. (this.element.style.color = 'white'),
  57658. (this.element.style.padding = '10px'),
  57659. (this.element.style.opacity = '0.5'),
  57660. (this.element.style.fontSize = '11px'),
  57661. this.element.setAttribute('id', 'spe-perfs')),
  57662. (this.element.style.left = `${e}px`),
  57663. (this.element.style.top = `${t}px`);
  57664. }
  57665. dispose() {
  57666. this.element.parentElement?.removeChild(this.element);
  57667. }
  57668. start() {
  57669. this._startTime = performance.now();
  57670. }
  57671. end() {
  57672. let e = performance.now() - this._startTime;
  57673. this.element.innerHTML = e.toFixed(3) + ' ms';
  57674. }
  57675. };
  57676. function JH(e) {
  57677. let t;
  57678. if (e.index)
  57679. for (let i = 0; i < e.index.array.length; i += 3)
  57680. (t = e.index.array[i]), (e.index.array[i] = e.index.array[i + 2]), (e.index.array[i + 2] = t);
  57681. }
  57682. function ah(e) {
  57683. return e instanceof Sh ? 'SubdivObject' : e.geometry.type === 'NonParametricGeometry' ? 'NonParametric' : 'Mesh';
  57684. }
  57685. function $H(e, t) {
  57686. let i = {};
  57687. return (
  57688. e.traverseEntity((r) => {
  57689. if (!r.visible || !(r instanceof ar) || r.type !== 'Mesh' || Array.isArray(r.material) || (r.states && Object.keys(r.states).length))
  57690. return;
  57691. let s = r.parent;
  57692. for (; s; ) {
  57693. if (s instanceof ar && r.states && Object.keys(r.states).length) return;
  57694. s = s.parent;
  57695. }
  57696. let n = r.material.uuid,
  57697. a = t.shared.materials[n];
  57698. if (a) {
  57699. if (!nr.isMergable(a)) return;
  57700. } else {
  57701. let l = t.scene.objects.get(r.uuid)?.data;
  57702. if (l && 'material' in l && typeof l.material != 'string') {
  57703. if (!nr.isMergable(l.material)) return;
  57704. n = nr.getHash(l.material);
  57705. }
  57706. }
  57707. i[n] || (i[n] = {});
  57708. let o = i[n][ah(r)];
  57709. if (o) {
  57710. if ((o.push(r), r.cloner)) for (let l of r.cloner.children) o.push(l);
  57711. } else if (((i[n][ah(r)] = [r]), r.cloner)) for (let l of r.cloner.children) i[n][ah(r)].push(l);
  57712. }),
  57713. i
  57714. );
  57715. }
  57716. function e9(e) {
  57717. let t = 0;
  57718. return (
  57719. Object.values(e).forEach((i) => {
  57720. Object.values(i).forEach((r) => {
  57721. let s = r.length;
  57722. s > t && (t = s);
  57723. });
  57724. }),
  57725. t
  57726. );
  57727. }
  57728. function t9(e, t) {
  57729. let i = $H(t, e),
  57730. r = e9(i),
  57731. s = new Array(r),
  57732. n = 0,
  57733. a = new Array(r),
  57734. o = 0,
  57735. l = new Array(r),
  57736. h = 0,
  57737. u = new Array(r),
  57738. c = 0;
  57739. for (let [d, p] of Object.entries(i))
  57740. for (let f of Object.values(p)) {
  57741. if (
  57742. ((o = 0),
  57743. (h = 0),
  57744. f.forEach((m) => {
  57745. m instanceof ar && ((a[o++] = m.geometry.clone()), (l[h++] = m));
  57746. }),
  57747. h < 2)
  57748. )
  57749. continue;
  57750. for (let m = 0; m < h; m++)
  57751. l[m].updateWorldMatrix(!0, !1), a[m].applyMatrix4(l[m].matrixWorld), l[m].matrixWorld.determinant() < 0 && JH(a[m]);
  57752. let g = go(a.slice(0, o), !1);
  57753. if (g) {
  57754. let m;
  57755. switch (d) {
  57756. case 'SubdivObject': {
  57757. console.warn('Turning subdiv object into mesh'), (m = new tr(g, l[0].material));
  57758. break;
  57759. }
  57760. default: {
  57761. m = new tr(g, l[0].material);
  57762. break;
  57763. }
  57764. }
  57765. (m.castShadow = l[0].castShadow), (m.receiveShadow = l[0].receiveShadow), t.add(m);
  57766. let v = (y) => {
  57767. c = 0;
  57768. for (let b of y)
  57769. b.children && v(b.children),
  57770. b instanceof ar &&
  57771. (Array.isArray(b.material) ||
  57772. (i[b.material.uuid] && i[b.material.uuid][ah(b)] && i[b.material.uuid][ah(b)].length > 1) ||
  57773. (u[c++] = b));
  57774. for (let b = 0; b < c; b++) t.attach(u[b]);
  57775. };
  57776. for (let y = 0; y < h; y++) {
  57777. let b = l[y];
  57778. v(b.children), (s[n++] = b);
  57779. }
  57780. }
  57781. }
  57782. for (let d = 0; d < n; d++) s[d].removeFromParent();
  57783. }
  57784. var i9 = Eh(q2(), 1),
  57785. r9 = new G();
  57786. function s9(e) {
  57787. let t = 'The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.';
  57788. e.endsWith('.spline')
  57789. ? console.warn(t + ' The .spline files are only meant to be used by the Editor.')
  57790. : e.endsWith('.splinecode') || console.warn(t);
  57791. }
  57792. var Iv = class {
  57793. constructor(e, { renderOnDemand: t = !0 } = {}) {
  57794. (this._viewportMode = 1),
  57795. (this._viewportWidth = window.innerWidth),
  57796. (this._viewportHeight = window.innerHeight),
  57797. (this._proxyObjectCache = new Map()),
  57798. (this._lastTime = performance.now()),
  57799. (this.time = performance.now()),
  57800. (this.dt = 0),
  57801. (this._skipRender = !1),
  57802. (this.renderOnDemand = !0),
  57803. (this.disposed = !1),
  57804. (this.requestRender = () => {
  57805. this._skipRender = !1;
  57806. }),
  57807. (this.render = (i) => {
  57808. !this._renderer ||
  57809. ((this._rafId = requestAnimationFrame(this.render)),
  57810. (this.time = i),
  57811. (this.dt = this.time - this._lastTime),
  57812. (this._lastTime = this.time),
  57813. this._perfs?.start(),
  57814. !(this.renderOnDemand && this._skipRender) &&
  57815. ((this._skipRender = this._controls?.update(this.dt) ?? !0),
  57816. this._eventManager &&
  57817. (this._eventManager.isEnable || this._eventManager.activate(),
  57818. this._eventManager.handlers.Follow.onAnimationFrameDamping(),
  57819. this._eventManager.handlers.LookAt.onAnimationFrameDamping(),
  57820. (this._eventManager.handlers.Start.hasVideoAction ||
  57821. this._eventManager.handlers.Basic.hasVideoAction ||
  57822. this._eventManager.handlers.Conditional.hasVideoAction) &&
  57823. (this._skipRender = !1)),
  57824. this._scene &&
  57825. this._camera &&
  57826. (this._scene.pathConstraints.applyConstraints(this._scene),
  57827. this._renderer.renderSplineScene(this._scene, this._camera, this._sharedAssetsManager)),
  57828. this._perfs?.end()));
  57829. }),
  57830. (this._resize = __(() => {
  57831. !this._renderer ||
  57832. (this._viewportMode === 1 && this._frameView && (this._frameView.frameSize = r9.set(this._viewportWidth, this._viewportHeight)),
  57833. this._renderer.setSize(this._viewportWidth, this._viewportHeight, !1),
  57834. this._camera &&
  57835. (this._frameView?.updateCamera(),
  57836. this._camera.cameraType === 'PerspectiveCamera' && (this._camera.aspect = this._viewportWidth / this._viewportHeight),
  57837. this._camera.updateProjectionMatrix()),
  57838. this.requestRender());
  57839. }, 10)),
  57840. (this.canvas = e),
  57841. (this.renderOnDemand = t),
  57842. window.location.search.includes('perfs') && (this._perfs = new KH({ x: 10, y: 10 })),
  57843. iU(e);
  57844. }
  57845. async load(e, t) {
  57846. s9(e), (this.disposed = !1);
  57847. let i = await (await fetch(e, t)).arrayBuffer();
  57848. await this.start(i);
  57849. }
  57850. async start(e, { interactive: t = !0 } = {}) {
  57851. if (this.disposed) return;
  57852. let i = await fV(e);
  57853. (this._data = i),
  57854. i.version &&
  57855. (0, i9.default)(i.version, '0.9.297') > 0 &&
  57856. console.warn('Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version.'),
  57857. await Promise.all([rb(i) && R6(), Xk(i) && L6(), i.scene.environment.usePhysics && xN(), Jx(i) && Ik()].filter(Boolean)),
  57858. this._eventManager && this._eventManager.deactivate(),
  57859. this._controls && this._controls.dispose(),
  57860. this._scene?.dispose();
  57861. let r = new ZH(i);
  57862. if (
  57863. ((this._scene = r.scene),
  57864. (this._sharedAssetsManager = r.sharedAssets),
  57865. (this._camera = this._scene.activeCamera),
  57866. window.location.search.includes('merge-geometries'))
  57867. ) {
  57868. let s = performance.now();
  57869. t9(i, r.scene);
  57870. let n = performance.now();
  57871. console.log('Merged geometries in ', n - s, ' ms');
  57872. }
  57873. if (
  57874. (rb(i) &&
  57875. this._scene.traverse((s) => {
  57876. Sn(s) && s.recomputeBoolean();
  57877. }),
  57878. this._sharedAssetsManager.setRequestRender(() => {
  57879. this.requestRender(),
  57880. this._scene?.traverse((s) => {
  57881. s instanceof eu && s.pendingMediaLoad && s.update();
  57882. });
  57883. }),
  57884. Jx(i) && HG(i))
  57885. ) {
  57886. let s = Object.keys(i.shared.fonts)
  57887. .map((n) => this._sharedAssetsManager.getFont(n))
  57888. .map((n) => n.loadingPromise);
  57889. await Promise.all(s);
  57890. }
  57891. if (
  57892. (this._scene.rewriteEventsBeforeGoToPlayMode(),
  57893. i2(i.scene, this._scene, this._sharedAssetsManager),
  57894. this._renderer ||
  57895. ((this._renderer = new QH({
  57896. canvas: this.canvas,
  57897. antialias: !1,
  57898. alpha: !0,
  57899. stencil: !1,
  57900. depth: !1,
  57901. powerPreference: 'high-performance'
  57902. })),
  57903. this._renderer.setPixelRatio(window.devicePixelRatio),
  57904. this._renderer.pipeline.addEventListener('smaaloaded', this.requestRender),
  57905. (this._renderer.shadowMap.enabled = !0),
  57906. (this._renderer.shadowMap.type = i.scene.environment.ambientLight.softShadows ? og : sw),
  57907. I8(i.scene.environment.ambientLight.softShadowQuality)),
  57908. this._frameView)
  57909. )
  57910. this._frameView.setCamera(this._camera);
  57911. else {
  57912. let s = Object.values(i.frames)[0];
  57913. s.preset === 'fullscreen'
  57914. ? ((this._viewportMode = 1),
  57915. this.canvas.parentElement &&
  57916. ((this._viewportWidth = this.canvas.parentElement.clientWidth || 300), (this.canvas.style.width = '100%')),
  57917. this.canvas.parentElement &&
  57918. ((this._viewportHeight = this.canvas.parentElement.clientHeight || 150), (this.canvas.style.height = '100%')))
  57919. : ((this._viewportMode = 2),
  57920. (this._viewportWidth = s.size[0]),
  57921. (this._viewportHeight = s.size[1]),
  57922. (this.canvas.style.width = `${this._viewportWidth}px`),
  57923. (this.canvas.style.height = `${this._viewportHeight}px`)),
  57924. this._renderer.setSize(this._viewportWidth, this._viewportHeight, !1),
  57925. (this._frameView = new gV(
  57926. this._renderer,
  57927. this._camera,
  57928. new G(this._viewportWidth, this._viewportHeight),
  57929. new G(window.innerWidth, window.innerHeight)
  57930. ));
  57931. }
  57932. if (
  57933. (t &&
  57934. (this._scene.updateMatrixWorld(!0),
  57935. (this._controls = new WG(i, this._scene, this._renderer, this.requestRender, this._sharedAssetsManager, !0)),
  57936. (this._eventManager = new mV(
  57937. this._renderer,
  57938. this._scene,
  57939. this._camera,
  57940. i.scene.publish.stopRaycast,
  57941. i.scene.publish.preventScroll,
  57942. i.scene.publish.preventTouchScroll,
  57943. i.scene.publish.hideCursor,
  57944. this._sharedAssetsManager,
  57945. this.requestRender,
  57946. this._controls,
  57947. !0
  57948. ))),
  57949. this._resize(),
  57950. !this._resizeObserver && this.canvas.parentElement)
  57951. ) {
  57952. let s = !0;
  57953. (this._resizeObserver = new ResizeObserver(() => {
  57954. if (s) {
  57955. s = !1;
  57956. return;
  57957. }
  57958. (this._viewportWidth = this.canvas.clientWidth), (this._viewportHeight = this.canvas.clientHeight), this._resize();
  57959. })),
  57960. this._resizeObserver.observe(this.canvas.parentElement);
  57961. }
  57962. this._rafId === void 0 ? this.render(performance.now()) : this.requestRender();
  57963. }
  57964. findObjectById(e) {
  57965. let t = this._scene?.getObjectByProperty('uuid', e);
  57966. return this._createProxyObject(t);
  57967. }
  57968. findObjectByName(e) {
  57969. let t = this._scene?.getObjectByName(e);
  57970. return this._createProxyObject(t);
  57971. }
  57972. getSplineEvents() {
  57973. return (this._eventManager?.handlers.Spline).splineEvents;
  57974. }
  57975. emitEvent(e, t) {
  57976. (this.findObjectById(t) || this.findObjectByName(t))?.emitEvent(e);
  57977. }
  57978. emitEventReverse(e, t) {
  57979. (this.findObjectById(t) || this.findObjectByName(t))?.emitEventReverse(e);
  57980. }
  57981. addEventListener(e, t) {
  57982. this.canvas.addEventListener(e, t);
  57983. }
  57984. removeEventListener(e, t) {
  57985. this.canvas.removeEventListener(e, t);
  57986. }
  57987. setZoom(e) {
  57988. this._controls?.orbitControls instanceof l2 && this._controls?.orbitControls.zoomOut(e);
  57989. }
  57990. get eventManager() {
  57991. return this._eventManager;
  57992. }
  57993. get controls() {
  57994. return this._controls;
  57995. }
  57996. setSize(e, t) {
  57997. (this._viewportWidth = e), (this._viewportHeight = t), (this._viewportMode = 2), this._resize();
  57998. }
  57999. setBackgroundColor(e) {
  58000. let { r: t, g: i, b: r, a: s } = { r: 0, g: 0, b: 0, a: 1 },
  58001. n = new ji(t, i, r, s);
  58002. try {
  58003. n.setStyle(e);
  58004. } catch {
  58005. console.error('This is not a valid css color', e);
  58006. }
  58007. this._scene?.setBackgroundColor(n), this.requestRender();
  58008. }
  58009. dispose() {
  58010. (this.disposed = !0),
  58011. this._eventManager?.deactivate(),
  58012. this._scene?.dispose(),
  58013. this._sharedAssetsManager?.dispose(),
  58014. this._rafId && cancelAnimationFrame(this._rafId),
  58015. this._proxyObjectCache.forEach((e) => {
  58016. zy.unsubscribe(e);
  58017. }),
  58018. this._renderer?.dispose(),
  58019. this._sharedAssetsManager?.dispose(),
  58020. this._resizeObserver && (this._resizeObserver.disconnect(), (this._resizeObserver = void 0)),
  58021. (this.canvas.style.width = ''),
  58022. (this.canvas.style.height = ''),
  58023. this.canvas.removeAttribute('width'),
  58024. this.canvas.removeAttribute('height'),
  58025. this._frameView && (this._frameView = void 0),
  58026. this._controls?.dispose(),
  58027. rU(this.canvas);
  58028. }
  58029. get data() {
  58030. return this._data;
  58031. }
  58032. _createProxyObject(e) {
  58033. if (e == null) return;
  58034. if (this._proxyObjectCache.has(e.uuid)) return this._proxyObjectCache.get(e.uuid);
  58035. let t = {
  58036. name: e.name,
  58037. uuid: e.uuid,
  58038. visible: e.visible,
  58039. intensity: e.intensity,
  58040. position: e.position,
  58041. rotation: e.rotation,
  58042. scale: e.scale,
  58043. emitEvent(r) {
  58044. e.dispatchEvent({ type: 'userEvent', eventName: r });
  58045. },
  58046. emitEventReverse(r) {
  58047. e.dispatchEvent({ type: 'userEvent', eventName: r, reverse: !0 });
  58048. }
  58049. },
  58050. i = zy(t, (r, s) => {
  58051. typeof e[r] != 'object' && Object.getOwnPropertyDescriptor(e, r)?.writable && (e[r] = s), this.requestRender(), e.updateMatrix();
  58052. });
  58053. return this._proxyObjectCache.set(e.uuid, i), i;
  58054. }
  58055. };
  58056. var Iu = window,
  58057. Ru =
  58058. Iu.ShadowRoot &&
  58059. (Iu.ShadyCSS === void 0 || Iu.ShadyCSS.nativeShadow) &&
  58060. 'adoptedStyleSheets' in Document.prototype &&
  58061. 'replace' in CSSStyleSheet.prototype,
  58062. Rv = Symbol(),
  58063. p2 = new WeakMap(),
  58064. kh = class {
  58065. constructor(t, i, r) {
  58066. if (((this._$cssResult$ = !0), r !== Rv)) throw Error('CSSResult is not constructable. Use `unsafeCSS` or `css` instead.');
  58067. (this.cssText = t), (this.t = i);
  58068. }
  58069. get styleSheet() {
  58070. let t = this.o,
  58071. i = this.t;
  58072. if (Ru && t === void 0) {
  58073. let r = i !== void 0 && i.length === 1;
  58074. r && (t = p2.get(i)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), r && p2.set(i, t));
  58075. }
  58076. return t;
  58077. }
  58078. toString() {
  58079. return this.cssText;
  58080. }
  58081. },
  58082. f2 = (e) => new kh(typeof e == 'string' ? e : e + '', void 0, Rv),
  58083. Bv = (e, ...t) => {
  58084. let i =
  58085. e.length === 1
  58086. ? e[0]
  58087. : t.reduce(
  58088. (r, s, n) =>
  58089. r +
  58090. ((a) => {
  58091. if (a._$cssResult$ === !0) return a.cssText;
  58092. if (typeof a == 'number') return a;
  58093. throw Error(
  58094. "Value passed to 'css' function must be a 'css' function result: " +
  58095. a +
  58096. ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."
  58097. );
  58098. })(s) +
  58099. e[n + 1],
  58100. e[0]
  58101. );
  58102. return new kh(i, e, Rv);
  58103. },
  58104. zv = (e, t) => {
  58105. Ru
  58106. ? (e.adoptedStyleSheets = t.map((i) => (i instanceof CSSStyleSheet ? i : i.styleSheet)))
  58107. : t.forEach((i) => {
  58108. let r = document.createElement('style'),
  58109. s = Iu.litNonce;
  58110. s !== void 0 && r.setAttribute('nonce', s), (r.textContent = i.cssText), e.appendChild(r);
  58111. });
  58112. },
  58113. Bu = Ru
  58114. ? (e) => e
  58115. : (e) =>
  58116. e instanceof CSSStyleSheet
  58117. ? ((t) => {
  58118. let i = '';
  58119. for (let r of t.cssRules) i += r.cssText;
  58120. return f2(i);
  58121. })(e)
  58122. : e;
  58123. var Nv,
  58124. zu = window,
  58125. m2 = zu.trustedTypes,
  58126. n9 = m2 ? m2.emptyScript : '',
  58127. g2 = zu.reactiveElementPolyfillSupport,
  58128. Fv = {
  58129. toAttribute(e, t) {
  58130. switch (t) {
  58131. case Boolean:
  58132. e = e ? n9 : null;
  58133. break;
  58134. case Object:
  58135. case Array:
  58136. e = e == null ? e : JSON.stringify(e);
  58137. }
  58138. return e;
  58139. },
  58140. fromAttribute(e, t) {
  58141. let i = e;
  58142. switch (t) {
  58143. case Boolean:
  58144. i = e !== null;
  58145. break;
  58146. case Number:
  58147. i = e === null ? null : Number(e);
  58148. break;
  58149. case Object:
  58150. case Array:
  58151. try {
  58152. i = JSON.parse(e);
  58153. } catch {
  58154. i = null;
  58155. }
  58156. }
  58157. return i;
  58158. }
  58159. },
  58160. v2 = (e, t) => t !== e && (t == t || e == e),
  58161. Uv = { attribute: !0, type: String, converter: Fv, reflect: !1, hasChanged: v2 },
  58162. Zs = class extends HTMLElement {
  58163. constructor() {
  58164. super(), (this._$Ei = new Map()), (this.isUpdatePending = !1), (this.hasUpdated = !1), (this._$El = null), this.u();
  58165. }
  58166. static addInitializer(t) {
  58167. var i;
  58168. this.finalize(), ((i = this.h) !== null && i !== void 0 ? i : (this.h = [])).push(t);
  58169. }
  58170. static get observedAttributes() {
  58171. this.finalize();
  58172. let t = [];
  58173. return (
  58174. this.elementProperties.forEach((i, r) => {
  58175. let s = this._$Ep(r, i);
  58176. s !== void 0 && (this._$Ev.set(s, r), t.push(s));
  58177. }),
  58178. t
  58179. );
  58180. }
  58181. static createProperty(t, i = Uv) {
  58182. if (
  58183. (i.state && (i.attribute = !1),
  58184. this.finalize(),
  58185. this.elementProperties.set(t, i),
  58186. !i.noAccessor && !this.prototype.hasOwnProperty(t))
  58187. ) {
  58188. let r = typeof t == 'symbol' ? Symbol() : '__' + t,
  58189. s = this.getPropertyDescriptor(t, r, i);
  58190. s !== void 0 && Object.defineProperty(this.prototype, t, s);
  58191. }
  58192. }
  58193. static getPropertyDescriptor(t, i, r) {
  58194. return {
  58195. get() {
  58196. return this[i];
  58197. },
  58198. set(s) {
  58199. let n = this[t];
  58200. (this[i] = s), this.requestUpdate(t, n, r);
  58201. },
  58202. configurable: !0,
  58203. enumerable: !0
  58204. };
  58205. }
  58206. static getPropertyOptions(t) {
  58207. return this.elementProperties.get(t) || Uv;
  58208. }
  58209. static finalize() {
  58210. if (this.hasOwnProperty('finalized')) return !1;
  58211. this.finalized = !0;
  58212. let t = Object.getPrototypeOf(this);
  58213. if (
  58214. (t.finalize(),
  58215. t.h !== void 0 && (this.h = [...t.h]),
  58216. (this.elementProperties = new Map(t.elementProperties)),
  58217. (this._$Ev = new Map()),
  58218. this.hasOwnProperty('properties'))
  58219. ) {
  58220. let i = this.properties,
  58221. r = [...Object.getOwnPropertyNames(i), ...Object.getOwnPropertySymbols(i)];
  58222. for (let s of r) this.createProperty(s, i[s]);
  58223. }
  58224. return (this.elementStyles = this.finalizeStyles(this.styles)), !0;
  58225. }
  58226. static finalizeStyles(t) {
  58227. let i = [];
  58228. if (Array.isArray(t)) {
  58229. let r = new Set(t.flat(1 / 0).reverse());
  58230. for (let s of r) i.unshift(Bu(s));
  58231. } else t !== void 0 && i.push(Bu(t));
  58232. return i;
  58233. }
  58234. static _$Ep(t, i) {
  58235. let r = i.attribute;
  58236. return r === !1 ? void 0 : typeof r == 'string' ? r : typeof t == 'string' ? t.toLowerCase() : void 0;
  58237. }
  58238. u() {
  58239. var t;
  58240. (this._$E_ = new Promise((i) => (this.enableUpdating = i))),
  58241. (this._$AL = new Map()),
  58242. this._$Eg(),
  58243. this.requestUpdate(),
  58244. (t = this.constructor.h) === null || t === void 0 || t.forEach((i) => i(this));
  58245. }
  58246. addController(t) {
  58247. var i, r;
  58248. ((i = this._$ES) !== null && i !== void 0 ? i : (this._$ES = [])).push(t),
  58249. this.renderRoot !== void 0 && this.isConnected && ((r = t.hostConnected) === null || r === void 0 || r.call(t));
  58250. }
  58251. removeController(t) {
  58252. var i;
  58253. (i = this._$ES) === null || i === void 0 || i.splice(this._$ES.indexOf(t) >>> 0, 1);
  58254. }
  58255. _$Eg() {
  58256. this.constructor.elementProperties.forEach((t, i) => {
  58257. this.hasOwnProperty(i) && (this._$Ei.set(i, this[i]), delete this[i]);
  58258. });
  58259. }
  58260. createRenderRoot() {
  58261. var t;
  58262. let i = (t = this.shadowRoot) !== null && t !== void 0 ? t : this.attachShadow(this.constructor.shadowRootOptions);
  58263. return zv(i, this.constructor.elementStyles), i;
  58264. }
  58265. connectedCallback() {
  58266. var t;
  58267. this.renderRoot === void 0 && (this.renderRoot = this.createRenderRoot()),
  58268. this.enableUpdating(!0),
  58269. (t = this._$ES) === null ||
  58270. t === void 0 ||
  58271. t.forEach((i) => {
  58272. var r;
  58273. return (r = i.hostConnected) === null || r === void 0 ? void 0 : r.call(i);
  58274. });
  58275. }
  58276. enableUpdating(t) {}
  58277. disconnectedCallback() {
  58278. var t;
  58279. (t = this._$ES) === null ||
  58280. t === void 0 ||
  58281. t.forEach((i) => {
  58282. var r;
  58283. return (r = i.hostDisconnected) === null || r === void 0 ? void 0 : r.call(i);
  58284. });
  58285. }
  58286. attributeChangedCallback(t, i, r) {
  58287. this._$AK(t, r);
  58288. }
  58289. _$EO(t, i, r = Uv) {
  58290. var s;
  58291. let n = this.constructor._$Ep(t, r);
  58292. if (n !== void 0 && r.reflect === !0) {
  58293. let a = (((s = r.converter) === null || s === void 0 ? void 0 : s.toAttribute) !== void 0 ? r.converter : Fv).toAttribute(
  58294. i,
  58295. r.type
  58296. );
  58297. (this._$El = t), a == null ? this.removeAttribute(n) : this.setAttribute(n, a), (this._$El = null);
  58298. }
  58299. }
  58300. _$AK(t, i) {
  58301. var r;
  58302. let s = this.constructor,
  58303. n = s._$Ev.get(t);
  58304. if (n !== void 0 && this._$El !== n) {
  58305. let a = s.getPropertyOptions(n),
  58306. o =
  58307. typeof a.converter == 'function'
  58308. ? { fromAttribute: a.converter }
  58309. : ((r = a.converter) === null || r === void 0 ? void 0 : r.fromAttribute) !== void 0
  58310. ? a.converter
  58311. : Fv;
  58312. (this._$El = n), (this[n] = o.fromAttribute(i, a.type)), (this._$El = null);
  58313. }
  58314. }
  58315. requestUpdate(t, i, r) {
  58316. let s = !0;
  58317. t !== void 0 &&
  58318. (((r = r || this.constructor.getPropertyOptions(t)).hasChanged || v2)(this[t], i)
  58319. ? (this._$AL.has(t) || this._$AL.set(t, i),
  58320. r.reflect === !0 && this._$El !== t && (this._$EC === void 0 && (this._$EC = new Map()), this._$EC.set(t, r)))
  58321. : (s = !1)),
  58322. !this.isUpdatePending && s && (this._$E_ = this._$Ej());
  58323. }
  58324. async _$Ej() {
  58325. this.isUpdatePending = !0;
  58326. try {
  58327. await this._$E_;
  58328. } catch (i) {
  58329. Promise.reject(i);
  58330. }
  58331. let t = this.scheduleUpdate();
  58332. return t != null && (await t), !this.isUpdatePending;
  58333. }
  58334. scheduleUpdate() {
  58335. return this.performUpdate();
  58336. }
  58337. performUpdate() {
  58338. var t;
  58339. if (!this.isUpdatePending) return;
  58340. this.hasUpdated, this._$Ei && (this._$Ei.forEach((s, n) => (this[n] = s)), (this._$Ei = void 0));
  58341. let i = !1,
  58342. r = this._$AL;
  58343. try {
  58344. (i = this.shouldUpdate(r)),
  58345. i
  58346. ? (this.willUpdate(r),
  58347. (t = this._$ES) === null ||
  58348. t === void 0 ||
  58349. t.forEach((s) => {
  58350. var n;
  58351. return (n = s.hostUpdate) === null || n === void 0 ? void 0 : n.call(s);
  58352. }),
  58353. this.update(r))
  58354. : this._$Ek();
  58355. } catch (s) {
  58356. throw ((i = !1), this._$Ek(), s);
  58357. }
  58358. i && this._$AE(r);
  58359. }
  58360. willUpdate(t) {}
  58361. _$AE(t) {
  58362. var i;
  58363. (i = this._$ES) === null ||
  58364. i === void 0 ||
  58365. i.forEach((r) => {
  58366. var s;
  58367. return (s = r.hostUpdated) === null || s === void 0 ? void 0 : s.call(r);
  58368. }),
  58369. this.hasUpdated || ((this.hasUpdated = !0), this.firstUpdated(t)),
  58370. this.updated(t);
  58371. }
  58372. _$Ek() {
  58373. (this._$AL = new Map()), (this.isUpdatePending = !1);
  58374. }
  58375. get updateComplete() {
  58376. return this.getUpdateComplete();
  58377. }
  58378. getUpdateComplete() {
  58379. return this._$E_;
  58380. }
  58381. shouldUpdate(t) {
  58382. return !0;
  58383. }
  58384. update(t) {
  58385. this._$EC !== void 0 && (this._$EC.forEach((i, r) => this._$EO(r, this[r], i)), (this._$EC = void 0)), this._$Ek();
  58386. }
  58387. updated(t) {}
  58388. firstUpdated(t) {}
  58389. };
  58390. (Zs.finalized = !0),
  58391. (Zs.elementProperties = new Map()),
  58392. (Zs.elementStyles = []),
  58393. (Zs.shadowRootOptions = { mode: 'open' }),
  58394. g2?.({ ReactiveElement: Zs }),
  58395. ((Nv = zu.reactiveElementVersions) !== null && Nv !== void 0 ? Nv : (zu.reactiveElementVersions = [])).push('1.6.0');
  58396. var kv,
  58397. Nu = window,
  58398. al = Nu.trustedTypes,
  58399. y2 = al ? al.createPolicy('lit-html', { createHTML: (e) => e }) : void 0,
  58400. Un = `lit$${(Math.random() + '').slice(9)}$`,
  58401. M2 = '?' + Un,
  58402. a9 = `<${M2}>`,
  58403. ol = document,
  58404. Gh = (e = '') => ol.createComment(e),
  58405. Vh = (e) => e === null || (typeof e != 'object' && typeof e != 'function'),
  58406. E2 = Array.isArray,
  58407. o9 = (e) => E2(e) || typeof e?.[Symbol.iterator] == 'function',
  58408. jh = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
  58409. x2 = /-->/g,
  58410. b2 = />/g,
  58411. Da = RegExp(
  58412. `>|[
  58413. \f\r](?:([^\\s"'>=/]+)([
  58414. \f\r]*=[
  58415. \f\r]*(?:[^
  58416. \f\r"'\`<>=]|("|')|))|$)`,
  58417. 'g'
  58418. ),
  58419. w2 = /'/g,
  58420. _2 = /"/g,
  58421. C2 = /^(?:script|style|textarea|title)$/i,
  58422. T2 =
  58423. (e) =>
  58424. (t, ...i) => ({ _$litType$: e, strings: t, values: i }),
  58425. P2 = T2(1),
  58426. UK = T2(2),
  58427. La = Symbol.for('lit-noChange'),
  58428. ui = Symbol.for('lit-nothing'),
  58429. A2 = new WeakMap(),
  58430. nl = ol.createTreeWalker(ol, 129, null, !1),
  58431. l9 = (e, t) => {
  58432. let i = e.length - 1,
  58433. r = [],
  58434. s,
  58435. n = t === 2 ? '<svg>' : '',
  58436. a = jh;
  58437. for (let l = 0; l < i; l++) {
  58438. let h = e[l],
  58439. u,
  58440. c,
  58441. d = -1,
  58442. p = 0;
  58443. for (; p < h.length && ((a.lastIndex = p), (c = a.exec(h)), c !== null); )
  58444. (p = a.lastIndex),
  58445. a === jh
  58446. ? c[1] === '!--'
  58447. ? (a = x2)
  58448. : c[1] !== void 0
  58449. ? (a = b2)
  58450. : c[2] !== void 0
  58451. ? (C2.test(c[2]) && (s = RegExp('</' + c[2], 'g')), (a = Da))
  58452. : c[3] !== void 0 && (a = Da)
  58453. : a === Da
  58454. ? c[0] === '>'
  58455. ? ((a = s ?? jh), (d = -1))
  58456. : c[1] === void 0
  58457. ? (d = -2)
  58458. : ((d = a.lastIndex - c[2].length), (u = c[1]), (a = c[3] === void 0 ? Da : c[3] === '"' ? _2 : w2))
  58459. : a === _2 || a === w2
  58460. ? (a = Da)
  58461. : a === x2 || a === b2
  58462. ? (a = jh)
  58463. : ((a = Da), (s = void 0));
  58464. let f = a === Da && e[l + 1].startsWith('/>') ? ' ' : '';
  58465. n +=
  58466. a === jh
  58467. ? h + a9
  58468. : d >= 0
  58469. ? (r.push(u), h.slice(0, d) + '$lit$' + h.slice(d) + Un + f)
  58470. : h + Un + (d === -2 ? (r.push(void 0), l) : f);
  58471. }
  58472. let o = n + (e[i] || '<?>') + (t === 2 ? '</svg>' : '');
  58473. if (!Array.isArray(e) || !e.hasOwnProperty('raw')) throw Error('invalid template strings array');
  58474. return [y2 !== void 0 ? y2.createHTML(o) : o, r];
  58475. },
  58476. Oa = class {
  58477. constructor({ strings: t, _$litType$: i }, r) {
  58478. let s;
  58479. this.parts = [];
  58480. let n = 0,
  58481. a = 0,
  58482. o = t.length - 1,
  58483. l = this.parts,
  58484. [h, u] = l9(t, i);
  58485. if (((this.el = Oa.createElement(h, r)), (nl.currentNode = this.el.content), i === 2)) {
  58486. let c = this.el.content,
  58487. d = c.firstChild;
  58488. d.remove(), c.append(...d.childNodes);
  58489. }
  58490. for (; (s = nl.nextNode()) !== null && l.length < o; ) {
  58491. if (s.nodeType === 1) {
  58492. if (s.hasAttributes()) {
  58493. let c = [];
  58494. for (let d of s.getAttributeNames())
  58495. if (d.endsWith('$lit$') || d.startsWith(Un)) {
  58496. let p = u[a++];
  58497. if ((c.push(d), p !== void 0)) {
  58498. let f = s.getAttribute(p.toLowerCase() + '$lit$').split(Un),
  58499. g = /([.?@])?(.*)/.exec(p);
  58500. l.push({
  58501. type: 1,
  58502. index: n,
  58503. name: g[2],
  58504. strings: f,
  58505. ctor: g[1] === '.' ? Gv : g[1] === '?' ? Vv : g[1] === '@' ? Hv : hl
  58506. });
  58507. } else l.push({ type: 6, index: n });
  58508. }
  58509. for (let d of c) s.removeAttribute(d);
  58510. }
  58511. if (C2.test(s.tagName)) {
  58512. let c = s.textContent.split(Un),
  58513. d = c.length - 1;
  58514. if (d > 0) {
  58515. s.textContent = al ? al.emptyScript : '';
  58516. for (let p = 0; p < d; p++) s.append(c[p], Gh()), nl.nextNode(), l.push({ type: 2, index: ++n });
  58517. s.append(c[d], Gh());
  58518. }
  58519. }
  58520. } else if (s.nodeType === 8)
  58521. if (s.data === M2) l.push({ type: 2, index: n });
  58522. else {
  58523. let c = -1;
  58524. for (; (c = s.data.indexOf(Un, c + 1)) !== -1; ) l.push({ type: 7, index: n }), (c += Un.length - 1);
  58525. }
  58526. n++;
  58527. }
  58528. }
  58529. static createElement(t, i) {
  58530. let r = ol.createElement('template');
  58531. return (r.innerHTML = t), r;
  58532. }
  58533. };
  58534. function ll(e, t, i = e, r) {
  58535. var s, n, a, o;
  58536. if (t === La) return t;
  58537. let l = r !== void 0 ? ((s = i._$Co) === null || s === void 0 ? void 0 : s[r]) : i._$Cl,
  58538. h = Vh(t) ? void 0 : t._$litDirective$;
  58539. return (
  58540. l?.constructor !== h &&
  58541. ((n = l?._$AO) === null || n === void 0 || n.call(l, !1),
  58542. h === void 0 ? (l = void 0) : ((l = new h(e)), l._$AT(e, i, r)),
  58543. r !== void 0 ? (((a = (o = i)._$Co) !== null && a !== void 0 ? a : (o._$Co = []))[r] = l) : (i._$Cl = l)),
  58544. l !== void 0 && (t = ll(e, l._$AS(e, t.values), l, r)),
  58545. t
  58546. );
  58547. }
  58548. var jv = class {
  58549. constructor(t, i) {
  58550. (this.u = []), (this._$AN = void 0), (this._$AD = t), (this._$AM = i);
  58551. }
  58552. get parentNode() {
  58553. return this._$AM.parentNode;
  58554. }
  58555. get _$AU() {
  58556. return this._$AM._$AU;
  58557. }
  58558. v(t) {
  58559. var i;
  58560. let {
  58561. el: { content: r },
  58562. parts: s
  58563. } = this._$AD,
  58564. n = ((i = t?.creationScope) !== null && i !== void 0 ? i : ol).importNode(r, !0);
  58565. nl.currentNode = n;
  58566. let a = nl.nextNode(),
  58567. o = 0,
  58568. l = 0,
  58569. h = s[0];
  58570. for (; h !== void 0; ) {
  58571. if (o === h.index) {
  58572. let u;
  58573. h.type === 2
  58574. ? (u = new Ia(a, a.nextSibling, this, t))
  58575. : h.type === 1
  58576. ? (u = new h.ctor(a, h.name, h.strings, this, t))
  58577. : h.type === 6 && (u = new Wv(a, this, t)),
  58578. this.u.push(u),
  58579. (h = s[++l]);
  58580. }
  58581. o !== h?.index && ((a = nl.nextNode()), o++);
  58582. }
  58583. return n;
  58584. }
  58585. p(t) {
  58586. let i = 0;
  58587. for (let r of this.u) r !== void 0 && (r.strings !== void 0 ? (r._$AI(t, r, i), (i += r.strings.length - 2)) : r._$AI(t[i])), i++;
  58588. }
  58589. },
  58590. Ia = class {
  58591. constructor(t, i, r, s) {
  58592. var n;
  58593. (this.type = 2),
  58594. (this._$AH = ui),
  58595. (this._$AN = void 0),
  58596. (this._$AA = t),
  58597. (this._$AB = i),
  58598. (this._$AM = r),
  58599. (this.options = s),
  58600. (this._$Cm = (n = s?.isConnected) === null || n === void 0 || n);
  58601. }
  58602. get _$AU() {
  58603. var t, i;
  58604. return (i = (t = this._$AM) === null || t === void 0 ? void 0 : t._$AU) !== null && i !== void 0 ? i : this._$Cm;
  58605. }
  58606. get parentNode() {
  58607. let t = this._$AA.parentNode,
  58608. i = this._$AM;
  58609. return i !== void 0 && t.nodeType === 11 && (t = i.parentNode), t;
  58610. }
  58611. get startNode() {
  58612. return this._$AA;
  58613. }
  58614. get endNode() {
  58615. return this._$AB;
  58616. }
  58617. _$AI(t, i = this) {
  58618. (t = ll(this, t, i)),
  58619. Vh(t)
  58620. ? t === ui || t == null || t === ''
  58621. ? (this._$AH !== ui && this._$AR(), (this._$AH = ui))
  58622. : t !== this._$AH && t !== La && this.g(t)
  58623. : t._$litType$ !== void 0
  58624. ? this.$(t)
  58625. : t.nodeType !== void 0
  58626. ? this.T(t)
  58627. : o9(t)
  58628. ? this.k(t)
  58629. : this.g(t);
  58630. }
  58631. O(t, i = this._$AB) {
  58632. return this._$AA.parentNode.insertBefore(t, i);
  58633. }
  58634. T(t) {
  58635. this._$AH !== t && (this._$AR(), (this._$AH = this.O(t)));
  58636. }
  58637. g(t) {
  58638. this._$AH !== ui && Vh(this._$AH) ? (this._$AA.nextSibling.data = t) : this.T(ol.createTextNode(t)), (this._$AH = t);
  58639. }
  58640. $(t) {
  58641. var i;
  58642. let { values: r, _$litType$: s } = t,
  58643. n = typeof s == 'number' ? this._$AC(t) : (s.el === void 0 && (s.el = Oa.createElement(s.h, this.options)), s);
  58644. if (((i = this._$AH) === null || i === void 0 ? void 0 : i._$AD) === n) this._$AH.p(r);
  58645. else {
  58646. let a = new jv(n, this),
  58647. o = a.v(this.options);
  58648. a.p(r), this.T(o), (this._$AH = a);
  58649. }
  58650. }
  58651. _$AC(t) {
  58652. let i = A2.get(t.strings);
  58653. return i === void 0 && A2.set(t.strings, (i = new Oa(t))), i;
  58654. }
  58655. k(t) {
  58656. E2(this._$AH) || ((this._$AH = []), this._$AR());
  58657. let i = this._$AH,
  58658. r,
  58659. s = 0;
  58660. for (let n of t) s === i.length ? i.push((r = new Ia(this.O(Gh()), this.O(Gh()), this, this.options))) : (r = i[s]), r._$AI(n), s++;
  58661. s < i.length && (this._$AR(r && r._$AB.nextSibling, s), (i.length = s));
  58662. }
  58663. _$AR(t = this._$AA.nextSibling, i) {
  58664. var r;
  58665. for ((r = this._$AP) === null || r === void 0 || r.call(this, !1, !0, i); t && t !== this._$AB; ) {
  58666. let s = t.nextSibling;
  58667. t.remove(), (t = s);
  58668. }
  58669. }
  58670. setConnected(t) {
  58671. var i;
  58672. this._$AM === void 0 && ((this._$Cm = t), (i = this._$AP) === null || i === void 0 || i.call(this, t));
  58673. }
  58674. },
  58675. hl = class {
  58676. constructor(t, i, r, s, n) {
  58677. (this.type = 1),
  58678. (this._$AH = ui),
  58679. (this._$AN = void 0),
  58680. (this.element = t),
  58681. (this.name = i),
  58682. (this._$AM = s),
  58683. (this.options = n),
  58684. r.length > 2 || r[0] !== '' || r[1] !== ''
  58685. ? ((this._$AH = Array(r.length - 1).fill(new String())), (this.strings = r))
  58686. : (this._$AH = ui);
  58687. }
  58688. get tagName() {
  58689. return this.element.tagName;
  58690. }
  58691. get _$AU() {
  58692. return this._$AM._$AU;
  58693. }
  58694. _$AI(t, i = this, r, s) {
  58695. let n = this.strings,
  58696. a = !1;
  58697. if (n === void 0) (t = ll(this, t, i, 0)), (a = !Vh(t) || (t !== this._$AH && t !== La)), a && (this._$AH = t);
  58698. else {
  58699. let o = t,
  58700. l,
  58701. h;
  58702. for (t = n[0], l = 0; l < n.length - 1; l++)
  58703. (h = ll(this, o[r + l], i, l)),
  58704. h === La && (h = this._$AH[l]),
  58705. a || (a = !Vh(h) || h !== this._$AH[l]),
  58706. h === ui ? (t = ui) : t !== ui && (t += (h ?? '') + n[l + 1]),
  58707. (this._$AH[l] = h);
  58708. }
  58709. a && !s && this.j(t);
  58710. }
  58711. j(t) {
  58712. t === ui ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? '');
  58713. }
  58714. },
  58715. Gv = class extends hl {
  58716. constructor() {
  58717. super(...arguments), (this.type = 3);
  58718. }
  58719. j(t) {
  58720. this.element[this.name] = t === ui ? void 0 : t;
  58721. }
  58722. },
  58723. h9 = al ? al.emptyScript : '',
  58724. Vv = class extends hl {
  58725. constructor() {
  58726. super(...arguments), (this.type = 4);
  58727. }
  58728. j(t) {
  58729. t && t !== ui ? this.element.setAttribute(this.name, h9) : this.element.removeAttribute(this.name);
  58730. }
  58731. },
  58732. Hv = class extends hl {
  58733. constructor(t, i, r, s, n) {
  58734. super(t, i, r, s, n), (this.type = 5);
  58735. }
  58736. _$AI(t, i = this) {
  58737. var r;
  58738. if ((t = (r = ll(this, t, i, 0)) !== null && r !== void 0 ? r : ui) === La) return;
  58739. let s = this._$AH,
  58740. n = (t === ui && s !== ui) || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive,
  58741. a = t !== ui && (s === ui || n);
  58742. n && this.element.removeEventListener(this.name, this, s), a && this.element.addEventListener(this.name, this, t), (this._$AH = t);
  58743. }
  58744. handleEvent(t) {
  58745. var i, r;
  58746. typeof this._$AH == 'function'
  58747. ? this._$AH.call((r = (i = this.options) === null || i === void 0 ? void 0 : i.host) !== null && r !== void 0 ? r : this.element, t)
  58748. : this._$AH.handleEvent(t);
  58749. }
  58750. },
  58751. Wv = class {
  58752. constructor(t, i, r) {
  58753. (this.element = t), (this.type = 6), (this._$AN = void 0), (this._$AM = i), (this.options = r);
  58754. }
  58755. get _$AU() {
  58756. return this._$AM._$AU;
  58757. }
  58758. _$AI(t) {
  58759. ll(this, t);
  58760. }
  58761. };
  58762. var S2 = Nu.litHtmlPolyfillSupport;
  58763. S2?.(Oa, Ia), ((kv = Nu.litHtmlVersions) !== null && kv !== void 0 ? kv : (Nu.litHtmlVersions = [])).push('2.6.0');
  58764. var Uu = (e, t, i) => {
  58765. var r, s;
  58766. let n = (r = i?.renderBefore) !== null && r !== void 0 ? r : t,
  58767. a = n._$litPart$;
  58768. if (a === void 0) {
  58769. let o = (s = i?.renderBefore) !== null && s !== void 0 ? s : null;
  58770. n._$litPart$ = a = new Ia(t.insertBefore(Gh(), o), o, void 0, i ?? {});
  58771. }
  58772. return a._$AI(e), a;
  58773. };
  58774. var Xv, qv;
  58775. var Fn = class extends Zs {
  58776. constructor() {
  58777. super(...arguments), (this.renderOptions = { host: this }), (this._$Do = void 0);
  58778. }
  58779. createRenderRoot() {
  58780. var t, i;
  58781. let r = super.createRenderRoot();
  58782. return ((t = (i = this.renderOptions).renderBefore) !== null && t !== void 0) || (i.renderBefore = r.firstChild), r;
  58783. }
  58784. update(t) {
  58785. let i = this.render();
  58786. this.hasUpdated || (this.renderOptions.isConnected = this.isConnected),
  58787. super.update(t),
  58788. (this._$Do = Uu(i, this.renderRoot, this.renderOptions));
  58789. }
  58790. connectedCallback() {
  58791. var t;
  58792. super.connectedCallback(), (t = this._$Do) === null || t === void 0 || t.setConnected(!0);
  58793. }
  58794. disconnectedCallback() {
  58795. var t;
  58796. super.disconnectedCallback(), (t = this._$Do) === null || t === void 0 || t.setConnected(!1);
  58797. }
  58798. render() {
  58799. return La;
  58800. }
  58801. };
  58802. (Fn.finalized = !0),
  58803. (Fn._$litElement$ = !0),
  58804. (Xv = globalThis.litElementHydrateSupport) === null || Xv === void 0 || Xv.call(globalThis, { LitElement: Fn });
  58805. var D2 = globalThis.litElementPolyfillSupport;
  58806. D2?.({ LitElement: Fn });
  58807. ((qv = globalThis.litElementVersions) !== null && qv !== void 0 ? qv : (globalThis.litElementVersions = [])).push('3.2.2');
  58808. var L2 = (e) => (t) =>
  58809. typeof t == 'function'
  58810. ? ((i, r) => (customElements.define(i, r), r))(e, t)
  58811. : ((i, r) => {
  58812. let { kind: s, elements: n } = r;
  58813. return {
  58814. kind: s,
  58815. elements: n,
  58816. finisher(a) {
  58817. customElements.define(i, a);
  58818. }
  58819. };
  58820. })(e, t);
  58821. var c9 = (e, t) =>
  58822. t.kind === 'method' && t.descriptor && !('value' in t.descriptor)
  58823. ? {
  58824. ...t,
  58825. finisher(i) {
  58826. i.createProperty(t.key, e);
  58827. }
  58828. }
  58829. : {
  58830. kind: 'field',
  58831. key: Symbol(),
  58832. placement: 'own',
  58833. descriptor: {},
  58834. originalKey: t.key,
  58835. initializer() {
  58836. typeof t.initializer == 'function' && (this[t.key] = t.initializer.call(this));
  58837. },
  58838. finisher(i) {
  58839. i.createProperty(t.key, e);
  58840. }
  58841. };
  58842. function Wr(e) {
  58843. return (t, i) =>
  58844. i !== void 0
  58845. ? ((r, s, n) => {
  58846. s.constructor.createProperty(n, r);
  58847. })(e, t, i)
  58848. : c9(e, t);
  58849. }
  58850. var Yv,
  58851. dJ =
  58852. ((Yv = window.HTMLSlotElement) === null || Yv === void 0 ? void 0 : Yv.prototype.assignedElements) != null
  58853. ? (e, t) => e.assignedElements(t)
  58854. : (e, t) => e.assignedNodes(t).filter((i) => i.nodeType === Node.ELEMENT_NODE);
  58855. var Fu = window.IntersectionObserver != null;
  58856. var d9 = P2` <style>
  58857. :host {
  58858. width: 100%;
  58859. }</style
  58860. ><style>
  58861. :host {
  58862. height: 100%;
  58863. }
  58864. </style>
  58865. <div id="container">
  58866. <canvas id="spline"></canvas>
  58867. <div id="hints">
  58868. <svg
  58869. id="hint-drag"
  58870. width="34"
  58871. height="49"
  58872. viewBox="0 0 34 49"
  58873. fill="none"
  58874. xmlns="http://www.w3.org/2000/svg"
  58875. >
  58876. <g>
  58877. <circle
  58878. cx="11.5"
  58879. cy="11.5"
  58880. r="9"
  58881. fill="white"
  58882. fill-opacity="0.75"
  58883. stroke="black"
  58884. />
  58885. <g>
  58886. <path
  58887. d="M13.5808 28.5807C13.5808 29.1151 14.014 29.5484 14.5485 29.5484C15.083 29.5484 15.5163 29.1151 15.5163 28.5807V24.7097C15.5163 23.6407 16.3828 22.7742 17.4517 22.7742C18.5207 22.7742 19.3872 23.6407 19.3872 24.7097V28.5807C19.3872 29.1152 19.8205 29.5484 20.355 29.5484C20.8894 29.5484 21.3227 29.1152 21.3227 28.5807V26.6452C21.3227 25.5762 22.1893 24.7097 23.2582 24.7097C24.3271 24.7097 25.1937 25.5762 25.1937 26.6452V28.5807C25.1937 29.1152 25.6269 29.5484 26.1614 29.5485C26.6959 29.5485 27.1292 29.1151 27.1292 28.5806C27.1292 27.5117 27.9957 26.6452 29.0646 26.6452C30.1336 26.6452 31.0001 27.5117 31.0001 28.5806L31.0001 38.9677C31.0001 43.386 27.4184 46.9677 23.0001 46.9677L20.1974 46.9677C18.5785 47.1273 5.02742 48.0887 4.87243 35.5722C4.87155 35.5568 4.87109 35.5413 4.87109 35.5256L4.87109 32.4197C4.87109 30.8339 6.15663 29.5484 7.74242 29.5484C7.76004 29.5484 7.77432 29.5627 7.77432 29.5803L7.77432 34.871C7.77432 35.1117 7.94423 35.3548 8.18496 35.3548H8.87384C9.33553 35.3548 9.7098 34.9806 9.7098 34.5189L9.7098 17.9355C9.7098 16.8665 10.5764 16 11.6453 16C12.7142 16 13.5808 16.8665 13.5808 17.9355L13.5808 28.5807Z"
  58888. fill="white"
  58889. />
  58890. <path
  58891. d="M15.0163 24.7097V28.5807C15.0163 28.839 14.8068 29.0484 14.5485 29.0484C14.2902 29.0484 14.0808 28.839 14.0808 28.5807L14.0808 17.9355C14.0808 16.5904 12.9904 15.5 11.6453 15.5C10.3002 15.5 9.2098 16.5904 9.2098 17.9355L9.2098 34.5189C9.2098 34.7044 9.05939 34.8548 8.87384 34.8548H8.27432L8.27432 29.5803C8.27432 29.2865 8.03616 29.0484 7.74242 29.0484C5.88049 29.0484 4.37109 30.5578 4.37109 32.4197L4.37109 35.5256C4.37109 35.5467 4.3716 35.5676 4.3726 35.5884C4.41428 38.8082 5.31931 41.2025 6.71237 42.9656C8.10271 44.7253 9.94976 45.8194 11.8161 46.4937C15.4974 47.824 19.3423 47.5525 20.2217 47.4677L23.0001 47.4677C27.6945 47.4677 31.5001 43.6621 31.5001 38.9677L31.5001 28.5806C31.5001 27.2356 30.4097 26.1452 29.0646 26.1452C27.7196 26.1452 26.6292 27.2356 26.6292 28.5806C26.6292 28.839 26.4197 29.0485 26.1614 29.0485C25.9031 29.0485 25.6937 28.839 25.6937 28.5807V26.6452C25.6937 25.3001 24.6033 24.2097 23.2582 24.2097C21.9131 24.2097 20.8227 25.3001 20.8227 26.6452V28.5807C20.8227 28.839 20.6133 29.0484 20.355 29.0484C20.0966 29.0484 19.8872 28.839 19.8872 28.5807V24.7097C19.8872 23.3646 18.7968 22.2742 17.4517 22.2742C16.1067 22.2742 15.0163 23.3646 15.0163 24.7097Z"
  58892. stroke="black"
  58893. />
  58894. </g>
  58895. </g>
  58896. </svg>
  58897. </div>
  58898. <div id="preloader">
  58899. <svg width="32" height="32" viewBox="0 0 32 32" fill="none" id="spinner">
  58900. <circle
  58901. cx="16"
  58902. cy="16"
  58903. r="15"
  58904. stroke="url(#paint1_linear)"
  58905. strokeOpacity="0.4"
  58906. strokeWidth="2"
  58907. />
  58908. <defs>
  58909. <linearGradient
  58910. id="paint1_linear"
  58911. x1="0"
  58912. y1="16"
  58913. x2="16"
  58914. y2="16"
  58915. gradientUnits="userSpaceOnUse"
  58916. >
  58917. <stop stop-color="currentColor" />
  58918. <stop offset="1" stop-color="currentColor" stop-opacity="0" />
  58919. </linearGradient>
  58920. </defs>
  58921. </svg>
  58922. </div>
  58923. <a
  58924. id="logo"
  58925. href="https://spline.design/?utm_source=spline-viewer&utm_campaign=spline-logo"
  58926. >
  58927. <span></span>
  58928. <svg
  58929. width="89"
  58930. height="13"
  58931. viewBox="0 0 89 13"
  58932. fill="none"
  58933. xmlns="http://www.w3.org/2000/svg"
  58934. >
  58935. <path
  58936. d="M0.966 10V1.276H3.894C4.53 1.276 5.05 1.374 5.454 1.57C5.858 1.766 6.156 2.028 6.348 2.356C6.544 2.68 6.642 3.044 6.642 3.448C6.642 3.972 6.494 4.396 6.198 4.72C5.906 5.04 5.504 5.22 4.992 5.26C5.4 5.288 5.746 5.378 6.03 5.53C6.318 5.678 6.536 5.894 6.684 6.178C6.836 6.462 6.912 6.822 6.912 7.258C6.912 7.882 6.784 8.398 6.528 8.806C6.276 9.21 5.928 9.51 5.484 9.706C5.04 9.902 4.532 10 3.96 10H0.966ZM2.346 8.698H3.678C4.27 8.698 4.708 8.606 4.992 8.422C5.28 8.238 5.424 7.872 5.424 7.324C5.424 6.912 5.346 6.618 5.19 6.442C5.034 6.262 4.824 6.15 4.56 6.106C4.296 6.058 4.002 6.034 3.678 6.034H2.346V8.698ZM2.346 4.882H3.636C4.024 4.882 4.328 4.834 4.548 4.738C4.768 4.638 4.922 4.492 5.01 4.3C5.102 4.108 5.148 3.87 5.148 3.586C5.152 3.206 5.012 2.942 4.728 2.794C4.448 2.642 4.082 2.566 3.63 2.566H2.346V4.882ZM10.2126 10.132C9.64456 10.132 9.18856 9.934 8.84456 9.538C8.50056 9.142 8.32856 8.574 8.32856 7.834V3.448H9.74456V7.456C9.74456 7.776 9.78056 8.04 9.85256 8.248C9.92456 8.456 10.0386 8.608 10.1946 8.704C10.3506 8.8 10.5526 8.848 10.8006 8.848C11.1006 8.848 11.3706 8.762 11.6106 8.59C11.8546 8.414 12.0266 8.216 12.1266 7.996V3.448H13.5426V10H12.3366L12.1746 7.528L12.2826 8.026C12.2346 8.386 12.1386 8.726 11.9946 9.046C11.8546 9.366 11.6406 9.628 11.3526 9.832C11.0686 10.032 10.6886 10.132 10.2126 10.132ZM15.3263 10V3.448H16.7603L16.7423 10H15.3263ZM16.0523 2.482C15.7923 2.482 15.5723 2.392 15.3923 2.212C15.2123 2.028 15.1223 1.794 15.1223 1.51C15.1223 1.23 15.2123 1.002 15.3923 0.826C15.5723 0.65 15.7923 0.562 16.0523 0.562C16.3043 0.562 16.5203 0.65 16.7003 0.826C16.8843 1.002 16.9763 1.23 16.9763 1.51C16.9763 1.794 16.8843 2.028 16.7003 2.212C16.5203 2.392 16.3043 2.482 16.0523 2.482ZM18.549 10V0.663999H19.965V10H18.549ZM23.6579 10.096C23.1379 10.096 22.7319 9.964 22.4399 9.7C22.1519 9.432 22.0079 9.05 22.0079 8.554V5.242C22.0079 5.11 22.0359 4.992 22.0919 4.888C22.1479 4.78 22.2299 4.712 22.3379 4.684L22.0079 3.712V3.538L22.3259 1.576H23.4059V8.2C23.4059 8.432 23.4559 8.594 23.5559 8.686C23.6599 8.778 23.8519 8.824 24.1319 8.824C24.3119 8.824 24.4779 8.824 24.6299 8.824C24.7819 8.82 24.9199 8.816 25.0439 8.812V10.018C24.8359 10.054 24.6079 10.076 24.3599 10.084C24.1119 10.092 23.8779 10.096 23.6579 10.096ZM21.1499 4.684V3.448H25.0559V4.684H21.1499ZM29.7628 10L27.7768 3.454H29.3308L30.1468 6.706L30.5488 8.794L30.6208 8.8L30.9448 6.7L31.7308 3.454H33.5128L34.2868 6.712L34.6048 8.866L34.6948 8.86L35.1028 6.712L35.9188 3.454H37.4668L35.4868 10H33.8308L33.0448 6.88L32.6788 4.984H32.5768L32.1928 6.886L31.4128 10H29.7628ZM38.5295 10V3.448H39.9635L39.9455 10H38.5295ZM39.2555 2.482C38.9955 2.482 38.7755 2.392 38.5955 2.212C38.4155 2.028 38.3255 1.794 38.3255 1.51C38.3255 1.23 38.4155 1.002 38.5955 0.826C38.7755 0.65 38.9955 0.562 39.2555 0.562C39.5075 0.562 39.7235 0.65 39.9035 0.826C40.0875 1.002 40.1795 1.23 40.1795 1.51C40.1795 1.794 40.0875 2.028 39.9035 2.212C39.7235 2.392 39.5075 2.482 39.2555 2.482ZM43.6149 10.096C43.0949 10.096 42.6889 9.964 42.3969 9.7C42.1089 9.432 41.9649 9.05 41.9649 8.554V5.242C41.9649 5.11 41.9929 4.992 42.0489 4.888C42.1049 4.78 42.1869 4.712 42.2949 4.684L41.9649 3.712V3.538L42.2829 1.576H43.3629V8.2C43.3629 8.432 43.4129 8.594 43.5129 8.686C43.6169 8.778 43.8089 8.824 44.0889 8.824C44.2689 8.824 44.4349 8.824 44.5869 8.824C44.7389 8.82 44.8769 8.816 45.0009 8.812V10.018C44.7929 10.054 44.5649 10.076 44.3169 10.084C44.0689 10.092 43.8349 10.096 43.6149 10.096ZM41.1069 4.684V3.448H45.0129V4.684H41.1069ZM46.3339 10V0.663999H47.7379V3.454L47.6419 5.32L47.6959 5.848L47.6239 5.422C47.6719 5.062 47.7639 4.722 47.8999 4.402C48.0399 4.078 48.2499 3.816 48.5299 3.616C48.8139 3.416 49.1939 3.316 49.6699 3.316C50.2899 3.316 50.7679 3.51 51.1039 3.898C51.4439 4.282 51.6139 4.87 51.6139 5.662V10H50.1919V6.154C50.1919 5.598 50.1099 5.2 49.9459 4.96C49.7819 4.72 49.4879 4.6 49.0639 4.6C48.7719 4.6 48.5079 4.698 48.2719 4.894C48.0399 5.086 47.8639 5.3 47.7439 5.536V10H46.3339ZM58.1494 10.12C57.5094 10.12 56.9554 10.018 56.4874 9.814C56.0194 9.61 55.6554 9.304 55.3954 8.896C55.1354 8.484 54.9994 7.968 54.9874 7.348H56.3554C56.3714 7.684 56.4534 7.966 56.6014 8.194C56.7534 8.422 56.9654 8.592 57.2374 8.704C57.5134 8.816 57.8454 8.872 58.2334 8.872C58.6054 8.872 58.9094 8.828 59.1454 8.74C59.3814 8.652 59.5554 8.528 59.6674 8.368C59.7794 8.204 59.8354 8.012 59.8354 7.792C59.8354 7.552 59.7674 7.35 59.6314 7.186C59.4954 7.018 59.2794 6.862 58.9834 6.718C58.6914 6.57 58.3034 6.412 57.8194 6.244C57.3194 6.072 56.8814 5.862 56.5054 5.614C56.1334 5.366 55.8434 5.072 55.6354 4.732C55.4314 4.388 55.3294 3.986 55.3294 3.526C55.3294 2.75 55.5834 2.158 56.0914 1.75C56.5994 1.342 57.2954 1.138 58.1794 1.138C58.7914 1.138 59.2874 1.232 59.6674 1.42C60.0474 1.608 60.3334 1.886 60.5254 2.254C60.7214 2.618 60.8514 3.07 60.9154 3.61H59.5414C59.5054 3.334 59.4314 3.106 59.3194 2.926C59.2074 2.746 59.0534 2.612 58.8574 2.524C58.6654 2.432 58.4234 2.386 58.1314 2.386C57.6794 2.386 57.3314 2.478 57.0874 2.662C56.8434 2.842 56.7214 3.112 56.7214 3.472C56.7214 3.676 56.7594 3.862 56.8354 4.03C56.9154 4.198 57.0774 4.364 57.3214 4.528C57.5694 4.692 57.9414 4.872 58.4374 5.068C58.8214 5.22 59.1814 5.366 59.5174 5.506C59.8574 5.642 60.1554 5.8 60.4114 5.98C60.6714 6.16 60.8754 6.384 61.0234 6.652C61.1714 6.92 61.2474 7.26 61.2514 7.672C61.2594 8.464 60.9994 9.07 60.4714 9.49C59.9474 9.91 59.1734 10.12 58.1494 10.12ZM65.5797 10.072C65.1477 10.072 64.8037 10 64.5477 9.856C64.2917 9.712 64.1037 9.544 63.9837 9.352C63.8637 9.156 63.7877 8.984 63.7557 8.836L63.2757 8.86L63.8337 8.386C63.8617 8.486 63.9237 8.584 64.0197 8.68C64.1157 8.772 64.2557 8.848 64.4397 8.908C64.6237 8.964 64.8497 8.992 65.1177 8.992C65.5657 8.992 65.9337 8.818 66.2217 8.47C66.5137 8.122 66.6597 7.54 66.6597 6.724C66.6597 6.02 66.5237 5.48 66.2517 5.104C65.9797 4.724 65.6317 4.534 65.2077 4.534C64.9077 4.534 64.6597 4.576 64.4637 4.66C64.2717 4.744 64.1257 4.842 64.0257 4.954C63.9257 5.066 63.8617 5.166 63.8337 5.254V4.804C63.8417 4.672 63.8757 4.524 63.9357 4.36C63.9997 4.192 64.1017 4.03 64.2417 3.874C64.3857 3.714 64.5737 3.584 64.8057 3.484C65.0417 3.38 65.3337 3.328 65.6817 3.328C66.2097 3.328 66.6537 3.47 67.0137 3.754C67.3737 4.038 67.6457 4.428 67.8297 4.924C68.0177 5.416 68.1117 5.976 68.1117 6.604C68.1117 7.184 68.0397 7.692 67.8957 8.128C67.7557 8.56 67.5637 8.92 67.3197 9.208C67.0797 9.496 66.8097 9.712 66.5097 9.856C66.2097 10 65.8997 10.072 65.5797 10.072ZM62.4237 12.418V3.448H63.8157L63.8337 4.354V8.44L63.7557 8.836L63.8337 10.006V12.418H62.4237ZM69.4787 10V0.663999H70.8947V10H69.4787ZM72.6896 10V3.448H74.1236L74.1056 10H72.6896ZM73.4156 2.482C73.1556 2.482 72.9356 2.392 72.7556 2.212C72.5756 2.028 72.4856 1.794 72.4856 1.51C72.4856 1.23 72.5756 1.002 72.7556 0.826C72.9356 0.65 73.1556 0.562 73.4156 0.562C73.6676 0.562 73.8836 0.65 74.0636 0.826C74.2476 1.002 74.3396 1.23 74.3396 1.51C74.3396 1.794 74.2476 2.028 74.0636 2.212C73.8836 2.392 73.6676 2.482 73.4156 2.482ZM75.9003 10V3.448H77.1123L77.2683 5.92L77.1663 5.422C77.2143 5.062 77.3083 4.722 77.4483 4.402C77.5923 4.078 77.8063 3.816 78.0903 3.616C78.3743 3.416 78.7543 3.316 79.2303 3.316C79.8503 3.316 80.3303 3.51 80.6703 3.898C81.0103 4.282 81.1803 4.87 81.1803 5.662V10H79.7643V6.154C79.7643 5.778 79.7263 5.476 79.6503 5.248C79.5783 5.02 79.4603 4.856 79.2963 4.756C79.1323 4.652 78.9143 4.6 78.6423 4.6C78.3463 4.6 78.0763 4.688 77.8323 4.864C77.5923 5.036 77.4203 5.232 77.3163 5.452V10H75.9003ZM85.5704 10.09C84.9384 10.09 84.3904 9.962 83.9264 9.706C83.4664 9.446 83.1124 9.064 82.8644 8.56C82.6164 8.056 82.4924 7.438 82.4924 6.706C82.4924 5.994 82.6224 5.386 82.8824 4.882C83.1464 4.374 83.5084 3.988 83.9684 3.724C84.4284 3.456 84.9564 3.322 85.5524 3.322C86.1404 3.322 86.6424 3.438 87.0584 3.67C87.4784 3.902 87.7984 4.246 88.0184 4.702C88.2384 5.154 88.3484 5.71 88.3484 6.37C88.3484 6.498 88.3444 6.604 88.3364 6.688C88.3324 6.772 88.3264 6.872 88.3184 6.988H83.9024C83.9384 7.656 84.1024 8.148 84.3944 8.464C84.6864 8.776 85.0444 8.932 85.4684 8.932C85.8644 8.932 86.1664 8.848 86.3744 8.68C86.5864 8.508 86.7224 8.316 86.7824 8.104H88.1504C88.1144 8.524 87.9824 8.884 87.7544 9.184C87.5264 9.48 87.2244 9.706 86.8484 9.862C86.4764 10.014 86.0504 10.09 85.5704 10.09ZM84.5504 6.022H86.9384C86.9264 5.542 86.8104 5.172 86.5904 4.912C86.3704 4.648 86.0084 4.516 85.5044 4.516C84.9804 4.516 84.5904 4.692 84.3344 5.044C84.0784 5.392 83.9344 5.874 83.9024 6.49C83.9344 6.31 84.0024 6.188 84.1064 6.124C84.2104 6.056 84.3584 6.022 84.5504 6.022Z"
  58937. fill="white"
  58938. />
  58939. </svg>
  58940. </a>
  58941. </div>`,
  58942. Hi = class extends Fn {
  58943. constructor() {
  58944. super();
  58945. this.url = null;
  58946. this.width = void 0;
  58947. this.height = void 0;
  58948. this.background = void 0;
  58949. this.loading = 'auto';
  58950. this.unloadable = !1;
  58951. this.eventsTarget = void 0;
  58952. this.loadingAnim = !1;
  58953. this._intersectionObserver = null;
  58954. this._isElementInViewport = !1;
  58955. this._loaded = !1;
  58956. this._loadedUrl = null;
  58957. this._wasContextLost = !1;
  58958. this._handleContextLost = () => {
  58959. (this._wasContextLost = !0),
  58960. (this._loadedUrl = null),
  58961. this._spline.dispose(),
  58962. this._isElementInViewport && this.load(),
  58963. this.dispatchEvent(new CustomEvent('context-loss', { detail: {} }));
  58964. };
  58965. this._handleContextRestored = () => {};
  58966. this.onLoaded = () => {
  58967. (this._loaded = !0),
  58968. this.eventsTarget !== void 0 && this._spline.eventManager.updateUseWindowEvents(this.eventsTarget === 'global'),
  58969. this.background !== void 0 && this._spline?.setBackgroundColor(this.background),
  58970. this._spline?.data.scene.publish.settings.web.logo !== !1 && (this._logo.style.display = 'flex'),
  58971. this.loadingAnim && (this._preloader.style.display = 'none'),
  58972. setTimeout(() => {
  58973. this._canvas.style.visibility = 'visible';
  58974. }),
  58975. this.dispatchEvent(new CustomEvent('load-complete', { detail: { url: this.url } })),
  58976. (this.hint ?? this._spline.data.scene.publish.settings.web.hint) &&
  58977. (this._canvas.addEventListener('pointerdown', this.onInteract),
  58978. this._canvas.addEventListener('pointerup', this.onInteract),
  58979. (this._hintDrag.style.display = 'block'));
  58980. };
  58981. this.onInteract = () => {
  58982. this._canvas.removeEventListener('pointerdown', this.onInteract),
  58983. this._canvas.removeEventListener('pointerup', this.onInteract),
  58984. (this._hintDrag.style.display = 'none');
  58985. };
  58986. this.attachShadow({ mode: 'open' });
  58987. let i = this.shadowRoot;
  58988. Uu(d9, i),
  58989. (this._container = i.querySelector('#container')),
  58990. (this._canvas = i.querySelector('#spline')),
  58991. (this._logo = i.querySelector('#logo')),
  58992. (this._hintDrag = i.querySelector('#hint-drag')),
  58993. (this._preloader = i.querySelector('#preloader')),
  58994. this._canvas.addEventListener('webglcontextlost', this._handleContextLost),
  58995. this._canvas.addEventListener('webglcontextrestored', this._handleContextRestored),
  58996. (this._spline = new Iv(this._canvas)),
  58997. Fu
  58998. ? (this._intersectionObserver = new IntersectionObserver(
  58999. (r) => {
  59000. for (let s of r)
  59001. s.target === this &&
  59002. ((this._isElementInViewport = s.isIntersecting),
  59003. this._isElementInViewport && (!this._loaded || this._wasContextLost)
  59004. ? this.load()
  59005. : this.unloadable && !this._isElementInViewport && this._loaded && this.unload(),
  59006. this.dispatchEvent(new CustomEvent('viewport-intersection', { detail: { intersection: this._isElementInViewport } })));
  59007. },
  59008. { root: null, rootMargin: '0px', threshold: 1e-5 }
  59009. ))
  59010. : (this._isElementInViewport = !0);
  59011. }
  59012. unload() {
  59013. !this._loaded ||
  59014. ((this._loaded = !1),
  59015. (this._loadedUrl = null),
  59016. this._spline.dispose(),
  59017. this.dispatchEvent(new CustomEvent('unload', { detail: {} })));
  59018. }
  59019. recreateCanvas() {
  59020. let i = this._canvas;
  59021. i.removeEventListener('pointerdown', this.onInteract),
  59022. i.removeEventListener('pointerup', this.onInteract),
  59023. i.removeEventListener('webglcontextlost', this._handleContextLost),
  59024. i.removeEventListener('webglcontextrestored', this._handleContextRestored);
  59025. let r = document.createElement('canvas');
  59026. this._container.insertBefore(r, this._canvas),
  59027. this._container.removeChild(this._canvas),
  59028. r.setAttribute('id', 'spline'),
  59029. (this._canvas = r),
  59030. this._canvas.addEventListener('webglcontextlost', this._handleContextLost),
  59031. this._canvas.addEventListener('webglcontextrestored', this._handleContextRestored),
  59032. (this._spline = new Iv(this._canvas));
  59033. }
  59034. load() {
  59035. (this._loaded && !this._wasContextLost) ||
  59036. (!this._isElementInViewport && this.loading !== 'eager') ||
  59037. !this.url ||
  59038. this.url === this._loadedUrl ||
  59039. (this.loadingAnim && (this._preloader.style.display = 'flex'),
  59040. (this._canvas.style.visibility = 'hidden'),
  59041. this.dispatchEvent(new CustomEvent('load-start', { detail: { url: this.url } })),
  59042. this._wasContextLost && this.recreateCanvas(),
  59043. this._canvas.removeEventListener('pointerdown', this.onInteract),
  59044. this._canvas.removeEventListener('pointerup', this.onInteract),
  59045. (this._hintDrag.style.display = 'none'),
  59046. (this._loadedUrl = this.url),
  59047. this._spline.load(this.url).then(this.onLoaded));
  59048. }
  59049. updated(i) {
  59050. super.updated(i), i.has('url') && (this.url == null && this._loaded ? this.unload() : this.url !== this._loadedUrl && this.load());
  59051. let r = this.shadowRoot?.querySelector('style:nth-child(1)'),
  59052. s = this.shadowRoot?.querySelector('style:nth-child(2)');
  59053. if (
  59054. (i.has('width') && this.width !== void 0 && ((this._container.style.width = this.width + 'px'), r?.remove()),
  59055. i.has('height') && this.height !== void 0 && ((this._container.style.height = this.height + 'px'), s?.remove()),
  59056. i.has('background') && this.background !== void 0 && this._spline?.setBackgroundColor(this.background),
  59057. i.has('eventsTarget') && this.eventsTarget !== void 0)
  59058. ) {
  59059. let n = this.eventsTarget === 'global';
  59060. this._spline?.eventManager?.updateUseWindowEvents(n), this._spline?.controls?.updateUseWindowEvents(n);
  59061. }
  59062. }
  59063. connectedCallback() {
  59064. super.connectedCallback(), Fu && this._intersectionObserver.observe(this);
  59065. }
  59066. disconnectedCallback() {
  59067. Fu && this._intersectionObserver.unobserve(this), super.disconnectedCallback();
  59068. }
  59069. };
  59070. (Hi.styles = Bv`
  59071. :host {
  59072. display: block;
  59073. }
  59074. #container {
  59075. width: 100%;
  59076. height: 100%;
  59077. position: relative;
  59078. }
  59079. #spline {
  59080. display: block;
  59081. }
  59082. #logo {
  59083. display: none;
  59084. position: absolute;
  59085. z-index: 2;
  59086. bottom: 20px;
  59087. right: 20px;
  59088. width: 0px;
  59089. height: 0px;
  59090. flex-direction: row;
  59091. align-items: center;
  59092. justify-content: center;
  59093. gap: 6px;
  59094. border-radius: 12px;
  59095. background: linear-gradient(180deg, #16181c 0%, #121316 100%);
  59096. box-shadow: inset 0px -2px 0px -1px #060709,
  59097. inset 0px 1px 0px rgba(255, 255, 255, 0.04);
  59098. }
  59099. #logo span {
  59100. display: block;
  59101. width: 20px;
  59102. height: 20px;
  59103. background-size: cover;
  59104. }
  59105. #logo svg {
  59106. display: block;
  59107. margin-right: 2px;
  59108. }
  59109. #logo:hover {
  59110. background: linear-gradient(180deg, #1b1c21 0%, #17181c 100%);
  59111. }
  59112. #hints {
  59113. position: absolute;
  59114. top: 0;
  59115. left: 0;
  59116. width: 100%;
  59117. height: 100%;
  59118. display: flex;
  59119. align-items: center;
  59120. justify-content: center;
  59121. pointer-events: none;
  59122. }
  59123. #hint-drag {
  59124. animation-duration: 4s;
  59125. animation-name: slidein;
  59126. animation-iteration-count: infinite;
  59127. animation-timing-function: ease-in-out;
  59128. display: none;
  59129. }
  59130. @keyframes slidein {
  59131. from {
  59132. transform: translateX(0px);
  59133. opacity: 0;
  59134. }
  59135. 50% {
  59136. opacity: 0;
  59137. transform: translateX(0px);
  59138. }
  59139. 60% {
  59140. opacity: 1;
  59141. }
  59142. 65% {
  59143. transform: translateX(-30px);
  59144. }
  59145. 85% {
  59146. transform: translateX(30px);
  59147. }
  59148. 90% {
  59149. opacity: 1;
  59150. }
  59151. to {
  59152. opacity: 0;
  59153. transform: translateX(0px);
  59154. }
  59155. }
  59156. #preloader {
  59157. position: absolute;
  59158. display: none;
  59159. top: 0;
  59160. left: 0;
  59161. align-items: center;
  59162. justify-content: center;
  59163. width: 100%;
  59164. height: 100%;
  59165. }
  59166. @keyframes spin {
  59167. 0% {
  59168. transform: rotate(0deg);
  59169. }
  59170. 100% {
  59171. transform: rotate(360deg);
  59172. }
  59173. }
  59174. #spinner {
  59175. color: rgba(0, 0, 0, 0.5);
  59176. animation: spin 1s infinite linear;
  59177. }
  59178. `),
  59179. Pr([Wr({ type: String })], Hi.prototype, 'url', 2),
  59180. Pr([Wr({ type: Number })], Hi.prototype, 'width', 2),
  59181. Pr([Wr({ type: Number })], Hi.prototype, 'height', 2),
  59182. Pr([Wr({ type: String })], Hi.prototype, 'background', 2),
  59183. Pr([Wr({ type: String })], Hi.prototype, 'loading', 2),
  59184. Pr([Wr({ type: Boolean })], Hi.prototype, 'unloadable', 2),
  59185. Pr([Wr({ type: String, attribute: 'events-target' })], Hi.prototype, 'eventsTarget', 2),
  59186. Pr([Wr({ type: Boolean })], Hi.prototype, 'hint', 2),
  59187. Pr([Wr({ type: Boolean, attribute: 'loading-anim' })], Hi.prototype, 'loadingAnim', 2),
  59188. (Hi = Pr([L2('spline-viewer')], Hi));
  59189. export { Hi as SplineViewer };